mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: joro@8bytes.org, jgg@ziepe.ca, kevin.tian@intel.com
Cc: will@kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] iommufd/selftest: Use a fwnode to distinguish devices
Date: Tue, 28 Nov 2023 10:42:11 +0000	[thread overview]
Message-ID: <e365c08b21a8d0b60e6f5d1411be6701c1a06a53.1701165201.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1701165201.git.robin.murphy@arm.com>

With bus ops gone, the trick of registering against a specific bus no
longer really works, and we start getting given devices from other buses
to probe, which leads to spurious groups for devices with no IOMMU on
arm64, but may inadvertently steal devices from the real IOMMU on Intel,
AMD or S390. Driver coexistence is based on the fwspec mechanism, so
register with a non-NULL fwnode and give mock devices a corresponding
fwspec, to let the IOMMU core distinguish things correctly for us.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/iommu/iommufd/selftest.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index 5d93434003d8..f46ce0f8808d 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -432,7 +432,11 @@ static bool mock_domain_capable(struct device *dev, enum iommu_cap cap)
 	return false;
 }
 
+static struct fwnode_handle mock_fwnode = {
+};
+
 static struct iommu_device mock_iommu_device = {
+	.fwnode = &mock_fwnode,
 };
 
 static struct iommu_device *mock_probe_device(struct device *dev)
@@ -569,12 +573,17 @@ static struct mock_dev *mock_dev_create(unsigned long dev_flags)
 	if (rc)
 		goto err_put;
 
+	rc = iommu_fwspec_init(&mdev->dev, &mock_fwnode, &mock_ops);
+	if (rc)
+		goto err_put;
+
 	rc = device_add(&mdev->dev);
 	if (rc)
 		goto err_put;
 	return mdev;
 
 err_put:
+	iommu_fwspec_free(&mdev->dev);
 	put_device(&mdev->dev);
 	return ERR_PTR(rc);
 }
-- 
2.39.2.101.g768bb238c484.dirty


  reply	other threads:[~2023-11-28 10:42 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 ` Robin Murphy [this message]
2023-11-28 14:43   ` [PATCH 1/2] iommufd/selftest: Use a fwnode to distinguish devices 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
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=e365c08b21a8d0b60e6f5d1411be6701c1a06a53.1701165201.git.robin.murphy@arm.com \
    --to=robin.murphy@arm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®