All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read()
@ 2015-09-10 14:58 Gabriele Paoloni
  2015-09-10 14:58 ` [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Gabriele Paoloni @ 2015-09-10 14:58 UTC (permalink / raw)
  To: bhelgaas, jingoohan1, pratyush.anand
  Cc: linux-pci, gabriele.paoloni, wangzhou1, yuanzhichang, zhudacai,
	zhangjukuo, qiuzhenfa, liguozhu

From: gabriele paoloni <gabriele.paoloni@huawei.com>

This patchset:
1) fixes a bug in spear13xx when calling dw_pcie_cfg_read and
   dw_pcie_cfg_write;
2) reworks dw_pcie_cfg_read/dw_pcie_cfg_write in pcie-designware.c in
   order to make it easier for callers to pass input parameters;
3) adds sanity checks in dw_pcie_cfg_read/dw_pcie_cfg_write to make
   sure the PCI header offset does not conflict with the size of
   the read/written field.

gabriele paoloni (3):
  PCIE: spear13xx: fix addresses in dw_pcie_cfg_read and
    dw_pcie_cfg_write
  PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read()
  PCIE: designware: add sanity checks on the header offset in
    dw_pcie_cfg_read and dw_pcie_cfg_write

 drivers/pci/host/pci-exynos.c      |  5 ++--
 drivers/pci/host/pci-keystone-dw.c |  4 ++--
 drivers/pci/host/pcie-designware.c | 47 +++++++++++++++++++++++---------------
 3 files changed, 32 insertions(+), 24 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write
  2015-09-10 14:58 [PATCH v2 0/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
@ 2015-09-10 14:58 ` Gabriele Paoloni
  2015-09-10 16:30   ` Pratyush Anand
  2015-09-10 14:58 ` [PATCH v2 2/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
  2015-09-10 14:58 ` [PATCH v2 3/3] PCI: designware: add sanity checks on the header offset in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
  2 siblings, 1 reply; 6+ messages in thread
From: Gabriele Paoloni @ 2015-09-10 14:58 UTC (permalink / raw)
  To: bhelgaas, jingoohan1, pratyush.anand
  Cc: linux-pci, gabriele.paoloni, wangzhou1, yuanzhichang, zhudacai,
	zhangjukuo, qiuzhenfa, liguozhu

From: gabriele paoloni <gabriele.paoloni@huawei.com>

Currently spear13xx passes the wrong "address" in many calls to
dw_pcie_cfg_read and dw_pcie_cfg_write: the passed address is
always pp->dbi_base, that is wrong as it does not consider
the offset to access the right register of the PCI header.
This patches fixes these function calls passing the address to
access the right register.

Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
---
 drivers/pci/host/pcie-spear13xx.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/host/pcie-spear13xx.c b/drivers/pci/host/pcie-spear13xx.c
index c49fbdc..5f3513b 100644
--- a/drivers/pci/host/pcie-spear13xx.c
+++ b/drivers/pci/host/pcie-spear13xx.c
@@ -146,6 +146,7 @@ struct pcie_app_reg {
 static int spear13xx_pcie_establish_link(struct pcie_port *pp)
 {
 	u32 val;
+	int where;
 	struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
 	struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
 	u32 exp_cap_off = EXP_CAP_ID_OFFSET;
@@ -163,9 +164,10 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp)
 	 * default value in capability register is 512 bytes. So force
 	 * it to 128 here.
 	 */
-	dw_pcie_cfg_read(pp->dbi_base, exp_cap_off + PCI_EXP_DEVCTL, 4, &val);
+	where = exp_cap_off + PCI_EXP_DEVCTL;
+	dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, 4, &val);
 	val &= ~PCI_EXP_DEVCTL_READRQ;
-	dw_pcie_cfg_write(pp->dbi_base, exp_cap_off + PCI_EXP_DEVCTL, 4, val);
+	dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3), where, 4, val);
 
 	dw_pcie_cfg_write(pp->dbi_base, PCI_VENDOR_ID, 2, 0x104A);
 	dw_pcie_cfg_write(pp->dbi_base, PCI_DEVICE_ID, 2, 0xCD80);
@@ -175,22 +177,24 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp)
 	 * also works
 	 */
 	if (spear13xx_pcie->is_gen1) {
-		dw_pcie_cfg_read(pp->dbi_base, exp_cap_off + PCI_EXP_LNKCAP, 4,
+		where = exp_cap_off + PCI_EXP_LNKCAP;
+		dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, 4,
 				 &val);
 		if ((val & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) {
 			val &= ~((u32)PCI_EXP_LNKCAP_SLS);
 			val |= PCI_EXP_LNKCAP_SLS_2_5GB;
-			dw_pcie_cfg_write(pp->dbi_base, exp_cap_off +
-					  PCI_EXP_LNKCAP, 4, val);
+			dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3),
+					where, 4, val);
 		}
 
-		dw_pcie_cfg_read(pp->dbi_base, exp_cap_off + PCI_EXP_LNKCTL2, 4,
+		where = exp_cap_off + PCI_EXP_LNKCTL2;
+		dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, 4,
 				 &val);
 		if ((val & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) {
 			val &= ~((u32)PCI_EXP_LNKCAP_SLS);
 			val |= PCI_EXP_LNKCAP_SLS_2_5GB;
-			dw_pcie_cfg_write(pp->dbi_base, exp_cap_off +
-					  PCI_EXP_LNKCTL2, 4, val);
+			dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3),
+					where, 4, val);
 		}
 	}
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read()
  2015-09-10 14:58 [PATCH v2 0/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
  2015-09-10 14:58 ` [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
@ 2015-09-10 14:58 ` Gabriele Paoloni
  2015-09-10 14:58 ` [PATCH v2 3/3] PCI: designware: add sanity checks on the header offset in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
  2 siblings, 0 replies; 6+ messages in thread
From: Gabriele Paoloni @ 2015-09-10 14:58 UTC (permalink / raw)
  To: bhelgaas, jingoohan1, pratyush.anand
  Cc: linux-pci, gabriele.paoloni, wangzhou1, yuanzhichang, zhudacai,
	zhangjukuo, qiuzhenfa, liguozhu

From: gabriele paoloni <gabriele.paoloni@huawei.com>

This patch changes the implementation of dw_pcie_cfg_read() and
dw_pcie_cfg_write() to improve the function usage from the callers
perspective.
Currently the callers are obliged to pass the 32bit aligned address
of the register that contains the field of the PCI header that they
want to read/write; also they have to pass the offset of the field
in that register. This is quite tricky to use as the callers are
obliged to sum the PCI header base address to the field offset
masked to retrieve the 32b aligned register address.

With the new API the callers have to pass the base address of the
PCI header and the offset corresponding to the field they intend to
read/write.

Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
---
 drivers/pci/host/pci-exynos.c      |  5 ++---
 drivers/pci/host/pci-keystone-dw.c |  4 ++--
 drivers/pci/host/pcie-designware.c | 28 ++++++++++++++--------------
 drivers/pci/host/pcie-spear13xx.c  | 20 ++++++++------------
 4 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c
index f9f468d..8b0e04b 100644
--- a/drivers/pci/host/pci-exynos.c
+++ b/drivers/pci/host/pci-exynos.c
@@ -454,7 +454,7 @@ static int exynos_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
 	int ret;
 
 	exynos_pcie_sideband_dbi_r_mode(pp, true);
-	ret = dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, size, val);
+	ret = dw_pcie_cfg_read(pp->dbi_base, where, size, val);
 	exynos_pcie_sideband_dbi_r_mode(pp, false);
 	return ret;
 }
