Re: [PATCH 0/2] enable 802.11w in mt7601u driver

2018-07-09 Thread Jakub Kicinski
On Mon,  9 Jul 2018 12:20:25 +0200, Lorenzo Bianconi wrote:
> Lorenzo Bianconi (1):
>   mt7601u: use sw encryption for hw unsupported ciphers
> 
> Davide Caratti (1):
>   mt7601u: expose 802.11w support
> 
>  drivers/net/wireless/mediatek/mt7601u/init.c |  1 +
>  drivers/net/wireless/mediatek/mt7601u/main.c | 11 +++
>  2 files changed, 12 insertions(+)

Acked-by: Jakub Kicinski 


Re: [PATCH v2 11/24] mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

2018-07-09 Thread Boris Brezillon
On Mon, 9 Jul 2018 22:35:56 +0200
Arnd Bergmann  wrote:

> On Mon, Jul 9, 2018 at 10:09 PM, Boris Brezillon
>  wrote:
> > Fixes the following smatch warning:
> >
> > drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: 
> > uninitialized symbol 'ret'.
> >
> > Signed-off-by: Boris Brezillon 
> > ---
> >  drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c 
> > b/drivers/mtd/nand/raw/sunxi_nand.c
> > index 99043c3a4fa7..4b11cd4a79be 100644
> > --- a/drivers/mtd/nand/raw/sunxi_nand.c
> > +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> > @@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, 
> > const uint8_t *buf,
> >
> >  static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
> >  {
> > -   uint8_t ret;
> > +   uint8_t ret = 0;
> >
> > sunxi_nfc_read_buf(mtd, , 1);
> >  
> 
> Should there perhaps be a warning when no data was returned after a timeout?

We're planning to move this driver to ->exec_op() soon, and with
->exec_op() errors are properly propagated to the core. I guess we can
live with this lack of dev_warn() for a bit longer :-).


Re: [PATCH v2 00/24] mtd: rawnand: Improve compile-test coverage

2018-07-09 Thread Arnd Bergmann
On Mon, Jul 9, 2018 at 10:09 PM, Boris Brezillon
 wrote:
> Hello,
>
> This is an attempt at adding "depends || COMPILE_TEST" to all NAND
> drivers that have no compile-time dependencies on arch
> features/headers.
>
> This will hopefully help us (NAND/MTD maintainers) in detecting build
> issues earlier. Unfortunately we still have a few drivers that can't
> easily be modified to be arch independent.
>
> I tried to put all patches that only touch the NAND subsystem first,
> so that they can be applied even if other patches are being discussed.
>
> Don't hesitate to point any missing dependencies when compiled with
> COMPILE_TEST. I didn't have any problem when compiling, but that might
> be because the dependencies were already selected.

Looks good to me overall.

> In this v2, I tried to fix all warnings/errors reported by kbuild/0day
> robots. The only remaining ones are those in omap_elm.c which seems to
> do some weird cpu_to_be32() conversions. I guess I could replace those
> by iowrite32be() calls (or just add (__force __u32)), but I don't want
> to risk a regression on this driver, so I'm just leaving it for someone
> else to fix :P.

Agreed, this is definedly very odd code. It looks like the intention
is to write all the bits in reverse order, but four bytes at a time. I'm
fairly sure the current implementation cannot work on big-endian,
in particularly this line:

val = cpu_to_be32(*(u32 *) [0]) >> 12;

Since shifting a number after the byteswap is not well-defined.
It's probably correct on little-endian, but it's not clear what the
best way would be to write this is an endian-neutral way.

Arnd


Re: [PATCH v2 11/24] mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

2018-07-09 Thread Arnd Bergmann
On Mon, Jul 9, 2018 at 10:09 PM, Boris Brezillon
 wrote:
> Fixes the following smatch warning:
>
> drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: 
> uninitialized symbol 'ret'.
>
> Signed-off-by: Boris Brezillon 
> ---
>  drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c 
> b/drivers/mtd/nand/raw/sunxi_nand.c
> index 99043c3a4fa7..4b11cd4a79be 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, 
> const uint8_t *buf,
>
>  static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
>  {
> -   uint8_t ret;
> +   uint8_t ret = 0;
>
> sunxi_nfc_read_buf(mtd, , 1);
>

Should there perhaps be a warning when no data was returned after a timeout?

  Arnd


[PATCH v2 02/24] mtd: rawnand: atmel: Add an __iomem cast on gen_pool_dma_alloc() call

2018-07-09 Thread Boris Brezillon
gen_pool_dma_alloc() return type is void *, while internally, the
memory region exposed by the sram driver has been mapped with
ioremap().

Add a void * to void __iomem * cast to make sparse happy.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c 
b/drivers/mtd/nand/raw/atmel/nand-controller.c
index e8f7549d0354..30dae4c9d439 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -2219,9 +2219,9 @@ atmel_hsmc_nand_controller_init(struct 
atmel_hsmc_nand_controller *nc)
return -ENOMEM;
}
 
-   nc->sram.virt = gen_pool_dma_alloc(nc->sram.pool,
-   ATMEL_NFC_SRAM_SIZE,
-   >sram.dma);
+   nc->sram.virt = (void __iomem *)gen_pool_dma_alloc(nc->sram.pool,
+  ATMEL_NFC_SRAM_SIZE,
+  >sram.dma);
if (!nc->sram.virt) {
dev_err(nc->base.dev,
"Could not allocate memory from the NFC SRAM pool\n");
-- 
2.14.1



[PATCH v2 03/24] mtd: rawnand: atmel: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having ARCH_AT91 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver
compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 230311fa2cc0..1488ad0a0199 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -277,7 +277,8 @@ config MTD_NAND_CS553X
 
 config MTD_NAND_ATMEL
tristate "Support for NAND Flash / SmartMedia on AT91"
-   depends on ARCH_AT91
+   depends on ARCH_AT91 || COMPILE_TEST
+   depends on HAS_IOMEM
select MFD_ATMEL_SMC
help
  Enables support for NAND Flash / Smart Media Card interface
-- 
2.14.1



[PATCH v2 00/24] mtd: rawnand: Improve compile-test coverage

2018-07-09 Thread Boris Brezillon
Hello,

This is an attempt at adding "depends || COMPILE_TEST" to all NAND
drivers that have no compile-time dependencies on arch
features/headers.

This will hopefully help us (NAND/MTD maintainers) in detecting build
issues earlier. Unfortunately we still have a few drivers that can't
easily be modified to be arch independent.

I tried to put all patches that only touch the NAND subsystem first,
so that they can be applied even if other patches are being discussed.

Don't hesitate to point any missing dependencies when compiled with
COMPILE_TEST. I didn't have any problem when compiling, but that might
be because the dependencies were already selected.

In this v2, I tried to fix all warnings/errors reported by kbuild/0day
robots. The only remaining ones are those in omap_elm.c which seems to
do some weird cpu_to_be32() conversions. I guess I could replace those
by iowrite32be() calls (or just add (__force __u32)), but I don't want
to risk a regression on this driver, so I'm just leaving it for someone
else to fix :P.

Regards,

Boris

Changes in v2:
- Fix a few problems reported by kbuild robots and Stephen Rothwell

Boris Brezillon (24):
  mtd: rawnand: atmel: Use uintptr_t casts instead of unsigned int
  mtd: rawnand: atmel: Add an __iomem cast on gen_pool_dma_alloc() call
  mtd: rawnand: atmel: Allow selection of this driver when
COMPILE_TEST=y
  mtd: rawnand: s3c2410: Allow selection of this driver when
COMPILE_TEST=y
  mtd: rawnand: orion: Avoid direct inclusion of asm headers
  mtd: rawnand: orion: Allow selection of this driver when
COMPILE_TEST=y
  mtd: rawnand: davinci: Stop doing iomem pointer <-> u32 conversions
  mtd: rawnand: davinci: Use uintptr_t casts instead of unsigned ones
  mtd: rawnand: davinci: Allow selection of this driver when
COMPILE_TEST=y
  mtd: rawnand: sunxi: Add an U suffix to NFC_PAGE_OP definition
  mtd: rawnand: sunxi: Make sure ret is initialized in
sunxi_nfc_read_byte()
  mtd: rawnand: sunxi: Allow selection of this driver when
COMPILE_TEST=y
  mtd: rawnand: fscm: Avoid collision on PC def when compiling for MIPS
  mtd: rawnand: fsmc: Use uintptr_t casts instead of unsigned ones
  mtd: rawnand: fsmc: Allow selection of this driver when COMPILE_TEST=y
  memory: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y
  mtd: rawnand: fsl_ifc: Add an __iomem specifier on eccstat_regs
  mtd: rawnand: fsl_ifc: Allow selection of this driver when
COMPILE_TEST=y
  MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9
  mtd: rawnand: txx9ndfmc: Allow selection of this driver when
COMPILE_TEST=y
  MIPS: jz4740: Move jz4740_nand.h header to
include/linux/platform_data/jz4740
  mtd: rawnand: jz4740: Allow selection of this driver when
COMPILE_TEST=y
  mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780
  memory: jz4780-nemc: Allow selection of this driver when
COMPILE_TEST=y

 arch/mips/jz4740/board-qi_lb60.c   |  3 +-
 arch/mips/txx9/generic/setup.c |  2 +-
 arch/mips/txx9/generic/setup_tx4938.c  |  2 +-
 arch/mips/txx9/generic/setup_tx4939.c  |  2 +-
 drivers/memory/Kconfig |  6 ++--
 drivers/mtd/nand/raw/Kconfig   | 33 ++
 drivers/mtd/nand/raw/atmel/nand-controller.c   |  8 +++---
 drivers/mtd/nand/raw/davinci_nand.c| 33 ++
 drivers/mtd/nand/raw/fsl_ifc_nand.c|  2 +-
 drivers/mtd/nand/raw/fsmc_nand.c   | 33 +++---
 drivers/mtd/nand/raw/jz4740_nand.c |  2 +-
 drivers/mtd/nand/raw/orion_nand.c  |  2 +-
 drivers/mtd/nand/raw/sunxi_nand.c  |  4 +--
 drivers/mtd/nand/raw/txx9ndfmc.c   |  2 +-
 .../linux/platform_data/jz4740}/jz4740_nand.h  |  4 +--
 .../linux/platform_data}/txx9/ndfmc.h  |  6 ++--
 16 files changed, 77 insertions(+), 67 deletions(-)
 rename {arch/mips/include/asm/mach-jz4740 => 
include/linux/platform_data/jz4740}/jz4740_nand.h (91%)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h 
(91%)

-- 
2.14.1



[PATCH v2 01/24] mtd: rawnand: atmel: Use uintptr_t casts instead of unsigned int

2018-07-09 Thread Boris Brezillon
When casting a pointer to an unsigned in, uintptr_t should be used to
cope with the pointer size differences between 32-bit and 64-bit
architectures.

This is needed if we want to allow compilation of this driver when
COMPILE_TEST=y.

Reported-by: Stephen Rothwell 
Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c 
b/drivers/mtd/nand/raw/atmel/nand-controller.c
index e686fe73159e..e8f7549d0354 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -2050,7 +2050,7 @@ atmel_smc_nand_controller_init(struct 
atmel_smc_nand_controller *nc)
return ret;
}
 
-   nc->ebi_csa_offs = (unsigned int)match->data;
+   nc->ebi_csa_offs = (uintptr_t)match->data;
 
/*
 * The at91sam9263 has 2 EBIs, if the NAND controller is under EBI1
-- 
2.14.1



[PATCH v2 18/24] mtd: rawnand: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes maintainers' life easier by allowing them to compile-test
this driver without having FSL_SOC, ARCH_LAYERSCAPE or SOC_LS1021A
enabled.

We also need to add a dependency on HAS_IOMEM to make sure the
driver compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 29d360f984c9..dc6c5aff4172 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -408,7 +408,8 @@ config MTD_NAND_FSL_ELBC
 
 config MTD_NAND_FSL_IFC
tristate "NAND support for Freescale IFC controller"
-   depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A
+   depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST
+   depends on HAS_IOMEM
select FSL_IFC
select MEMORY
help
-- 
2.14.1



[PATCH v2 06/24] mtd: rawnand: orion: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having PLAT_ORION enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles
correctly, and a dependency on !IA64 because the {read,write}s{bwl}()
accessors are not defined for this architecture.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index e01b3da726c0..efc5dcd5135c 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -289,7 +289,7 @@ config MTD_NAND_MARVELL
tristate "NAND controller support on Marvell boards"
depends on PXA3xx || ARCH_MMP || PLAT_ORION || ARCH_MVEBU || \
   COMPILE_TEST
-   depends on HAS_IOMEM
+   depends on HAS_IOMEM && !IA64
help
  This enables the NAND flash controller driver for Marvell boards,
  including:
@@ -381,7 +381,8 @@ config MTD_NAND_PLATFORM
 
 config MTD_NAND_ORION
tristate "NAND Flash support for Marvell Orion SoC"
-   depends on PLAT_ORION
+   depends on PLAT_ORION || COMPILE_TEST
+   depends on HAS_IOMEM
help
  This enables the NAND flash controller on Orion machines.
 
-- 
2.14.1



[PATCH v2 15/24] mtd: rawnand: fsmc: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having PLAT_SPEAR, ARCH_NOMADIK,
ARCH_U8500 or MACH_U300 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver
compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index ee836f7d7b8b..29d360f984c9 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -503,8 +503,9 @@ config MTD_NAND_JZ4780
 
 config MTD_NAND_FSMC
tristate "Support for NAND on ST Micros FSMC"
-   depends on OF
-   depends on PLAT_SPEAR || ARCH_NOMADIK || ARCH_U8500 || MACH_U300
+   depends on OF && HAS_IOMEM
+   depends on PLAT_SPEAR || ARCH_NOMADIK || ARCH_U8500 || MACH_U300 || \
+  COMPILE_TEST
help
  Enables support for NAND Flash chips on the ST Microelectronics
  Flexible Static Memory Controller (FSMC)
-- 
2.14.1



[PATCH v2 05/24] mtd: rawnand: orion: Avoid direct inclusion of asm headers

2018-07-09 Thread Boris Brezillon
Include linux/sizes.h instead of asm/sizes.h to make code completely
arch independent.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/orion_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/orion_nand.c 
b/drivers/mtd/nand/raw/orion_nand.c
index 1a4828442675..27cc902545f3 100644
--- a/drivers/mtd/nand/raw/orion_nand.c
+++ b/drivers/mtd/nand/raw/orion_nand.c
@@ -18,7 +18,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 struct orion_nand_info {
-- 
2.14.1



[PATCH v2 20/24] mtd: rawnand: txx9ndfmc: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having SOC_TX4938 or SOC_TX4939
enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver
compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index dc6c5aff4172..f4bbc90ee250 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -471,7 +471,8 @@ config MTD_NAND_DAVINCI
 
 config MTD_NAND_TXX9NDFMC
tristate "NAND Flash support for TXx9 SoC"
-   depends on SOC_TX4938 || SOC_TX4939
+   depends on SOC_TX4938 || SOC_TX4939 || COMPILE_TEST
+   depends on HAS_IOMEM
help
  This enables the NAND flash controller on the TXx9 SoCs.
 
-- 
2.14.1



[PATCH v2 16/24] memory: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes maintainers' life easier by allowing them to compile-test
this driver without having FSL_SOC, ARCH_LAYERSCAPE or SOC_LS1021A
enabled.

We also need to add a dependency on HAS_IOMEM to make sure the
driver compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/memory/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig
index 8d731d6c3e54..78457ab2cbc4 100644
--- a/drivers/memory/Kconfig
+++ b/drivers/memory/Kconfig
@@ -116,7 +116,8 @@ config FSL_CORENET_CF
 
 config FSL_IFC
bool
-   depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A
+   depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST
+   depends on HAS_IOMEM
 
 config JZ4780_NEMC
bool "Ingenic JZ4780 SoC NEMC driver"
-- 
2.14.1



[PATCH v2 22/24] mtd: rawnand: jz4740: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having MACH_JZ4740 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver
compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index f4bbc90ee250..7b5e97719c25 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -492,7 +492,8 @@ config MTD_NAND_NUC900
 
 config MTD_NAND_JZ4740
tristate "Support for JZ4740 SoC NAND controller"
-   depends on MACH_JZ4740
+   depends on MACH_JZ4740 || COMPILE_TEST
+   depends on HAS_IOMEM
help
Enables support for NAND Flash on JZ4740 SoC based boards.
 
-- 
2.14.1



[PATCH v2 21/24] MIPS: jz4740: Move jz4740_nand.h header to include/linux/platform_data/jz4740

2018-07-09 Thread Boris Brezillon
This way we will be able to compile the jz4740_nand driver when
COMPILE_TEST=y.

Signed-off-by: Boris Brezillon 
---
 arch/mips/jz4740/board-qi_lb60.c  | 3 ++-
 drivers/mtd/nand/raw/jz4740_nand.c| 2 +-
 .../mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h  | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)
 rename {arch/mips/include/asm/mach-jz4740 => 
include/linux/platform_data/jz4740}/jz4740_nand.h (91%)

diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 60f0767507c6..af0c8ace0141 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -29,10 +29,11 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/drivers/mtd/nand/raw/jz4740_nand.c 
b/drivers/mtd/nand/raw/jz4740_nand.c
index 613b00a9604b..a0254461812d 100644
--- a/drivers/mtd/nand/raw/jz4740_nand.c
+++ b/drivers/mtd/nand/raw/jz4740_nand.c
@@ -25,7 +25,7 @@
 
 #include 
 
-#include 
+#include 
 
 #define JZ_REG_NAND_CTRL   0x50
 #define JZ_REG_NAND_ECC_CTRL   0x100
diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h 
b/include/linux/platform_data/jz4740/jz4740_nand.h
similarity index 91%
rename from arch/mips/include/asm/mach-jz4740/jz4740_nand.h
rename to include/linux/platform_data/jz4740/jz4740_nand.h
index f381d465e768..bc571f6d5ced 100644
--- a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
+++ b/include/linux/platform_data/jz4740/jz4740_nand.h
@@ -13,8 +13,8 @@
  *
  */
 
-#ifndef __ASM_MACH_JZ4740_JZ4740_NAND_H__
-#define __ASM_MACH_JZ4740_JZ4740_NAND_H__
+#ifndef __JZ4740_NAND_H__
+#define __JZ4740_NAND_H__
 
 #include 
 #include 
-- 
2.14.1



[PATCH v2 17/24] mtd: rawnand: fsl_ifc: Add an __iomem specifier on eccstat_regs

