[PATCH] b43: Replace mdelay with msleep in b43_radio_2057_init_post

2017-12-23 Thread Jia-Ju Bai
b43_radio_2057_init_post is not called in an interrupt handler 
nor holding a spinlock.
The function mdelay in it can be replaced with msleep, to reduce busy wait.

Signed-off-by: Jia-Ju Bai 
---
 drivers/net/wireless/broadcom/b43/phy_n.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c 
b/drivers/net/wireless/broadcom/b43/phy_n.c
index a5557d7..5bc838e 100644
--- a/drivers/net/wireless/broadcom/b43/phy_n.c
+++ b/drivers/net/wireless/broadcom/b43/phy_n.c
@@ -1031,7 +1031,7 @@ static void b43_radio_2057_init_post(struct b43_wldev 
*dev)
 
b43_radio_set(dev, R2057_RFPLL_MISC_CAL_RESETN, 0x78);
b43_radio_set(dev, R2057_XTAL_CONFIG2, 0x80);
-   mdelay(2);
+   msleep(2);
b43_radio_mask(dev, R2057_RFPLL_MISC_CAL_RESETN, ~0x78);
b43_radio_mask(dev, R2057_XTAL_CONFIG2, ~0x80);
 
-- 
1.7.9.5



[ANN] wireless-regdb: master-2017-12-23

2017-12-23 Thread Seth Forshee
A new release of wireless-regdb (master-2017-12-23) is available at:

https://www.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-2017.12.23.tar.gz

Note that this is the first release to include the new regulatory
database format, supporting direct loading of the database by the
kernel. The short log of changes since the 2017-03-07 release is below.

Thanks,
Seth

---

Andreas Mohr (1):
  wireless-regdb: reduce power level limit of KR (Korea) 802.11b/g/n to the 
certification-requested "20mW" (13dBm).

Aron Rosenberg (1):
  Set NO-OUTDOOR Flag on Canada 5Ghz 5150 to 5250

Chen-Yu Tsai (2):
  wireless-regdb: Update regulatory document references for Taiwan (TW)
  wireless-regdb: Add 60 GHz rule for Taiwan (TW)

Edwin Steele (1):
  wireless-regdb: Update rules for Turkey 5ghz

Johannes Berg (1):
  regdb: write firmware file format (version code 20)

Seth Forshee (8):
  wireless-regdb: Add 5 Ghz rules for Kazakhstan (KZ)
  wireless-regdb: Update rules for Denmark (DK)
  wireless-regdb: Restore generation of old format database files
  wireless-regdb: Add sforshee's x509 certificate
  wireless-regdb: Better support for generating public certificates
  wireless-regdb: Install regulatory.db and regulatory.db.p7s to 
/lib/firmware
  wireless-regdb: Document regulatory.db in the manual page
  wireless-regdb: update regulatory database based on preceding changes

Sven Eckelmann (1):
  wireless-regdb: Update regulatory rules for Singapore (SG)

Xose Vazquez Perez (1):
  wireless-regdb: add Short Range Devices (SRD) (ETSI EN 300 440) for Spain


Re: [PATCH] wireless-regdb: Update rules for Denmark (DK)

2017-12-23 Thread Seth Forshee
On Fri, Dec 22, 2017 at 10:38:08AM -0600, Seth Forshee wrote:
> Refresh the frequency ranges and power limits based on the
> following sources:
> 
>  
> https://erhvervsstyrelsen.dk/sites/default/files/007_interface-datanet_5-6_ghz.pdf.pdf
>  https://erhvervsstyrelsen.dk/sites/default/files/radiograenseflader-63.pdf
> 
> Cc: Per Mejdal Rasmussen 
> Signed-off-by: Seth Forshee 

Applied.


Re: [PATCH v3 00/27] kill devm_ioremap_nocache

2017-12-23 Thread Guenter Roeck

On 12/23/2017 05:48 AM, Greg KH wrote:

On Sat, Dec 23, 2017 at 06:55:25PM +0800, Yisheng Xie wrote:

Hi all,

When I tried to use devm_ioremap function and review related code, I found
devm_ioremap and devm_ioremap_nocache is almost the same with each other,
except one use ioremap while the other use ioremap_nocache.


For all arches?  Really?  Look at MIPS, and x86, they have different
functions.



Both mips and x86 end up mapping the same function, but other arches don't.
mn10300 is one where ioremap and ioremap_nocache are definitely different.

Guenter


While ioremap's
default function is ioremap_nocache, so devm_ioremap_nocache also have the
same function with devm_ioremap, which can just be killed to reduce the size
of devres.o(from 20304 bytes to 18992 bytes in my compile environment).

I have posted two versions, which use macro instead of function for
devm_ioremap_nocache[1] or devm_ioremap[2]. And Greg suggest me to kill
devm_ioremap_nocache for no need to keep a macro around for the duplicate
thing. So here comes v3 and please help to review.


I don't think this can be done, what am I missing?  These functions are
not identical, sorry for missing that before.

thanks,

greg k-h





Re: [PATCH v3 00/27] kill devm_ioremap_nocache

2017-12-23 Thread Greg KH
On Sat, Dec 23, 2017 at 06:55:25PM +0800, Yisheng Xie wrote:
> Hi all,
> 
> When I tried to use devm_ioremap function and review related code, I found
> devm_ioremap and devm_ioremap_nocache is almost the same with each other,
> except one use ioremap while the other use ioremap_nocache.

For all arches?  Really?  Look at MIPS, and x86, they have different
functions.

> While ioremap's
> default function is ioremap_nocache, so devm_ioremap_nocache also have the
> same function with devm_ioremap, which can just be killed to reduce the size
> of devres.o(from 20304 bytes to 18992 bytes in my compile environment).
> 
> I have posted two versions, which use macro instead of function for
> devm_ioremap_nocache[1] or devm_ioremap[2]. And Greg suggest me to kill
> devm_ioremap_nocache for no need to keep a macro around for the duplicate
> thing. So here comes v3 and please help to review.

I don't think this can be done, what am I missing?  These functions are
not identical, sorry for missing that before.

thanks,

greg k-h


Re: [PATCH v3 27/27] devres: kill devm_ioremap_nocache

2017-12-23 Thread Greg KH
On Sat, Dec 23, 2017 at 07:02:59PM +0800, Yisheng Xie wrote:
> --- a/lib/devres.c
> +++ b/lib/devres.c
> @@ -44,35 +44,6 @@ void __iomem *devm_ioremap(struct device *dev, 
> resource_size_t offset,
>  EXPORT_SYMBOL(devm_ioremap);
>  
>  /**
> - * devm_ioremap_nocache - Managed ioremap_nocache()
> - * @dev: Generic device to remap IO address for
> - * @offset: Resource address to map
> - * @size: Size of map
> - *
> - * Managed ioremap_nocache().  Map is automatically unmapped on driver
> - * detach.
> - */
> -void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t 
> offset,
> -resource_size_t size)
> -{
> - void __iomem **ptr, *addr;
> -
> - ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
> - if (!ptr)
> - return NULL;
> -
> - addr = ioremap_nocache(offset, size);

Wait, devm_ioremap() calls ioremap(), not ioremap_nocache(), are you
_SURE_ that these are all identical?  For all arches?  If so, then
ioremap_nocache() can also be removed, right?

In my quick glance, I don't think you can do this series at all :(

greg k-h


Re: MT7630 support

2017-12-23 Thread Lorenzo Bianconi
> Hi
>
> On Thu, 21 Dec 2017, Stanislaw Gruszka wrote:
>
>> On Wed, Dec 20, 2017 at 06:39:34PM +0100, Enrico Mioso wrote:
>> > Hello guys.
>> > So, at some point I felt crazy enough to try to add support for the MT7630 
>> > chipset to the rt2xx ralink wireless drivers.
>> > I expected this to be a little bit of a challenge.
>> > I did begin adding some code paths around, reading from the mixed-up 
>> > drivers here:
>> > https://github.com/neurobin/MT7630E
>> > (thanks a lot to the guys who are working on this, and who worked on this).
>> > and working on the kernel's git rt2xx tree. I am sending a raw diff that 
>> > will for sure not compile. I am asking for guidance and help in going on.
>>
>> I think better way to add support for MT7630 chip to mailine kernel
>> would be via new Felix's mt76 driver, because there are less diffrence
>> between MT7630 and MT76x2 than between MT7630 and the old Ralink chips.
>>
>
> MT7630e is part of the MT76x0 family
> Felix's driver is missing the baseband/rf tables for MT76x0.
>
> The full driver for MT7610E is here
> https://github.com/i80s/mtk-sources
>
> /me now reading Felix code to adapot MT76x2 for mt7612u ...

Hi Hans,

very good news since that task is in my TODO list for a while now so I
guess we can start working together on it.
Have you already had some working code to support mt7612u on mt76 or
just looking at the code?

Regards,
Lorenzo

>
> Greetings
> Ulli



-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep


[PATCH v3 27/27] devres: kill devm_ioremap_nocache

2017-12-23 Thread Yisheng Xie
Now, nobody use devm_ioremap_nocache anymore, can it can just be
removed. After this patch the size of devres.o will be reduced from
20304 bytes to 18992 bytes.

Suggested-by: Greg KH 
Signed-off-by: Yisheng Xie 
---
 Documentation/driver-model/devres.txt   |  1 -
 include/linux/io.h  |  2 --
 lib/devres.c| 29 -
 scripts/coccinelle/free/devm_free.cocci |  2 --
 4 files changed, 34 deletions(-)

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index c180045..c3fddb5 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -292,7 +292,6 @@ IOMAP
   devm_ioport_map()
   devm_ioport_unmap()
   devm_ioremap()
-  devm_ioremap_nocache()
   devm_ioremap_wc()
   devm_ioremap_resource() : checks resource, requests memory region, ioremaps
   devm_iounmap()
diff --git a/include/linux/io.h b/include/linux/io.h
index 32e30e8..a9c7270 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -75,8 +75,6 @@ static inline void devm_ioport_unmap(struct device *dev, void 
__iomem *addr)
 
 void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
   resource_size_t size);
-void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
-  resource_size_t size);
 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
   resource_size_t size);
 void devm_iounmap(struct device *dev, void __iomem *addr);
diff --git a/lib/devres.c b/lib/devres.c
index 5f2aedd..f818fcf 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -44,35 +44,6 @@ void __iomem *devm_ioremap(struct device *dev, 
resource_size_t offset,
 EXPORT_SYMBOL(devm_ioremap);
 
 /**
- * devm_ioremap_nocache - Managed ioremap_nocache()
- * @dev: Generic device to remap IO address for
- * @offset: Resource address to map
- * @size: Size of map
- *
- * Managed ioremap_nocache().  Map is automatically unmapped on driver
- * detach.
- */
-void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
-  resource_size_t size)
-{
-   void __iomem **ptr, *addr;
-
-   ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
-   if (!ptr)
-   return NULL;
-
-   addr = ioremap_nocache(offset, size);
-   if (addr) {
-   *ptr = addr;
-   devres_add(dev, ptr);
-   } else
-   devres_free(ptr);
-
-   return addr;
-}
-EXPORT_SYMBOL(devm_ioremap_nocache);
-
-/**
  * devm_ioremap_wc - Managed ioremap_wc()
  * @dev: Generic device to remap IO address for
  * @offset: Resource address to map
diff --git a/scripts/coccinelle/free/devm_free.cocci 
b/scripts/coccinelle/free/devm_free.cocci
index c990d2c..36b8752 100644
--- a/scripts/coccinelle/free/devm_free.cocci
+++ b/scripts/coccinelle/free/devm_free.cocci
@@ -51,8 +51,6 @@ expression x;
 |
  x = devm_ioremap(...)
 |
- x = devm_ioremap_nocache(...)
-|
  x = devm_ioport_map(...)
 )
 
-- 
1.8.3.1



[PATCH v3 25/27] wireless: replace devm_ioremap_nocache with devm_ioremap

2017-12-23 Thread Yisheng Xie
Default ioremap is ioremap_nocache, so devm_ioremap has the same
function with devm_ioremap_nocache, which can just be killed to
save the size of devres.o

This patch is to use use devm_ioremap instead of devm_ioremap_nocache,
which should not have any function change but prepare for killing
devm_ioremap_nocache.

Cc: Kalle Valo 
Cc: linux-wireless@vger.kernel.org
Cc: net...@vger.kernel.org
Signed-off-by: Yisheng Xie 
---
 drivers/net/wireless/ath/ath9k/ahb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ahb.c 
b/drivers/net/wireless/ath/ath9k/ahb.c
index 2bd982c..6e13e62 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -91,7 +91,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
return -ENXIO;
}
 
-   mem = devm_ioremap_nocache(>dev, res->start, resource_size(res));
+   mem = devm_ioremap(>dev, res->start, resource_size(res));
if (mem == NULL) {
dev_err(>dev, "ioremap failed\n");
return -ENOMEM;
-- 
1.8.3.1



[PATCH v3 00/27] kill devm_ioremap_nocache

2017-12-23 Thread Yisheng Xie
Hi all,

When I tried to use devm_ioremap function and review related code, I found
devm_ioremap and devm_ioremap_nocache is almost the same with each other,
except one use ioremap while the other use ioremap_nocache. While ioremap's
default function is ioremap_nocache, so devm_ioremap_nocache also have the
same function with devm_ioremap, which can just be killed to reduce the size
of devres.o(from 20304 bytes to 18992 bytes in my compile environment).

I have posted two versions, which use macro instead of function for
devm_ioremap_nocache[1] or devm_ioremap[2]. And Greg suggest me to kill
devm_ioremap_nocache for no need to keep a macro around for the duplicate
thing. So here comes v3 and please help to review.

Thanks so much!
Yisheng Xie

[1] https://lkml.org/lkml/2017/11/20/135
[2] https://lkml.org/lkml/2017/11/25/21

Yisheng Xie (27):
  ASOC: replace devm_ioremap_nocache with devm_ioremap
  spi: replace devm_ioremap_nocache with devm_ioremap
  staging: replace devm_ioremap_nocache with devm_ioremap
  ipack: replace devm_ioremap_nocache with devm_ioremap
  media: replace devm_ioremap_nocache with devm_ioremap
  gpio: replace devm_ioremap_nocache with devm_ioremap
  mmc: replace devm_ioremap_nocache with devm_ioremap
  PCI: replace devm_ioremap_nocache with devm_ioremap
  platform/x86: replace devm_ioremap_nocache with devm_ioremap
  tty: replace devm_ioremap_nocache with devm_ioremap
  video: replace devm_ioremap_nocache with devm_ioremap
  rtc: replace devm_ioremap_nocache with devm_ioremap
  char: replace devm_ioremap_nocache with devm_ioremap
  mtd: nand: replace devm_ioremap_nocache with devm_ioremap
  dmaengine: replace devm_ioremap_nocache with devm_ioremap
  ata: replace devm_ioremap_nocache with devm_ioremap
  irqchip: replace devm_ioremap_nocache with devm_ioremap
  pinctrl: replace devm_ioremap_nocache with devm_ioremap
  drm: replace devm_ioremap_nocache with devm_ioremap
  regulator: replace devm_ioremap_nocache with devm_ioremap
  watchdog: replace devm_ioremap_nocache with devm_ioremap
  tools/testing/nvdimm: replace devm_ioremap_nocache with devm_ioremap
  MIPS: pci: replace devm_ioremap_nocache with devm_ioremap
  can: replace devm_ioremap_nocache with devm_ioremap
  wireless: replace devm_ioremap_nocache with devm_ioremap
  ethernet: replace devm_ioremap_nocache with devm_ioremap
  devres: kill devm_ioremap_nocache

 Documentation/driver-model/devres.txt   |  1 -
 arch/mips/pci/pci-ar2315.c  |  3 +--
 drivers/ata/pata_arasan_cf.c|  3 +--
 drivers/ata/pata_octeon_cf.c|  9 
 drivers/ata/pata_rb532_cf.c |  2 +-
 drivers/char/hw_random/bcm63xx-rng.c|  3 +--
 drivers/char/hw_random/octeon-rng.c | 10 -
 drivers/dma/altera-msgdma.c |  3 +--
 drivers/dma/sprd-dma.c  |  4 ++--
 drivers/gpio/gpio-ath79.c   |  3 +--
 drivers/gpio/gpio-em.c  |  6 ++---
 drivers/gpio/gpio-htc-egpio.c   |  4 ++--
 drivers/gpio/gpio-xgene.c   |  3 +--
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_drv.c   |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c   |  3 +--
 drivers/gpu/drm/sti/sti_hda.c   |  4 ++--
 drivers/gpu/drm/sti/sti_hdmi.c  |  2 +-
 drivers/gpu/drm/sti/sti_tvout.c |  2 +-
 drivers/gpu/drm/sti/sti_vtg.c   |  2 +-
 drivers/ipack/devices/ipoctal.c | 13 +--
 drivers/irqchip/irq-renesas-intc-irqpin.c   |  4 ++--
 drivers/media/platform/tegra-cec/tegra_cec.c|  4 ++--
 drivers/mmc/host/sdhci-acpi.c   |  3 +--
 drivers/mtd/nand/fsl_upm.c  |  4 ++--
 drivers/net/can/sja1000/sja1000_platform.c  |  4 ++--
 drivers/net/ethernet/altera/altera_tse_main.c   |  3 +--
 drivers/net/ethernet/ethoc.c|  8 +++
 drivers/net/ethernet/lantiq_etop.c  |  4 ++--
 drivers/net/ethernet/ti/netcp_core.c|  2 +-
 drivers/net/wireless/ath/ath9k/ahb.c|  2 +-
 drivers/pci/dwc/pci-dra7xx.c|  2 +-
 drivers/pinctrl/bcm/pinctrl-ns2-mux.c   |  2 +-
 drivers/pinctrl/bcm/pinctrl-nsp-mux.c   |  4 ++--
 drivers/pinctrl/freescale/pinctrl-imx1-core.c   |  2 +-
 drivers/pinctrl/pinctrl-amd.c   |  4 ++--
 drivers/platform/x86/intel_pmc_core.c   |  5 ++---
 drivers/regulator/ti-abb-regulator.c|  6 ++---
 drivers/rtc/rtc-sh.c|  4 ++--
 drivers/spi/spi-jcore.c |  3 +--
 drivers/staging/fsl-mc/bus/mc-io.c  |  8 +++
 drivers/tty/mips_ejtag_fdc.c|  4 ++--
 drivers/tty/serial/8250/8250_omap.c |  3 +--
 drivers/tty/serial/lantiq.c |  3 +--
 drivers/tty/serial/meson_uart.c  

Re: MT7630 support

2017-12-23 Thread Enrico Mioso

Hello!
Oh - this is great!
thank you very very much! Grabbing the repository right now.
I am really thankful. Thanks for your work, also.

Enrico


On Sat, 23 Dec 2017, Hans Ulli Kroll wrote:


Date: Sat, 23 Dec 2017 10:47:38
From: Hans Ulli Kroll 
To: Enrico Mioso 
Cc: Hans Ulli Kroll ,
Stanislaw Gruszka , linux-wireless@vger.kernel.org,
Johannes Berg ,
Daniel Golle , Arnd Bergmann ,
John Crispin , n...@nbd.name
Subject: Re: MT7630 support

Hi Enrico

On Sat, 23 Dec 2017, Enrico Mioso wrote:


Hello Ulli!

First of all - thank you for the help and the precious info / link.
I'll look at it now.
Thank you very very much.

Enrico



On
https://github.com/ulli-kroll/mt7610u
I have a reworked mt7610u driver, of course PCIe code is missing here.

Ulli





Re: MT7630 support

2017-12-23 Thread Hans Ulli Kroll
Hi Enrico

On Sat, 23 Dec 2017, Enrico Mioso wrote:

> Hello Ulli!
> 
> First of all - thank you for the help and the precious info / link.
> I'll look at it now.
> Thank you very very much.
> 
> Enrico
> 

On
https://github.com/ulli-kroll/mt7610u
I have a reworked mt7610u driver, of course PCIe code is missing here.

Ulli




[PATCH 3/5] iwlwifi: mvm: move TSO segment to a separate function

2017-12-23 Thread Luca Coelho
From: Sara Sharon 

This makes future bail-outs from transmitting an AMSDU more
readable.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 158 +++-
 1 file changed, 83 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index dda77b327c98..641f42cabfff 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -680,6 +680,74 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct 
sk_buff *skb)
 }
 
 #ifdef CONFIG_INET
+
+static int
+iwl_mvm_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
+  netdev_features_t netdev_flags,
+  struct sk_buff_head *mpdus_skb)
+{
+   struct sk_buff *tmp, *next;
+   struct ieee80211_hdr *hdr = (void *)skb->data;
+   char cb[sizeof(skb->cb)];
+   u16 i = 0;
+   unsigned int tcp_payload_len;
+   unsigned int mss = skb_shinfo(skb)->gso_size;
+   bool ipv4 = (skb->protocol == htons(ETH_P_IP));
+   u16 ip_base_id = ipv4 ? ntohs(ip_hdr(skb)->id) : 0;
+
+   skb_shinfo(skb)->gso_size = num_subframes * mss;
+   memcpy(cb, skb->cb, sizeof(cb));
+
+   next = skb_gso_segment(skb, netdev_flags);
+   skb_shinfo(skb)->gso_size = mss;
+   if (WARN_ON_ONCE(IS_ERR(next)))
+   return -EINVAL;
+   else if (next)
+   consume_skb(skb);
+
+   while (next) {
+   tmp = next;
+   next = tmp->next;
+
+   memcpy(tmp->cb, cb, sizeof(tmp->cb));
+   /*
+* Compute the length of all the data added for the A-MSDU.
+* This will be used to compute the length to write in the TX
+* command. We have: SNAP + IP + TCP for n -1 subframes and
+* ETH header for n subframes.
+*/
+   tcp_payload_len = skb_tail_pointer(tmp) -
+   skb_transport_header(tmp) -
+   tcp_hdrlen(tmp) + tmp->data_len;
+
+   if (ipv4)
+   ip_hdr(tmp)->id = htons(ip_base_id + i * num_subframes);
+
+   if (tcp_payload_len > mss) {
+   skb_shinfo(tmp)->gso_size = mss;
+   } else {
+   if (ieee80211_is_data_qos(hdr->frame_control)) {
+   u8 *qc;
+
+   if (ipv4)
+   ip_send_check(ip_hdr(tmp));
+
+   qc = ieee80211_get_qos_ctl((void *)tmp->data);
+   *qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
+   }
+   skb_shinfo(tmp)->gso_size = 0;
+   }
+
+   tmp->prev = NULL;
+   tmp->next = NULL;
+
+   __skb_queue_tail(mpdus_skb, tmp);
+   i++;
+   }
+
+   return 0;
+}
+
 static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct sk_buff *skb,
  struct ieee80211_tx_info *info,
  struct ieee80211_sta *sta,
@@ -688,14 +756,10 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct 
sk_buff *skb,
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
struct ieee80211_hdr *hdr = (void *)skb->data;
unsigned int mss = skb_shinfo(skb)->gso_size;
-   struct sk_buff *tmp, *next;
-   char cb[sizeof(skb->cb)];
unsigned int num_subframes, tcp_payload_len, subf_len, max_amsdu_len;
-   bool ipv4 = (skb->protocol == htons(ETH_P_IP));
-   u16 ip_base_id = ipv4 ? ntohs(ip_hdr(skb)->id) : 0;
-   u16 snap_ip_tcp, pad, i = 0;
+   u16 snap_ip_tcp, pad;
unsigned int dbg_max_amsdu_len;
-   netdev_features_t netdev_features = NETIF_F_CSUM_MASK | NETIF_F_SG;
+   netdev_features_t netdev_flags = NETIF_F_CSUM_MASK | NETIF_F_SG;
u8 *qc, tid, txf;
 
snap_ip_tcp = 8 + skb_transport_header(skb) - skb_network_header(skb) +
@@ -705,16 +769,8 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct 
sk_buff *skb,
 
if (!sta->max_amsdu_len ||
!ieee80211_is_data_qos(hdr->frame_control) ||
-   (!mvmsta->tlc_amsdu && !dbg_max_amsdu_len)) {
-   num_subframes = 1;
-   pad = 0;
-   goto segment;
-   }
-
-   qc = ieee80211_get_qos_ctl(hdr);
-   tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
-   if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT))
-   return -EINVAL;
+   (!mvmsta->tlc_amsdu && !dbg_max_amsdu_len))
+   return iwl_mvm_tx_tso_segment(skb, 1, netdev_flags, mpdus_skb);
 
/*
 * Do not build AMSDU for IPv6 with extension headers.
@@ -723,22 +779,22 @@ static int iwl_mvm_tx_tso(struct iwl_mvm *mvm, struct 

[PATCH 5/5] iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq

2017-12-23 Thread Luca Coelho
From: Luca Coelho 

Sometimes iwl_mvm_disable_txq() may be called with mac80211_queue ==
IEEE80211_INVAL_HW_QUEUE, and this would cause us to use BIT(0xFF)
which is way too large for the u16 we used to store it in
hw_queue_to_mac820211.  If this happens the following UBSAN warning
will be generated:

[  167.185167] UBSAN: Undefined behaviour in 
drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5
[  167.185171] shift exponent 255 is too large for 64-bit type 'long unsigned 
int'

Fix that by checking that it is not IEEE80211_INVAL_HW_QUEUE and,
while at it, add a warning if the queue number is larger than
IEEE80211_MAX_QUEUES.

Fixes: 34e10860ae8d ("iwlwifi: mvm: remove references to queue_info in new TX 
path")
Reported-by: Paul Menzel 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index d65e1db7c097..70f8b8eb6117 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -800,12 +800,19 @@ int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue, 
int mac80211_queue,
.scd_queue = queue,
.action = SCD_CFG_DISABLE_QUEUE,
};
-   bool remove_mac_queue = true;
+   bool remove_mac_queue = mac80211_queue != IEEE80211_INVAL_HW_QUEUE;
int ret;
 
+   if (WARN_ON(remove_mac_queue && mac80211_queue >= IEEE80211_MAX_QUEUES))
+   return -EINVAL;
+
if (iwl_mvm_has_new_tx_api(mvm)) {
spin_lock_bh(>queue_info_lock);
-   mvm->hw_queue_to_mac80211[queue] &= ~BIT(mac80211_queue);
+
+   if (remove_mac_queue)
+   mvm->hw_queue_to_mac80211[queue] &=
+   ~BIT(mac80211_queue);
+
spin_unlock_bh(>queue_info_lock);
 
iwl_trans_txq_free(mvm->trans, queue);
-- 
2.15.1



[PATCH 4/5] iwlwifi: set default timstamp marker cmd

2017-12-23 Thread Luca Coelho
From: Mordechay Goodstein 

In case debug configuration is started with LDBG cmd also start timestamp
marker for syncing logs witn the FW.

Signed-off-by: Mordechay Goodstein 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c |  4 
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c | 24 +++-
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.h |  5 +
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 67aefc8fc9ac..bb286f59a6fd 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -66,6 +66,7 @@
 #include "iwl-drv.h"
 #include "runtime.h"
 #include "dbg.h"
+#include "debugfs.h"
 #include "iwl-io.h"
 #include "iwl-prph.h"
 #include "iwl-csr.h"
@@ -1079,6 +1080,9 @@ int iwl_fw_start_dbg_conf(struct iwl_fw_runtime *fwrt, u8 
conf_id)
IWL_WARN(fwrt, "FW already configured (%d) - re-configuring\n",
 fwrt->dump.conf);
 
+   /* start default config marker cmd for syncing logs */
+   iwl_fw_trigger_timestamp(fwrt, 1);
+
/* Send all HCMDs for configuring the FW debug */
ptr = (void *)>fw->dbg_conf_tlv[conf_id]->hcmd;
for (i = 0; i < fwrt->fw->dbg_conf_tlv[conf_id]->num_of_hcmds; i++) {
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c 
b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
index e2ded29a145d..98a76bf6e71f 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
@@ -157,6 +157,20 @@ static void iwl_fw_timestamp_marker_wk(struct work_struct 
*work)
 ret, jiffies_to_msecs(delay) / 1000);
 }
 
+void iwl_fw_trigger_timestamp(struct iwl_fw_runtime *fwrt, u32 delay)
+{
+   IWL_INFO(fwrt,
+"starting timestamp_marker trigger with delay: %us\n",
+delay);
+
+   iwl_fw_cancel_timestamp(fwrt);
+
+   fwrt->timestamp.delay = msecs_to_jiffies(delay * 1000);
+
+   schedule_delayed_work(>timestamp.wk,
+ round_jiffies_relative(fwrt->timestamp.delay));
+}
+
 static ssize_t iwl_dbgfs_timestamp_marker_write(struct iwl_fw_runtime *fwrt,
char *buf, size_t count,
loff_t *ppos)
@@ -168,16 +182,8 @@ static ssize_t iwl_dbgfs_timestamp_marker_write(struct 
iwl_fw_runtime *fwrt,
if (ret < 0)
return ret;
 
-   IWL_INFO(fwrt,
-"starting timestamp_marker trigger with delay: %us\n",
-delay);
+   iwl_fw_trigger_timestamp(fwrt, delay);
 
-   iwl_fw_cancel_timestamp(fwrt);
-
-   fwrt->timestamp.delay = msecs_to_jiffies(delay * 1000);
-
-   schedule_delayed_work(>timestamp.wk,
- round_jiffies_relative(fwrt->timestamp.delay));
return count;
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h 
b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h
index e57ff92a68ae..9fcb2b3a7d67 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h
@@ -75,6 +75,8 @@ static inline void iwl_fw_cancel_timestamp(struct 
iwl_fw_runtime *fwrt)
cancel_delayed_work_sync(>timestamp.wk);
 }
 
+void iwl_fw_trigger_timestamp(struct iwl_fw_runtime *fwrt, u32 delay);
+
 #else
 static inline int iwl_fwrt_dbgfs_register(struct iwl_fw_runtime *fwrt,
  struct dentry *dbgfs_dir)
@@ -84,4 +86,7 @@ static inline int iwl_fwrt_dbgfs_register(struct 
iwl_fw_runtime *fwrt,
 
 static inline void iwl_fw_cancel_timestamp(struct iwl_fw_runtime *fwrt) {}
 
+static inline void iwl_fw_trigger_timestamp(struct iwl_fw_runtime *fwrt,
+   u32 delay) {}
+
 #endif /* CONFIG_IWLWIFI_DEBUGFS */
-- 
2.15.1



[PATCH 2/5] iwlwifi: mvm: take RCU lock before dereferencing

2017-12-23 Thread Luca Coelho
From: Sara Sharon 

RCU isn't properly locked.

Fixes: 46d372af9935 ("iwlwifi: mvm: rs: new rate scale API - add FW 
notifications")
Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
index 55d1274c6092..fb5745660509 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c
@@ -234,13 +234,15 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm, struct 
iwl_rx_packet *pkt)
struct iwl_mvm_sta *mvmsta;
struct iwl_lq_sta_rs_fw *lq_sta;
 
+   rcu_read_lock();
+
notif = (void *)pkt->data;
mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, notif->sta_id);
 
