linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] bcma: delete duplicate readl
       [not found] <1357987577-20661-1-git-send-email-nlhintz@hotmail.com>
@ 2013-01-12 10:46 ` Nathan Hintz
  2013-01-12 14:16   ` Hauke Mehrtens
  2013-01-12 10:46 ` [PATCH 2/5] bcma: jump to 'out' label for invalid 'func' value Nathan Hintz
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Nathan Hintz @ 2013-01-12 10:46 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, hauke, Nathan Hintz

The 'val' has already been read by the prior call to 'mips_busprobe32';
this 'readl' is unnecessary.

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
---
 drivers/bcma/driver_pci_host.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 536d353..56073a5 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -122,8 +122,6 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
 			val = 0xffffffff;
 			goto unmap;
 		}
-
-		val = readl(mmio);
 	}
 	val >>= (8 * (off & 3));
 
-- 
1.7.7.6


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

* [PATCH 2/5] bcma: jump to 'out' label for invalid 'func' value
       [not found] <1357987577-20661-1-git-send-email-nlhintz@hotmail.com>
  2013-01-12 10:46 ` [PATCH 1/5] bcma: delete duplicate readl Nathan Hintz
@ 2013-01-12 10:46 ` Nathan Hintz
  2013-01-12 14:18   ` Hauke Mehrtens
  2013-01-12 10:46 ` [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space Nathan Hintz
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Nathan Hintz @ 2013-01-12 10:46 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, hauke, Nathan Hintz

Consistently jump to the 'out' label for error conditions (adds
missing check for 'func' validity in bcma_extpci_write_config).

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
---
 drivers/bcma/driver_pci_host.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 56073a5..187cc9f 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -94,7 +94,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
 	if (dev == 0) {
 		/* we support only two functions on device 0 */
 		if (func > 1)
-			return -EINVAL;
+			goto out;
 
 		/* accesses to config registers with offsets >= 256
 		 * requires indirect access.
@@ -157,6 +157,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 	if (unlikely(len != 1 && len != 2 && len != 4))
 		goto out;
 	if (dev == 0) {
+		/* we support only two functions on device 0 */
+		if (func > 1)
+			goto out;
+
 		/* accesses to config registers with offsets >= 256
 		 * requires indirect access.
 		 */
-- 
1.7.7.6


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

* [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space
       [not found] <1357987577-20661-1-git-send-email-nlhintz@hotmail.com>
  2013-01-12 10:46 ` [PATCH 1/5] bcma: delete duplicate readl Nathan Hintz
  2013-01-12 10:46 ` [PATCH 2/5] bcma: jump to 'out' label for invalid 'func' value Nathan Hintz
@ 2013-01-12 10:46 ` Nathan Hintz
  2013-01-12 14:38   ` Hauke Mehrtens
  2013-01-12 10:46 ` [PATCH 4/5] bcma: add support for 1 and 2 byte extended config space access Nathan Hintz
  2013-01-12 10:46 ` [PATCH 5/5] bcma: use consistent case for 'hex' constants Nathan Hintz
  4 siblings, 1 reply; 11+ messages in thread
From: Nathan Hintz @ 2013-01-12 10:46 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, hauke, Nathan Hintz

For PCI config space access offsets < 256 for device '0',
bcma_extpci_write_config performs an 'ioremap_nocache' on a 4 byte
section of the PCI config space (an area that has already
previously been mapped), and then subsequently unmaps that 4 byte
section.  This can't be a good thing for future read access from
that now unmapped location.  Modify the config space writes to use
the existing access functions (similar to how it is done for the reads).

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
---
 drivers/bcma/driver_pci_host.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 187cc9f..e1381ba 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -149,7 +149,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 				   const void *buf, int len)
 {
 	int err = -EINVAL;
-	u32 addr = 0, val = 0;
+	u32 addr, val;
 	void __iomem *mmio = 0;
 	u16 chipid = pc->core->bus->chipinfo.id;
 
@@ -165,12 +165,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 		 * requires indirect access.
 		 */
 		if (off < PCI_CONFIG_SPACE_SIZE) {
-			addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
+			addr = BCMA_CORE_PCI_PCICFG0;
 			addr |= (func << 8);
 			addr |= (off & 0xfc);
-			mmio = ioremap_nocache(addr, sizeof(val));
-			if (!mmio)
-				goto out;
+			val = pcicore_read32(pc, addr);
 		}
 	} else {
 		addr = bcma_get_cfgspace_addr(pc, dev, func, off);
@@ -189,12 +187,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 
 	switch (len) {
 	case 1:
-		val = readl(mmio);
 		val &= ~(0xFF << (8 * (off & 3)));
 		val |= *((const u8 *)buf) << (8 * (off & 3));
 		break;
 	case 2:
-		val = readl(mmio);
 		val &= ~(0xFFFF << (8 * (off & 3)));
 		val |= *((const u16 *)buf) << (8 * (off & 3));
 		break;
@@ -202,13 +198,17 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 		val = *((const u32 *)buf);
 		break;
 	}
-	if (dev == 0 && !addr) {
+	if (dev == 0) {
 		/* accesses to config registers with offsets >= 256
 		 * requires indirect access.
 		 */
-		addr = (func << 12);
-		addr |= (off & 0x0FFF);
-		bcma_pcie_write_config(pc, addr, val);
+		if (off >= PCI_CONFIG_SPACE_SIZE) {
+			addr = (func << 12);
+			addr |= (off & 0x0FFF);
+			bcma_pcie_write_config(pc, addr, val);
+		} else {
+			pcicore_write32(pc, addr, val);
+		}
 	} else {
 		writel(val, mmio);
 
-- 
1.7.7.6


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

* [PATCH 4/5] bcma: add support for 1 and 2 byte extended config space access
       [not found] <1357987577-20661-1-git-send-email-nlhintz@hotmail.com>
                   ` (2 preceding siblings ...)
  2013-01-12 10:46 ` [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space Nathan Hintz
@ 2013-01-12 10:46 ` Nathan Hintz
  2013-01-12 14:44   ` Hauke Mehrtens
  2013-01-12 10:46 ` [PATCH 5/5] bcma: use consistent case for 'hex' constants Nathan Hintz
  4 siblings, 1 reply; 11+ messages in thread
