diff mbox

[2/2] powerpc/powernc: revert part of commit d905c5df(PPC: POWERNV: move iommu_add_device earlier)

Message ID 1398047119-6861-2-git-send-email-weiyang@linux.vnet.ibm.com (mailing list archive)
State Accepted
Commit 3f28c5af3964c11e61e9a58df77cae5ebdb8209e
Headers show

Commit Message

Wei Yang April 21, 2014, 2:25 a.m. UTC
Here is a draft call flow:

pci_device_add
   pcibios_add_device
      pci_dma_dev_setup
         pnv_pci_dma_dev_setup
            pnv_pci_ioda_dma_dev_setup
               set_iommu_table_base_and_group <--- here
device_add

When set_iommu_table_base_and_group() is invoked int
pnv_pci_ioda_dma_dev_setup(), the dev->kobj->sd is not initialized. The
dev->kobj->sd is initialized in device_add().

After applying this patch, the error
    iommu_tce: 0003:05:00.0 has not been added, ret=-14
is cleared.

This patch revert the change for pnv_pci_ioda_dma_dev_setup() from commit
d905c5df(PPC: POWERNV: move iommu_add_device earlier).

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Benjamin Herrenschmidt April 21, 2014, 3:37 a.m. UTC | #1
On Mon, 2014-04-21 at 10:25 +0800, Wei Yang wrote:
> Here is a draft call flow:
> 
> pci_device_add
>    pcibios_add_device
>       pci_dma_dev_setup
>          pnv_pci_dma_dev_setup
>             pnv_pci_ioda_dma_dev_setup
>                set_iommu_table_base_and_group <--- here
> device_add
> 
> When set_iommu_table_base_and_group() is invoked int
> pnv_pci_ioda_dma_dev_setup(), the dev->kobj->sd is not initialized. The
> dev->kobj->sd is initialized in device_add().
> 
> After applying this patch, the error
>     iommu_tce: 0003:05:00.0 has not been added, ret=-14
> is cleared.
> 
> This patch revert the change for pnv_pci_ioda_dma_dev_setup() from commit
> d905c5df(PPC: POWERNV: move iommu_add_device earlier).

But in that case, is the group still set ?

Alexey, is that correct ?

Cheers,
Ben.

> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index fc4edda..b5d8f73 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1425,7 +1425,7 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev
>  
>  	pe = &phb->ioda.pe_array[pdn->pe_number];
>  	WARN_ON(get_dma_ops(&pdev->dev) != &dma_iommu_ops);
> -	set_iommu_table_base_and_group(&pdev->dev, &pe->tce32_table);
> +	set_iommu_table_base(&pdev->dev, &pe->tce32_table);
>  }
>  
>  static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb,
Wei Yang April 21, 2014, 5:22 a.m. UTC | #2
On Mon, Apr 21, 2014 at 01:37:32PM +1000, Benjamin Herrenschmidt wrote:
>On Mon, 2014-04-21 at 10:25 +0800, Wei Yang wrote:
>> Here is a draft call flow:
>> 
>> pci_device_add
>>    pcibios_add_device
>>       pci_dma_dev_setup
>>          pnv_pci_dma_dev_setup
>>             pnv_pci_ioda_dma_dev_setup
>>                set_iommu_table_base_and_group <--- here
>> device_add
>> 
>> When set_iommu_table_base_and_group() is invoked int
>> pnv_pci_ioda_dma_dev_setup(), the dev->kobj->sd is not initialized. The
>> dev->kobj->sd is initialized in device_add().
>> 
>> After applying this patch, the error
>>     iommu_tce: 0003:05:00.0 has not been added, ret=-14
>> is cleared.
>> 
>> This patch revert the change for pnv_pci_ioda_dma_dev_setup() from commit
>> d905c5df(PPC: POWERNV: move iommu_add_device earlier).
>
>But in that case, is the group still set ?

I think so.

iommu_add_device() will be invoked when device_add() notify the pci bus.

>
>Alexey, is that correct ?
>
>Cheers,
>Ben.
>
>> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/platforms/powernv/pci-ioda.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
>> index fc4edda..b5d8f73 100644
>> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
>> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
>> @@ -1425,7 +1425,7 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev
>>  
>>  	pe = &phb->ioda.pe_array[pdn->pe_number];
>>  	WARN_ON(get_dma_ops(&pdev->dev) != &dma_iommu_ops);
>> -	set_iommu_table_base_and_group(&pdev->dev, &pe->tce32_table);
>> +	set_iommu_table_base(&pdev->dev, &pe->tce32_table);
>>  }
>>  
>>  static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb,
>
Wei Yang April 21, 2014, 6:11 a.m. UTC | #3
On Mon, Apr 21, 2014 at 01:22:13PM +0800, Wei Yang wrote:
>On Mon, Apr 21, 2014 at 01:37:32PM +1000, Benjamin Herrenschmidt wrote:
>>On Mon, 2014-04-21 at 10:25 +0800, Wei Yang wrote:
>>> Here is a draft call flow:
>>> 
>>> pci_device_add
>>>    pcibios_add_device
>>>       pci_dma_dev_setup
>>>          pnv_pci_dma_dev_setup
>>>             pnv_pci_ioda_dma_dev_setup
>>>                set_iommu_table_base_and_group <--- here
>>> device_add
>>> 
>>> When set_iommu_table_base_and_group() is invoked int
>>> pnv_pci_ioda_dma_dev_setup(), the dev->kobj->sd is not initialized. The
>>> dev->kobj->sd is initialized in device_add().
>>> 
>>> After applying this patch, the error
>>>     iommu_tce: 0003:05:00.0 has not been added, ret=-14
>>> is cleared.
>>> 
>>> This patch revert the change for pnv_pci_ioda_dma_dev_setup() from commit
>>> d905c5df(PPC: POWERNV: move iommu_add_device earlier).
>>
>>But in that case, is the group still set ?
>
>I think so.
>
>iommu_add_device() will be invoked when device_add() notify the pci bus.
>

Did a quick test, after applying this patch, the logic would be the same for
VF and PF hotplug, the iommu_group is created with corresponding device.
diff mbox

Patch

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index fc4edda..b5d8f73 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1425,7 +1425,7 @@  static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev
 
 	pe = &phb->ioda.pe_array[pdn->pe_number];
 	WARN_ON(get_dma_ops(&pdev->dev) != &dma_iommu_ops);
-	set_iommu_table_base_and_group(&pdev->dev, &pe->tce32_table);
+	set_iommu_table_base(&pdev->dev, &pe->tce32_table);
 }
 
 static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb,