Add IPROC PCIe new features
v2 cover Add IPROC PCIe new features
This patch set extends support of new IPROC PCIe host controller features
- Add CRS check using controller register status flags
- Add 32bit outbound window mapping configuration
This patch set is based on Linux-5.0-rc2.
Changes from v1:
- Addressed Bjorn Helgaas comments.
- Removed set order mode patch from patchset.
Srinath Mannam (2):
PCI: iproc: Add CRS check in config read
PCI: iproc: Add PCIe 32bit outbound memory configuration
drivers/pci/controller/pcie-iproc.c | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/2 PCI: iproc: Add CRS check in config read
In the current implementation, config read output data 0xffff0001 is assumed as CRS completion. But sometimes 0xffff0001 can be a valid data.
IPROC PCIe host controller has a register to show config read request status flags like SC, UR, CRS and CA. So that extra check is added to confirm the CRS using status flags before reissue config read.
--- drivers/pci/controller/pcie-iproc.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-iproc.c +21 -2
@@ -60,6 +60,10 @@#define APB_ERR_EN_SHIFT 0#define APB_ERR_EN BIT(APB_ERR_EN_SHIFT) +#define CFG_RD_SUCCESS 0 +#define CFG_RD_UR 1 +#define CFG_RD_CRS 2 +#define CFG_RD_CA 3#define CFG_RETRY_STATUS 0xffff0001#define CFG_RETRY_STATUS_TIMEOUT_US 500000/* 500 milliseconds */
@@ -289,6 +293,9 @@ enum iproc_pcie_reg {IPROC_PCIE_IARR4 ,IPROC_PCIE_IMAP4 , +/* config read status */ +IPROC_PCIE_CFG_RD_STATUS , +/* link status */ IPROC_PCIE_LINK_STATUS,
@@ -350,6 +357,7 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { [IPROC_PCIE_IMAP3] = 0xe08, [IPROC_PCIE_IARR4] = 0xe68, [IPROC_PCIE_IMAP4] = 0xe70, + [IPROC_PCIE_CFG_RD_STATUS] = 0xee0, [IPROC_PCIE_LINK_STATUS] = 0xf0c, [IPROC_PCIE_APB_ERR_EN] = 0xf40, };
@@ -474,10 +482,12 @@ static void __iomem *iproc_pcie_map_ep_cfg_reg(struct iproc_pcie *pcie,return (pcie->base + offset); } -static unsigned int iproc_pcie_cfg_retry (void __iomem *cfg_data_p) +static unsigned int iproc_pcie_cfg_retry (struct iproc_pcie *pcie, +void __iomem *cfg_data_p) {int timeout =CFG_RETRY_STATUS_TIMEOUT_US ;unsigned int data; +u32 status;/* * As per PCIe spec r3.1, sec 2.3.2, CRS Software Visibility only
@@ -498,6 +508,15 @@ static unsigned int iproc_pcie_cfg_retry(void __iomem *cfg_data_p)*/ data =readl (cfg_data_p);while (data ==CFG_RETRY_STATUS && timeout--) { +/* +* CRS state is set in CFG_RD status register +* This will handle the case where CFG_RETRY_STATUS is +* valid config data. +*/ + status =iproc_pcie_read_reg (pcie,IPROC_PCIE_CFG_RD_STATUS ); +if (status !=CFG_RD_CRS ) +return data; +udelay (1 ); data =readl (cfg_data_p); }
@@ -576,7 +595,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn,if (!cfg_data_p)return PCIBIOS_DEVICE_NOT_FOUND ; - data =iproc_pcie_cfg_retry (cfg_data_p); + data =iproc_pcie_cfg_retry (pcie, cfg_data_p); *val = data;if (size <=2 )
Signature · 1 line
2.7.4
Re: [PATCH v2 1/2] PCI: iproc: Add CRS check in config read
Quoted 39 lines · Srinath Mannam
In the current implementation, config read output data
0xffff0001is assumed as CRS completion. But sometimes0xffff0001can be a valid data.IPROC PCIe host controller has a register to show config read request status flags like SC, UR, CRS and CA. So that extra check is added to confirm the CRS using status flags before reissue config read.
Signed-off-by Srinath Mannam <[email protected]>Reviewed-by Ray Jui <[email protected]>--- drivers/pci/controller/pcie-iproc.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-iproc.c +7
-0@@ -60,6 +60,10 @@#define APB_ERR_EN_SHIFT 0#define APB_ERR_EN BIT(APB_ERR_EN_SHIFT) +#define CFG_RD_SUCCESS 0 +#define CFG_RD_UR 1 +#define CFG_RD_CRS 2 +#define CFG_RD_CA 3#define CFG_RETRY_STATUS 0xffff0001#define CFG_RETRY_STATUS_TIMEOUT_US 500000/* 500 milliseconds */ @@ -289,6 +293,9 @@ enum iproc_pcie_reg {IPROC_PCIE_IARR4 ,IPROC_PCIE_IMAP4 , +/* config read status */ +IPROC_PCIE_CFG_RD_STATUS , +/* link status */ IPROC_PCIE_LINK_STATUS,
drivers/pci/controller/pcie-iproc.c static const u16 iproc_pcie_reg_paxb_v2[] = { · line 360
Quoted 4 lines
drivers/pci/controller/pcie-iproc.c +1
-0@@ -350,6 +357,7 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { [IPROC_PCIE_IMAP3] = 0xe08, [IPROC_PCIE_IARR4] = 0xe68, [IPROC_PCIE_IMAP4] = 0xe70, + [IPROC_PCIE_CFG_RD_STATUS] = 0xee0,
So, with the *current* code, on controllers that does not support this register you won't be able to get any HW whose config space register value reads 0xffff0001 to work, is that correct ?
Lorenzo
Quoted 45 lines
drivers/pci/controller/pcie-iproc.c +13
-2[IPROC_PCIE_LINK_STATUS] = 0xf0c, [IPROC_PCIE_APB_ERR_EN] = 0xf40, };@@ -474,10 +482,12 @@ static void __iomem *iproc_pcie_map_ep_cfg_reg(struct iproc_pcie *pcie,return (pcie->base + offset); } -static unsigned int iproc_pcie_cfg_retry (void __iomem *cfg_data_p) +static unsigned int iproc_pcie_cfg_retry (struct iproc_pcie *pcie, +void __iomem *cfg_data_p) {int timeout =CFG_RETRY_STATUS_TIMEOUT_US ;unsigned int data; +u32 status;/* * As per PCIe spec r3.1, sec 2.3.2, CRS Software Visibility only @@ -498,6 +508,15 @@ static unsigned int iproc_pcie_cfg_retry(void __iomem *cfg_data_p)*/ data =readl (cfg_data_p);while (data ==CFG_RETRY_STATUS && timeout--) { +/* +* CRS state is set in CFG_RD status register +* This will handle the case where CFG_RETRY_STATUS is +* valid config data. +*/ + status =iproc_pcie_read_reg (pcie,IPROC_PCIE_CFG_RD_STATUS ); +if (status !=CFG_RD_CRS ) +return data; +udelay (1 ); data =readl (cfg_data_p); }@@ -576,7 +595,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn,if (!cfg_data_p)return PCIBIOS_DEVICE_NOT_FOUND ; - data =iproc_pcie_cfg_retry (cfg_data_p); + data =iproc_pcie_cfg_retry (pcie, cfg_data_p); *val = data;if (size <=2 )Signature · 1 line
2.7.4
Re: [PATCH v2 1/2] PCI: iproc: Add CRS check in config read
Hi Lorenzo,
Thanks for review, please see my comments below inline.
Quoted 40 lines · Lorenzo Pieralisi
Quoted 38 lines · Srinath Mannam
In the current implementation, config read output data
0xffff0001is assumed as CRS completion. But sometimes0xffff0001can be a valid data.IPROC PCIe host controller has a register to show config read request status flags like SC, UR, CRS and CA. So that extra check is added to confirm the CRS using status flags before reissue config read.
Signed-off-by Srinath Mannam <[email protected]>Reviewed-by Ray Jui <[email protected]>--- drivers/pci/controller/pcie-iproc.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-iproc.c +7
-0@@ -60,6 +60,10 @@#define APB_ERR_EN_SHIFT 0#define APB_ERR_EN BIT(APB_ERR_EN_SHIFT) +#define CFG_RD_SUCCESS 0 +#define CFG_RD_UR 1 +#define CFG_RD_CRS 2 +#define CFG_RD_CA 3#define CFG_RETRY_STATUS 0xffff0001#define CFG_RETRY_STATUS_TIMEOUT_US 500000/* 500 milliseconds */ @@ -289,6 +293,9 @@ enum iproc_pcie_reg {IPROC_PCIE_IARR4 ,IPROC_PCIE_IMAP4 , +/* config read status */ +IPROC_PCIE_CFG_RD_STATUS , +/* link status */ IPROC_PCIE_LINK_STATUS,
Quoted 10 lines
drivers/pci/controller/pcie-iproc.c static const u16 iproc_pcie_reg_paxb_v2[] = { · line 360
Quoted 5 lines
drivers/pci/controller/pcie-iproc.c +1
-0@@ -350,6 +357,7 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { [IPROC_PCIE_IMAP3] = 0xe08, [IPROC_PCIE_IARR4] = 0xe68, [IPROC_PCIE_IMAP4] = 0xe70, + [IPROC_PCIE_CFG_RD_STATUS] = 0xee0,So, with the *current* code, on controllers that does not support this register you won't be able to get any HW whose config space register value reads
0xffff0001to work, is that correct ?
Yes, this feature(register) is available only in "iProc PCIe PAXB v2" controller for other controllers it will not applicable.
Regards,
Srinath.
Quoted 47 lines
Lorenzo
Quoted 45 lines
drivers/pci/controller/pcie-iproc.c +13
-3[IPROC_PCIE_LINK_STATUS] = 0xf0c, [IPROC_PCIE_APB_ERR_EN] = 0xf40, };@@ -474,10 +482,12 @@ static void __iomem *iproc_pcie_map_ep_cfg_reg(struct iproc_pcie *pcie,return (pcie->base + offset); } -static unsigned int iproc_pcie_cfg_retry (void __iomem *cfg_data_p) +static unsigned int iproc_pcie_cfg_retry (struct iproc_pcie *pcie, +void __iomem *cfg_data_p) {int timeout =CFG_RETRY_STATUS_TIMEOUT_US ;unsigned int data; +u32 status;/* * As per PCIe spec r3.1, sec 2.3.2, CRS Software Visibility only @@ -498,6 +508,15 @@ static unsigned int iproc_pcie_cfg_retry(void __iomem *cfg_data_p)*/ data =readl (cfg_data_p);while (data ==CFG_RETRY_STATUS && timeout--) { +/* +* CRS state is set in CFG_RD status register +* This will handle the case where CFG_RETRY_STATUS is +* valid config data. +*/ + status =iproc_pcie_read_reg (pcie,IPROC_PCIE_CFG_RD_STATUS ); +if (status !=CFG_RD_CRS ) +return data; +udelay (1 ); data =readl (cfg_data_p); }@@ -576,7 +595,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn,if (!cfg_data_p)return PCIBIOS_DEVICE_NOT_FOUND ; - data =iproc_pcie_cfg_retry (cfg_data_p); + data =iproc_pcie_cfg_retry (pcie, cfg_data_p); *val = data;if (size <=2 ) --2.7.4
PATCH v2 2/2 PCI: iproc: Add PCIe 32bit outbound memory configuration
In reply to Srinath MannamAdd configuration to support IPROC PCIe host controller outbound memory window mapping with SOC address range inside 4GB boundary, which is 32 bit AXI address.
--- drivers/pci/controller/pcie-iproc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-iproc.c +19 -2
@@ -955,8 +955,25 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr,resource_size_t window_size = ob_map->window_sizes[size_idx] *SZ_1M ; -if (size < window_size) -continue ; +/* +* Keep iterating until we reach the last window and +* with the minimal window size at index zero. In this +* case, we take a compromise by mapping it using the +* minimum window size that can be supported +*/ +if (size < window_size) { +if (size_idx >0 || window_idx >0 ) +continue ; + +/* +* For the corner case of reaching the minimal +* window size that can be supported on the +* last window +*/ + axi_addr =ALIGN_DOWN (axi_addr, window_size); + pci_addr =ALIGN_DOWN (pci_addr, window_size); + size = window_size; + }if (!IS_ALIGNED (axi_addr, window_size) || !IS_ALIGNED (pci_addr, window_size)) {
Signature · 1 line
2.7.4
Re: [PATCH v2 2/2] PCI: iproc: Add PCIe 32bit outbound memory configuration
Quoted 3 lines · Srinath Mannam
Add configuration to support IPROC PCIe host controller outbound memory window mapping with SOC address range inside 4GB boundary, which is 32 bit AXI address.
I do not understand what this means, explain it to me and rewrite the commit log accordingly.
What does this solve ? Why do we need this patch or rephrased, what is missing in the current driver ?
Quoted 5 lines
Signed-off-by Srinath Mannam <[email protected]>Signed-off-by Abhishek Shah <[email protected]>Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>Reviewed-by Vikram Prakash <[email protected]>
Review tags should be given on public mailing lists, these ones seem to come from non-public review cycles in which case you must drop them.
Quoted 8 lines
drivers/pci/controller/pcie-iproc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-iproc.c +0
-0
drivers/pci/controller/pcie-iproc.c static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, · line 962
Quoted 10 lines
drivers/pci/controller/pcie-iproc.c +5
-2@@ -955,8 +955,25 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr,resource_size_t window_size = ob_map->window_sizes[size_idx] *SZ_1M ; -if (size < window_size) -continue ; +/* +* Keep iterating until we reach the last window and +* with the minimal window size at index zero. In this +* case, we take a compromise by mapping it using the +* minimum window size that can be supported
See above, I do not understand clearly what this means.
Lorenzo
Quoted 20 lines
drivers/pci/controller/pcie-iproc.c +14
-0+*/ +if (size < window_size) { +if (size_idx >0 || window_idx >0 ) +continue ; + +/* +* For the corner case of reaching the minimal +* window size that can be supported on the +* last window +*/ + axi_addr =ALIGN_DOWN (axi_addr, window_size); + pci_addr =ALIGN_DOWN (pci_addr, window_size); + size = window_size; + }if (!IS_ALIGNED (axi_addr, window_size) || !IS_ALIGNED (pci_addr, window_size)) {Signature · 1 line
2.7.4
Re: [PATCH v2 2/2] PCI: iproc: Add PCIe 32bit outbound memory configuration
Hi Lorenzo,
Thanks for review, please see my comments below inline.
Quoted 9 lines · Lorenzo Pieralisi
Quoted 3 lines · Srinath Mannam
Add configuration to support IPROC PCIe host controller outbound memory window mapping with SOC address range inside 4GB boundary, which is 32 bit AXI address.
I do not understand what this means, explain it to me and rewrite the commit log accordingly.
This is about "I/O regions" addressing given through ranges DT property. In the current driver "I/O regions" address mapping to corresponding PCI memory address in controller outbound registers
is supports above 32-bit address.
Quoted 2 lines
What does this solve ? Why do we need this patch or rephrased, what is missing in the current driver ?
With this patch, If ranges DT property has below 32-bit I/O regions address then it will be added in the outbound mapping. This will help to access I/O region from CPU in 32-bit. I will update commit log and send next patch set.
Ex:
1. ranges DT property for current driver is,
ranges = <0x83000000 0x0 0x40000000 0x4 0x00000000 0 0x40000000>;
I/O region address is 0x400000000
2. ranges DT property with this patch,
ranges = <0x83000000 0x0 0x42000000 0x0 0x42000000 0 0x2000000>;
I/O region address is 0x42000000Regards,
Srinath.
Quoted 54 lines
Quoted 6 lines
Signed-off-by Srinath Mannam <[email protected]>Signed-off-by Abhishek Shah <[email protected]>Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>Reviewed-by Vikram Prakash <[email protected]>Review tags should be given on public mailing lists, these ones seem to come from non-public review cycles in which case you must drop them.
Quoted 8 lines
drivers/pci/controller/pcie-iproc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-iproc.c +0
-0drivers/pci/controller/pcie-iproc.c static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, · line 962
Quoted 10 lines
drivers/pci/controller/pcie-iproc.c +5
-2@@ -955,8 +955,25 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr,resource_size_t window_size = ob_map->window_sizes[size_idx] *SZ_1M ; -if (size < window_size) -continue ; +/* +* Keep iterating until we reach the last window and +* with the minimal window size at index zero. In this +* case, we take a compromise by mapping it using the +* minimum window size that can be supported See above, I do not understand clearly what this means.
Lorenzo
Quoted 20 lines
drivers/pci/controller/pcie-iproc.c +14
-1+*/ +if (size < window_size) { +if (size_idx >0 || window_idx >0 ) +continue ; + +/* +* For the corner case of reaching the minimal +* window size that can be supported on the +* last window +*/ + axi_addr =ALIGN_DOWN (axi_addr, window_size); + pci_addr =ALIGN_DOWN (pci_addr, window_size); + size = window_size; + }if (!IS_ALIGNED (axi_addr, window_size) || !IS_ALIGNED (pci_addr, window_size)) { --2.7.4
v2 cover Add IPROC PCIe new features
In reply to Srinath MannamThis patch set extends support of new IPROC PCIe host controller features
- Add CRS state check using controller register status flags
- Add 32bit outbound window mapping configuration
This patch set is based on Linux-5.0-rc2.
Changes from v1:
- Addressed Bjorn Helgaas comments.
- Removed set order mode patch from patchset.
Srinath Mannam (2):
PCI: iproc: Add CRS state check in config read
PCI: iproc: Add PCIe 32bit outbound memory configuration
drivers/pci/controller/pcie-iproc.c | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4