From: Nathan Hintz @ 2013-01-12 10:46 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, hauke, Nathan Hintz

The sanity checks allow 1 and 2 byte reads/writes of the extended
PCI config space to proceed; however, the code only supports 4
byte reads/writes.  This patch adds support for 1 and 2 byte
reads/writes of the extended PCI config space.

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
---
 drivers/bcma/driver_pci_host.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index e1381ba..92800b4 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -101,7 +101,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
 		 */
 		if (off >= PCI_CONFIG_SPACE_SIZE) {
 			addr = (func << 12);
-			addr |= (off & 0x0FFF);
+			addr |= (off & 0x0FFC);
 			val = bcma_pcie_read_config(pc, addr);
 		} else {
 			addr = BCMA_CORE_PCI_PCICFG0;
@@ -164,7 +164,11 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 		/* accesses to config registers with offsets >= 256
 		 * requires indirect access.
 		 */
-		if (off < PCI_CONFIG_SPACE_SIZE) {
+		if (off >= PCI_CONFIG_SPACE_SIZE) {
+			addr = (func << 12);
+			addr |= (off & 0x0FFC);
+			val = bcma_pcie_read_config(pc, addr);
+		} else {
 			addr = BCMA_CORE_PCI_PCICFG0;
 			addr |= (func << 8);
 			addr |= (off & 0xfc);
@@ -202,13 +206,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 		/* accesses to config registers with offsets >= 256
 		 * requires indirect access.
 		 */
-		if (off >= PCI_CONFIG_SPACE_SIZE) {
-			addr = (func << 12);
-			addr |= (off & 0x0FFF);
+		if (off >= PCI_CONFIG_SPACE_SIZE)
 			bcma_pcie_write_config(pc, addr, val);
-		} else {
+		else
 			pcicore_write32(pc, addr, val);
-		}
 	} else {
 		writel(val, mmio);
 
-- 
1.7.7.6


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

* [PATCH 5/5] bcma: use consistent case for 'hex' constants
       [not found] <1357987577-20661-1-git-send-email-nlhintz@hotmail.com>
                   ` (3 preceding siblings ...)
  2013-01-12 10:46 ` [PATCH 4/5] bcma: add support for 1 and 2 byte extended config space access Nathan Hintz
@ 2013-01-12 10:46 ` Nathan Hintz
  2013-01-12 14:05   ` Hauke Mehrtens
  4 siblings, 1 reply; 11+ messages in thread
From: Nathan Hintz @ 2013-01-12 10:46 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, hauke, Nathan Hintz


Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
---
 drivers/bcma/driver_pci_host.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 92800b4..d3bde6c 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -106,7 +106,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
 		} else {
 			addr = BCMA_CORE_PCI_PCICFG0;
 			addr |= (func << 8);
-			addr |= (off & 0xfc);
+			addr |= (off & 0xFC);
 			val = pcicore_read32(pc, addr);
 		}
 	} else {
@@ -119,7 +119,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
 			goto out;
 
 		if (mips_busprobe32(val, mmio)) {
-			val = 0xffffffff;
+			val = 0xFFFFFFFF;
 			goto unmap;
 		}
 	}
@@ -171,7 +171,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 		} else {
 			addr = BCMA_CORE_PCI_PCICFG0;
 			addr |= (func << 8);
-			addr |= (off & 0xfc);
+			addr |= (off & 0xFC);
 			val = pcicore_read32(pc, addr);
 		}
 	} else {
@@ -184,7 +184,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
 			goto out;
 
 		if (mips_busprobe32(val, mmio)) {
-			val = 0xffffffff;
+			val = 0xFFFFFFFF;
 			goto unmap;
 		}
 	}
@@ -279,7 +279,7 @@ static u8 bcma_find_pci_capability(struct bcma_drv_pci *pc, unsigned int dev,
 	/* check for Header type 0 */
 	bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
 				sizeof(u8));
-	if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
+	if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
 		return cap_ptr;
 
 	/* check if the capability pointer field exists */
-- 
1.7.7.6


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

* Re: [PATCH 5/5] bcma: use consistent case for 'hex' constants
  2013-01-12 10:46 ` [PATCH 5/5] bcma: use consistent case for 'hex' constants Nathan Hintz
@ 2013-01-12 14:05   ` Hauke Mehrtens
  0 siblings, 0 replies; 11+ messages in thread
From: Hauke Mehrtens @ 2013-01-12 14:05 UTC (permalink / raw)
  To: Nathan Hintz; +Cc: linville, linux-wireless

On 01/12/2013 11:46 AM, Nathan Hintz wrote:
> 
> Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>  drivers/bcma/driver_pci_host.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
> index 92800b4..d3bde6c 100644
> --- a/drivers/bcma/driver_pci_host.c
> +++ b/drivers/bcma/driver_pci_host.c
> @@ -106,7 +106,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		} else {
>  			addr = BCMA_CORE_PCI_PCICFG0;
>  			addr |= (func << 8);
> -			addr |= (off & 0xfc);
> +			addr |= (off & 0xFC);
>  			val = pcicore_read32(pc, addr);
>  		}
>  	} else {
> @@ -119,7 +119,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
>  			goto out;
>  
>  		if (mips_busprobe32(val, mmio)) {
> -			val = 0xffffffff;
> +			val = 0xFFFFFFFF;
>  			goto unmap;
>  		}
>  	}
> @@ -171,7 +171,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		} else {
>  			addr = BCMA_CORE_PCI_PCICFG0;
>  			addr |= (func << 8);
> -			addr |= (off & 0xfc);
> +			addr |= (off & 0xFC);
>  			val = pcicore_read32(pc, addr);
>  		}
>  	} else {
> @@ -184,7 +184,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  			goto out;
>  
>  		if (mips_busprobe32(val, mmio)) {
> -			val = 0xffffffff;
> +			val = 0xFFFFFFFF;
>  			goto unmap;
>  		}
>  	}
> @@ -279,7 +279,7 @@ static u8 bcma_find_pci_capability(struct bcma_drv_pci *pc, unsigned int dev,
>  	/* check for Header type 0 */
>  	bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
>  				sizeof(u8));
> -	if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
> +	if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
>  		return cap_ptr;
>  
>  	/* check if the capability pointer field exists */
> 


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

* Re: [PATCH 1/5] bcma: delete duplicate readl
  2013-01-12 10:46 ` [PATCH 1/5] bcma: delete duplicate readl Nathan Hintz
@ 2013-01-12 14:16   ` Hauke Mehrtens
  0 siblings, 0 replies; 11+ messages in thread
From: Hauke Mehrtens @ 2013-01-12 14:16 UTC (permalink / raw)
  To: Nathan Hintz; +Cc: linville, linux-wireless

