lkml.org 
[lkml]   [2021]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC 07/20] iommu/iommufd: Add iommufd_[un]bind_device()
    On Wed, Sep 29, 2021 at 09:24:57AM -0300, Jason Gunthorpe wrote:
    65;6402;1c> On Wed, Sep 29, 2021 at 03:25:54PM +1000, David Gibson wrote:
    >
    > > > +struct iommufd_device {
    > > > + unsigned int id;
    > > > + struct iommufd_ctx *ictx;
    > > > + struct device *dev; /* always be the physical device */
    > > > + u64 dev_cookie;
    > >
    > > Why do you need both an 'id' and a 'dev_cookie'? Since they're both
    > > unique, couldn't you just use the cookie directly as the index into
    > > the xarray?
    >
    > ID is the kernel value in the xarray - xarray is much more efficient &
    > safe with small kernel controlled values.
    >
    > dev_cookie is a user assigned value that may not be unique. It's
    > purpose is to allow userspace to receive and event and go back to its
    > structure. Most likely userspace will store a pointer here, but it is
    > also possible userspace could not use it.
    >
    > It is a pretty normal pattern

    Hm, ok. Could you point me at an example?

    --
    David Gibson | I'll have my music baroque, and my code
    david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
    | _way_ _around_!
    http://www.ozlabs.org/~dgibson
    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2021-09-30 06:20    [W:5.092 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site