Date: Thu, 16 Jul 2015 08:11:44 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 201611] [patch] Add devfs_get_cdevpriv_from_file(9) Message-ID: <bug-201611-8@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-201611-8>