From owner-freebsd-bugs@freebsd.org Thu Jul 16 08:11:44 2015 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C930A9A353E for ; Thu, 16 Jul 2015 08:11:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AADF61D56 for ; Thu, 16 Jul 2015 08:11:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id t6G8Bi7O035079 for ; Thu, 16 Jul 2015 08:11:44 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 201611] [patch] Add devfs_get_cdevpriv_from_file(9) Date: Thu, 16 Jul 2015 08:11:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: patch X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: aritger@nvidia.com X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status keywords bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2015 08:11:45 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201611 Bug ID: 201611 Summary: [patch] Add devfs_get_cdevpriv_from_file(9) Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: New Keywords: patch Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: aritger@nvidia.com Keywords: patch Created attachment 158831 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=158831&action=edit patch to implement devfs_get_cdevpriv_from_file(9) In the NVIDIA GPU driver stack for FreeBSD, we have a variety of cases where one user-space driver component calls our kernel-space driver component to allocate an object (e.g., a block of video memory) and then needs to share the object with another user-space driver component. We would like to share these objects between user-space driver components by passing a file descriptor over a UNIX domain socket. E.g., Process A: - alloc video memory - fd = open("/dev/nvidiactl"); - call kernel driver to associate video memory with fd - pass fd to process B - close fd Process B: - receive fd from process A - call kernel driver to retrieve video memory assocated with fd - close fd But to do this, we would like to be able to map from a file descriptor to the per-open file descriptor data (registered with devfs_set_cdevpriv(9) and normally retrieved using devfs_get_cdevpriv(9)). If I understand correctly, this can be done with (pseudo-code): struct file *fp; struct cdev_privdata *p; struct driver_per_open *popen; fget(curthread, fd, &fp); p = fp->f_cdevpriv; popen = p->cdpd_data; /* use popen... */ fdrop(fp, curthread); However, it looks like struct cdev_privdata is not intended to be accessed by drivers. Would it be reasonable to extend the devfs_cdevpriv(9) family of functions with a function that can retrieve the driver specific data, given a struct file? That way, drivers could do: struct file *fp; struct driver_per_open *popen; fget(curthread, fd, &fp); devfs_get_cdevpriv_from_file(&popen, fp); /* use popen... */ fdrop(fp, curthread); The attached patch implements devfs_get_cdevpriv_from_file(). -- You are receiving this mail because: You are the assignee for the bug.