@@ -465,8 +465,7 @@ static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
 	int ret;
 
 	exynos_pcie_sideband_dbi_w_mode(pp, true);
-	ret = dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3),
-			where, size, val);
+	ret = dw_pcie_cfg_write(pp->dbi_base, where, size, val);
 	exynos_pcie_sideband_dbi_w_mode(pp, false);
 	return ret;
 }
diff --git a/drivers/pci/host/pci-keystone-dw.c b/drivers/pci/host/pci-keystone-dw.c
index f34892e..2b391f4 100644
--- a/drivers/pci/host/pci-keystone-dw.c
+++ b/drivers/pci/host/pci-keystone-dw.c
@@ -403,7 +403,7 @@ int ks_dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 
 	addr = ks_pcie_cfg_setup(ks_pcie, bus_num, devfn);
 
-	return dw_pcie_cfg_read(addr + (where & ~0x3), where, size, val);
+	return dw_pcie_cfg_read(addr, where, size, val);
 }
 
 int ks_dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
@@ -415,7 +415,7 @@ int ks_dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 
 	addr = ks_pcie_cfg_setup(ks_pcie, bus_num, devfn);
 
-	return dw_pcie_cfg_write(addr + (where & ~0x3), where, size, val);
+	return dw_pcie_cfg_write(addr, where, size, val);
 }
 
 /**
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 69486be..4f8ff80 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -82,12 +82,14 @@ static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys)
 
 int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val)
 {
+	addr += (where & ~0x3);
 	*val = readl(addr);
+	where &= 3;
 
 	if (size == 1)
-		*val = (*val >> (8 * (where & 3))) & 0xff;
+		*val = (*val >> (8 * where)) & 0xff;
 	else if (size == 2)
-		*val = (*val >> (8 * (where & 3))) & 0xffff;
+		*val = (*val >> (8 * where)) & 0xffff;
 	else if (size != 4)
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
@@ -96,12 +98,14 @@ int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val)
 
 int dw_pcie_cfg_write(void __iomem *addr, int where, int size, u32 val)
 {
+	addr += where;
+
 	if (size == 4)
 		writel(val, addr);
 	else if (size == 2)
-		writew(val, addr + (where & 2));
+		writew(val, addr);
 	else if (size == 1)
-		writeb(val, addr + (where & 3));
+		writeb(val, addr);
 	else
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
@@ -132,8 +136,7 @@ static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
 	if (pp->ops->rd_own_conf)
 		ret = pp->ops->rd_own_conf(pp, where, size, val);
 	else
-		ret = dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where,
-				size, val);
+		ret = dw_pcie_cfg_read(pp->dbi_base, where, size, val);
 
 	return ret;
 }
@@ -146,8 +149,7 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
 	if (pp->ops->wr_own_conf)
 		ret = pp->ops->wr_own_conf(pp, where, size, val);
 	else
-		ret = dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3), where,
-				size, val);
+		ret = dw_pcie_cfg_write(pp->dbi_base, where, size, val);
 
 	return ret;
 }
@@ -541,13 +543,12 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 		u32 devfn, int where, int size, u32 *val)
 {
 	int ret, type;
-	u32 address, busdev, cfg_size;
+	u32 busdev, cfg_size;
 	u64 cpu_addr;
 	void __iomem *va_cfg_base;
 
 	busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
 		 PCIE_ATU_FUNC(PCI_FUNC(devfn));
-	address = where & ~0x3;
 
 	if (bus->parent->number == pp->root_bus_nr) {
 		type = PCIE_ATU_TYPE_CFG0;
@@ -564,7 +565,7 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 	dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
 				  type, cpu_addr,
 				  busdev, cfg_size);
-	ret = dw_pcie_cfg_read(va_cfg_base + address, where, size, val);
+	ret = dw_pcie_cfg_read(va_cfg_base, where, size, val);
 	dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
 				  PCIE_ATU_TYPE_IO, pp->io_mod_base,
 				  pp->io_bus_addr, pp->io_size);
@@ -576,13 +577,12 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 		u32 devfn, int where, int size, u32 val)
 {
 	int ret, type;
-	u32 address, busdev, cfg_size;
+	u32 busdev, cfg_size;
 	u64 cpu_addr;
 	void __iomem *va_cfg_base;
 
 	busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
 		 PCIE_ATU_FUNC(PCI_FUNC(devfn));
-	address = where & ~0x3;
 
 	if (bus->parent->number == pp->root_bus_nr) {
 		type = PCIE_ATU_TYPE_CFG0;
@@ -599,7 +599,7 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 	dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
 				  type, cpu_addr,
 				  busdev, cfg_size);
-	ret = dw_pcie_cfg_write(va_cfg_base + address, where, size, val);
+	ret = dw_pcie_cfg_write(va_cfg_base, where, size, val);
 	dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
 				  PCIE_ATU_TYPE_IO, pp->io_mod_base,
 				  pp->io_bus_addr, pp->io_size);
diff --git a/drivers/pci/host/pcie-spear13xx.c b/drivers/pci/host/pcie-spear13xx.c
index 5f3513b..c49fbdc 100644
--- a/drivers/pci/host/pcie-spear13xx.c
+++ b/drivers/pci/host/pcie-spear13xx.c
@@ -146,7 +146,6 @@ struct pcie_app_reg {
 static int spear13xx_pcie_establish_link(struct pcie_port *pp)
 {
 	u32 val;
-	int where;
 	struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pp);
 	struct pcie_app_reg *app_reg = spear13xx_pcie->app_base;
 	u32 exp_cap_off = EXP_CAP_ID_OFFSET;
@@ -164,10 +163,9 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp)
 	 * default value in capability register is 512 bytes. So force
 	 * it to 128 here.
 	 */
-	where = exp_cap_off + PCI_EXP_DEVCTL;
-	dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, 4, &val);
+	dw_pcie_cfg_read(pp->dbi_base, exp_cap_off + PCI_EXP_DEVCTL, 4, &val);
 	val &= ~PCI_EXP_DEVCTL_READRQ;
-	dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3), where, 4, val);
+	dw_pcie_cfg_write(pp->dbi_base, exp_cap_off + PCI_EXP_DEVCTL, 4, val);
 
 	dw_pcie_cfg_write(pp->dbi_base, PCI_VENDOR_ID, 2, 0x104A);
 	dw_pcie_cfg_write(pp->dbi_base, PCI_DEVICE_ID, 2, 0xCD80);
@@ -177,24 +175,22 @@ static int spear13xx_pcie_establish_link(struct pcie_port *pp)
 	 * also works
 	 */
 	if (spear13xx_pcie->is_gen1) {
-		where = exp_cap_off + PCI_EXP_LNKCAP;
-		dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, 4,
+		dw_pcie_cfg_read(pp->dbi_base, exp_cap_off + PCI_EXP_LNKCAP, 4,
 				 &val);
 		if ((val & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) {
 			val &= ~((u32)PCI_EXP_LNKCAP_SLS);
 			val |= PCI_EXP_LNKCAP_SLS_2_5GB;
-			dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3),
-					where, 4, val);
+			dw_pcie_cfg_write(pp->dbi_base, exp_cap_off +
+					  PCI_EXP_LNKCAP, 4, val);
 		}
 
