From: Jason Gunthorpe <jgg@ziepe.ca>
To: Robin Murphy <robin.murphy@arm.com>
Cc: joro@8bytes.org, kevin.tian@intel.com, will@kernel.org,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] iommufd/selftest: Use a fwnode to distinguish devices
Date: Tue, 28 Nov 2023 15:07:58 -0400 [thread overview]
Message-ID: <20231128190758.GA1312390@ziepe.ca> (raw)
In-Reply-To: <a9674ad7-e773-495b-abc3-dae1f74a7694@arm.com>
On Tue, Nov 28, 2023 at 05:36:33PM +0000, Robin Murphy wrote:
> You see this is exactly the kind of complexity I *don't* want, since the
> only thing it would foreseeably benefit is the one special case of the
> IOMMUFD selftest, which can far more trivially just adopt the other of the
> two "standard" usage models we have. I've been trying to get *away* from
> having to have boilerplate checks in all the drivers, and this would require
> bringing back a load of the ones I've just removed :(
I don't think we need to bring back the fwspec checks you removed, the
loop just needs to keep the NULL check:
+ list_for_each_entry(iommu, &iommu_device_list, list) {
+ if (iommu->ops != ops && !iommu->fwnode) {
+ ops = iommu->ops;
+ ret = iommu_init_device(pinf, iommu->ops);
+ if (ret != -ENODEV)
+ return ret;
+ }
+ }
Iterate over all the global driver ops only. Drivers with a fwnode
will never be called without a fwspec.
Also, does omap have problems now too? omap seems to set fwnode but
does some slightly different open coded non-fwspec parsing that worked
at bus time? Is it still OK? Does fwspec even find ops in omap's FW
description (ie it looks like it make iommu-cells optional or
something)?
> As I said before, I really want to avoid the perf_event_init model of
> calling round every driver saying "hey, do you want this?" since it's also
> error-prone if any of those drivers doesn't get the boilerplate exactly
> right and inadvertently fails to reject something it should have.
The core missed an API that every driver needs: give me the struct
iommu_driver* the FW has referenced.
Instead every driver open codes something like
arm_smmu_get_by_fwnode(), or much worse.
If we force the drivers to say
iommu_driver = iommu_fw_give_me_my_driver(dev, ops)
Then we automatically have a place to do all the rejection checks we
need, and driver's can't inadvertently skip this because they really
can't work without the iommu_driver at all.
Anyhow, I completed the series I talked about yesterday. It turned out
really nice I think, especially the driver facing API is much
cleaner. I'm just going through the last bits before I share it.
Jason
next prev parent reply other threads:[~2023-11-28 19:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 10:42 [PATCH 0/2] iommufd/selftest: Fix and cleanup for bus ops Robin Murphy
2023-11-28 10:42 ` [PATCH 1/2] iommufd/selftest: Use a fwnode to distinguish devices Robin Murphy
2023-11-28 14:43 ` Jason Gunthorpe
2023-11-28 16:02 ` Robin Murphy
2023-11-28 16:33 ` Jason Gunthorpe
2023-11-28 17:36 ` Robin Murphy
2023-11-28 19:07 ` Jason Gunthorpe [this message]
2023-11-28 10:42 ` [PATCH 2/2] iommufd/selftest: Use normal IOMMU registration Robin Murphy
2023-11-28 14:35 ` Jason Gunthorpe
2023-11-28 14:53 ` Robin Murphy
2023-11-28 14:56 ` Jason Gunthorpe
2023-12-06 5:48 ` kernel test robot
2023-12-06 10:42 ` kernel test robot
2023-12-06 11:35 ` kernel test robot
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=20231128190758.GA1312390@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox