[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB5276C1C35BB1E22D68C3E2A08C829@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Fri, 8 Jul 2022 05:52:32 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Robin Murphy <robin.murphy@....com>,
"joro@...tes.org" <joro@...tes.org>
CC: "will@...nel.org" <will@...nel.org>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>,
"suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
"vasant.hegde@....com" <vasant.hegde@....com>,
"mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
"gerald.schaefer@...ux.ibm.com" <gerald.schaefer@...ux.ibm.com>,
"schnelle@...ux.ibm.com" <schnelle@...ux.ibm.com>,
"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v3 04/15] iommu: Move bus setup to IOMMU device
registration
> From: Robin Murphy <robin.murphy@....com>
> Sent: Thursday, July 7, 2022 6:58 PM
>
> On 2022-07-07 07:51, Tian, Kevin wrote:
> >> From: Robin Murphy <robin.murphy@....com>
> >> Sent: Wednesday, July 6, 2022 1:08 AM
> >>
> >> @@ -202,12 +210,32 @@ int iommu_device_register(struct
> iommu_device
> >> *iommu,
> >> spin_lock(&iommu_device_lock);
> >> list_add_tail(&iommu->list, &iommu_device_list);
> >> spin_unlock(&iommu_device_lock);
> >> +
> >> + for (int i = 0; i < ARRAY_SIZE(iommu_buses); i++) {
> >> + struct bus_type *bus = iommu_buses[i];
> >> + int err;
> >> +
> >> + if (bus->iommu_ops && bus->iommu_ops != ops) {
> >> + err = -EBUSY;
> >> + } else {
> >> + bus->iommu_ops = ops;
> >> + err = bus_iommu_probe(bus);
> >> + }
> >> + if (err) {
> >> + iommu_device_unregister(iommu);
> >> + return err;
> >> + }
> >> + }
> >> +
> >
> > Probably move above into a new function bus_iommu_probe_all():
> >
> > /* probe all buses for devices associated with this iommu */
> > err = bus_iommu_probe_all();
> > if (err) {
> > iommu_device_unregister(iommu);
> > return err;
> > }
> >
> > Just my personal preference on leaving logic in iommu_device_register()
> > more relevant to the iommu instance itself.
>
> On reflection I think it makes sense to pull the
> iommu_device_unregister() out of the loop anyway - I think that's really
> a left-over from between v1 and v2 when that error case briefly jumped
> to another cleanup loop, before I realised it was actually trivial for
> iommu_device_unregister() to clean up for itself.
>
> However I now see I've also missed another opportunity, and the -EBUSY
> case should be hoisted out of the loop as well, since checking
> iommu_buses[0] is sufficient. Then it's hopefully much clearer that once
> the bus ops go away we'll be left with just a single extra line for the
> loop, as in iommu_device_unregister(). Does that sound reasonable?
>
Yes, sounds good to me.
Powered by blists - more mailing lists