if (!mvmsta) {
IWL_ERR(mvm, "Invalid sta id (%d) in FW TLC notification\n",
notif->sta_id);
-   return;
+   goto out;
}
 
lq_sta = >lq_sta.rs_fw;
@@ -251,6 +253,8 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm, struct 
iwl_rx_packet *pkt)
IWL_DEBUG_RATE(mvm, "new rate_n_flags: 0x%X\n",
   lq_sta->last_rate_n_flags);
}
+out:
+   rcu_read_unlock();
 }
 
 void rs_fw_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
-- 
2.15.1



[PATCH 1/5] iwlwifi: mvm: flip AMSDU addresses only for 9000 family

2017-12-23 Thread Luca Coelho
From: Sara Sharon 

Hardware bug was fixed in later generation.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index a3f7c1bf3cc8..71d6660c48e1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -830,6 +830,16 @@ static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm,
rcu_read_unlock();
 }
 
+static void iwl_mvm_flip_address(u8 *addr)
+{
+   int i;
+   u8 mac_addr[ETH_ALEN];
+
+   for (i = 0; i < ETH_ALEN; i++)
+   mac_addr[i] = addr[ETH_ALEN - i - 1];
+   ether_addr_copy(addr, mac_addr);
+}
+
 void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
struct iwl_rx_cmd_buffer *rxb, int queue)
 {
@@ -984,21 +994,16 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct 
napi_struct *napi,
 */
if ((desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) &&
!WARN_ON(!ieee80211_is_data_qos(hdr->frame_control))) {
-   int i;
u8 *qc = ieee80211_get_qos_ctl(hdr);
-   u8 mac_addr[ETH_ALEN];
 
*qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
 
-   for (i = 0; i < ETH_ALEN; i++)
-   mac_addr[i] = hdr->addr3[ETH_ALEN - i - 1];
-   ether_addr_copy(hdr->addr3, mac_addr);
+   if (mvm->trans->cfg->device_family ==
+   IWL_DEVICE_FAMILY_9000) {
+   iwl_mvm_flip_address(hdr->addr3);
 
-   if (ieee80211_has_a4(hdr->frame_control)) {
-   for (i = 0; i < ETH_ALEN; i++)
-   mac_addr[i] =
-   hdr->addr4[ETH_ALEN - i - 1];
-   ether_addr_copy(hdr->addr4, mac_addr);
+   if (ieee80211_has_a4(hdr->frame_control))
+   iwl_mvm_flip_address(hdr->addr4);
}
}
if (baid != IWL_RX_REORDER_DATA_INVALID_BAID) {
-- 
2.15.1



[PATCH 0/5] iwlwifi: updates intended for v4.16 2017-12-23

2017-12-23 Thread Luca Coelho
From: Luca Coelho 

Hi,

Here's the fourth and probably last batch of patches intended for
4.16.  Nothing major, just continued development, some cleanups and
small fixes here and there.

* Fix a UBSAN warning;
* Improvement in the net-stack/driver log syncing
* An RCU lock fix in the new rate-scaling code;
* Small cleanups;

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

FYI, I'll be on holidays/vacations for the next few weeks, so there
will probably not be much activity in the iwlwifi driver code.

Please review.

Cheers,
Luca.


Luca Coelho (1):
  iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq

Mordechay Goodstein (1):
  iwlwifi: set default timstamp marker cmd

Sara Sharon (3):
  iwlwifi: mvm: flip AMSDU addresses only for 9000 family
  iwlwifi: mvm: take RCU lock before dereferencing
  iwlwifi: mvm: move TSO segment to a separate function

 drivers/net/wireless/intel/iwlwifi/fw/dbg.c |   4 +
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c |  24 ++--
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.h |   5 +
 drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c  |   6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c   |  25 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 158 +---
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c  |  11 +-
 7 files changed, 136 insertions(+), 97 deletions(-)

-- 
2.15.1