From: Jason Gunthorpe <jgg@nvidia.com>
To: Tony Krowiak <akrowiak@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, Halil Pasic <pasic@linux.ibm.com>,
Pierre Morel <pmorel@linux.ibm.com>,
"Raj, Ashok" <ashok.raj@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Daniel Vetter <daniel@ffwll.ch>, Christoph Hellwig <hch@lst.de>,
Leon Romanovsky <leonro@nvidia.com>,
Max Gurtovoy <mgurtovoy@nvidia.com>,
Tarun Gupta <targupta@nvidia.com>
Subject: Re: [PATCH v2 06/13] vfio/ap_ops: Convert to use vfio_register_group_dev()
Date: Tue, 4 May 2021 13:55:40 -0300 [thread overview]
Message-ID: <20210504165540.GY1370958@nvidia.com> (raw)
In-Reply-To: <80caaa31-3918-c96d-d7ff-727ddd1a4d1e@linux.ibm.com>
On Tue, May 04, 2021 at 10:42:04AM -0400, Tony Krowiak wrote:
>
>
> On 4/26/21 4:00 PM, Jason Gunthorpe wrote:
> > This is straightforward conversion, the ap_matrix_mdev is actually serving
> > as the vfio_device and we can replace all the mdev_get_drvdata()'s with a
> > simple container_of().
>
> This is a nit, but most of the mdev_get_drvdata()'s are not being
> replaced by container_of(); in most places, the replacement is
> dev_get_drvdata().
Hum, only sysfs uses dev_get_drvdata(), but OK but numbers there are
more of them.
> > vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->matrix);
> > - mdev_set_drvdata(mdev, matrix_mdev);
> > matrix_mdev->pqap_hook.hook = handle_pqap;
> > matrix_mdev->pqap_hook.owner = THIS_MODULE;
> > mutex_lock(&matrix_dev->lock);
> > list_add(&matrix_mdev->node, &matrix_dev->mdev_list);
> > mutex_unlock(&matrix_dev->lock);
> > + ret = vfio_register_group_dev(&matrix_mdev->vdev);
> > + if (ret)
> > + goto err_list;
> > + dev_set_drvdata(&mdev->dev, matrix_mdev);
>
> I'm wondering whether the code above should be done under
> the matrix_dev->lock. Does the mdev exist in the sysfs at the
> point the probe is called? If so, then is it possible for functions
> that acquire the matrix_mdev from the drvdata to get called before
> the drvdata is set?
The sysfs is inserted by
vfio_ap_matrix_driver.driver.dev_groups = vfio_ap_mdev_attr_groups
And if you look in really_probe() you can see the order is:
ret = drv->probe(dev);
if (device_add_groups(dev, drv->dev_groups)) {
Any access to drvdata has to be protected by the device_lock or inside
one of these special ordered regions like a driver core created sysfs
callback.
Thanks,
Jason
next prev parent reply other threads:[~2021-05-04 16:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-26 20:00 [PATCH v2 00/13] Remove vfio_mdev.c, mdev_parent_ops and more Jason Gunthorpe
2021-04-26 20:00 ` [PATCH v2 01/13] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
2021-04-27 11:05 ` Cornelia Huck
2021-04-26 20:00 ` [PATCH v2 06/13] vfio/ap_ops: Convert to use vfio_register_group_dev() Jason Gunthorpe
2021-05-04 14:42 ` Tony Krowiak
2021-05-04 16:55 ` Jason Gunthorpe [this message]
2021-04-26 20:00 ` [PATCH v2 07/13] vfio/ccw: " Jason Gunthorpe
2021-04-27 20:06 ` Eric Farman
2021-04-27 22:10 ` Jason Gunthorpe
2021-04-28 12:55 ` Eric Farman
2021-04-28 13:21 ` Jason Gunthorpe
2021-04-28 17:09 ` Cornelia Huck
2021-04-28 17:20 ` Jason Gunthorpe
2021-04-29 11:58 ` Cornelia Huck
2021-04-29 18:13 ` Jason Gunthorpe
2021-04-30 12:31 ` Cornelia Huck
2021-04-30 17:19 ` Jason Gunthorpe
2021-05-03 10:54 ` s390 common I/O layer locking (was: [PATCH v2 07/13] vfio/ccw: Convert to use vfio_register_group_dev()) Cornelia Huck
2021-05-04 15:10 ` s390 common I/O layer locking Vineeth Vijayan
2021-07-24 13:24 ` Christoph Hellwig
2021-08-03 14:27 ` Vineeth Vijayan
2021-08-10 15:00 ` Cornelia Huck
2021-04-26 20:00 ` [PATCH v2 11/13] vfio/mdev: Remove mdev_parent_ops Jason Gunthorpe
2021-04-27 21:30 ` [PATCH v2 00/13] Remove vfio_mdev.c, mdev_parent_ops and more Alex Williamson
2021-04-27 22:20 ` Jason Gunthorpe
2021-04-27 22:49 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210504165540.GY1370958@nvidia.com \
--to=jgg@nvidia.com \
--cc=akrowiak@linux.ibm.com \
--cc=ashok.raj@intel.com \
--cc=borntraeger@de.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@lst.de \
--cc=leonro@nvidia.com \
--cc=linux-s390@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=targupta@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox