wifi: nl80211: disallow setting special AP channel widths
Subsystems (9)
Sasha Levin
maintainerPATCH 1/11 wifi: nl80211: disallow setting special AP channel widths
From: Johannes Berg <[email protected]>
[ Upstream commit 23daf1b4c91db9b26f8425cc7039cf96d22ccbfe ]
Setting the AP channel width is meant for use with the normal 20/40/... MHz channel width progression, and switching around in S1G or narrow channels isn't supported. Disallow that.
--- net/wireless/nl80211.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/wireless/nl80211.c +27 -0
@@ -3346,6 +3346,33 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,if (chandef.chan != cur_chan)return -EBUSY ; +/* only allow this for regular channel widths */ +switch (wdev->links[link_id].ap.chandef.width) { +case NL80211_CHAN_WIDTH_20_NOHT : +case NL80211_CHAN_WIDTH_20 : +case NL80211_CHAN_WIDTH_40 : +case NL80211_CHAN_WIDTH_80 : +case NL80211_CHAN_WIDTH_80P80 : +case NL80211_CHAN_WIDTH_160 : +case NL80211_CHAN_WIDTH_320 : +break ; +default : +return -EINVAL ; + } + +switch (chandef.width) { +case NL80211_CHAN_WIDTH_20_NOHT : +case NL80211_CHAN_WIDTH_20 : +case NL80211_CHAN_WIDTH_40 : +case NL80211_CHAN_WIDTH_80 : +case NL80211_CHAN_WIDTH_80P80 : +case NL80211_CHAN_WIDTH_160 : +case NL80211_CHAN_WIDTH_320 : +break ; +default : +return -EINVAL ; + } + result =rdev_set_ap_chanwidth (rdev, dev, link_id, &chandef);if (result)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/11 r8169: remove detection of chip version 11 (early RTL8168b)
From: Heiner Kallweit <[email protected]>
[ Upstream commit 982300c115d229565d7af8e8b38aa1ee7bb1f5bd ]
This early RTL8168b version was the first PCIe chip version, and it's quite quirky. Last sign of life is from more than 15 yrs ago. Let's remove detection of this chip version, we'll see whether anybody complains. If not, support for this chip version can be removed a few kernel versions later.
--- drivers/net/ethernet/realtek/r8169_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +3 -1
@@ -2119,7 +2119,9 @@ static enum mac_version rtl8169_get_mac_version(u16 xid, bool gmii)/* 8168B family. */ { 0x7c8, 0x380, RTL_GIGA_MAC_VER_17 }, - { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11 }, +/* This one is very old and rare, let's see if anybody complains. +* { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11 }, +*/ /* 8101 family. */ { 0x7c8, 0x448, RTL_GIGA_MAC_VER_39 },
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/11 net/mlx5e: SHAMPO, Fix invalid WQ linked list unlink
In reply to Sasha LevinFrom: Dragos Tatulea <[email protected]>
[ Upstream commit fba8334721e266f92079632598e46e5f89082f30 ]
When all the strides in a WQE have been consumed, the WQE is unlinked from the WQ linked list (mlx5_wq_ll_pop()). For SHAMPO, it is possible to receive CQEs with 0 consumed strides for the same WQE even after the WQE is fully consumed and unlinked. This triggers an additional unlink for the same wqe which corrupts the linked list.
Fix this scenario by accepting 0 sized consumed strides without unlinking the WQE again.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +3 -0
@@ -2146,6 +2146,9 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqif (likely (wi->consumed_strides < rq->mpwqe.num_strides))return ; +if (unlikely (!cstrides)) +return ; + wq = &rq->mpwqe.wq; wqe =mlx5_wq_ll_get_wqe (wq, wqe_id);mlx5e_free_rx_mpwqe (rq, wi, true);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/11 selftests/bpf: Fix send_signal test with nested CONFIG_PARAVIRT
In reply to Sasha LevinFrom: Yonghong Song <[email protected]>
[ Upstream commit 7015843afcaf68c132784c89528dfddc0005e483 ]
Alexei reported that send_signal test may fail with nested CONFIG_PARAVIRT configs. In this particular case, the base VM is AMD with 166 cpus, and I run selftests with regular qemu on top of that and indeed send_signal test failed. I also tried with an Intel box with 80 cpus and there is no issue.
The main qemu command line includes:
-enable-kvm -smp 16 -cpu host
The failure log looks like:
$ ./test_progs -t send_signal [ 48.501588] watchdog: BUG: soft lockup - CPU#9 stuck for 26s! [test_progs:2225] [ 48.503622] Modules linked in: bpf_testmod(O) [ 48.503622] CPU: 9 PID: 2225 Comm: test_progs Tainted: G O 6.9.0-08561-g2c1713a8f1c9-dirty #69 [ 48.507629] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 [ 48.511635] RIP: 0010:handle_softirqs+0x71/0x290 [ 48.511635] Code: [...] 10 0a 00 00 00 31 c0 65 66 89 05 d5 f4 fa 7e fb bb ff ff ff ff <49> c7 c2 cb [ 48.518527] RSP: 0018:ffffc90000310fa0 EFLAGS: 00000246 [ 48.519579] RAX: 0000000000000000 RBX: 00000000ffffffff RCX: 00000000000006e0 [ 48.522526] RDX: 0000000000000006 RSI: ffff88810791ae80 RDI: 0000000000000000 [ 48.523587] RBP: ffffc90000fabc88 R08: 00000005a0af4f7f R09: 0000000000000000 [ 48.525525] R10: 0000000561d2f29c R11: 0000000000006534 R12: 0000000000000280 [ 48.528525] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 48.528525] FS: 00007f2f2885cd00(0000) GS:ffff888237c40000(0000) knlGS:0000000000000000 [ 48.531600] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 48.535520] CR2: 00007f2f287059f0 CR3: 0000000106a28002 CR4: 00000000003706f0 [ 48.537538] Call Trace: [ 48.537538] <IRQ> [ 48.537538] ? watchdog_timer_fn+0x1cd/0x250 [ 48.539590] ? lockup_detector_update_enable+0x50/0x50 [ 48.539590] ? __hrtimer_run_queues+0xff/0x280 [ 48.542520] ? hrtimer_interrupt+0x103/0x230 [ 48.544524] ? __sysvec_apic_timer_interrupt+0x4f/0x140 [ 48.545522] ? sysvec_apic_timer_interrupt+0x3a/0x90 [ 48.547612] ? asm_sysvec_apic_timer_interrupt+0x1a/0x20 [ 48.547612] ? handle_softirqs+0x71/0x290 [ 48.547612] irq_exit_rcu+0x63/0x80 [ 48.551585] sysvec_apic_timer_interrupt+0x75/0x90 [ 48.552521] </IRQ> [ 48.553529] <TASK> [ 48.553529] asm_sysvec_apic_timer_interrupt+0x1a/0x20 [ 48.555609] RIP: 0010:finish_task_switch.isra.0+0x90/0x260 [ 48.556526] Code: [...] 9f 58 0a 00 00 48 85 db 0f 85 89 01 00 00 4c 89 ff e8 53 d9 bd 00 fb 66 90 <4d> 85 ed 74 [ 48.562524] RSP: 0018:ffffc90000fabd38 EFLAGS: 00000282 [ 48.563589] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff83385620 [ 48.563589] RDX: ffff888237c73ae4 RSI: 0000000000000000 RDI: ffff888237c6fd00 [ 48.568521] RBP: ffffc90000fabd68 R08: 0000000000000000 R09: 0000000000000000 [ 48.569528] R10: 0000000000000001 R11: 0000000000000000 R12: ffff8881009d0000 [ 48.573525] R13: ffff8881024e5400 R14: ffff88810791ae80 R15: ffff888237c6fd00 [ 48.575614] ? finish_task_switch.isra.0+0x8d/0x260 [ 48.576523] __schedule+0x364/0xac0 [ 48.577535] schedule+0x2e/0x110 [ 48.578555] pipe_read+0x301/0x400 [ 48.579589] ? destroy_sched_domains_rcu+0x30/0x30 [ 48.579589] vfs_read+0x2b3/0x2f0 [ 48.579589] ksys_read+0x8b/0xc0 [ 48.583590] do_syscall_64+0x3d/0xc0 [ 48.583590] entry_SYSCALL_64_after_hwframe+0x4b/0x53 [ 48.586525] RIP: 0033:0x7f2f28703fa1 [ 48.587592] Code: [...] 00 00 00 0f 1f 44 00 00 f3 0f 1e fa 80 3d c5 23 14 00 00 74 13 31 c0 0f 05 <48> 3d 00 f0 [ 48.593534] RSP: 002b:00007ffd90f8cf88 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 48.595589] RAX: ffffffffffffffda RBX: 00007ffd90f8d5e8 RCX: 00007f2f28703fa1 [ 48.595589] RDX: 0000000000000001 RSI: 00007ffd90f8cfb0 RDI: 0000000000000006 [ 48.599592] RBP: 00007ffd90f8d2f0 R08: 0000000000000064 R09: 0000000000000000 [ 48.602527] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 [ 48.603589] R13: 00007ffd90f8d608 R14: 00007f2f288d8000 R15: 0000000000f6bdb0 [ 48.605527] </TASK>
In the test, two processes are communicating through pipe. Further debugging with strace found that the above splat is triggered as read() syscall could not receive the data even if the corresponding write() syscall in another process successfully wrote data into the pipe.
The failed subtest is "send_signal_perf". The corresponding perf event has sample_period 1 and config PERF_COUNT_SW_CPU_CLOCK. sample_period 1 means every overflow event will trigger a call to the BPF program. So I suspect this may overwhelm the system. So I increased the sample_period to 100,000 and the test passed. The sample_period 10,000 still has the test failed.
In other parts of selftest, e.g., [1], sample_freq is used instead. So I decided to use sample_freq = 1,000 since the test can pass as well.
[1] https://lore.kernel.org/bpf/[email protected]/
--- tools/testing/selftests/bpf/prog_tests/send_signal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/send_signal.c +2 -1
@@ -152,7 +152,8 @@ static void test_send_signal_tracepoint(bool signal_thread)static void test_send_signal_perf (bool signal_thread) {struct perf_event_attr attr = { - .sample_period =1 , + .freq =1 , + .sample_freq =1000 , .type =PERF_TYPE_SOFTWARE , .config =PERF_COUNT_SW_CPU_CLOCK , };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/11 af_unix: Don't retry after unix_state_lock_nested() in unix_stream_connect().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 1ca27e0c8c13ac50a4acf9cdf77069e2d94a547d ]
When a SOCK_(STREAM|SEQPACKET) socket connect()s to another one, we need to lock the two sockets to check their states in unix_stream_connect().
We use unix_state_lock() for the server and unix_state_lock_nested() for client with tricky sk->sk_state check to avoid deadlock.
The possible deadlock scenario are the following:
1) Self connect()
2) Simultaneous connect()
The former is simple, attempt to grab the same lock, and the latter is AB-BA deadlock.
After the server's unix_state_lock(), we check the server socket's state, and if it's not TCP_LISTEN, connect() fails with -EINVAL.
Then, we avoid the former deadlock by checking the client's state before unix_state_lock_nested(). If its state is not TCP_LISTEN, we can make sure that the client and the server are not identical based on the state.
Also, the latter deadlock can be avoided in the same way. Due to the server sk->sk_state requirement, AB-BA deadlock could happen only with TCP_LISTEN sockets. So, if the client's state is TCP_LISTEN, we can give up the second lock to avoid the deadlock.
CPU 1 CPU 2 CPU 3
connect(A -> B) connect(B -> A) listen(A)
--- --- ---
unix_state_lock(B)
B->sk_state == TCP_LISTEN
READ_ONCE(A->sk_state) == TCP_CLOSE
^^^^^^^^^
ok, will lock A unix_state_lock(A)
.--------------' WRITE_ONCE(A->sk_state, TCP_LISTEN)
| unix_state_unlock(A)
|
| unix_state_lock(A)
| A->sk_sk_state == TCP_LISTEN
| READ_ONCE(B->sk_state) == TCP_LISTEN
v ^^^^^^^^^^ unix_state_lock_nested(A) Don't lock B !!
Currently, while checking the client's state, we also check if it's TCP_ESTABLISHED, but this is unlikely and can be checked after we know the state is not TCP_CLOSE.
Moreover, if it happens after the second lock, we now jump to the restart label, but it's unlikely that the server is not found during the retry, so the jump is mostly to revist the client state check.
Let's remove the retry logic and check the state against TCP_CLOSE first.
--- net/unix/af_unix.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-)
net/unix/af_unix.c +9 -25
@@ -1461,6 +1461,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,struct unix_sock *u =unix_sk (sk), *newu, *otheru;struct net *net =sock_net (sk);struct sk_buff *skb =NULL ; +unsigned char state;long timeo;int err;
@@ -1505,7 +1506,6 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, goto out; } -/* Latch state of peer */ unix_state_lock (other);/* Apparently VFS overslept socket death. Retry. */
@@ -1535,37 +1535,21 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, goto restart; } -/* Latch our state. - -It is tricky place. We need to grab our state lock and cannot -drop lock on peer. It is dangerous because deadlock is -possible. Connect to self case and simultaneous -attempt to connect are eliminated by checking socket -state. other is TCP_LISTEN, if sk is TCP_LISTEN we -check this before attempt to grab lock. - -Well, and we have to recheck the state after socket locked. +/* self connect and simultaneous connect are eliminated +* by rejecting TCP_LISTEN socket to avoid deadlock. */ -switch (READ_ONCE (sk->sk_state)) { -case TCP_CLOSE : -/* This is ok... continue with connect */ -break ; -case TCP_ESTABLISHED : -/* Socket is already connected */ - err = -EISCONN ; - goto out_unlock; -default : - err = -EINVAL ; + state =READ_ONCE (sk->sk_state); +if (unlikely (state !=TCP_CLOSE )) { + err = state ==TCP_ESTABLISHED ? -EISCONN : -EINVAL ; goto out_unlock; }unix_state_lock_nested (sk,U_LOCK_SECOND ); -if (sk->sk_state !=TCP_CLOSE ) { +if (unlikely (sk->sk_state !=TCP_CLOSE )) { + err = sk->sk_state ==TCP_ESTABLISHED ? -EISCONN : -EINVAL ;unix_state_unlock (sk); -unix_state_unlock (other); -sock_put (other); - goto restart; + goto out_unlock; } err =security_unix_stream_connect (sk, other, newsk);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/11 PCI: Add Edimax Vendor ID to pci_ids.h
In reply to Sasha LevinFrom: FUJITA Tomonori <[email protected]>
[ Upstream commit eee5528890d54b22b46f833002355a5ee94c3bb4 ]
Add the Edimax Vendor ID (0x1432) for an ethernet driver for Tehuti Networks TN40xx chips. This ID can be used for Realtek 8180 and Ralink rt28xx wireless drivers.
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -2109,6 +2109,8 @@#define PCI_VENDOR_ID_CHELSIO 0x1425 +#define PCI_VENDOR_ID_EDIMAX 0x1432 +#define PCI_VENDOR_ID_ADLINK 0x144a#define PCI_VENDOR_ID_SAMSUNG 0x144d
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/11 udf: prevent integer overflow in udf_bitmap_free_blocks()
In reply to Sasha LevinFrom: Roman Smirnov <[email protected]>
[ Upstream commit 56e69e59751d20993f243fb7dd6991c4e522424c ]
An overflow may occur if the function is called with the last block and an offset greater than zero. It is necessary to add a check to avoid this.
Found by Linux Verification Center (linuxtesting.org) with Svace.
[JK: Make test cover also unalloc table freeing]
--- fs/udf/balloc.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
fs/udf/balloc.c +13 -23
@@ -22,6 +22,7 @@#include "udfdecl.h" #include <linux/bitops.h> +#include <linux/overflow.h> #include "udf_i.h" #include "udf_sb.h"
@@ -133,7 +134,6 @@ static void udf_bitmap_free_blocks(struct super_block *sb, {struct udf_sb_info *sbi =UDF_SB (sb);struct buffer_head *bh =NULL ; -struct udf_part_map *partmap;unsigned long block;unsigned long block_group;unsigned long bit;
@@ -142,19 +142,9 @@ static void udf_bitmap_free_blocks(struct super_block *sb,unsigned long overflow;mutex_lock (&sbi->s_alloc_mutex); - partmap = &sbi->s_partmaps[bloc->partitionReferenceNum]; -if (bloc->logicalBlockNum + count < count || - (bloc->logicalBlockNum + count) > partmap->s_partition_len) { -udf_debug ("%u < %d || %u + %u > %u\n" , - bloc->logicalBlockNum,0 , - bloc->logicalBlockNum, count, - partmap->s_partition_len); - goto error_return; - } - +/* We make sure this cannot overflow when mounting the filesystem */ block = bloc->logicalBlockNum + offset + (sizeof (struct spaceBitmapDesc ) <<3 ); - do { overflow = 0; block_group = block >> (sb->s_blocksize_bits + 3);
@@ -384,7 +374,6 @@ static void udf_table_free_blocks(struct super_block *sb, uint32_t count) {struct udf_sb_info *sbi =UDF_SB (sb); -struct udf_part_map *partmap;uint32_t start, end;uint32_t elen;struct kernel_lb_addr eloc;
@@ -393,16 +382,6 @@ static void udf_table_free_blocks(struct super_block *sb,struct udf_inode_info *iinfo;mutex_lock (&sbi->s_alloc_mutex); - partmap = &sbi->s_partmaps[bloc->partitionReferenceNum]; -if (bloc->logicalBlockNum + count < count || - (bloc->logicalBlockNum + count) > partmap->s_partition_len) { -udf_debug ("%u < %d || %u + %u > %u\n" , - bloc->logicalBlockNum,0 , - bloc->logicalBlockNum, count, - partmap->s_partition_len); - goto error_return; - } - iinfo =UDF_I (table);udf_add_free_space (sb, sbi->s_partition, count);
@@ -677,6 +656,17 @@ void udf_free_blocks(struct super_block *sb, struct inode *inode, {uint16_t partition = bloc->partitionReferenceNum;struct udf_part_map *map = &UDF_SB (sb)->s_partmaps[partition]; +uint32_t blk; + +if (check_add_overflow (bloc->logicalBlockNum, offset, &blk) || +check_add_overflow (blk, count, &blk) || + bloc->logicalBlockNum + count > map->s_partition_len) { +udf_debug ("Invalid request to free blocks: (%d, %u), off %u, " +"len %u, partition len %u\n" , + partition, bloc->logicalBlockNum, offset, count, + map->s_partition_len); +return ; + }if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_BITMAP ) { udf_bitmap_free_blocks(sb, map->s_uspace.s_bitmap,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/11 wifi: nl80211: don't give key data to userspace
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit a7e5793035792cc46a1a4b0a783655ffa897dfe9 ]
When a key is requested by userspace, there's really no need to include the key data, the sequence counter is really what userspace needs in this case. The fact that it's included is just a historic quirk.
Remove the key data.
--- net/wireless/nl80211.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
net/wireless/nl80211.c +2 -8
@@ -4421,10 +4421,7 @@ static void get_key_callback(void *c, struct key_params *params)struct nlattr *key;struct get_key_cookie *cookie = c; - if ((params->key && - nla_put(cookie->msg, NL80211_ATTR_KEY_DATA, - params->key_len, params->key)) || - (params->seq && + if ((params->seq && nla_put(cookie->msg, NL80211_ATTR_KEY_SEQ, params->seq_len, params->seq)) || (params->cipher &&
@@ -4436,10 +4433,7 @@ static void get_key_callback(void *c, struct key_params *params)if (!key) goto nla_put_failure; - if ((params->key && - nla_put(cookie->msg, NL80211_KEY_DATA, - params->key_len, params->key)) || - (params->seq && + if ((params->seq && nla_put(cookie->msg, NL80211_KEY_SEQ, params->seq_len, params->seq)) || (params->cipher &&
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/11 can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum
In reply to Sasha LevinFrom: Marc Kleine-Budde <[email protected]>
[ Upstream commit b8e0ddd36ce9536ad7478dd27df06c9ae92370ba ]
This is a preparatory patch to work around a problem similar to erratum DS80000789E 6 of the mcp2518fd, the other variants of the chip family (mcp2517fd and mcp251863) are probably also affected.
Erratum DS80000789E 6 says "reading of the FIFOCI bits in the FIFOSTA register for an RX FIFO may be corrupted". However observation shows that this problem is not limited to RX FIFOs but also effects the TEF FIFO.
When handling the TEF interrupt, the driver reads the FIFO header index from the TEF FIFO STA register of the chip.
In the bad case, the driver reads a too large head index. In the original code, the driver always trusted the read value, which caused old CAN transmit complete events that were already processed to be re-processed.
Instead of reading and trusting the head index, read the head index and calculate the number of CAN frames that were supposedly received - replace mcp251xfd_tef_ring_update() with mcp251xfd_get_tef_len().
The mcp251xfd_handle_tefif() function reads the CAN transmit complete events from the chip, iterates over them and pushes them into the network stack. The original driver already contains code to detect old CAN transmit complete events, that will be updated in the next patch.
--- .../net/can/spi/mcp251xfd/mcp251xfd-ring.c | 2 + drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c | 54 +++++++++++++------ drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 13 ++--- 3 files changed, 43 insertions(+), 26 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c +2 -0
@@ -475,6 +475,8 @@ int mcp251xfd_ring_alloc(struct mcp251xfd_priv *priv)clear_bit (MCP251XFD_FLAGS_FD_MODE , priv->flags); } + tx_ring->obj_num_shift_to_u8 =BITS_PER_TYPE (tx_ring->obj_num) - +ilog2 (tx_ring->obj_num); tx_ring->obj_size = tx_obj_size; rem = priv->rx_obj_num;
drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c +38 -16
98 lines not on this page · raw message
drivers/net/can/spi/mcp251xfd/mcp251xfd.h +3 -10
@@ -519,6 +519,7 @@ struct mcp251xfd_tef_ring {/* u8 obj_num equals tx_ring->obj_num */ /* u8 obj_size equals sizeof(struct mcp251xfd_hw_tef_obj) */ +/* u8 obj_num_shift_to_u8 equals tx_ring->obj_num_shift_to_u8 */ union mcp251xfd_write_reg_buf irq_enable_buf;struct spi_transfer irq_enable_xfer;
@@ -537,6 +538,7 @@ struct mcp251xfd_tx_ring {u8 nr;u8 fifo_nr;u8 obj_num; +u8 obj_num_shift_to_u8;u8 obj_size;struct mcp251xfd_tx_obj obj[MCP251XFD_TX_OBJ_NUM_MAX ];
@@ -843,17 +845,8 @@ static inline u8 mcp251xfd_get_tef_tail(const struct mcp251xfd_priv *priv)return priv->tef->tail & (priv->tx->obj_num -1 ); } -static inline u8 mcp251xfd_get_tef_len (const struct mcp251xfd_priv *priv) +static inline u8 mcp251xfd_get_tef_linear_len (const struct mcp251xfd_priv *priv,u8 len) { -return priv->tef->head - priv->tef->tail; -} - -static inline u8 mcp251xfd_get_tef_linear_len (const struct mcp251xfd_priv *priv) -{ -u8 len; - - len =mcp251xfd_get_tef_len (priv); -return min_t (u8, len, priv->tx->obj_num -mcp251xfd_get_tef_tail (priv)); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/11 can: mcp251xfd: tef: update workaround for erratum DS80000789E 6 of mcp2518fd
In reply to Sasha LevinFrom: Marc Kleine-Budde <[email protected]>
[ Upstream commit 3a0a88fcbaf9e027ecca3fe8775be9700b4d6460 ]
This patch updates the workaround for a problem similar to erratum DS80000789E 6 of the mcp2518fd, the other variants of the chip family (mcp2517fd and mcp251863) are probably also affected.
Erratum DS80000789E 6 says "reading of the FIFOCI bits in the FIFOSTA register for an RX FIFO may be corrupted". However observation shows that this problem is not limited to RX FIFOs but also effects the TEF FIFO.
In the bad case, the driver reads a too large head index. As the FIFO is implemented as a ring buffer, this results in re-handling old CAN transmit complete events.
Every transmit complete event contains with a sequence number that equals to the sequence number of the corresponding TX request. This way old TX complete events can be detected.
If the original driver detects a non matching sequence number, it prints an info message and tries again later. As wrong sequence numbers can be explained by the erratum DS80000789E 6, demote the info message to debug level, streamline the code and update the comments.
Keep the behavior: If an old CAN TX complete event is detected, abort the iteration and mark the number of valid CAN TX complete events as processed in the chip by incrementing the FIFO's tail index.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c | 71 +++++++------------ 1 file changed, 27 insertions(+), 44 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c +27 -44
@@ -60,56 +60,39 @@ static int mcp251xfd_check_tef_tail(const struct mcp251xfd_priv *priv)return 0 ; } -static int -mcp251xfd_handle_tefif_recover (const struct mcp251xfd_priv *priv,const u32 seq) -{ -const struct mcp251xfd_tx_ring *tx_ring = priv->tx; -u32 tef_sta; -int err; - - err =regmap_read (priv->map_reg,MCP251XFD_REG_TEFSTA , &tef_sta); -if (err) -return err; - -if (tef_sta &MCP251XFD_REG_TEFSTA_TEFOVIF ) { -netdev_err (priv->ndev, -"Transmit Event FIFO buffer overflow.\n" ); -return -ENOBUFS ; - } - -netdev_info (priv->ndev, -"Transmit Event FIFO buffer %s. (seq=0x%08x, tef_tail=0x%08x, tef_head=0x%08x, tx_head=0x%08x).\n" , - tef_sta &MCP251XFD_REG_TEFSTA_TEFFIF ? -"full" : tef_sta &MCP251XFD_REG_TEFSTA_TEFNEIF ? -"not empty" :"empty" , - seq, priv->tef->tail, priv->tef->head, tx_ring->head); - -/* The Sequence Number in the TEF doesn't match our tef_tail. */ -return -EAGAIN ; -} -static int mcp251xfd_handle_tefif_one (struct mcp251xfd_priv *priv,const struct mcp251xfd_hw_tef_obj *hw_tef_obj,unsigned int *frame_len_ptr) {struct net_device_stats *stats = &priv->ndev->stats; +u32 seq, tef_tail_masked, tef_tail;struct sk_buff *skb; -u32 seq, seq_masked, tef_tail_masked, tef_tail; - seq =FIELD_GET (MCP251XFD_OBJ_FLAGS_SEQ_MCP2518FD_MASK , +/* Use the MCP2517FD mask on the MCP2518FD, too. We only +* compare 7 bits, this is enough to detect old TEF objects. +*/ + seq =FIELD_GET (MCP251XFD_OBJ_FLAGS_SEQ_MCP2517FD_MASK , hw_tef_obj->flags); - -/* Use the MCP2517FD mask on the MCP2518FD, too. We only -* compare 7 bits, this should be enough to detect -* net-yet-completed, i.e. old TEF objects. -*/ - seq_masked = seq & -field_mask (MCP251XFD_OBJ_FLAGS_SEQ_MCP2517FD_MASK ); tef_tail_masked = priv->tef->tail &field_mask (MCP251XFD_OBJ_FLAGS_SEQ_MCP2517FD_MASK ); -if (seq_masked != tef_tail_masked) -return mcp251xfd_handle_tefif_recover (priv, seq); + +/* According to mcp2518fd erratum DS80000789E 6. the FIFOCI +* bits of a FIFOSTA register, here the TX FIFO tail index +* might be corrupted and we might process past the TEF FIFO's +* head into old CAN frames. +* +* Compare the sequence number of the currently processed CAN +* frame with the expected sequence number. Abort with +* -EBADMSG if an old CAN frame is detected. +*/ +if (seq != tef_tail_masked) { +netdev_dbg (priv->ndev,"%s: chip=0x%02x ring=0x%02x\n" , __func__, + seq, tef_tail_masked); + stats->tx_fifo_errors++; + +return -EBADMSG ; + } tef_tail =mcp251xfd_get_tef_tail (priv); skb = priv->can.echo_skb[tef_tail];
@@ -223,12 +206,12 @@ int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)unsigned int frame_len =0 ; err =mcp251xfd_handle_tefif_one (priv, &hw_tef_obj[i], &frame_len); -/* -EAGAIN means the Sequence Number in the TEF -* doesn't match our tef_tail. This can happen if we -* read the TEF objects too early. Leave loop let the -* interrupt handler call us again. +/* -EBADMSG means we're affected by mcp2518fd erratum +* DS80000789E 6., i.e. the Sequence Number in the TEF +* doesn't match our tef_tail. Don't process any +* further and mark processed frames as good. */ -if (err == -EAGAIN ) +if (err == -EBADMSG ) goto out_netif_wake_queue;if (err)return err;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/11 btrfs: fix bitmap leak when loading free space cache on duplicate entry
In reply to Sasha LevinFrom: Filipe Manana <[email protected]>
[ Upstream commit 320d8dc612660da84c3b70a28658bb38069e5a9a ]
If we failed to link a free space entry because there's already a conflicting entry for the same offset, we free the free space entry but we don't free the associated bitmap that we had just allocated before. Fix that by freeing the bitmap before freeing the entry.
--- fs/btrfs/free-space-cache.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/free-space-cache.c +1 -0
@@ -865,6 +865,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,spin_unlock (&ctl->tree_lock);btrfs_err (fs_info,"Duplicate entries in free space cache, dumping" ); +kmem_cache_free (btrfs_free_space_bitmap_cachep, e->bitmap);kmem_cache_free (btrfs_free_space_cachep, e); goto free_cache; }
Signature · 1 line
2.43.0