2018-07-09 Thread Boris Brezillon
The local eccstat_regs variable in fsl_ifc_run_command() is missing an
__iomem specifier, and sparce complains about that.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/fsl_ifc_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c 
b/drivers/mtd/nand/raw/fsl_ifc_nand.c
index 382b67e97174..75d3c951f61a 100644
--- a/drivers/mtd/nand/raw/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c
@@ -225,7 +225,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
int bufnum = nctrl->page & priv->bufnum_mask;
int sector_start = bufnum * chip->ecc.steps;
int sector_end = sector_start + chip->ecc.steps - 1;
-   __be32 *eccstat_regs;
+   __be32 __iomem *eccstat_regs;
 
eccstat_regs = ifc->ifc_nand.nand_eccstat;
eccstat = ifc_in32(_regs[sector_start / 4]);
-- 
2.14.1



[PATCH v2 23/24] mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780

2018-07-09 Thread Boris Brezillon
This MACH_JZ4780 dependency is taken care of by JZ4780_NEMC, no need
to repeat it here.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 7b5e97719c25..d9cd9608bc2d 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -499,7 +499,7 @@ config MTD_NAND_JZ4740
 
 config MTD_NAND_JZ4780
tristate "Support for NAND on JZ4780 SoC"
-   depends on MACH_JZ4780 && JZ4780_NEMC
+   depends on JZ4780_NEMC
help
  Enables support for NAND Flash connected to the NEMC on JZ4780 SoC
  based boards, using the BCH controller for hardware error correction.
-- 
2.14.1



[PATCH v2 12/24] mtd: rawnand: sunxi: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having ARCH_SUNXI enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver
compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 539b0619f53a..ee836f7d7b8b 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -518,7 +518,8 @@ config MTD_NAND_XWAY
 
 config MTD_NAND_SUNXI
tristate "Support for NAND on Allwinner SoCs"
-   depends on ARCH_SUNXI
+   depends on ARCH_SUNXI || COMPILE_TEST
+   depends on HAS_IOMEM
help
  Enables support for NAND Flash chips on Allwinner SoCs.
 
-- 
2.14.1



[PATCH v2 19/24] MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9

2018-07-09 Thread Boris Brezillon
This way we will be able to compile the ndfmc driver when
COMPILE_TEST=y.

Signed-off-by: Boris Brezillon 
---
 arch/mips/txx9/generic/setup.c  | 2 +-
 arch/mips/txx9/generic/setup_tx4938.c   | 2 +-
 arch/mips/txx9/generic/setup_tx4939.c   | 2 +-
 drivers/mtd/nand/raw/txx9ndfmc.c| 2 +-
 {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h 
(91%)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 1791a44ee570..aa47932abd28 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -35,7 +36,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #ifdef CONFIG_CPU_TX49XX
 #include 
diff --git a/arch/mips/txx9/generic/setup_tx4938.c 
b/arch/mips/txx9/generic/setup_tx4938.c
index 85d1795652da..17395d5d15ca 100644
--- a/arch/mips/txx9/generic/setup_tx4938.c
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -17,13 +17,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/arch/mips/txx9/generic/setup_tx4939.c 
b/arch/mips/txx9/generic/setup_tx4939.c
index 274928987a21..360c388f4c82 100644
--- a/arch/mips/txx9/generic/setup_tx4939.c
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -21,13 +21,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/drivers/mtd/nand/raw/txx9ndfmc.c b/drivers/mtd/nand/raw/txx9ndfmc.c
index b567d212fe7d..04d57474ef97 100644
--- a/drivers/mtd/nand/raw/txx9ndfmc.c
+++ b/drivers/mtd/nand/raw/txx9ndfmc.c
@@ -20,7 +20,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /* TXX9 NDFMC Registers */
 #define TXX9_NDFDTR0x00
diff --git a/arch/mips/include/asm/txx9/ndfmc.h 
b/include/linux/platform_data/txx9/ndfmc.h
similarity index 91%
rename from arch/mips/include/asm/txx9/ndfmc.h
rename to include/linux/platform_data/txx9/ndfmc.h
index fa67f3df78fc..fc172627d54e 100644
--- a/arch/mips/include/asm/txx9/ndfmc.h
+++ b/include/linux/platform_data/txx9/ndfmc.h
@@ -5,8 +5,8 @@
  *
  * (C) Copyright TOSHIBA CORPORATION 2007
  */
-#ifndef __ASM_TXX9_NDFMC_H
-#define __ASM_TXX9_NDFMC_H
+#ifndef __TXX9_NDFMC_H
+#define __TXX9_NDFMC_H
 
 #define NDFMC_PLAT_FLAG_USE_BSPRT  0x01
 #define NDFMC_PLAT_FLAG_NO_RSTR0x02
@@ -27,4 +27,4 @@ struct txx9ndfmc_platform_data {
 void txx9_ndfmc_init(unsigned long baseaddr,
 const struct txx9ndfmc_platform_data *plat_data);
 
-#endif /* __ASM_TXX9_NDFMC_H */
+#endif /* __TXX9_NDFMC_H */
-- 
2.14.1



[PATCH v2 10/24] mtd: rawnand: sunxi: Add an U suffix to NFC_PAGE_OP definition

2018-07-09 Thread Boris Brezillon
Fixes the "warning: large integer implicitly truncated to unsigned type
[-Woverflow]" warning when compiled for x86.

This is needed in order to allow compiling this driver when
COMPILE_TEST=y.

Reported-by: Stephen Rothwell 
Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c 
b/drivers/mtd/nand/raw/sunxi_nand.c
index d831a141a196..99043c3a4fa7 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -127,7 +127,7 @@
 #define NFC_CMD_TYPE_MSK   GENMASK(31, 30)
 #define NFC_NORMAL_OP  (0 << 30)
 #define NFC_ECC_OP (1 << 30)
-#define NFC_PAGE_OP(2 << 30)
+#define NFC_PAGE_OP(2U << 30)
 
 /* define bit use in NFC_RCMD_SET */
 #define NFC_READ_CMD_MSK   GENMASK(7, 0)
-- 
2.14.1



[PATCH v2 13/24] mtd: rawnand: fscm: Avoid collision on PC def when compiling for MIPS

2018-07-09 Thread Boris Brezillon
We want to allow this driver to be selected when COMPILE_TEST=y, this
means the driver can be compiled for any arch, including MIPS. When
compiling this driver for MIPS, we end up with a collision on the 'PC'
macro definition (also defined in arch/mips/include/asm/ptrace.h).

Prefix the fsmc one with FSMC_ to avoid this problem.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/fsmc_nand.c | 29 +++--
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index f4a5a317d4ae..d71c49f50e77 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -62,7 +62,7 @@
reg)
 
 /* fsmc controller registers for NAND flash */
-#define PC 0x00
+#define FSMC_PC0x00
/* pc register definitions */
#define FSMC_RESET  (1 << 0)
#define FSMC_WAITON (1 << 1)
@@ -273,12 +273,13 @@ static void fsmc_nand_setup(struct fsmc_nand_data *host,
tset = (tims->tset & FSMC_TSET_MASK) << FSMC_TSET_SHIFT;
 
if (host->nand.options & NAND_BUSWIDTH_16)
-   writel_relaxed(value | FSMC_DEVWID_16, host->regs_va + PC);
+   writel_relaxed(value | FSMC_DEVWID_16,
+  host->regs_va + FSMC_PC);
else
-   writel_relaxed(value | FSMC_DEVWID_8, host->regs_va + PC);
+   writel_relaxed(value | FSMC_DEVWID_8, host->regs_va + FSMC_PC);
 
-   writel_relaxed(readl(host->regs_va + PC) | tclr | tar,
-  host->regs_va + PC);
+   writel_relaxed(readl(host->regs_va + FSMC_PC) | tclr | tar,
+  host->regs_va + FSMC_PC);
writel_relaxed(thiz | thold | twait | tset, host->regs_va + COMM);
writel_relaxed(thiz | thold | twait | tset, host->regs_va + ATTRIB);
 }
@@ -371,12 +372,12 @@ static void fsmc_enable_hwecc(struct mtd_info *mtd, int 
mode)
 {
struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
 
-   writel_relaxed(readl(host->regs_va + PC) & ~FSMC_ECCPLEN_256,
-  host->regs_va + PC);
-   writel_relaxed(readl(host->regs_va + PC) & ~FSMC_ECCEN,
-  host->regs_va + PC);
-   writel_relaxed(readl(host->regs_va + PC) | FSMC_ECCEN,
-  host->regs_va + PC);
+   writel_relaxed(readl(host->regs_va + FSMC_PC) & ~FSMC_ECCPLEN_256,
+  host->regs_va + FSMC_PC);
+   writel_relaxed(readl(host->regs_va + FSMC_PC) & ~FSMC_ECCEN,
+  host->regs_va + FSMC_PC);
+   writel_relaxed(readl(host->regs_va + FSMC_PC) | FSMC_ECCEN,
+  host->regs_va + FSMC_PC);
 }
 
 /*
@@ -618,11 +619,11 @@ static void fsmc_select_chip(struct mtd_info *mtd, int 
chipnr)
if (chipnr > 0)
return;
 
-   pc = readl(host->regs_va + PC);
+   pc = readl(host->regs_va + FSMC_PC);
if (chipnr < 0)
-   writel_relaxed(pc & ~FSMC_ENABLE, host->regs_va + PC);
+   writel_relaxed(pc & ~FSMC_ENABLE, host->regs_va + FSMC_PC);
else
-   writel_relaxed(pc | FSMC_ENABLE, host->regs_va + PC);
+   writel_relaxed(pc | FSMC_ENABLE, host->regs_va + FSMC_PC);
 
/* nCE line must be asserted before starting any operation */
mb();
-- 
2.14.1



[PATCH v2 14/24] mtd: rawnand: fsmc: Use uintptr_t casts instead of unsigned ones

2018-07-09 Thread Boris Brezillon
uintptr_t should be used when casting a pointer to an unsigned int so
that the code compiles without warnings even on 64-bit architectures.

This is needed if we want to allow selection of this driver when
COMPILE_TEST=y.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/fsmc_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index d71c49f50e77..527bebc7e6c9 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -547,7 +547,7 @@ static void fsmc_write_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)
struct fsmc_nand_data *host  = mtd_to_fsmc(mtd);
int i;
 
