Introduce device_iommu_mapped() function
Subsystems (10)
Joerg Roedel
maintainerv2 cover Introduce device_iommu_mapped() function
Hi,
here is the second version of this patch-set. It replaces the various (dev->iommu_group) checks with a function call which better expresses their intend.
Changes to the first version are the added patch for rcar-dmac, a driver I missed before. I also added all Acked-By's I received on the first version.
Please review and provide Acks, if there are no objections. I have some iommu patches that depend on these, so I'd like to carry this patch-set in the IOMMU tree.
Regards,
Joerg
Joerg Roedel (6):
driver core: Introduce device_iommu_mapped() function iommu/of: Use device_iommu_mapped() ACPI/IORT: Use device_iommu_mapped() powerpc/iommu: Use device_iommu_mapped()
xhci: Use device_iommu_mapped()
dmaengine: sh: rcar-dmac: Use device_iommu_mapped()
arch/powerpc/kernel/eeh.c | 2 +- arch/powerpc/kernel/iommu.c | 6 +++--- drivers/acpi/arm64/iort.c | 2 +- drivers/dma/sh/rcar-dmac.c | 2 +- drivers/iommu/of_iommu.c | 2 +- drivers/usb/host/xhci.c | 2 +- include/linux/device.h | 10 ++++++++++ 7 files changed, 18 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 1/6 driver core: Introduce device_iommu_mapped() function
From: Joerg Roedel <[email protected]>
Some places in the kernel check the iommu_group pointer in 'struct device' in order to find ot whether a device is mapped by an IOMMU.
This is not good way to make this check, as the pointer will be moved to 'struct dev_iommu_data'. This way to make the check is also not very readable.
Introduce an explicit function to perform this check.
--- include/linux/device.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/device.h +10 -0
@@ -1058,6 +1058,16 @@ static inline struct device *kobj_to_dev(struct kobject *kobj) return container_of(kobj, struct device, kobj); } +/** +* device_iommu_mapped - Returns true when the device DMA is translated +* by an IOMMU +* @dev: Device to perform the check on +*/ +static inline bool device_iommu_mapped (struct device *dev) +{ +return (dev->iommu_group !=NULL ); +} +/* Get the wakeup routines, which depend on struct device */ #include <linux/pm_wakeup.h>
Re: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function
Hello!
Quoted 26 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Some places in the kernel check the
iommu_grouppointer in 'struct device' in order to find ot whether a device is mapped by an IOMMU.This is not good way to make this check, as the pointer will be moved to 'struct
dev_iommu_data'. This way to make the check is also not very readable.Introduce an explicit function to perform this check.
Cc Greg Kroah-Hartman <[email protected]>Acked-by Robin Murphy <[email protected]>Signed-off-by Joerg Roedel <[email protected]>--- include/linux/device.h | 10 ++++++++++ 1 file changed, 10 insertions(+)include/linux/device.h +0
-0@@ -1058,6 +1058,16 @@ static inline struct device *kobj_to_dev(struct kobject *kobj) return container_of(kobj, struct device, kobj);
include/linux/device.h static inline struct device *kobj_to_dev(struct kobject *kobj) · line 1068
Quoted 10 lines
include/linux/device.h +8
-0} +/** +* device_iommu_mapped - Returns true when the device DMA is translated +* by an IOMMU +* @dev: Device to perform the check on +*/ +static inline bool device_iommu_mapped (struct device *dev) +{ +return (dev->iommu_group !=NULL );
You know that parens are unnecessary here, right? :-)
include/linux/device.h static inline struct device *kobj_to_dev(struct kobject *kobj) · line 1073
Quoted 5 lines
include/linux/device.h +2
-0+} +/* Get the wakeup routines, which depend on struct device */ #include <linux/pm_wakeup.h>
MBR, Sergei
Joerg Roedel
maintainerRe: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function
Quoted 5 lines · Sergei Shtylyov
include/linux/device.h static inline struct device *kobj_to_dev(struct kobject *kobj) · line 1068
Quoted 3 lines
include/linux/device.h +3
-0+static inline bool device_iommu_mapped (struct device *dev) +{ +return (dev->iommu_group !=NULL );You know that parens are unnecessary here, right? :-)
Yes, I know, but it feels incomplete to me without them :-)
Joerg
Greg Kroah-Hartman
maintainerRe: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function
In reply to Joerg RoedelQuoted 6 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Some places in the kernel check the
iommu_grouppointer in 'struct device' in order to find ot whether a device is mapped by an IOMMU.
Quoted 8 lines
This is not good way to make this check, as the pointer will be moved to 'struct
dev_iommu_data'. This way to make the check is also not very readable.Introduce an explicit function to perform this check.
Cc Greg Kroah-Hartman <[email protected]>
No need to have a cc: line if I have already acked it :)
thanks,
greg k-h
Re: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function
Quoted 5 lines · Greg Kroah-Hartman
Quoted 2 lines · Joerg Roedel
Cc Greg Kroah-Hartman <[email protected]>No need to have a cc: line if I have already acked it :)
Right, I'll remove it, sorry for the noise.
Regards,
Joerg
Vinod Koul
maintainerRe: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function
In reply to Joerg RoedelQuoted 4 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Some places in the kernel check the
iommu_grouppointer in 'struct device' in order to find ot whether a device is
^^
Typo
Re: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function
Quoted 7 lines · Vinod Koul
Quoted 4 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Some places in the kernel check the
iommu_grouppointer in 'struct device' in order to find ot whether a device is^^Typo
Right, fixed now, thanks.
Joerg Roedel
maintainerPATCH v2 2/6 iommu/of: Use device_iommu_mapped()
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use Use device_iommu_mapped() to check if the device is already mapped by an IOMMU.
--- drivers/iommu/of_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/of_iommu.c +1 -1
@@ -220,7 +220,7 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,* If we have reason to believe the IOMMU driver missed the initial * add_device callback for dev, replay it to get things in order. */ -if (ops && ops->add_device && dev->bus && !dev->iommu_group) +if (ops && ops->add_device && dev->bus && !device_iommu_mapped (dev)) err = ops->add_device (dev);/* Ignore all other errors apart from EPROBE_DEFER */
Joerg Roedel
maintainerPATCH v2 3/6 ACPI/IORT: Use device_iommu_mapped()
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Replace the iommu-check with a proper and readable function call.
--- drivers/acpi/arm64/iort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/arm64/iort.c +1 -1
@@ -805,7 +805,7 @@ static inline int iort_add_device_replay(const struct iommu_ops *ops, {int err =0 ; -if (ops->add_device && dev->bus && !dev->iommu_group) +if (ops->add_device && dev->bus && !device_iommu_mapped (dev)) err = ops->add_device (dev);return err;
Re: [PATCH 3/6] ACPI/IORT: Use device_iommu_mapped()
Quoted 8 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Replace the iommu-check with a proper and readable function call.
Cc Lorenzo Pieralisi <[email protected]>Acked-by Robin Murphy <[email protected]>Signed-off-by Joerg Roedel <[email protected]>
Thanks
Hanjun
Joerg Roedel
maintainerPATCH v2 4/6 powerpc/iommu: Use device_iommu_mapped()
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new function to replace the open-coded iommu check.
--- arch/powerpc/kernel/eeh.c | 2 +- arch/powerpc/kernel/iommu.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/kernel/eeh.c +1 -1
@@ -1472,7 +1472,7 @@ static int dev_has_iommu_table(struct device *dev, void *data)if (!dev)return 0 ; -if (dev->iommu_group) { +if (device_iommu_mapped (dev)) { *ppdev = pdev;return 1 ; }
arch/powerpc/kernel/iommu.c +3 -3
@@ -1086,7 +1086,7 @@ int iommu_add_device(struct device *dev)if (!device_is_registered (dev))return -ENOENT ; -if (dev->iommu_group) { +if (device_iommu_mapped (dev)) {pr_debug ("%s: Skipping device %s with iommu group %d\n" , __func__,dev_name (dev),iommu_group_id (dev->iommu_group));
@@ -1129,7 +1129,7 @@ void iommu_del_device(struct device *dev)* and we needn't detach them from the associated * IOMMU groups */ -if (!dev->iommu_group) { +if (!device_iommu_mapped (dev)) {pr_debug ("iommu_tce: skipping device %s with no tbl\n" ,dev_name (dev));return ;
@@ -1148,7 +1148,7 @@ static int tce_iommu_bus_notifier(struct notifier_block *nb,case BUS_NOTIFY_ADD_DEVICE :return iommu_add_device (dev);case BUS_NOTIFY_DEL_DEVICE : -if (dev->iommu_group) +if (device_iommu_mapped (dev))iommu_del_device (dev);return 0 ;default :
Joerg Roedel
maintainerPATCH v2 5/6 xhci: Use device_iommu_mapped()
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Replace the dev->iommu_group check with a proper function call that better reprensents its purpose.
--- drivers/usb/host/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci.c +1 -1
@@ -244,7 +244,7 @@ static void xhci_zero_64b_regs(struct xhci_hcd *xhci)* an iommu. Doing anything when there is no iommu is definitely * unsafe... */ -if (!(xhci->quirks &XHCI_ZERO_64B_REGS ) || !dev->iommu_group) +if (!(xhci->quirks &XHCI_ZERO_64B_REGS ) || !device_iommu_mapped (dev))return ;xhci_info (xhci,"Zeroing 64bit base registers, expecting fault\n" );
Re: [PATCH 5/6] xhci: Use device_iommu_mapped()
Quoted 18 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Replace the
dev->iommu_groupcheck with a proper function call that better reprensents its purpose.Cc Mathias Nyman <[email protected]>Acked-by Robin Murphy <[email protected]>Signed-off-by Joerg Roedel <[email protected]>--- drivers/usb/host/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/host/xhci.c +0
-0
drivers/usb/host/xhci.c static void xhci_zero_64b_regs(struct xhci_hcd *xhci) · line 250
Quoted 8 lines
drivers/usb/host/xhci.c +1
-1@@ -244,7 +244,7 @@ static void xhci_zero_64b_regs(struct xhci_hcd *xhci)* an iommu. Doing anything when there is no iommu is definitely * unsafe... */ -if (!(xhci->quirks &XHCI_ZERO_64B_REGS ) || !dev->iommu_group) +if (!(xhci->quirks &XHCI_ZERO_64B_REGS ) || !device_iommu_mapped (dev))return ;xhci_info (xhci,"Zeroing 64bit base registers, expecting fault\n" );
Joerg Roedel
maintainerPATCH v2 6/6 dmaengine: sh: rcar-dmac: Use device_iommu_mapped()
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use Use device_iommu_mapped() to check if the device is already mapped by an IOMMU.
--- drivers/dma/sh/rcar-dmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/sh/rcar-dmac.c +1 -1
@@ -1809,7 +1809,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)* level we can't disable it selectively, so ignore channel 0 for now if * the device is part of an IOMMU group. */ -if (pdev->dev.iommu_group) { +if (device_iommu_mapped (&pdev->dev)) { dmac->n_channels--; channels_offset =1 ; }
Re: [PATCH 6/6] dmaengine: sh: rcar-dmac: Use device_iommu_mapped()
Quoted 4 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Use Use
device_iommu_mapped()to check if the device is already mapped by an IOMMU.