diff mbox series

[OpenWrt-Devel,v3] kernel: ath10k-ct: provide a build variant for small RAM devices

Message ID 20191222182057.9805-1-fercerpav@gmail.com
State Accepted
Delegated to: Hauke Mehrtens
Headers show
Series [OpenWrt-Devel,v3] kernel: ath10k-ct: provide a build variant for small RAM devices | expand

Commit Message

Paul Fertser Dec. 22, 2019, 6:20 p.m. UTC
According to many bugreports [0][1][2] the default ath10k-ct kernel
module is unusable on devices with just 64 MiB RAM or with 128 MiB and
dual ath10k cards. The target boards boot but eventually oom-killer
starts to interfere with normal operation, so the current state is
effectively broken.

Since the two patches in question have a performance impact (and
possibly some other unexpected side-effects) a dedicated build variant
is added so that users of the low RAM devices can still benefit from all
the ath10k-ct advantages.

According to testing [3] results, the issue can be experienced even with
"a 256MB device with three radios". Measured performance impact of
implementing small buffers was lowering "the maximum 5 GHz throughput on
an IPQ40xx device without RPS/XPS optimizations from 494/432 Mbit/s for
TCP transfers (download/upload) to 438/343 Mbit/s"

The patches were apparently inspired by QSDK tweaks used by ODMs for the
affected devices.

[0] http://lists.infradead.org/pipermail/openwrt-devel/2019-December/020573.html
[1] https://github.com/openwrt/openwrt/pull/1077
[2] https://bugs.openwrt.org/index.php?do=details&task_id=2664
[3] https://github.com/freifunk-gluon/gluon/pull/1440#issue-195607701

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
---
This is compile-tested only!

Changes for v3:

    - Apply all patches to both build variants, select by a preprocessor
      symbol

Changes for v2:

    - Added performance impact details to the commit message
    - Fixed QUILT=1 operation
    - Refreshed the new patches

 package/kernel/ath10k-ct/Makefile             |  18 +++-
 ...0-0010-ath10k-limit-htt-rx-ring-size.patch |  28 +++++
 ...60-0011-ath10k-limit-pci-buffer-size.patch | 100 ++++++++++++++++++
 3 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch
 create mode 100644 package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch

Comments

Bjørn Mork Dec. 23, 2019, 9:17 a.m. UTC | #1
Paul Fertser <fercerpav@gmail.com> writes:

> --- /dev/null
> +++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
> @@ -0,0 +1,100 @@
> +--- a/ath10k-4.19/pci.c
> ++++ b/ath10k-4.19/pci.c
> +@@ -142,7 +142,11 @@ static struct ce_attr host_ce_config_wla
> + 		.flags = CE_ATTR_FLAGS,
> + 		.src_nentries = 0,
> + 		.src_sz_max = 2048,
> ++#ifndef CONFIG_ATH10K_SMALLBUFFERS
> + 		.dest_nentries = 512,
> ++#else
> ++		.dest_nentries = 128,
> ++#endif
> + 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
> + 	},
> + 

Why not replace the magic numbers with a macro?  Then you could get away
with *one* "if configx then this else that"?  And preferably put it in a
header file.

Or maybe these things even could be made runtime configurable?  Buffers
of this size really should be IMHO, as there is no way to make one size
fit all.  As demonstrated...


Bjørn
Hauke Mehrtens Dec. 23, 2019, 7:45 p.m. UTC | #2
On 12/23/19 10:17 AM, Bjørn Mork wrote:
> Paul Fertser <fercerpav@gmail.com> writes:
> 
>> --- /dev/null
>> +++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
>> @@ -0,0 +1,100 @@
>> +--- a/ath10k-4.19/pci.c
>> ++++ b/ath10k-4.19/pci.c
>> +@@ -142,7 +142,11 @@ static struct ce_attr host_ce_config_wla
>> + 		.flags = CE_ATTR_FLAGS,
>> + 		.src_nentries = 0,
>> + 		.src_sz_max = 2048,
>> ++#ifndef CONFIG_ATH10K_SMALLBUFFERS
>> + 		.dest_nentries = 512,
>> ++#else
>> ++		.dest_nentries = 128,
>> ++#endif
>> + 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
>> + 	},
>> + 
> 
> Why not replace the magic numbers with a macro?  Then you could get away
> with *one* "if configx then this else that"?  And preferably put it in a
> header file.
> 
> Or maybe these things even could be made runtime configurable?  Buffers
> of this size really should be IMHO, as there is no way to make one size
> fit all.  As demonstrated...

Hi,

Runtime configuration would be nice, but as far as I know there is no
standard interface available.

Huake
Paul Fertser Dec. 23, 2019, 7:57 p.m. UTC | #3
Hi Bjørn,

On Mon, Dec 23, 2019 at 10:17:11AM +0100, Bjørn Mork wrote:
> Paul Fertser <fercerpav@gmail.com> writes:
> > --- /dev/null
> > +++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
> > @@ -0,0 +1,100 @@
> > +--- a/ath10k-4.19/pci.c
> > ++++ b/ath10k-4.19/pci.c
> > +@@ -142,7 +142,11 @@ static struct ce_attr host_ce_config_wla
> > + 		.flags = CE_ATTR_FLAGS,
> > + 		.src_nentries = 0,
> > + 		.src_sz_max = 2048,
> > ++#ifndef CONFIG_ATH10K_SMALLBUFFERS
> > + 		.dest_nentries = 512,
> > ++#else
> > ++		.dest_nentries = 128,
> > ++#endif
> > + 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
> > + 	},
> > + 
> 
> Why not replace the magic numbers with a macro?  Then you could get away
> with *one* "if configx then this else that"?  And preferably put it in a
> header file.

There're different values for different buffers so there can't be a
single number to fit them all. And I do not see how adding 4 different
defines just for the sake of it would make sense there.

> Or maybe these things even could be made runtime configurable?  Buffers
> of this size really should be IMHO, as there is no way to make one size
> fit all.  As demonstrated...

This was already discussed, please see [0]. I think adding a kernel
module parameter would make sense for this but it's also much more
complicated than just adding two patches that were already used in
OpenWrt for many years. So far nobody volunteered to do that, and I
wanted to provide at least some semi-sane solution for the upcoming
release.

[0] https://patchwork.ozlabs.org/comment/2322701/
Hauke Mehrtens Dec. 24, 2019, 12:16 a.m. UTC | #4
On 12/23/19 8:57 PM, Paul Fertser wrote:
> Hi Bjørn,
> 
> On Mon, Dec 23, 2019 at 10:17:11AM +0100, Bjørn Mork wrote:
>> Paul Fertser <fercerpav@gmail.com> writes:
>>> --- /dev/null
>>> +++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
>>> @@ -0,0 +1,100 @@
>>> +--- a/ath10k-4.19/pci.c
>>> ++++ b/ath10k-4.19/pci.c
>>> +@@ -142,7 +142,11 @@ static struct ce_attr host_ce_config_wla
>>> + 		.flags = CE_ATTR_FLAGS,
>>> + 		.src_nentries = 0,
>>> + 		.src_sz_max = 2048,
>>> ++#ifndef CONFIG_ATH10K_SMALLBUFFERS
>>> + 		.dest_nentries = 512,
>>> ++#else
>>> ++		.dest_nentries = 128,
>>> ++#endif
>>> + 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
>>> + 	},
>>> + 
>>
>> Why not replace the magic numbers with a macro?  Then you could get away
>> with *one* "if configx then this else that"?  And preferably put it in a
>> header file.
> 
> There're different values for different buffers so there can't be a
> single number to fit them all. And I do not see how adding 4 different
> defines just for the sake of it would make sense there.
> 
>> Or maybe these things even could be made runtime configurable?  Buffers
>> of this size really should be IMHO, as there is no way to make one size
>> fit all.  As demonstrated...
> 
> This was already discussed, please see [0]. I think adding a kernel
> module parameter would make sense for this but it's also much more
> complicated than just adding two patches that were already used in
> OpenWrt for many years. So far nobody volunteered to do that, and I
> wanted to provide at least some semi-sane solution for the upcoming
> release.
> 
> [0] https://patchwork.ozlabs.org/comment/2322701/
> 
Hi Paul,

Thank you for your patches, I applied both patches to master with some
small fixes and backported the first patch for 19.07 branch. The patch
adding the dependencies to the ath79 target is not applying on 19.07, it
would be nice if you could provide a version on top of 19.07 too.

Hauke
diff mbox series

Patch

diff --git a/package/kernel/ath10k-ct/Makefile b/package/kernel/ath10k-ct/Makefile
index dbf75fe174..e38380547a 100644
--- a/package/kernel/ath10k-ct/Makefile
+++ b/package/kernel/ath10k-ct/Makefile
@@ -35,6 +35,7 @@  define KernelPackage/ath10k-ct
 	$(PKG_BUILD_DIR)/ath10k$(CT_KVER)/ath10k_core.ko
   AUTOLOAD:=$(call AutoProbe,ath10k_pci)
   PROVIDES:=kmod-ath10k
+  VARIANT:=regular
 endef
 
 define KernelPackage/ath10k-ct/config
@@ -42,7 +43,17 @@  define KernelPackage/ath10k-ct/config
        config ATH10K-CT_LEDS
                bool "Enable LED support"
                default y
-               depends on PACKAGE_kmod-ath10k-ct
+               depends on PACKAGE_kmod-ath10k-ct || PACKAGE_kmod-ath10k-ct-smallbuffers
+endef
+
+define KernelPackage/ath10k-ct-smallbuffers
+$(call KernelPackage/ath10k-ct)
+  TITLE+= (small buffers for low-RAM devices)
+  VARIANT:=smallbuffers
+endef
+
+define KernelPackage/ath10k-ct-smallbuffers/config
+$(call KernelPackage/ath10k-ct/config)
 endef
 
 NOSTDINC_FLAGS = \
