RDMA/siw: Fix potential NULL pointer dereference in header processing
Subsystems (188)
PATCH 152/283 net: atm: fix crash due to unvalidated vcc pointer in sigd_send()
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit ae88a5d2f29b69819dc7b04086734439d074a643 ]
Reproducer available at [1].
The ATM send path (sendmsg -> vcc_sendmsg -> sigd_send) reads the vcc pointer from msg->vcc and uses it directly without any validation. This pointer comes from userspace via sendmsg() and can be arbitrarily forged:
int fd = socket(AF_ATMSVC, SOCK_DGRAM, 0);
ioctl(fd, ATMSIGD_CTRL); // become ATM signaling daemon
struct msghdr msg = { .msg_iov = &iov, ... };
*(unsigned long *)(buf + 4) = 0xdeadbeef; // fake vcc pointer
sendmsg(fd, &msg, 0); // kernel dereferences 0xdeadbeefIn normal operation, the kernel sends the vcc pointer to the signaling daemon via sigd_enq() when processing operations like connect(), bind(), or listen(). The daemon is expected to return the same pointer when responding. However, a malicious daemon can send arbitrary pointer values.
Fix this by introducing find_get_vcc() which validates the pointer by searching through vcc_hash (similar to how sigd_close() iterates over all VCCs), and acquires a reference via sock_hold() if found.
Since struct atm_vcc embeds struct sock as its first member, they share the same lifetime. Therefore using sock_hold/sock_put is sufficient to keep the vcc alive while it is being used.
Note that there may be a race with sigd_close() which could mark the vcc with various flags (e.g., ATM_VF_RELEASED) after find_get_vcc() returns. However, sock_hold() guarantees the memory remains valid, so this race only affects the logical state, not memory safety.
[1]: https://gist.github.com/mrpre/1ba5949c45529c511152e2f4c755b0f3
--- net/atm/signaling.c | 56 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
net/atm/signaling.c +54 -2
@@ -22,6 +22,36 @@struct atm_vcc *sigd =NULL ; +/* +* find_get_vcc - validate and get a reference to a vcc pointer +* @vcc: the vcc pointer to validate +* +* This function validates that @vcc points to a registered VCC in vcc_hash. +* If found, it increments the socket reference count and returns the vcc. +* The caller must call sock_put(sk_atm(vcc)) when done. +* +* Returns the vcc pointer if valid, NULL otherwise. +*/ +static struct atm_vcc *find_get_vcc (struct atm_vcc *vcc) +{ +int i; + +read_lock (&vcc_sklist_lock); +for (i =0 ; i <VCC_HTABLE_SIZE ; i++) { +struct sock *s; + +sk_for_each (s, &vcc_hash[i]) { +if (atm_sk (s) == vcc) { +sock_hold (s); +read_unlock (&vcc_sklist_lock); +return vcc; + } + } + } +read_unlock (&vcc_sklist_lock); +return NULL ; +} +static void sigd_put_skb (struct sk_buff *skb) {if (!sigd) {
@@ -69,7 +99,14 @@ static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb) msg = (struct atmsvc_msg *) skb->data;WARN_ON (refcount_sub_and_test (skb->truesize, &sk_atm (vcc)->sk_wmem_alloc)); - vcc = *(struct atm_vcc **) &msg->vcc; + + vcc =find_get_vcc (*(struct atm_vcc **)&msg->vcc); +if (!vcc) { +pr_debug ("invalid vcc pointer in msg\n" ); +dev_kfree_skb (skb); +return -EINVAL ; + } +pr_debug ("%d (0x%lx)\n" , (int )msg->type, (unsigned long )vcc); sk =sk_atm (vcc);
@@ -100,7 +137,16 @@ static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb)clear_bit (ATM_VF_WAITING , &vcc->flags);break ;case as_indicate: - vcc = *(struct atm_vcc **)&msg->listen_vcc; +/* Release the reference from msg->vcc, we'll use msg->listen_vcc instead */ +sock_put (sk); + + vcc =find_get_vcc (*(struct atm_vcc **)&msg->listen_vcc); +if (!vcc) { +pr_debug ("invalid listen_vcc pointer in msg\n" ); +dev_kfree_skb (skb); +return -EINVAL ; + } + sk =sk_atm (vcc);pr_debug ("as_indicate!!!\n" );lock_sock (sk);
@@ -115,6 +161,8 @@ static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb) sk->sk_state_change (sk); as_indicate_complete:release_sock (sk); +/* Paired with find_get_vcc(msg->listen_vcc) above */ +sock_put (sk);return 0 ;case as_close:set_bit (ATM_VF_RELEASED , &vcc->flags);
@@ -131,11 +179,15 @@ static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb)break ;default :pr_alert ("bad message type %d\n" , (int )msg->type); +/* Paired with find_get_vcc(msg->vcc) above */ +sock_put (sk);return -EINVAL ; } sk->sk_state_change (sk); out:dev_kfree_skb (skb); +/* Paired with find_get_vcc(msg->vcc) above */ +sock_put (sk);return 0 ; }
Signature · 1 line
2.51.0
PATCH 153/283 net: sunhme: Fix sbus regression
In reply to Sasha LevinFrom: René Rebe <[email protected]>
[ Upstream commit 8c5d17834ec104d0abd1bda52fbc04e647fab274 ]
Commit cc216e4b44ce ("net: sunhme: Switch SBUS to devres") changed explicit sized of_ioremap with BMAC_REG_SIZEs to devm_platform_ioremap_resource mapping all the resource. However, this does not work on my Sun Ultra 2 with SBUS HMEs:
hme f0072f38: error -EBUSY: can't request region for resource [mem 0x1ffe8c07000-0x1ffe8c0701f] hme f0072f38: Cannot map TCVR registers.
hme f0072f38: probe with driver hme failed with error -16
hme f007ab44: error -EBUSY: can't request region for resource [mem 0x1ff28c07000-0x1ff28c0701f] hme f007ab44: Cannot map TCVR registers.
hme f007ab44: probe with driver hme failed with error -16
Turns out the open-firmware resources overlap, at least on this machines and PROM version:
hexdump /proc/device-tree/sbus@1f,0/SUNW,hme@2,8c00000/reg:
00 00 00 02 08 c0 00 00 00 00 01 08 00 00 00 02 08 c0 20 00 00 00 20 00 00 00 00 02 08 c0 40 00 00 00 20 00 00 00 00 02 08 c0 60 00 00 00 20 00 00 00 00 02 08 c0 70 00 00 00 00 20
And the driver previously explicitly mapped way smaller mmio regions:
/proc/iomem:
1ff28c00000-1ff28c00107 : HME Global Regs
1ff28c02000-1ff28c02033 : HME TX Regs
1ff28c04000-1ff28c0401f : HME RX Regs
1ff28c06000-1ff28c0635f : HME BIGMAC Regs
1ff28c07000-1ff28c0701f : HME Tranceiver Regs
Quirk this specific issue by truncating the previous resource to not overlap into the TCVR registers.
--- drivers/net/ethernet/sun/sunhme.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/sun/sunhme.c +3 -0
@@ -2551,6 +2551,9 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) goto err_out_clear_quattro; } +/* BIGMAC may have bogus sizes */ +if ((op->resource[3 ].end - op->resource[3 ].start) >=BMAC_REG_SIZE ) + op->resource[3 ].end = op->resource[3 ].start +BMAC_REG_SIZE -1 ; hp->bigmacregs =devm_platform_ioremap_resource (op,3 );if (IS_ERR (hp->bigmacregs)) {dev_err (&op->dev,"Cannot map BIGMAC registers.\n" );
Signature · 1 line
2.51.0
PATCH 154/283 net: Add skb_dstref_steal and skb_dstref_restore
In reply to Sasha LevinFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit c3f0c02997c7f8489fec259e28e0e04e9811edac ]
Going forward skb_dst_set will assert that skb dst_entry
is empty during skb_dst_set to prevent potential leaks. There are few places that still manually manage dst_entry not using the helpers. Convert them to the following new helpers:
- skb_dstref_steal that resets dst_entry and returns previous dst_entry value
- skb_dstref_restore that restores dst_entry previously reset via skb_dstref_steal
Stable-dep-of: 81b84de32bb2 ("xfrm: fix ip_rt_bug race in icmp_route_lookup reverse path")
--- include/linux/skbuff.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
include/linux/skbuff.h +32 -0
@@ -1122,6 +1122,38 @@ static inline struct dst_entry *skb_dst(const struct sk_buff *skb)return (struct dst_entry *)(skb->_skb_refdst &SKB_DST_PTRMASK ); } +/** +* skb_dstref_steal() - return current dst_entry value and clear it +* @skb: buffer +* +* Resets skb dst_entry without adjusting its reference count. Useful in +* cases where dst_entry needs to be temporarily reset and restored. +* Note that the returned value cannot be used directly because it +* might contain SKB_DST_NOREF bit. +* +* When in doubt, prefer skb_dst_drop() over skb_dstref_steal() to correctly +* handle dst_entry reference counting. +* +* Returns: original skb dst_entry. +*/ +static inline unsigned long skb_dstref_steal (struct sk_buff *skb) +{ +unsigned long refdst = skb->_skb_refdst; + + skb->_skb_refdst =0 ; +return refdst; +} + +/** +* skb_dstref_restore() - restore skb dst_entry removed via skb_dstref_steal() +* @skb: buffer +* @refdst: dst entry from a call to skb_dstref_steal() +*/ +static inline void skb_dstref_restore (struct sk_buff *skb,unsigned long refdst) +{ + skb->_skb_refdst = refdst; +} +/** * skb_dst_set - sets skb dst * @skb: buffer
Signature · 1 line
2.51.0
PATCH 155/283 net: Switch to skb_dstref_steal/skb_dstref_restore for ip_route_input callers
In reply to Sasha LevinFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit e97e6a1830ddb5885ba312e56b6fa3aa39b5f47e ]
Going forward skb_dst_set will assert that skb dst_entry is empty during skb_dst_set. skb_dstref_steal is added to reset existing entry without doing refcnt. skb_dstref_restore should be used to restore the previous entry. Convert icmp_route_lookup and ip_options_rcv_srr to these helpers. Add extra call to skb_dstref_reset to icmp_route_lookup to clear the ip_route_input entry.
Stable-dep-of: 81b84de32bb2 ("xfrm: fix ip_rt_bug race in icmp_route_lookup reverse path")
--- net/ipv4/icmp.c | 7 ++++--- net/ipv4/ip_options.c | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-)
net/ipv4/icmp.c +4 -3
@@ -546,14 +546,15 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4, goto relookup_failed; }/* Ugh! */ - orefdst = skb_in->_skb_refdst;/* save old refdst */ -skb_dst_set (skb_in,NULL ); + orefdst =skb_dstref_steal (skb_in); err =ip_route_input (skb_in, fl4_dec.daddr, fl4_dec.saddr, dscp, rt2->dst.dev);dst_release (&rt2->dst); rt2 =skb_rtable (skb_in); - skb_in->_skb_refdst = orefdst;/* restore old refdst */ +/* steal dst entry from skb_in, don't drop refcnt */ +skb_dstref_steal (skb_in); +skb_dstref_restore (skb_in, orefdst); }if (err)
net/ipv4/ip_options.c +2 -3
@@ -615,14 +615,13 @@ int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev) }memcpy (&nexthop, &optptr[srrptr-1 ],4 ); - orefdst = skb->_skb_refdst; -skb_dst_set (skb,NULL ); + orefdst =skb_dstref_steal (skb); err =ip_route_input (skb, nexthop, iph->saddr,ip4h_dscp (iph), dev); rt2 =skb_rtable (skb);if (err || (rt2->rt_type !=RTN_UNICAST && rt2->rt_type !=RTN_LOCAL )) {skb_dst_drop (skb); - skb->_skb_refdst = orefdst; +skb_dstref_restore (skb, orefdst);return -EINVAL ; }refdst_drop (orefdst);
Signature · 1 line
2.51.0
PATCH 156/283 xfrm: fix ip_rt_bug race in icmp_route_lookup reverse path
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit 81b84de32bb27ae1ae2eb9acf0420e9d0d14bf00 ]
icmp_route_lookup() performs multiple route lookups to find a suitable route for sending ICMP error messages, with special handling for XFRM (IPsec) policies.
The lookup sequence is:
1. First, lookup output route for ICMP reply (dst = original src)
2. Pass through xfrm_lookup() for policy check
3. If blocked (-EPERM) or dst is not local, enter "reverse path"
4. In reverse path, call xfrm_decode_session_reverse() to get fl4_dec which reverses the original packet's flow (saddr<->daddr swapped)
5. If fl4_dec.saddr is local (we are the original destination), use __ip_route_output_key() for output route lookup
6. If fl4_dec.saddr is NOT local (we are a forwarding node), use ip_route_input() to simulate the reverse packet's input path
7. Finally, pass rt2 through xfrm_lookup() with XFRM_LOOKUP_ICMP flag
The bug occurs in step 6: ip_route_input() is called with fl4_dec.daddr (original packet's source) as destination. If this address becomes local between the initial check and ip_route_input() call (e.g., due to concurrent "ip addr add"), ip_route_input() returns a LOCAL route with dst.output set to ip_rt_bug.
This route is then used for ICMP output, causing dst_output() to call ip_rt_bug(), triggering a WARN_ON:
------------[ cut here ]------------ WARNING: net/ipv4/route.c:1275 at ip_rt_bug+0x21/0x30, CPU#1 Call Trace: <TASK> ip_push_pending_frames+0x202/0x240 icmp_push_reply+0x30d/0x430 __icmp_send+0x1149/0x24f0 ip_options_compile+0xa2/0xd0 ip_rcv_finish_core+0x829/0x1950 ip_rcv+0x2d7/0x420 __netif_receive_skb_one_core+0x185/0x1f0 netif_receive_skb+0x90/0x450 tun_get_user+0x3413/0x3fb0 tun_chr_write_iter+0xe4/0x220 ...
Fix this by checking rt2->rt_type after ip_route_input(). If it's RTN_LOCAL, the route cannot be used for output, so treat it as an error.
The reproducer requires kernel modification to widen the race window, making it unsuitable as a selftest. It is available at:
https://gist.github.com/mrpre/eae853b72ac6a750f5d45d64ddac1e81
--- net/ipv4/icmp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/ipv4/icmp.c +15 -0
@@ -555,6 +555,21 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4,/* steal dst entry from skb_in, don't drop refcnt */ skb_dstref_steal (skb_in);skb_dstref_restore (skb_in, orefdst); + +/* +* At this point, fl4_dec.daddr should NOT be local (we +* checked fl4_dec.saddr above). However, a race condition +* may occur if the address is added to the interface +* concurrently. In that case, ip_route_input() returns a +* LOCAL route with dst.output=ip_rt_bug, which must not +* be used for output. +*/ +if (!err && rt2 && rt2->rt_type ==RTN_LOCAL ) { +net_warn_ratelimited ("detected local route for %pI4 during ICMP sending, src %pI4\n" , + &fl4_dec.daddr, &fl4_dec.saddr); +dst_release (&rt2->dst); + err = -EINVAL ; + } }if (err)
Signature · 1 line
2.51.0
PATCH 157/283 serial: caif: fix use-after-free in caif_serial ldisc_close()
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit 308e7e4d0a846359685f40aade023aee7b27284c ]
There is a use-after-free bug in caif_serial where handle_tx() may access ser->tty after the tty has been freed.
The race condition occurs between ldisc_close() and packet transmission:
CPU 0 (close) CPU 1 (xmit)
------------- ------------
ldisc_close()
tty_kref_put(ser->tty)
[tty may be freed here]
<-- race window -->
caif_xmit()
handle_tx()
tty = ser->tty // dangling ptr
tty->ops->write() // UAF!
schedule_work()
ser_release()
unregister_netdevice()The root cause is that tty_kref_put() is called in ldisc_close() while the network device is still active and can receive packets.
Since ser and tty have a 1:1 binding relationship with consistent lifecycles (ser is allocated in ldisc_open and freed in ser_release via unregister_netdevice, and each ser binds exactly one tty), we can safely defer the tty reference release to ser_release() where the network device is unregistered.
Fix this by moving tty_kref_put() from ldisc_close() to ser_release(), after unregister_netdevice(). This ensures the tty reference is held as long as the network device exists, preventing the UAF.
Note: We save ser->tty before unregister_netdevice() because ser is embedded in netdev's private data and will be freed along with netdev (needs_free_netdev = true).
How to reproduce: Add mdelay(500) at the beginning of ldisc_close() to widen the race window, then run the reproducer program [1].
Note: There is a separate deadloop issue in handle_tx() when using PORT_UNKNOWN serial ports (e.g., /dev/ttyS3 in QEMU without proper serial backend). This deadloop exists even without this patch, and is likely caused by inconsistency between uart_write_room() and uart_write() in serial core. It has been addressed in a separate patch [2].
KASAN report:
==================================================================
BUG: KASAN: slab-use-after-free in handle_tx+0x5d1/0x620 Read of size 1 at addr ffff8881131e1490 by task caif_uaf_trigge/9929 Call Trace: <TASK> dump_stack_lvl+0x10e/0x1f0 print_report+0xd0/0x630 kasan_report+0xe4/0x120 handle_tx+0x5d1/0x620 dev_hard_start_xmit+0x9d/0x6c0 __dev_queue_xmit+0x6e2/0x4410 packet_xmit+0x243/0x360 packet_sendmsg+0x26cf/0x5500 __sys_sendto+0x4a3/0x520 __x64_sys_sendto+0xe0/0x1c0 do_syscall_64+0xc9/0xf80 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f615df2c0d7 Allocated by task 9930: Freed by task 64: Last potentially related work creation: The buggy address belongs to the object at ffff8881131e1000 which belongs to the cache kmalloc-cg-2k of size 2048
The buggy address is located 1168 bytes inside of
freed 2048-byte region [ffff8881131e1000, ffff8881131e1800)
The buggy address belongs to the physical page:
page_owner tracks the page as allocated
page last free pid 9778 tgid 9778 stack trace:
Memory state around the buggy address:
ffff8881131e1380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881131e1400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881131e1480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881131e1500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881131e1580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================[1]: https://gist.github.com/mrpre/f683f244544f7b11e7fa87df9e6c2eeb
[2]: https://lore.kernel.org/linux-serial/[email protected]/T/#u
--- drivers/net/caif/caif_serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/caif/caif_serial.c +3 -2
@@ -298,6 +298,7 @@ static void ser_release(struct work_struct *work) {struct list_head list;struct ser_device *ser, *tmp; +struct tty_struct *tty;spin_lock (&ser_lock);list_replace_init (&ser_release_list, &list);
@@ -306,9 +307,11 @@ static void ser_release(struct work_struct *work)if (!list_empty (&list)) {rtnl_lock ();list_for_each_entry_safe (ser, tmp, &list, node) { + tty = ser->tty;dev_close (ser->dev);unregister_netdevice (ser->dev);debugfs_deinit (ser); +tty_kref_put (tty); }rtnl_unlock (); }
@@ -369,8 +372,6 @@ static void ldisc_close(struct tty_struct *tty) {struct ser_device *ser = tty->disc_data; -tty_kref_put (ser->tty); -spin_lock (&ser_lock);list_move (&ser->node, &ser_release_list);spin_unlock (&ser_lock);
Signature · 1 line
2.51.0
PATCH 158/283 octeon_ep: support to fetch firmware info
In reply to Sasha LevinFrom: Shinas Rasheed <[email protected]>
[ Upstream commit 8d6198a14e2bfb09f190055b387c90b4ac9b49a4 ]
Add support to fetch firmware info such as heartbeat miss count, heartbeat interval. This shall be used for heartbeat monitor.
Stable-dep-of: 73e6ffa37ceb ("octeon_ep: disable per ring interrupts")
--- .../marvell/octeon_ep/octep_cn9k_pf.c | 10 +++----- .../ethernet/marvell/octeon_ep/octep_config.h | 22 +++++++++++++---- .../marvell/octeon_ep/octep_ctrl_net.c | 24 ++++++++++++++++++- .../marvell/octeon_ep/octep_ctrl_net.h | 18 ++++++++++++++ .../ethernet/marvell/octeon_ep/octep_main.c | 16 +++++++++---- .../marvell/octeon_ep/octep_regs_cn9k_pf.h | 4 ++++ 6 files changed, 77 insertions(+), 17 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +3 -7
@@ -16,9 +16,6 @@#define CTRL_MBOX_MAX_PF 128#define CTRL_MBOX_SZ ((size_t)(0x400000 / CTRL_MBOX_MAX_PF)) -#define FW_HB_INTERVAL_IN_SECS 1 -#define FW_HB_MISS_COUNT 10 -/* Names of Hardware non-queue generic interrupts */ static char *cn93_non_ioq_msix_names[] = {"epf_ire_rint" ,
@@ -250,12 +247,11 @@ static void octep_init_config_cn93_pf(struct octep_device *oct) link =PCI_DEVFN (PCI_SLOT (oct->pdev->devfn), link); } conf->ctrl_mbox_cfg.barmem_addr = (void __iomem *)oct->mmio[2 ].hw_addr + - (0x400000ull *7 ) + +CN93_PEM_BAR4_INDEX_OFFSET + (link *CTRL_MBOX_SZ ); - conf->hb_interval =FW_HB_INTERVAL_IN_SECS ; - conf->max_hb_miss_cnt =FW_HB_MISS_COUNT ; - + conf->fw_info.hb_interval =OCTEP_DEFAULT_FW_HB_INTERVAL ; + conf->fw_info.hb_miss_count =OCTEP_DEFAULT_FW_HB_MISS_COUNT ; }/* Setup registers for a hardware Tx Queue */
drivers/net/ethernet/marvell/octeon_ep/octep_config.h +17 -5
@@ -49,6 +49,11 @@/* Default MTU */ #define OCTEP_DEFAULT_MTU 1500 +/* pf heartbeat interval in milliseconds */ +#define OCTEP_DEFAULT_FW_HB_INTERVAL 1000 +/* pf heartbeat miss count */ +#define OCTEP_DEFAULT_FW_HB_MISS_COUNT 20 +/* Macros to get octeon config params */ #define CFG_GET_IQ_CFG (cfg) ((cfg)->iq)#define CFG_GET_IQ_NUM_DESC (cfg) ((cfg)->iq.num_descs)
@@ -181,6 +186,16 @@ struct octep_ctrl_mbox_config {void __iomem *barmem_addr; }; +/* Info from firmware */ +struct octep_fw_info { +/* interface pkind */ +u16 pkind; +/* heartbeat interval in milliseconds */ +u16 hb_interval; +/* heartbeat miss count */ +u16 hb_miss_count; +}; +/* Data Structure to hold configuration limits and active config */ struct octep_config {/* Input Queue attributes. */
@@ -201,10 +216,7 @@ struct octep_config {/* ctrl mbox config */ struct octep_ctrl_mbox_config ctrl_mbox_cfg; -/* Configured maximum heartbeat miss count */ -u32 max_hb_miss_cnt; - -/* Configured firmware heartbeat interval in secs */ - u32 hb_interval; +/* fw info */ + struct octep_fw_info fw_info; };#endif /* _OCTEP_CONFIG_H_ */
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +23 -1
@@ -26,7 +26,7 @@ static atomic_t ctrl_net_msg_id;/* Control plane version in which OCTEP_CTRL_NET_H2F_CMD was added */ static const u32 octep_ctrl_net_h2f_cmd_versions[OCTEP_CTRL_NET_H2F_CMD_MAX ] = { - [OCTEP_CTRL_NET_H2F_CMD_INVALID ...OCTEP_CTRL_NET_H2F_CMD_LINK_INFO ] = + [OCTEP_CTRL_NET_H2F_CMD_INVALID ...OCTEP_CTRL_NET_H2F_CMD_GET_INFO ] =OCTEP_CP_VERSION (1 ,0 ,0 ) };
@@ -353,6 +353,28 @@ void octep_ctrl_net_recv_fw_messages(struct octep_device *oct) } } +int octep_ctrl_net_get_info (struct octep_device *oct,int vfid, +struct octep_fw_info *info) +{ +struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_h2f_resp *resp; +struct octep_ctrl_net_h2f_req *req; +int err; + + req = &d.data.req; +init_send_req (&d.msg, req,0 , vfid); + req->hdr.s.cmd =OCTEP_CTRL_NET_H2F_CMD_GET_INFO ; + req->link_info.cmd =OCTEP_CTRL_NET_CMD_GET ; + err =octep_send_mbox_req (oct, &d, true); +if (err <0 ) +return err; + + resp = &d.data.resp; +memcpy (info, &resp->info.fw_info,sizeof (struct octep_fw_info )); + +return 0 ; +} +int octep_ctrl_net_uninit (struct octep_device *oct) {struct octep_ctrl_net_wait_data *pos, *n;
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h +18 -0
@@ -41,6 +41,7 @@ enum octep_ctrl_net_h2f_cmd {OCTEP_CTRL_NET_H2F_CMD_LINK_STATUS ,OCTEP_CTRL_NET_H2F_CMD_RX_STATE ,OCTEP_CTRL_NET_H2F_CMD_LINK_INFO , +OCTEP_CTRL_NET_H2F_CMD_GET_INFO , OCTEP_CTRL_NET_H2F_CMD_MAX };
@@ -161,6 +162,11 @@ struct octep_ctrl_net_h2f_resp_cmd_state {u16 state; }; +/* get info request */ +struct octep_ctrl_net_h2f_resp_cmd_get_info { +struct octep_fw_info fw_info; +}; +/* Host to fw response data */ struct octep_ctrl_net_h2f_resp {union octep_ctrl_net_resp_hdr hdr;
@@ -171,6 +177,7 @@ struct octep_ctrl_net_h2f_resp {struct octep_ctrl_net_h2f_resp_cmd_state link;struct octep_ctrl_net_h2f_resp_cmd_state rx;struct octep_ctrl_net_link_info link_info; +struct octep_ctrl_net_h2f_resp_cmd_get_info info; }; } __packed;
@@ -330,6 +337,17 @@ int octep_ctrl_net_set_link_info(struct octep_device *oct,*/ void octep_ctrl_net_recv_fw_messages (struct octep_device *oct); +/** Get info from firmware. +* +* @param oct: non-null pointer to struct octep_device. +* @param vfid: Index of virtual function. +* @param info: non-null pointer to struct octep_fw_info. +* +* return value: 0 on success, -errno on failure. +*/ +int octep_ctrl_net_get_info (struct octep_device *oct,int vfid, +struct octep_fw_info *info); +/** Uninitialize data for ctrl net. * * @param oct: non-null pointer to struct octep_device.
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +12 -4
@@ -907,9 +907,9 @@ static void octep_hb_timeout_task(struct work_struct *work)int miss_cnt; miss_cnt =atomic_inc_return (&oct->hb_miss_cnt); -if (miss_cnt < oct->conf->max_hb_miss_cnt) { +if (miss_cnt < oct->conf->fw_info.hb_miss_count) {queue_delayed_work (octep_wq, &oct->hb_task, -msecs_to_jiffies (oct->conf->hb_interval *1000 )); +msecs_to_jiffies (oct->conf->fw_info.hb_interval));return ; }
@@ -1002,8 +1002,7 @@ int octep_device_setup(struct octep_device *oct)atomic_set (&oct->hb_miss_cnt,0 );INIT_DELAYED_WORK (&oct->hb_task, octep_hb_timeout_task); -queue_delayed_work (octep_wq, &oct->hb_task, -msecs_to_jiffies (oct->conf->hb_interval *1000 )); +return 0 ; unsupported_dev:
@@ -1133,6 +1132,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)dev_err (&pdev->dev,"Device setup failed\n" ); goto err_octep_config; } + +octep_ctrl_net_get_info (octep_dev,OCTEP_CTRL_NET_INVALID_VFID , + &octep_dev->conf->fw_info); +dev_info (&octep_dev->pdev->dev,"Heartbeat interval %u msecs Heartbeat miss count %u\n" , + octep_dev->conf->fw_info.hb_interval, + octep_dev->conf->fw_info.hb_miss_count); +queue_delayed_work (octep_wq, &octep_dev->hb_task, +msecs_to_jiffies (octep_dev->conf->fw_info.hb_interval)); +INIT_WORK (&octep_dev->tx_timeout_task, octep_tx_timeout_task);INIT_WORK (&octep_dev->ctrl_mbox_task, octep_ctrl_mbox_task);INIT_DELAYED_WORK (&octep_dev->intr_poll_task, octep_intr_poll_task);
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cn9k_pf.h +4 -0
@@ -370,4 +370,8 @@/* bit 1 for firmware heartbeat interrupt */ #define CN93_SDP_EPF_OEI_RINT_DATA_BIT_HBEAT BIT_ULL(1) +#define CN93_PEM_BAR4_INDEX 7 +#define CN93_PEM_BAR4_INDEX_SIZE 0x400000ULL +#define CN93_PEM_BAR4_INDEX_OFFSET (CN93_PEM_BAR4_INDEX * CN93_PEM_BAR4_INDEX_SIZE) +#endif /* _OCTEP_REGS_CN9K_PF_H_ */
Signature · 1 line
2.51.0
PATCH 159/283 octeon_ep: restructured interrupt handlers
In reply to Sasha LevinFrom: Shinas Rasheed <[email protected]>
[ Upstream commit 0b8ef824eedef96f3423f61dde2629755707b168 ]
Separated queue specific interrupts to register to individual msix-vectors instead of using a single generic interrupt handler on a single msix-vector.
Stable-dep-of: 73e6ffa37ceb ("octeon_ep: disable per ring interrupts")
--- .../marvell/octeon_ep/octep_cn9k_pf.c | 158 ++++++++++---- .../ethernet/marvell/octeon_ep/octep_main.c | 197 +++++++++++++++++- .../ethernet/marvell/octeon_ep/octep_main.h | 13 +- 3 files changed, 323 insertions(+), 45 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +122 -36
@@ -369,34 +369,40 @@ static void octep_setup_mbox_regs_cn93_pf(struct octep_device *oct, int q_no) mbox->mbox_read_reg = oct->mmio[0 ].hw_addr +CN93_SDP_R_MBOX_VF_PF_DATA (q_no); } -/* Process non-ioq interrupts required to keep pf interface running. -* OEI_RINT is needed for control mailbox -*/ -static bool octep_poll_non_ioq_interrupts_cn93_pf (struct octep_device *oct) -{ -bool handled = false; -u64 reg0; - -/* Check for OEI INTR */ - reg0 =octep_read_csr64 (oct,CN93_SDP_EPF_OEI_RINT ); -if (reg0) { -dev_info (&oct->pdev->dev, -"Received OEI_RINT intr: 0x%llx\n" , - reg0); -octep_write_csr64 (oct,CN93_SDP_EPF_OEI_RINT , reg0); -if (reg0 &CN93_SDP_EPF_OEI_RINT_DATA_BIT_MBOX ) +/* Poll OEI events like heartbeat */ +static void octep_poll_oei_cn93_pf (struct octep_device *oct) +{ +u64 reg; + + reg =octep_read_csr64 (oct,CN93_SDP_EPF_OEI_RINT ); +if (reg) { +octep_write_csr64 (oct,CN93_SDP_EPF_OEI_RINT , reg); +if (reg &CN93_SDP_EPF_OEI_RINT_DATA_BIT_MBOX )queue_work (octep_wq, &oct->ctrl_mbox_task); -else if (reg0 &CN93_SDP_EPF_OEI_RINT_DATA_BIT_HBEAT ) +else if (reg &CN93_SDP_EPF_OEI_RINT_DATA_BIT_HBEAT )atomic_set (&oct->hb_miss_cnt,0 ); - - handled = true; } +} + +/* OEI interrupt handler */ +static irqreturn_t octep_oei_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; -return handled; +octep_poll_oei_cn93_pf (oct); +return IRQ_HANDLED ; +} + +/* Process non-ioq interrupts required to keep pf interface running. +* OEI_RINT is needed for control mailbox +*/ +static void octep_poll_non_ioq_interrupts_cn93_pf (struct octep_device *oct) +{ +octep_poll_oei_cn93_pf (oct); } -/* Interrupts handler for all non-queue generic interrupts. */ -static irqreturn_t octep_non_ioq_intr_handler_cn93_pf (void *dev) +/* Interrupt handler for input ring error interrupts. */ +static irqreturn_t octep_ire_intr_handler_cn93_pf (void *dev) {struct octep_device *oct = (struct octep_device *)dev;struct pci_dev *pdev = oct->pdev;
@@ -421,8 +427,17 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev) reg_val); } } - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupt handler for output ring error interrupts. */ +static irqreturn_t octep_ore_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev; +u64 reg_val =0 ; +int i =0 ;/* Check for ORERR INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_ORERR_RINT );
@@ -440,9 +455,16 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev) reg_val); } } - - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupt handler for vf input ring error interrupts. */ +static irqreturn_t octep_vfire_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev; +u64 reg_val =0 ;/* Check for VFIRE INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_VFIRE_RINT (0 ));
@@ -450,8 +472,16 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev)dev_info (&pdev->dev,"Received VFIRE_RINT intr: 0x%llx\n" , reg_val);octep_write_csr64 (oct,CN93_SDP_EPF_VFIRE_RINT (0 ), reg_val); - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupt handler for vf output ring error interrupts. */ +static irqreturn_t octep_vfore_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev; +u64 reg_val =0 ;/* Check for VFORE INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_VFORE_RINT (0 ));
@@ -459,19 +489,30 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev)dev_info (&pdev->dev,"Received VFORE_RINT intr: 0x%llx\n" , reg_val);octep_write_csr64 (oct,CN93_SDP_EPF_VFORE_RINT (0 ), reg_val); - goto irq_handled; } +return IRQ_HANDLED ; +} -/* Check for MBOX INTR and OEI INTR */ -if (octep_poll_non_ioq_interrupts_cn93_pf (oct)) - goto irq_handled; +/* Interrupt handler for dpi dma related interrupts. */ +static irqreturn_t octep_dma_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +u64 reg_val =0 ;/* Check for DMA INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_DMA_RINT );if (reg_val) {octep_write_csr64 (oct,CN93_SDP_EPF_DMA_RINT , reg_val); - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupt handler for dpi dma transaction error interrupts for VFs */ +static irqreturn_t octep_dma_vf_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev; +u64 reg_val =0 ;/* Check for DMA VF INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_DMA_VF_RINT (0 ));
@@ -479,8 +520,16 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev)dev_info (&pdev->dev,"Received DMA_VF_RINT intr: 0x%llx\n" , reg_val);octep_write_csr64 (oct,CN93_SDP_EPF_DMA_VF_RINT (0 ), reg_val); - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupt handler for pp transaction error interrupts for VFs */ +static irqreturn_t octep_pp_vf_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev; +u64 reg_val =0 ;/* Check for PPVF INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_PP_VF_RINT (0 ));
@@ -488,8 +537,16 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev)dev_info (&pdev->dev,"Received PP_VF_RINT intr: 0x%llx\n" , reg_val);octep_write_csr64 (oct,CN93_SDP_EPF_PP_VF_RINT (0 ), reg_val); - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupt handler for mac related interrupts. */ +static irqreturn_t octep_misc_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev; +u64 reg_val =0 ;/* Check for MISC INTR */ reg_val =octep_read_csr64 (oct,CN93_SDP_EPF_MISC_RINT );
@@ -497,11 +554,17 @@ static irqreturn_t octep_non_ioq_intr_handler_cn93_pf(void *dev)dev_info (&pdev->dev,"Received MISC_RINT intr: 0x%llx\n" , reg_val);octep_write_csr64 (oct,CN93_SDP_EPF_MISC_RINT , reg_val); - goto irq_handled; } +return IRQ_HANDLED ; +} + +/* Interrupts handler for all reserved interrupts. */ +static irqreturn_t octep_rsvd_intr_handler_cn93_pf (void *dev) +{ +struct octep_device *oct = (struct octep_device *)dev; +struct pci_dev *pdev = oct->pdev;dev_info (&pdev->dev,"Reserved interrupts raised; Ignore\n" ); -irq_handled:return IRQ_HANDLED ; }
@@ -565,8 +628,15 @@ static void octep_enable_interrupts_cn93_pf(struct octep_device *oct)octep_write_csr64 (oct,CN93_SDP_EPF_IRERR_RINT_ENA_W1S , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_ORERR_RINT_ENA_W1S , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_OEI_RINT_ENA_W1S ,-1ULL ); + +octep_write_csr64 (oct,CN93_SDP_EPF_VFIRE_RINT_ENA_W1S (0 ),-1ULL ); +octep_write_csr64 (oct,CN93_SDP_EPF_VFORE_RINT_ENA_W1S (0 ),-1ULL ); +octep_write_csr64 (oct,CN93_SDP_EPF_MISC_RINT_ENA_W1S , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_DMA_RINT_ENA_W1S , intr_mask); + +octep_write_csr64 (oct,CN93_SDP_EPF_DMA_VF_RINT_ENA_W1S (0 ),-1ULL ); +octep_write_csr64 (oct,CN93_SDP_EPF_PP_VF_RINT_ENA_W1S (0 ),-1ULL ); }/* Disable all interrupts */
@@ -584,8 +654,15 @@ static void octep_disable_interrupts_cn93_pf(struct octep_device *oct)octep_write_csr64 (oct,CN93_SDP_EPF_IRERR_RINT_ENA_W1C , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_ORERR_RINT_ENA_W1C , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_OEI_RINT_ENA_W1C ,-1ULL ); + +octep_write_csr64 (oct,CN93_SDP_EPF_VFIRE_RINT_ENA_W1C (0 ),-1ULL ); +octep_write_csr64 (oct,CN93_SDP_EPF_VFORE_RINT_ENA_W1C (0 ),-1ULL ); +octep_write_csr64 (oct,CN93_SDP_EPF_MISC_RINT_ENA_W1C , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_DMA_RINT_ENA_W1C , intr_mask); + +octep_write_csr64 (oct,CN93_SDP_EPF_DMA_VF_RINT_ENA_W1C (0 ),-1ULL ); +octep_write_csr64 (oct,CN93_SDP_EPF_PP_VF_RINT_ENA_W1C (0 ),-1ULL ); }/* Get new Octeon Read Index: index of descriptor that Octeon reads next. */
@@ -718,7 +795,16 @@ void octep_device_setup_cn93_pf(struct octep_device *oct) oct->hw_ops.setup_oq_regs = octep_setup_oq_regs_cn93_pf; oct->hw_ops.setup_mbox_regs = octep_setup_mbox_regs_cn93_pf; - oct->hw_ops.non_ioq_intr_handler = octep_non_ioq_intr_handler_cn93_pf; + oct->hw_ops.oei_intr_handler = octep_oei_intr_handler_cn93_pf; + oct->hw_ops.ire_intr_handler = octep_ire_intr_handler_cn93_pf; + oct->hw_ops.ore_intr_handler = octep_ore_intr_handler_cn93_pf; + oct->hw_ops.vfire_intr_handler = octep_vfire_intr_handler_cn93_pf; + oct->hw_ops.vfore_intr_handler = octep_vfore_intr_handler_cn93_pf; + oct->hw_ops.dma_intr_handler = octep_dma_intr_handler_cn93_pf; + oct->hw_ops.dma_vf_intr_handler = octep_dma_vf_intr_handler_cn93_pf; + oct->hw_ops.pp_vf_intr_handler = octep_pp_vf_intr_handler_cn93_pf; + oct->hw_ops.misc_intr_handler = octep_misc_intr_handler_cn93_pf; + oct->hw_ops.rsvd_intr_handler = octep_rsvd_intr_handler_cn93_pf; oct->hw_ops.ioq_intr_handler = octep_ioq_intr_handler_cn93_pf; oct->hw_ops.soft_reset = octep_soft_reset_cn93_pf; oct->hw_ops.reinit_regs = octep_reinit_regs_cn93_pf;
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +190 -7
217 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_main.h +11 -2
@@ -65,7 +65,16 @@ struct octep_hw_ops {void (*setup_oq_regs)(struct octep_device *oct,int q);void (*setup_mbox_regs)(struct octep_device *oct,int mbox); -irqreturn_t (*non_ioq_intr_handler)(void *ioq_vector); +irqreturn_t (*oei_intr_handler)(void *ioq_vector); +irqreturn_t (*ire_intr_handler)(void *ioq_vector); +irqreturn_t (*ore_intr_handler)(void *ioq_vector); +irqreturn_t (*vfire_intr_handler)(void *ioq_vector); +irqreturn_t (*vfore_intr_handler)(void *ioq_vector); +irqreturn_t (*dma_intr_handler)(void *ioq_vector); +irqreturn_t (*dma_vf_intr_handler)(void *ioq_vector); +irqreturn_t (*pp_vf_intr_handler)(void *ioq_vector); +irqreturn_t (*misc_intr_handler)(void *ioq_vector); +irqreturn_t (*rsvd_intr_handler)(void *ioq_vector);irqreturn_t (*ioq_intr_handler)(void *ioq_vector);int (*soft_reset)(struct octep_device *oct);void (*reinit_regs)(struct octep_device *oct);
@@ -73,7 +82,7 @@ struct octep_hw_ops {void (*enable_interrupts)(struct octep_device *oct);void (*disable_interrupts)(struct octep_device *oct); -bool (*poll_non_ioq_interrupts)(struct octep_device *oct); +void (*poll_non_ioq_interrupts)(struct octep_device *oct);void (*enable_io_queues)(struct octep_device *oct);void (*disable_io_queues)(struct octep_device *oct);
Signature · 1 line
2.51.0
PATCH 160/283 octeon_ep: support Octeon CN10K devices
In reply to Sasha LevinFrom: Shinas Rasheed <[email protected]>
[ Upstream commit 0807dc76f3bf500f9a22465eedd2290da7357efb ]
Add PCI Endpoint NIC support for Octeon CN10K devices. CN10K devices are part of Octeon 10 family products with similar PCI NIC characteristics. These include:
- CN10KA
- CNF10KA
- CNF10KB
- CN10KB
Update supported device list in Documentation
Stable-dep-of: 73e6ffa37ceb ("octeon_ep: disable per ring interrupts")
--- .../ethernet/marvell/octeon_ep.rst | 4 + .../net/ethernet/marvell/octeon_ep/Makefile | 3 +- .../marvell/octeon_ep/octep_cnxk_pf.c | 886 ++++++++++++++++++ .../ethernet/marvell/octeon_ep/octep_main.c | 20 + .../ethernet/marvell/octeon_ep/octep_main.h | 6 + .../marvell/octeon_ep/octep_regs_cnxk_pf.h | 400 ++++++++ 6 files changed, 1318 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c create mode 100644 drivers/net/ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h
Documentation/networking/device_drivers/ethernet/marvell/octeon_ep.rst +4 -0
@@ -24,6 +24,10 @@ Supported Devices Currently, this driver support following devices: * Network controller: Cavium, Inc. Device b200 * Network controller: Cavium, Inc. Device b400 + * Network controller: Cavium, Inc. Device b900 + * Network controller: Cavium, Inc. Device ba00 + * Network controller: Cavium, Inc. Device bc00 + * Network controller: Cavium, Inc. Device bd00 Interface Control =================
drivers/net/ethernet/marvell/octeon_ep/Makefile +2 -1
@@ -6,4 +6,5 @@ obj-$(CONFIG_OCTEON_EP) += octeon_ep.o octeon_ep-y := octep_main.o octep_cn9k_pf.o octep_tx.o octep_rx.o \ - octep_ethtool.o octep_ctrl_mbox.o octep_ctrl_net.o + octep_ethtool.o octep_ctrl_mbox.o octep_ctrl_net.o \ + octep_cnxk_pf.o
drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c new file +886 -0
886 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +20 -0
@@ -24,6 +24,10 @@ struct workqueue_struct *octep_wq;static const struct pci_device_id octep_pci_id_tbl[] = { {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,OCTEP_PCI_DEVICE_ID_CN93_PF )}, {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,OCTEP_PCI_DEVICE_ID_CNF95N_PF )}, + {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,OCTEP_PCI_DEVICE_ID_CN10KA_PF )}, + {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,OCTEP_PCI_DEVICE_ID_CNF10KA_PF )}, + {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,OCTEP_PCI_DEVICE_ID_CNF10KB_PF )}, + {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,OCTEP_PCI_DEVICE_ID_CN10KB_PF )}, {0 , }, };MODULE_DEVICE_TABLE (pci, octep_pci_id_tbl);
@@ -1126,6 +1130,14 @@ static const char *octep_devid_to_str(struct octep_device *oct)return "CN93XX" ;case OCTEP_PCI_DEVICE_ID_CNF95N_PF :return "CNF95N" ; +case OCTEP_PCI_DEVICE_ID_CN10KA_PF : +return "CN10KA" ; +case OCTEP_PCI_DEVICE_ID_CNF10KA_PF : +return "CNF10KA" ; +case OCTEP_PCI_DEVICE_ID_CNF10KB_PF : +return "CNF10KB" ; +case OCTEP_PCI_DEVICE_ID_CN10KB_PF : +return "CN10KB" ;default :return "Unsupported" ; }
@@ -1171,6 +1183,14 @@ int octep_device_setup(struct octep_device *oct) OCTEP_MINOR_REV(oct));octep_device_setup_cn93_pf (oct);break ; +case OCTEP_PCI_DEVICE_ID_CNF10KA_PF : +case OCTEP_PCI_DEVICE_ID_CN10KA_PF : +case OCTEP_PCI_DEVICE_ID_CNF10KB_PF : +case OCTEP_PCI_DEVICE_ID_CN10KB_PF : +dev_info (&pdev->dev,"Setting up OCTEON %s PF PASS%d.%d\n" , +octep_devid_to_str (oct),OCTEP_MAJOR_REV (oct),OCTEP_MINOR_REV (oct)); +octep_device_setup_cnxk_pf (oct); +break ;default :dev_err (&pdev->dev,"%s: unsupported device\n" , __func__);
drivers/net/ethernet/marvell/octeon_ep/octep_main.h +6 -0
@@ -23,6 +23,11 @@#define OCTEP_PCI_DEVICE_ID_CNF95N_PF 0xB400 //95N PF +#define OCTEP_PCI_DEVICE_ID_CN10KA_PF 0xB900 //CN10KA PF +#define OCTEP_PCI_DEVICE_ID_CNF10KA_PF 0xBA00 //CNF10KA PF +#define OCTEP_PCI_DEVICE_ID_CNF10KB_PF 0xBC00 //CNF10KB PF +#define OCTEP_PCI_DEVICE_ID_CN10KB_PF 0xBD00 //CN10KB PF +#define OCTEP_MAX_QUEUES 63#define OCTEP_MAX_IQ OCTEP_MAX_QUEUES#define OCTEP_MAX_OQ OCTEP_MAX_QUEUES
@@ -377,6 +382,7 @@ int octep_setup_oqs(struct octep_device *oct);void octep_free_oqs (struct octep_device *oct);void octep_oq_dbell_init (struct octep_device *oct);void octep_device_setup_cn93_pf (struct octep_device *oct); +void octep_device_setup_cnxk_pf (struct octep_device *oct);int octep_iq_process_completions (struct octep_iq *iq,u16 budget);int octep_oq_process_rx (struct octep_oq *oq,int budget);void octep_set_ethtool_ops (struct net_device *netdev);
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h new file +400 -0
400 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH 161/283 octeon_ep: disable per ring interrupts
In reply to Sasha LevinFrom: Vimlesh Kumar <[email protected]>
[ Upstream commit 73e6ffa37cebee152c07c5f2b8bc70fd2899ea6e ]
Disable the MSI-X per ring interrupt for every PF ring when PF netdev goes down.
--- .../ethernet/marvell/octeon_ep/octep_cn9k_pf.c | 18 +++++++++++++++--- .../ethernet/marvell/octeon_ep/octep_cnxk_pf.c | 18 +++++++++++++++--- .../marvell/octeon_ep/octep_regs_cn9k_pf.h | 1 + .../marvell/octeon_ep/octep_regs_cnxk_pf.h | 1 + 4 files changed, 32 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +15 -3
@@ -642,14 +642,26 @@ static void octep_enable_interrupts_cn93_pf(struct octep_device *oct)/* Disable all interrupts */ static void octep_disable_interrupts_cn93_pf (struct octep_device *oct) { -u64 intr_mask =0ULL ; +u64 reg_val, intr_mask =0ULL ;int srn, num_rings, i; srn =CFG_GET_PORTS_PF_SRN (oct->conf); num_rings =CFG_GET_PORTS_ACTIVE_IO_RINGS (oct->conf); -for (i =0 ; i < num_rings; i++) - intr_mask |= (0x1ULL << (srn + i)); +for (i =0 ; i < num_rings; i++) { + intr_mask |=BIT_ULL (srn + i); + reg_val =octep_read_csr64 (oct, +CN93_SDP_R_IN_INT_LEVELS (srn + i)); + reg_val &= ~CN93_INT_ENA_BIT ; +octep_write_csr64 (oct, +CN93_SDP_R_IN_INT_LEVELS (srn + i), reg_val); + + reg_val =octep_read_csr64 (oct, +CN93_SDP_R_OUT_INT_LEVELS (srn + i)); + reg_val &= ~CN93_INT_ENA_BIT ; +octep_write_csr64 (oct, +CN93_SDP_R_OUT_INT_LEVELS (srn + i), reg_val); + }octep_write_csr64 (oct,CN93_SDP_EPF_IRERR_RINT_ENA_W1C , intr_mask);octep_write_csr64 (oct,CN93_SDP_EPF_ORERR_RINT_ENA_W1C , intr_mask);
drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c +15 -3
@@ -683,14 +683,26 @@ static void octep_enable_interrupts_cnxk_pf(struct octep_device *oct)/* Disable all interrupts */ static void octep_disable_interrupts_cnxk_pf (struct octep_device *oct) { -u64 intr_mask =0ULL ; +u64 reg_val, intr_mask =0ULL ;int srn, num_rings, i; srn =CFG_GET_PORTS_PF_SRN (oct->conf); num_rings =CFG_GET_PORTS_ACTIVE_IO_RINGS (oct->conf); -for (i =0 ; i < num_rings; i++) - intr_mask |= (0x1ULL << (srn + i)); +for (i =0 ; i < num_rings; i++) { + intr_mask |=BIT_ULL (srn + i); + reg_val =octep_read_csr64 (oct, +CNXK_SDP_R_IN_INT_LEVELS (srn + i)); + reg_val &= ~CNXK_INT_ENA_BIT ; +octep_write_csr64 (oct, +CNXK_SDP_R_IN_INT_LEVELS (srn + i), reg_val); + + reg_val =octep_read_csr64 (oct, +CNXK_SDP_R_OUT_INT_LEVELS (srn + i)); + reg_val &= ~CNXK_INT_ENA_BIT ; +octep_write_csr64 (oct, +CNXK_SDP_R_OUT_INT_LEVELS (srn + i), reg_val); + }octep_write_csr64 (oct,CNXK_SDP_EPF_IRERR_RINT_ENA_W1C , intr_mask);octep_write_csr64 (oct,CNXK_SDP_EPF_ORERR_RINT_ENA_W1C , intr_mask);
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cn9k_pf.h +1 -0
@@ -373,5 +373,6 @@#define CN93_PEM_BAR4_INDEX 7#define CN93_PEM_BAR4_INDEX_SIZE 0x400000ULL#define CN93_PEM_BAR4_INDEX_OFFSET (CN93_PEM_BAR4_INDEX * CN93_PEM_BAR4_INDEX_SIZE) +#define CN93_INT_ENA_BIT BIT_ULL(62)#endif /* _OCTEP_REGS_CN9K_PF_H_ */
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h +1 -0
@@ -396,5 +396,6 @@#define CNXK_PEM_BAR4_INDEX 7#define CNXK_PEM_BAR4_INDEX_SIZE 0x400000ULL#define CNXK_PEM_BAR4_INDEX_OFFSET (CNXK_PEM_BAR4_INDEX * CNXK_PEM_BAR4_INDEX_SIZE) +#define CNXK_INT_ENA_BIT BIT_ULL(62)#endif /* _OCTEP_REGS_CNXK_PF_H_ */
Signature · 1 line
2.51.0
PATCH 162/283 octeon_ep: set backpressure watermark for RX queues
In reply to Sasha LevinFrom: Shinas Rasheed <[email protected]>
[ Upstream commit 15bc81212f593fbd7bda787598418b931842dc14 ]
Set backpressure watermark for hardware RX queues. Backpressure gets triggered when the available buffers of a hardware RX queue falls below the set watermark. This backpressure will propagate to packet processing pipeline in the OCTEON card, so that the host receives fewer packets and prevents packet dropping at host.
Stable-dep-of: ce8fe3fc4f99 ("octeon_ep: ensure dbell BADDR updation")
--- drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c | 7 +++++++ drivers/net/ethernet/marvell/octeon_ep/octep_config.h | 10 ++++++++++ .../ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h | 3 +++ 3 files changed, 20 insertions(+)
drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c +7 -0
@@ -258,6 +258,7 @@ static void octep_init_config_cnxk_pf(struct octep_device *oct) conf->oq.refill_threshold =OCTEP_OQ_REFILL_THRESHOLD ; conf->oq.oq_intr_pkt =OCTEP_OQ_INTR_PKT_THRESHOLD ; conf->oq.oq_intr_time =OCTEP_OQ_INTR_TIME_THRESHOLD ; + conf->oq.wmark =OCTEP_OQ_WMARK_MIN ; conf->msix_cfg.non_ioq_msix =CNXK_NUM_NON_IOQ_INTR ; conf->msix_cfg.ioq_msix = conf->pf_ring_cfg.active_io_rings;
@@ -378,6 +379,12 @@ static void octep_setup_oq_regs_cnxk_pf(struct octep_device *oct, int oq_no) reg_val = ((u64 )time_threshold <<32 ) |CFG_GET_OQ_INTR_PKT (oct->conf);octep_write_csr64 (oct,CNXK_SDP_R_OUT_INT_LEVELS (oq_no), reg_val); + +/* set watermark for backpressure */ + reg_val =octep_read_csr64 (oct,CNXK_SDP_R_OUT_WMARK (oq_no)); + reg_val &= ~0xFFFFFFFFULL ; + reg_val |=CFG_GET_OQ_WMARK (oct->conf); +octep_write_csr64 (oct,CNXK_SDP_R_OUT_WMARK (oq_no), reg_val); }/* Setup registers for a PF mailbox */
drivers/net/ethernet/marvell/octeon_ep/octep_config.h +10 -0
@@ -19,6 +19,9 @@/* Packet threshold for Tx queue interrupt */ #define OCTEP_IQ_INTR_THRESHOLD 0x0 +/* Minimum watermark for backpressure */ +#define OCTEP_OQ_WMARK_MIN 256 +/* Rx Queue: maximum descriptors per ring */ #define OCTEP_OQ_MAX_DESCRIPTORS 1024
@@ -68,6 +71,7 @@#define CFG_GET_OQ_REFILL_THRESHOLD (cfg) ((cfg)->oq.refill_threshold)#define CFG_GET_OQ_INTR_PKT (cfg) ((cfg)->oq.oq_intr_pkt)#define CFG_GET_OQ_INTR_TIME (cfg) ((cfg)->oq.oq_intr_time) +#define CFG_GET_OQ_WMARK (cfg) ((cfg)->oq.wmark)#define CFG_GET_PORTS_MAX_IO_RINGS (cfg) ((cfg)->pf_ring_cfg.max_io_rings)#define CFG_GET_PORTS_ACTIVE_IO_RINGS (cfg) ((cfg)->pf_ring_cfg.active_io_rings)
@@ -137,6 +141,12 @@ struct octep_oq_config {* default. The time is specified in microseconds. */ u32 oq_intr_time; + +/* Water mark for backpressure. +* Output queue sends backpressure signal to source when +* free buffer count falls below wmark. +*/ +u32 wmark; };/* Tx/Rx configuration */
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h +3 -0
@@ -143,6 +143,9 @@#define CNXK_SDP_R_OUT_SLIST_DBELL (ring) \ (CNXK_SDP_R_OUT_SLIST_DBELL_START + ((ring) * CNXK_RING_OFFSET)) +#define CNXK_SDP_R_OUT_WMARK (ring) \ + (CNXK_SDP_R_OUT_WMARK_START + ((ring) * CNXK_RING_OFFSET)) +#define CNXK_SDP_R_OUT_CNTS (ring) \ (CNXK_SDP_R_OUT_CNTS_START + ((ring) * CNXK_RING_OFFSET))
Signature · 1 line
2.51.0
PATCH 163/283 octeon_ep: ensure dbell BADDR updation
In reply to Sasha LevinFrom: Vimlesh Kumar <[email protected]>
[ Upstream commit ce8fe3fc4f99efd872120301c0f72f2e90ab9769 ]
Make sure the OUT DBELL base address reflects the
latest values written to it.
Fix:
Add a wait until the OUT DBELL base address register is updated with the DMA ring descriptor address, and modify the setup_oq function to properly handle failures.
--- .../marvell/octeon_ep/octep_cn9k_pf.c | 3 +- .../marvell/octeon_ep/octep_cnxk_pf.c | 46 +++++++++++++++---- .../ethernet/marvell/octeon_ep/octep_main.h | 2 +- .../net/ethernet/marvell/octeon_ep/octep_rx.c | 8 +++- 4 files changed, 48 insertions(+), 11 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +2 -1
@@ -302,7 +302,7 @@ static void octep_setup_iq_regs_cn93_pf(struct octep_device *oct, int iq_no) }/* Setup registers for a hardware Rx Queue */ -static void octep_setup_oq_regs_cn93_pf (struct octep_device *oct,int oq_no) +static int octep_setup_oq_regs_cn93_pf (struct octep_device *oct,int oq_no) {u64 reg_val;u64 oq_ctl =0ULL ;
@@ -350,6 +350,7 @@ static void octep_setup_oq_regs_cn93_pf(struct octep_device *oct, int oq_no) reg_val = ((u64 )time_threshold <<32 ) |CFG_GET_OQ_INTR_PKT (oct->conf);octep_write_csr64 (oct,CN93_SDP_R_OUT_INT_LEVELS (oq_no), reg_val); +return 0 ; }/* Setup registers for a PF mailbox */
drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c +38 -8
78 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_main.h +1 -1
@@ -67,7 +67,7 @@ struct octep_pci_win_regs {struct octep_hw_ops {void (*setup_iq_regs)(struct octep_device *oct,int q); -void (*setup_oq_regs)(struct octep_device *oct,int q); +int (*setup_oq_regs)(struct octep_device *oct,int q);void (*setup_mbox_regs)(struct octep_device *oct,int mbox);irqreturn_t (*oei_intr_handler)(void *ioq_vector);
drivers/net/ethernet/marvell/octeon_ep/octep_rx.c +7 -1
@@ -12,6 +12,8 @@#include "octep_config.h" #include "octep_main.h" +static void octep_oq_free_ring_buffers (struct octep_oq *oq); +static void octep_oq_reset_indices (struct octep_oq *oq) { oq->host_read_idx =0 ;
@@ -169,11 +171,15 @@ static int octep_setup_oq(struct octep_device *oct, int q_no) goto oq_fill_buff_err;octep_oq_reset_indices (oq); - oct->hw_ops.setup_oq_regs (oct, q_no); +if (oct->hw_ops.setup_oq_regs (oct, q_no)) + goto oq_setup_err; + oct->num_oqs++;return 0 ; +oq_setup_err: +octep_oq_free_ring_buffers (oq); oq_fill_buff_err:vfree (oq->buff_info); oq->buff_info =NULL ;
Signature · 1 line
2.51.0
PATCH 164/283 ionic: Rate limit unknown xcvr type messages
In reply to Sasha LevinFrom: Eric Joyner <[email protected]>
[ Upstream commit cdb1634de3bf197c0d86487d1fb84c128a79cc7c ]
Running ethtool repeatedly with a transceiver unknown to the driver or firmware will cause the driver to spam the kernel logs with "unknown xcvr type" messages which can distract from real issues; and this isn't interesting information outside of debugging. Fix this by rate limiting the output so that there are still notifications but not so many that they flood the log.
Using dev_dbg_once() would reduce the number of messages further, but this would miss the case where a different unknown transceiver type is plugged in, and its status is requested.
--- drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +4 -3
@@ -222,9 +222,10 @@ static int ionic_get_link_ksettings(struct net_device *netdev,/* This means there's no module plugged in */ break ;default : -dev_info (lif->ionic->dev,"unknown xcvr type pid=%d / 0x%x\n" , - idev->port_info->status.xcvr.pid, - idev->port_info->status.xcvr.pid); +dev_dbg_ratelimited (lif->ionic->dev, +"unknown xcvr type pid=%d / 0x%x\n" , + idev->port_info->status.xcvr.pid, + idev->port_info->status.xcvr.pid);break ; }
Signature · 1 line
2.51.0
PATCH 165/283 octeontx2-pf: Unregister devlink on probe failure
In reply to Sasha LevinFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 943f3b8bfbf297cf74392b50a7108ce1fe4cbd8c ]
When probe fails after devlink registration, the missing devlink unregister call causing a memory leak.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1 -0
@@ -3097,6 +3097,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ; err_pf_sriov_init: +otx2_unregister_dl (pf);otx2_shutdown_tc (pf); err_mcam_flow_del:otx2_mcam_flow_del (pf);
Signature · 1 line
2.51.0
PATCH 166/283 RDMA/rtrs: server: remove dead code
In reply to Sasha LevinFrom: Honggang LI <[email protected]>
[ Upstream commit a3572bdc3a028ca47f77d7166ac95b719cf77d50 ]
As rkey had been initialized to zero, the WARN_ON_ONCE should never been triggered. Remove it.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +1 -7
@@ -205,7 +205,6 @@ static int rdma_write_sg(struct rtrs_srv_op *id)size_t sg_cnt;int err, offset;bool need_inval; -u32 rkey =0 ;struct ib_reg_wr rwr;struct ib_sge *plist;struct ib_sge list;
@@ -237,11 +236,6 @@ static int rdma_write_sg(struct rtrs_srv_op *id) wr->wr.num_sge =1 ; wr->remote_addr =le64_to_cpu (id->rd_msg->desc[0 ].addr); wr->rkey =le32_to_cpu (id->rd_msg->desc[0 ].key); -if (rkey ==0 ) - rkey = wr->rkey; -else -/* Only one key is actually used */ -WARN_ON_ONCE (rkey != wr->rkey); wr->wr.opcode =IB_WR_RDMA_WRITE ; wr->wr.wr_cqe = &io_comp_cqe;
@@ -274,7 +268,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) inv_wr.opcode =IB_WR_SEND_WITH_INV ; inv_wr.wr_cqe = &io_comp_cqe; inv_wr.send_flags =0 ; - inv_wr.ex.invalidate_rkey = rkey; + inv_wr.ex.invalidate_rkey = wr->rkey; } imm_wr.wr.next =NULL ;
Signature · 1 line
2.51.0
PATCH 167/283 IB/cache: update gid cache on client reregister event
In reply to Sasha LevinFrom: Etienne AUJAMES <[email protected]>
[ Upstream commit ddd6c8c873e912cb1ead79def54de5e24ff71c80 ]
Some HCAs (e.g: ConnectX4) do not trigger a IB_EVENT_GID_CHANGE on subnet prefix update from SM (PortInfo).
Since the commit d58c23c92548 ("IB/core: Only update PKEY and GID caches on respective events"), the GID cache is updated exclusively on IB_EVENT_GID_CHANGE. If this event is not emitted, the subnet prefix in the IPoIB interface’s hardware address remains set to its default value (0xfe80000000000000).
Then rdma_bind_addr() failed because it relies on hardware address to find the port GID (subnet_prefix + port GUID).
This patch fixes this issue by updating the GID cache on IB_EVENT_CLIENT_REREGISTER event (emitted on PortInfo::ClientReregister=1).
--- drivers/infiniband/core/cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cache.c +2 -1
@@ -1566,7 +1566,8 @@ static void ib_cache_event_task(struct work_struct *_work)* the cache. */ ret =ib_cache_update (work->event.device, work->event.element.port_num, - work->event.event ==IB_EVENT_GID_CHANGE , + work->event.event ==IB_EVENT_GID_CHANGE || + work->event.event ==IB_EVENT_CLIENT_REREGISTER , work->event.event ==IB_EVENT_PKEY_CHANGE , work->enforce_security);
Signature · 1 line
2.51.0
PATCH 168/283 RDMA/hns: Fix WQ_MEM_RECLAIM warning
In reply to Sasha LevinFrom: Chengchang Tang <[email protected]>
[ Upstream commit c0a26bbd3f99b7b03f072e3409aff4e6ec8af6f6 ]
When sunrpc is used, if a reset triggered, our wq may lead the following trace:
workqueue: WQ_MEM_RECLAIM xprtiod:xprt_rdma_connect_worker [rpcrdma] is flushing !WQ_MEM_RECLAIM hns_roce_irq_workq:flush_work_handle [hns_roce_hw_v2]
WARNING: CPU: 0 PID: 8250 at kernel/workqueue.c:2644 check_flush_dependency+0xe0/0x144 Call trace: check_flush_dependency+0xe0/0x144 start_flush_work.constprop.0+0x1d0/0x2f0 __flush_work.isra.0+0x40/0xb0 flush_work+0x14/0x30 hns_roce_v2_destroy_qp+0xac/0x1e0 [hns_roce_hw_v2] ib_destroy_qp_user+0x9c/0x2b4 rdma_destroy_qp+0x34/0xb0 rpcrdma_ep_destroy+0x28/0xcc [rpcrdma] rpcrdma_ep_put+0x74/0xb4 [rpcrdma] rpcrdma_xprt_disconnect+0x1d8/0x260 [rpcrdma] xprt_rdma_connect_worker+0xc0/0x120 [rpcrdma] process_one_work+0x1cc/0x4d0 worker_thread+0x154/0x414 kthread+0x104/0x144 ret_from_fork+0x10/0x18
Since QP destruction frees memory, this wq should have the WQ_MEM_RECLAIM.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -1
@@ -6604,7 +6604,8 @@ static int hns_roce_v2_init_eq_table(struct hns_roce_dev *hr_dev)INIT_WORK (&hr_dev->ecc_work, fmea_ram_ecc_work); - hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" ,0 ); + hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" , +WQ_MEM_RECLAIM );if (!hr_dev->irq_workq) {dev_err (dev,"failed to create irq workqueue.\n" ); ret = -ENOMEM ;
Signature · 1 line
2.51.0
PATCH 169/283 RDMA/hns: Notify ULP of remaining soft-WCs during reset
In reply to Sasha LevinFrom: Chengchang Tang <[email protected]>
[ Upstream commit 0789f929900d85b80b343c5f04f8b9444e991384 ]
During a reset, software-generated WCs cannot be reported via interrupts. This may cause the ULP to miss some WCs.
To avoid this, add check in the CQ arm process: if a hardware reset has occurred and there are still unreported soft-WCs, notify the ULP to handle the remaining WCs, thereby preventing any loss of completions.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +23 -0
@@ -3588,6 +3588,23 @@ static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev, HNS_ROCE_V2_CQ_DEFAULT_INTERVAL); } +static bool left_sw_wc (struct hns_roce_dev *hr_dev,struct hns_roce_cq *hr_cq) +{ +struct hns_roce_qp *hr_qp; + +list_for_each_entry (hr_qp, &hr_cq->sq_list, sq_node) { +if (hr_qp->sq.head != hr_qp->sq.tail) +return true; + } + +list_for_each_entry (hr_qp, &hr_cq->rq_list, rq_node) { +if (hr_qp->rq.head != hr_qp->rq.tail) +return true; + } + +return false; +} +static int hns_roce_v2_req_notify_cq (struct ib_cq *ibcq,enum ib_cq_notify_flags flags) {
@@ -3596,6 +3613,12 @@ static int hns_roce_v2_req_notify_cq(struct ib_cq *ibcq,struct hns_roce_v2_db cq_db = {};u32 notify_flag; +if (hr_dev->state >=HNS_ROCE_DEVICE_STATE_RST_DOWN ) { +if ((flags &IB_CQ_REPORT_MISSED_EVENTS ) && +left_sw_wc (hr_dev, hr_cq)) +return 1 ; +return 0 ; + }/* * flags = 0, then notify_flag : next * flags = 1, then notify flag : solocited
Signature · 1 line
2.51.0
PATCH 170/283 power: supply: ab8500: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit c4af8a98bb52825a5331ae1d0604c0ea6956ba4b ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Commit 1c1f13a006ed ("power: supply: ab8500: Move to componentized binding") introduced this issue during a refactorization. Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/ab8500_charger.c | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/power/supply/ab8500_charger.c +20 -20
@@ -3456,26 +3456,6 @@ static int ab8500_charger_probe(struct platform_device *pdev)return ret; } -/* Request interrupts */ -for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { - irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name); -if (irq <0 ) -return irq; - - ret =devm_request_threaded_irq (dev, - irq,NULL , ab8500_charger_irq[i].isr, -IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , - ab8500_charger_irq[i].name, di); - -if (ret !=0 ) { -dev_err (dev,"failed to request %s IRQ %d: %d\n" - , ab8500_charger_irq[i].name, irq, ret); -return ret; - } -dev_dbg (dev,"Requested %s IRQ %d: %d\n" , - ab8500_charger_irq[i].name, irq, ret); - } -/* initialize lock */ spin_lock_init (&di->usb_state.usb_lock);mutex_init (&di->usb_ipt_crnt_lock);
@@ -3604,6 +3584,26 @@ static int ab8500_charger_probe(struct platform_device *pdev)return PTR_ERR (di->usb_chg.psy); } +/* Request interrupts */ +for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { + irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name); +if (irq <0 ) +return irq; + + ret =devm_request_threaded_irq (dev, + irq,NULL , ab8500_charger_irq[i].isr, +IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , + ab8500_charger_irq[i].name, di); + +if (ret !=0 ) { +dev_err (dev,"failed to request %s IRQ %d: %d\n" + , ab8500_charger_irq[i].name, irq, ret); +return ret; + } +dev_dbg (dev,"Requested %s IRQ %d: %d\n" , + ab8500_charger_irq[i].name, irq, ret); + } +/* * Check what battery we have, since we always have the USB * psy, use that as a handle.
Signature · 1 line
2.51.0
PATCH 171/283 power: supply: act8945a: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 3291c51d4684d048dd2eb91b5b65fcfdaf72141f ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/act8945a_charger.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/power/supply/act8945a_charger.c +8 -8
@@ -597,14 +597,6 @@ static int act8945a_charger_probe(struct platform_device *pdev)return irq ?: -ENXIO ; } - ret =devm_request_irq (&pdev->dev, irq, act8945a_status_changed, -IRQF_TRIGGER_FALLING ,"act8945a_interrupt" , - charger); -if (ret) { -dev_err (&pdev->dev,"failed to request nIRQ pin IRQ\n" ); -return ret; - } - charger->desc.name ="act8945a-charger" ; charger->desc.get_property = act8945a_charger_get_property; charger->desc.properties = act8945a_charger_props;
@@ -625,6 +617,14 @@ static int act8945a_charger_probe(struct platform_device *pdev)return PTR_ERR (charger->psy); } + ret =devm_request_irq (&pdev->dev, irq, act8945a_status_changed, +IRQF_TRIGGER_FALLING ,"act8945a_interrupt" , + charger); +if (ret) { +dev_err (&pdev->dev,"failed to request nIRQ pin IRQ\n" ); +return ret; + } +platform_set_drvdata (pdev, charger);INIT_WORK (&charger->work, act8945a_work);
Signature · 1 line
2.51.0
PATCH 172/283 power: supply: bq256xx: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 8005843369723d9c8975b7c4202d1b85d6125302 ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/bq256xx_charger.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/power/supply/bq256xx_charger.c +6 -6
@@ -1746,6 +1746,12 @@ static int bq256xx_probe(struct i2c_client *client)usb_register_notifier (bq->usb3_phy, &bq->usb_nb); } + ret =bq256xx_power_supply_init (bq, &psy_cfg, dev); +if (ret) { +dev_err (dev,"Failed to register power supply\n" ); +return ret; + } +if (client->irq) { ret = devm_request_threaded_irq(dev, client->irq, NULL, bq256xx_irq_handler_thread,
@@ -1758,12 +1764,6 @@ static int bq256xx_probe(struct i2c_client *client) } } - ret =bq256xx_power_supply_init (bq, &psy_cfg, dev); -if (ret) { -dev_err (dev,"Failed to register power supply\n" ); -return ret; - } - ret =bq256xx_hw_init (bq);if (ret) {dev_err (dev,"Cannot initialize the chip.\n" );
Signature · 1 line
2.51.0
PATCH 173/283 power: supply: bq25980: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 5f0b1cb41906e86b64bf69f5ededb83b0d757c27 ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/bq25980_charger.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/power/supply/bq25980_charger.c +6 -6
@@ -1241,6 +1241,12 @@ static int bq25980_probe(struct i2c_client *client)return ret; } + ret =bq25980_power_supply_init (bq, dev); +if (ret) { +dev_err (dev,"Failed to register power supply\n" ); +return ret; + } +if (client->irq) { ret = devm_request_threaded_irq(dev, client->irq, NULL, bq25980_irq_handler_thread,
@@ -1251,12 +1257,6 @@ static int bq25980_probe(struct i2c_client *client)return ret; } - ret =bq25980_power_supply_init (bq, dev); -if (ret) { -dev_err (dev,"Failed to register power supply\n" ); -return ret; - } - ret =bq25980_hw_init (bq);if (ret) {dev_err (dev,"Cannot initialize the chip.\n" );
Signature · 1 line
2.51.0
PATCH 174/283 power: supply: cpcap-battery: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 642f33e34b969eedec334738fd5df95d2dc42742 ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/cpcap-battery.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/power/supply/cpcap-battery.c +4 -4
@@ -1122,10 +1122,6 @@ static int cpcap_battery_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ddata); - error =cpcap_battery_init_interrupts (pdev, ddata); -if (error) -return error; - error =cpcap_battery_init_iio (ddata);if (error)return error;
@@ -1142,6 +1138,10 @@ static int cpcap_battery_probe(struct platform_device *pdev)return error; } + error =cpcap_battery_init_interrupts (pdev, ddata); +if (error) +return error; +atomic_set (&ddata->active,1 ); error =cpcap_battery_calibrate (ddata);
Signature · 1 line
2.51.0
PATCH 175/283 power: supply: goldfish: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit b2ce982e2e0c888dc55c888ad0e20ea04daf2e6b ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/goldfish_battery.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/power/supply/goldfish_battery.c +6 -6
@@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)if (data->irq <0 )return -ENODEV ; - ret =devm_request_irq (&pdev->dev, data->irq, - goldfish_battery_interrupt, -IRQF_SHARED , pdev->name, data); -if (ret) -return ret; - psy_cfg.drv_data = data; data->ac =power_supply_register (&pdev->dev, &ac_desc, &psy_cfg);
@@ -245,6 +239,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)platform_set_drvdata (pdev, data); + ret =devm_request_irq (&pdev->dev, data->irq, + goldfish_battery_interrupt, +IRQF_SHARED , pdev->name, data); +if (ret) +return ret; +GOLDFISH_BATTERY_WRITE (data,BATTERY_INT_ENABLE ,BATTERY_INT_MASK );return 0 ; }
Signature · 1 line
2.51.0
PATCH 176/283 power: supply: rt9455: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit e2febe375e5ea5afed92f4cd9711bde8f24ee6d2 ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.
--- drivers/power/supply/rt9455_charger.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/power/supply/rt9455_charger.c +9 -8
@@ -1663,6 +1663,15 @@ static int rt9455_probe(struct i2c_client *client) rt9455_charger_config.supplied_to = rt9455_charger_supplied_to; rt9455_charger_config.num_supplicants =ARRAY_SIZE (rt9455_charger_supplied_to); + + info->charger =devm_power_supply_register (dev, &rt9455_charger_desc, + &rt9455_charger_config); +if (IS_ERR (info->charger)) { +dev_err (dev,"Failed to register charger\n" ); + ret =PTR_ERR (info->charger); + goto put_usb_notifier; + } + ret = devm_request_threaded_irq(dev, client->irq, NULL, rt9455_irq_handler_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
@@ -1678,14 +1687,6 @@ static int rt9455_probe(struct i2c_client *client) goto put_usb_notifier; } - info->charger =devm_power_supply_register (dev, &rt9455_charger_desc, - &rt9455_charger_config); -if (IS_ERR (info->charger)) { -dev_err (dev,"Failed to register charger\n" ); - ret =PTR_ERR (info->charger); - goto put_usb_notifier; - } -return 0 ; put_usb_notifier:
Signature · 1 line
2.51.0
PATCH 177/283 power: supply: sbs-battery: Fix use-after-free in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 8d59cf3887fbabacef53bfba473e33e8a8d9d07b ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...
Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle. Keep the old behavior of just printing a warning in case of any failures during the IRQ request and finishing the probe successfully.
--- drivers/power/supply/sbs-battery.c | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/power/supply/sbs-battery.c +18 -18
@@ -1173,24 +1173,6 @@ static int sbs_probe(struct i2c_client *client)i2c_set_clientdata (client, chip); -if (!chip->gpio_detect) - goto skip_gpio; - - irq =gpiod_to_irq (chip->gpio_detect); -if (irq <=0 ) { -dev_warn (&client->dev,"Failed to get gpio as irq: %d\n" , irq); - goto skip_gpio; - } - - rc =devm_request_threaded_irq (&client->dev, irq,NULL , sbs_irq, -IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING |IRQF_ONESHOT , -dev_name (&client->dev), chip); -if (rc) { -dev_warn (&client->dev,"Failed to request irq: %d\n" , rc); - goto skip_gpio; - } - -skip_gpio:/* * Before we register, we might need to make sure we can actually talk * to the battery.
@@ -1216,6 +1198,24 @@ static int sbs_probe(struct i2c_client *client)return dev_err_probe (&client->dev,PTR_ERR (chip->power_supply),"Failed to register power supply\n" ); +if (!chip->gpio_detect) + goto out; + + irq =gpiod_to_irq (chip->gpio_detect); +if (irq <=0 ) { +dev_warn (&client->dev,"Failed to get gpio as irq: %d\n" , irq); + goto out; + } + + rc =devm_request_threaded_irq (&client->dev, irq,NULL , sbs_irq, +IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING |IRQF_ONESHOT , +dev_name (&client->dev), chip); +if (rc) { +dev_warn (&client->dev,"Failed to request irq: %d\n" , rc); + goto out; + } + +out:dev_info (&client->dev,"%s: battery gas gauge device registered\n" , client->name);
Signature · 1 line
2.51.0
PATCH 178/283 power: reset: nvmem-reboot-mode: respect cell size for nvmem_cell_write
In reply to Sasha LevinFrom: Alexander Koskovich <[email protected]>
[ Upstream commit 36b05629226413836cfbb3fbe6689cd188bca156 ]
Some platforms expose reboot mode cells that are smaller than an unsigned int, in which cases lead to write failures. Read the cell first to determine actual size and only write the number of bytes the cell can hold.
--- drivers/power/reset/nvmem-reboot-mode.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/power/reset/nvmem-reboot-mode.c +13 -2
@@ -10,6 +10,7 @@#include <linux/nvmem-consumer.h> #include <linux/platform_device.h> #include <linux/reboot-mode.h> +#include <linux/slab.h> struct nvmem_reboot_mode {struct reboot_mode_driver reboot;
@@ -19,12 +20,22 @@ struct nvmem_reboot_mode {static int nvmem_reboot_mode_write (struct reboot_mode_driver *reboot,unsigned int magic) { -int ret;struct nvmem_reboot_mode *nvmem_rbm; +size_t buf_len; +void *buf; +int ret; nvmem_rbm = container_of(reboot, struct nvmem_reboot_mode, reboot); - ret =nvmem_cell_write (nvmem_rbm->cell, &magic,sizeof (magic)); + buf =nvmem_cell_read (nvmem_rbm->cell, &buf_len); +if (IS_ERR (buf)) +return PTR_ERR (buf); +kfree (buf); + +if (buf_len >sizeof (magic)) +return -EINVAL ; + + ret =nvmem_cell_write (nvmem_rbm->cell, &magic, buf_len);if (ret <0 )dev_err (reboot->dev,"update reboot mode bits failed\n" );
Signature · 1 line
2.51.0
PATCH 179/283 power: supply: bq27xxx: fix wrong errno when bus ops are unsupported
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit 688364a11647dc09ba1e4429313e0008066ec790 ]
bq27xxx_write(), bq27xxx_read_block(), and bq27xxx_write_block() return -EPERM when the bus callback pointer is NULL. A NULL callback indicates the operation is not supported by the bus/driver, not that permission is denied.
Return -EOPNOTSUPP instead of -EPERM when di->bus.write/ read_bulk/write_bulk is NULL.
--- drivers/power/supply/bq27xxx_battery.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/power/supply/bq27xxx_battery.c +3 -3
@@ -1162,7 +1162,7 @@ static inline int bq27xxx_write(struct bq27xxx_device_info *di, int reg_index,return -EINVAL ;if (!di->bus.write) -return -EPERM ; +return -EOPNOTSUPP ; ret = di->bus.write (di, di->regs[reg_index], value, single);if (ret <0 )
@@ -1181,7 +1181,7 @@ static inline int bq27xxx_read_block(struct bq27xxx_device_info *di, int reg_indreturn -EINVAL ;if (!di->bus.read_bulk) -return -EPERM ; +return -EOPNOTSUPP ; ret = di->bus.read_bulk (di, di->regs[reg_index], data, len);if (ret <0 )
@@ -1200,7 +1200,7 @@ static inline int bq27xxx_write_block(struct bq27xxx_device_info *di, int reg_inreturn -EINVAL ;if (!di->bus.write_bulk) -return -EPERM ; +return -EOPNOTSUPP ; ret = di->bus.write_bulk (di, di->regs[reg_index], data, len);if (ret <0 )
Signature · 1 line
2.51.0
PATCH 180/283 power: supply: wm97xx: Fix NULL pointer dereference in power_supply_changed()
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 39fe0eac6d755ef215026518985fcf8de9360e9e ]
In probe(), request_irq() is called before allocating/registering a power_supply handle. If an interrupt is fired between the call to request_irq() and power_supply_register(), the power_supply handle will be used uninitialized in power_supply_changed() in wm97xx_bat_update() (triggered from the interrupt handler). This will lead to a NULL pointer dereference since
Fix this racy NULL pointer dereference by making sure the IRQ is requested _after_ the registration of the power_supply handle. Since the IRQ is the last thing requests in the probe() now, remove the error path for freeing it. Instead add one for unregistering the power_supply handle when IRQ request fails.
--- drivers/power/supply/wm97xx_battery.c | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/power/supply/wm97xx_battery.c +19 -15
@@ -178,12 +178,6 @@ static int wm97xx_bat_probe(struct platform_device *dev) "failed to get charge GPIO\n");if (charge_gpiod) {gpiod_set_consumer_name (charge_gpiod,"BATT CHRG" ); - ret =request_irq (gpiod_to_irq (charge_gpiod), - wm97xx_chrg_irq,0 , -"AC Detect" , dev); -if (ret) -return dev_err_probe (&dev->dev, ret, -"failed to request GPIO irq\n" ); props++;/* POWER_SUPPLY_PROP_STATUS */ }
@@ -199,10 +193,8 @@ static int wm97xx_bat_probe(struct platform_device *dev) props++;/* POWER_SUPPLY_PROP_VOLTAGE_MIN */ prop =kcalloc (props,sizeof (*prop),GFP_KERNEL ); -if (!prop) { - ret = -ENOMEM ; - goto err3; - } +if (!prop) +return -ENOMEM ; prop[i++] =POWER_SUPPLY_PROP_PRESENT ;if (charge_gpiod)
@@ -236,15 +228,27 @@ static int wm97xx_bat_probe(struct platform_device *dev)schedule_work (&bat_work); }else { ret =PTR_ERR (bat_psy); - goto err4; + goto free; + } + +if (charge_gpiod) { + ret =request_irq (gpiod_to_irq (charge_gpiod), wm97xx_chrg_irq, +0 ,"AC Detect" , dev); +if (ret) { +dev_err_probe (&dev->dev, ret, +"failed to request GPIO irq\n" ); + goto unregister; + } }return 0 ; -err4: + +unregister: +power_supply_unregister (bat_psy); + +free:kfree (prop); -err3: -if (charge_gpiod) -free_irq (gpiod_to_irq (charge_gpiod), dev); +return ret; }
Signature · 1 line
2.51.0
PATCH 181/283 RDMA/rtrs-srv: fix SG mapping
In reply to Sasha LevinFrom: Roman Penyaev <[email protected]>
[ Upstream commit 83835f7c07b523c7ca2a5ad0a511670b5810539e ]
This fixes the following error on the server side:
RTRS server session allocation failed: -EINVAL
caused by the caller of the ib_dma_map_sg(), which does not expect less mapped entries, than requested, which is in the order of things and can be easily reproduced on the machine with enabled IOMMU.
The fix is to treat any positive number of mapped sg entries as a successful mapping and cache DMA addresses by traversing modified SG table.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +20 -5
@@ -592,7 +592,7 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) srv_path->mrs_num++) {struct rtrs_srv_mr *srv_mr = &srv_path->mrs[srv_path->mrs_num];struct scatterlist *s; -int nr, nr_sgt, chunks; +int nr, nr_sgt, chunks, ind; sgt = &srv_mr->sgt; chunks = chunks_per_mr * srv_path->mrs_num;
@@ -622,7 +622,7 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) } nr =ib_map_mr_sg (mr, sgt->sgl, nr_sgt,NULL , max_chunk_size); -if (nr != nr_sgt) { +if (nr < nr_sgt) { err = nr <0 ? nr : -EINVAL ; goto dereg_mr; }
@@ -638,9 +638,24 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) goto dereg_mr; } } -/* Eventually dma addr for each chunk can be cached */ -for_each_sg (sgt->sgl, s, nr_sgt, i) - srv_path->dma_addr[chunks + i] =sg_dma_address (s); + +/* +* Cache DMA addresses by traversing sg entries. If +* regions were merged, an inner loop is required to +* populate the DMA address array by traversing larger +* regions. +*/ + ind = chunks; +for_each_sg (sgt->sgl, s, nr_sgt, i) { +unsigned int dma_len =sg_dma_len (s); +u64 dma_addr =sg_dma_address (s); +u64 dma_addr_end = dma_addr + dma_len; + +do { + srv_path->dma_addr[ind++] = dma_addr; + dma_addr += max_chunk_size; + }while (dma_addr < dma_addr_end); + }ib_update_fast_reg_key (mr,ib_inc_rkey (mr->rkey)); srv_mr->mr = mr;
Signature · 1 line
2.51.0
PATCH 182/283 RDMA/rxe: Fix double free in rxe_srq_from_init
In reply to Sasha LevinFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 0beefd0e15d962f497aad750b2d5e9c3570b66d1 ]
In rxe_srq_from_init(), the queue pointer 'q' is assigned to 'srq->rq.queue' before copying the SRQ number to user space. If copy_to_user() fails, the function calls rxe_queue_cleanup() to free the queue, but leaves the now-invalid pointer in 'srq->rq.queue'.
The caller of rxe_srq_from_init() (rxe_create_srq) eventually calls rxe_srq_cleanup() upon receiving the error, which triggers a second rxe_queue_cleanup() on the same memory, leading to a double free.
The call trace looks like this:
kmem_cache_free+0x.../0x... rxe_queue_cleanup+0x1a/0x30 [rdma_rxe] rxe_srq_cleanup+0x42/0x60 [rdma_rxe] rxe_elem_release+0x31/0x70 [rdma_rxe] rxe_create_srq+0x12b/0x1a0 [rdma_rxe] ib_create_srq_user+0x9a/0x150 [ib_core]
Fix this by moving 'srq->rq.queue = q' after copy_to_user.
--- drivers/infiniband/sw/rxe/rxe_srq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_srq.c +3 -3
@@ -77,9 +77,6 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq, goto err_free; } - srq->rq.queue = q; - init->attr.max_wr = srq->rq.max_wr; -if (uresp) {if (copy_to_user (&uresp->srq_num, &srq->srq_num,sizeof (uresp->srq_num))) {
@@ -88,6 +85,9 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq, } } + srq->rq.queue = q; + init->attr.max_wr = srq->rq.max_wr; +return 0 ; err_free:
Signature · 1 line
2.51.0
PATCH 183/283 tools/power/x86/intel-speed-select: Fix file descriptor leak in isolate_cpus()
In reply to Sasha LevinFrom: Malaya Kumar Rout <[email protected]>
[ Upstream commit 56c17ee151c6e1a73d77e15b82a8e2130cd8dd16 ]
The file descriptor opened in isolate_cpus() when (!level) is true was not being closed before returning, causing a file descriptor leak in both the error path and the success path.
When write() fails at line 950, the function returns at line 953 without closing the file descriptor. Similarly, on success, the function returns at line 956 without closing the file descriptor.
Add close(fd) calls before both return statements to fix the resource leak. This follows the same pattern used elsewhere in the same function where file descriptors are properly closed before returning (see lines 1005 and 1027).
--- tools/power/x86/intel-speed-select/isst-config.c | 2 ++ 1 file changed, 2 insertions(+)
tools/power/x86/intel-speed-select/isst-config.c +2 -0
@@ -936,9 +936,11 @@ int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int lev ret =write (fd,"member" ,strlen ("member" ));if (ret ==-1 ) {printf ("Can't update to member\n" ); +close (fd);return ret; } +close (fd);return 0 ; }
Signature · 1 line
2.51.0
PATCH 184/283 mtd: rawnand: cadence: Fix return type of CDMA send-and-wait helper
In reply to Sasha LevinFrom: Alok Tiwari <[email protected]>
[ Upstream commit 6d8226cbbf124bb5613b532216b74c886a4361b7 ]
cadence_nand_cdma_send_and_wait() propagates negative errno values from cadence_nand_cdma_send(), returns -ETIMEDOUT on failure and -EIO when the CDMA engine reports a command failure.
However, it is declared as u32, causing error codes to wrap. Change the return type to int to correctly propagate errors.
--- drivers/mtd/nand/raw/cadence-nand-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/cadence-nand-controller.c +1 -1
@@ -1018,7 +1018,7 @@ static int cadence_nand_cdma_send(struct cdns_nand_ctrl *cdns_ctrl, }/* Send SDMA command and wait for finish. */ -static u32 +static int cadence_nand_cdma_send_and_wait (struct cdns_nand_ctrl *cdns_ctrl,u8 thread) {
Signature · 1 line
2.51.0
PATCH 185/283 crypto: ccp - Add an S4 restore flow
In reply to Sasha LevinFrom: "Mario Limonciello (AMD)" <[email protected]>
[ Upstream commit 0ba2035026d0ab6c7c7e65ad8b418dc73d5700d9 ]
The system will have lost power during S4. The ring used for TEE communications needs to be initialized before use.
--- drivers/crypto/ccp/psp-dev.c | 11 +++++++++++ drivers/crypto/ccp/sp-dev.c | 12 ++++++++++++ drivers/crypto/ccp/sp-dev.h | 3 +++ drivers/crypto/ccp/sp-pci.c | 16 +++++++++++++++- drivers/crypto/ccp/tee-dev.c | 5 +++++ drivers/crypto/ccp/tee-dev.h | 1 + 6 files changed, 47 insertions(+), 1 deletion(-)
drivers/crypto/ccp/psp-dev.c +11 -0
@@ -253,6 +253,17 @@ struct psp_device *psp_get_master_device(void)return sp ? sp->psp_data :NULL ; } +int psp_restore (struct sp_device *sp) +{ +struct psp_device *psp = sp->psp_data; +int ret =0 ; + +if (psp->tee_data) + ret =tee_restore (psp); + +return ret; +} +void psp_pci_init (void ) { psp_master =psp_get_master_device ();
drivers/crypto/ccp/sp-dev.c +12 -0
@@ -229,6 +229,18 @@ int sp_resume(struct sp_device *sp)return 0 ; } +int sp_restore (struct sp_device *sp) +{ +if (sp->psp_data) { +int ret =psp_restore (sp); + +if (ret) +return ret; + } + +return sp_resume (sp); +} +struct sp_device *sp_get_psp_master_device (void ) {struct sp_device *i, *ret =NULL ;
drivers/crypto/ccp/sp-dev.h +3 -0
@@ -138,6 +138,7 @@ struct sp_device *sp_get_master(void);int sp_suspend (struct sp_device *sp);int sp_resume (struct sp_device *sp); +int sp_restore (struct sp_device *sp);int sp_request_ccp_irq (struct sp_device *sp,irq_handler_t handler,const char *name,void *data);void sp_free_ccp_irq (struct sp_device *sp,void *data);
@@ -171,6 +172,7 @@ int psp_dev_init(struct sp_device *sp);void psp_pci_init (void );void psp_dev_destroy (struct sp_device *sp);void psp_pci_exit (void ); +int psp_restore (struct sp_device *sp);#else /* !CONFIG_CRYPTO_DEV_SP_PSP */
@@ -178,6 +180,7 @@ static inline int psp_dev_init(struct sp_device *sp) { return 0; }static inline void psp_pci_init (void ) { }static inline void psp_dev_destroy (struct sp_device *sp) { }static inline void psp_pci_exit (void ) { } +static inline int psp_restore (struct sp_device *sp) {return 0 ; }#endif /* CONFIG_CRYPTO_DEV_SP_PSP */
drivers/crypto/ccp/sp-pci.c +15 -1
@@ -407,6 +407,13 @@ static int __maybe_unused sp_pci_resume(struct device *dev)return sp_resume (sp); } +static int __maybe_unused sp_pci_restore (struct device *dev) +{ +struct sp_device *sp =dev_get_drvdata (dev); + +return sp_restore (sp); +} +#ifdef CONFIG_CRYPTO_DEV_SP_PSP static const struct sev_vdata sevv1 = { .cmdresp_reg = 0x10580, /* C2PMSG_32 */
@@ -585,7 +592,14 @@ static const struct pci_device_id sp_pci_table[] = { };MODULE_DEVICE_TABLE (pci, sp_pci_table); -static SIMPLE_DEV_PM_OPS(sp_pci_pm_ops, sp_pci_suspend, sp_pci_resume); +static const struct dev_pm_ops sp_pci_pm_ops = { + .suspend =pm_sleep_ptr (sp_pci_suspend), + .resume =pm_sleep_ptr (sp_pci_resume), + .freeze =pm_sleep_ptr (sp_pci_suspend), + .thaw =pm_sleep_ptr (sp_pci_resume), + .poweroff =pm_sleep_ptr (sp_pci_suspend), + .restore_early =pm_sleep_ptr (sp_pci_restore), +};static struct pci_driver sp_pci_driver = { .name ="ccp" ,
drivers/crypto/ccp/tee-dev.c +5 -0
@@ -395,3 +395,8 @@ int psp_check_tee_status(void)return 0 ; }EXPORT_SYMBOL (psp_check_tee_status); + +int tee_restore (struct psp_device *psp) +{ +return tee_init_ring (psp->tee_data); +}
drivers/crypto/ccp/tee-dev.h +1 -0
@@ -122,5 +122,6 @@ struct tee_ring_cmd {int tee_dev_init (struct psp_device *psp);void tee_dev_destroy (struct psp_device *psp); +int tee_restore (struct psp_device *psp);#endif /* __TEE_DEV_H__ */
Signature · 1 line
2.51.0
PATCH 186/283 crypto: ccp - Move direct access to some PSP registers out of TEE
In reply to Sasha LevinFrom: Tom Lendacky <[email protected]>
[ Upstream commit 949a0c8dd3c257730ef7205be759e4bc6cf49cea ]
With the PSP mailbox registers supporting more than just TEE, access to them must be maintained and serialized by the PSP device support. Remove TEE support direct access and create an interface in the PSP support where the register access can be controlled/serialized.
Stable-dep-of: 7b85137caf11 ("crypto: ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails")
--- drivers/crypto/ccp/psp-dev.c | 60 ++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/psp-dev.h | 18 +++++++++++ drivers/crypto/ccp/sp-dev.h | 3 ++ drivers/crypto/ccp/sp-pci.c | 18 +++++++---- drivers/crypto/ccp/tee-dev.c | 48 ++++++----------------------- drivers/crypto/ccp/tee-dev.h | 15 ++------- 6 files changed, 104 insertions(+), 58 deletions(-)
drivers/crypto/ccp/psp-dev.c +60 -0
@@ -9,6 +9,9 @@#include <linux/kernel.h> #include <linux/irqreturn.h> +#include <linux/mutex.h> +#include <linux/bitfield.h> +#include <linux/delay.h> #include "sp-dev.h" #include "psp-dev.h"
@@ -19,6 +22,62 @@struct psp_device *psp_master; +#define PSP_C2PMSG_17_CMDRESP_CMD GENMASK(19, 16) + +static int psp_mailbox_poll (const void __iomem *cmdresp_reg,unsigned int *cmdresp, +unsigned int timeout_msecs) +{ +while (true) { + *cmdresp =ioread32 (cmdresp_reg); +if (FIELD_GET (PSP_CMDRESP_RESP , *cmdresp)) +return 0 ; + +if (!timeout_msecs--) +break ; + +usleep_range (1000 ,1100 ); + } + +return -ETIMEDOUT ; +} + +int psp_mailbox_command (struct psp_device *psp,enum psp_cmd cmd,void *cmdbuff, +unsigned int timeout_msecs,unsigned int *cmdresp) +{ +void __iomem *cmdresp_reg, *cmdbuff_lo_reg, *cmdbuff_hi_reg; +int ret; + +if (!psp || !psp->vdata || !psp->vdata->cmdresp_reg || + !psp->vdata->cmdbuff_addr_lo_reg || !psp->vdata->cmdbuff_addr_hi_reg) +return -ENODEV ; + + cmdresp_reg = psp->io_regs + psp->vdata->cmdresp_reg; + cmdbuff_lo_reg = psp->io_regs + psp->vdata->cmdbuff_addr_lo_reg; + cmdbuff_hi_reg = psp->io_regs + psp->vdata->cmdbuff_addr_hi_reg; + +mutex_lock (&psp->mailbox_mutex); + +/* Ensure mailbox is ready for a command */ + ret = -EBUSY ; +if (psp_mailbox_poll (cmdresp_reg, cmdresp,0 )) + goto unlock; + +if (cmdbuff) { +iowrite32 (lower_32_bits (__psp_pa (cmdbuff)), cmdbuff_lo_reg); +iowrite32 (upper_32_bits (__psp_pa (cmdbuff)), cmdbuff_hi_reg); + } + + *cmdresp =FIELD_PREP (PSP_C2PMSG_17_CMDRESP_CMD , cmd); +iowrite32 (*cmdresp, cmdresp_reg); + + ret =psp_mailbox_poll (cmdresp_reg, cmdresp, timeout_msecs); + +unlock: +mutex_unlock (&psp->mailbox_mutex); + +return ret; +} +static struct psp_device *psp_alloc_struct (struct sp_device *sp) {struct device *dev = sp->dev;
@@ -164,6 +223,7 @@ int psp_dev_init(struct sp_device *sp) } psp->io_regs = sp->io_map; +mutex_init (&psp->mailbox_mutex); ret =psp_get_capability (psp);if (ret)
drivers/crypto/ccp/psp-dev.h +18 -0
@@ -14,6 +14,8 @@#include <linux/list.h> #include <linux/bits.h> #include <linux/interrupt.h> +#include <linux/mutex.h> +#include <linux/psp.h> #include "sp-dev.h"
@@ -33,6 +35,7 @@ struct psp_device {struct sp_device *sp;void __iomem *io_regs; +struct mutex mailbox_mutex;psp_irq_handler_t sev_irq_handler;void *sev_irq_data;
@@ -71,4 +74,19 @@ struct psp_device *psp_get_master_device(void);#define PSP_SECURITY_HSP_TPM_AVAILABLE BIT(10)#define PSP_SECURITY_ROM_ARMOR_ENFORCED BIT(11) +/** +* enum psp_cmd - PSP mailbox commands +* @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer +* @PSP_CMD_TEE_RING_DESTROY: Destroy TEE ring buffer +* @PSP_CMD_MAX: Maximum command id +*/ +enum psp_cmd { +PSP_CMD_TEE_RING_INIT =1 , +PSP_CMD_TEE_RING_DESTROY =2 , +PSP_CMD_MAX =15 , +}; + +int psp_mailbox_command (struct psp_device *psp,enum psp_cmd cmd,void *cmdbuff, +unsigned int timeout_msecs,unsigned int *cmdresp); +#endif /* __PSP_DEV_H */
drivers/crypto/ccp/sp-dev.h +3 -0
@@ -71,6 +71,9 @@ struct psp_vdata {const struct sev_vdata *sev;const struct tee_vdata *tee;const struct platform_access_vdata *platform_access; +const unsigned int cmdresp_reg; +const unsigned int cmdbuff_addr_lo_reg; +const unsigned int cmdbuff_addr_hi_reg;const unsigned int feature_reg;const unsigned int inten_reg;const unsigned int intsts_reg;
drivers/crypto/ccp/sp-pci.c +12 -6
@@ -428,18 +428,12 @@ static const struct sev_vdata sevv2 = { };static const struct tee_vdata teev1 = { - .cmdresp_reg =0x10544 ,/* C2PMSG_17 */ - .cmdbuff_addr_lo_reg =0x10548 ,/* C2PMSG_18 */ - .cmdbuff_addr_hi_reg =0x1054c ,/* C2PMSG_19 */ .ring_wptr_reg =0x10550 ,/* C2PMSG_20 */ .ring_rptr_reg =0x10554 ,/* C2PMSG_21 */ .info_reg =0x109e8 ,/* C2PMSG_58 */ };static const struct tee_vdata teev2 = { - .cmdresp_reg =0x10944 ,/* C2PMSG_17 */ - .cmdbuff_addr_lo_reg =0x10948 ,/* C2PMSG_18 */ - .cmdbuff_addr_hi_reg =0x1094c ,/* C2PMSG_19 */ .ring_wptr_reg =0x10950 ,/* C2PMSG_20 */ .ring_rptr_reg =0x10954 ,/* C2PMSG_21 */ };
@@ -476,6 +470,9 @@ static const struct psp_vdata pspv2 = {static const struct psp_vdata pspv3 = { .tee = &teev1, .platform_access = &pa_v1, + .cmdresp_reg =0x10544 ,/* C2PMSG_17 */ + .cmdbuff_addr_lo_reg =0x10548 ,/* C2PMSG_18 */ + .cmdbuff_addr_hi_reg =0x1054c ,/* C2PMSG_19 */ .bootloader_info_reg =0x109ec ,/* C2PMSG_59 */ .feature_reg =0x109fc ,/* C2PMSG_63 */ .inten_reg =0x10690 ,/* P2CMSG_INTEN */
@@ -486,6 +483,9 @@ static const struct psp_vdata pspv3 = {static const struct psp_vdata pspv4 = { .sev = &sevv2, .tee = &teev1, + .cmdresp_reg =0x10544 ,/* C2PMSG_17 */ + .cmdbuff_addr_lo_reg =0x10548 ,/* C2PMSG_18 */ + .cmdbuff_addr_hi_reg =0x1054c ,/* C2PMSG_19 */ .bootloader_info_reg =0x109ec ,/* C2PMSG_59 */ .feature_reg =0x109fc ,/* C2PMSG_63 */ .inten_reg =0x10690 ,/* P2CMSG_INTEN */
@@ -495,6 +495,9 @@ static const struct psp_vdata pspv4 = {static const struct psp_vdata pspv5 = { .tee = &teev2, .platform_access = &pa_v2, + .cmdresp_reg =0x10944 ,/* C2PMSG_17 */ + .cmdbuff_addr_lo_reg =0x10948 ,/* C2PMSG_18 */ + .cmdbuff_addr_hi_reg =0x1094c ,/* C2PMSG_19 */ .feature_reg =0x109fc ,/* C2PMSG_63 */ .inten_reg =0x10510 ,/* P2CMSG_INTEN */ .intsts_reg =0x10514 ,/* P2CMSG_INTSTS */
@@ -503,6 +506,9 @@ static const struct psp_vdata pspv5 = {static const struct psp_vdata pspv6 = { .sev = &sevv2, .tee = &teev2, + .cmdresp_reg =0x10944 ,/* C2PMSG_17 */ + .cmdbuff_addr_lo_reg =0x10948 ,/* C2PMSG_18 */ + .cmdbuff_addr_hi_reg =0x1094c ,/* C2PMSG_19 */ .feature_reg =0x109fc ,/* C2PMSG_63 */ .inten_reg =0x10510 ,/* P2CMSG_INTEN */ .intsts_reg =0x10514 ,/* P2CMSG_INTSTS */
drivers/crypto/ccp/tee-dev.c +9 -39
84 lines not on this page · raw message
drivers/crypto/ccp/tee-dev.h +2 -13
@@ -17,21 +17,10 @@#include <linux/device.h> #include <linux/mutex.h> -#define TEE_DEFAULT_TIMEOUT 10 +#define TEE_DEFAULT_CMD_TIMEOUT (10 * MSEC_PER_SEC) +#define TEE_DEFAULT_RING_TIMEOUT 10#define MAX_BUFFER_SIZE 988 -/** -* enum tee_ring_cmd_id - TEE interface commands for ring buffer configuration -* @TEE_RING_INIT_CMD: Initialize ring buffer -* @TEE_RING_DESTROY_CMD: Destroy ring buffer -* @TEE_RING_MAX_CMD: Maximum command id -*/ -enum tee_ring_cmd_id { -TEE_RING_INIT_CMD =0x00010000 , -TEE_RING_DESTROY_CMD =0x00020000 , -TEE_RING_MAX_CMD =0x000F0000 , -}; -/** * struct tee_init_ring_cmd - Command to init TEE ring buffer * @low_addr: bits [31:0] of the physical address of ring buffer
Signature · 1 line
2.51.0
PATCH 187/283 crypto: ccp - Factor out ring destroy handling to a helper
In reply to Sasha LevinFrom: "Mario Limonciello (AMD)" <[email protected]>
[ Upstream commit d95f87a65bce5f2f2a02ca6094ca4841d4073df3 ]
The ring destroy command needs to be used in multiple places. Split out the code to a helper.
Stable-dep-of: 7b85137caf11 ("crypto: ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails")
--- drivers/crypto/ccp/tee-dev.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-)
drivers/crypto/ccp/tee-dev.c +24 -12
@@ -86,6 +86,29 @@ static inline void tee_free_cmd_buffer(struct tee_init_ring_cmd *cmd)kfree (cmd); } +static bool tee_send_destroy_cmd (struct psp_tee_device *tee) +{ +unsigned int reg; +int ret; + + ret =psp_mailbox_command (tee->psp,PSP_CMD_TEE_RING_DESTROY ,NULL , +TEE_DEFAULT_CMD_TIMEOUT , ®); +if (ret) { +dev_err (tee->dev,"tee: ring destroy command timed out, disabling TEE support\n" ); + psp_dead = true; +return false; + } + +if (FIELD_GET (PSP_CMDRESP_STS , reg)) { +dev_err (tee->dev,"tee: ring destroy command failed (%#010lx)\n" , +FIELD_GET (PSP_CMDRESP_STS , reg)); + psp_dead = true; +return false; + } + +return true; +} +static int tee_init_ring (struct psp_tee_device *tee) {int ring_size =MAX_RING_BUFFER_ENTRIES *sizeof (struct tee_ring_cmd );
@@ -136,24 +159,13 @@ static int tee_init_ring(struct psp_tee_device *tee)static void tee_destroy_ring (struct psp_tee_device *tee) { -unsigned int reg; -int ret; -if (!tee->rb_mgr.ring_start)return ;if (psp_dead) goto free_ring; - ret =psp_mailbox_command (tee->psp,PSP_CMD_TEE_RING_DESTROY ,NULL , -TEE_DEFAULT_CMD_TIMEOUT , ®); -if (ret) { -dev_err (tee->dev,"tee: ring destroy command timed out, disabling TEE support\n" ); - psp_dead = true; - }else if (FIELD_GET (PSP_CMDRESP_STS , reg)) { -dev_err (tee->dev,"tee: ring destroy command failed (%#010lx)\n" , -FIELD_GET (PSP_CMDRESP_STS , reg)); - } +tee_send_destroy_cmd (tee); free_ring:tee_free_ring (tee);
Signature · 1 line
2.51.0
PATCH 188/283 crypto: ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails
In reply to Sasha LevinFrom: "Mario Limonciello (AMD)" <[email protected]>
[ Upstream commit 7b85137caf110a09a4a18f00f730de4709f9afc8 ]
The hibernate resume sequence involves loading a resume kernel that is just used for loading the hibernate image before shifting back to the existing kernel.
During that hibernate resume sequence the resume kernel may have loaded the ccp driver. If this happens the resume kernel will also have called PSP_CMD_TEE_RING_INIT but it will never have called PSP_CMD_TEE_RING_DESTROY.
This is problematic because the existing kernel needs to re-initialize the ring. One could argue that the existing kernel should call destroy as part of restore() but there is no guarantee that the resume kernel did or didn't load the ccp driver. There is also no callback opportunity for the resume kernel to destroy before handing back control to the existing kernel.
Similar problems could potentially exist with the use of kdump and crash handling. I actually reproduced this issue like this:
1) rmmod ccp
2) hibernate the system
3) resume the system
4) modprobe ccp
The resume kernel will have loaded ccp but never destroyed and then when I try to modprobe it fails.
Because of these possible cases add a flow that checks the error code from the PSP_CMD_TEE_RING_INIT call and tries to call PSP_CMD_TEE_RING_DESTROY if it failed. If this succeeds then call PSP_CMD_TEE_RING_INIT again.
--- drivers/crypto/ccp/tee-dev.c | 14 ++++++++++++++ include/linux/psp.h | 1 + 2 files changed, 15 insertions(+)
drivers/crypto/ccp/tee-dev.c +14 -0
@@ -113,6 +113,7 @@ static int tee_init_ring(struct psp_tee_device *tee) {int ring_size =MAX_RING_BUFFER_ENTRIES *sizeof (struct tee_ring_cmd );struct tee_init_ring_cmd *cmd; +bool retry = false;unsigned int reg;int ret;
@@ -135,6 +136,7 @@ static int tee_init_ring(struct psp_tee_device *tee)/* Send command buffer details to Trusted OS by writing to * CPU-PSP message registers */ +retry_init: ret =psp_mailbox_command (tee->psp,PSP_CMD_TEE_RING_INIT , cmd,TEE_DEFAULT_CMD_TIMEOUT , ®);if (ret) {
@@ -145,6 +147,18 @@ static int tee_init_ring(struct psp_tee_device *tee) }if (FIELD_GET (PSP_CMDRESP_STS , reg)) { +/* +* During the hibernate resume sequence driver may have gotten loaded +* but the ring not properly destroyed. If the ring doesn't work, try +* to destroy and re-init once. +*/ +if (!retry &&FIELD_GET (PSP_CMDRESP_STS , reg) ==PSP_TEE_STS_RING_BUSY ) { +dev_info (tee->dev,"tee: ring init command failed with busy status, retrying\n" ); +if (tee_send_destroy_cmd (tee)) { + retry = true; + goto retry_init; + } + }dev_err (tee->dev,"tee: ring init command failed (%#010lx)\n" ,FIELD_GET (PSP_CMDRESP_STS , reg));tee_free_ring (tee);
include/linux/psp.h +1 -0
@@ -18,6 +18,7 @@* and should include an appropriate local definition in their source file. */ #define PSP_CMDRESP_STS GENMASK(15, 0) +#define PSP_TEE_STS_RING_BUSY 0x0000000d/* Ring already initialized */ #define PSP_CMDRESP_CMD GENMASK(23, 16)#define PSP_CMDRESP_RESERVED GENMASK(29, 24)#define PSP_CMDRESP_RECOVERY BIT(30)
Signature · 1 line
2.51.0
PATCH 189/283 mtd: parsers: Fix memory leak in mtd_parser_tplink_safeloader_parse()
In reply to Sasha LevinFrom: Zilin Guan <[email protected]>
[ Upstream commit 980ce2b02dd06a4fdf5fee38b2e14becf9cf7b8b ]
The function mtd_parser_tplink_safeloader_parse() allocates buf via mtd_parser_tplink_safeloader_read_table(). If the allocation for parts[idx].name fails inside the loop, the code jumps to the err_free label without freeing buf, leading to a memory leak.
Fix this by freeing the temporary buffer buf in the err_free label.
Compile tested only. Issue found using a prototype static analysis tool and code review.
--- drivers/mtd/parsers/tplink_safeloader.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/parsers/tplink_safeloader.c +1 -0
@@ -116,6 +116,7 @@ static int mtd_parser_tplink_safeloader_parse(struct mtd_info *mtd,return idx; err_free: +kfree (buf);for (idx -=1 ; idx >=0 ; idx--)kfree (parts[idx].name); err_free_parts:
Signature · 1 line
2.51.0
PATCH 190/283 RDMA/uverbs: Validate wqe_size before using it in ib_uverbs_post_send
In reply to Sasha LevinFrom: Yi Liu <[email protected]>
[ Upstream commit 1956f0a74ccf5dc9c3ef717f2985c3ed3400aab0 ]
ib_uverbs_post_send() uses cmd.wqe_size from userspace without any validation before passing it to kmalloc() and using the allocated buffer as struct ib_uverbs_send_wr.
If a user provides a small wqe_size value (e.g., 1), kmalloc() will succeed, but subsequent accesses to user_wr->opcode, user_wr->num_sge, and other fields will read beyond the allocated buffer, resulting in an out-of-bounds read from kernel heap memory. This could potentially leak sensitive kernel information to userspace.
Additionally, providing an excessively large wqe_size can trigger a WARNING in the memory allocation path, as reported by syzkaller.
This is inconsistent with ib_uverbs_unmarshall_recv() which properly validates that wqe_size >= sizeof(struct ib_uverbs_recv_wr) before proceeding.
Add the same validation for ib_uverbs_post_send() to ensure wqe_size is at least sizeof(struct ib_uverbs_send_wr).
--- drivers/infiniband/core/uverbs_cmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/core/uverbs_cmd.c +4 -1
@@ -2030,7 +2030,10 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs)if (ret)return ret; - user_wr =kmalloc (cmd.wqe_size,GFP_KERNEL ); +if (cmd.wqe_size <sizeof (struct ib_uverbs_send_wr )) +return -EINVAL ; + + user_wr =kmalloc (cmd.wqe_size,GFP_KERNEL | __GFP_NOWARN);if (!user_wr)return -ENOMEM ;
Signature · 1 line
2.51.0
PATCH 191/283 RDMA/rxe: Fix race condition in QP timer handlers
In reply to Sasha LevinFrom: Li Zhijian <[email protected]>
[ Upstream commit 87bf646921430e303176edc4eb07c30160361b73 ]
I encontered the following warning:
WARNING: drivers/infiniband/sw/rxe/rxe_task.c:249 at rxe_sched_task+0x1c8/0x238 [rdma_rxe], CPU#0: swapper/0/0 ... libsha1 [last unloaded: ip6_udp_tunnel] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Tainted: G C 6.19.0-rc5-64k-v8+ #37 PREEMPT Tainted: [C]=CRAP Hardware name: Raspberry Pi 4 Model B Rev 1.2 Call trace: rxe_sched_task+0x1c8/0x238 [rdma_rxe] (P) retransmit_timer+0x130/0x188 [rdma_rxe] call_timer_fn+0x68/0x4d0 __run_timers+0x630/0x888 ... WARNING: drivers/infiniband/sw/rxe/rxe_task.c:38 at rxe_sched_task+0x1c0/0x238 [rdma_rxe], CPU#0: swapper/0/0 ... WARNING: drivers/infiniband/sw/rxe/rxe_task.c:111 at do_work+0x488/0x5c8 [rdma_rxe], CPU#3: kworker/u17:4/93400 ... refcount_t: underflow; use-after-free. WARNING: lib/refcount.c:28 at refcount_warn_saturate+0x138/0x1a0, CPU#3: kworker/u17:4/93400
The issue is caused by a race condition between retransmit_timer() and rxe_destroy_qp, leading to the Queue Pair's (QP) reference count dropping to zero during timer handler execution.
It seems this warning is harmless because rxe_qp_do_cleanup() will flush all pending timers and requests.
Example of flow causing the issue:
CPU0 CPU1
retransmit_timer() {
spin_lock_irqsave
rxe_destroy_qp()
__rxe_cleanup()
__rxe_put() // qp->ref_count decrease to 0
rxe_qp_do_cleanup() {
if (qp->valid) {
rxe_sched_task() {
WARN_ON(rxe_read(task->qp) <= 0);
}
}
spin_unlock_irqrestore
}
spin_lock_irqsave
qp->valid = 0
spin_unlock_irqrestore
}Ensure the QP's reference count is maintained and its validity is checked within the timer callbacks by adding calls to rxe_get(qp) and corresponding rxe_put(qp) after use.
--- drivers/infiniband/sw/rxe/rxe_comp.c | 3 +++ drivers/infiniband/sw/rxe/rxe_req.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/infiniband/sw/rxe/rxe_comp.c +3 -0
@@ -119,12 +119,15 @@ void retransmit_timer(struct timer_list *t)rxe_dbg_qp (qp,"retransmit timer fired\n" ); +if (!rxe_get (qp)) +return ;spin_lock_irqsave (&qp->state_lock, flags);if (qp->valid) { qp->comp.timeout =1 ;rxe_sched_task (&qp->comp.task); }spin_unlock_irqrestore (&qp->state_lock, flags); +rxe_put (qp); }void rxe_comp_queue_pkt (struct rxe_qp *qp,struct sk_buff *skb)
drivers/infiniband/sw/rxe/rxe_req.c +3 -0
@@ -103,6 +103,8 @@ void rnr_nak_timer(struct timer_list *t)rxe_dbg_qp (qp,"nak timer fired\n" ); +if (!rxe_get (qp)) +return ;spin_lock_irqsave (&qp->state_lock, flags);if (qp->valid) {/* request a send queue retry */
@@ -111,6 +113,7 @@ void rnr_nak_timer(struct timer_list *t)rxe_sched_task (&qp->req.task); }spin_unlock_irqrestore (&qp->state_lock, flags); +rxe_put (qp); }static void req_check_sq_drain_done (struct rxe_qp *qp)
Signature · 1 line
2.51.0
PATCH 192/283 RDMA/core: Fix a couple of obvious typos in comments
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit 0aa44595d61ca9e61239f321fec799518884feb3 ]
Fix typos.
Stable-dep-of: afcae7d7b8a2 ("RDMA/core: add rdma_rw_max_sge() helper for SQ sizing")
--- drivers/infiniband/core/rw.c | 2 +- include/rdma/ib_verbs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/rw.c +1 -1
@@ -666,7 +666,7 @@ void rdma_rw_init_qp(struct ib_device *dev, struct ib_qp_init_attr *attr) factor =1 ;/* -* If the devices needs MRs to perform RDMA READ or WRITE operations, +* If the device needs MRs to perform RDMA READ or WRITE operations, * we'll need two additional MRs for the registrations and the * invalidation. */
include/rdma/ib_verbs.h +1 -1
@@ -1096,7 +1096,7 @@ struct ib_qp_cap {/* * Maximum number of rdma_rw_ctx structures in flight at a time. -* ib_create_qp() will calculate the right amount of neededed WRs +* ib_create_qp() will calculate the right amount of needed WRs * and MRs based on this. */ u32 max_rdma_ctxs;
Signature · 1 line
2.51.0
PATCH 193/283 svcrdma: Remove queue-shortening warnings
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit b918bfcf370c92ea3b82fa9bb3d017702b5fa4cb ]
These won't have much diagnostic value for site administrators. Since they can't be disabled, they become noise.
What's more, the subsequent rdma_create_qp() call adjusts the Send Queue size (possibly downward) without warning, making the size reported by these pr_warns inaccurate.
Stable-dep-of: afcae7d7b8a2 ("RDMA/core: add rdma_rw_max_sge() helper for SQ sizing")
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +1 -6
@@ -406,8 +406,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) rq_depth = newxprt->sc_max_requests + newxprt->sc_max_bc_requests + newxprt->sc_recv_batch;if (rq_depth > dev->attrs.max_qp_wr) { -pr_warn ("svcrdma: reducing receive depth to %d\n" , - dev->attrs.max_qp_wr); rq_depth = dev->attrs.max_qp_wr; newxprt->sc_recv_batch =1 ; newxprt->sc_max_requests = rq_depth -2 ;
@@ -417,11 +415,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) ctxts =rdma_rw_mr_factor (dev, newxprt->sc_port_num,RPCSVC_MAXPAGES ); ctxts *= newxprt->sc_max_requests; newxprt->sc_sq_depth = rq_depth + ctxts; -if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) { -pr_warn ("svcrdma: reducing send depth to %d\n" , - dev->attrs.max_qp_wr); +if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) newxprt->sc_sq_depth = dev->attrs.max_qp_wr; - }atomic_set (&newxprt->sc_sq_avail, newxprt->sc_sq_depth); newxprt->sc_pd =ib_alloc_pd (dev,0 );
Signature · 1 line
2.51.0
PATCH 194/283 svcrdma: Clean up comment in svc_rdma_accept()
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit fc2e69db82c1ac506cd7f539a3ab66d51d3380dc ]
The comment that starts "Qualify ..." applies to only some of the following code paragraph. Re-arrange the lines so the comment makes more sense.
Stable-dep-of: afcae7d7b8a2 ("RDMA/core: add rdma_rw_max_sge() helper for SQ sizing")
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +10 -7
@@ -391,18 +391,22 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) dev = newxprt->sc_cm_id->device; newxprt->sc_port_num = newxprt->sc_cm_id->port_num; -/* Qualify the transport resource defaults with the -* capabilities of this particular device */ + newxprt->sc_max_req_size = svcrdma_max_req_size; + newxprt->sc_max_requests = svcrdma_max_requests; + newxprt->sc_max_bc_requests = svcrdma_max_bc_requests; + newxprt->sc_recv_batch =RPCRDMA_MAX_RECV_BATCH ; + newxprt->sc_fc_credits =cpu_to_be32 (newxprt->sc_max_requests); + +/* Qualify the transport's resource defaults with the +* capabilities of this particular device. +*/ +/* Transport header, head iovec, tail iovec */ newxprt->sc_max_send_sges =3 ;/* Add one SGE per page list entry */ newxprt->sc_max_send_sges += (svcrdma_max_req_size /PAGE_SIZE ) +1 ;if (newxprt->sc_max_send_sges > dev->attrs.max_send_sge) newxprt->sc_max_send_sges = dev->attrs.max_send_sge; - newxprt->sc_max_req_size = svcrdma_max_req_size; - newxprt->sc_max_requests = svcrdma_max_requests; - newxprt->sc_max_bc_requests = svcrdma_max_bc_requests; - newxprt->sc_recv_batch =RPCRDMA_MAX_RECV_BATCH ; rq_depth = newxprt->sc_max_requests + newxprt->sc_max_bc_requests + newxprt->sc_recv_batch;if (rq_depth > dev->attrs.max_qp_wr) {
@@ -411,7 +415,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_requests = rq_depth -2 ; newxprt->sc_max_bc_requests =2 ; } - newxprt->sc_fc_credits =cpu_to_be32 (newxprt->sc_max_requests); ctxts =rdma_rw_mr_factor (dev, newxprt->sc_port_num,RPCSVC_MAXPAGES ); ctxts *= newxprt->sc_max_requests; newxprt->sc_sq_depth = rq_depth + ctxts;
Signature · 1 line
2.51.0
PATCH 195/283 svcrdma: Increase the per-transport rw_ctx count
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit 2da0f610e733606e06284ac3c1f188b9dec75d68 ]
rdma_rw_mr_factor() returns the smallest number of MRs needed to move a particular number of pages. svcrdma currently asks for the number of MRs needed to move RPCSVC_MAXPAGES (a little over one megabyte), as that is the number of pages in the largest r/wsize the server supports.
This call assumes that the client's NIC can bundle a full one megabyte payload in a single rdma_segment. In fact, most NICs cannot handle a full megabyte with a single rkey / rdma_segment. Clients will typically split even a single Read chunk into many segments.
The server needs one MR to read each rdma_segment in a Read chunk, and thus each one needs an rw_ctx.
svcrdma has been vastly underestimating the number of rw_ctxs needed to handle 64 RPC requests with large Read chunks using small rdma_segments.
Unfortunately there doesn't seem to be a good way to estimate this number without knowing the client NIC's capabilities. Even then, the client RPC/RDMA implementation is still free to split a chunk into smaller segments (for example, it might be using physical registration, which needs an rdma_segment per page).
The best we can do for now is choose a number that will guarantee forward progress in the worst case (one page per segment).
At some later point, we could add some mechanisms to make this much less of a problem:
- Add a core API to add more rw_ctxs to an already-established QP
- svcrdma could treat rw_ctx exhaustion as a temporary error and try again
- Limit the number of Reads in flight
Stable-dep-of: afcae7d7b8a2 ("RDMA/core: add rdma_rw_max_sge() helper for SQ sizing")
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +7 -2
@@ -415,8 +415,13 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_requests = rq_depth -2 ; newxprt->sc_max_bc_requests =2 ; } - ctxts =rdma_rw_mr_factor (dev, newxprt->sc_port_num,RPCSVC_MAXPAGES ); - ctxts *= newxprt->sc_max_requests; + +/* Arbitrarily estimate the number of rw_ctxs needed for +* this transport. This is enough rw_ctxs to make forward +* progress even if the client is using one rkey per page +* in each Read chunk. +*/ + ctxts =3 *RPCSVC_MAXPAGES ; newxprt->sc_sq_depth = rq_depth + ctxts;if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) newxprt->sc_sq_depth = dev->attrs.max_qp_wr;
Signature · 1 line
2.51.0
PATCH 196/283 svcrdma: Reduce the number of rdma_rw contexts per-QP
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit 59243315890578a040a2d50ae9e001a2ef2fcb62 ]
There is an upper bound on the number of rdma_rw contexts that can be created per QP.
This invisible upper bound is because rdma_create_qp() adds one or more additional SQEs for each ctxt that the ULP requests via qp_attr.cap.max_rdma_ctxs. The QP's actual Send Queue length is on the order of the sum of qp_attr.cap.max_send_wr and a factor times qp_attr.cap.max_rdma_ctxs. The factor can be up to three, depending on whether MR operations are required before RDMA Reads.
This limit is not visible to RDMA consumers via dev->attrs. When the limit is surpassed, QP creation fails with -ENOMEM. For example:
svcrdma's estimate of the number of rdma_rw contexts it needs is three times the number of pages in RPCSVC_MAXPAGES. When MAXPAGES is about 260, the internally-computed SQ length should be:
64 credits + 10 backlog + 3 * (3 * 260) = 2414
Which is well below the advertised qp_max_wr of 32768.
If RPCSVC_MAXPAGES is increased to 4MB, that's 1040 pages:
64 credits + 10 backlog + 3 * (3 * 1040) = 9434
However, QP creation fails. Dynamic printk for mlx5 shows:
calc_sq_size:618:(pid 1514): send queue size (9326 * 256 / 64 -> 65536) exceeds limits(32768)
Although 9326 is still far below qp_max_wr, QP creation still fails.
Because the total SQ length calculation is opaque to RDMA consumers, there doesn't seem to be much that can be done about this except for consumers to try to keep the requested rdma_rw ctxt count low.
Stable-dep-of: afcae7d7b8a2 ("RDMA/core: add rdma_rw_max_sge() helper for SQ sizing")
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +8 -6
@@ -363,12 +363,12 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,*/ static struct svc_xprt *svc_rdma_accept (struct svc_xprt *xprt) { +unsigned int ctxts, rq_depth, maxpayload;struct svcxprt_rdma *listen_rdma;struct svcxprt_rdma *newxprt =NULL ;struct rdma_conn_param conn_param;struct rpcrdma_connect_private pmsg;struct ib_qp_init_attr qp_attr; -unsigned int ctxts, rq_depth;struct ib_device *dev;int ret =0 ; RPC_IFDEBUG(struct sockaddr *sap);
@@ -416,12 +416,14 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_bc_requests =2 ; } -/* Arbitrarily estimate the number of rw_ctxs needed for -* this transport. This is enough rw_ctxs to make forward -* progress even if the client is using one rkey per page -* in each Read chunk. +/* Arbitrary estimate of the needed number of rdma_rw contexts. */ - ctxts =3 *RPCSVC_MAXPAGES ; + maxpayload =min (xprt->xpt_server->sv_max_payload, +RPCSVC_MAXPAYLOAD_RDMA ); + ctxts = newxprt->sc_max_requests *3 * +rdma_rw_mr_factor (dev, newxprt->sc_port_num, + maxpayload >>PAGE_SHIFT ); + newxprt->sc_sq_depth = rq_depth + ctxts;if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) newxprt->sc_sq_depth = dev->attrs.max_qp_wr;
Signature · 1 line
2.51.0
PATCH 197/283 RDMA/core: add rdma_rw_max_sge() helper for SQ sizing
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit afcae7d7b8a278a6c29e064f99e5bafd4ac1fb37 ]
svc_rdma_accept() computes sc_sq_depth as the sum of rq_depth and the number of rdma_rw contexts (ctxts). This value is used to allocate the Send CQ and to initialize the sc_sq_avail credit pool.
However, when the device uses memory registration for RDMA operations, rdma_rw_init_qp() inflates the QP's max_send_wr by a factor of three per context to account for REG and INV work requests. The Send CQ and credit pool remain sized for only one work request per context, causing Send Queue exhaustion under heavy NFS WRITE workloads.
Introduce rdma_rw_max_sge() to compute the actual number of Send Queue entries required for a given number of rdma_rw contexts. Upper layer protocols call this helper before creating a Queue Pair so that their Send CQs and credit accounting match the QP's true capacity.
Update svc_rdma_accept() to use rdma_rw_max_sge() when computing sc_sq_depth, ensuring the credit pool reflects the work requests that rdma_rw_init_qp() will reserve.
--- drivers/infiniband/core/rw.c | 53 +++++++++++++++++------- include/rdma/rw.h | 2 + net/sunrpc/xprtrdma/svc_rdma_transport.c | 8 +++- 3 files changed, 46 insertions(+), 17 deletions(-)
drivers/infiniband/core/rw.c +38 -15
@@ -651,34 +651,57 @@ unsigned int rdma_rw_mr_factor(struct ib_device *device, u32 port_num, }EXPORT_SYMBOL (rdma_rw_mr_factor); +/** +* rdma_rw_max_send_wr - compute max Send WRs needed for RDMA R/W contexts +* @dev: RDMA device +* @port_num: port number +* @max_rdma_ctxs: number of rdma_rw_ctx structures +* @create_flags: QP create flags (pass IB_QP_CREATE_INTEGRITY_EN if +* data integrity will be enabled on the QP) +* +* Returns the total number of Send Queue entries needed for +* @max_rdma_ctxs. The result accounts for memory registration and +* invalidation work requests when the device requires them. +* +* ULPs use this to size Send Queues and Send CQs before creating a +* Queue Pair. +*/ +unsigned int rdma_rw_max_send_wr (struct ib_device *dev,u32 port_num, +unsigned int max_rdma_ctxs,u32 create_flags) +{ +unsigned int factor =1 ; +unsigned int result; + +if (create_flags &IB_QP_CREATE_INTEGRITY_EN || +rdma_rw_can_use_mr (dev, port_num)) + factor +=2 ;/* reg + inv */ + +if (check_mul_overflow (factor, max_rdma_ctxs, &result)) +return UINT_MAX ; +return result; +} +EXPORT_SYMBOL (rdma_rw_max_send_wr); +void rdma_rw_init_qp (struct ib_device *dev,struct ib_qp_init_attr *attr) { -u32 factor; +unsigned int factor =1 ;WARN_ON_ONCE (attr->port_num ==0 );/* -* Each context needs at least one RDMA READ or WRITE WR. -* -* For some hardware we might need more, eventually we should ask the -* HCA driver for a multiplier here. -*/ - factor =1 ; - -/* -* If the device needs MRs to perform RDMA READ or WRITE operations, -* we'll need two additional MRs for the registrations and the -* invalidation. +* If the device uses MRs to perform RDMA READ or WRITE operations, +* or if data integrity is enabled, account for registration and +* invalidation work requests. */ if (attr->create_flags &IB_QP_CREATE_INTEGRITY_EN ||rdma_rw_can_use_mr (dev, attr->port_num)) - factor +=2 ;/* inv + reg */ + factor +=2 ;/* reg + inv */ attr->cap.max_send_wr += factor * attr->cap.max_rdma_ctxs;/* -* But maybe we were just too high in the sky and the device doesn't -* even support all we need, and we'll have to live with what we get.. +* The device might not support all we need, and we'll have to +* live with what we get. */ attr->cap.max_send_wr =min_t (u32, attr->cap.max_send_wr, dev->attrs.max_qp_wr);
include/rdma/rw.h +2 -0
@@ -66,6 +66,8 @@ int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num,unsigned int rdma_rw_mr_factor (struct ib_device *device,u32 port_num,unsigned int maxpages); +unsigned int rdma_rw_max_send_wr (struct ib_device *dev,u32 port_num, +unsigned int max_rdma_ctxs,u32 create_flags);void rdma_rw_init_qp (struct ib_device *dev,struct ib_qp_init_attr *attr);int rdma_rw_init_mrs (struct ib_qp *qp,struct ib_qp_init_attr *attr);void rdma_rw_cleanup_mrs (struct ib_qp *qp);
net/sunrpc/xprtrdma/svc_rdma_transport.c +6 -2
@@ -416,7 +416,10 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_bc_requests =2 ; } -/* Arbitrary estimate of the needed number of rdma_rw contexts. +/* Estimate the needed number of rdma_rw contexts. The maximum +* Read and Write chunks have one segment each. Each request +* can involve one Read chunk and either a Write chunk or Reply +* chunk; thus a factor of three. */ maxpayload =min (xprt->xpt_server->sv_max_payload,RPCSVC_MAXPAYLOAD_RDMA );
@@ -424,7 +427,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)rdma_rw_mr_factor (dev, newxprt->sc_port_num, maxpayload >>PAGE_SHIFT ); - newxprt->sc_sq_depth = rq_depth + ctxts; + newxprt->sc_sq_depth = rq_depth + +rdma_rw_max_send_wr (dev, newxprt->sc_port_num, ctxts,0 );if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) newxprt->sc_sq_depth = dev->attrs.max_qp_wr;atomic_set (&newxprt->sc_sq_avail, newxprt->sc_sq_depth);
Signature · 1 line
2.51.0
PATCH 198/283 cxl: Fix premature commit_end increment on decoder commit failure
In reply to Sasha LevinFrom: Yuxiong Wang <[email protected]>
[ Upstream commit 7b6f9d9b1ea05c9c22570126547c780e8c6c3f62 ]
In cxl_decoder_commit(), commit_end is incremented before verifying whether the commit succeeded, and the CXL_DECODER_F_ENABLE bit in cxld->flags is only set after a successful commit. As a result, if the commit fails, commit_end has been incremented and cxld->reset() has no effect since the flag is not set, so commit_end remains incorrectly incremented. The inconsistency between commit_end and CXL_DECODER_F_ENABLE causes failure during subsequent either commit or reset operations.
Fix this by incrementing commit_end only after confirming the commit succeeded. Also, remove the ineffective cxld->reset() call. According to CXL Spec r4.0 8.2.4.20.12 Committing Decoder Programming, since cxld_await_commit() has cleared the decoder commit bit on failure, no additional reset is required.
[dj: Fixed commit log 80 char wrapping. ]
[dj: Fix "Fixes" tag to correct hash length. ]
[dj: Change spec to r4.0. ]
--- drivers/cxl/core/hdm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/hdm.c +1 -2
@@ -710,14 +710,13 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld)writel (ctrl, hdm +CXL_HDM_DECODER0_CTRL_OFFSET (id));up_read (&cxl_dpa_rwsem); - port->commit_end++; rc =cxld_await_commit (hdm, cxld->id);if (rc) {dev_dbg (&port->dev,"%s: error %d committing decoder\n" ,dev_name (&cxld->dev), rc); - cxld->reset (cxld);return rc; } + port->commit_end++; cxld->flags |=CXL_DECODER_F_ENABLE ;return 0 ;
Signature · 1 line
2.51.0
PATCH 199/283 mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()
In reply to Sasha LevinFrom: Weigang He <[email protected]>
[ Upstream commit 7cce81df7d26d44123bd7620715c8349d96793d7 ]
of_get_child_by_name() returns a node pointer with refcount incremented, which must be released with of_node_put() when done. However, in parse_fixed_partitions(), when dedicated is true (i.e., a "partitions" subnode was found), the ofpart_node obtained from of_get_child_by_name() is never released on any code path.
Add of_node_put(ofpart_node) calls on all exit paths when dedicated is true to fix the reference count leak.
This bug was detected by our static analysis tool.
--- drivers/mtd/parsers/ofpart_core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/mtd/parsers/ofpart_core.c +14 -2
@@ -77,6 +77,7 @@ static int parse_fixed_partitions(struct mtd_info *master, of_id =of_match_node (parse_ofpart_match_table, ofpart_node);if (dedicated && !of_id) {/* The 'partitions' subnode might be used by another parser */ +of_node_put (ofpart_node);return 0 ; }
@@ -91,12 +92,18 @@ static int parse_fixed_partitions(struct mtd_info *master, nr_parts++; } -if (nr_parts ==0 ) +if (nr_parts ==0 ) { +if (dedicated) +of_node_put (ofpart_node);return 0 ; + } parts =kcalloc (nr_parts,sizeof (*parts),GFP_KERNEL ); -if (!parts) +if (!parts) { +if (dedicated) +of_node_put (ofpart_node);return -ENOMEM ; + } i =0 ;for_each_child_of_node (ofpart_node, pp) {
@@ -175,6 +182,9 @@ static int parse_fixed_partitions(struct mtd_info *master,if (quirks && quirks->post_parse) quirks->post_parse (master, parts, nr_parts); +if (dedicated) +of_node_put (ofpart_node); + *pparts = parts;return nr_parts;
@@ -183,6 +193,8 @@ static int parse_fixed_partitions(struct mtd_info *master, master->name, pp, mtd_node); ret = -EINVAL ; ofpart_none: +if (dedicated) +of_node_put (ofpart_node);of_node_put (pp);kfree (parts);return ret;
Signature · 1 line
2.51.0
PATCH 200/283 mtd: spinand: Fix kernel doc
In reply to Sasha LevinFrom: Miquel Raynal <[email protected]>
[ Upstream commit a57b1f07d2d35843a7ada30c8cf9a215c0931868 ]
The @data buffer is 5 bytes, not 4, it has been extended for the need of devices with an extra ID bytes.
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -195,7 +195,7 @@ struct spinand_device;/** * struct spinand_id - SPI NAND id structure -* @data: buffer containing the id bytes. Currently 4 bytes large, but can +* @data: buffer containing the id bytes. Currently 5 bytes large, but can * be extended if required * @len: ID length */
Signature · 1 line
2.51.0
PATCH 201/283 power: supply: qcom_battmgr: Recognize "LiP" as lithium-polymer
In reply to Sasha LevinFrom: Val Packett <[email protected]>
[ Upstream commit c655f45480637aee326b5bd96488d35ab90db2b0 ]
On the Dell Latitude 7455, the firmware uses "LiP" with a lowercase 'i' for the battery chemistry type, but only all-uppercase "LIP" was being recognized. Add the CamelCase variant to the check to fix the "Unknown battery technology" warning.
--- drivers/power/supply/qcom_battmgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/qcom_battmgr.c +2 -1
@@ -981,7 +981,8 @@ static unsigned int qcom_battmgr_sc8280xp_parse_technology(const char *chemistryif ((!strncmp (chemistry,"LIO" ,BATTMGR_CHEMISTRY_LEN )) || (!strncmp (chemistry,"OOI" ,BATTMGR_CHEMISTRY_LEN )))return POWER_SUPPLY_TECHNOLOGY_LION ; -if (!strncmp (chemistry,"LIP" ,BATTMGR_CHEMISTRY_LEN )) +if (!strncmp (chemistry,"LIP" ,BATTMGR_CHEMISTRY_LEN ) || + !strncmp (chemistry,"LiP" ,BATTMGR_CHEMISTRY_LEN ))return POWER_SUPPLY_TECHNOLOGY_LIPO ;pr_err ("Unknown battery technology '%s'\n" , chemistry);
Signature · 1 line
2.51.0
PATCH 202/283 RDMA/uverbs: Add __GFP_NOWARN to ib_uverbs_unmarshall_recv() kmalloc
In reply to Sasha LevinFrom: Yi Liu <[email protected]>
[ Upstream commit 58b604dfc7bb753f91bc0ccd3fa705e14e6edfb4 ]
Since wqe_size in ib_uverbs_unmarshall_recv() is user-provided and already validated, but can still be large, add __GFP_NOWARN to suppress memory allocation warnings for large sizes, consistent with the similar fix in ib_uverbs_post_send().
--- drivers/infiniband/core/uverbs_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_cmd.c +1 -1
@@ -2223,7 +2223,7 @@ ib_uverbs_unmarshall_recv(struct uverbs_req_iter *iter, u32 wr_count,if (ret)return ERR_PTR (ret); - user_wr =kmalloc (wqe_size,GFP_KERNEL ); + user_wr =kmalloc (wqe_size,GFP_KERNEL | __GFP_NOWARN);if (!user_wr)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.51.0
PATCH 203/283 pNFS: fix a missing wake up while waiting on NFS_LAYOUT_DRAIN
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit 5248d8474e594d156bee1ed10339cc16e207a28b ]
It is possible to have a task get stuck on waiting on the NFS_LAYOUT_DRAIN in the following scenario
1. cpu a: waiter test NFS_LAYOUT_DRAIN (1) and plh_outstanding (1)
2. cpu b: atomic_dec_and_test() -> clear bit -> wake up
3. cpu c: sets NFS_LAYOUT_DRAIN again
4. cpu a: calls wait_on_bit() sleeps forever.
To expand on this we have say 2 outstanding pnfs write IO that get ESTALE which causes both to call pnfs_destroy_layout() and set the NFS_LAYOUT_DRAIN bit but the 1st one doesn't call the pnfs_put_layout_hdr() yet (as that would prevent the 2nd ESTALE write from trying to call pnfs_destroy_layout()). If the 1st ESTALE write is the one that initially sets the NFS_LAYOUT_DRAIN so that new IO on this file initiates new LAYOUTGET. Another new write would find NFS_LAYOUT_DRAIN set and phl_outstanding>0 (step 1) and would wait_on_bit(). LAYOUTGET completes doing step 2. Now, the 2nd of ESTALE writes is calling pnfs_destory_layout() and set the NFS_LAYOUT_DRAIN bit (step 3). Finally, the waiting write wakes up to check the bit and goes back to sleep.
The problem revolves around the fact that if NFS_LAYOUT_INVALID_STID was already set, it should not do the work of pnfs_mark_layout_stateid_invalid(), thus NFS_LAYOUT_DRAIN will not be set more than once for an invalid layout.
--- fs/nfs/pnfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/pnfs.c +2 -1
@@ -464,7 +464,8 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo, };struct pnfs_layout_segment *lseg, *next; -set_bit (NFS_LAYOUT_INVALID_STID , &lo->plh_flags); +if (test_and_set_bit (NFS_LAYOUT_INVALID_STID , &lo->plh_flags)) +return !list_empty (&lo->plh_segs);clear_bit (NFS_INO_LAYOUTCOMMIT , &NFS_I (lo->plh_inode)->flags);list_for_each_entry_safe (lseg, next, &lo->plh_segs, pls_list)pnfs_clear_lseg_state (lseg, lseg_list);
Signature · 1 line
2.51.0
PATCH 204/283 scsi: smartpqi: Fix memory leak in pqi_report_phys_luns()
In reply to Sasha LevinFrom: Zilin Guan <[email protected]>
[ Upstream commit 41b37312bd9722af77ec7817ccf22d7a4880c289 ]
pqi_report_phys_luns() fails to release the rpl_list buffer when encountering an unsupported data format or when the allocation for rpl_16byte_wwid_list fails. These early returns bypass the cleanup logic, leading to memory leaks.
Consolidate the error handling by adding an out_free_rpl_list label and use goto statements to ensure rpl_list is consistently freed on failure.
Compile tested only. Issue found using a prototype static analysis tool and code review.
--- drivers/scsi/smartpqi/smartpqi_init.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +10 -3
@@ -1240,7 +1240,8 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **bdev_err (&ctrl_info->pci_dev->dev,"RPL returned unsupported data format %u\n" , rpl_response_format); -return -EINVAL ; + rc = -EINVAL ; + goto out_free_rpl_list; }else {dev_warn (&ctrl_info->pci_dev->dev,"RPL returned extended format 2 instead of 4\n" );
@@ -1252,8 +1253,10 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b rpl_16byte_wwid_list =kmalloc (struct_size (rpl_16byte_wwid_list, lun_entries, num_physicals),GFP_KERNEL ); -if (!rpl_16byte_wwid_list) -return -ENOMEM ; +if (!rpl_16byte_wwid_list) { + rc = -ENOMEM ; + goto out_free_rpl_list; + }put_unaligned_be32 (num_physicals *sizeof (struct report_phys_lun_16byte_wwid ), &rpl_16byte_wwid_list->header.list_length);
@@ -1274,6 +1277,10 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b *buffer = rpl_16byte_wwid_list;return 0 ; + +out_free_rpl_list: +kfree (rpl_list); +return rc; }static inline int pqi_report_logical_luns (struct pqi_ctrl_info *ctrl_info,void **buffer)
Signature · 1 line
2.51.0
PATCH 205/283 scsi: ufs: host: mediatek: Require CONFIG_PM
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit bbb8d98fb4536594cb104fd630ea0f7dce3771d6 ]
The added print statement from a recent fix causes the driver to fail building when CONFIG_PM is disabled:
drivers/ufs/host/ufs-mediatek.c: In function 'ufs_mtk_resume':drivers/ufs/host/ufs-mediatek.c:1890:40: error: 'struct dev_pm_info' has no member named 'request'
1890 | hba->dev->power.request,
It seems unlikely that the driver can work at all without CONFIG_PM, so just add a dependency and remove the existing ifdef checks, rather than adding another ifdef.
--- drivers/ufs/host/Kconfig | 1 + drivers/ufs/host/ufs-mediatek.c | 12 +++--------- include/ufs/ufshcd.h | 4 ---- 3 files changed, 4 insertions(+), 13 deletions(-)
drivers/ufs/host/Kconfig +1 -0
@@ -72,6 +72,7 @@ config SCSI_UFS_QCOM config SCSI_UFS_MEDIATEK tristate "Mediatek specific hooks to UFS controller platform driver" depends on SCSI_UFSHCD_PLATFORM && ARCH_MEDIATEK + depends on PM depends on RESET_CONTROLLER select PHY_MTK_UFS select RESET_TI_SYSCON
drivers/ufs/host/ufs-mediatek.c +3 -9
@@ -1852,7 +1852,6 @@ static int ufs_mtk_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int ufs_mtk_system_suspend (struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev);
@@ -1875,9 +1874,7 @@ static int ufs_mtk_system_resume(struct device *dev)return ufshcd_system_resume (dev); } -#endif -#ifdef CONFIG_PM static int ufs_mtk_runtime_suspend (struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev);
@@ -1900,13 +1897,10 @@ static int ufs_mtk_runtime_resume(struct device *dev)return ufshcd_runtime_resume (dev); } -#endif static const struct dev_pm_ops ufs_mtk_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, - ufs_mtk_system_resume) -SET_RUNTIME_PM_OPS (ufs_mtk_runtime_suspend, - ufs_mtk_runtime_resume,NULL ) + SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, ufs_mtk_system_resume) +RUNTIME_PM_OPS (ufs_mtk_runtime_suspend, ufs_mtk_runtime_resume,NULL ) .prepare = ufshcd_suspend_prepare, .complete = ufshcd_resume_complete, };
@@ -1916,7 +1910,7 @@ static struct platform_driver ufs_mtk_pltform = { .remove = ufs_mtk_remove, .driver = { .name = "ufshcd-mtk", - .pm = &ufs_mtk_pm_ops, + .pm = pm_ptr(&ufs_mtk_pm_ops), .of_match_table = ufs_mtk_of_match, }, };
include/ufs/ufshcd.h +0 -4
@@ -1329,17 +1329,13 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)return hba->priv; } -#ifdef CONFIG_PM extern int ufshcd_runtime_suspend (struct device *dev);extern int ufshcd_runtime_resume (struct device *dev); -#endif -#ifdef CONFIG_PM_SLEEP extern int ufshcd_system_suspend (struct device *dev);extern int ufshcd_system_resume (struct device *dev);extern int ufshcd_system_freeze (struct device *dev);extern int ufshcd_system_thaw (struct device *dev);extern int ufshcd_system_restore (struct device *dev); -#endif extern int ufshcd_dme_configure_adapt(struct ufs_hba *hba, int agreed_gear,
Signature · 1 line
2.51.0
PATCH 206/283 scsi: csiostor: Fix dereference of null pointer rn
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 1982257570b84dc33753d536dd969fd357a014e9 ]
The error exit path when rn is NULL ends up deferencing the null pointer rn via the use of the macro CSIO_INC_STATS. Fix this by adding a new error return path label after the use of the macro to avoid the deference.
--- drivers/scsi/csiostor/csio_scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/csiostor/csio_scsi.c +2 -1
@@ -2074,7 +2074,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)struct csio_scsi_level_data sld;if (!rn) - goto fail; + goto fail_ret;csio_dbg (hw,"Request to reset LUN:%llu (ssni:0x%x tgtid:%d)\n" , cmnd->device->lun, rn->flowid, rn->scsi_id);
@@ -2220,6 +2220,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)csio_put_scsi_ioreq_lock (hw, scsim, ioreq); fail:CSIO_INC_STATS (rn, n_lun_rst_fail); +fail_ret:return FAILED ; }
Signature · 1 line
2.51.0
PATCH 207/283 nvdimm: virtio_pmem: serialize flush requests
In reply to Sasha LevinFrom: Li Chen <[email protected]>
[ Upstream commit a9ba6733c7f1096c4506bf4e34a546e07242df74 ]
Under heavy concurrent flush traffic, virtio-pmem can overflow its request virtqueue (req_vq): virtqueue_add_sgs() starts returning -ENOSPC and the driver logs "no free slots in the virtqueue". Shortly after that the device enters VIRTIO_CONFIG_S_NEEDS_RESET and flush requests fail with "virtio pmem device needs a reset".
Serialize virtio_pmem_flush() with a per-device mutex so only one flush request is in-flight at a time. This prevents req_vq descriptor overflow under high concurrency.
Reproducer (guest with virtio-pmem):
- mkfs.ext4 -F /dev/pmem0
- mount -t ext4 -o dax,noatime /dev/pmem0 /mnt/bench
- fio: ioengine=io_uring rw=randwrite bs=4k iodepth=64 numjobs=64 direct=1 fsync=1 runtime=30s time_based=1
- dmesg: "no free slots in the virtqueue"
"virtio pmem device needs a reset"
--- drivers/nvdimm/nd_virtio.c | 3 ++- drivers/nvdimm/virtio_pmem.c | 1 + drivers/nvdimm/virtio_pmem.h | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/nvdimm/nd_virtio.c +2 -1
@@ -44,6 +44,8 @@ static int virtio_pmem_flush(struct nd_region *nd_region)unsigned long flags;int err, err1; +guard (mutex)(&vpmem->flush_lock); +/* * Don't bother to submit the request to the device if the device is * not activated.
@@ -53,7 +55,6 @@ static int virtio_pmem_flush(struct nd_region *nd_region)return -EIO ; } -might_sleep (); req_data =kmalloc (sizeof (*req_data),GFP_KERNEL );if (!req_data)return -ENOMEM ;
drivers/nvdimm/virtio_pmem.c +1 -0
@@ -49,6 +49,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev) goto out_err; } +mutex_init (&vpmem->flush_lock); vpmem->vdev = vdev; vdev->priv = vpmem; err =init_vq (vpmem);
drivers/nvdimm/virtio_pmem.h +4 -0
@@ -13,6 +13,7 @@#include <linux/module.h> #include <uapi/linux/virtio_pmem.h> #include <linux/libnvdimm.h> +#include <linux/mutex.h> #include <linux/spinlock.h> struct virtio_pmem_request {
@@ -35,6 +36,9 @@ struct virtio_pmem {/* Virtio pmem request queue */ struct virtqueue *req_vq; +/* Serialize flush requests to the device. */ +struct mutex flush_lock; +/* nvdimm bus registers virtio pmem device */ struct nvdimm_bus *nvdimm_bus;struct nvdimm_bus_descriptor nd_desc;
Signature · 1 line
2.51.0
PATCH 208/283 fs/nfs: Fix readdir slow-start regression
In reply to Sasha LevinFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 42e7c876b182da65723700f6bc507a8aecb10d3b ]
Commit 580f236737d1 ("NFS: Adjust the amount of readahead performed by NFS readdir") reduces the amount of readahead names caching done by the client.
The downside of this approach is READDIR now may suffer from a slow-start issue, where initially it will fetch names that fit in a single page, then in 2, 4, 8 until the maximum supported transfer size (usually 1M).
This patch tries to take a balanced approach between mitigating the slow-start issue still maintaining some efficiency gains.
--- fs/nfs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +2 -2
@@ -70,7 +70,7 @@ const struct address_space_operations nfs_dir_aops = { .free_folio = nfs_readdir_clear_array, }; -#define NFS_INIT_DTSIZE PAGE_SIZE +#define NFS_INIT_DTSIZE SZ_64Kstatic struct nfs_open_dir_context *alloc_nfs_open_dir_context (struct inode *dir)
@@ -81,7 +81,7 @@ alloc_nfs_open_dir_context(struct inode *dir) ctx =kzalloc (sizeof (*ctx),GFP_KERNEL_ACCOUNT );if (ctx !=NULL ) { ctx->attr_gencount = nfsi->attr_gencount; - ctx->dtsize =NFS_INIT_DTSIZE ; + ctx->dtsize =min (NFS_SERVER (dir)->dtsize,NFS_INIT_DTSIZE );spin_lock (&dir->i_lock);if (list_empty (&nfsi->open_files) && (nfsi->cache_validity &NFS_INO_DATA_INVAL_DEFER ))
Signature · 1 line
2.51.0
PATCH 209/283 tracing: Properly process error handling in event_hist_trigger_parse()
In reply to Sasha LevinFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 0550069cc25f513ce1f109c88f7c1f01d63297db ]
Memory allocated with trigger_data_alloc() requires trigger_data_free() for proper cleanup.
Replace kfree() with trigger_data_free() to fix this.
Found via static analysis and code review.
This isn't a real bug due to the current code basically being an open coded version of trigger_data_free() without the synchronization. The synchronization isn't needed as this is the error path of creation and there's nothing to synchronize against yet. Replace the kfree() to be consistent with the allocation.
--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -6889,7 +6889,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,remove_hist_vars (hist_data); -kfree (trigger_data); +trigger_data_free (trigger_data);destroy_hist_data (hist_data); goto out;
Signature · 1 line
2.51.0
PATCH 210/283 tracing: Remove duplicate ENABLE_EVENT_STR and DISABLE_EVENT_STR macros
In reply to Sasha LevinFrom: Steven Rostedt <[email protected]>
[ Upstream commit 9df0e49c5b9b8d051529be9994e4f92f2d20be6f ]
The macros ENABLE_EVENT_STR and DISABLE_EVENT_STR were added to trace.h so that more than one file can have access to them, but was never removed from their original location. Remove the duplicates.
--- kernel/trace/trace_events.c | 5 ----- 1 file changed, 5 deletions(-)
kernel/trace/trace_events.c +0 -5
@@ -3575,11 +3575,6 @@ void trace_put_event_file(struct trace_event_file *file)EXPORT_SYMBOL_GPL (trace_put_event_file); #ifdef CONFIG_DYNAMIC_FTRACE - -/* Avoid typos */ -#define ENABLE_EVENT_STR "enable_event" -#define DISABLE_EVENT_STR "disable_event" - struct event_probe_data { struct trace_event_file *file; unsigned long count;
Signature · 1 line
2.51.0
PATCH 211/283 fbdev: of_display_timing: Fix device node reference leak in of_get_display_timings()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit c39ee2d264f98efa14aa46c9942114cb03c7baa6 ]
Use for_each_child_of_node_scoped instead of for_each_child_of_node to ensure automatic of_node_put on early exit paths, preventing device node reference leak.
--- drivers/video/of_display_timing.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/of_display_timing.c +3 -3
@@ -195,7 +195,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) disp->num_timings =0 ; disp->native_mode =0 ; -for_each_child_of_node (timings_np, entry) { +for_each_child_of_node_scoped (timings_np, child) {struct display_timing *dt;int r;
@@ -206,7 +206,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) goto timingfail; } - r =of_parse_display_timing (entry, dt); + r =of_parse_display_timing (child, dt);if (r) {/* * to not encourage wrong devicetrees, fail in case of
@@ -218,7 +218,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) goto timingfail; } -if (native_mode == entry) +if (native_mode == child) disp->native_mode = disp->num_timings; disp->timings[disp->num_timings] = dt;
Signature · 1 line
2.51.0
PATCH 212/283 fbdev: au1200fb: Fix a memory leak in au1200fb_drv_probe()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit ce4e25198a6aaaaf36248edf8daf3d744ec8e309 ]
In au1200fb_drv_probe(), when platform_get_irq fails(), it directly returns from the function with an error code, which causes a memory leak.
Replace it with a goto label to ensure proper cleanup.
--- drivers/video/fbdev/au1200fb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/au1200fb.c +4 -2
@@ -1732,8 +1732,10 @@ static int au1200fb_drv_probe(struct platform_device *dev)/* Now hook interrupt too */ irq =platform_get_irq (dev,0 ); -if (irq <0 ) -return irq; +if (irq <0 ) { + ret = irq; + goto failed; + } ret =request_irq (irq, au1200fb_handle_irq,IRQF_SHARED ,"lcd" , (void *)dev);
Signature · 1 line
2.51.0
PATCH 213/283 clk: qcom: gcc-sm8550: Use floor ops for SDCC RCGs
In reply to Sasha LevinFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 1c06e3956054fb5a0930f07b02726b1774b6c700 ]
In line with commit a27ac3806b0a ("clk: qcom: gcc-sm8450: Use floor ops for SDCC RCGs") done to fix issues with overclocked SD cards on SM8450 powered boards set floor clock operations for SDCC RCGs on SM8550.
This change fixes initialization of some SD cards, where the problem is manifested by the SDHC driver:
mmc0: Card appears overclocked; req 50000000 Hz, actual 100000000 Hz
mmc0: error -110 whilst initialising SD card
--- drivers/clk/qcom/gcc-sm8550.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8550.c +2 -2
@@ -1025,7 +1025,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_9, .num_parents = ARRAY_SIZE(gcc_parent_data_9), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_shared_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -1048,7 +1048,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_shared_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 214/283 clk: qcom: rcg2: compute 2d using duty fraction directly
In reply to Sasha LevinFrom: Taniya Das <[email protected]>
[ Upstream commit d6205a1878dd4cc9664c4b4829b68a29c0426efc ]
The duty-cycle calculation in clk_rcg2_set_duty_cycle() currently derives an intermediate percentage duty_per = (num * 100) / den and then computes:
d = DIV_ROUND_CLOSEST(n * duty_per * 2, 100);
This introduces integer truncation at the percentage step (division by den) and a redundant scaling by 100, which can reduce precision for large den and skew the final rounding.
Compute 2d directly from the duty fraction to preserve precision and avoid the unnecessary scaling:
d = DIV_ROUND_CLOSEST(n * duty->num * 2, duty->den);
This keeps the intended formula d ≈ n * 2 * (num/den) while performing a single, final rounded division, improving accuracy especially for small duty cycles or large denominators. It also removes the unused duty_per variable, simplifying the code.
There is no functional changes beyond improved numerical accuracy.
--- drivers/clk/qcom/clk-rcg2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/clk/qcom/clk-rcg2.c +2 -4
@@ -434,7 +434,7 @@ static int clk_rcg2_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)static int clk_rcg2_set_duty_cycle (struct clk_hw *hw,struct clk_duty *duty) {struct clk_rcg2 *rcg =to_clk_rcg2 (hw); -u32 notn_m, n, m, d, not2d, mask, duty_per, cfg; +u32 notn_m, n, m, d, not2d, mask, cfg;int ret;/* Duty-cycle cannot be modified for non-MND RCGs */
@@ -453,10 +453,8 @@ static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) n = (~(notn_m) + m) & mask; - duty_per = (duty->num *100 ) / duty->den; -/* Calculate 2d value */ - d =DIV_ROUND_CLOSEST (n * duty_per *2 ,100 ); + d =DIV_ROUND_CLOSEST (n * duty->num *2 , duty->den);/* * Check bit widths of 2d. If D is too big reduce duty cycle.
Signature · 1 line
2.51.0
PATCH 215/283 clk: meson: gxbb: Limit the HDMI PLL OD to /4 on GXL/GXM SoCs
In reply to Sasha LevinFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 5b1a43950fd3162af0ce52b13c14a2d29b179d4f ]
GXBB has the HDMI PLL OD in the HHI_HDMI_PLL_CNTL2 register while for GXL/GXM the OD has moved to HHI_HDMI_PLL_CNTL3. At first glance the rest of the OD setup seems identical.
However, looking at the downstream kernel sources as well as testing shows that GXL only supports three OD values:
- register value 0 means: divide by 1
- register value 1 means: divide by 2
- register value 2 means: divide by 4
Using register value 3 (which on GXBB means: divide by 8) still divides by 4 as verified using meson-clk-measure. Downstream sources are also only using OD register values 0, 1 and 2 for GXL (while for GXBB the downstream kernel sources are also using value 3).
Add clk_div_table and have it replace the CLK_DIVIDER_POWER_OF_TWO flag to make the kernel's view of this register match with how the hardware actually works.
--- drivers/clk/meson/gxbb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/clk/meson/gxbb.c +14 -3
@@ -318,12 +318,23 @@ static struct clk_regmap gxbb_hdmi_pll = { }, }; +/* +* GXL hdmi OD dividers are POWER_OF_TWO dividers but limited to /4. +* A divider value of 3 should map to /8 but instead map /4 so ignore it. +*/ +static const struct clk_div_table gxl_hdmi_pll_od_div_table[] = { + { .val =0 , .div =1 }, + { .val =1 , .div =2 }, + { .val =2 , .div =4 }, + {/* sentinel */ } +}; +static struct clk_regmap gxl_hdmi_pll_od = { .data = &(struct clk_regmap_div_data ){ .offset =HHI_HDMI_PLL_CNTL +8 , .shift =21 , .width =2 , - .flags =CLK_DIVIDER_POWER_OF_TWO , + .table = gxl_hdmi_pll_od_div_table, }, .hw.init = &(struct clk_init_data ){ .name ="hdmi_pll_od" ,
@@ -341,7 +352,7 @@ static struct clk_regmap gxl_hdmi_pll_od2 = { .offset = HHI_HDMI_PLL_CNTL + 8, .shift = 23, .width = 2, - .flags = CLK_DIVIDER_POWER_OF_TWO, + .table = gxl_hdmi_pll_od_div_table, }, .hw.init = &(struct clk_init_data ){ .name ="hdmi_pll_od2" ,
@@ -359,7 +370,7 @@ static struct clk_regmap gxl_hdmi_pll = { .offset = HHI_HDMI_PLL_CNTL + 8, .shift = 19, .width = 2, - .flags = CLK_DIVIDER_POWER_OF_TWO, + .table = gxl_hdmi_pll_od_div_table, }, .hw.init = &(struct clk_init_data ){ .name ="hdmi_pll" ,
Signature · 1 line
2.51.0
PATCH 216/283 clk: qcom: gcc-sm8450: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 89428516f99572a9c37ebbb7859595881e7025a0 ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-sm8450.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8450.c +2 -2
@@ -936,7 +936,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_7, .num_parents = ARRAY_SIZE(gcc_parent_data_7), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -959,7 +959,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 217/283 clk: qcom: gcc-sdx75: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 4b057462bb61a6571608ba393e6e018c9da9c9c3 ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-sdx75.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sdx75.c +2 -2
@@ -1033,7 +1033,7 @@ static struct clk_rcg2 gcc_sdcc1_apps_clk_src = { .name = "gcc_sdcc1_apps_clk_src", .parent_data = gcc_parent_data_17, .num_parents = ARRAY_SIZE(gcc_parent_data_17), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -1057,7 +1057,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .name = "gcc_sdcc2_apps_clk_src", .parent_data = gcc_parent_data_18, .num_parents = ARRAY_SIZE(gcc_parent_data_18), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 218/283 clk: qcom: gcc-qdu1000: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 947c4b326c1f4dc64aed42170b39c2cf551ba8ca ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-qdu1000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-qdu1000.c +2 -2
@@ -904,7 +904,7 @@ static struct clk_rcg2 gcc_sdcc5_apps_clk_src = { .name = "gcc_sdcc5_apps_clk_src", .parent_data = gcc_parent_data_8, .num_parents = ARRAY_SIZE(gcc_parent_data_8), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -923,7 +923,7 @@ static struct clk_rcg2 gcc_sdcc5_ice_core_clk_src = { .name = "gcc_sdcc5_ice_core_clk_src", .parent_data = gcc_parent_data_2, .num_parents = ARRAY_SIZE(gcc_parent_data_2), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 219/283 clk: qcom: gcc-msm8953: Remove ALWAYS_ON flag from cpp_gdsc
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit 5f613e7034187179a9d088ff5fd02b1089d0cf20 ]
cpp_gdsc should not be always on, ALWAYS_ON flag was set accidentally.
--- drivers/clk/qcom/gcc-msm8953.c | 1 - 1 file changed, 1 deletion(-)
drivers/clk/qcom/gcc-msm8953.c +0 -1
@@ -3946,7 +3946,6 @@ static struct gdsc cpp_gdsc = { .pd = { .name = "cpp_gdsc", }, - .flags = ALWAYS_ON, .pwrsts = PWRSTS_OFF_ON, };
Signature · 1 line
2.51.0
PATCH 220/283 clk: qcom: gcc-msm8917: Remove ALWAYS_ON flag from cpp_gdsc
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit e4eb42f290aecac0ba355b1f8d7243be6de11f32 ]
cpp_gdsc should not be always on, ALWAYS_ON flag was set accidentally.
--- drivers/clk/qcom/gcc-msm8917.c | 1 - 1 file changed, 1 deletion(-)
drivers/clk/qcom/gcc-msm8917.c +0 -1
@@ -3034,7 +3034,6 @@ static struct gdsc cpp_gdsc = { .pd = { .name = "cpp_gdsc", }, - .flags = ALWAYS_ON, .pwrsts = PWRSTS_OFF_ON, };
Signature · 1 line
2.51.0
PATCH 221/283 clk: qcom: gcc-ipq5018: flag sleep clock as critical
In reply to Sasha LevinFrom: George Moussalem <[email protected]>
[ Upstream commit 04c4dc1f541135708d90a9b4632af51136f93ac3 ]
The sleep clock never be disabled. To avoid the kernel trying to disable it and keep it always on, flag it as critical.
--- drivers/clk/qcom/gcc-ipq5018.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-ipq5018.c +1 -0
@@ -1339,6 +1339,7 @@ static struct clk_branch gcc_sleep_clk_src = { .name = "gcc_sleep_clk_src", .parent_data = gcc_sleep_clk_data, .num_parents = ARRAY_SIZE(gcc_sleep_clk_data), + .flags = CLK_IS_CRITICAL, .ops = &clk_branch2_ops, }, },
Signature · 1 line
2.51.0
PATCH 222/283 clk: Move clk_{save,restore}_context() to COMMON_CLK section
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit f47c1b77d0a2a9c0d49ec14302e74f933398d1a3 ]
The clk_save_context() and clk_restore_context() helpers are only implemented by the Common Clock Framework. They are not available when using legacy clock frameworks. Dummy implementations are provided, but only if no clock support is available at all.
Hence when CONFIG_HAVE_CLK=y, but CONFIG_COMMON_CLK is not enabled:
m68k-linux-gnu-ld: drivers/net/phy/air_en8811h.o: in function `en8811h_resume':
air_en8811h.c:(.text+0x83e): undefined reference to `clk_restore_context'
m68k-linux-gnu-ld: drivers/net/phy/air_en8811h.o: in function `en8811h_suspend':
air_en8811h.c:(.text+0x856): undefined reference to `clk_save_context'Fix this by moving forward declarations and dummy implementions from the HAVE_CLK to the COMMON_CLK section.
--- include/linux/clk.h | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-)
include/linux/clk.h +24 -24
@@ -216,6 +216,23 @@ int clk_rate_exclusive_get(struct clk *clk);*/ void clk_rate_exclusive_put (struct clk *clk); +/** +* clk_save_context - save clock context for poweroff +* +* Saves the context of the clock register for powerstates in which the +* contents of the registers will be lost. Occurs deep within the suspend +* code so locking is not necessary. +*/ +int clk_save_context (void ); + +/** +* clk_restore_context - restore clock context after poweroff +* +* This occurs with all clocks enabled. Occurs deep within the resume code +* so locking is not necessary. +*/ +void clk_restore_context (void ); +#else static inline int clk_notifier_register(struct clk *clk,
@@ -276,6 +293,13 @@ static inline int clk_rate_exclusive_get(struct clk *clk)static inline void clk_rate_exclusive_put (struct clk *clk) {} +static inline int clk_save_context (void ) +{ +return 0 ; +} + +static inline void clk_restore_context (void ) {} +#endif #ifdef CONFIG_HAVE_CLK_PREPARE
@@ -872,23 +896,6 @@ struct clk *clk_get_parent(struct clk *clk);*/ struct clk *clk_get_sys (const char *dev_id,const char *con_id); -/** -* clk_save_context - save clock context for poweroff -* -* Saves the context of the clock register for powerstates in which the -* contents of the registers will be lost. Occurs deep within the suspend -* code so locking is not necessary. -*/ -int clk_save_context (void ); - -/** -* clk_restore_context - restore clock context after poweroff -* -* This occurs with all clocks enabled. Occurs deep within the resume code -* so locking is not necessary. -*/ -void clk_restore_context (void ); -#else /* !CONFIG_HAVE_CLK */ static inline struct clk *clk_get (struct device *dev,const char *id)
@@ -1055,13 +1062,6 @@ static inline struct clk *clk_get_sys(const char *dev_id, const char *con_id) return NULL; } -static inline int clk_save_context (void ) -{ -return 0 ; -} - -static inline void clk_restore_context (void ) {} -#endif /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
Signature · 1 line
2.51.0
PATCH 223/283 clk: qcom: dispcc-sdm845: Enable parents for pixel clocks
In reply to Sasha LevinFrom: Petr Hodina <[email protected]>
[ Upstream commit a1d63493634e98360140027fef49d82b1ff0a267 ]
Add CLK_OPS_PARENT_ENABLE to MDSS pixel clock sources to ensure parent clocks are enabled during clock operations, preventing potential stability issues during display configuration.
--- drivers/clk/qcom/dispcc-sdm845.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/dispcc-sdm845.c +2 -2
@@ -280,7 +280,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { .name = "disp_cc_mdss_pclk0_clk_src", .parent_data = disp_cc_parent_data_4, .num_parents = ARRAY_SIZE(disp_cc_parent_data_4), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
@@ -295,7 +295,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { .name = "disp_cc_mdss_pclk1_clk_src", .parent_data = disp_cc_parent_data_4, .num_parents = ARRAY_SIZE(disp_cc_parent_data_4), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
Signature · 1 line
2.51.0
PATCH 224/283 clk: qcom: gfx3d: add parent to parent request map
In reply to Sasha LevinFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 2583cb925ca1ce450aa5d74a05a67448db970193 ]
After commit d228ece36345 ("clk: divider: remove round_rate() in favor of determine_rate()") determining GFX3D clock rate crashes, because the passed parent map doesn't provide the expected best_parent_hw clock (with the roundd_rate path before the offending commit the best_parent_hw was ignored).
Set the field in parent_req in addition to setting it in the req, fixing the crash.
clk_hw_round_rate (drivers/clk/clk.c:1764) (P) clk_divider_bestdiv (drivers/clk/clk-divider.c:336) divider_determine_rate (drivers/clk/clk-divider.c:358) clk_alpha_pll_postdiv_determine_rate (drivers/clk/qcom/clk-alpha-pll.c:1275) clk_core_determine_round_nolock (drivers/clk/clk.c:1606) clk_core_round_rate_nolock (drivers/clk/clk.c:1701) __clk_determine_rate (drivers/clk/clk.c:1741) clk_gfx3d_determine_rate (drivers/clk/qcom/clk-rcg2.c:1268) clk_core_determine_round_nolock (drivers/clk/clk.c:1606) clk_core_round_rate_nolock (drivers/clk/clk.c:1701) clk_core_round_rate_nolock (drivers/clk/clk.c:1710) clk_round_rate (drivers/clk/clk.c:1804)
dev_pm_opp_set_rate (drivers/opp/core.c:1440 (discriminator 1)) msm_devfreq_target (drivers/gpu/drm/msm/msm_gpu_devfreq.c:51) devfreq_set_target (drivers/devfreq/devfreq.c:360) devfreq_update_target (drivers/devfreq/devfreq.c:426) devfreq_monitor (drivers/devfreq/devfreq.c:458) process_one_work (arch/arm64/include/asm/jump_label.h:36 include/trace/events/workqueue.h:110 kernel/workqueue.c:3284) worker_thread (kernel/workqueue.c:3356 (discriminator 2) kernel/workqueue.c:3443 (discriminator 2)) kthread (kernel/kthread.c:467) ret_from_fork (arch/arm64/kernel/entry.S:861)
--- drivers/clk/qcom/clk-rcg2.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/clk-rcg2.c +1 -0
@@ -918,6 +918,7 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw,if (req->max_rate < parent_req.max_rate) parent_req.max_rate = req->max_rate; + parent_req.best_parent_hw = req->best_parent_hw; ret =__clk_determine_rate (req->best_parent_hw, &parent_req);if (ret)return ret;
Signature · 1 line
2.51.0
PATCH 225/283 clk: mediatek: Fix error handling in runtime PM setup
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit aa2ad19210a6a444111bce55e8b69579f29318fb ]
devm_pm_runtime_enable() can fail due to memory allocation. The current code ignores its return value, and when pm_runtime_resume_and_get() fails, it returns directly without unmapping the shared_io region.
Add error handling for devm_pm_runtime_enable(). Reorder cleanup labels to properly unmap shared_io on pm_runtime_resume_and_get() failure.
--- drivers/clk/mediatek/clk-mtk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/clk/mediatek/clk-mtk.c +7 -5
@@ -497,14 +497,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,if (mcd->need_runtime_pm) { -devm_pm_runtime_enable (&pdev->dev); + r =devm_pm_runtime_enable (&pdev->dev); +if (r) + goto unmap_io;/* * Do a pm_runtime_resume_and_get() to workaround a possible * deadlock between clk_register() and the genpd framework. */ r =pm_runtime_resume_and_get (&pdev->dev);if (r) -return r; + goto unmap_io; }/* Calculate how many clk_hw_onecell_data entries to allocate */
@@ -618,11 +620,11 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev, free_data:mtk_free_clk_data (clk_data); free_base: -if (mcd->shared_io && base) -iounmap (base); -if (mcd->need_runtime_pm)pm_runtime_put (&pdev->dev); +unmap_io: +if (mcd->shared_io && base) +iounmap (base);return r; }
Signature · 1 line
2.51.0
PATCH 226/283 dmaengine: mediatek: uart-apdma: Fix above 4G addressing TX/RX
In reply to Sasha LevinFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 58ab9d7b6651d21e1cff1777529f2d3dd0b4e851 ]
The VFF_4G_SUPPORT register is named differently in datasheets, and its name is "VFF_ADDR2"; was this named correctly from the beginning it would've been clearer that there was a mistake in the programming sequence.
This register is supposed to hold the high bits to support the DMA addressing above 4G (so, more than 32 bits) and not a bit to "enable" the support for VFF 4G.
Fix the name of this register, and also fix its usage by writing the upper 32 bits of the dma_addr_t on it when the SoC supports such feature.
--- drivers/dma/mediatek/mtk-uart-apdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/mediatek/mtk-uart-apdma.c +5 -5
@@ -41,7 +41,7 @@#define VFF_STOP_CLR_B 0#define VFF_EN_CLR_B 0#define VFF_INT_EN_CLR_B 0 -#define VFF_4G_SUPPORT_CLR_B 0 +#define VFF_ADDR2_CLR_B 0/* * interrupt trigger level for tx
@@ -72,7 +72,7 @@/* TX: the buffer size SW can write. RX: the buffer size HW can write. */ #define VFF_LEFT_SIZE 0x40#define VFF_DEBUG_STATUS 0x50 -#define VFF_4G_SUPPORT 0x54 +#define VFF_ADDR2 0x54struct mtk_uart_apdmadev {struct dma_device ddev;
@@ -149,7 +149,7 @@ static void mtk_uart_apdma_start_tx(struct mtk_chan *c)mtk_uart_apdma_write (c,VFF_INT_FLAG ,VFF_TX_INT_CLR_B );if (mtkd->support_33bits) -mtk_uart_apdma_write (c,VFF_4G_SUPPORT ,VFF_4G_EN_B ); +mtk_uart_apdma_write (c,VFF_ADDR2 ,upper_32_bits (d->addr)); }mtk_uart_apdma_write (c,VFF_EN ,VFF_EN_B );
@@ -192,7 +192,7 @@ static void mtk_uart_apdma_start_rx(struct mtk_chan *c)mtk_uart_apdma_write (c,VFF_INT_FLAG ,VFF_RX_INT_CLR_B );if (mtkd->support_33bits) -mtk_uart_apdma_write (c,VFF_4G_SUPPORT ,VFF_4G_EN_B ); +mtk_uart_apdma_write (c,VFF_ADDR2 ,upper_32_bits (d->addr)); }mtk_uart_apdma_write (c,VFF_INT_EN ,VFF_RX_INT_EN_B );
@@ -298,7 +298,7 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan) }if (mtkd->support_33bits) -mtk_uart_apdma_write (c,VFF_4G_SUPPORT ,VFF_4G_SUPPORT_CLR_B ); +mtk_uart_apdma_write (c,VFF_ADDR2 ,VFF_ADDR2_CLR_B ); err_pm:pm_runtime_put_noidle (mtkd->ddev.dev);
Signature · 1 line
2.51.0
PATCH 227/283 dma: dma-axi-dmac: fix SW cyclic transfers
In reply to Sasha LevinFrom: Nuno Sá <[email protected]>
[ Upstream commit 9bd257181fd5c996d922e9991500ad27987cfbf4 ]
If 'hw_cyclic' is false we should still be able to do cyclic transfers in "software". That was not working for the case where 'desc->num_sgs' is 1 because 'chan->next_desc' is never set with the current desc which means that the cyclic transfer only runs once and in the next SOT interrupt we do nothing since vchan_next_desc() will return NULL.
Fix it by setting 'chan->next_desc' as soon as we get a new desc via vchan_next_desc().
base-commit: 398035178503bf662281bbffb4bebce1460a4bc5
--- drivers/dma/dma-axi-dmac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/dma-axi-dmac.c +1 -2
@@ -225,6 +225,7 @@ static void axi_dmac_start_transfer(struct axi_dmac_chan *chan)return ;list_move_tail (&vdesc->node, &chan->active_descs); desc =to_axi_dmac_desc (vdesc); + chan->next_desc = desc; } sg = &desc->sg[desc->num_submitted];
@@ -242,8 +243,6 @@ static void axi_dmac_start_transfer(struct axi_dmac_chan *chan)else chan->next_desc =NULL ; flags |=AXI_DMAC_FLAG_LAST ; - }else { - chan->next_desc = desc; } sg->id =axi_dmac_read (dmac,AXI_DMAC_REG_TRANSFER_ID );
Signature · 1 line
2.51.0
PATCH 228/283 staging: greybus: lights: avoid NULL deref
In reply to Sasha LevinFrom: Chaitanya Mishra <[email protected]>
[ Upstream commit efcffd9a6ad8d190651498d5eda53bfc7cf683a7 ]
gb_lights_light_config() stores channel_count before allocating the channels array. If kcalloc() fails, gb_lights_release() iterates the non-zero count and dereferences light->channels, which is NULL.
Allocate channels first and only then publish channels_count so the cleanup path can't walk a NULL pointer.
--- drivers/staging/greybus/light.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/greybus/light.c +6 -2
@@ -1029,14 +1029,18 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)if (!strlen (conf.name))return -EINVAL ; - light->channels_count = conf.channel_count; light->name =kstrndup (conf.name,NAMES_MAX ,GFP_KERNEL );if (!light->name)return -ENOMEM ; - light->channels =kcalloc (light->channels_count, + light->channels =kcalloc (conf.channel_count,sizeof (struct gb_channel ),GFP_KERNEL );if (!light->channels)return -ENOMEM ; +/* +* Publish channels_count only after channels allocation so cleanup +* doesn't walk a NULL channels pointer on allocation failure. +*/ + light->channels_count = conf.channel_count;/* First we collect all the configurations for all channels */ for (i =0 ; i < light->channels_count; i++) {
Signature · 1 line
2.51.0
PATCH 229/283 serial: imx: change SERIAL_IMX_CONSOLE to bool
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 79527d86ba91c2d9354832d19fd12b3baa66bd10 ]
SERIAL_IMX_CONSOLE is a build option for the imx driver (SERIAL_IMX). It does not build a separate console driver file, so it can't be built as a module since it isn't built at all.
Change the Kconfig symbol from tristate to bool and update the help text accordingly.
--- drivers/tty/serial/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/Kconfig +3 -3
@@ -479,14 +479,14 @@ config SERIAL_IMX can enable its onboard serial port by enabling this option. config SERIAL_IMX_CONSOLE - tristate "Console on IMX serial port" + bool "Console on IMX serial port" depends on SERIAL_IMX select SERIAL_CORE_CONSOLE help If you have enabled the serial port on the Freescale IMX - CPU you can make it the console by answering Y/M to this option. + CPU you can make it the console by answering Y to this option. - Even if you say Y/M here, the currently visible virtual console + Even if you say Y here, the currently visible virtual console (/dev/tty0) will still be used as the system console by default, but you can alter that using a kernel command line option such as "console=ttymxc0". (Try "man bootparam" or see the documentation of
Signature · 1 line
2.51.0
PATCH 230/283 serial: SH_SCI: improve "DMA support" prompt
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 93bb95a11238d66a4c9aa6eabf9774b073a5895c ]
Having a prompt of "DMA support" suddenly appear during a "make oldconfig" can be confusing. Add a little helpful text to the prompt message.
--- drivers/tty/serial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/Kconfig +1 -1
@@ -661,7 +661,7 @@ config SERIAL_SH_SCI_EARLYCON default ARCH_RENESAS config SERIAL_SH_SCI_DMA - bool "DMA support" if EXPERT + bool "Support for DMA on SuperH SCI(F)" if EXPERT depends on SERIAL_SH_SCI && DMA_ENGINE default ARCH_RENESAS
Signature · 1 line
2.51.0
PATCH 231/283 mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms
In reply to Sasha LevinFrom: Matthew Schwartz <[email protected]>
[ Upstream commit aced969e9bf3701dc75cfca57c78c031b7875b9d ]
The existing 1ms delay in sd_power_on is insufficient and causes resume errors around 4% of the time.
Increasing the delay to 5ms resolves this issue after testing 300 s2idle cycles.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
@@ -938,7 +938,7 @@ static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)if (err <0 )return err; -mdelay (1 ); +mdelay (5 ); err =rtsx_pci_write_register (pcr,CARD_OE ,SD_OUTPUT_EN ,SD_OUTPUT_EN );if (err <0 )
Signature · 1 line
2.51.0
PATCH 232/283 iio: pressure: mprls0025pa: fix scan_type struct
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit 8a228e036926f7e57421d750c3724e63f11b808a ]
Fix the scan_type sign and realbits assignment.
The pressure is a 24bit unsigned int between output_min and output_max.
transfer function A: 10% to 90% of 2^24
transfer function B: 2.5% to 22.5% of 2^24
transfer function C: 20% to 80% of 2^24
[MPR_FUNCTION_A] = { .output_min = 1677722, .output_max = 15099494 } [MPR_FUNCTION_B] = { .output_min = 419430, .output_max = 3774874 } [MPR_FUNCTION_C] = { .output_min = 3355443, .output_max = 13421773 }
--- drivers/iio/pressure/mprls0025pa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/pressure/mprls0025pa.c +2 -2
@@ -132,8 +132,8 @@ static const struct iio_chan_spec mpr_channels[] = {BIT (IIO_CHAN_INFO_OFFSET ), .scan_index = 0, .scan_type = { - .sign ='s' , - .realbits =32 , + .sign ='u' , + .realbits =24 , .storagebits =32 , .endianness =IIO_CPU , },
Signature · 1 line
2.51.0
PATCH 233/283 watchdog: starfive-wdt: Fix PM reference leak in probe error path
In reply to Sasha LevinFrom: Kery Qi <[email protected]>
[ Upstream commit 3f2d8d79cceb05a8b8dd200fa81c0dffc59ec46f ]
The PM reference count is not expected to be incremented on return in functions starfive_wdt_probe.
However, pm_runtime_get_sync will increment pm usage counter even failed. Forgetting to putting operation will result in a reference leak here.
Replace it with pm_runtime_resume_and_get to keep usage counter balanced.
--- drivers/watchdog/starfive-wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +1 -1
@@ -444,7 +444,7 @@ static int starfive_wdt_probe(struct platform_device *pdev)platform_set_drvdata (pdev, wdt);pm_runtime_enable (&pdev->dev);if (pm_runtime_enabled (&pdev->dev)) { - ret =pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_resume_and_get (&pdev->dev);if (ret <0 )return ret; }else {
Signature · 1 line
2.51.0
PATCH 234/283 coresight: etm3x: Fix cpulocked warning on cpuhp
In reply to Sasha LevinFrom: Antonio Borneo <[email protected]>
[ Upstream commit 1feb0377b9b816f89a04fc381eb19fc6bac9f4a4 ]
When changes [1] and [2] have been applied to the driver etm4x, the same modifications have been also collapsed in [3] and applied in one shot to the driver etm3x.
While doing this, the driver etm3x has not been aligned to etm4x on the use of non cpuslocked version of cpuhp callback setup APIs.
The current code triggers two run-time warnings when the kernel is compiled with CONFIG_PROVE_LOCKING=y.
Use non cpuslocked version of cpuhp callback setup APIs in driver etm3x, aligning it to the driver etm4x.
[1] commit 2d1a8bfb61ec ("coresight: etm4x: Fix etm4_count race by moving cpuhp callbacks to init")
[2] commit 22a550a306ad ("coresight: etm4x: Allow etm4x to be built as a module")
[3] commit 97fe626ce64c ("coresight: etm3x: Allow etm3x to be built as a module")
--- drivers/hwtracing/coresight/coresight-etm3x-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm3x-core.c +6 -6
@@ -814,16 +814,16 @@ static int __init etm_hp_setup(void) {int ret; - ret =cpuhp_setup_state_nocalls_cpuslocked (CPUHP_AP_ARM_CORESIGHT_STARTING , -"arm/coresight:starting" , - etm_starting_cpu, etm_dying_cpu); + ret =cpuhp_setup_state_nocalls (CPUHP_AP_ARM_CORESIGHT_STARTING , +"arm/coresight:starting" , + etm_starting_cpu, etm_dying_cpu);if (ret)return ret; - ret =cpuhp_setup_state_nocalls_cpuslocked (CPUHP_AP_ONLINE_DYN , -"arm/coresight:online" , - etm_online_cpu,NULL ); + ret =cpuhp_setup_state_nocalls (CPUHP_AP_ONLINE_DYN , +"arm/coresight:online" , + etm_online_cpu,NULL );/* HP dyn state ID returned in ret on success */ if (ret >0 ) {
Signature · 1 line
2.51.0
PATCH 235/283 Revert "mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms"
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit ff112f1ecd10b72004eac05bae395e1c65f0c63c ]
This reverts commit aced969e9bf3701dc75cfca57c78c031b7875b9d.
It was determined that this was not the correct "fix", so should be reverted.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
@@ -938,7 +938,7 @@ static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)if (err <0 )return err; -mdelay (5 ); +mdelay (1 ); err =rtsx_pci_write_register (pcr,CARD_OE ,SD_OUTPUT_EN ,SD_OUTPUT_EN );if (err <0 )
Signature · 1 line
2.51.0
PATCH 236/283 mfd: arizona: Fix regulator resource leak on wm5102_clear_write_sequencer() failure
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit 4feb753ba6e5e5bbaba868b841a2db41c21e56fa ]
The wm5102_clear_write_sequencer() helper may return an error and just return, bypassing the cleanup sequence and causing regulators to remain enabled, leading to a resource leak.
Change the direct return to jump to the err_reset label to properly free the resources.
--- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/arizona-core.c +1 -1
@@ -1100,7 +1100,7 @@ int arizona_dev_init(struct arizona *arizona) }else if (val &0x01 ) { ret =wm5102_clear_write_sequencer (arizona);if (ret) -return ret; + goto err_reset; }break ;default :
Signature · 1 line
2.51.0
PATCH 237/283 mfd: simple-mfd-i2c: Add MAX77705 support
In reply to Sasha LevinFrom: Dzmitry Sankouski <[email protected]>
[ Upstream commit 7b591ef98b3fc1ce20c3ccb86715429b72e2e6f0 ]
Add MAX77705 support - fuel gauge and hwmon devices. Hwmon provides charger input and system bus measurements.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/simple-mfd-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/mfd/simple-mfd-i2c.c +11 -0
@@ -83,11 +83,22 @@ static const struct simple_mfd_data maxim_max5970 = { .mfd_cell_size = ARRAY_SIZE(max5970_cells), }; +static const struct mfd_cell max77705_sensor_cells[] = { + { .name ="max77705-battery" }, + { .name ="max77705-hwmon" , }, +}; + +static const struct simple_mfd_data maxim_mon_max77705 = { + .mfd_cell = max77705_sensor_cells, + .mfd_cell_size =ARRAY_SIZE (max77705_sensor_cells), +}; +static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible ="kontron,sl28cpld" }, { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a}, { .compatible ="maxim,max5970" , .data = &maxim_max5970}, { .compatible ="maxim,max5978" , .data = &maxim_max5970}, + { .compatible ="maxim,max77705-battery" , .data = &maxim_mon_max77705}, {} };MODULE_DEVICE_TABLE (of, simple_mfd_i2c_of_match);
Signature · 1 line
2.51.0
PATCH 238/283 mfd: simple-mfd-i2c: Add compatible strings for Layerscape QIXIS FPGA
In reply to Sasha LevinFrom: Ioana Ciornei <[email protected]>
[ Upstream commit 81a2c31257411296862487aaade98b7d9e25dc72 ]
The QIXIS FPGA found on Layerscape boards such as LX2160AQDS, LS1028AQDS etc deals with power-on-reset timing, muxing etc. Use the simple-mfd-i2c as its core driver by adding its compatible string (already found in some dt files). By using the simple-mfd-i2c driver, any child device will have access to the i2c regmap created by it.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/simple-mfd-i2c.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/simple-mfd-i2c.c +2 -0
@@ -99,6 +99,8 @@ static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "maxim,max5970", .data = &maxim_max5970}, { .compatible = "maxim,max5978", .data = &maxim_max5970}, { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, + { .compatible = "fsl,lx2160aqds-fpga" }, + { .compatible = "fsl,ls1028aqds-fpga" }, {} };MODULE_DEVICE_TABLE (of, simple_mfd_i2c_of_match);
Signature · 1 line
2.51.0
PATCH 239/283 mfd: simple-mfd-i2c: Add SpacemiT P1 support
In reply to Sasha LevinFrom: Alex Elder <[email protected]>
[ Upstream commit 6fc5d415c10e98ac1b31dd1d5653443e691cdcff ]
Enable support for the RTC and regulators found in the SpacemiT P1 PMIC. Support is implemented by the simple I2C MFD driver.
The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This PMIC provides 6 buck converters and 12 LDO regulators. It also implements a switch, watchdog timer, real-time clock, and more. Initially its RTC and regulators are supported.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/Kconfig | 13 +++++++++++++ drivers/mfd/simple-mfd-i2c.c | 17 +++++++++++++++++ 2 files changed, 30 insertions(+)
drivers/mfd/Kconfig +13 -0
@@ -1137,6 +1137,19 @@ config MFD_QCOM_RPM Say M here if you want to include support for the Qualcomm RPM as a module. This will build a module called "qcom_rpm". +config MFD_SPACEMIT_P1 + tristate "SpacemiT P1 PMIC" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on I2C + select I2C_K1 + select MFD_SIMPLE_MFD_I2C + help + This option supports the I2C-based SpacemiT P1 PMIC, which + contains regulators, a power switch, GPIOs, an RTC, and more. + This option is selected when any of the supported sub-devices + is configured. The basic functionality is implemented by the + simple MFD I2C driver. + config MFD_SPMI_PMIC tristate "Qualcomm SPMI PMICs" depends on ARCH_QCOM || COMPILE_TEST
drivers/mfd/simple-mfd-i2c.c +17 -0
@@ -93,6 +93,22 @@ static const struct simple_mfd_data maxim_mon_max77705 = { .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), }; +static const struct regmap_config spacemit_p1_regmap_config = { + .reg_bits =8 , + .val_bits =8 , +}; + +static const struct mfd_cell spacemit_p1_cells[] = { + { .name ="spacemit-p1-regulator" , }, + { .name ="spacemit-p1-rtc" , }, +}; + +static const struct simple_mfd_data spacemit_p1 = { + .regmap_config = &spacemit_p1_regmap_config, + .mfd_cell = spacemit_p1_cells, + .mfd_cell_size =ARRAY_SIZE (spacemit_p1_cells), +}; +static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible ="kontron,sl28cpld" }, { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a},
@@ -101,6 +117,7 @@ static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, { .compatible = "fsl,lx2160aqds-fpga" }, { .compatible = "fsl,ls1028aqds-fpga" }, + { .compatible = "spacemit,p1", .data = &spacemit_p1, }, {} };MODULE_DEVICE_TABLE (of, simple_mfd_i2c_of_match);
Signature · 1 line
2.51.0
PATCH 240/283 mfd: simple-mfd-i2c: Keep compatible strings in alphabetical order
In reply to Sasha LevinFrom: Ioana Ciornei <[email protected]>
[ Upstream commit 3ed50d77924ff2e35918739df145dd429cee0ce4 ]
Reorder the of_device_id structures so that they are in alphabetical order.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/simple-mfd-i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mfd/simple-mfd-i2c.c +3 -3
@@ -110,13 +110,13 @@ static const struct simple_mfd_data spacemit_p1 = { };static const struct of_device_id simple_mfd_i2c_of_match[] = { + { .compatible ="fsl,ls1028aqds-fpga" }, + { .compatible ="fsl,lx2160aqds-fpga" }, { .compatible ="kontron,sl28cpld" }, - { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a}, { .compatible ="maxim,max5970" , .data = &maxim_max5970}, { .compatible ="maxim,max5978" , .data = &maxim_max5970}, { .compatible ="maxim,max77705-battery" , .data = &maxim_mon_max77705}, - { .compatible ="fsl,lx2160aqds-fpga" }, - { .compatible ="fsl,ls1028aqds-fpga" }, + { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a}, { .compatible ="spacemit,p1" , .data = &spacemit_p1, }, {} };
Signature · 1 line
2.51.0
PATCH 241/283 mfd: simple-mfd-i2c: Add Delta TN48M CPLD support
In reply to Sasha LevinFrom: Robert Marko <[email protected]>
[ Upstream commit 8f34c1a64c5394d2b51d3fba197947dc4b0b48a0 ]
Delta TN48M switches have a Lattice CPLD that serves multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and provide a common symbol on which the subdevice drivers can depend on.
--- drivers/mfd/Kconfig | 11 +++++++++++ drivers/mfd/simple-mfd-i2c.c | 1 + 2 files changed, 12 insertions(+)
drivers/mfd/Kconfig +11 -0
@@ -335,6 +335,17 @@ config MFD_CS47L92 help Support for Cirrus Logic CS42L92, CS47L92 and CS47L93 Smart Codecs +config MFD_TN48M_CPLD + tristate "Delta Networks TN48M switch CPLD driver" + depends on I2C + depends on ARCH_MVEBU || COMPILE_TEST + select MFD_SIMPLE_MFD_I2C + help + Select this option to enable support for Delta Networks TN48M switch + CPLD. It consists of reset and GPIO drivers. CPLD provides GPIOS-s + for the SFP slots as well as power supply related information. + SFP support depends on the GPIO driver being selected. + config PMIC_DA903X bool "Dialog Semiconductor DA9030/DA9034 PMIC Support" depends on I2C=y
drivers/mfd/simple-mfd-i2c.c +1 -0
@@ -110,6 +110,7 @@ static const struct simple_mfd_data spacemit_p1 = { };static const struct of_device_id simple_mfd_i2c_of_match[] = { + { .compatible ="delta,tn48m-cpld" }, { .compatible ="fsl,ls1028aqds-fpga" }, { .compatible ="fsl,lx2160aqds-fpga" }, { .compatible ="kontron,sl28cpld" },
Signature · 1 line
2.51.0
PATCH 242/283 drivers: iio: mpu3050: use dev_err_probe for regulator request
In reply to Sasha LevinFrom: Svyatoslav Ryhel <[email protected]>
[ Upstream commit b010880b9936da14f8035585ab57577aa05be23a ]
Regulator requesting may result in deferred probing error which will abort driver probing. To avoid this just use dev_err_probe which handles deferred probing.
--- drivers/iio/gyro/mpu3050-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/gyro/mpu3050-core.c +2 -4
@@ -1172,10 +1172,8 @@ int mpu3050_common_probe(struct device *dev, mpu3050->regs[1 ].supply = mpu3050_reg_vlogic; ret =devm_regulator_bulk_get (dev,ARRAY_SIZE (mpu3050->regs), mpu3050->regs); -if (ret) { -dev_err (dev,"Cannot get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Cannot get regulators\n" ); ret =mpu3050_power_up (mpu3050);if (ret)
Signature · 1 line
2.51.0
PATCH 243/283 usb: bdc: fix sleep during atomic
In reply to Sasha LevinFrom: Justin Chen <[email protected]>
[ Upstream commit f1195ca3b4bbd001d3f1264dce91f83dec7777f5 ]
bdc_run() can be ran during atomic context leading to a sleep during atomic warning. Fix this by replacing read_poll_timeout() with read_poll_timeout_atomic().
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +2 -2
@@ -35,8 +35,8 @@ static int poll_oip(struct bdc *bdc, u32 usec)u32 status;int ret; - ret =readl_poll_timeout (bdc->regs +BDC_BDCSC , status, - (BDC_CSTS (status) !=BDC_OIP ),10 , usec); + ret =readl_poll_timeout_atomic (bdc->regs +BDC_BDCSC , status, + (BDC_CSTS (status) !=BDC_OIP ),10 , usec);if (ret)dev_err (bdc->dev,"operation timedout BDCSC: 0x%08x\n" , status);else
Signature · 1 line
2.51.0
PATCH 244/283 pinctrl: equilibrium: Fix device node reference leak in pinbank_init()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit c0b4a4feeb43305a754893d8d9c6b2b5a52d45ac ]
When calling of_parse_phandle_with_fixed_args(), the caller is responsible to call of_node_put() to release the reference of device node.
In pinbank_init(), the reference of the node obtained from the "gpio-ranges" property is never released, resulting in a reference count leak.
Add the missing of_node_put() call to fix the leak.
--- drivers/pinctrl/pinctrl-equilibrium.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/pinctrl-equilibrium.c +1 -0
@@ -850,6 +850,7 @@ static int pinbank_init(struct device_node *np, bank->pin_base = spec.args[1 ]; bank->nr_pins = spec.args[2 ]; +of_node_put (spec.np); bank->aval_pinmap =readl (bank->membase +REG_AVAIL ); bank->id = id;
Signature · 1 line
2.51.0
PATCH 245/283 ovl: Fix uninit-value in ovl_fill_real
In reply to Sasha LevinFrom: Qing Wang <[email protected]>
[ Upstream commit 1992330d90dd766fcf1730fd7bf2d6af65370ac4 ]
Syzbot reported a KMSAN uninit-value issue in ovl_fill_real.
This iusse's call chain is:__do_sys_getdents64()
-> iterate_dir()
...
-> ext4_readdir()
-> fscrypt_fname_alloc_buffer() // alloc
-> fscrypt_fname_disk_to_usr // write without tail '\0'
-> dir_emit()
-> ovl_fill_real() // read by strcmp()The string is used to store the decrypted directory entry name for an encrypted inode. As shown in the call chain, fscrypt_fname_disk_to_usr() write it without null-terminate. However, ovl_fill_real() uses strcmp() to compare the name against "..", which assumes a null-terminated string and may trigger a KMSAN uninit-value warning when the buffer tail contains uninit data.
--- fs/overlayfs/readdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/readdir.c +1 -1
@@ -659,7 +659,7 @@ static bool ovl_fill_real(struct dir_context *ctx, const char *name, container_of(ctx, struct ovl_readdir_translate, ctx);struct dir_context *orig_ctx = rdt->orig_ctx; -if (rdt->parent_ino &&strcmp (name,".." ) ==0 ) { +if (rdt->parent_ino && namelen ==2 && !strncmp (name,".." ,2 )) { ino = rdt->parent_ino; }else if (rdt->cache) {struct ovl_cache_entry *p;
Signature · 1 line
2.51.0
PATCH 246/283 iio: sca3000: Fix a resource leak in sca3000_probe()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 62b44ebc1f2c71db3ca2d4737c52e433f6f03038 ]
spi->irq from request_threaded_irq() not released when iio_device_register() fails. Add an return value check and jump to a common error handler when iio_device_register() fails.
--- drivers/iio/accel/sca3000.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/accel/sca3000.c +5 -1
@@ -1496,7 +1496,11 @@ static int sca3000_probe(struct spi_device *spi)if (ret) goto error_free_irq; -return iio_device_register (indio_dev); + ret =iio_device_register (indio_dev); +if (ret) + goto error_free_irq; + +return 0 ; error_free_irq:if (spi->irq)
Signature · 1 line
2.51.0
PATCH 247/283 pinctrl: qcom: sm8250-lpass-lpi: Fix i2s2_data_groups definition
In reply to Sasha LevinFrom: Luca Weiss <[email protected]>
[ Upstream commit eabf273c8466af3f033473c2d2267a6ea7946d57 ]
The i2s2_data function is available on both gpio12 and gpio13. Fix the groups definition.
--- drivers/pinctrl/qcom/pinctrl-sm8250-lpass-lpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-sm8250-lpass-lpi.c +1 -1
@@ -88,7 +88,7 @@ static const char * const i2s1_ws_groups[] = { "gpio7" };static const char *const i2s1_data_groups[] = {"gpio8" ,"gpio9" };static const char *const wsa_swr_clk_groups[] = {"gpio10" };static const char *const wsa_swr_data_groups[] = {"gpio11" }; -static const char *const i2s2_data_groups[] = {"gpio12" ,"gpio12" }; +static const char *const i2s2_data_groups[] = {"gpio12" ,"gpio13" };static const struct lpi_pingroup sm8250_groups[] = {LPI_PINGROUP (0 ,0 , swr_tx_clk, qua_mi2s_sclk, _, _),
Signature · 1 line
2.51.0
PATCH 248/283 pinctrl: single: fix refcount leak in pcs_add_gpio_func()
In reply to Sasha LevinFrom: Wei Li <[email protected]>
[ Upstream commit 353353309b0f7afa407df29e455f9d15b5acc296 ]
of_parse_phandle_with_args() returns a device_node pointer with refcount incremented in gpiospec.np. The loop iterates through all phandles but never releases the reference, causing a refcount leak on each iteration.
Add of_node_put() calls to release the reference after extracting the needed arguments and on the error path when devm_kzalloc() fails.
This bug was detected by our static analysis tool and verified by my code review.
--- drivers/pinctrl/pinctrl-single.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-single.c +2 -0
@@ -1363,6 +1363,7 @@ static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs) } range =devm_kzalloc (pcs->dev,sizeof (*range),GFP_KERNEL );if (!range) { +of_node_put (gpiospec.np); ret = -ENOMEM ;break ; }
@@ -1372,6 +1373,7 @@ static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs)mutex_lock (&pcs->mutex);list_add_tail (&range->node, &pcs->gpiofuncs);mutex_unlock (&pcs->mutex); +of_node_put (gpiospec.np); }return ret; }
Signature · 1 line
2.51.0
PATCH 249/283 leds: qcom-lpg: Check the return value of regmap_bulk_write()
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit f42033b5ce8c79c5db645916c9a72ee3e10cecfa ]
The lpg_lut_store() function currently ignores the return value of regmap_bulk_write() and always returns 0. This can cause hardware write failures to go undetected, leading the caller to believe LUT programming succeeded when it may have failed.
Check the return value of regmap_bulk_write() in lpg_lut_store and return the error to the caller on failure.
--- drivers/leds/rgb/leds-qcom-lpg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/leds/rgb/leds-qcom-lpg.c +5 -3
@@ -221,7 +221,7 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern, {unsigned int idx;u16 val; -int i; +int i, ret; idx =bitmap_find_next_zero_area (lpg->lut_bitmap, lpg->lut_size,0 , len,0 );
@@ -231,8 +231,10 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,for (i =0 ; i < len; i++) { val = pattern[i].brightness; -regmap_bulk_write (lpg->map, lpg->lut_base +LPG_LUT_REG (idx + i), - &val,sizeof (val)); + ret =regmap_bulk_write (lpg->map, lpg->lut_base +LPG_LUT_REG (idx + i), + &val,sizeof (val)); +if (ret) +return ret; }bitmap_set (lpg->lut_bitmap, idx, len);
Signature · 1 line
2.51.0
PATCH 250/283 backlight: qcom-wled: Support ovp values for PMI8994
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit f29f972a6e7e3f187ea4d89b98a76c1981ca4d53 ]
WLED4 found in PMI8994 supports different ovp values.
--- drivers/video/backlight/qcom-wled.c | 41 +++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/video/backlight/qcom-wled.c +39 -2
@@ -1244,6 +1244,15 @@ static const struct wled_var_cfg wled4_ovp_cfg = { .size = ARRAY_SIZE(wled4_ovp_values), }; +static const u32 pmi8994_wled_ovp_values[] = { +31000 ,29500 ,19400 ,17800 , +}; + +static const struct wled_var_cfg pmi8994_wled_ovp_cfg = { + .values = pmi8994_wled_ovp_values, + .size =ARRAY_SIZE (pmi8994_wled_ovp_values), +}; +static inline u32 wled5_ovp_values_fn (u32 idx) {/*
@@ -1357,6 +1366,29 @@ static int wled_configure(struct wled *wled) }, }; +const struct wled_u32_opts pmi8994_wled_opts[] = { + { + .name ="qcom,current-boost-limit" , + .val_ptr = &cfg->boost_i_limit, + .cfg = &wled4_boost_i_limit_cfg, + }, + { + .name ="qcom,current-limit-microamp" , + .val_ptr = &cfg->string_i_limit, + .cfg = &wled4_string_i_limit_cfg, + }, + { + .name ="qcom,ovp-millivolt" , + .val_ptr = &cfg->ovp, + .cfg = &pmi8994_wled_ovp_cfg, + }, + { + .name ="qcom,switching-freq" , + .val_ptr = &cfg->switch_freq, + .cfg = &wled3_switch_freq_cfg, + }, + }; +const struct wled_u32_opts wled5_opts[] = { { .name ="qcom,current-boost-limit" ,
@@ -1423,8 +1455,13 @@ static int wled_configure(struct wled *wled)break ;case 4 : - u32_opts = wled4_opts; - size =ARRAY_SIZE (wled4_opts); +if (of_device_is_compatible (dev->of_node,"qcom,pmi8994-wled" )) { + u32_opts = pmi8994_wled_opts; + size =ARRAY_SIZE (pmi8994_wled_opts); + }else { + u32_opts = wled4_opts; + size =ARRAY_SIZE (wled4_opts); + } *cfg = wled4_config_defaults; wled->wled_set_brightness = wled4_set_brightness; wled->wled_sync_toggle = wled3_sync_toggle;
Signature · 1 line
2.51.0
PATCH 251/283 backlight: qcom-wled: Change PM8950 WLED configurations
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit 83333aa97441ba7ce32b91e8a007c72d316a1c67 ]
PMI8950 WLED needs same configurations as PMI8994 WLED.
--- drivers/video/backlight/qcom-wled.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/backlight/qcom-wled.c +2 -1
@@ -1455,7 +1455,8 @@ static int wled_configure(struct wled *wled)break ;case 4 : -if (of_device_is_compatible (dev->of_node,"qcom,pmi8994-wled" )) { +if (of_device_is_compatible (dev->of_node,"qcom,pmi8950-wled" ) || +of_device_is_compatible (dev->of_node,"qcom,pmi8994-wled" )) { u32_opts = pmi8994_wled_opts; size =ARRAY_SIZE (pmi8994_wled_opts); }else {
Signature · 1 line
2.51.0
PATCH 252/283 dmaengine: fsl-edma-main: Convert to platform remove callback returning void
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit fa13c3ef3f45bca5a1474755dac57bfaf28ef61b ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() is renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 666c53e94c1d ("dmaengine: fsl-edma: don't explicitly disable clocks in .remove()")
--- drivers/dma/fsl-edma-main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/dma/fsl-edma-main.c +2 -4
@@ -669,7 +669,7 @@ static int fsl_edma_probe(struct platform_device *pdev)return 0 ; } -static int fsl_edma_remove (struct platform_device *pdev) +static void fsl_edma_remove (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;struct fsl_edma_engine *fsl_edma =platform_get_drvdata (pdev);
@@ -679,8 +679,6 @@ static int fsl_edma_remove(struct platform_device *pdev)dma_async_device_unregister (&fsl_edma->dma_dev);fsl_edma_cleanup_vchan (&fsl_edma->dma_dev);fsl_disable_clocks (fsl_edma, fsl_edma->drvdata->dmamuxs); - -return 0 ; }static int fsl_edma_suspend_late (struct device *dev)
@@ -749,7 +747,7 @@ static struct platform_driver fsl_edma_driver = { .pm = &fsl_edma_pm_ops, }, .probe = fsl_edma_probe, - .remove = fsl_edma_remove, + .remove_new = fsl_edma_remove, };static int __init fsl_edma_init (void )
Signature · 1 line
2.51.0
PATCH 253/283 dmaengine: fsl-edma: don't explicitly disable clocks in .remove()
In reply to Sasha LevinFrom: Jared Kangas <[email protected]>
[ Upstream commit 666c53e94c1d0bf0bdf14c49505ece9ddbe725bc ]
The clocks in fsl_edma_engine::muxclk are allocated and enabled with devm_clk_get_enabled(), which automatically cleans these resources up, but these clocks are also manually disabled in fsl_edma_remove(). This causes warnings on driver removal for each clock:
edma_module already disabled
WARNING: CPU: 0 PID: 418 at drivers/clk/clk.c:1200 clk_core_disable+0x198/0x1c8
[...]
Call trace:
clk_core_disable+0x198/0x1c8 (P)
clk_disable+0x34/0x58
fsl_edma_remove+0x74/0xe8 [fsl_edma]
[...]
---[ end trace 0000000000000000 ]---
edma_module already unprepared
WARNING: CPU: 0 PID: 418 at drivers/clk/clk.c:1059 clk_core_unprepare+0x1f8/0x220
[...]
Call trace:
clk_core_unprepare+0x1f8/0x220 (P)
clk_unprepare+0x34/0x58
fsl_edma_remove+0x7c/0xe8 [fsl_edma]
[...]
---[ end trace 0000000000000000 ]---Fix these warnings by removing the unnecessary fsl_disable_clocks() call in fsl_edma_remove().
--- drivers/dma/fsl-edma-main.c | 1 - 1 file changed, 1 deletion(-)
drivers/dma/fsl-edma-main.c +0 -1
@@ -678,7 +678,6 @@ static void fsl_edma_remove(struct platform_device *pdev)of_dma_controller_free (np);dma_async_device_unregister (&fsl_edma->dma_dev);fsl_edma_cleanup_vchan (&fsl_edma->dma_dev); -fsl_disable_clocks (fsl_edma, fsl_edma->drvdata->dmamuxs); }static int fsl_edma_suspend_late (struct device *dev)
Signature · 1 line
2.51.0
PATCH 254/283 io_uring/cancel: de-unionize file and user_data in struct io_cancel_data
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 22dbb0987bd1e0ec3b1e4ad20756a98f99aa4a08 ]
By having them share the same space in struct io_cancel_data, it ends up disallowing IORING_ASYNC_CANCEL_FD|IORING_ASYNC_CANCEL_USERDATA from working. Eg you cannot match on both a file and user_data for cancelation purposes. This obviously isn't a common use case as nobody has reported this, but it does result in -ENOENT potentially being returned when trying to match on both, rather than actually doing what the API says it would.
--- io_uring/cancel.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
io_uring/cancel.h +2 -4
@@ -4,10 +4,8 @@struct io_cancel_data {struct io_ring_ctx *ctx; -union { -u64 data; -struct file *file; - }; +u64 data; +struct file *file;u8 opcode;u32 flags;int seq;
Signature · 1 line
2.51.0
PATCH 255/283 fs/ntfs3: prevent infinite loops caused by the next valid being the same
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit 27b75ca4e51e3e4554dc85dbf1a0246c66106fd3 ]
When processing valid within the range [valid : pos), if valid cannot be retrieved correctly, for example, if the retrieved valid value is always the same, this can trigger a potential infinite loop, similar to the hung problem reported by syzbot [1].
Adding a check for the valid value within the loop body, and terminating the loop and returning -EINVAL if the value is the same as the current value, can prevent this.
[1]
INFO: task syz.4.21:6056 blocked for more than 143 seconds. Call Trace: rwbase_write_lock+0x14f/0x750 kernel/locking/rwbase_rt.c:244 inode_lock include/linux/fs.h:1027 [inline] ntfs_file_write_iter+0xe6/0x870 fs/ntfs3/file.c:1284
--- fs/ntfs3/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ntfs3/file.c +6 -2
@@ -901,8 +901,12 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from) goto out;if (lcn ==SPARSE_LCN ) { - ni->i_valid = valid = - frame_vbo + ((u64 )clen << sbi->cluster_bits); + valid = frame_vbo + ((u64 )clen << sbi->cluster_bits); +if (ni->i_valid == valid) { + err = -EINVAL ; + goto out; + } + ni->i_valid = valid;continue ; }
Signature · 1 line
2.51.0
PATCH 256/283 fs/ntfs3: Fix slab-out-of-bounds read in DeleteIndexEntryRoot
In reply to Sasha LevinFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit b2bc7c44ed1779fc9eaab9a186db0f0d01439622 ]
In the 'DeleteIndexEntryRoot' case of the 'do_action' function, the entry size ('esize') is retrieved from the log record without adequate bounds checking.
Specifically, the code calculates the end of the entry ('e2') using:
e2 = Add2Ptr(e1, esize);
It then calculates the size for memmove using 'PtrOffset(e2, ...)', which subtracts the end pointer from the buffer limit. If 'esize' is maliciously large, 'e2' exceeds the used buffer size. This results in a negative offset which, when cast to size_t for memmove, interprets as a massive unsigned integer, leading to a heap buffer overflow.
This commit adds a check to ensure that the entry size ('esize') strictly fits within the remaining used space of the index header before performing memory operations.
--- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/fslog.c +3 -0
@@ -3431,6 +3431,9 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, e1 =Add2Ptr (attr,le16_to_cpu (lrh->attr_off)); esize =le16_to_cpu (e1->size); +if (PtrOffset (e1,Add2Ptr (hdr, used)) < esize) + goto dirty_vol; + e2 =Add2Ptr (e1, esize);memmove (e1, e2,PtrOffset (e2,Add2Ptr (hdr, used)));
Signature · 1 line
2.51.0
PATCH 257/283 ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs
In reply to Sasha LevinFrom: Sean V Kelley <[email protected]>
[ Upstream commit 56eb0c0ed345da7815274aa821a8546a073d7e97 ]
per_cpu(cpc_desc_ptr, cpu) object is initialized for only the online CPUs via acpi_soft_cpu_online() --> __acpi_processor_start() --> acpi_cppc_processor_probe().
However, send_pcc_cmd() and acpi_get_psd_map() still iterate over all possible CPUs. In acpi_get_psd_map(), encountering an offline CPU returns -EFAULT, causing cppc_cpufreq initialization to fail.
This breaks systems booted with "nosmt" or "nosmt=force".
Fix by using for_each_online_cpu() in both functions.
--- drivers/acpi/cppc_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/cppc_acpi.c +2 -2
@@ -347,7 +347,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd) end:if (cmd ==CMD_WRITE ) {if (unlikely (ret)) { -for_each_possible_cpu (i) { +for_each_online_cpu (i) {struct cpc_desc *desc =per_cpu (cpc_desc_ptr, i);if (!desc)
@@ -509,7 +509,7 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data)else if (pdomain->coord_type ==DOMAIN_COORD_TYPE_SW_ANY ) cpu_data->shared_type =CPUFREQ_SHARED_TYPE_ANY ; -for_each_possible_cpu (i) { +for_each_online_cpu (i) {if (i == cpu)continue ;
Signature · 1 line
2.51.0
PATCH 258/283 powercap: intel_rapl_tpmi: Remove FW_BUG from invalid version check
In reply to Sasha LevinFrom: Kuppuswamy Sathyanarayanan <[email protected]>
[ Upstream commit c7d54dafa042cf379859dba265fe5afef6fa8770 ]
On partitioned systems, multiple TPMI instances may exist per package, but RAPL registers are only valid on one instance since RAPL has package-scope control. Other instances return invalid versions during domain parsing, which is expected behavior on such systems.
Currently this generates a firmware bug warning:
intel_rapl_tpmi: [Firmware Bug]: Invalid version
Remove the FW_BUG tag, downgrade to pr_debug(), and update the message to clarify that invalid versions are expected on partitioned systems where only one instance can be valid.
--- drivers/powercap/intel_rapl_tpmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/powercap/intel_rapl_tpmi.c +1 -1
@@ -156,7 +156,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) tpmi_domain_flags = tpmi_domain_header >>32 &0xffff ;if (tpmi_domain_version ==TPMI_VERSION_INVALID ) { -pr_warn (FW_BUG "Invalid version\n" ); +pr_debug ("Invalid version, other instances may be valid\n" );return -ENODEV ; }
Signature · 1 line
2.51.0
PATCH 259/283 kbuild: Add objtool to top-level clean target
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 68b4fe32d73789dea23e356f468de67c8367ef8f ]
Objtool is an integral part of the build, make sure it gets cleaned by "make clean" and "make mrproper".
--- Makefile | 11 ++++++++++- tools/objtool/Makefile | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-)
Makefile +10 -1
@@ -1356,6 +1356,15 @@ ifneq ($(wildcard $(resolve_btfids_O)),) $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean endif +PHONY += objtool_clean + +objtool_O = $(abspath $(objtree))/tools/objtool + +objtool_clean: +ifneq ($(wildcard $(objtool_O)),) + $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean +endif + tools/: FORCE $(Q)mkdir -p $(objtree)/tools $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
@@ -1509,7 +1518,7 @@ vmlinuxclean: $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) -clean: archclean vmlinuxclean resolve_btfids_clean +clean: archclean vmlinuxclean resolve_btfids_clean objtool_clean # mrproper - Delete all generated files, including .config #
tools/objtool/Makefile +2 -0
@@ -7,6 +7,8 @@ srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif +RM ?= rm -f + LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ ifneq ($(OUTPUT),) LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd
Signature · 1 line
2.51.0
PATCH 260/283 selftests/memfd: delete unused declarations
In reply to Sasha LevinFrom: Greg Thelen <[email protected]>
[ Upstream commit a9117b4d7f178ea36e8d256f8ab3752839e245b2 ]
Commit 32d118ad50a5 ("selftests/memfd: add tests for F_SEAL_EXEC"):
- added several unused 'nbytes' local variables
Commit 6469b66e3f5a ("selftests: improve vm.memfd_noexec sysctl tests"):
- orphaned 'newpid_thread_fn2()' forward declaration
- orphaned 'join_newpid_thread()' forward declaration
- added unused 'pid' local in sysctl_simple_child()
- orphaned 'fd' local in sysctl_simple_child()
- added unused 'fd' in sysctl_nested_child()
Delete the unused locals and forward declarations.
Stable-dep-of: b24335521de9 ("selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT")
--- tools/testing/selftests/memfd/memfd_test.c | 10 ---------- 1 file changed, 10 deletions(-)
tools/testing/selftests/memfd/memfd_test.c +0 -10
@@ -45,8 +45,6 @@*/ static size_t mfd_def_size =MFD_DEF_SIZE ;static const char *memfd_str =MEMFD_STR ; -static int newpid_thread_fn2 (void *arg); -static void join_newpid_thread (pid_t pid);static ssize_t fd2name (int fd,char *buf,size_t bufsize) {
@@ -195,7 +193,6 @@ static unsigned int mfd_assert_get_seals(int fd)static void mfd_assert_has_seals (int fd,unsigned int seals) {char buf[PATH_MAX ]; -int nbytes;unsigned int s;fd2name (fd, buf,PATH_MAX );
@@ -715,7 +712,6 @@ static void mfd_assert_mode(int fd, int mode) {struct stat st;char buf[PATH_MAX ]; -int nbytes;fd2name (fd, buf,PATH_MAX );
@@ -734,7 +730,6 @@ static void mfd_assert_mode(int fd, int mode)static void mfd_assert_chmod (int fd,int mode) {char buf[PATH_MAX ]; -int nbytes;fd2name (fd, buf,PATH_MAX );
@@ -750,7 +745,6 @@ static void mfd_fail_chmod(int fd, int mode) {struct stat st;char buf[PATH_MAX ]; -int nbytes;fd2name (fd, buf,PATH_MAX );
@@ -1297,9 +1291,6 @@ static void test_sysctl_set_sysctl2(void)static int sysctl_simple_child (void *arg) { -int fd; -int pid; -printf ("%s sysctl 0\n" , memfd_str);test_sysctl_set_sysctl0 ();
@@ -1364,7 +1355,6 @@ static void test_sysctl_sysctl2_failset(void)static int sysctl_nested_child (void *arg) { -int fd;int pid;printf ("%s nested sysctl 0\n" , memfd_str);
Signature · 1 line
2.51.0
PATCH 261/283 selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT
In reply to Sasha LevinFrom: Aristeu Rozanski <[email protected]>
[ Upstream commit b24335521de92fd2ee22460072b75367ca8860b0 ]
selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT
In order to synchronize new processes to test inheritance of memfd_noexec sysctl, memfd_test sets up the sysctl with a value before creating the new process. The new process then sends itself a SIGSTOP in order to wait for the parent to flip the sysctl value and send a SIGCONT signal.
This would work as intended if it wasn't the fact that the new process is being created with CLONE_NEWPID, which creates a new PID namespace and the new process has PID 1 in this namespace. There're restrictions on sending signals to PID 1 and, although it's relaxed for other than root PID namespace, it's biting us here. In this specific case the SIGSTOP sent by the new process is ignored (no error to kill() is returned) and it never stops its execution. This is usually not noticiable as the parent usually manages to set the new sysctl value before the child has a chance to run and the test succeeds. But if you run the test in a loop, it eventually reproduces:
while [ 1 ]; do ./memfd_test >log 2>&1 || break; done; cat log
So this patch replaces the SIGSTOP/SIGCONT synchronization with IPC semaphore.
--- tools/testing/selftests/memfd/memfd_test.c | 113 +++++++++++++++++++-- 1 file changed, 105 insertions(+), 8 deletions(-)
tools/testing/selftests/memfd/memfd_test.c +105 -8
@@ -18,6 +18,9 @@#include <sys/stat.h> #include <sys/syscall.h> #include <sys/wait.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> #include <unistd.h> #include <ctype.h>
@@ -39,6 +42,20 @@ F_SEAL_EXEC)#define MFD_NOEXEC_SEAL 0x0008U +union semun { +int val; +struct semid_ds *buf; +unsigned short int *array; +struct seminfo *__buf; +}; + +/* +* we use semaphores on nested wait tasks due the use of CLONE_NEWPID: the +* child will be PID 1 and can't send SIGSTOP to themselves due special +* treatment of the init task, so the SIGSTOP/SIGCONT synchronization +* approach can't be used here. +*/ +#define SEM_KEY 0xdeadbeef/* * Default is not to test hugetlbfs
@@ -1333,8 +1350,22 @@ static int sysctl_nested(void *arg)static int sysctl_nested_wait (void *arg) { -/* Wait for a SIGCONT. */ -kill (getpid (),SIGSTOP ); +int sem =semget (SEM_KEY ,1 ,0600 ); +struct sembuf sembuf; + +if (sem <0 ) { +perror ("semget:" ); +abort (); + } + sembuf.sem_num =0 ; + sembuf.sem_flg =0 ; + sembuf.sem_op =0 ; + +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +abort (); + } +return sysctl_nested (arg); }
@@ -1355,7 +1386,9 @@ static void test_sysctl_sysctl2_failset(void)static int sysctl_nested_child (void *arg) { -int pid; +int pid, sem; +union semun semun; +struct sembuf sembuf;printf ("%s nested sysctl 0\n" , memfd_str);sysctl_assert_write ("0" );
@@ -1389,23 +1422,53 @@ static int sysctl_nested_child(void *arg) test_sysctl_sysctl2_failset);join_thread (pid); + sem =semget (SEM_KEY ,1 ,IPC_CREAT |0600 ); +if (sem <0 ) { +perror ("semget:" ); +return 1 ; + } + semun.val =1 ; + sembuf.sem_op =-1 ; + sembuf.sem_flg =0 ; + sembuf.sem_num =0 ; +/* Verify that the rules are actually inherited after fork. */ printf ("%s nested sysctl 0 -> 1 after fork\n" , memfd_str);sysctl_assert_write ("0" ); +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl1_failset);sysctl_assert_write ("1" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);printf ("%s nested sysctl 0 -> 2 after fork\n" , memfd_str);sysctl_assert_write ("0" ); +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl2_failset);sysctl_assert_write ("2" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);/*
@@ -1415,28 +1478,62 @@ static int sysctl_nested_child(void *arg)*/ printf ("%s nested sysctl 2 -> 1 after fork\n" , memfd_str);sysctl_assert_write ("2" ); + +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl2);sysctl_assert_write ("1" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);printf ("%s nested sysctl 2 -> 0 after fork\n" , memfd_str);sysctl_assert_write ("2" ); + +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl2);sysctl_assert_write ("0" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);printf ("%s nested sysctl 1 -> 0 after fork\n" , memfd_str);sysctl_assert_write ("1" ); + +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl1);sysctl_assert_write ("0" ); -kill (pid,SIGCONT ); +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid); +semctl (sem,0 ,IPC_RMID ); +return 0 ; }
Signature · 1 line
2.51.0
PATCH 262/283 ACPI: PM: Add unused power resource quirk for THUNDEROBOT ZERO
In reply to Sasha LevinFrom: Zhai Can <[email protected]>
[ Upstream commit cd7ef20ba8c6e936dba133b4136537a8ada22976 ]
On the THUNDEROBOT ZERO laptop, the second NVMe slot and the discrete NVIDIA GPU are both controlled by power-resource PXP. Due to the SSDT table bug (lack of reference), PXP will be shut dow as an "unused" power resource during initialization, making the NVMe slot #2 + NVIDIA both inaccessible.
This issue was introduced by commit a1224f34d72a ("ACPI: PM: Check states of power resources during initialization"). Here are test results on the three consecutive commits:
(bad again!) a1224f34d72a ACPI: PM: Check states of power resources during initialization (good) bc2836859643 ACPI: PM: Do not turn off power resources in unknown state (bad) 519d81956ee2 Linux 5.15-rc6
On commit bc2836859643 ("ACPI: PM: Do not turn off power resources in unknown state") this was not an issue because the power resource state left UNKNOWN thus being ignored.
See also commit 9b04d99788cf ("ACPI: PM: Do not turn of unused power resources on the Toshiba Click Mini") which is another almost identical case to this one.
--- drivers/acpi/power.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/acpi/power.c +13 -0
@@ -1035,6 +1035,19 @@ static const struct dmi_system_id dmi_leave_unused_power_resources_on[] = { DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE Click Mini L9W-B"), }, }, + { + /* + * THUNDEROBOT ZERO laptop: Due to its SSDT table bug, power + * resource 'PXP' will be shut down on initialization, making + * the NVMe #2 and the NVIDIA dGPU both unavailable (they're + * both controlled by 'PXP'). + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "THUNDEROBOT"), + DMI_MATCH(DMI_PRODUCT_NAME, "ZERO"), + } + + }, {} };
Signature · 1 line
2.51.0
PATCH 263/283 cpuidle: Skip governor when only one idle state is available
In reply to Sasha LevinFrom: Aboorva Devarajan <[email protected]>
[ Upstream commit e5c9ffc6ae1bcdb1062527d611043681ac301aca ]
On certain platforms (PowerNV systems without a power-mgt DT node), cpuidle may register only a single idle state. In cases where that single state is a polling state (state 0), the ladder governor may incorrectly treat state 1 as the first usable state and pass an out-of-bounds index. This can lead to a NULL enter callback being invoked, ultimately resulting in a system crash.
[ 13.342636] cpuidle-powernv : Only Snooze is available [ 13.351854] Faulting instruction address: 0x00000000 [ 13.376489] NIP [0000000000000000] 0x0 [ 13.378351] LR [c000000001e01974] cpuidle_enter_state+0x2c4/0x668
Fix this by adding a bail-out in cpuidle_select() that returns state 0 directly when state_count <= 1, bypassing the governor and keeping the tick running.
--- drivers/cpuidle/cpuidle.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/cpuidle/cpuidle.c +10 -0
@@ -356,6 +356,16 @@ noinstr int cpuidle_enter_state(struct cpuidle_device *dev,int cpuidle_select (struct cpuidle_driver *drv,struct cpuidle_device *dev,bool *stop_tick) { +/* +* If there is only a single idle state (or none), there is nothing +* meaningful for the governor to choose. Skip the governor and +* always use state 0 with the tick running. +*/ +if (drv->state_count <=1 ) { + *stop_tick = false; +return 0 ; + } +return cpuidle_curr_governor->select (drv, dev, stop_tick); }
Signature · 1 line
2.51.0
PATCH 264/283 selftests: mlxsw: tc_restrictions: Fix test failure with new iproute2
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit a2646773a005b59fd1dc7ff3ba15df84889ca5d2 ]
As explained in [1], iproute2 started rejecting tc-police burst sizes that result in an overflow. This can happen when the burst size is high enough and the rate is low enough.
A couple of test cases specify such configurations, resulting in iproute2 errors and test failure.
Fix by reducing the burst size so that the test will pass with both new and old iproute2 versions.
[1] https://lore.kernel.org/netdev/[email protected]/
--- tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh +2 -2
@@ -317,7 +317,7 @@ police_limits_test() tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ - action police rate 0.5kbit burst 1m conform-exceed drop/ok + action police rate 0.5kbit burst 2k conform-exceed drop/ok check_fail $? "Incorrect success to add police action with too low rate" tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
@@ -327,7 +327,7 @@ police_limits_test() tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ - action police rate 1.5kbit burst 1m conform-exceed drop/ok + action police rate 1.5kbit burst 2k conform-exceed drop/ok check_err $? "Failed to add police action with low rate" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
Signature · 1 line
2.51.0
PATCH 265/283 net: sparx5/lan969x: fix DWRR cost max to match hardware register width
In reply to Sasha LevinFrom: Daniel Machon <[email protected]>
[ Upstream commit 6c28aa8dfdf24f554d4c5d4ff7d723a95360d94a ]
DWRR (Deficit Weighted Round Robin) scheduling distributes bandwidth across traffic classes based on per-queue cost values, where lower cost means higher bandwidth share.
The SPX5_DWRR_COST_MAX constant is 63 (6 bits) but the hardware register field HSCH_DWRR_ENTRY_DWRR_COST is GENMASK(24, 20), only 5 bits wide (max 31). This causes sparx5_weight_to_hw_cost() to compute cost values that silently overflow via FIELD_PREP, resulting in incorrect scheduling weights.
Set SPX5_DWRR_COST_MAX to 31 to match the hardware register width.
--- drivers/net/ethernet/microchip/sparx5/sparx5_qos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/sparx5/sparx5_qos.h +1 -1
@@ -35,7 +35,7 @@#define SPX5_SE_BURST_UNIT 4096/* Dwrr */ -#define SPX5_DWRR_COST_MAX 63 +#define SPX5_DWRR_COST_MAX 31struct sparx5_shaper {u32 mode;
Signature · 1 line
2.51.0
PATCH 266/283 net: mscc: ocelot: extract ocelot_xmit_timestamp() helper
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 29372f07f7969a2f0490793226ecf6c8c6bde0fa ]
Extract the PTP timestamp handling logic from ocelot_port_xmit() into a separate ocelot_xmit_timestamp() helper function. This is a pure refactor with no behavioral change.
The helper returns false if the skb was consumed (freed) due to a timestamp request failure, and true if the caller should continue with frame injection. The rew_op value is returned via pointer.
This prepares for splitting ocelot_port_xmit() into separate FDMA and register injection paths in a subsequent patch.
Stable-dep-of: 026f6513c588 ("net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()")
--- drivers/net/ethernet/mscc/ocelot_net.c | 36 ++++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +22 -14
@@ -551,33 +551,41 @@ static int ocelot_port_stop(struct net_device *dev)return 0 ; } -static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +static bool ocelot_xmit_timestamp (struct ocelot *ocelot,int port, +struct sk_buff *skb,u32 *rew_op) { -struct ocelot_port_private *priv =netdev_priv (dev); -struct ocelot_port *ocelot_port = &priv->port; -struct ocelot *ocelot = ocelot_port->ocelot; -int port = priv->port.index; -u32 rew_op =0 ; - -if (!static_branch_unlikely (&ocelot_fdma_enabled) && - !ocelot_can_inject (ocelot,0 )) -return NETDEV_TX_BUSY ; - -/* Check if timestamping is needed */ if (ocelot->ptp && (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP )) {struct sk_buff *clone =NULL ;if (ocelot_port_txtstamp_request (ocelot, port, skb, &clone)) {kfree_skb (skb); -return NETDEV_TX_OK ; +return false; }if (clone)OCELOT_SKB_CB (skb)->clone = clone; - rew_op =ocelot_ptp_rew_op (skb); + *rew_op =ocelot_ptp_rew_op (skb); } +return true; +} + +static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +{ +struct ocelot_port_private *priv =netdev_priv (dev); +struct ocelot_port *ocelot_port = &priv->port; +struct ocelot *ocelot = ocelot_port->ocelot; +int port = priv->port.index; +u32 rew_op =0 ; + +if (!static_branch_unlikely (&ocelot_fdma_enabled) && + !ocelot_can_inject (ocelot,0 )) +return NETDEV_TX_BUSY ; + +if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) +return NETDEV_TX_OK ; +if (static_branch_unlikely (&ocelot_fdma_enabled)) {ocelot_fdma_inject_frame (ocelot, port, rew_op, skb, dev); }else {
Signature · 1 line
2.51.0
PATCH 267/283 net: mscc: ocelot: split xmit into FDMA and register injection paths
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 47f79b20e7fb885aa1623b759a68e8e27401ec4d ]
Split ocelot_port_xmit() into two separate functions:
- ocelot_port_xmit_fdma(): handles the FDMA injection path
- ocelot_port_xmit_inj(): handles the register-based injection path
The top-level ocelot_port_xmit() now dispatches to the appropriate function based on the ocelot_fdma_enabled static key.
This is a pure refactor with no behavioral change. Separating the two code paths makes each one simpler and prepares for adding proper locking to the register injection path without affecting the FDMA path.
Stable-dep-of: 026f6513c588 ("net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()")
--- drivers/net/ethernet/mscc/ocelot_net.c | 39 ++++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +30 -9
@@ -571,7 +571,25 @@ static bool ocelot_xmit_timestamp(struct ocelot *ocelot, int port,return true; } -static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ocelot_port_xmit_fdma (struct sk_buff *skb, +struct net_device *dev) +{ +struct ocelot_port_private *priv =netdev_priv (dev); +struct ocelot_port *ocelot_port = &priv->port; +struct ocelot *ocelot = ocelot_port->ocelot; +int port = priv->port.index; +u32 rew_op =0 ; + +if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) +return NETDEV_TX_OK ; + +ocelot_fdma_inject_frame (ocelot, port, rew_op, skb, dev); + +return NETDEV_TX_OK ; +} + +static netdev_tx_t ocelot_port_xmit_inj (struct sk_buff *skb, +struct net_device *dev) {struct ocelot_port_private *priv =netdev_priv (dev);struct ocelot_port *ocelot_port = &priv->port;
@@ -579,24 +597,27 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)int port = priv->port.index;u32 rew_op =0 ; -if (!static_branch_unlikely (&ocelot_fdma_enabled) && - !ocelot_can_inject (ocelot,0 )) +if (!ocelot_can_inject (ocelot,0 ))return NETDEV_TX_BUSY ;if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op))return NETDEV_TX_OK ; -if (static_branch_unlikely (&ocelot_fdma_enabled)) { -ocelot_fdma_inject_frame (ocelot, port, rew_op, skb, dev); - }else { -ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); +ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); -consume_skb (skb); - } +consume_skb (skb);return NETDEV_TX_OK ; } +static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +{ +if (static_branch_unlikely (&ocelot_fdma_enabled)) +return ocelot_port_xmit_fdma (skb, dev); + +return ocelot_port_xmit_inj (skb, dev); +} +enum ocelot_action_type {OCELOT_MACT_LEARN ,OCELOT_MACT_FORGET ,
Signature · 1 line
2.51.0
PATCH 268/283 net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 026f6513c5880c2c89e38ad66bbec2868f978605 ]
ocelot_port_xmit_inj() calls ocelot_can_inject() and ocelot_port_inject_frame() without holding the injection group lock. Both functions contain lockdep_assert_held() for the injection lock, and the correct caller felix_port_deferred_xmit() properly acquires the lock using ocelot_lock_inj_grp() before calling these functions.
Add ocelot_lock_inj_grp()/ocelot_unlock_inj_grp() around the register injection path to fix the missing lock protection. The FDMA path is not affected as it uses its own locking mechanism.
--- drivers/net/ethernet/mscc/ocelot_net.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +10 -2
@@ -597,14 +597,22 @@ static netdev_tx_t ocelot_port_xmit_inj(struct sk_buff *skb,int port = priv->port.index;u32 rew_op =0 ; -if (!ocelot_can_inject (ocelot,0 )) +ocelot_lock_inj_grp (ocelot,0 ); + +if (!ocelot_can_inject (ocelot,0 )) { +ocelot_unlock_inj_grp (ocelot,0 );return NETDEV_TX_BUSY ; + } -if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) +if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) { +ocelot_unlock_inj_grp (ocelot,0 );return NETDEV_TX_OK ; + }ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); +ocelot_unlock_inj_grp (ocelot,0 ); +consume_skb (skb);return NETDEV_TX_OK ;
Signature · 1 line
2.51.0
PATCH 269/283 ipv6: Fix out-of-bound access in fib6_add_rt2node().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 8244f959e2c125c849e569f5b23ed49804cce695 ]
syzbot reported out-of-bound read in fib6_add_rt2node(). [0]
When IPv6 route is created with RTA_NH_ID, struct fib6_info does not have the trailing struct fib6_nh.
The cited commit started to check !iter->fib6_nh->fib_nh_gw_family to ensure that rt6_qualify_for_ecmp() will return false for iter.
If iter->nh is not NULL, rt6_qualify_for_ecmp() returns false anyway.
Let's check iter->nh before reading iter->fib6_nh and avoid OOB read.
[0]:
BUG: KASAN: slab-out-of-bounds in fib6_add_rt2node+0x349c/0x3500 net/ipv6/ip6_fib.c:1142 Read of size 1 at addr ffff8880384ba6de by task syz.0.18/5500 CPU: 0 UID: 0 PID: 5500 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xba/0x230 mm/kasan/report.c:482 kasan_report+0x117/0x150 mm/kasan/report.c:595 fib6_add_rt2node+0x349c/0x3500 net/ipv6/ip6_fib.c:1142 fib6_add_rt2node_nh net/ipv6/ip6_fib.c:1363 [inline] fib6_add+0x910/0x18c0 net/ipv6/ip6_fib.c:1531 __ip6_ins_rt net/ipv6/route.c:1351 [inline] ip6_route_add+0xde/0x1b0 net/ipv6/route.c:3957 inet6_rtm_newroute+0x268/0x19e0 net/ipv6/route.c:5660 rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6958 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa68/0xad0 net/socket.c:2592 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f9316b9aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffd8809b678 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f9316e15fa0 RCX: 00007f9316b9aeb9 RDX: 0000000000000000 RSI: 0000200000004380 RDI: 0000000000000003 RBP: 00007f9316c08c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f9316e15fac R14: 00007f9316e15fa0 R15: 00007f9316e15fa0 </TASK> Allocated by task 5499: kasan_save_stack mm/kasan/common.c:57 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5657 [inline] __kmalloc_noprof+0x40c/0x7e0 mm/slub.c:5669 kmalloc_noprof include/linux/slab.h:961 [inline] kzalloc_noprof include/linux/slab.h:1094 [inline] fib6_info_alloc+0x30/0xf0 net/ipv6/ip6_fib.c:155 ip6_route_info_create+0x142/0x860 net/ipv6/route.c:3820 ip6_route_add+0x49/0x1b0 net/ipv6/route.c:3949 inet6_rtm_newroute+0x268/0x19e0 net/ipv6/route.c:5660 rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6958 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa68/0xad0 net/socket.c:2592 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- net/ipv6/ip6_fib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_fib.c +1 -1
@@ -1137,7 +1137,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,fib6_add_gc_list (iter); }if (!(rt->fib6_flags & (RTF_ADDRCONF |RTF_PREFIX_RT )) && - !iter->fib6_nh->fib_nh_gw_family) { + (iter->nh || !iter->fib6_nh->fib_nh_gw_family)) { iter->fib6_flags &= ~RTF_ADDRCONF ; iter->fib6_flags &= ~RTF_PREFIX_RT ; }
Signature · 1 line
2.51.0
PATCH 270/283 net: sparx5/lan969x: fix PTP clock max_adj value
In reply to Sasha LevinFrom: Daniel Machon <[email protected]>
[ Upstream commit a49d2a2c37a6252c41cbdd505f9d1c58d5a3817a ]
The max_adj field in ptp_clock_info tells userspace how much the PHC clock frequency can be adjusted. ptp4l reads this and will never request a correction larger than max_adj.
On both sparx5 and lan969x the clock offset may never converge because the servo needs a frequency correction larger than the current max_adj of 200000 (200 ppm) allows. The servo rails at the max and the offset stays in the tens of microseconds.
The hardware has no inherent max adjustment limit; frequency correction is done by writing a 64-bit clock period increment to CLK_PER_CFG, and the register has plenty of range. The 200000 value was just an overly conservative software limit. The max_adj is shared between sparx5 and lan969x, and the increased value is safe for both.
Fix this by increasing max_adj to 10000000 (10000 ppm), giving the servo sufficient headroom.
--- drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c +1 -1
@@ -562,7 +562,7 @@ static int sparx5_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)static struct ptp_clock_info sparx5_ptp_clock_info = { .owner =THIS_MODULE , .name ="sparx5 ptp" , - .max_adj =200000 , + .max_adj =10000000 , .gettime64 = sparx5_ptp_gettime64, .settime64 = sparx5_ptp_settime64, .adjtime = sparx5_ptp_adjtime,
Signature · 1 line
2.51.0
PATCH 271/283 net: usb: catc: enable basic endpoint checking
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 9e7021d2aeae57c323a6f722ed7915686cdcc123 ]
catc_probe() fills three URBs with hardcoded endpoint pipes without verifying the endpoint descriptors:
- usb_sndbulkpipe(usbdev, 1) and usb_rcvbulkpipe(usbdev, 1) for TX/RX
- usb_rcvintpipe(usbdev, 2) for interrupt status
A malformed USB device can present these endpoints with transfer types that differ from what the driver assumes.
Add a catc_usb_ep enum for endpoint numbers, replacing magic constants throughout. Add usb_check_bulk_endpoints() and usb_check_int_endpoints() calls after usb_set_interface() to verify endpoint types before use, rejecting devices with mismatched descriptors at probe time.
Similar to
- commit 90b7f2961798 ("net: usb: rtl8150: enable basic endpoint checking") which fixed the issue in rtl8150.
--- drivers/net/usb/catc.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
drivers/net/usb/catc.c +31 -6
@@ -64,6 +64,16 @@ static const char driver_name[] = "catc";#define CTRL_QUEUE 16/* Max control requests in flight (power of two) */ #define RX_PKT_SZ 1600/* Max size of receive packet for F5U011 */ +/* +* USB endpoints. +*/ + +enum catc_usb_ep { +CATC_USB_EP_CONTROL =0 , +CATC_USB_EP_BULK =1 , +CATC_USB_EP_INT_IN =2 , +}; +/* * Control requests. */
@@ -772,6 +782,13 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idu8 broadcast[ETH_ALEN ];u8 *macbuf;int pktsz, ret = -ENOMEM ; +static const u8 bulk_ep_addr[] = { +CATC_USB_EP_BULK |USB_DIR_OUT , +CATC_USB_EP_BULK |USB_DIR_IN , +0 }; +static const u8 int_ep_addr[] = { +CATC_USB_EP_INT_IN |USB_DIR_IN , +0 }; macbuf =kmalloc (ETH_ALEN ,GFP_KERNEL );if (!macbuf)
@@ -784,6 +801,14 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id goto fail_mem; } +/* Verify that all required endpoints are present */ +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr) || + !usb_check_int_endpoints (intf, int_ep_addr)) { +dev_err (dev,"Missing or invalid endpoints\n" ); + ret = -ENODEV ; + goto fail_mem; + } + netdev =alloc_etherdev (sizeof (struct catc ));if (!netdev) goto fail_mem;
@@ -828,14 +853,14 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idusb_fill_control_urb (catc->ctrl_urb, usbdev,usb_sndctrlpipe (usbdev,0 ),NULL ,NULL ,0 , catc_ctrl_done, catc); -usb_fill_bulk_urb (catc->tx_urb, usbdev,usb_sndbulkpipe (usbdev,1 ), -NULL ,0 , catc_tx_done, catc); +usb_fill_bulk_urb (catc->tx_urb, usbdev,usb_sndbulkpipe (usbdev,CATC_USB_EP_BULK ), +NULL ,0 , catc_tx_done, catc); -usb_fill_bulk_urb (catc->rx_urb, usbdev,usb_rcvbulkpipe (usbdev,1 ), - catc->rx_buf, pktsz, catc_rx_done, catc); +usb_fill_bulk_urb (catc->rx_urb, usbdev,usb_rcvbulkpipe (usbdev,CATC_USB_EP_BULK ), + catc->rx_buf, pktsz, catc_rx_done, catc); -usb_fill_int_urb (catc->irq_urb, usbdev,usb_rcvintpipe (usbdev,2 ), - catc->irq_buf,2 , catc_irq_done, catc,1 ); +usb_fill_int_urb (catc->irq_urb, usbdev,usb_rcvintpipe (usbdev,CATC_USB_EP_INT_IN ), + catc->irq_buf,2 , catc_irq_done, catc,1 );if (!catc->is_f5u011) {u32 *buf;
Signature · 1 line
2.51.0
PATCH 272/283 xen-netback: reject zero-queue configuration from guest
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 6d1dc8014334c7fb25719999bca84d811e60a559 ]
A malicious or buggy Xen guest can write "0" to the xenbus key "multi-queue-num-queues". The connect() function in the backend only validates the upper bound (requested_num_queues > xenvif_max_queues) but not zero, allowing requested_num_queues=0 to reach vzalloc(array_size(0, sizeof(struct xenvif_queue))), which triggers WARN_ON_ONCE(!size) in __vmalloc_node_range().
On systems with panic_on_warn=1, this allows a guest-to-host denial of service.
The Xen network interface specification requires
the queue count to be "greater than zero".
Add a zero check to match the validation already present in xen-blkback, which has included this
guard since its multi-queue support was added.
--- drivers/net/xen-netback/xenbus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/xen-netback/xenbus.c +3 -2
@@ -735,10 +735,11 @@ static void connect(struct backend_info *be)*/ requested_num_queues =xenbus_read_unsigned (dev->otherend,"multi-queue-num-queues" ,1 ); -if (requested_num_queues > xenvif_max_queues) { +if (requested_num_queues > xenvif_max_queues || + requested_num_queues ==0 ) {/* buggy or malicious guest */ xenbus_dev_fatal (dev, -EINVAL , -"guest requested %u queues, exceeding the maximum of %u." , +"guest requested %u queues, but valid range is 1 - %u." , requested_num_queues, xenvif_max_queues);return ; }
Signature · 1 line
2.51.0
PATCH 273/283 net/rds: rds_sendmsg should not discard payload_len
In reply to Sasha LevinFrom: Allison Henderson <[email protected]>
[ Upstream commit da29e453dcb3aa7cabead7915f5f945d0add3a52 ]
Commit 3db6e0d172c9 ("rds: use RCU to synchronize work-enqueue with connection teardown") modifies rds_sendmsg to avoid enqueueing work while a tear down is in progress. However, it also changed the return value of rds_sendmsg to that of rds_send_xmit instead of the payload_len. This means the user may incorrectly receive errno values when it should have simply received a payload of 0 while the peer attempts a reconnections. So this patch corrects the teardown handling code to only use the out error path in that case, thus restoring the original payload_len return value.
--- net/rds/send.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/rds/send.c +4 -2
@@ -1382,9 +1382,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)else queue_delayed_work (rds_wq, &cpath->cp_send_w,1 );rcu_read_unlock (); + +if (ret) + goto out; } -if (ret) - goto out; +rds_message_put (rm);for (ind =0 ; ind < vct.indx; ind++)
Signature · 1 line
2.51.0
PATCH 274/283 net: bridge: mcast: always update mdb_n_entries for vlan contexts
In reply to Sasha LevinFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 8b769e311a86bb9d15c5658ad283b86fc8f080a2 ]
syzbot triggered a warning[1] about the number of mdb entries in a context. It turned out that there are multiple ways to trigger that warning today (some got added during the years), the root cause of the problem is that the increase is done conditionally, and over the years these different conditions increased so there were new ways to trigger the warning, that is to do a decrease which wasn't paired with a previous increase.
For example one way to trigger it is with flush:
$ ip l add br0 up type bridge vlan_filtering 1 mcast_snooping 1
$ ip l add dumdum up master br0 type dummy
$ bridge mdb add dev br0 port dumdum grp 239.0.0.1 permanent vid 1
$ ip link set dev br0 down
$ ip link set dev br0 type bridge mcast_vlan_snooping 1
^^^^ this will enable snooping, but will not update mdb_n_entries
because in __br_multicast_enable_port_ctx() we check !netif_running
$ bridge mdb flush dev br0
^^^ this will trigger the warning because it will delete the pg which
we added above, which will try to decrease mdb_n_entriesFix the problem by removing the conditional increase and always keep the count up-to-date while the vlan exists. In order to do that we have to first initialize it on port-vlan context creation, and then always increase or decrease the value regardless of mcast options. To keep the current behaviour we have to enforce the mdb limit only if the context is port's or if the port-vlan's mcast snooping is enabled.
[1]
------------[ cut here ]------------ n == 0 WARNING: net/bridge/br_multicast.c:718 at br_multicast_port_ngroups_dec_one net/bridge/br_multicast.c:718 [inline], CPU#0: syz.4.4607/22043 WARNING: net/bridge/br_multicast.c:718 at br_multicast_port_ngroups_dec net/bridge/br_multicast.c:771 [inline], CPU#0: syz.4.4607/22043 WARNING: net/bridge/br_multicast.c:718 at br_multicast_del_pg+0x1bbe/0x1e20 net/bridge/br_multicast.c:825, CPU#0: syz.4.4607/22043 Modules linked in: CPU: 0 UID: 0 PID: 22043 Comm: syz.4.4607 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/24/2026 RIP: 0010:br_multicast_port_ngroups_dec_one net/bridge/br_multicast.c:718 [inline] RIP: 0010:br_multicast_port_ngroups_dec net/bridge/br_multicast.c:771 [inline] RIP: 0010:br_multicast_del_pg+0x1bbe/0x1e20 net/bridge/br_multicast.c:825 Code: 41 5f 5d e9 04 7a 48 f7 e8 3f 73 5c f7 90 0f 0b 90 e9 cf fd ff ff e8 31 73 5c f7 90 0f 0b 90 e9 16 fd ff ff e8 23 73 5c f7 90 <0f> 0b 90 e9 60 fd ff ff e8 15 73 5c f7 eb 05 e8 0e 73 5c f7 48 8b RSP: 0018:ffffc9000c207220 EFLAGS: 00010293 RAX: ffffffff8a68042d RBX: ffff88807c6f1800 RCX: ffff888066e90000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffff888066e90000 R09: 000000000000000c R10: 000000000000000c R11: 0000000000000000 R12: ffff8880303ef800 R13: dffffc0000000000 R14: ffff888050eb11c4 R15: 1ffff1100a1d6238 FS: 00007fa45921b6c0(0000) GS:ffff8881256f5000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa4591f9ff8 CR3: 0000000081df2000 CR4: 00000000003526f0 Call Trace: <TASK> br_mdb_flush_pgs net/bridge/br_mdb.c:1525 [inline] br_mdb_flush net/bridge/br_mdb.c:1544 [inline] br_mdb_del_bulk+0x5e2/0xb20 net/bridge/br_mdb.c:1561 rtnl_mdb_del+0x48a/0x640 net/core/rtnetlink.c:-1 rtnetlink_rcv_msg+0x77e/0xbe0 net/core/rtnetlink.c:6967 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa68/0xad0 net/socket.c:2592 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fa45839aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa45921b028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fa458615fa0 RCX: 00007fa45839aeb9 RDX: 0000000000000000 RSI: 00002000000000c0 RDI: 0000000000000004 RBP: 00007fa458408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fa458616038 R14: 00007fa458615fa0 R15: 00007fff0b59fae8 </TASK>
--- net/bridge/br_multicast.c | 45 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 27 deletions(-)
net/bridge/br_multicast.c +18 -27
@@ -243,14 +243,11 @@ br_multicast_port_vid_to_port_ctx(struct net_bridge_port *port, u16 vid)lockdep_assert_held_once (&port->br->multicast_lock); -if (!br_opt_get (port->br,BROPT_MCAST_VLAN_SNOOPING_ENABLED )) -return NULL ; -/* Take RCU to access the vlan. */ rcu_read_lock (); vlan =br_vlan_find (nbp_vlan_group_rcu (port), vid); -if (vlan && !br_multicast_port_ctx_vlan_disabled (&vlan->port_mcast_ctx)) +if (vlan) pmctx = &vlan->port_mcast_ctx;rcu_read_unlock ();
@@ -700,7 +697,10 @@ br_multicast_port_ngroups_inc_one(struct net_bridge_mcast_port *pmctx,u32 max =READ_ONCE (pmctx->mdb_max_entries);u32 n =READ_ONCE (pmctx->mdb_n_entries); -if (max && n >= max) { +/* enforce the max limit when it's a port pmctx or a port-vlan pmctx +* with snooping enabled +*/ +if (!br_multicast_port_ctx_vlan_disabled (pmctx) && max && n >= max) {NL_SET_ERR_MSG_FMT_MOD (extack,"%s is already in %u groups, and mcast_max_groups=%u" , what, n, max);return -E2BIG ;
@@ -735,9 +735,7 @@ static int br_multicast_port_ngroups_inc(struct net_bridge_port *port,return err; } -/* Only count on the VLAN context if VID is given, and if snooping on -* that VLAN is enabled. -*/ +/* Only count on the VLAN context if VID is given */ if (!group->vid)return 0 ;
@@ -2009,6 +2007,18 @@ void br_multicast_port_ctx_init(struct net_bridge_port *port,timer_setup (&pmctx->ip6_own_query.timer, br_ip6_multicast_port_query_expired,0 );#endif +/* initialize mdb_n_entries if a new port vlan is being created */ +if (vlan) { +struct net_bridge_port_group *pg; +u32 n =0 ; + +spin_lock_bh (&port->br->multicast_lock); +hlist_for_each_entry (pg, &port->mglist, mglist) +if (pg->key.addr.vid == vlan->vid) + n++; +WRITE_ONCE (pmctx->mdb_n_entries, n); +spin_unlock_bh (&port->br->multicast_lock); + } }void br_multicast_port_ctx_deinit (struct net_bridge_mcast_port *pmctx)
@@ -2092,25 +2102,6 @@ static void __br_multicast_enable_port_ctx(struct net_bridge_mcast_port *pmctx)br_ip4_multicast_add_router (brmctx, pmctx);br_ip6_multicast_add_router (brmctx, pmctx); } - -if (br_multicast_port_ctx_is_vlan (pmctx)) { -struct net_bridge_port_group *pg; -u32 n =0 ; - -/* The mcast_n_groups counter might be wrong. First, -* BR_VLFLAG_MCAST_ENABLED is toggled before temporary entries -* are flushed, thus mcast_n_groups after the toggle does not -* reflect the true values. And second, permanent entries added -* while BR_VLFLAG_MCAST_ENABLED was disabled, are not reflected -* either. Thus we have to refresh the counter. -*/ - -hlist_for_each_entry (pg, &pmctx->port->mglist, mglist) { -if (pg->key.addr.vid == pmctx->vlan->vid) - n++; - } -WRITE_ONCE (pmctx->mdb_n_entries, n); - } }static void br_multicast_enable_port_ctx (struct net_bridge_mcast_port *pmctx)
Signature · 1 line
2.51.0
PATCH 275/283 selftests: forwarding: vxlan_bridge_1d: fix test failure with br_netfilter enabled
In reply to Sasha LevinFrom: Aleksei Oladko <[email protected]>
[ Upstream commit 02cb2e6bacbb08ebf6acb61be816efd11e1f4a21 ]
The test generates VXLAN traffic using mausezahn, where the encapsulated inner IPv4 packet contains a zero IP header checksum. After VXLAN decapsulation, such packets do not pass sanity checks in br_netfilter and are dropped, which causes the test to fail.
Fix this by calculating and setting a valid IPv4 header checksum for the encapsulated packet generated by mausezahn, so that the packet is accepted by br_netfilter. Fixed by using the payload_template_calc_checksum() / payload_template_expand_checksum() helpers that are only available in v6.3 and newer kernels.
--- .../net/forwarding/vxlan_bridge_1d.sh | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +16 -10
@@ -559,6 +559,21 @@ vxlan_encapped_ping_do() local inner_tos=$1; shift local outer_tos=$1; shift + local ipv4hdr=$(: + )"45:"$( : IP version + IHL + )"$inner_tos:"$( : IP TOS + )"00:54:"$( : IP total length + )"99:83:"$( : IP identification + )"40:00:"$( : IP flags + frag off + )"40:"$( : IP TTL + )"01:"$( : IP proto + )"CHECKSUM:"$( : IP header csum + )"c0:00:02:03:"$( : IP saddr: 192.0.2.3 + )"c0:00:02:01"$( : IP daddr: 192.0.2.1 + ) + local checksum=$(payload_template_calc_checksum "$ipv4hdr") + ipv4hdr=$(payload_template_expand_checksum "$ipv4hdr" $checksum) + $MZ $dev -c $count -d 100msec -q \ -b $next_hop_mac -B $dest_ip \ -t udp tos=$outer_tos,sp=23456,dp=$VXPORT,p=$(:
@@ -569,16 +584,7 @@ vxlan_encapped_ping_do() )"$dest_mac:"$( : ETH daddr )"$(mac_get w2):"$( : ETH saddr )"08:00:"$( : ETH type - )"45:"$( : IP version + IHL - )"$inner_tos:"$( : IP TOS - )"00:54:"$( : IP total length - )"99:83:"$( : IP identification - )"40:00:"$( : IP flags + frag off - )"40:"$( : IP TTL - )"01:"$( : IP proto - )"00:00:"$( : IP header csum - )"c0:00:02:03:"$( : IP saddr: 192.0.2.3 - )"c0:00:02:01:"$( : IP daddr: 192.0.2.1 + )"$ipv4hdr:"$( : IPv4 header )"08:"$( : ICMP type )"00:"$( : ICMP code )"8b:f2:"$( : ICMP csum
Signature · 1 line
2.51.0
PATCH 276/283 selftests: forwarding: vxlan_bridge_1d_ipv6: fix test failure with br_netfilter enabled
In reply to Sasha LevinFrom: Aleksei Oladko <[email protected]>
[ Upstream commit ce9f6aec0fb780dafc1dfc5f47c688422aff464a ]
The test generates VXLAN traffic using mausezahn, where the encapsulated inner IPv6 packet has an incorrect payload length set in the IPv6 header. After VXLAN decapsulation, such packets do not pass sanity checks in br_netfilter and are dropped, which causes the test to fail.
Fix this by setting the correct IPv6 payload length for the encapsulated packet generated by mausezahn, so that the packet is accepted by br_netfilter.
tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh lines 698-706
)"00:03:"$( : Payload length
)"3a:"$( : Next header
)"04:"$( : Hop limit
)"$saddr:"$( : IP saddr
)"$daddr:"$( : IP daddr
)"80:"$( : ICMPv6.type
)"00:"$( : ICMPv6.code
)"00:"$( : ICMPv6.checksum
)Data after IPv6 header:
• 80: — 1 byte (ICMPv6 type)
• 00: — 1 byte (ICMPv6 code)
• 00: — 1 byte (ICMPv6 checksum, truncated)
Total: 3 bytes → 00:03 is correct. The old value 00:08 did not match the actual payload size.
--- tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh +1 -1
@@ -695,7 +695,7 @@ vxlan_encapped_ping_do() )"6"$( : IP version )"$inner_tos"$( : Traffic class )"0:00:00:"$( : Flow label - )"00:08:"$( : Payload length + )"00:03:"$( : Payload length )"3a:"$( : Next header )"04:"$( : Hop limit )"$saddr:"$( : IP saddr
Signature · 1 line
2.51.0
PATCH 277/283 netfilter: nf_conntrack_h323: don't pass uninitialised l3num value
In reply to Sasha LevinFrom: Florian Westphal <[email protected]>
[ Upstream commit a6d28eb8efe96b3e35c92efdf1bfacb0cccf541f ]
Mihail Milev reports: Error: UNINIT (CWE-457):
net/netfilter/nf_conntrack_h323_main.c:1189:2: var_decl:
Declaring variable "tuple" without initializer.
net/netfilter/nf_conntrack_h323_main.c:1197:2:
uninit_use_in_call: Using uninitialized value "tuple.src.l3num" when calling "__nf_ct_expect_find".
net/netfilter/nf_conntrack_expect.c:142:2:
read_value: Reading value "tuple->src.l3num" when calling "nf_ct_expect_dst_hash".
1195| tuple.dst.protonum = IPPROTO_TCP; 1196| 1197|-> exp = __nf_ct_expect_find(net, nf_ct_zone(ct), &tuple); 1198| if (exp && exp->master == ct) 1199| return exp;
Switch this to a C99 initialiser and set the l3num value.
--- net/netfilter/nf_conntrack_h323_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/nf_conntrack_h323_main.c +5 -5
@@ -1186,13 +1186,13 @@ static struct nf_conntrack_expect *find_expect(struct nf_conn *ct, {struct net *net =nf_ct_net (ct);struct nf_conntrack_expect *exp; -struct nf_conntrack_tuple tuple; +struct nf_conntrack_tuple tuple = { + .src.l3num =nf_ct_l3num (ct), + .dst.protonum =IPPROTO_TCP , + .dst.u.tcp.port = port, + }; -memset (&tuple.src.u3,0 ,sizeof (tuple.src.u3)); - tuple.src.u.tcp.port =0 ;memcpy (&tuple.dst.u3, addr,sizeof (tuple.dst.u3)); - tuple.dst.u.tcp.port = port; - tuple.dst.protonum =IPPROTO_TCP ; exp =__nf_ct_expect_find (net,nf_ct_zone (ct), &tuple);if (exp && exp->master == ct)
Signature · 1 line
2.51.0
PATCH 278/283 net: remove WARN_ON_ONCE when accessing forward path array
In reply to Sasha LevinFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 008e7a7c293b30bc43e4368dac6ea3808b75a572 ]
Although unlikely, recent support for IPIP tunnels increases chances of reaching this WARN_ON_ONCE if userspace manages to build a sufficiently long forward path.
Remove it.
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -701,7 +701,7 @@ static struct net_device_path *dev_fwd_path(struct net_device_path_stack *stack) {int k = stack->num_paths++; -if (WARN_ON_ONCE (k >=NET_DEVICE_PATH_STACK_MAX )) +if (k >=NET_DEVICE_PATH_STACK_MAX )return NULL ;return &stack->path[k];
Signature · 1 line
2.51.0
PATCH 279/283 netfilter: nf_tables: fix use-after-free in nf_tables_addchain()
In reply to Sasha LevinFrom: Inseo An <[email protected]>
[ Upstream commit 71e99ee20fc3f662555118cf1159443250647533 ]
nf_tables_addchain() publishes the chain to table->chains via list_add_tail_rcu() (in nft_chain_add()) before registering hooks. If nf_tables_register_hook() then fails, the error path calls nft_chain_del() (list_del_rcu()) followed by nf_tables_chain_destroy() with no RCU grace period in between.
This creates two use-after-free conditions:
1) Control-plane: nf_tables_dump_chains() traverses table->chains under rcu_read_lock(). A concurrent dump can still be walking the chain when the error path frees it.
2) Packet path: for NFPROTO_INET, nf_register_net_hook() briefly installs the IPv4 hook before IPv6 registration fails. Packets entering nft_do_chain() via the transient IPv4 hook can still be dereferencing chain->blob_gen_X when the error path frees the chain.
Add synchronize_rcu() between nft_chain_del() and the chain destroy so that all RCU readers -- both dump threads and in-flight packet evaluation -- have finished before the chain is freed.
--- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_tables_api.c +1 -0
@@ -2581,6 +2581,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, err_register_hook:nft_chain_del (chain); +synchronize_rcu (); err_chain_add:nft_trans_destroy (trans); err_trans:
Signature · 1 line
2.51.0
PATCH 280/283 ipv6: fix a race in ip6_sock_set_v6only()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 452a3eee22c57a5786ae6db5c97f3b0ec13bb3b7 ]
It is unlikely that this function will be ever called with isk->inet_num being not zero.
Perform the check on isk->inet_num inside the locked section for complete safety.
--- include/net/ipv6.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/net/ipv6.h +7 -4
@@ -1293,12 +1293,15 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex,static inline int ip6_sock_set_v6only (struct sock *sk) { -if (inet_sk (sk)->inet_num) -return -EINVAL ; +int ret =0 ; +lock_sock (sk); - sk->sk_ipv6only = true; +if (inet_sk (sk)->inet_num) + ret = -EINVAL ; +else + sk->sk_ipv6only = true;release_sock (sk); -return 0 ; +return ret; }static inline void ip6_sock_set_recverr (struct sock *sk)
Signature · 1 line
2.51.0
PATCH 281/283 bpftool: Fix truncated netlink dumps
In reply to Sasha LevinFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 3b39d73cc3379360a33eb583b17f21fe55e1288e ]
Netlink requires that the recv buffer used during dumps is at least min(PAGE_SIZE, 8k) (see the man page). Otherwise the messages will get truncated. Make sure bpftool follows this requirement, avoid missing information on systems with large pages.
--- tools/bpf/bpftool/net.c | 5 ++++- tools/lib/bpf/netlink.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
tools/bpf/bpftool/net.c +4 -1
@@ -150,7 +150,7 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,bool multipart = true;struct nlmsgerr *err;struct nlmsghdr *nh; -char buf[4096 ]; +char buf[8192 ];int len, ret;while (multipart) {
@@ -195,6 +195,9 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,return ret; } } + +if (len) +p_err ("Invalid message or trailing data in Netlink response: %d bytes left" , len); } ret =0 ; done:
tools/lib/bpf/netlink.c +3 -1
@@ -143,7 +143,7 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,struct nlmsghdr *nh;int len, ret; - ret =alloc_iov (&iov,4096 ); + ret =alloc_iov (&iov,8192 );if (ret) goto done;
@@ -212,6 +212,8 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq, } } } +if (len) +pr_warn ("Invalid message or trailing data in Netlink response: %d bytes left\n" , len); } ret =0 ; done:
Signature · 1 line
2.51.0
PATCH 282/283 ping: annotate data-races in ping_lookup()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit ad5dfde2a5733aaf652ea3e40c8c5e071e935901 ]
isk->inet_num, isk->inet_rcv_saddr and sk->sk_bound_dev_if are read locklessly in ping_lookup().
Add READ_ONCE()/WRITE_ONCE() annotations.
The race on isk->inet_rcv_saddr is probably coming from IPv6 support, but does not deserve a specific backport.
--- net/ipv4/ping.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
net/ipv4/ping.c +19 -12
@@ -159,7 +159,7 @@ void ping_unhash(struct sock *sk)pr_debug ("ping_unhash(isk=%p,isk->num=%u)\n" , isk, isk->inet_num);spin_lock (&ping_table.lock);if (sk_del_node_init_rcu (sk)) { - isk->inet_num =0 ; +WRITE_ONCE (isk->inet_num,0 ); isk->inet_sport =0 ;sock_prot_inuse_add (sock_net (sk), sk->sk_prot,-1 ); }
@@ -192,31 +192,35 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident) } sk_for_each_rcu(sk, hslot) { + int bound_dev_if; + if (!net_eq(sock_net(sk), net)) continue; isk = inet_sk(sk); pr_debug("iterate\n"); - if (isk->inet_num != ident) + if (READ_ONCE(isk->inet_num) != ident) continue; + bound_dev_if = READ_ONCE(sk->sk_bound_dev_if); if (skb->protocol == htons(ETH_P_IP) && sk->sk_family == AF_INET) { + __be32 rcv_saddr = READ_ONCE(isk->inet_rcv_saddr); + pr_debug("found: %p: num=%d, daddr=%pI4, dif=%d\n", sk, - (int) isk->inet_num, &isk->inet_rcv_saddr, - sk->sk_bound_dev_if); + ident, &rcv_saddr, + bound_dev_if); - if (isk->inet_rcv_saddr && - isk->inet_rcv_saddr != ip_hdr(skb)->daddr) + if (rcv_saddr && rcv_saddr != ip_hdr(skb)->daddr) continue; #if IS_ENABLED(CONFIG_IPV6) } else if (skb->protocol == htons(ETH_P_IPV6) && sk->sk_family == AF_INET6) { pr_debug("found: %p: num=%d, daddr=%pI6c, dif=%d\n", sk, - (int) isk->inet_num, + ident, &sk->sk_v6_rcv_saddr, - sk->sk_bound_dev_if); + bound_dev_if); if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr) && !ipv6_addr_equal(&sk->sk_v6_rcv_saddr,
@@ -227,8 +231,8 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident)continue ; } -if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif && - sk->sk_bound_dev_if != sdif) +if (bound_dev_if && bound_dev_if != dif && + bound_dev_if != sdif)continue ; goto exit;
@@ -403,7 +407,9 @@ static void ping_set_saddr(struct sock *sk, struct sockaddr *saddr)if (saddr->sa_family ==AF_INET ) {struct inet_sock *isk =inet_sk (sk);struct sockaddr_in *addr = (struct sockaddr_in *) saddr; - isk->inet_rcv_saddr = isk->inet_saddr = addr->sin_addr.s_addr; + + isk->inet_saddr = addr->sin_addr.s_addr; +WRITE_ONCE (isk->inet_rcv_saddr, addr->sin_addr.s_addr);#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr->sa_family == AF_INET6) {struct sockaddr_in6 *addr = (struct sockaddr_in6 *) saddr;
@@ -860,7 +866,8 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,struct sk_buff *skb;int copied, err; -pr_debug ("ping_recvmsg(sk=%p,sk->num=%u)\n" , isk, isk->inet_num); +pr_debug ("ping_recvmsg(sk=%p,sk->num=%u)\n" , isk, +READ_ONCE (isk->inet_num)); err = -EOPNOTSUPP ;if (flags &MSG_OOB )
Signature · 1 line
2.51.0
PATCH 283/283 Linux 6.6.128-rc1
In reply to Sasha Levin--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 6 PATCHLEVEL = 6 -SUBLEVEL = 127 -EXTRAVERSION = +SUBLEVEL = 128 +EXTRAVERSION = -rc1 NAME = Pinguïn Aangedreven # *DOCUMENTATION*
Signature · 1 line
2.51.0