MIPS/PCI: Call pcie_bus_configure_settings() to set MPS/MRRS
PATCH 1/2 MIPS/PCI: Call pcie_bus_configure_settings() to set MPS/MRRS
Call pcie_bus_configure_settings() on MIPS, like for other platforms. The function pcie_bus_configure_settings() makes sure the MPS (Max Payload Size) across the bus is uniform and provides the ability to tune the MRSS (Max Read Request Size) and MPS (Max Payload Size) to higher performance values. Some devices will not operate properly if these aren't set correctly because the firmware doesn't always do it.
--- arch/mips/pci/pci-legacy.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/mips/pci/pci-legacy.c +4 -0
@@ -127,8 +127,12 @@ static void pcibios_scanbus(struct pci_controller *hose)if (pci_has_flag (PCI_PROBE_ONLY )) {pci_bus_claim_resources (bus); }else { +struct pci_bus *child; +pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +list_for_each_entry (child, &bus->children, node) +pcie_bus_configure_settings (child); }pci_bus_add_devices (bus); }
Signature · 1 line
2.7.0
PATCH 2/2 MIPS/PCI: Let Loongson-3 pci_ops access extended config space
--- arch/mips/pci/ops-loongson3.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
arch/mips/pci/ops-loongson3.c +21 -8
@@ -24,16 +24,29 @@ static int loongson3_pci_config_access(unsigned char access_type,int function =PCI_FUNC (devfn);int reg = where & ~3 ; - addr = (busnum <<16 ) | (device <<11 ) | (function <<8 ) | reg; -if (busnum ==0 ) { -if (device >31 ) +if (where <256 ) {/* standard config */ + addr = (busnum <<16 ) | (device <<11 ) | (function <<8 ) | reg; +if (busnum ==0 ) { +if (device >31 ) +return PCIBIOS_DEVICE_NOT_FOUND ; + addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE ) | (addr &0xffff )); + type =0 ; + }else { + addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE_TP1 ) | (addr)); + type =0x10000 ; + } + }else {/* extended config */ +struct pci_dev *rootdev; + + rootdev =pci_get_domain_bus_and_slot (0 ,0 ,0 ); +if (!rootdev) +return PCIBIOS_DEVICE_NOT_FOUND ; + + addr =pci_resource_start (rootdev,3 ); +if (!addr)return PCIBIOS_DEVICE_NOT_FOUND ; - addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE ) | (addr &0xffff )); - type =0 ; - }else { - addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE_TP1 ) | (addr)); - type =0x10000 ; + addrp = (void *)TO_UNCAC (addr | busnum <<20 | device <<15 | function <<12 | reg); }if (access_type ==PCI_ACCESS_WRITE )
Signature · 1 line
2.7.0
Hi Huacai,
Quoted 11 lines · Huacai Chen
Call
pcie_bus_configure_settings()on MIPS, like for other platforms. The functionpcie_bus_configure_settings()makes sure the MPS (Max Payload Size) across the bus is uniform and provides the ability to tune the MRSS (Max Read Request Size) and MPS (Max Payload Size) to higher performance values. Some devices will not operate properly if these aren't set correctly because the firmware doesn't always do it.Signed-off-by Huacai Chen <[email protected]>--- arch/mips/pci/pci-legacy.c | 4 ++++ 1 file changed, 4 insertions(+)
Thanks - applied to mips-next for 4.20.
Paul
Re: [PATCH 2/2] MIPS/PCI: Let Loongson-3 pci_ops access extended config space
In reply to Huacai ChenHi Huacai,
Quoted 4 lines · Huacai Chen
Signed-off-by Huacai Chen <[email protected]>--- arch/mips/pci/ops-loongson3.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
Please can you add a commit message, even if it's brief.
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 27
Quoted 12 lines
arch/mips/pci/ops-loongson3.c +1
-3@@ -24,16 +24,29 @@ static int loongson3_pci_config_access(unsigned char access_type,int function =PCI_FUNC (devfn);int reg = where & ~3 ; - addr = (busnum <<16 ) | (device <<11 ) | (function <<8 ) | reg; -if (busnum ==0 ) { -if (device >31 ) +if (where <256 ) {/* standard config */
This can be PCI_CFG_SPACE_SIZE instead of the magic 256 number, to make it clearer what's going on.
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 32
Quoted 5 lines
arch/mips/pci/ops-loongson3.c +5
-0+ addr = (busnum <<16 ) | (device <<11 ) | (function <<8 ) | reg; +if (busnum ==0 ) { +if (device >31 ) +return PCIBIOS_DEVICE_NOT_FOUND ; + addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE ) | (addr &0xffff ));
I know this is existing code, but we could clean up some unnecessary brackets whilst we're here:
addrp = (void *)TO_UNCAC(HT1LO_PCICFG_BASE | (addr & 0xffff));
Actually we can go further than that - the only thing in bits 16 & above of addr is busnum & we already know it's zero, so we don't need to mask addr at all & this line can be simplified to:
addrp = (void *)TO_UNCAC(HT1LO_PCICFG_BASE | addr);
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 33
Quoted 1 line
arch/mips/pci/ops-loongson3.c +1
-0+ type =0 ;
Is the type variable ever used? It looks unused both in the existing code & after this patch - can we just remove it?
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 36
Quoted 3 lines
arch/mips/pci/ops-loongson3.c +3
-0+ }else { + addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE_TP1 ) | (addr)); + type =0x10000 ;
Similar comments to above - we could drop some brackets & perhaps drop the type variable.
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 38
Quoted 2 lines
arch/mips/pci/ops-loongson3.c +2
-0+ } + }else {/* extended config */
Should this be "} else if (where < PCI_CFG_SPACE_EXP_SIZE) {"?
Quoted 21 lines
arch/mips/pci/ops-loongson3.c +9
-5+struct pci_dev *rootdev; + + rootdev =pci_get_domain_bus_and_slot (0 ,0 ,0 ); +if (!rootdev) +return PCIBIOS_DEVICE_NOT_FOUND ; + + addr =pci_resource_start (rootdev,3 ); +if (!addr)return PCIBIOS_DEVICE_NOT_FOUND ; - addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE ) | (addr &0xffff )); - type =0 ; - }else { - addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE_TP1 ) | (addr)); - type =0x10000 ; + addrp = (void *)TO_UNCAC (addr | busnum <<20 | device <<15 | function <<12 | reg); }if (access_type ==PCI_ACCESS_WRITE )Signature · 1 line
2.7.0
Thanks,
Paul
Re: [PATCH 2/2] MIPS/PCI: Let Loongson-3 pci_ops access extended config space
Hi, Paul,
I will improve this patch, and could you please read my new comments on the VDSO patch?
Thanks,
Huacai
Quoted 84 lines · Paul Burton
Hi Huacai,
Quoted 4 lines · Huacai Chen
Signed-off-by Huacai Chen <[email protected]>--- arch/mips/pci/ops-loongson3.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)Please can you add a commit message, even if it's brief.
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 27
Quoted 12 lines
arch/mips/pci/ops-loongson3.c +1
-3@@ -24,16 +24,29 @@ static int loongson3_pci_config_access(unsigned char access_type,int function =PCI_FUNC (devfn);int reg = where & ~3 ; - addr = (busnum <<16 ) | (device <<11 ) | (function <<8 ) | reg; -if (busnum ==0 ) { -if (device >31 ) +if (where <256 ) {/* standard config */ This can be
PCI_CFG_SPACE_SIZEinstead of the magic 256 number, to make it clearer what's going on.arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 32
Quoted 5 lines
arch/mips/pci/ops-loongson3.c +5
-0+ addr = (busnum <<16 ) | (device <<11 ) | (function <<8 ) | reg; +if (busnum ==0 ) { +if (device >31 ) +return PCIBIOS_DEVICE_NOT_FOUND ; + addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE ) | (addr &0xffff ));I know this is existing code, but we could clean up some unnecessary brackets whilst we're here:
addrp = (void *)TO_UNCAC(HT1LO_PCICFG_BASE | (addr & 0xffff));Actually we can go further than that - the only thing in bits 16 & above of addr is busnum & we already know it's zero, so we don't need to mask addr at all & this line can be simplified to:
addrp = (void *)TO_UNCAC(HT1LO_PCICFG_BASE | addr);arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 33
Quoted 1 line
arch/mips/pci/ops-loongson3.c +1
-0+ type =0 ;Is the type variable ever used? It looks unused both in the existing code & after this patch - can we just remove it?
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 36
Quoted 3 lines
arch/mips/pci/ops-loongson3.c +3
-0+ }else { + addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE_TP1 ) | (addr)); + type =0x10000 ;Similar comments to above - we could drop some brackets & perhaps drop the type variable.
arch/mips/pci/ops-loongson3.c static int loongson3_pci_config_access(unsigned char access_type, · line 38
Quoted 2 lines
arch/mips/pci/ops-loongson3.c +2
-0+ } + }else {/* extended config */ Should this be "} else if (where <
PCI_CFG_SPACE_EXP_SIZE) {"?Quoted 20 lines
arch/mips/pci/ops-loongson3.c +9
-6+struct pci_dev *rootdev; + + rootdev =pci_get_domain_bus_and_slot (0 ,0 ,0 ); +if (!rootdev) +return PCIBIOS_DEVICE_NOT_FOUND ; + + addr =pci_resource_start (rootdev,3 ); +if (!addr)return PCIBIOS_DEVICE_NOT_FOUND ; - addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE ) | (addr &0xffff )); - type =0 ; - }else { - addrp = (void *)(TO_UNCAC (HT1LO_PCICFG_BASE_TP1 ) | (addr)); - type =0x10000 ; + addrp = (void *)TO_UNCAC (addr | busnum <<20 | device <<15 | function <<12 | reg); }if (access_type ==PCI_ACCESS_WRITE ) --Quoted 1 line
2.7.0
Thanks,
Paul
Re: [PATCH 2/2] MIPS/PCI: Let Loongson-3 pci_ops access extended config space
Hi Huacai,
Quoted 2 lines · Huacai Chen
I will improve this patch, and could you please read my new comments on the VDSO patch?
Yes, I saw your response. As mentioned I'm not keen to unconditionally take away 4MB of the user address space, so I'm looking at whether we can fix your issue without that.
Thanks,
Paul