-		where = exp_cap_off + PCI_EXP_LNKCTL2;
-		dw_pcie_cfg_read(pp->dbi_base + (where & ~0x3), where, 4,
+		dw_pcie_cfg_read(pp->dbi_base, exp_cap_off + PCI_EXP_LNKCTL2, 4,
 				 &val);
 		if ((val & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) {
 			val &= ~((u32)PCI_EXP_LNKCAP_SLS);
 			val |= PCI_EXP_LNKCAP_SLS_2_5GB;
-			dw_pcie_cfg_write(pp->dbi_base + (where & ~0x3),
-					where, 4, val);
+			dw_pcie_cfg_write(pp->dbi_base, exp_cap_off +
+					  PCI_EXP_LNKCTL2, 4, val);
 		}
 	}
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] PCI: designware: add sanity checks on the header offset in dw_pcie_cfg_read and dw_pcie_cfg_write
  2015-09-10 14:58 [PATCH v2 0/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
  2015-09-10 14:58 ` [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
  2015-09-10 14:58 ` [PATCH v2 2/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
@ 2015-09-10 14:58 ` Gabriele Paoloni
  2 siblings, 0 replies; 6+ messages in thread
From: Gabriele Paoloni @ 2015-09-10 14:58 UTC (permalink / raw)
  To: bhelgaas, jingoohan1, pratyush.anand
  Cc: linux-pci, gabriele.paoloni, wangzhou1, yuanzhichang, zhudacai,
	zhangjukuo, qiuzhenfa, liguozhu

From: gabriele paoloni <gabriele.paoloni@huawei.com>

This patch adds sanity checks on "where" input parameter in
dw_pcie_cfg_read and dw_pcie_cfg_write. These checks make sure
that offset passed in by the caller is not in conflict with
the size of the PCI header field that is being read/written

Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
---
 drivers/pci/host/pcie-designware.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 4f8ff80..c0825b7 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -88,9 +88,14 @@ int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val)
 
 	if (size == 1)
 		*val = (*val >> (8 * where)) & 0xff;
-	else if (size == 2)
+	else if (size == 2) {
+		if (where & 1)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
 		*val = (*val >> (8 * where)) & 0xffff;
-	else if (size != 4)
+	} else if (size == 4) {
+		if (where & 3)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
+	} else
 		return PCIBIOS_BAD_REGISTER_NUMBER;
 
 	return PCIBIOS_SUCCESSFUL;
@@ -100,11 +105,15 @@ int dw_pcie_cfg_write(void __iomem *addr, int where, int size, u32 val)
 {
 	addr += where;
 
-	if (size == 4)
+	if (size == 4) {
+		if ((uintptr_t)addr & 3)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
 		writel(val, addr);
-	else if (size == 2)
+	} else if (size == 2) {
+		if ((uintptr_t)addr & 1)
+			return PCIBIOS_BAD_REGISTER_NUMBER;
 		writew(val, addr);
-	else if (size == 1)
+	} else if (size == 1)
 		writeb(val, addr);
 	else
 		return PCIBIOS_BAD_REGISTER_NUMBER;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write
  2015-09-10 14:58 ` [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
@ 2015-09-10 16:30   ` Pratyush Anand
  2015-09-10 16:41     ` Gabriele Paoloni
  0 siblings, 1 reply; 6+ messages in thread
From: Pratyush Anand @ 2015-09-10 16:30 UTC (permalink / raw)
  To: Gabriele Paoloni, Bjorn Helgaas
  Cc: Jingoo Han, linux-pci, Zhou Wang, Zhichang Yuan, zhudacai,
	Zhang Jukuo, qiuzhenfa, Liguozhu

Hi Gab,

On Thu, Sep 10, 2015 at 8:28 PM, Gabriele Paoloni
<gabriele.paoloni@huawei.com> wrote:
> From: gabriele paoloni <gabriele.paoloni@huawei.com>
>
> Currently spear13xx passes the wrong "address" in many calls to
> dw_pcie_cfg_read and dw_pcie_cfg_write: the passed address is
> always pp->dbi_base, that is wrong as it does not consider
> the offset to access the right register of the PCI header.
> This patches fixes these function calls passing the address to
> access the right register.

Thanks for the effort, however there were some more issues with
current implementation.
Like PCI_EXP_DEVCTL is only two bytes of register. Next two bytes are
PCI_EXP_DEVSTS which is RO, so writing 4 bytes at offset 'exp_cap_off
+ PCI_EXP_DEVCTL' is not correct.

I had sent a patch to correct all the issues with current
implementation [1]. You can take that as your 1st patch.

[1] https://lkml.org/lkml/2015/9/7/5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write
  2015-09-10 16:30   ` Pratyush Anand
@ 2015-09-10 16:41     ` Gabriele Paoloni
  0 siblings, 0 replies; 6+ messages in thread
From: Gabriele Paoloni @ 2015-09-10 16:41 UTC (permalink / raw)
  To: Pratyush Anand, Bjorn Helgaas
  Cc: Jingoo Han, linux-pci, Wangzhou (B),
	Yuanzhichang, Zhudacai, zhangjukuo, qiuzhenfa, Liguozhu (Kenneth)

PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBQcmF0eXVzaCBBbmFuZCBbbWFp
bHRvOnByYXR5dXNoLmFuYW5kQGdtYWlsLmNvbV0NCj4gU2VudDogVGh1cnNkYXksIFNlcHRlbWJl
ciAxMCwgMjAxNSA1OjMwIFBNDQo+IFRvOiBHYWJyaWVsZSBQYW9sb25pOyBCam9ybiBIZWxnYWFz
DQo+IENjOiBKaW5nb28gSGFuOyBsaW51eC1wY2lAdmdlci5rZXJuZWwub3JnOyBXYW5nemhvdSAo
Qik7IFl1YW56aGljaGFuZzsNCj4gWmh1ZGFjYWk7IHpoYW5nanVrdW87IHFpdXpoZW5mYTsgTGln
dW96aHUgKEtlbm5ldGgpDQo+IFN1YmplY3Q6IFJlOiBbUEFUQ0ggdjIgMS8zXSBQQ0k6IHNwZWFy
MTN4eDogZml4IGFkZHJlc3NlcyBpbg0KPiBkd19wY2llX2NmZ19yZWFkIGFuZCBkd19wY2llX2Nm
Z193cml0ZQ0KPiANCj4gSGkgR2FiLA0KPiANCj4gT24gVGh1LCBTZXAgMTAsIDIwMTUgYXQgODoy
OCBQTSwgR2FicmllbGUgUGFvbG9uaQ0KPiA8Z2FicmllbGUucGFvbG9uaUBodWF3ZWkuY29tPiB3
cm90ZToNCj4gPiBGcm9tOiBnYWJyaWVsZSBwYW9sb25pIDxnYWJyaWVsZS5wYW9sb25pQGh1YXdl
aS5jb20+DQo+ID4NCj4gPiBDdXJyZW50bHkgc3BlYXIxM3h4IHBhc3NlcyB0aGUgd3JvbmcgImFk
ZHJlc3MiIGluIG1hbnkgY2FsbHMgdG8NCj4gPiBkd19wY2llX2NmZ19yZWFkIGFuZCBkd19wY2ll
X2NmZ193cml0ZTogdGhlIHBhc3NlZCBhZGRyZXNzIGlzDQo+ID4gYWx3YXlzIHBwLT5kYmlfYmFz
ZSwgdGhhdCBpcyB3cm9uZyBhcyBpdCBkb2VzIG5vdCBjb25zaWRlcg0KPiA+IHRoZSBvZmZzZXQg
dG8gYWNjZXNzIHRoZSByaWdodCByZWdpc3RlciBvZiB0aGUgUENJIGhlYWRlci4NCj4gPiBUaGlz
IHBhdGNoZXMgZml4ZXMgdGhlc2UgZnVuY3Rpb24gY2FsbHMgcGFzc2luZyB0aGUgYWRkcmVzcyB0
bw0KPiA+IGFjY2VzcyB0aGUgcmlnaHQgcmVnaXN0ZXIuDQo+IA0KPiBUaGFua3MgZm9yIHRoZSBl
ZmZvcnQsIGhvd2V2ZXIgdGhlcmUgd2VyZSBzb21lIG1vcmUgaXNzdWVzIHdpdGgNCj4gY3VycmVu
dCBpbXBsZW1lbnRhdGlvbi4NCj4gTGlrZSBQQ0lfRVhQX0RFVkNUTCBpcyBvbmx5IHR3byBieXRl
cyBvZiByZWdpc3Rlci4gTmV4dCB0d28gYnl0ZXMgYXJlDQo+IFBDSV9FWFBfREVWU1RTIHdoaWNo
IGlzIFJPLCBzbyB3cml0aW5nIDQgYnl0ZXMgYXQgb2Zmc2V0ICdleHBfY2FwX29mZg0KPiArIFBD
SV9FWFBfREVWQ1RMJyBpcyBub3QgY29ycmVjdC4NCj4gDQo+IEkgaGFkIHNlbnQgYSBwYXRjaCB0
byBjb3JyZWN0IGFsbCB0aGUgaXNzdWVzIHdpdGggY3VycmVudA0KPiBpbXBsZW1lbnRhdGlvbiBb
MV0uIFlvdSBjYW4gdGFrZSB0aGF0IGFzIHlvdXIgMXN0IHBhdGNoLg0KDQpPb3BzIFNvcnJ5LCBJ
IG1pc3NlZCB0aGF0IHBhdGNoIQ0KSSdsbCB0YWtlIGl0IGFzIHBhdGNoIDEsIE1hbnkgVGhhbmtz
DQoNCkdhYg0KDQo+IA0KPiBbMV0gaHR0cHM6Ly9sa21sLm9yZy9sa21sLzIwMTUvOS83LzUNCg==

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-10 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-10 14:58 [PATCH v2 0/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
2015-09-10 14:58 ` [PATCH v2 1/3] PCI: spear13xx: fix addresses in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni
2015-09-10 16:30   ` Pratyush Anand
2015-09-10 16:41     ` Gabriele Paoloni
2015-09-10 14:58 ` [PATCH v2 2/3] PCI: designware: change dw_pcie_cfg_write() and dw_pcie_cfg_read() Gabriele Paoloni
2015-09-10 14:58 ` [PATCH v2 3/3] PCI: designware: add sanity checks on the header offset in dw_pcie_cfg_read and dw_pcie_cfg_write Gabriele Paoloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.