[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN][RFC PATCH v4 09/16] xen/iommu: Introduce iommu_remove_dt_device()
- To: Michal Orzel <michal.orzel@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
- Date: Thu, 9 Feb 2023 23:06:34 -0800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8aLkufrf21sr24vi1qYvnsgcw3tzCrDJ6V4niJVEoPw=; b=hsBXPdDZ4Ka5Z6Y1KbqwRBH7tgt1Pv5wCn7P3dLRX+s9trR5Yw8vY1gXqmHOw1hQTrD1Uj7ognfMNI0VIY3OPa+zsBkf3Pxqx8os3qMfsWRWTHYH/Ahnm5G2IUE5hd6ycApXPQVFrHPxUlAuv/1K45N9o5Y3q+hfyUsy72IWvU/lz7eul7irMVNFnB/qMy0bhHGcaVm6NkaJ6r9yldihr3ivSI+v7us/UxpceoJ6SBu50l4Hg2kgtlQ2SPAq2DqDBahOr89nknT4+TLPx+z0BURKDDb5hi+8pzgBIeMU2lT9v/4BTMKHo/Uk6CquaM3WHxyzgNHRLVs2gWBHQDY+Dg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dusCKnU/k6S2dqXrAWgFc+n4/fVKT1M9WH7ByD9SJIr8aNpgkTV+vxU2YVvuTaaonY2WesgnCReUT0NcnmSZjswpTpwCb9vFytcnbHHMyovPEFUAiKvXKDvthmD6MjiXiZGZpTXnYLamAWmZyG2iX9jKeCR4K14k1BYGiBn4euMcAXuKzoCTjPVSmWntni7Jvv/skfYctn+OWZeYZlAYJ2lMgXy8Q5ld/GfDroYU9o+YV09s9nFakpxsfQ0NyT1O0yftE6RI8OhN0zC0uo3riC09qDdXKTB3p+VE/87+xa1IbuPZVvu4ZAPta6UDYGC1OLwpZLxoZJqoAf1CDzVvmw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: sstabellini@xxxxxxxxxx, julien@xxxxxxx, Luca.Fancellu@xxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Fri, 10 Feb 2023 07:07:07 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Hi Michal,
On 1/23/23 2:00 AM, Michal Orzel wrote:
Hi Vikram,
On 07/12/2022 07:18, Vikram Garhwal wrote:
Remove master device from the IOMMU.
Adding some description on the purpose would be beneficial.
will do.
Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
xen/drivers/passthrough/device_tree.c | 38 +++++++++++++++++++++++++++
xen/include/xen/iommu.h | 2 ++
2 files changed, 40 insertions(+)
diff --git a/xen/drivers/passthrough/device_tree.c
b/xen/drivers/passthrough/device_tree.c
index 457df333a0..a8ba0b0d17 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -126,6 +126,44 @@ int iommu_release_dt_devices(struct domain *d)
return 0;
}
+int iommu_remove_dt_device(struct dt_device_node *np)
+{
+ const struct iommu_ops *ops = iommu_get_ops();
+ struct device *dev = dt_to_dev(np);
+ int rc;
+
Aren't we missing a check if iommu is enabled?
IIUC your question: There is only one caller which is in dynamic
programming part handle_remove_irq_iommu(). The call only happen if the
dt_node has iommu property.
+ if ( !ops )
+ return -EOPNOTSUPP;
-EINVAL to match the return values returned by other functions?
+
+ spin_lock(&dtdevs_lock);
+
+ if ( iommu_dt_device_is_assigned_locked(np) ) {
Incorrect coding style. The closing brace should be placed on the next line.
Fixed this for v5.
+ rc = -EBUSY;
+ goto fail;
+ }
+
+ /*
+ * The driver which supports generic IOMMU DT bindings must have
+ * these callback implemented.
+ */
+ if ( !ops->remove_device ) {
Incorrect coding style. The closing brace should be placed on the next line.
Fixed this for v5.
+ rc = -EOPNOTSUPP;
-EINVAL to match the return values returned by other functions?
+ goto fail;
+ }
+
+ /*
+ * Remove master device from the IOMMU if latter is present and available.
+ */
No need for a multi-line comment style.
Fixed this for v5.
+ rc = ops->remove_device(0, dev);
+
+ if ( rc == 0 )
!rc is preffered.
Fixed this for v5.
+ iommu_fwspec_free(dev);
+
+fail:
+ spin_unlock(&dtdevs_lock);
+ return rc;
+}
+
int iommu_add_dt_device(struct dt_device_node *np)
{
const struct iommu_ops *ops = iommu_get_ops();
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 4f22fc1bed..1b36c0419d 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -225,6 +225,8 @@ int iommu_release_dt_devices(struct domain *d);
*/
int iommu_add_dt_device(struct dt_device_node *np);
+int iommu_remove_dt_device(struct dt_device_node *np);
These prototypes look to be placed in order. So your function should be
placed before add function.
Fixed this for v5.
+
int iommu_do_dt_domctl(struct xen_domctl *, struct domain *,
XEN_GUEST_HANDLE_PARAM(xen_domctl_t));
--
2.17.1
~Michal
|