Re: [PATCH v2] iommu/fsl: Fix warning resulting from adding PCI device twice

2014-09-05 Thread Joerg Roedel
On Thu, Sep 04, 2014 at 05:08:45PM +0530, Varun Sethi wrote:
 iommu_group_get_for_dev determines the iommu group for the PCI device and adds
 the device to the group.
 
 In the PAMU driver we were again adding the device to the same group without 
 checking
 if the device already had an iommu group. This resulted in the following 
 warning.

 [...]
 
 Signed-off-by: Varun Sethi varun.se...@freescale.com
 ---
 v2 changes
 - directly check for the device iommu_group
 
  drivers/iommu/fsl_pamu_domain.c |   10 --
  1 file changed, 8 insertions(+), 2 deletions(-)

Applied to iommu/fixes and added stable tag, thanks.

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH v2] iommu/fsl: Fix warning resulting from adding PCI device twice

2014-09-04 Thread Varun Sethi
iommu_group_get_for_dev determines the iommu group for the PCI device and adds
the device to the group.

In the PAMU driver we were again adding the device to the same group without 
checking
if the device already had an iommu group. This resulted in the following 
warning.

sysfs: cannot create duplicate filename 
'/devices/ffe20.pcie/pci:00/:00:00.0/iommu_group'
[ cut here ]
WARNING: at fs/sysfs/dir.c:31
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc3-2-g7505cea-dirty #126
task: c001fe0a ti: c001fe044000 task.ti: c001fe044000
NIP: c018879c LR: c0188798 CTR: c001ea50
REGS: c001fe047040 TRAP: 0700   Not tainted  
(3.17.0-rc3-2-g7505cea-dirty)
MSR: 80029000 CE,EE,ME  CR: 24ad8e22  XER: 2000
SOFTE: 1 
GPR00: c0188798 c001fe0472c0 c09a52e0 0065 
GPR04: 0001  3a30303a 2700 
GPR08: 2f696f6d c08d3830 c09b3938 c09bb3d0 
GPR12: 28ad8e24 cfff4000 c000205c  
GPR16:     
GPR20:    c08a4c70 
GPR24: c07e9010 c001fe0140a8 ffef 0001 
GPR28: c001fe22ebb8 c07e9010 c090bf10 c001fe22 
NIP [c018879c] .sysfs_warn_dup+0x74/0xa4
LR [c0188798] .sysfs_warn_dup+0x70/0xa4
Call Trace:
[c001fe0472c0] [c0188798] .sysfs_warn_dup+0x70/0xa4 (unreliable)
[c001fe047350] [c0188d34] 
.sysfs_do_create_link_sd.clone.2+0x168/0x174
[c001fe047400] [c04b3cf8] .iommu_group_add_device+0x78/0x244
[c001fe0474b0] [c04b6964] .fsl_pamu_add_device+0x88/0x1a8
[c001fe047570] [c04b3960] .iommu_bus_notifier+0xdc/0x15c
[c001fe047600] [c0059848] .notifier_call_chain+0x8c/0xe8
[c001fe0476a0] [c0059d04] .__blocking_notifier_call_chain+0x58/0x84
[c001fe047750] [c036619c] .device_add+0x464/0x5c8
[c001fe047820] [c0300ebc] .pci_device_add+0x14c/0x17c
[c001fe0478c0] [c0300fbc] .pci_scan_single_device+0xd0/0xf4
[c001fe047970] [c030104c] .pci_scan_slot+0x6c/0x18c
[c001fe047a10] [c030226c] .pci_scan_child_bus+0x40/0x114
[c001fe047ac0] [c0021974] .pcibios_scan_phb+0x240/0x2c8
[c001fe047b70] [c085a970] .pcibios_init+0x64/0xc8
[c001fe047c00] [c0001884] .do_one_initcall+0xbc/0x224
[c001fe047d00] [c0852d50] .kernel_init_freeable+0x14c/0x21c
[c001fe047db0] [c0002078] .kernel_init+0x1c/0xfa4
[c001fe047e30] [c884] .ret_from_kernel_thread+0x58/0xd4
Instruction dump:
7c7f1b79 4182001c 7fe4fb78 7f83e378 38a01000 4bffc905 6000 7c641b78 
e87e8008 7fa5eb78 48482ff5 6000 0fe0 7fe3fb78 4bf7bd39 6000 



Signed-off-by: Varun Sethi varun.se...@freescale.com
---
v2 changes
- directly check for the device iommu_group

 drivers/iommu/fsl_pamu_domain.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 61d1daf..56feed7 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -984,7 +984,7 @@ static int fsl_pamu_add_device(struct device *dev)
struct iommu_group *group = ERR_PTR(-ENODEV);
struct pci_dev *pdev;
const u32 *prop;
-   int ret, len;
+   int ret = 0, len;
 
/*
 * For platform devices we allocate a separate group for
@@ -1007,7 +1007,13 @@ static int fsl_pamu_add_device(struct device *dev)
if (IS_ERR(group))
return PTR_ERR(group);
 
-   ret = iommu_group_add_device(group, dev);
+   /*
+* Check if device has already been added to an iommu group.
+* Group could have already been created for a PCI device in
+* the iommu_group_get_for_dev path.
+*/
+   if (!dev-iommu_group)
+   ret = iommu_group_add_device(group, dev);
 
iommu_group_put(group);
return ret;
-- 
1.7.9.5

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v2] iommu/fsl: Fix warning resulting from adding PCI device twice

2014-09-04 Thread Emil Medve
On 09/04/2014 06:38 AM, Varun Sethi wrote:
 iommu_group_get_for_dev determines the iommu group for the PCI device and adds
 the device to the group.
 
 In the PAMU driver we were again adding the device to the same group without 
 checking
 if the device already had an iommu group. This resulted in the following 
 warning.
 
 sysfs: cannot create duplicate filename 
 '/devices/ffe20.pcie/pci:00/:00:00.0/iommu_group'
 [ cut here ]
 WARNING: at fs/sysfs/dir.c:31
 Modules linked in:
 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc3-2-g7505cea-dirty #126
 task: c001fe0a ti: c001fe044000 task.ti: c001fe044000
 NIP: c018879c LR: c0188798 CTR: c001ea50
 REGS: c001fe047040 TRAP: 0700   Not tainted  
 (3.17.0-rc3-2-g7505cea-dirty)
 MSR: 80029000 CE,EE,ME  CR: 24ad8e22  XER: 2000
 SOFTE: 1 
 GPR00: c0188798 c001fe0472c0 c09a52e0 0065 
 GPR04: 0001  3a30303a 2700 
 GPR08: 2f696f6d c08d3830 c09b3938 c09bb3d0 
 GPR12: 28ad8e24 cfff4000 c000205c  
 GPR16:     
 GPR20:    c08a4c70 
 GPR24: c07e9010 c001fe0140a8 ffef 0001 
 GPR28: c001fe22ebb8 c07e9010 c090bf10 c001fe22 
 NIP [c018879c] .sysfs_warn_dup+0x74/0xa4
 LR [c0188798] .sysfs_warn_dup+0x70/0xa4
 Call Trace:
 [c001fe0472c0] [c0188798] .sysfs_warn_dup+0x70/0xa4 (unreliable)
 [c001fe047350] [c0188d34] 
 .sysfs_do_create_link_sd.clone.2+0x168/0x174
 [c001fe047400] [c04b3cf8] .iommu_group_add_device+0x78/0x244
 [c001fe0474b0] [c04b6964] .fsl_pamu_add_device+0x88/0x1a8
 [c001fe047570] [c04b3960] .iommu_bus_notifier+0xdc/0x15c
 [c001fe047600] [c0059848] .notifier_call_chain+0x8c/0xe8
 [c001fe0476a0] [c0059d04] 
 .__blocking_notifier_call_chain+0x58/0x84
 [c001fe047750] [c036619c] .device_add+0x464/0x5c8
 [c001fe047820] [c0300ebc] .pci_device_add+0x14c/0x17c
 [c001fe0478c0] [c0300fbc] .pci_scan_single_device+0xd0/0xf4
 [c001fe047970] [c030104c] .pci_scan_slot+0x6c/0x18c
 [c001fe047a10] [c030226c] .pci_scan_child_bus+0x40/0x114
 [c001fe047ac0] [c0021974] .pcibios_scan_phb+0x240/0x2c8
 [c001fe047b70] [c085a970] .pcibios_init+0x64/0xc8
 [c001fe047c00] [c0001884] .do_one_initcall+0xbc/0x224
 [c001fe047d00] [c0852d50] .kernel_init_freeable+0x14c/0x21c
 [c001fe047db0] [c0002078] .kernel_init+0x1c/0xfa4
 [c001fe047e30] [c884] .ret_from_kernel_thread+0x58/0xd4
 Instruction dump:
 7c7f1b79 4182001c 7fe4fb78 7f83e378 38a01000 4bffc905 6000 7c641b78 
 e87e8008 7fa5eb78 48482ff5 6000 0fe0 7fe3fb78 4bf7bd39 6000 
 
 
 
 Signed-off-by: Varun Sethi varun.se...@freescale.com

Tested-by: Emil Medve emilian.me...@freescale.com
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu