diff mbox

[U-Boot] pcie/layerscape: fix bug in bus number computation when setting msi-map

Message ID 1463469520-705-1-git-send-email-bogdan.purcareata@nxp.com
State Accepted
Commit 3378727d13dac410d8ef2d8426d4c9bfc4974405
Delegated to: York Sun
Headers show

Commit Message

Bogdan Purcareata May 17, 2016, 7:18 a.m. UTC
When multiple PCI cards are present in an ls2080a board, the second
card does not get its msi-map set up properly due to a bug in computing
the bus number.

The bus number returned by PCI_BDF() is not the actual PCI bus
number, but instead represents a global u-boot PCI bus number.  A given
bus number is relative to hose->first_busno, so that has to be subtracted
from the PCI device id.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
Acked-by: Stuart Yoder <stuart.yoder@nxp.com>
---
 drivers/pci/pcie_layerscape.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Bogdan Purcareata June 3, 2016, 11:19 a.m. UTC | #1
Ping?

Bogdan P.

On 17.05.2016 10:18, Bogdan Purcareata wrote:
> When multiple PCI cards are present in an ls2080a board, the second
> card does not get its msi-map set up properly due to a bug in computing
> the bus number.
>
> The bus number returned by PCI_BDF() is not the actual PCI bus
> number, but instead represents a global u-boot PCI bus number.  A given
> bus number is relative to hose->first_busno, so that has to be subtracted
> from the PCI device id.
>
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> Acked-by: Stuart Yoder <stuart.yoder@nxp.com>
> ---
>  drivers/pci/pcie_layerscape.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c
> index 0ba960e..2e6b986 100644
> --- a/drivers/pci/pcie_layerscape.c
> +++ b/drivers/pci/pcie_layerscape.c
> @@ -569,7 +569,7 @@ static void fdt_fixup_pcie(void *blob)
>  	unsigned char header_type;
>  	int index;
>  	u32 streamid;
> -	pci_dev_t dev;
> +	pci_dev_t dev, bdf;
>  	int bus;
>  	unsigned short id;
>  	struct pci_controller *hose;
> @@ -611,12 +611,15 @@ static void fdt_fixup_pcie(void *blob)
>  					continue;
>  				}
>
> +				/* the DT fixup must be relative to the hose first_busno */
> +				bdf = dev - PCI_BDF(hose->first_busno, 0, 0);
> +
>  				/* map PCI b.d.f to streamID in LUT */
> -				ls_pcie_lut_set_mapping(pcie, index, dev >> 8,
> +				ls_pcie_lut_set_mapping(pcie, index, bdf >> 8,
>  							streamid);
>
>  				/* update msi-map in device tree */
> -				fdt_pcie_set_msi_map_entry(blob, pcie, dev >> 8,
> +				fdt_pcie_set_msi_map_entry(blob, pcie, bdf >> 8,
>  							   streamid);
>  			}
>  		}
>
York Sun June 3, 2016, 4:31 p.m. UTC | #2
On 06/03/2016 04:19 AM, Bogdan Purcareata wrote:
> Ping?

If you checked patchwork, you would see this patch is marked as "under review".
It is in my test queue and will be merged along with other patches.

York

> 
> Bogdan P.
> 
> On 17.05.2016 10:18, Bogdan Purcareata wrote:
>> When multiple PCI cards are present in an ls2080a board, the second
>> card does not get its msi-map set up properly due to a bug in computing
>> the bus number.
>>
>> The bus number returned by PCI_BDF() is not the actual PCI bus
>> number, but instead represents a global u-boot PCI bus number.  A given
>> bus number is relative to hose->first_busno, so that has to be subtracted
>> from the PCI device id.
>>
>> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
>> Acked-by: Stuart Yoder <stuart.yoder@nxp.com>
>> ---
>>  drivers/pci/pcie_layerscape.c | 9 ++++++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c
>> index 0ba960e..2e6b986 100644
>> --- a/drivers/pci/pcie_layerscape.c
>> +++ b/drivers/pci/pcie_layerscape.c
>> @@ -569,7 +569,7 @@ static void fdt_fixup_pcie(void *blob)
>>  	unsigned char header_type;
>>  	int index;
>>  	u32 streamid;
>> -	pci_dev_t dev;
>> +	pci_dev_t dev, bdf;
>>  	int bus;
>>  	unsigned short id;
>>  	struct pci_controller *hose;
>> @@ -611,12 +611,15 @@ static void fdt_fixup_pcie(void *blob)
>>  					continue;
>>  				}
>>
>> +				/* the DT fixup must be relative to the hose first_busno */
>> +				bdf = dev - PCI_BDF(hose->first_busno, 0, 0);
>> +
>>  				/* map PCI b.d.f to streamID in LUT */
>> -				ls_pcie_lut_set_mapping(pcie, index, dev >> 8,
>> +				ls_pcie_lut_set_mapping(pcie, index, bdf >> 8,
>>  							streamid);
>>
>>  				/* update msi-map in device tree */
>> -				fdt_pcie_set_msi_map_entry(blob, pcie, dev >> 8,
>> +				fdt_pcie_set_msi_map_entry(blob, pcie, bdf >> 8,
>>  							   streamid);
>>  			}
>>  		}
>>
York Sun June 4, 2016, 5:05 a.m. UTC | #3
On 05/17/2016 03:52 AM, Bogdan Purcareata wrote:
> When multiple PCI cards are present in an ls2080a board, the second
> card does not get its msi-map set up properly due to a bug in computing
> the bus number.
> 
> The bus number returned by PCI_BDF() is not the actual PCI bus
> number, but instead represents a global u-boot PCI bus number.  A given
> bus number is relative to hose->first_busno, so that has to be subtracted
> from the PCI device id.
> 
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> Acked-by: Stuart Yoder <stuart.yoder@nxp.com>
> ---
>  drivers/pci/pcie_layerscape.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 

Applied to fsl-qoriq master branch. Awaiting upstream.
Thanks.

York
diff mbox

Patch

diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c
index 0ba960e..2e6b986 100644
--- a/drivers/pci/pcie_layerscape.c
+++ b/drivers/pci/pcie_layerscape.c
@@ -569,7 +569,7 @@  static void fdt_fixup_pcie(void *blob)
 	unsigned char header_type;
 	int index;
 	u32 streamid;
-	pci_dev_t dev;
+	pci_dev_t dev, bdf;
 	int bus;
 	unsigned short id;
 	struct pci_controller *hose;
@@ -611,12 +611,15 @@  static void fdt_fixup_pcie(void *blob)
 					continue;
 				}
 
+				/* the DT fixup must be relative to the hose first_busno */
+				bdf = dev - PCI_BDF(hose->first_busno, 0, 0);
+
 				/* map PCI b.d.f to streamID in LUT */
-				ls_pcie_lut_set_mapping(pcie, index, dev >> 8,
+				ls_pcie_lut_set_mapping(pcie, index, bdf >> 8,
 							streamid);
 
 				/* update msi-map in device tree */
-				fdt_pcie_set_msi_map_entry(blob, pcie, dev >> 8,
+				fdt_pcie_set_msi_map_entry(blob, pcie, bdf >> 8,
 							   streamid);
 			}
 		}