@@ -90,6 +101,10 @@  ifeq ($(CONFIG_ATH10K-CT_LEDS),y)
   NOSTDINC_FLAGS += -DCONFIG_ATH10K_LEDS
 endif
 
+ifeq ($(BUILD_VARIANT),smallbuffers)
+  NOSTDINC_FLAGS += -DCONFIG_ATH10K_SMALLBUFFERS
+endif
+
 define Build/Configure
 	cp $(STAGING_DIR)/usr/include/mac80211/ath/*.h $(PKG_BUILD_DIR)
 endef
@@ -107,3 +122,4 @@  define Build/Compile
 endef
 
 $(eval $(call KernelPackage,ath10k-ct))
+$(eval $(call KernelPackage,ath10k-ct-smallbuffers))
diff --git a/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch b/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch
new file mode 100644
index 0000000000..a3a939440a
--- /dev/null
+++ b/package/kernel/ath10k-ct/patches/960-0010-ath10k-limit-htt-rx-ring-size.patch
@@ -0,0 +1,28 @@ 
+--- a/ath10k-4.19/htt.h
++++ b/ath10k-4.19/htt.h
+@@ -237,7 +237,11 @@ enum htt_rx_ring_flags {
+ };
+ 
+ #define HTT_RX_RING_SIZE_MIN 128
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ #define HTT_RX_RING_SIZE_MAX 2048
++#else
++#define HTT_RX_RING_SIZE_MAX 512
++#endif
+ #define HTT_RX_RING_SIZE HTT_RX_RING_SIZE_MAX
+ #define HTT_RX_RING_FILL_LEVEL (((HTT_RX_RING_SIZE) / 2) - 1)
+ #define HTT_RX_RING_FILL_LEVEL_DUAL_MAC (HTT_RX_RING_SIZE - 1)
+--- a/ath10k-5.2/htt.h
++++ b/ath10k-5.2/htt.h
+@@ -225,7 +225,11 @@ enum htt_rx_ring_flags {
+ };
+ 
+ #define HTT_RX_RING_SIZE_MIN 128
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ #define HTT_RX_RING_SIZE_MAX 2048
++#else
++#define HTT_RX_RING_SIZE_MAX 512
++#endif
+ #define HTT_RX_RING_SIZE HTT_RX_RING_SIZE_MAX
+ #define HTT_RX_RING_FILL_LEVEL (((HTT_RX_RING_SIZE) / 2) - 1)
+ #define HTT_RX_RING_FILL_LEVEL_DUAL_MAC (HTT_RX_RING_SIZE - 1)
diff --git a/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
new file mode 100644
index 0000000000..517be89dab
--- /dev/null
+++ b/package/kernel/ath10k-ct/patches/960-0011-ath10k-limit-pci-buffer-size.patch
@@ -0,0 +1,100 @@ 
+--- a/ath10k-4.19/pci.c
++++ b/ath10k-4.19/pci.c
+@@ -142,7 +142,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 512,
++#else
++		.dest_nentries = 128,
++#endif
+ 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
+ 	},
+ 
+@@ -151,7 +155,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 128,
++#else
++		.dest_nentries = 64,
++#endif
+ 		.recv_cb = ath10k_pci_htc_rx_cb,
+ 	},
+ 
+@@ -178,7 +186,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 512,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 512,
++#else
++		.dest_nentries = 128,
++#endif
+ 		.recv_cb = ath10k_pci_htt_rx_cb,
+ 	},
+ 
+@@ -203,7 +215,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 128,
++#else
++		.dest_nentries = 96,
++#endif
+ 		.recv_cb = ath10k_pci_pktlog_rx_cb,
+ 	},
+ 
+--- a/ath10k-5.2/pci.c
++++ b/ath10k-5.2/pci.c
+@@ -131,7 +131,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 512,
++#else
++		.dest_nentries = 128,
++#endif
+ 		.recv_cb = ath10k_pci_htt_htc_rx_cb,
+ 	},
+ 
+@@ -140,7 +144,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 128,
++#else
++		.dest_nentries = 64,
++#endif
+ 		.recv_cb = ath10k_pci_htc_rx_cb,
+ 	},
+ 
+@@ -167,7 +175,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 512,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 512,
++#else
++		.dest_nentries = 128,
++#endif
+ 		.recv_cb = ath10k_pci_htt_rx_cb,
+ 	},
+ 
+@@ -192,7 +204,11 @@ static struct ce_attr host_ce_config_wla
+ 		.flags = CE_ATTR_FLAGS,
+ 		.src_nentries = 0,
+ 		.src_sz_max = 2048,
++#ifndef CONFIG_ATH10K_SMALLBUFFERS
+ 		.dest_nentries = 128,
++#else
++		.dest_nentries = 96,
++#endif
+ 		.recv_cb = ath10k_pci_pktlog_rx_cb,
+ 	},
+