All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Will Deacon <will@kernel.org>, Kevin Tian <kevin.tian@intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Subject: Re: [PATCH v2 03/10] iommu: Inline iommu_group_get_for_dev() into __iommu_probe_device()
Date: Fri, 2 Jun 2023 14:17:54 -0300	[thread overview]
Message-ID: <ZHokQkog30XkravM@nvidia.com> (raw)
In-Reply-To: <6676d850-f633-bacd-445b-44cf045a699c@linux.intel.com>

On Sun, May 21, 2023 at 04:19:34PM +0800, Baolu Lu wrote:
> On 5/20/23 2:42 AM, Jason Gunthorpe wrote:
> > This is the only caller, and it doesn't need the generality of the
> > function. We already know there is no iommu_group, so it is simply two
> > function calls.
> > 
> > Moving it here allows the following patches to split the logic in these
> > functions.
> > 
> > Reviewed-by: Kevin Tian<kevin.tian@intel.com>
> > Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
> > ---
> >   drivers/iommu/iommu.c | 50 ++++++++-----------------------------------
> >   1 file changed, 9 insertions(+), 41 deletions(-)
> > 
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index 35dadcc9999f8b..6177e01ced67ab 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -127,7 +127,6 @@ static int iommu_setup_default_domain(struct iommu_group *group,
> >   				      int target_type);
> >   static int iommu_create_device_direct_mappings(struct iommu_domain *domain,
> >   					       struct device *dev);
> > -static struct iommu_group *iommu_group_get_for_dev(struct device *dev);
> >   static ssize_t iommu_group_store_type(struct iommu_group *group,
> >   				      const char *buf, size_t count);
> > @@ -379,12 +378,18 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
> >   	if (ops->is_attach_deferred)
> >   		dev->iommu->attach_deferred = ops->is_attach_deferred(dev);
> > -	group = iommu_group_get_for_dev(dev);
> > +	group = ops->device_group(dev);
> > +	if (WARN_ON_ONCE(group == NULL))
> > +		group = ERR_PTR(-EINVAL);
> >   	if (IS_ERR(group)) {
> >   		ret = PTR_ERR(group);
> >   		goto out_release;
> >   	}
> > +	ret = iommu_group_add_device(group, dev);
> > +	if (ret)
> > +		goto err_put_group;
> > +
> >   	mutex_lock(&group->mutex);
> >   	if (group_list && !group->default_domain && list_empty(&group->entry))
> >   		list_add_tail(&group->entry, group_list);
> > @@ -396,6 +401,8 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
> >   	return 0;
> > +err_put_group:
> 
> nit: perhaps out_put_group?

err_ is the right label, this is not a success path.. Most of the
labels are err_ except for out_unlock which is sometimes a success and
out_module_put which has always been mislabeled..

Jason

  reply	other threads:[~2023-06-02 17:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 18:42 [PATCH v2 00/10] Consolidate the probe_device path Jason Gunthorpe
2023-05-19 18:42 ` [PATCH v2 01/10] iommu: Have __iommu_probe_device() check for already probed devices Jason Gunthorpe
2023-05-21  8:17   ` Baolu Lu
2023-05-22 12:18   ` Rafael J. Wysocki
2023-05-19 18:42 ` [PATCH v2 02/10] iommu: Use iommu_group_ref_get/put() for dev->iommu_group Jason Gunthorpe
2023-05-21  8:18   ` Baolu Lu
2023-05-19 18:42 ` [PATCH v2 03/10] iommu: Inline iommu_group_get_for_dev() into __iommu_probe_device() Jason Gunthorpe
2023-05-21  8:19   ` Baolu Lu
2023-06-02 17:17     ` Jason Gunthorpe [this message]
2023-05-19 18:42 ` [PATCH v2 04/10] iommu: Simplify the __iommu_group_remove_device() flow Jason Gunthorpe
2023-05-21  9:08   ` Baolu Lu
2023-05-22  8:35   ` Niklas Schnelle
2023-05-29 19:33     ` Jason Gunthorpe
2023-05-19 18:42 ` [PATCH v2 05/10] iommu: Add iommu_init/deinit_device() paired functions Jason Gunthorpe
2023-05-21 11:09   ` Baolu Lu
2023-05-21 11:31   ` Baolu Lu
2023-05-22  2:31     ` Baolu Lu
2023-06-02 17:20     ` Jason Gunthorpe
2023-05-19 18:42 ` [PATCH v2 06/10] iommu: Move the iommu driver sysfs setup into iommu_init/deinit_device() Jason Gunthorpe
2023-05-22  0:51   ` Baolu Lu
2023-05-19 18:42 ` [PATCH v2 07/10] iommu: Do not export iommu_device_link/unlink() Jason Gunthorpe
2023-05-22  0:52   ` Baolu Lu
2023-05-19 18:42 ` [PATCH v2 08/10] iommu: Always destroy the iommu_group during iommu_release_device() Jason Gunthorpe
2023-05-22  1:43   ` Baolu Lu
2023-05-19 18:42 ` [PATCH v2 09/10] iommu: Split iommu_group_add_device() Jason Gunthorpe
2023-05-22  2:34   ` Baolu Lu
2023-05-25  5:37   ` Tian, Kevin
2023-05-19 18:42 ` [PATCH v2 10/10] iommu: Avoid locking/unlocking for iommu_probe_device() Jason Gunthorpe
2023-05-22  2:39   ` Baolu Lu
2023-05-25  5:37   ` Tian, Kevin

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=ZHokQkog30XkravM@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=rafael@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.