-   if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
+   if (IS_ALIGNED((uintptr_t)buf, sizeof(uint32_t)) &&
IS_ALIGNED(len, sizeof(uint32_t))) {
uint32_t *p = (uint32_t *)buf;
len = len >> 2;
@@ -570,7 +570,7 @@ static void fsmc_read_buf(struct mtd_info *mtd, uint8_t 
*buf, int len)
struct fsmc_nand_data *host  = mtd_to_fsmc(mtd);
int i;
 
-   if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
+   if (IS_ALIGNED((uintptr_t)buf, sizeof(uint32_t)) &&
IS_ALIGNED(len, sizeof(uint32_t))) {
uint32_t *p = (uint32_t *)buf;
len = len >> 2;
-- 
2.14.1



[PATCH v2 08/24] mtd: rawnand: davinci: Use uintptr_t casts instead of unsigned ones

2018-07-09 Thread Boris Brezillon
uintptr_t should be used when casting a pointer to an unsigned int so
that the code compiles without warnings even on 64-bit architectures.

This is needed if we want to allow selection of this driver when
COMPILE_TEST=y.

Reported-by: Stephen Rothwell 
Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/davinci_nand.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/raw/davinci_nand.c 
b/drivers/mtd/nand/raw/davinci_nand.c
index 9cd36a750965..e79ed0f60ade 100644
--- a/drivers/mtd/nand/raw/davinci_nand.c
+++ b/drivers/mtd/nand/raw/davinci_nand.c
@@ -318,7 +318,7 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd,
/* Unpack ten bytes into eight 10 bit values.  We know we're
 * little-endian, and use type punning for less shifting/masking.
 */
-   if (WARN_ON(0x01 & (unsigned) ecc_code))
+   if (WARN_ON(0x01 & (uintptr_t)ecc_code))
return -EINVAL;
ecc16 = (unsigned short *)ecc_code;
 
@@ -440,9 +440,9 @@ static void nand_davinci_read_buf(struct mtd_info *mtd, 
uint8_t *buf, int len)
 {
struct nand_chip *chip = mtd_to_nand(mtd);
 
-   if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0)
+   if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
ioread32_rep(chip->IO_ADDR_R, buf, len >> 2);
-   else if ((0x01 & ((unsigned)buf)) == 0 && (0x01 & len) == 0)
+   else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
ioread16_rep(chip->IO_ADDR_R, buf, len >> 1);
else
ioread8_rep(chip->IO_ADDR_R, buf, len);
@@ -453,9 +453,9 @@ static void nand_davinci_write_buf(struct mtd_info *mtd,
 {
struct nand_chip *chip = mtd_to_nand(mtd);
 
-   if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0)
+   if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
iowrite32_rep(chip->IO_ADDR_R, buf, len >> 2);
-   else if ((0x01 & ((unsigned)buf)) == 0 && (0x01 & len) == 0)
+   else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
iowrite16_rep(chip->IO_ADDR_R, buf, len >> 1);
else
iowrite8_rep(chip->IO_ADDR_R, buf, len);
-- 
2.14.1



[PATCH v2 09/24] mtd: rawnand: davinci: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having ARCH_DAVINCI or ARCH_KEYSTONE
enabled.

We also need to add a dependency on HAS_IOMEM to make sure the
driver compiles correctly.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index efc5dcd5135c..539b0619f53a 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -462,7 +462,8 @@ config MTD_NAND_SH_FLCTL
 
 config MTD_NAND_DAVINCI
 tristate "Support NAND on DaVinci/Keystone SoC"
-depends on ARCH_DAVINCI || (ARCH_KEYSTONE && TI_AEMIF)
+   depends on ARCH_DAVINCI || (ARCH_KEYSTONE && TI_AEMIF) || COMPILE_TEST
+   depends on HAS_IOMEM
 help
  Enable the driver for NAND flash chips on Texas Instruments
  DaVinci/Keystone processors.
-- 
2.14.1



[PATCH v2 04/24] mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

2018-07-09 Thread Boris Brezillon
It just makes NAND maintainers' life easier by allowing them to
compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX
enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles
correctly, and a dependency on !IA64 because the {read,write}s{bwl}()
accessors are not defined for this architecture.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 1488ad0a0199..e01b3da726c0 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -119,7 +119,8 @@ config MTD_NAND_AU1550
 
 config MTD_NAND_S3C2410
tristate "NAND Flash support for Samsung S3C SoCs"
-   depends on ARCH_S3C24XX || ARCH_S3C64XX
+   depends on ARCH_S3C24XX || ARCH_S3C64XX || COMPILE_TEST
+   depends on HAS_IOMEM && !IA64
help
  This enables the NAND flash controller on the S3C24xx and S3C64xx
  SoCs
-- 
2.14.1



[PATCH v2 07/24] mtd: rawnand: davinci: Stop doing iomem pointer <-> u32 conversions

2018-07-09 Thread Boris Brezillon
There is no point in doing this sort of conversion since pointers can
we can replace |= by += operations which are perfectly valid on
pointers.

This is done in preparation of COMPILE_TEST addition to the NAND_DAVINCI
Kconfig entry, since building for x86 generates a several warnings
because of inappropriate u32 <-> void * conversions (pointers are 64bits
large on x86_64).

Reported-by: Stephen Rothwell 
Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/davinci_nand.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/nand/raw/davinci_nand.c 
b/drivers/mtd/nand/raw/davinci_nand.c
index cd12e5abafde..9cd36a750965 100644
--- a/drivers/mtd/nand/raw/davinci_nand.c
+++ b/drivers/mtd/nand/raw/davinci_nand.c
@@ -60,8 +60,7 @@ struct davinci_nand_info {
void __iomem*base;
void __iomem*vaddr;
 
-   uint32_tioaddr;
-   uint32_tcurrent_cs;
+   void __iomem*current_cs;
 
uint32_tmask_chipsel;
uint32_tmask_ale;
@@ -102,17 +101,17 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, 
int cmd,
   unsigned int ctrl)
 {
struct davinci_nand_info*info = to_davinci_nand(mtd);
-   uint32_taddr = info->current_cs;
+   void __iomem*addr = info->current_cs;
struct nand_chip*nand = mtd_to_nand(mtd);
 
/* Did the control lines change? */
if (ctrl & NAND_CTRL_CHANGE) {
if ((ctrl & NAND_CTRL_CLE) == NAND_CTRL_CLE)
-   addr |= info->mask_cle;
+   addr += info->mask_cle;
else if ((ctrl & NAND_CTRL_ALE) == NAND_CTRL_ALE)
-   addr |= info->mask_ale;
+   addr += info->mask_ale;
 
-   nand->IO_ADDR_W = (void __iomem __force *)addr;
+   nand->IO_ADDR_W = addr;
}
 
if (cmd != NAND_CMD_NONE)
@@ -122,14 +121,14 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, 
int cmd,
 static void nand_davinci_select_chip(struct mtd_info *mtd, int chip)
 {
struct davinci_nand_info*info = to_davinci_nand(mtd);
-   uint32_taddr = info->ioaddr;
+
+   info->current_cs = info->vaddr;
 
/* maybe kick in a second chipselect */
if (chip > 0)
-   addr |= info->mask_chipsel;
-   info->current_cs = addr;
+   info->current_cs += info->mask_chipsel;
 
-   info->chip.IO_ADDR_W = (void __iomem __force *)addr;
+   info->chip.IO_ADDR_W = info->current_cs;
info->chip.IO_ADDR_R = info->chip.IO_ADDR_W;
 }
 
@@ -680,9 +679,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
info->chip.bbt_md   = pdata->bbt_md;
info->timing= pdata->timing;
 
-   info->ioaddr= (uint32_t __force) vaddr;
-
-   info->current_cs= info->ioaddr;
+   info->current_cs= info->vaddr;
info->core_chipsel  = pdata->core_chipsel;
info->mask_chipsel  = pdata->mask_chipsel;
 
-- 
2.14.1



[PATCH v2 11/24] mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

2018-07-09 Thread Boris Brezillon
Fixes the following smatch warning:

drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: 
uninitialized symbol 'ret'.

Signed-off-by: Boris Brezillon 
---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c 
b/drivers/mtd/nand/raw/sunxi_nand.c
index 99043c3a4fa7..4b11cd4a79be 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const 
uint8_t *buf,
 
 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
 {
-   uint8_t ret;
+   uint8_t ret = 0;
 
sunxi_nfc_read_buf(mtd, , 1);
 
-- 
2.14.1



[RFC v2 4/4] ath9k: Switch to mac80211 TXQ scheduling and airtime APIs

2018-07-09 Thread Toke Høiland-Jørgensen
This moves the ath9k driver to use the mac80211 TXQ scheduling and
airtime accounting APIs, removing the corresponding state tracking
inside the driver.

Signed-off-by: Toke Høiland-Jørgensen 
---
 drivers/net/wireless/ath/ath9k/ath9k.h |   14 --
 drivers/net/wireless/ath/ath9k/debug.c |3 
 drivers/net/wireless/ath/ath9k/debug.h |8 -
 drivers/net/wireless/ath/ath9k/debug_sta.c |   54 --
 drivers/net/wireless/ath/ath9k/init.c  |3 
 drivers/net/wireless/ath/ath9k/recv.c  |9 -
 drivers/net/wireless/ath/ath9k/xmit.c  |  245 
 7 files changed, 76 insertions(+), 260 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h 
b/drivers/net/wireless/ath/ath9k/ath9k.h
index ef0de4f1312c..f01aedfef24f 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -112,8 +112,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct 
ath_descdma *dd,
 #define ATH_TXFIFO_DEPTH   8
 #define ATH_TX_ERROR   0x01
 
-#define ATH_AIRTIME_QUANTUM300 /* usec */
-
 /* Stop tx traffic 1ms before the GO goes away */
 #define ATH_P2P_PS_STOP_TIME   1000
 
@@ -246,10 +244,8 @@ struct ath_atx_tid {
s8 bar_index;
bool active;
bool clear_ps_filter;
-   bool has_queued;
 };
 
-void __ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid);
 void ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid);
 
 struct ath_node {
@@ -263,12 +259,9 @@ struct ath_node {
 
bool sleeping;
bool no_ps_filter;
-   s64 airtime_deficit[IEEE80211_NUM_ACS];
-   u32 airtime_rx_start;
 
 #ifdef CONFIG_ATH9K_STATION_STATISTICS
struct ath_rx_rate_stats rx_rate_stats;
-   struct ath_airtime_stats airtime_stats;
 #endif
u8 key_idx[4];
 
@@ -986,11 +979,6 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct 
ath_rx_status *rs);
 
 #define ATH9K_NUM_CHANCTX  2 /* supports 2 operating channels */
 
-#define AIRTIME_USE_TX BIT(0)
-#define AIRTIME_USE_RX BIT(1)
-#define AIRTIME_USE_NEW_QUEUES BIT(2)
-#define AIRTIME_ACTIVE(flags) (!!(flags & (AIRTIME_USE_TX|AIRTIME_USE_RX)))
-
 struct ath_softc {
struct ieee80211_hw *hw;
struct device *dev;
@@ -1034,8 +1022,6 @@ struct ath_softc {
short nbcnvifs;
unsigned long ps_usecount;
 
-   u16 airtime_flags; /* AIRTIME_* */
-
struct ath_rx rx;
struct ath_tx tx;
struct ath_beacon beacon;
diff --git a/drivers/net/wireless/ath/ath9k/debug.c 
b/drivers/net/wireless/ath/ath9k/debug.c
index f685843a2ff3..ce62da4840e2 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1456,9 +1456,6 @@ int ath9k_init_debug(struct ath_hw *ah)
 #endif
debugfs_create_file("tpc", 0600, sc->debug.debugfs_phy, sc, _tpc);
 
-   debugfs_create_u16("airtime_flags", 0600,
-  sc->debug.debugfs_phy, >airtime_flags);
-
debugfs_create_file("nf_override", 0600,
sc->debug.debugfs_phy, sc, _nf_override);
 
diff --git a/drivers/net/wireless/ath/ath9k/debug.h 
b/drivers/net/wireless/ath/ath9k/debug.h
index 249f8141cd00..559d9628f280 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -319,20 +319,12 @@ ath9k_debug_sync_cause(struct ath_softc *sc, u32 
sync_cause)
 void ath_debug_rate_stats(struct ath_softc *sc,
  struct ath_rx_status *rs,
  struct sk_buff *skb);
-void ath_debug_airtime(struct ath_softc *sc,
-  struct ath_node *an,
-  u32 rx, u32 tx);
 #else
 static inline void ath_debug_rate_stats(struct ath_softc *sc,
struct ath_rx_status *rs,
struct sk_buff *skb)
 {
 }
-static inline void ath_debug_airtime(struct ath_softc *sc,
- struct ath_node *an,
- u32 rx, u32 tx)
-{
-}
 #endif /* CONFIG_ATH9K_STATION_STATISTICS */
 
 #endif /* DEBUG_H */
diff --git a/drivers/net/wireless/ath/ath9k/debug_sta.c 
b/drivers/net/wireless/ath/ath9k/debug_sta.c
index a6f45f1bb5bb..bb6f3250aa30 100644
--- a/drivers/net/wireless/ath/ath9k/debug_sta.c
+++ b/drivers/net/wireless/ath/ath9k/debug_sta.c
@@ -242,59 +242,6 @@ static const struct file_operations fops_node_recv = {
.llseek = default_llseek,
 };
 
-void ath_debug_airtime(struct ath_softc *sc,
-   struct ath_node *an,
-   u32 rx,
-   u32 tx)
-{
-   struct ath_airtime_stats *astats = >airtime_stats;
-
-   astats->rx_airtime += rx;
-   astats->tx_airtime += tx;
-}
-
-static ssize_t read_airtime(struct file *file, char __user *user_buf,
-   size_t count, loff_t *ppos)
-{
-   struct ath_node *an = file->private_data;
-   struct ath_airtime_stats *astats;
-   

[RFC v2 2/4] mac80211: Add airtime accounting and scheduling to TXQs

2018-07-09 Thread Toke Høiland-Jørgensen
This adds airtime accounting and scheduling to the mac80211 TXQ
scheduler. A new callback, ieee80211_sta_register_airtime(), is added
that drivers can call to report airtime usage for stations, and an
extended feature flag is added that drivers can use to opt into airtime
fairness scheduling.

When the airtime fairness feature is enabled, mac80211 will schedule TXQs
(through ieee80211_next_txq()) in a way that enforces airtime fairness
between active stations. This scheduling works the same way as the ath9k
in-driver airtime fairness scheduling, but also adds weighted fairness
to support airtime policies.

If the extended feature is not set, the scheduler will default to
round-robin scheduling.

Signed-off-by: Toke Høiland-Jørgensen 
---
 include/net/mac80211.h   |   28 
 include/uapi/linux/nl80211.h |3 ++
 net/mac80211/debugfs.c   |3 ++
 net/mac80211/debugfs_sta.c   |   35 +
 net/mac80211/ieee80211_i.h   |3 ++
 net/mac80211/main.c  |2 +
 net/mac80211/sta_info.c  |   24 +
 net/mac80211/sta_info.h  |   17 
 net/mac80211/tx.c|   60 --
 9 files changed, 161 insertions(+), 14 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 18e43193b614..17759d55b7d4 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -5291,6 +5291,34 @@ void ieee80211_sta_eosp(struct ieee80211_sta *pubsta);
  */
 void ieee80211_send_eosp_nullfunc(struct ieee80211_sta *pubsta, int tid);
 
+/**
+ * ieee80211_sta_register_airtime - register airtime usage for a sta/tid
+ *
+ * Register airtime usage for a given sta on a given tid. The driver can call
+ * this function to notify mac80211 that a station used a certain amount of
+ * airtime. This information will be used by the TXQ scheduler to schedule
+ * stations in a way that ensures airtime fairness.
+ *
+ * The reported airtime should as a minimum include all time that is spent
+ * transmitting to the remote station, including overhead and padding, but not
+ * including time spent waiting for a TXOP. If the time is not reported by the
+ * hardware it can in some cases be calculated from the rate and known frame
+ * composition. When possible, the time should include any failed transmission
+ * attempts.
+ *
+ * The driver can either call this function synchronously for every packet or
+ * aggregate, or asynchronously as airtime usage information becomes available.
+ * TX and RX airtime can be reported together, or separately by setting one of
+ * them to 0.
+ *
+ * @pubsta: the station
+ * @tid: the TID to register airtime for
+ * @tx_airtime: airtime used during TX (in usec)
+ * @rx_airtime: airtime used during RX (in usec)
+ */
+void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,
+   u32 tx_airtime, u32 rx_airtime);
+
 /**
  * ieee80211_iter_keys - iterate keys programmed into the device
  * @hw: pointer obtained from ieee80211_alloc_hw()
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 7acc16f34942..28550d01948f 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -5223,6 +5223,8 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT: Driver/device can omit all data
  * except for supported rates from the probe request content if requested
  * by the %NL80211_SCAN_FLAG_MIN_PREQ_CONTENT flag.
+ * @NL80211_EXT_FEATURE_AIRTIME_FAIRNESS: Driver supports airtime fairness
+ *  scheduling.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -5259,6 +5261,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_TXQS,
NL80211_EXT_FEATURE_SCAN_RANDOM_SN,
NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT,
+   NL80211_EXT_FEATURE_AIRTIME_FAIRNESS,
 
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index b5adf3625d16..08d112dc8bd6 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -379,6 +379,9 @@ void debugfs_hw_add(struct ieee80211_local *local)
if (local->ops->wake_tx_queue)
DEBUGFS_ADD_MODE(aqm, 0600);
 
+   debugfs_create_u16("airtime_flags", 0600,
+  phyd, >airtime_flags);
+
statsd = debugfs_create_dir("statistics", phyd);
 
/* if the dir failed, don't put all the other things into the root! */
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 4105081dc1df..de4067bc11cd 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -192,6 +192,37 @@ static ssize_t sta_aqm_read(struct file *file, char __user 
*userbuf,
 }
 STA_OPS(aqm);
 
+static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
+ 

[RFC v2 3/4] cfg80211: Add airtime statistics and settings

2018-07-09 Thread Toke Høiland-Jørgensen
This adds airtime statistics to the cfg80211 station dump, and also adds
a new parameter to set the airtime weight of each station. The latter
allows userspace to implement policies for different stations by varying
their weights.

Signed-off-by: Toke Høiland-Jørgensen 
---
 include/net/cfg80211.h   |   15 +++--
 include/uapi/linux/nl80211.h |   14 
 net/mac80211/cfg.c   |6 +
 net/mac80211/main.c  |2 +-
 net/mac80211/sta_info.c  |   15 +
 net/mac80211/sta_info.h  |4 ---
 net/wireless/core.c  |2 ++
 net/wireless/nl80211.c   |   50 ++
 8 files changed, 101 insertions(+), 7 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9ba1f289c439..1480eccbffe9 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -988,6 +988,7 @@ enum station_parameters_apply_mask {
  * @support_p2p_ps: information if station supports P2P PS mechanism
  * @he_capa: HE capabilities of station
  * @he_capa_len: the length of the HE capabilities
+ * @airtime_weight: airtime scheduler weight for this station
  */
 struct station_parameters {
const u8 *supported_rates;
@@ -1017,6 +1018,7 @@ struct station_parameters {
int support_p2p_ps;
const struct ieee80211_he_cap_elem *he_capa;
u8 he_capa_len;
+   u16 airtime_weight;
 };
 
 /**
@@ -1284,6 +1286,8 @@ struct cfg80211_tid_stats {
  * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
  * from this peer
  * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
+ * @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer
+ * @airtime_weight: current airtime scheduling weight
  * @pertid: per-TID statistics, see  cfg80211_tid_stats, using the last
  * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
  * Note that this doesn't use the @filled bit, but is used if non-NULL.
@@ -1330,10 +1334,12 @@ struct station_info {
 
u32 expected_throughput;
 
-   u64 rx_beacon;
+   u64 tx_duration;
u64 rx_duration;
+   u64 rx_beacon;
u8 rx_beacon_signal_avg;
struct cfg80211_tid_stats *pertid;
+   u16 airtime_weight;
s8 ack_signal;
s8 avg_ack_signal;
 };
@@ -2347,7 +2353,8 @@ enum cfg80211_connect_params_changed {
  * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
  * @WIPHY_PARAM_TXQ_LIMIT: TXQ packet limit has been changed
  * @WIPHY_PARAM_TXQ_MEMORY_LIMIT: TXQ memory limit has been changed
- * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum
+ * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum (bytes)
+ * @WIPHY_PARAM_AIRTIME_QUANTUM: Airtime scheduler quantum (usec)
  */
 enum wiphy_params_flags {
WIPHY_PARAM_RETRY_SHORT = 1 << 0,
@@ -2359,8 +2366,11 @@ enum wiphy_params_flags {
WIPHY_PARAM_TXQ_LIMIT   = 1 << 6,
WIPHY_PARAM_TXQ_MEMORY_LIMIT= 1 << 7,
WIPHY_PARAM_TXQ_QUANTUM = 1 << 8,
+   WIPHY_PARAM_AIRTIME_QUANTUM = 1 << 9,
 };
 
+#define IEEE80211_DEFAULT_AIRTIME_QUANTUM  300 /* usec */
+
 /**
  * struct cfg80211_pmksa - PMK Security Association
  *
@@ -4104,6 +4114,7 @@ struct wiphy {
u32 txq_limit;
u32 txq_memory_limit;
u32 txq_quantum;
+   u16 airtime_quantum;
 
char priv[0] __aligned(NETDEV_ALIGN);
 };
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 28550d01948f..c3ac69640475 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2241,6 +2241,11 @@ enum nl80211_commands {
  * association request when used with NL80211_CMD_NEW_STATION). Can be set
  * only if %NL80211_STA_FLAG_WME is set.
  *
+ * @NL80211_ATTR_AIRTIME_WEIGHT: Station's weight when scheduled by the airtime
+ *  scheduler.
+ * @NL80211_ATTR_AIRTIME_QUANTUM: Airtime scheduler quantum (usec). Airtime
+ *  share given to each station on each round of the airtime scheduler.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2682,6 +2687,9 @@ enum nl80211_attrs {
 
NL80211_ATTR_HE_CAPABILITY,
 
+   NL80211_ATTR_AIRTIME_WEIGHT,
+   NL80211_ATTR_AIRTIME_QUANTUM,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
@@ -3052,6 +3060,10 @@ enum nl80211_sta_bss_param {
  * @NL80211_STA_INFO_ACK_SIGNAL: signal strength of the last ACK frame(u8, dBm)
  * @NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG: avg signal strength of (data)
  * ACK frame (s8, dBm)
+ * @NL80211_STA_INFO_TX_DURATION: aggregate PPDU duration for all frames
+ * sent to the station (u64, usec)
+ * @NL80211_STA_INFO_AIRTIME_WEIGHT: current airtime weight for station
+ *  (u16, usec)
  * @__NL80211_STA_INFO_AFTER_LAST: internal
  * 

[RFC v2 1/4] mac80211: Add TXQ scheduling API

2018-07-09 Thread Toke Høiland-Jørgensen
This adds an API to mac80211 to handle scheduling of TXQs. The API
consists of two new functions: ieee80211_next_txq() and
ieee80211_schedule_txq(). The former returns the next TXQ that should be
scheduled, and is how the driver gets a queue to pull packets from. The
latter is called internally by mac80211 to start scheduling a queue, and
the driver is supposed to call it to re-schedule the TXQ after it is
finished pulling packets from it (unless the queue emptied). Drivers can
optionally filter TXQs on ac to support per-AC hardware queue designs,
and a sequence number mechanism is used to support drivers looping over
all available TXQs exactly once.

Using this API allows drivers to take advantage of mac80211 scheduling
features such as airtime fairness (added in a subsequent commit).
However, usage of the new API is optional, so support can be added to
individual drivers one at a time.

Signed-off-by: Toke Høiland-Jørgensen 
---
 include/net/mac80211.h |   50 +---
 net/mac80211/agg-tx.c  |2 +
 net/mac80211/ieee80211_i.h |7 
 net/mac80211/main.c|3 ++
 net/mac80211/sta_info.c|3 ++
 net/mac80211/tx.c  |   69 
 6 files changed, 130 insertions(+), 4 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5790f55c241d..18e43193b614 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -107,9 +107,16 @@
  * The driver is expected to initialize its private per-queue data for stations
  * and interfaces in the .add_interface and .sta_add ops.
  *
- * The driver can't access the queue directly. To dequeue a frame, it calls
- * ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it
- * calls the .wake_tx_queue driver op.
+ * The driver can't access the queue directly. To dequeue a frame from a
+ * txq, it calls ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to 
a
+ * queue, it calls the .wake_tx_queue driver op.
+ *
+ * Drivers can optionally delegate responsibility for scheduling queues to
+ * mac80211, to take advantage of airtime fairness accounting. In this case, to
+ * obtain the next queue to pull frames from, the driver calls
+ * ieee80211_next_txq(). The driver is then expected to re-schedule the txq
+ * using ieee80211_schedule_txq() if it is still active after the driver has
+ * finished pulling packets from it.
  *
  * For AP powersave TIM handling, the driver only needs to indicate if it has
  * buffered packets in the driver specific data structures by calling
@@ -5971,13 +5978,48 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, 
u8 tid);
  * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
  *
  * @hw: pointer as obtained from ieee80211_alloc_hw()
- * @txq: pointer obtained from station or virtual interface
+ * @txq: pointer obtained from station or virtual interface, or from
+ *   ieee80211_next_txq()
  *
  * Returns the skb if successful, %NULL if no frame was available.
  */
 struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
 struct ieee80211_txq *txq);
 
+/**
+ * ieee80211_schedule_txq - add txq to scheduling loop
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @txq: pointer obtained from station or virtual interface
+ * @reset_seqno: Whether to reset the internal scheduling sequence number,
+ *   allowing this txq to appear again in the current scheduling
+ *   round (see doc for ieee80211_next_txq()).
+ *
+ * Returns %true if the txq was actually added to the scheduling,
+ * %false otherwise.
+ */
+bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
+   struct ieee80211_txq *txq,
+   bool reset_seqno);
+
+/**
+ * ieee80211_next_txq - get next tx queue to pull packets from
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @ac: filter returned txqs with this AC number. Pass -1 for no filtering.
+ * @inc_seqno: Whether to increase the scheduling sequence number. Setting this
+ * to true signifies the start of a new scheduling round. Each TXQ
+ * will only be returned exactly once in each round (unless its
+ * sequence number is explicitly reset when calling
+ * ieee80211_schedule_txq()).
+ *
+ * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
+ * is returned, it will have been removed from the scheduler queue and needs to
+ * be re-scheduled with ieee80211_schedule_txq() to continue to be active.
+ */
+struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, s8 ac,
+bool inc_seqno);
+
 /**
  * ieee80211_txq_get_depth - get pending frame/byte count of given txq
  *
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 69e831bc317b..0a2e0d64fc11 100644
--- a/net/mac80211/agg-tx.c
+++ 

[RFC v2 0/4] Move TXQ scheduling into mac80211

2018-07-09 Thread Toke Høiland-Jørgensen
This is an updated version of my previous patch series to move TXQ
scheduling into mac80211, allowing more drivers to take advantage of
airtime fairness scheduling. This version keeps compatibility with the
old wake_tx_queue API, so drivers can be ported to the new API one at a
time. For now, only ath9k is changed.

There's also an update to the scheduling to use a sequence number to
keep track of scheduling rounds, so drivers have a clean way to loop
through all queued TXQs exactly once without having to keep track of the
first TXQ seen in a round.

Finally, the airtime fairness scheduler also incorporates weights into
the scheduling, which allows userspace to implement policies for how
airtime is divided between stations. I have a patch series for hostapd
to implement configurable policies, that I will post separately once the
kernel side is in place.

---

Toke Høiland-Jørgensen (4):
  mac80211: Add TXQ scheduling API
  mac80211: Add airtime accounting and scheduling to TXQs
  cfg80211: Add airtime statistics and settings
  ath9k: Switch to mac80211 TXQ scheduling and airtime APIs


 drivers/net/wireless/ath/ath9k/ath9k.h |   14 --
 drivers/net/wireless/ath/ath9k/debug.c |3 
 drivers/net/wireless/ath/ath9k/debug.h |8 -
 drivers/net/wireless/ath/ath9k/debug_sta.c |   54 --
 drivers/net/wireless/ath/ath9k/init.c  |3 
 drivers/net/wireless/ath/ath9k/recv.c  |9 -
 drivers/net/wireless/ath/ath9k/xmit.c  |  245 
 include/net/cfg80211.h |   15 +-
 include/net/mac80211.h |   78 -
 include/uapi/linux/nl80211.h   |   17 ++
 net/mac80211/agg-tx.c  |2 
 net/mac80211/cfg.c |6 +
 net/mac80211/debugfs.c |3 
 net/mac80211/debugfs_sta.c |   35 
 net/mac80211/ieee80211_i.h |   10 +
 net/mac80211/main.c|5 +
 net/mac80211/sta_info.c|   42 +
 net/mac80211/sta_info.h|   13 +
 net/mac80211/tx.c  |  101 
 net/wireless/core.c|2 
 net/wireless/nl80211.c |   50 ++
 21 files changed, 449 insertions(+), 266 deletions(-)



[PATCH 2/2] mt7601u: expose 802.11w support

2018-07-09 Thread Lorenzo Bianconi
From: Davide Caratti 

Set MFP_CAPABLE bit in hw flag capabilities exported by the driver

Signed-off-by: Davide Caratti 
Signed-off-by: Lorenzo Bianconi 
---
 drivers/net/wireless/mediatek/mt7601u/init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mediatek/mt7601u/init.c 
b/drivers/net/wireless/mediatek/mt7601u/init.c
index d3b611aaf061..faea99b7a445 100644
--- a/drivers/net/wireless/mediatek/mt7601u/init.c
+++ b/drivers/net/wireless/mediatek/mt7601u/init.c
@@ -603,6 +603,7 @@ int mt7601u_register_device(struct mt7601u_dev *dev)
ieee80211_hw_set(hw, SUPPORTS_HT_CCK_RATES);
ieee80211_hw_set(hw, AMPDU_AGGREGATION);
ieee80211_hw_set(hw, SUPPORTS_RC_TABLE);
+   ieee80211_hw_set(hw, MFP_CAPABLE);
hw->max_rates = 1;
hw->max_report_rates = 7;
hw->max_rate_tries = 1;
-- 
2.17.1



[PATCH 1/2] mt7601u: use sw encryption for hw unsupported ciphers

2018-07-09 Thread Lorenzo Bianconi
Fall back to software encryption for hw unsupported ciphers in order
to enable 802.11w

Signed-off-by: Lorenzo Bianconi 
---
 drivers/net/wireless/mediatek/mt7601u/main.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c 
b/drivers/net/wireless/mediatek/mt7601u/main.c
index 7b21016012c3..0f1789020960 100644
--- a/drivers/net/wireless/mediatek/mt7601u/main.c
+++ b/drivers/net/wireless/mediatek/mt7601u/main.c
@@ -308,6 +308,17 @@ mt7601u_set_key(struct ieee80211_hw *hw, enum set_key_cmd 
cmd,
int idx = key->keyidx;
int ret;
 
+   /* fall back to sw encryption for unsupported ciphers */
+   switch (key->cipher) {
+   case WLAN_CIPHER_SUITE_WEP40:
+   case WLAN_CIPHER_SUITE_WEP104:
+   case WLAN_CIPHER_SUITE_TKIP:
+   case WLAN_CIPHER_SUITE_CCMP:
+   break;
+   default:
+   return -EOPNOTSUPP;
+   }
+
if (cmd == SET_KEY) {
key->hw_key_idx = wcid->idx;
wcid->hw_key_idx = idx;
-- 
2.17.1



[PATCH 0/2] enable 802.11w in mt7601u driver

2018-07-09 Thread Lorenzo Bianconi
Lorenzo Bianconi (1):
  mt7601u: use sw encryption for hw unsupported ciphers

Davide Caratti (1):
  mt7601u: expose 802.11w support

 drivers/net/wireless/mediatek/mt7601u/init.c |  1 +
 drivers/net/wireless/mediatek/mt7601u/main.c | 11 +++
 2 files changed, 12 insertions(+)

-- 
2.17.1



Re: [PATCH] mac80211: restrict delayed tailroom needed decrement

2018-07-09 Thread Johannes Berg
On Mon, 2018-07-09 at 15:07 +0530, Manikanta Pubbisetty wrote:

> > I think you should do
> > 
> > ieee80211_key_destroy(..., type == STATION);
> 
> Even this would boil down to the same behavior, no?

Yes, but I think it's easier to understand than thinking "ok this will
delay" when you pass the parameter as true, but then it won't unless
extra conditions are met.

> I was going through the source to figure out that; but all that I could 
> understand is this was mainly done to improve roam time.

Ok, so perhaps more callers should be updated - still I think it'd be
easier to understand.

johannes


Re: [PATCH] mac80211: restrict delayed tailroom needed decrement

2018-07-09 Thread Manikanta Pubbisetty




On 7/9/2018 2:56 PM, Johannes Berg wrote:

On Mon, 2018-07-09 at 14:54 +0530, Manikanta Pubbisetty wrote:


This describes a scenario where there's *unnecessary* work done, but not
really one where we have something that's *incorrect*?


To me at least doing unnecessary things is incorrect :-D, may be we can
change the statement.

Well, I guess it's a question of semantics, but this doesn't really
result in any observable incorrect behaviour.


Okay.


Are you saying that you found a problem with this? Did this show up in
some sort of measurements?

Not really, I have observed in my testing that there were warnings
whenever a AP_VLAN was brought down; this is done in ieee80211_free_keys.
Warnings show up every time we bring down the AP_VLAN interface(using
ifconfig); warnings apart but I thought there would be unnecessary
overhead in the tailroom expansion though the overhead may be trivial.

Except for that maybe :-)


:-)


+++ b/net/mac80211/key.c
@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key 
*key,
   
   		ieee80211_debugfs_key_remove(key);
   
-		if (delay_tailroom) {

+   if (delay_tailroom &&
+   sdata->vif.type == NL80211_IFTYPE_STATION) {
/* see ieee80211_delayed_tailroom_dec */
sdata->crypto_tx_tailroom_pending_dec++;
schedule_delayed_work(>dec_tailroom_needed_wk,

I think you'd better change the caller, i.e. ieee80211_del_key(), and a
add a comment there that explains what's going on.

Not really sure what you were trying to tell here.

I think you should do

ieee80211_key_destroy(..., type == STATION);


Even this would boil down to the same behavior, no?



in the caller, instead of hard-coding the thing here.

There may be more places that want the delay, perhaps for other reasons?


I was going through the source to figure out that; but all that I could 
understand is this was mainly done to improve roam time.


Re: [PATCH] mac80211: restrict delayed tailroom needed decrement

2018-07-09 Thread Johannes Berg
On Mon, 2018-07-09 at 14:54 +0530, Manikanta Pubbisetty wrote:

> > This describes a scenario where there's *unnecessary* work done, but not
> > really one where we have something that's *incorrect*?
> > 
> 
> To me at least doing unnecessary things is incorrect :-D, may be we can 
> change the statement.

Well, I guess it's a question of semantics, but this doesn't really
result in any observable incorrect behaviour.

> > Are you saying that you found a problem with this? Did this show up in
> > some sort of measurements?
> 
> Not really, I have observed in my testing that there were warnings 
> whenever a AP_VLAN was brought down; this is done in ieee80211_free_keys.
> Warnings show up every time we bring down the AP_VLAN interface(using 
> ifconfig); warnings apart but I thought there would be unnecessary 
> overhead in the tailroom expansion though the overhead may be trivial.

Except for that maybe :-)

> > > +++ b/net/mac80211/key.c
> > > @@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct 
> > > ieee80211_key *key,
> > >   
> > >   ieee80211_debugfs_key_remove(key);
> > >   
> > > - if (delay_tailroom) {
> > > + if (delay_tailroom &&
> > > + sdata->vif.type == NL80211_IFTYPE_STATION) {
> > >   /* see ieee80211_delayed_tailroom_dec */
> > >   sdata->crypto_tx_tailroom_pending_dec++;
> > >   
> > > schedule_delayed_work(>dec_tailroom_needed_wk,
> > 
> > I think you'd better change the caller, i.e. ieee80211_del_key(), and a
> > add a comment there that explains what's going on.
> 
> Not really sure what you were trying to tell here.

I think you should do

ieee80211_key_destroy(..., type == STATION);

in the caller, instead of hard-coding the thing here.

There may be more places that want the delay, perhaps for other reasons?

johannes


Re: [PATCH] mac80211: restrict delayed tailroom needed decrement

2018-07-09 Thread Manikanta Pubbisetty




For example, let's consider the case of a 4-addr client connecting to
an AP for which AP_VLAN interface is also created, let the initial
value for tailroom_needed on the AP be 1.

* 4-addr client connects to the AP (AP: tailroom_needed = 1)
* AP will clear old keys, delay decrement of tailroom_needed count
* AP_VLAN is created, it takes the tailroom count from master
   (AP_VLAN: tailroom_needed = 1, AP: tailroom_needed = 1)
* Install new key for the station, assume key is plumbed in the HW,
   there won't be any change in tailroom_needed count on AP iface
* Delayed decrement of tailroom_needed count on AP
   (AP: tailroom_needed = 0, AP_VLAN: tailroom_needed = 1)

Because of the delayed decrement on AP iface, tailroom_needed count goes
out of sync between AP(master iface) and AP_VLAN(slave iface) and
there would be unnecessary tailroom created for the packets going
through AP_VLAN iface.

This describes a scenario where there's *unnecessary* work done, but not
really one where we have something that's *incorrect*?



To me at least doing unnecessary things is incorrect :-D, may be we can 
change the statement.



Are you saying that you found a problem with this? Did this show up in
some sort of measurements?


Not really, I have observed in my testing that there were warnings 
whenever a AP_VLAN was brought down; this is done in ieee80211_free_keys.
Warnings show up every time we bring down the AP_VLAN interface(using 
ifconfig); warnings apart but I thought there would be unnecessary 
overhead in the tailroom expansion though the overhead may be trivial.



+++ b/net/mac80211/key.c
@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key 
*key,
  
  		ieee80211_debugfs_key_remove(key);
  
-		if (delay_tailroom) {

+   if (delay_tailroom &&
+   sdata->vif.type == NL80211_IFTYPE_STATION) {
/* see ieee80211_delayed_tailroom_dec */
sdata->crypto_tx_tailroom_pending_dec++;
schedule_delayed_work(>dec_tailroom_needed_wk,

I think you'd better change the caller, i.e. ieee80211_del_key(), and a
add a comment there that explains what's going on.


Not really sure what you were trying to tell here.

Manikanta


Re: [PATCH] mac80211: restrict delayed tailroom needed decrement

2018-07-09 Thread Johannes Berg
On Mon, 2018-07-09 at 14:28 +0530, Manikanta Pubbisetty wrote:
> As explained in ieee80211_delayed_tailroom_dec(), during roam,
> keys of the old AP will be destroyed and new keys will be
> installed. Deletion of the old key causes
> crypto_tx_tailroom_needed_cnt to go from 1 to 0 and the new key
> installation causes a transition from 0 to 1.
> 
> Whenever crypto_tx_tailroom_needed_cnt transitions from 0 to 1,
> we invoke synchronize_net(); the reason for doing this is to avoid
> a race in the TX path as explained in increment_tailroom_need_count().
> This synchronize_net() operation can be slow and can affect the station
> roam time. To avoid this, decrementing the crypto_tx_tailroom_needed_cnt
> is delayed for a while so that upon installation of new key the
> transition would be from 1 to 2 instead of 0 to 1 and thereby
> improving the roam time.

Right.

> This is all correct for a STA iftype, but deferring the tailroom_needed
> decrement for other iftypes may be incorrect.

I don't understand this. What do you mean by "incorrect"?

> For example, let's consider the case of a 4-addr client connecting to
> an AP for which AP_VLAN interface is also created, let the initial
> value for tailroom_needed on the AP be 1.
> 
> * 4-addr client connects to the AP (AP: tailroom_needed = 1)
> * AP will clear old keys, delay decrement of tailroom_needed count
> * AP_VLAN is created, it takes the tailroom count from master
>   (AP_VLAN: tailroom_needed = 1, AP: tailroom_needed = 1)
> * Install new key for the station, assume key is plumbed in the HW,
>   there won't be any change in tailroom_needed count on AP iface
> * Delayed decrement of tailroom_needed count on AP
>   (AP: tailroom_needed = 0, AP_VLAN: tailroom_needed = 1)
> 
> Because of the delayed decrement on AP iface, tailroom_needed count goes
> out of sync between AP(master iface) and AP_VLAN(slave iface) and
> there would be unnecessary tailroom created for the packets going
> through AP_VLAN iface.

This describes a scenario where there's *unnecessary* work done, but not
really one where we have something that's *incorrect*?

Are you saying that you found a problem with this? Did this show up in
some sort of measurements?

> +++ b/net/mac80211/key.c
> @@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key 
> *key,
>  
>   ieee80211_debugfs_key_remove(key);
>  
> - if (delay_tailroom) {
> + if (delay_tailroom &&
> + sdata->vif.type == NL80211_IFTYPE_STATION) {
>   /* see ieee80211_delayed_tailroom_dec */
>   sdata->crypto_tx_tailroom_pending_dec++;
>   schedule_delayed_work(>dec_tailroom_needed_wk,

I think you'd better change the caller, i.e. ieee80211_del_key(), and a
add a comment there that explains what's going on.

But I'm not yet really sure what you're trying to do :-)

johannes


[PATCH] mac80211: restrict delayed tailroom needed decrement

2018-07-09 Thread Manikanta Pubbisetty
As explained in ieee80211_delayed_tailroom_dec(), during roam,
keys of the old AP will be destroyed and new keys will be
installed. Deletion of the old key causes
crypto_tx_tailroom_needed_cnt to go from 1 to 0 and the new key
installation causes a transition from 0 to 1.

Whenever crypto_tx_tailroom_needed_cnt transitions from 0 to 1,
we invoke synchronize_net(); the reason for doing this is to avoid
a race in the TX path as explained in increment_tailroom_need_count().
This synchronize_net() operation can be slow and can affect the station
roam time. To avoid this, decrementing the crypto_tx_tailroom_needed_cnt
is delayed for a while so that upon installation of new key the
transition would be from 1 to 2 instead of 0 to 1 and thereby
improving the roam time.

This is all correct for a STA iftype, but deferring the tailroom_needed
decrement for other iftypes may be incorrect.

For example, let's consider the case of a 4-addr client connecting to
an AP for which AP_VLAN interface is also created, let the initial
value for tailroom_needed on the AP be 1.

* 4-addr client connects to the AP (AP: tailroom_needed = 1)
* AP will clear old keys, delay decrement of tailroom_needed count
* AP_VLAN is created, it takes the tailroom count from master
  (AP_VLAN: tailroom_needed = 1, AP: tailroom_needed = 1)
* Install new key for the station, assume key is plumbed in the HW,
  there won't be any change in tailroom_needed count on AP iface
* Delayed decrement of tailroom_needed count on AP
  (AP: tailroom_needed = 0, AP_VLAN: tailroom_needed = 1)

Because of the delayed decrement on AP iface, tailroom_needed count goes
out of sync between AP(master iface) and AP_VLAN(slave iface) and
there would be unnecessary tailroom created for the packets going
through AP_VLAN iface.

Restricting delayed decrement to station interface alone fixes the problem
and it makes sense to do so because delayed decrement is done to improve
roam time which is applicable only for client devices.

Signed-off-by: Manikanta Pubbisetty 
---
 net/mac80211/key.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index ee0d0cc..d1ea86a 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -583,7 +583,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key 
*key,
 
ieee80211_debugfs_key_remove(key);
 
-   if (delay_tailroom) {
+   if (delay_tailroom &&
+   sdata->vif.type == NL80211_IFTYPE_STATION) {
/* see ieee80211_delayed_tailroom_dec */
sdata->crypto_tx_tailroom_pending_dec++;
schedule_delayed_work(>dec_tailroom_needed_wk,
-- 
2.7.4



Re: [PATCH v2] mac80211: Fix wlan freezes under load at rekey

2018-07-09 Thread Johannes Berg
Hi,

> I'll try that, but will probably take another week. My main main work
> station got severe file system corruption, forcing me to reinstall it
> from scratch. I suspect it was something in the wireless testing kernel
> 4.18-rc1 (944ae08d4e71) related to either btrfs or the ssd disk but
> since I needed the system just started over and avoid to run 4.18 if I
> do not have a full backup...

Ouch. FWIW, it's possible to run inside a VM with PCI(e) devices
outside, at least on some machines.

> > > hostapd or wpa_supplicant are "ordering" mac80211 to install a new key
> > > and are implementing the state machine and are in a good position to
> > > handle the fallout... at least theoretically.
> > 
> > Ideally it would even know beforehand that we don't want to handle the
> > PTK rekeying, and then could reconnect instead of going through the
> > handshake.
> > 
> 
> Don't see how we could do that in the kernel, all the relevant
> information is handled in the state machine. I guess an API extension
> telling hostap/supplicant if we can handle rekeys or not would tbe he
> only way to avoid that.

Right. Not really much point for now I guess.

> > So I think we're probably better off accepting the set_key but not
> > actually using it, and instead disconnecting... even if that's awkward
> > and should come with a big comment :-)
> 
> Instead of returning an error I'll change the code to accept the rekey
> but do nothing with it. (Basically delete the new key and keep the old
> active).
> And of course calling ieee80211_set_disassoc() prior to return "success".

Right. Did you handle/consider modes other than BSS/P2P client btw?

> Let's see how the supplicant will react on a disassoc while doing a rekey...

Shouldn't matter to it, I'd think.

johannes