On 01/12/2013 11:46 AM, Nathan Hintz wrote:
> The 'val' has already been read by the prior call to 'mips_busprobe32';
> this 'readl' is unnecessary.
> 
> Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>  drivers/bcma/driver_pci_host.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
> index 536d353..56073a5 100644
> --- a/drivers/bcma/driver_pci_host.c
> +++ b/drivers/bcma/driver_pci_host.c
> @@ -122,8 +122,6 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
>  			val = 0xffffffff;
>  			goto unmap;
>  		}
> -
> -		val = readl(mmio);
>  	}
>  	val >>= (8 * (off & 3));
>  
> 


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

* Re: [PATCH 2/5] bcma: jump to 'out' label for invalid 'func' value
  2013-01-12 10:46 ` [PATCH 2/5] bcma: jump to 'out' label for invalid 'func' value Nathan Hintz
@ 2013-01-12 14:18   ` Hauke Mehrtens
  0 siblings, 0 replies; 11+ messages in thread
From: Hauke Mehrtens @ 2013-01-12 14:18 UTC (permalink / raw)
  To: Nathan Hintz; +Cc: linville, linux-wireless

On 01/12/2013 11:46 AM, Nathan Hintz wrote:
> Consistently jump to the 'out' label for error conditions (adds
> missing check for 'func' validity in bcma_extpci_write_config).
> 
> Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>  drivers/bcma/driver_pci_host.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
> index 56073a5..187cc9f 100644
> --- a/drivers/bcma/driver_pci_host.c
> +++ b/drivers/bcma/driver_pci_host.c
> @@ -94,7 +94,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
>  	if (dev == 0) {
>  		/* we support only two functions on device 0 */
>  		if (func > 1)
> -			return -EINVAL;
> +			goto out;
>  
>  		/* accesses to config registers with offsets >= 256
>  		 * requires indirect access.
> @@ -157,6 +157,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  	if (unlikely(len != 1 && len != 2 && len != 4))
>  		goto out;
>  	if (dev == 0) {
> +		/* we support only two functions on device 0 */
> +		if (func > 1)
> +			goto out;
> +
>  		/* accesses to config registers with offsets >= 256
>  		 * requires indirect access.
>  		 */
> 


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

* Re: [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space
  2013-01-12 10:46 ` [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space Nathan Hintz
@ 2013-01-12 14:38   ` Hauke Mehrtens
  2013-01-12 14:45     ` Hauke Mehrtens
  0 siblings, 1 reply; 11+ messages in thread
From: Hauke Mehrtens @ 2013-01-12 14:38 UTC (permalink / raw)
  To: Nathan Hintz; +Cc: linville, linux-wireless

On 01/12/2013 11:46 AM, Nathan Hintz wrote:
> For PCI config space access offsets < 256 for device '0',
> bcma_extpci_write_config performs an 'ioremap_nocache' on a 4 byte
> section of the PCI config space (an area that has already
> previously been mapped), and then subsequently unmaps that 4 byte
> section.  This can't be a good thing for future read access from
> that now unmapped location.  Modify the config space writes to use
> the existing access functions (similar to how it is done for the reads).
> 
> Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
> ---
>  drivers/bcma/driver_pci_host.c |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
> index 187cc9f..e1381ba 100644
> --- a/drivers/bcma/driver_pci_host.c
> +++ b/drivers/bcma/driver_pci_host.c
> @@ -149,7 +149,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  				   const void *buf, int len)
>  {
>  	int err = -EINVAL;
> -	u32 addr = 0, val = 0;
> +	u32 addr, val;
>  	void __iomem *mmio = 0;
>  	u16 chipid = pc->core->bus->chipinfo.id;
>  
> @@ -165,12 +165,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		 * requires indirect access.
>  		 */
>  		if (off < PCI_CONFIG_SPACE_SIZE) {
> -			addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
> +			addr = BCMA_CORE_PCI_PCICFG0;
>  			addr |= (func << 8);
>  			addr |= (off & 0xfc);
> -			mmio = ioremap_nocache(addr, sizeof(val));
> -			if (!mmio)
> -				goto out;
> +			val = pcicore_read32(pc, addr);
>  		}

off >= PCI_CONFIG_SPACE_SIZE is not handled here, but I think it should
be. This part of the function should use the same code as used in
bcma_extpci_read_config().

Your patch improves this, but I think there is an other flaw in the code.

>  	} else {
>  		addr = bcma_get_cfgspace_addr(pc, dev, func, off);
> @@ -189,12 +187,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  
>  	switch (len) {
>  	case 1:
> -		val = readl(mmio);
>  		val &= ~(0xFF << (8 * (off & 3)));
>  		val |= *((const u8 *)buf) << (8 * (off & 3));
>  		break;
>  	case 2:
> -		val = readl(mmio);
>  		val &= ~(0xFFFF << (8 * (off & 3)));
>  		val |= *((const u16 *)buf) << (8 * (off & 3));
>  		break;
> @@ -202,13 +198,17 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		val = *((const u32 *)buf);
>  		break;
>  	}
> -	if (dev == 0 && !addr) {
> +	if (dev == 0) {
>  		/* accesses to config registers with offsets >= 256
>  		 * requires indirect access.
>  		 */
> -		addr = (func << 12);
> -		addr |= (off & 0x0FFF);
> -		bcma_pcie_write_config(pc, addr, val);
> +		if (off >= PCI_CONFIG_SPACE_SIZE) {
> +			addr = (func << 12);
> +			addr |= (off & 0x0FFF);
> +			bcma_pcie_write_config(pc, addr, val);
> +		} else {
> +			pcicore_write32(pc, addr, val);
> +		}
>  	} else {
>  		writel(val, mmio);
>  
> 


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

* Re: [PATCH 4/5] bcma: add support for 1 and 2 byte extended config space access
  2013-01-12 10:46 ` [PATCH 4/5] bcma: add support for 1 and 2 byte extended config space access Nathan Hintz
@ 2013-01-12 14:44   ` Hauke Mehrtens
  0 siblings, 0 replies; 11+ messages in thread
From: Hauke Mehrtens @ 2013-01-12 14:44 UTC (permalink / raw)
  To: Nathan Hintz; +Cc: linville, linux-wireless

On 01/12/2013 11:46 AM, Nathan Hintz wrote:
> The sanity checks allow 1 and 2 byte reads/writes of the extended
> PCI config space to proceed; however, the code only supports 4
> byte reads/writes.  This patch adds support for 1 and 2 byte
> reads/writes of the extended PCI config space.
> 
> Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>  drivers/bcma/driver_pci_host.c |   15 ++++++++-------
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
> index e1381ba..92800b4 100644
> --- a/drivers/bcma/driver_pci_host.c
> +++ b/drivers/bcma/driver_pci_host.c
> @@ -101,7 +101,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		 */
>  		if (off >= PCI_CONFIG_SPACE_SIZE) {
>  			addr = (func << 12);
> -			addr |= (off & 0x0FFF);
> +			addr |= (off & 0x0FFC);
>  			val = bcma_pcie_read_config(pc, addr);
>  		} else {
>  			addr = BCMA_CORE_PCI_PCICFG0;
> @@ -164,7 +164,11 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		/* accesses to config registers with offsets >= 256
>  		 * requires indirect access.
>  		 */
> -		if (off < PCI_CONFIG_SPACE_SIZE) {
> +		if (off >= PCI_CONFIG_SPACE_SIZE) {
> +			addr = (func << 12);
> +			addr |= (off & 0x0FFC);
> +			val = bcma_pcie_read_config(pc, addr);
> +		} else {
>  			addr = BCMA_CORE_PCI_PCICFG0;
>  			addr |= (func << 8);
>  			addr |= (off & 0xfc);
> @@ -202,13 +206,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>  		/* accesses to config registers with offsets >= 256
>  		 * requires indirect access.
>  		 */
> -		if (off >= PCI_CONFIG_SPACE_SIZE) {
> -			addr = (func << 12);
> -			addr |= (off & 0x0FFF);
> +		if (off >= PCI_CONFIG_SPACE_SIZE)
>  			bcma_pcie_write_config(pc, addr, val);
> -		} else {
> +		else
>  			pcicore_write32(pc, addr, val);
> -		}
>  	} else {
>  		writel(val, mmio);
>  
> 


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

* Re: [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space
  2013-01-12 14:38   ` Hauke Mehrtens
@ 2013-01-12 14:45     ` Hauke Mehrtens
  0 siblings, 0 replies; 11+ messages in thread
From: Hauke Mehrtens @ 2013-01-12 14:45 UTC (permalink / raw)
  To: Nathan Hintz; +Cc: linville, linux-wireless

On 01/12/2013 03:38 PM, Hauke Mehrtens wrote:
> On 01/12/2013 11:46 AM, Nathan Hintz wrote:
>> For PCI config space access offsets < 256 for device '0',
>> bcma_extpci_write_config performs an 'ioremap_nocache' on a 4 byte
>> section of the PCI config space (an area that has already
>> previously been mapped), and then subsequently unmaps that 4 byte
>> section.  This can't be a good thing for future read access from
>> that now unmapped location.  Modify the config space writes to use
>> the existing access functions (similar to how it is done for the reads).
>>
>> Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

>> ---
>>  drivers/bcma/driver_pci_host.c |   22 +++++++++++-----------
>>  1 files changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
>> index 187cc9f..e1381ba 100644
>> --- a/drivers/bcma/driver_pci_host.c
>> +++ b/drivers/bcma/driver_pci_host.c
>> @@ -149,7 +149,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>>  				   const void *buf, int len)
>>  {
>>  	int err = -EINVAL;
>> -	u32 addr = 0, val = 0;
>> +	u32 addr, val;
>>  	void __iomem *mmio = 0;
>>  	u16 chipid = pc->core->bus->chipinfo.id;
>>  
>> @@ -165,12 +165,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>>  		 * requires indirect access.
>>  		 */
>>  		if (off < PCI_CONFIG_SPACE_SIZE) {
>> -			addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
>> +			addr = BCMA_CORE_PCI_PCICFG0;
>>  			addr |= (func << 8);
>>  			addr |= (off & 0xfc);
>> -			mmio = ioremap_nocache(addr, sizeof(val));
>> -			if (!mmio)
>> -				goto out;
>> +			val = pcicore_read32(pc, addr);
>>  		}
> 
> off >= PCI_CONFIG_SPACE_SIZE is not handled here, but I think it should
> be. This part of the function should use the same code as used in
> bcma_extpci_read_config().
> 
> Your patch improves this, but I think there is an other flaw in the code.

I just saw you do this in the next patch, ignore this comment.

> 
>>  	} else {
>>  		addr = bcma_get_cfgspace_addr(pc, dev, func, off);
>> @@ -189,12 +187,10 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>>  
>>  	switch (len) {
>>  	case 1:
>> -		val = readl(mmio);
>>  		val &= ~(0xFF << (8 * (off & 3)));
>>  		val |= *((const u8 *)buf) << (8 * (off & 3));
>>  		break;
>>  	case 2:
>> -		val = readl(mmio);
>>  		val &= ~(0xFFFF << (8 * (off & 3)));
>>  		val |= *((const u16 *)buf) << (8 * (off & 3));
>>  		break;
>> @@ -202,13 +198,17 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
>>  		val = *((const u32 *)buf);
>>  		break;
>>  	}
>> -	if (dev == 0 && !addr) {
>> +	if (dev == 0) {
>>  		/* accesses to config registers with offsets >= 256
>>  		 * requires indirect access.
>>  		 */
>> -		addr = (func << 12);
>> -		addr |= (off & 0x0FFF);
>> -		bcma_pcie_write_config(pc, addr, val);
>> +		if (off >= PCI_CONFIG_SPACE_SIZE) {
>> +			addr = (func << 12);
>> +			addr |= (off & 0x0FFF);
>> +			bcma_pcie_write_config(pc, addr, val);
>> +		} else {
>> +			pcicore_write32(pc, addr, val);
>> +		}
>>  	} else {
>>  		writel(val, mmio);
>>  
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

end of thread, other threads:[~2013-01-12 14:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1357987577-20661-1-git-send-email-nlhintz@hotmail.com>
2013-01-12 10:46 ` [PATCH 1/5] bcma: delete duplicate readl Nathan Hintz
2013-01-12 14:16   ` Hauke Mehrtens
2013-01-12 10:46 ` [PATCH 2/5] bcma: jump to 'out' label for invalid 'func' value Nathan Hintz
2013-01-12 14:18   ` Hauke Mehrtens
2013-01-12 10:46 ` [PATCH 3/5] bcma: don't map/unmap a subset of the PCI config space Nathan Hintz
2013-01-12 14:38   ` Hauke Mehrtens
2013-01-12 14:45     ` Hauke Mehrtens
2013-01-12 10:46 ` [PATCH 4/5] bcma: add support for 1 and 2 byte extended config space access Nathan Hintz
2013-01-12 14:44   ` Hauke Mehrtens
2013-01-12 10:46 ` [PATCH 5/5] bcma: use consistent case for 'hex' constants Nathan Hintz
2013-01-12 14:05   ` Hauke Mehrtens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).