7.3.6-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 510/2651 staging: iio: adc: ad7816: Fix DMA safety issues in SPI transfers
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdelnasser Hussein <[email protected]>
[ Upstream commit 69fa76f0af3414cc189c3b0b807cb59e327ecc00 ]
The SPI operations in this driver are not DMA safe:
1. spi_read() uses a stack-allocated buffer.
2. spi_write() in ad7816_spi_read() uses a struct member that shares a cacheline with other variables.
3. spi_write() in ad7816_spi_write() passes a stack parameter by reference.
Fix these violations by replacing all spi_read() and spi_write() calls with spi_write_then_read(). This safely handles DMA by internally allocating a bounce buffer for the transfers, avoiding cacheline sharing issues without needing dedicated aligned buffers. This implicitly corrects the size argument in read to sizeof(buf).
--- drivers/staging/iio/adc/ad7816.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7816.c +3 -3
@@ -69,7 +69,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)gpiod_set_value (chip->rdwr_pin,1 );gpiod_set_value (chip->rdwr_pin,0 ); - ret =spi_write (spi_dev, &chip->channel_id,sizeof (chip->channel_id)); + ret =spi_write_then_read (spi_dev, &chip->channel_id,sizeof (chip->channel_id),NULL ,0 );if (ret <0 ) {dev_err (&spi_dev->dev,"SPI channel setting error\n" );return ret;
@@ -91,7 +91,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)gpiod_set_value (chip->rdwr_pin,0 );gpiod_set_value (chip->rdwr_pin,1 ); - ret =spi_read (spi_dev, &buf,sizeof (*data)); + ret =spi_write_then_read (spi_dev,NULL ,0 , &buf,sizeof (buf));if (ret <0 ) {dev_err (&spi_dev->dev,"SPI data read error\n" );return ret;
@@ -109,7 +109,7 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data)gpiod_set_value (chip->rdwr_pin,1 );gpiod_set_value (chip->rdwr_pin,0 ); - ret =spi_write (spi_dev, &data,sizeof (data)); + ret =spi_write_then_read (spi_dev, &data,sizeof (data),NULL ,0 );if (ret <0 )dev_err (&spi_dev->dev,"SPI oti data write error\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/2651 selftests/bpf: Wait for links to come up in lwt_ip_encap
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit 71b75648d1a21c0a6379741d00f41086ec95f14a ]
lwt_ip_encap creates three fresh netns with veth pairs across them and then immediately pings over IPv6. The peer ends of the first veth pair end up with the same ifindex in their respective netns, so linkwatch does not treat the carrier-on as urgent and may deliver NETDEV_CHANGE up to one second later. Until that happens addrconf considers the link not
ready: no ff00::/8 multicast route and no link-local address are installed, and the neighbour solicitation for the next hop is dropped as a no-route packet. The NS retransmit a second later succeeds, but ping -W1 has already given up:
check_ping_ok:FAIL:ip netns exec ns-lwt-ip-encap-1-... ping -6 -c 1 -W1 -I veth1 fb04::1 > /dev/null unexpected error: 256 (errno 2) lwt_ip_encap:FAIL:ping OK unexpected error: -1 (errno 2)
#226/1 lwt_ip_encap_ipv4/egress:FAIL
This reproduces reliably when the test is run standalone on an idle system where setup completes well within a second. The original shell script had a "sleep 1 # reduce flakiness" after setup which was lost in the conversion to test_progs.
Instead of sleeping, poll SIOCGIFFLAGS for IFF_RUNNING on all veths at the end of setup_network() so traffic is only sent once every link is operationally up.
--- .../selftests/bpf/prog_tests/lwt_ip_encap.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+)
tools/testing/selftests/bpf/prog_tests/lwt_ip_encap.c +53 -0
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only +#include <net/if.h> #include <netinet/in.h> +#include <sys/ioctl.h> #include "network_helpers.h" #include "test_progs.h"
@@ -141,6 +143,54 @@ static int set_bottom_addr(const char *ns1, const char *ns2, const char *ns3)return 1 ; } +/* +* A veth whose peer sits in another netns with the same ifindex gets its +* carrier-on handled as a non-urgent linkwatch event, i.e. up to 1s late. +* Until then IPv6 considers the link not ready (no ff00::/8 route, no +* link-local address) and silently drops neighbour solicitations, so wait +* for all links to be operationally up (IFF_RUNNING) before sending traffic. +*/ +static int wait_for_oper_up (const char *ns,const char *dev) +{ +struct nstoken *nstoken; +struct ifreq ifr = {}; +int i, fd, ret =-1 ; + + nstoken =open_netns (ns); +if (!ASSERT_OK_PTR (nstoken,"open ns" )) +return -1 ; + + fd =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (!ASSERT_OK_FD (fd,"socket" )) + goto out; + +strncpy (ifr.ifr_name, dev,IFNAMSIZ -1 ); +for (i =0 ; i <50 ; i++) { +if (!ASSERT_OK (ioctl (fd,SIOCGIFFLAGS , &ifr),"SIOCGIFFLAGS" )) +break ; +if (ifr.ifr_flags &IFF_RUNNING ) { + ret =0 ; +break ; + } +usleep (100000 ); + } +close (fd); +out: +ASSERT_OK (ret, dev); +close_netns (nstoken); +return ret; +} + +static int wait_for_links (const char *ns1,const char *ns2,const char *ns3) +{ +if (wait_for_oper_up (ns1,"veth1" ) ||wait_for_oper_up (ns1,"veth5" ) || +wait_for_oper_up (ns2,"veth2" ) ||wait_for_oper_up (ns2,"veth3" ) || +wait_for_oper_up (ns2,"veth6" ) ||wait_for_oper_up (ns2,"veth7" ) || +wait_for_oper_up (ns3,"veth4" ) ||wait_for_oper_up (ns3,"veth8" )) +return -1 ; +return 0 ; +} +static int configure_vrf (const char *ns1,const char *ns2) {if (!ns1 || !ns2)
@@ -304,6 +354,9 @@ static int setup_network(char *ns1, char *ns2, char *ns3, const char *vrf)if (!ASSERT_OK (configure_ns3 (ns3),"configure ns3 routes" )) goto fail; +if (!ASSERT_OK (wait_for_links (ns1, ns2, ns3),"wait for links" )) + goto fail; +/* Link bottom route to the GRE tunnels */ SYS (fail,"ip -n %s route add %s/32 dev veth5 via %s %s" , ns1,IP4_ADDR_GRE ,IP4_ADDR_6 , vrf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/2651 md/raid10: fix missing wakeup in wait_barrier_nolock
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit f00eb0ff45793383d5a62db2d2aea63ada0ccdbd ]
Fuzz testing triggered a hung raid10d thread:
INFO: task md0_raid10 blocked for more than 120 seconds. Call Trace: raid10d md_thread kthread
wait_barrier_nolock() speculatively increments nr_pending. If a concurrent writer changes resync_lock's sequence, it rolls the count back with atomic_dec_and_test(). The rollback currently wakes wait_barrier only when nr_pending reaches zero.
freeze_array() can be waiting for nr_pending == nr_queued + extra while array_freeze_pending is set. If the rollback changes nr_pending from 2 to 1, the condition becomes true but no wakeup is sent, leaving raid10d blocked indefinitely.
Also wake wait_barrier when array_freeze_pending is set, matching allow_barrier().
--- drivers/md/raid10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid10.c +2 -1
@@ -1010,7 +1010,8 @@ static bool wait_barrier_nolock(struct r10conf *conf)if (!read_seqretry (&conf->resync_lock, seq))return true; -if (atomic_dec_and_test (&conf->nr_pending)) +if (atomic_dec_and_test (&conf->nr_pending) || +READ_ONCE (conf->array_freeze_pending))wake_up_barrier (conf);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/2651 md: reject v0.90 arrays with too many devices
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 1a33a379e67853d6d778e6e80b214bdf1208f6f8 ]
The v0.90 superblock has room for MD_SB_DISKS device descriptors, but super_90_load() only rejects nonpositive raid_disks values. A crafted superblock can therefore copy a larger value into mddev->raid_disks. When metadata is next updated, super_90_sync() walks sb->disks[] up to that count and reads and writes beyond the 4 KiB superblock buffer.
A checksum-valid RAID1 member advertising 64 devices can be assembled by mdadm --incremental --run. The first write to the array then produces out-of-bounds writes from super_90_sync() under KASAN.
Reject device counts that cannot be represented by the v0.90 format while loading the superblock.
--- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
@@ -1393,7 +1393,7 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor goto abort; } -if (sb->raid_disks <=0 ) +if (sb->raid_disks <=0 || sb->raid_disks >MD_SB_DISKS ) goto abort;if (md_csum_fold (calc_sb_csum (sb)) !=md_csum_fold (sb->sb_csum)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/2651 md/raid0: validate device count before allocating devlist
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandradhar Kumar <[email protected]>
[ Upstream commit cf5963d6781ddee4c59a61debc459fcc7580f7b6 ]
create_strip_zones() allocates conf->devlist based on mddev->raid_disks before verifying that number of devices matches raid_disks. Move the existing device count validation before allocation to reject invalid configurations before attempting a potentially excessive allocation.
--- drivers/md/raid0.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/md/raid0.c +11 -5
@@ -79,7 +79,10 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) *private_conf =ERR_PTR (-ENOMEM );if (!conf)return -ENOMEM ; + + cnt =0 ;rdev_for_each (rdev1, mddev) { + cnt++;pr_debug ("md/raid0:%s: looking at %pg\n" ,mdname (mddev), rdev1->bdev);
@@ -144,6 +147,14 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) } err = -ENOMEM ; + +if (cnt != mddev->raid_disks) { +pr_warn ("md/raid0:%s: too few disks (%d of %d) - aborting!\n" , +mdname (mddev), cnt, mddev->raid_disks); + err = -EINVAL ; + goto abort; + } + conf->strip_zone = kvzalloc_objs(struct strip_zone, conf->nr_strip_zones);if (!conf->strip_zone) goto abort;
@@ -200,11 +211,6 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) smallest = rdev1; cnt++; } -if (cnt != mddev->raid_disks) { -pr_warn ("md/raid0:%s: too few disks (%d of %d) - aborting!\n" , -mdname (mddev), cnt, mddev->raid_disks); - goto abort; - } zone->nb_dev = cnt; zone->zone_end = smallest->sectors * cnt;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/2651 md/raid5: dont BUG() on an inconsistent reshape state from the superblock
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 0669c7dbd1d375f279e607a24addc2f1dae2d4f3 ]
raid5_run() branches on mddev->reshape_position. When it is MaxSector -- no reshape in progress -- the else branch asserts that nothing else describes one:
BUG_ON(mddev->level != mddev->new_level); BUG_ON(mddev->layout != mddev->new_layout); BUG_ON(mddev->chunk_sectors != mddev->new_chunk_sectors); BUG_ON(mddev->delta_disks != 0);
Nothing enforces that invariant. Both superblock validators copy the reshape fields straight off disk without cross-checking them against each other: super_1_validate() takes reshape_position, delta_disks, new_level, new_layout and new_chunk from the superblock whenever MD_FEATURE_RESHAPE_ACTIVE is set, and super_90_validate() does the same for minor version 91. A superblock that sets the reshape feature while leaving reshape_position at the MaxSector sentinel therefore reaches the else branch with a non-zero delta_disks, and assembling the array takes the machine down:
kernel BUG at drivers/md/raid5.c:8117!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:raid5_run+0x11a7/0x1670 drivers/md/raid5.c:8117 Call Trace: md_run+0xc2f/0x2510 drivers/md/md.c:6779 do_md_run+0x36/0x660 drivers/md/md.c:6880 array_state_store+0x9c5/0xcf0 drivers/md/md.c:4765 md_attr_store+0x1c5/0x330 drivers/md/md.c:6158 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345
This is reachable by anyone who can present an md superblock, so BUG() is the wrong response. Refuse to start the array instead, the way the reshape_position != MaxSector branch a few lines above already refuses a reshape it cannot resume. Nothing has been allocated at this point -- the journal-and-bitmap check just above returns -EINVAL the same way -- so there is nothing to unwind.
--- drivers/md/raid5.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/md/raid5.c +11 -5
@@ -8112,11 +8112,17 @@ static int raid5_run(struct mddev *mddev) }pr_debug ("md/raid:%s: reshape will continue\n" ,mdname (mddev));/* OK, we should be able to continue; */ - }else { -BUG_ON (mddev->level != mddev->new_level); -BUG_ON (mddev->layout != mddev->new_layout); -BUG_ON (mddev->chunk_sectors != mddev->new_chunk_sectors); -BUG_ON (mddev->delta_disks !=0 ); + }else if (mddev->level != mddev->new_level || + mddev->layout != mddev->new_layout || + mddev->chunk_sectors != mddev->new_chunk_sectors || + mddev->delta_disks !=0 ) { +/* No reshape is in progress, but the array describes one. +* The superblock validators do not cross-check these against +* reshape_position, so this is reachable from disk. +*/ +pr_warn ("md/raid:%s: inconsistent reshape state - aborting.\n" , +mdname (mddev)); +return -EINVAL ; } if (test_bit(MD_HAS_JOURNAL, &mddev->flags) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/2651 md/raid5: reject raid4/5 arrays with too few disks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Cheng <[email protected]>
[ Upstream commit 0d9bbbb6fafa22659ccd4d7ab94329a43c2632d0 ]
raid4 and raid5 require at least two disks, while raid6 requires at least four disks. setup_conf() only rejects raid6 arrays with fewer than four disks. As a result, an invalid raid4 or raid5 array can be assembled with no data disks and later reach raid5_set_limits().
Reject such arrays before the r5conf is created. This prevents the invalid geometry from reaching queue limit setup, where roundup_pow_of_two() can be called with a zero stripe size.
--- drivers/md/raid5.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/raid5.c +5 -3
@@ -7659,9 +7659,11 @@ static struct r5conf *setup_conf(struct mddev *mddev) mdname(mddev), mddev->new_layout);return ERR_PTR (-EIO ); } -if (mddev->new_level ==6 && mddev->raid_disks <4 ) { -pr_warn ("md/raid:%s: not enough configured devices (%d, minimum 4)\n" , -mdname (mddev), mddev->raid_disks); +if ((mddev->new_level !=6 && mddev->raid_disks <2 ) || + (mddev->new_level ==6 && mddev->raid_disks <4 )) { +pr_warn ("md/raid:%s: not enough configured devices (%d, minimum %d)\n" , +mdname (mddev), mddev->raid_disks, + mddev->new_level ==6 ?4 :2 );return ERR_PTR (-EINVAL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/2651 md/raid5: setup_conf: Fix null-ptr-def in error handling path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit eba5f518701b1c7f2d883504f89c41611bd2de46 ]
For raid5 setup_conf, if an error(eg. bioset_init fails) happens before 'conf->mddev = mddev', following error handling path could trigger a null-ptr-def problem:
free_conf
log_exit
raid5_has_ppl
test_bit(MD_HAS_PPL, &conf->mddev->flags) // conf->mddev is NULL !
Fix it by initializing conf->mddev in advance.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -7679,6 +7679,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)if (conf ==NULL ) goto abort; + conf->mddev = mddev;#if PAGE_SIZE !=DEFAULT_STRIPE_SIZE conf->stripe_size =DEFAULT_STRIPE_SIZE ; conf->stripe_shift =ilog2 (DEFAULT_STRIPE_SIZE ) -9 ;
@@ -7747,7 +7748,6 @@ static struct r5conf *setup_conf(struct mddev *mddev) ret =bioset_init (&conf->bio_split,BIO_POOL_SIZE ,0 ,0 );if (ret) goto abort; - conf->mddev = mddev; ret = -ENOMEM ; conf->stripe_hashtbl =kzalloc (PAGE_SIZE ,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 518/2651 md/raid5: reject a per-device size smaller than one chunk
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit 370ca0760b18c64592a258bcb057ff0a2531aabf ]
Both raid5_run() and raid5_resize() align the per-device size down to a whole multiple of the chunk size:
mddev->dev_sectors &= ~(chunk_sectors - 1);
Neither checks the result, so a size smaller than one chunk silently becomes zero.
In raid5_run() that is harmless: the array size is derived from the same zero, so the disk just ends up with no capacity.
In raid5_resize() it leaves the array inconsistent -- mddev->dev_sectors becomes zero, while mddev->array_sectors and the gendisk capacity keep the previous. A later raid4/raid5 -> raid0 takeover copies the zero into every rdev->sectors (raid0_takeover_raid45()), so create_strip_zones() builds a strip zone table whose zone_end is zero. Any read then passes bio_check_eod() against the stale capacity and hits the BUG() in find_zone():
kernel BUG at drivers/md/raid0.c:318!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI Call Trace: raid0_make_request md_handle_request submit_bio_noacct_nocheck block_read_full_folio read_part_sector bdev_disk_changed bdev_open
Reject a size smaller than one chunk in both functions, so that a running raid4/raid5 array always has mddev->dev_sectors >= one chunk.
The check is done where the value takes effect, not where it is assigned. mddev->dev_sectors is written from several places, and none of them can tell whether the value is usable: the chunk size may still change later. raid5_run() and raid5_resize() are where every input is final, so one check in each covers them all.
--- drivers/md/raid5.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/md/raid5.c +8 -0
@@ -8213,6 +8213,12 @@ static int raid5_run(struct mddev *mddev)/* device size must be a multiple of chunk size */ mddev->dev_sectors &= ~((sector_t )mddev->chunk_sectors -1 ); +if (!mddev->dev_sectors) { +pr_warn ("md/raid:%s: device size is smaller than one chunk\n" , +mdname (mddev)); + ret = -EINVAL ; + goto abort; + } mddev->resync_max_sectors = mddev->dev_sectors; if (mddev->degraded > dirty_parity_disks &&
@@ -8546,6 +8552,8 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)if (raid5_has_log (conf) ||raid5_has_ppl (conf))return -EINVAL ; sectors &= ~((sector_t )conf->chunk_sectors -1 ); +if (!sectors) +return -EINVAL ; newsize =raid5_size (mddev, sectors, mddev->raid_disks);if (mddev->external_size && mddev->array_sectors > newsize)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/2651 kernfs: dont hold kernfs_rwsem across notification delivery
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 23985e2b1f31623468244a2149b2388cda4925eb ]
Recently at Meta we noticed that on multi-tenant systems, a workload under extreme memory pressure negatively impacts unrelated workloads and system daemons like below [1] and fb-oomd [2]. Mainly we observed that system daemons were stuck on kernfs_rwsem in cgroup-related interfaces for long periods of time.
On further inspection, we found that the workload under pressure had registered inotify watches on its memory.events and was continuously receiving limit-hitting notifications. The cgroup notification is done in kernfs_notify_workfn(), which holds kernfs_supers_rwsem and kernfs_rwsem and calls fsnotify(), which allocates the event with kmalloc(GFP_KERNEL_ACCOUNT|__GFP_RETRY_MAYFAIL) charged to the watching cgroup, which is already under memory pressure. So the notify worker ended up in memory reclaim of a cgroup already under pressure, and itself kept triggering the limit notifications.
This notification path takes the locks in read mode, but a waiting writer blocks all future readers. That is exactly what is happening in the Meta fleet, and it leaves daemons that are critical to the reliability of the system stuck for long periods of time.
Commit 400188ae361a ("kernfs: Acquire kernfs_rwsem in kernfs_notify_workfn().") added kernfs_rwsem just to safely read kernfs_node::name. Let's sample the name once before the loop and drop the lock. kernfs_supers_rwsem still covers the list, and the removal paths take that one for reading too, so a stalled worker can still hold a removal up once a mount or unmount is queued behind it.
Two things change for a watcher. A name longer than NAME_MAX now gives an event with no name, where before it gave one with the full name; fsnotify() takes the name as optional, so the event still arrives. And the name and the parent are no longer sampled under one lock, so a rename between the two would name a file against the directory it moved to. That cannot happen today: kernfs_notify() rejects anything that is not a file, and no caller of kernfs_rename_ns() renames one.
[1] https://github.com/facebookincubator/below
[2] https://github.com/facebookincubator/oomd
--- fs/kernfs/file.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
fs/kernfs/file.c +16 -9
@@ -904,9 +904,12 @@ static loff_t kernfs_fop_llseek(struct file *file, loff_t offset, int whence)static void kernfs_notify_workfn (struct work_struct *work) { -struct kernfs_node *kn; +char name_buf[NAME_MAX +1 ];struct kernfs_super_info *info; +struct kernfs_node *kn;struct kernfs_root *root; +struct qstr name; +bool have_name; repeat:/* pop one off the notify_list */ spin_lock_irq (&kernfs_notify_lock);
@@ -922,14 +925,20 @@ static void kernfs_notify_workfn(struct work_struct *work) root =kernfs_root (kn);/* kick fsnotify */ +/* +* Sample the name once so kernfs_rwsem need not be held across the +* loop. A name that does not fit is reported without one; fsnotify() +* takes the name as optional, so a watcher loses the name and not the +* event. +*/ + have_name =kernfs_name (kn, name_buf,sizeof (name_buf)) >=0 ; + name =QSTR (name_buf); +down_read (&root->kernfs_supers_rwsem); -down_read (&root->kernfs_rwsem); -list_for_each_entry (info, &kernfs_root (kn)->supers, node) { +list_for_each_entry (info, &root->supers, node) {struct kernfs_node *parent;struct inode *p_inode =NULL ; -const char *kn_name;struct inode *inode; -struct qstr name;/* * We want fsnotify_modify() on @kn but as the
@@ -941,15 +950,14 @@ static void kernfs_notify_workfn(struct work_struct *work)if (!inode)continue ; - kn_name =kernfs_rcu_name (kn); - name =QSTR (kn_name); parent =kernfs_get_parent (kn);if (parent) { p_inode =ilookup (info->sb,kernfs_ino (parent));if (p_inode) {fsnotify (FS_MODIFY |FS_EVENT_ON_CHILD , inode,FSNOTIFY_EVENT_INODE , - p_inode, &name, inode,0 ); + p_inode, have_name ? &name :NULL , + inode,0 );iput (p_inode); }
@@ -962,7 +970,6 @@ static void kernfs_notify_workfn(struct work_struct *work)iput (inode); } -up_read (&root->kernfs_rwsem);up_read (&root->kernfs_supers_rwsem);kernfs_put (kn); goto repeat;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/2651 kernfs: dont repeat or skip an entry when readdir resumes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 5ebcb578adeec7407dd501108ab2f423ca8e3e55 ]
readdir keeps its place as a name hash in ctx->pos and pins the entry in file->private_data. If that entry is gone when the listing comes back, kernfs_dir_pos() searches the rbtree for the hash and keeps whatever node the descent stopped on. That is the entry before or after the missing one, depending on the shape of the tree.
Landing before it repeats an entry the previous getdents(2) call already reported. Landing after it, kernfs_dir_next_pos() calls rb_next() and steps over an unreported entry.
With children A(10), B(20), C(30):
report A, ctx->pos = 10
A removed
kernfs_dir_next_pos(10, A)
A is gone, the search for 10 stops at B
rb_next(B) -> C, so B is never reported
Only the repeat happens today, between two getdents(2) calls. The skip needs the pinned entry to go away inside one call, which the next patch allows when it drops kernfs_rwsem around dir_emit().
Before the commit 4e4d6d860b93 the descent kept a node only on the way left, which is a search for the first entry at or after the hash. That commit moved the assignment to the top of the loop, where it runs on right turns too. Restore that search, and step forward only when the pinned entry is still there rather than when the hash matches, since two entries in one directory can share a hash.
While here, kernfs_dir_next_pos() called the hash @ino. It is never an inode number, so name it @hash.
--- fs/kernfs/dir.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-)
fs/kernfs/dir.c +28 -15
@@ -1915,9 +1915,16 @@ static int kernfs_dir_fop_release(struct inode *inode, struct file *filp)return 0 ; } +/* +* Find where a listing left off. @resumed says whether @pos is still that +* entry; if not, the first entry at or after @hash is returned instead. +*/ static struct kernfs_node *kernfs_dir_pos (const struct ns_common *ns, -struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos) +struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos, +bool *resumed) { +if (resumed) + *resumed = false;if (pos) {int valid =kernfs_active (pos) && rcu_access_pointer(pos->__parent) == parent &&
@@ -1925,23 +1932,26 @@ static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns,kernfs_put (pos);if (!valid) pos =NULL ; +else if (resumed) + *resumed = true; }if (!pos && (hash >1 ) && (hash <INT_MAX )) {struct rb_node *node = parent->dir.children.rb_node; -u64 ns_id =kernfs_ns_id (ns); + +/* +* Keep a node only on the way left, so the search ends on the +* first entry at or after @hash. The empty name sorts before +* every entry sharing the hash, so it lands on the first. +*/ while (node) { - pos =rb_to_kn (node); +struct kernfs_node *kn =rb_to_kn (node); -if (hash < pos->hash) +if (kernfs_name_compare (hash,"" , ns, kn) <0 ) { + pos = kn; node = node->rb_left; -else if (hash > pos->hash) + }else { node = node->rb_right; -else if (ns_id <kernfs_ns_id (pos->ns)) - node = node->rb_left; -else if (ns_id >kernfs_ns_id (pos->ns)) - node = node->rb_right; -else -break ; + } } }/* Skip over entries which are dying/dead or in the wrong namespace */
@@ -1957,10 +1967,13 @@ static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns, }static struct kernfs_node *kernfs_dir_next_pos (const struct ns_common *ns, -struct kernfs_node *parent,ino_t ino,struct kernfs_node *pos) +struct kernfs_node *parent,loff_t hash,struct kernfs_node *pos) { - pos =kernfs_dir_pos (ns, parent, ino, pos); -if (pos) { +bool resumed; + + pos =kernfs_dir_pos (ns, parent, hash, pos, &resumed); +/* Step over @pos only if it survived; two entries can share a hash. */ +if (pos && resumed) { do { struct rb_node *node = rb_next(&pos->rb); if (!node)
@@ -1990,7 +2003,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)if (kernfs_ns_enabled (parent)) ns =kernfs_info (dentry->d_sb)->ns; -for (pos =kernfs_dir_pos (ns, parent, ctx->pos, pos); +for (pos =kernfs_dir_pos (ns, parent, ctx->pos, pos,NULL ); pos; pos =kernfs_dir_next_pos (ns, parent, ctx->pos, pos)) {const char *name =kernfs_rcu_name (pos);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/2651 kernfs: dont hold kernfs_rwsem across dir_emit()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 341c65579de5b632eb7913bb68b3e375eeeb3ddf ]
kernfs_fop_readdir() holds kernfs_rwsem for reading across the whole listing, dir_emit() included. dir_emit() copies to userspace, so it can fault into reclaim while holding the lock that every create, remove and rename in the hierarchy needs. sysfs and cgroupfs have one per machine.
Under memory pressure the monitoring daemons fault on their own getdents(2) buffer with it held:
below: page allocation stall for 120 secs: order:0,
mode:0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO|__GFP_COMP)
nodemask=(null),cpuset=hostcritical.slice,mems_allowed=0
Call Trace:
<TASK>
dump_stack_lvl+0x5d/0x80
__alloc_frozen_pages_noprof+0x5f4d/0x6300
? memcg_list_lru_alloc+0x73/0x320
? ima_file_check+0xd0/0x7d0
vma_alloc_folio_noprof+0x145/0x560
handle_mm_fault+0x17c9/0x2720
? find_vma+0x27/0x30
do_user_addr_fault+0x39f/0x6e0
exc_page_fault+0x8f/0x110
asm_exc_page_fault+0x22/0x30
RIP: 0010:filldir64+0xd7/0x1a0
[Code:/RSP:/RAX:..R15: register block elided]
kernfs_fop_readdir+0x2de/0x420
iterate_dir+0x8c/0x1f0
__se_sys_getdents64+0x61/0xe0
? copy_page_from_iter+0x860/0x860
do_syscall_64+0x6a/0x250
entry_SYSCALL_64_after_hwframe+0x4b/0x53
</TASK>Commit 9aab10a0249e ("kernfs: Don't re-lock kernfs_root::kernfs_rwsem in kernfs_fop_readdir().") took the lock drop out because dir_emit() was handed kernfs_node::name, which a rename can free. The previous patch emits a copy instead, so drop the lock around dir_emit().
A listing is no longer atomic within one getdents(2) call, which for most sysfs and cgroup directories is all of it. POSIX leaves that unspecified for an entry added or removed since opendir(3).
--- fs/kernfs/dir.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/kernfs/dir.c +7 -3
@@ -2015,10 +2015,14 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx) file->private_data = pos;kernfs_get (pos); -if (!dir_emit (ctx, name, len, ino, type)) { -up_read (&root->kernfs_rwsem); +/* +* dir_emit() can fault, so run it unlocked. @pos is pinned +* above and kernfs_dir_pos() rechecks it on the way back. +*/ +up_read (&root->kernfs_rwsem); +if (!dir_emit (ctx, name, len, ino, type))return 0 ; - } +down_read (&root->kernfs_rwsem); }up_read (&root->kernfs_rwsem); file->private_data =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/2651 ASoC: SOF: amd: return -EINVAL for unknown PCI revision in acp7x suspend
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit e419e9a6cbfe1d0947dd5ab8dabe9a5ed4b4f572 ]
amd_sof_acp7x_suspend() is registered only for ACP7.B and ACP7.F platforms. If an unexpected PCI revision reaches the switch statement the default case previously fell through, leaving ACP_CONTROL with a stale value (enable=false) before writing ZSC_DSP_CTRL=1. Return -EINVAL instead to surface the programming error immediately.
--- sound/soc/sof/amd/acp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sof/amd/acp.c +2 -1
@@ -1197,7 +1197,8 @@ int amd_sof_acp7x_suspend(struct snd_sof_dev *sdev, u32 target_state) enable = true;break ;default : -break ; +dev_err (sdev->dev,"Unexpected PCI revision: 0x%x\n" , acp_data->pci_rev); +return -EINVAL ; }snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACP_CONTROL , enable);snd_sof_dsp_write (sdev,ACP_DSP_BAR ,ACP7X_ZSC_DSP_CTRL ,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/2651 ASoC: SOF: amd: fix amd_sof_acp_remove() teardown ordering
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit db2167f2e3f72db64d01356cc9f2924d32fd5a51 ]
Call free_irq() before amd_sof_sdw_exit() in amd_sof_acp_remove(). amd_sof_sdw_exit() sets adata->sdw to NULL; if an IRQ fires between that point and the subsequent free_irq(), acp_irq_handler() may dereference the now-NULL pdev[] pointer, causing a use-after-free.
--- sound/soc/sof/amd/acp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/amd/acp.c +3 -3
@@ -1048,12 +1048,12 @@ void amd_sof_acp_remove(struct snd_sof_dev *sdev) {struct acp_dev_data *adata = sdev->pdata->hw_pdata; -if (adata->sdw) -amd_sof_sdw_exit (sdev); -if (sdev->ipc_irq)free_irq (sdev->ipc_irq, sdev); +if (adata->sdw) +amd_sof_sdw_exit (sdev); +if (adata->dmic_dev)platform_device_unregister (adata->dmic_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/2651 ASoC: SOF: amd: fix amd_sof_acp_probe() error unwind ordering
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vijendar Mukunda <[email protected]>
[ Upstream commit b6aaef8ca8c305170de83e621c7e16d56731312a ]
Call amd_sof_sdw_exit() after free_irq() in the free_ipc_irq error label of amd_sof_acp_probe(). Without this, an IRQ that fires between sdw context teardown and free_irq() can dereference freed SoundWire resources.
--- sound/soc/sof/amd/acp.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/amd/acp.c +2 -0
@@ -1038,6 +1038,8 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) free_ipc_irq:free_irq (sdev->ipc_irq, sdev); +if (adata->sdw) +amd_sof_sdw_exit (sdev); unregister_dev:platform_device_unregister (adata->dmic_dev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/2651 ASoC: mediatek: mt8189: Propagate APLL enable errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5a3c23d4aa89cdb7a3f2a42465c2cabcb71ebcdd ]
mt8189_apll1_enable() and mt8189_apll2_enable() currently ignore errors from regmap_update_bits() and do not clean up resources when clock enable operations fail.
Propagate these errors and roll back the clocks and tuner state on errors.
--- sound/soc/mediatek/mt8189/mt8189-afe-clk.c | 78 ++++++++++++++++------ 1 file changed, 56 insertions(+), 22 deletions(-)
sound/soc/mediatek/mt8189/mt8189-afe-clk.c +56 -22
@@ -454,30 +454,47 @@ int mt8189_apll1_enable(struct mtk_base_afe *afe) ret =mt8189_afe_enable_top_cg (afe,MT8189_CG_APLL1_CK );if (ret) -return ret; + goto err_clear_mux_setting; ret =mt8189_afe_enable_top_cg (afe,MT8189_PDN_APLL_TUNER1 );if (ret) -return ret; + goto err_disable_apll1_ck;/* sel 44.1kHz:1, apll_div:7, upper bound:3 */ -regmap_update_bits (afe->regmap,AFE_APLL1_TUNER_CFG , -XTAL_EN_128FS_SEL_MASK_SFT |APLL_DIV_MASK_SFT | -UPPER_BOUND_MASK_SFT , - (0x1 <<XTAL_EN_128FS_SEL_SFT ) | (7 <<APLL_DIV_SFT ) | - (3 <<UPPER_BOUND_SFT )); + ret =regmap_update_bits (afe->regmap,AFE_APLL1_TUNER_CFG , +XTAL_EN_128FS_SEL_MASK_SFT |APLL_DIV_MASK_SFT | +UPPER_BOUND_MASK_SFT , + (0x1 <<XTAL_EN_128FS_SEL_SFT ) | (7 <<APLL_DIV_SFT ) | + (3 <<UPPER_BOUND_SFT )); +if (ret) + goto err_disable_apll_tuner1;/* apll1 freq tuner enable */ -regmap_update_bits (afe->regmap,AFE_APLL1_TUNER_CFG , -FREQ_TUNER_EN_MASK_SFT , -0x1 <<FREQ_TUNER_EN_SFT ); + ret =regmap_update_bits (afe->regmap,AFE_APLL1_TUNER_CFG , +FREQ_TUNER_EN_MASK_SFT , +0x1 <<FREQ_TUNER_EN_SFT ); +if (ret) + goto err_disable_apll_tuner1;/* audio apll1 on */ ret =mt8189_afe_enable_top_cg (afe,MT8189_AUDIO_APLL1_EN_ON );if (ret) -return ret; + goto err_clear_freq_tuner_en;return 0 ; + +err_clear_freq_tuner_en: +regmap_update_bits (afe->regmap,AFE_APLL1_TUNER_CFG , +FREQ_TUNER_EN_MASK_SFT , +0x0 ); +err_disable_apll_tuner1: +mt8189_afe_disable_top_cg (afe,MT8189_PDN_APLL_TUNER1 ); +err_disable_apll1_ck: +mt8189_afe_disable_top_cg (afe,MT8189_CG_APLL1_CK ); +err_clear_mux_setting: +apll1_mux_setting (afe, false); + +return ret; }void mt8189_apll1_disable (struct mtk_base_afe *afe)
@@ -506,30 +523,47 @@ int mt8189_apll2_enable(struct mtk_base_afe *afe) ret =mt8189_afe_enable_top_cg (afe,MT8189_CG_APLL2_CK );if (ret) -return ret; + goto err_clear_mux_setting; ret =mt8189_afe_enable_top_cg (afe,MT8189_PDN_APLL_TUNER2 );if (ret) -return ret; + goto err_disable_apll2_ck;/* sel 48kHz: 2, apll_div: 7, upper bound: 3*/ -regmap_update_bits (afe->regmap,AFE_APLL2_TUNER_CFG , -XTAL_EN_128FS_SEL_MASK_SFT |APLL_DIV_MASK_SFT | -UPPER_BOUND_MASK_SFT , - (0x2 <<XTAL_EN_128FS_SEL_SFT ) | (7 <<APLL_DIV_SFT ) | - (3 <<UPPER_BOUND_SFT )); + ret =regmap_update_bits (afe->regmap,AFE_APLL2_TUNER_CFG , +XTAL_EN_128FS_SEL_MASK_SFT |APLL_DIV_MASK_SFT | +UPPER_BOUND_MASK_SFT , + (0x2 <<XTAL_EN_128FS_SEL_SFT ) | (7 <<APLL_DIV_SFT ) | + (3 <<UPPER_BOUND_SFT )); +if (ret) + goto err_disable_apll_tuner2;/* apll2 freq tuner enable */ -regmap_update_bits (afe->regmap,AFE_APLL2_TUNER_CFG , -FREQ_TUNER_EN_MASK_SFT , -0x1 <<FREQ_TUNER_EN_SFT ); + ret =regmap_update_bits (afe->regmap,AFE_APLL2_TUNER_CFG , +FREQ_TUNER_EN_MASK_SFT , +0x1 <<FREQ_TUNER_EN_SFT ); +if (ret) + goto err_disable_apll_tuner2;/* audio apll2 on */ ret =mt8189_afe_enable_top_cg (afe,MT8189_AUDIO_APLL2_EN_ON );if (ret) -return ret; + goto err_clear_freq_tuner_en;return 0 ; + +err_clear_freq_tuner_en: +regmap_update_bits (afe->regmap,AFE_APLL2_TUNER_CFG , +FREQ_TUNER_EN_MASK_SFT , +0x0 ); +err_disable_apll_tuner2: +mt8189_afe_disable_top_cg (afe,MT8189_PDN_APLL_TUNER2 ); +err_disable_apll2_ck: +mt8189_afe_disable_top_cg (afe,MT8189_CG_APLL2_CK ); +err_clear_mux_setting: +apll2_mux_setting (afe, false); + +return ret; }void mt8189_apll2_disable (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/2651 ASoC: mediatek: mt8189: Propagate MCK enable errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit bd9a8d9def207a8d7eeaa4dda1c53c5b4fca4008 ]
mt8189_mck_enable() currently returns without restoring the clock state when setting the clock parent, enabling the divider, or setting the divider rate fails.
Propagate the error and disable clocks enabled by the function.
--- sound/soc/mediatek/mt8189/mt8189-afe-clk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8189/mt8189-afe-clk.c +11 -3
@@ -639,7 +639,7 @@ int mt8189_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate) ret =mt8189_afe_set_clk_parent (afe, afe_priv->clk[m_sel_id], afe_priv->clk[apll_clk_id]);if (ret) -return ret; + goto err_disable_m_sel_clk; }/* enable div, set rate */
@@ -650,13 +650,21 @@ int mt8189_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate) ret =mt8189_afe_enable_clk (afe, afe_priv->clk[div_clk_id]);if (ret) -return ret; + goto err_disable_m_sel_clk; ret =mt8189_afe_set_clk_rate (afe, afe_priv->clk[div_clk_id], rate);if (ret) -return ret; + goto err_disable_div_clk;return 0 ; + +err_disable_div_clk: +mt8189_afe_disable_clk (afe, afe_priv->clk[div_clk_id]); +err_disable_m_sel_clk: +if (m_sel_id >=0 ) +mt8189_afe_disable_clk (afe, afe_priv->clk[m_sel_id]); + +return ret; }int mt8189_mck_disable (struct mtk_base_afe *afe,int mck_id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/2651 ASoC: mediatek: mt8189: Validate MCK ID
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit b6b47040e897f18df1ed53c658ab5159b035b5d1 ]
mt8189_mck_disable() only checks for negative MCK IDs. Reject IDs outside the valid MCK range as well.
--- sound/soc/mediatek/mt8189/mt8189-afe-clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8189/mt8189-afe-clk.c +2 -2
@@ -675,8 +675,8 @@ int mt8189_mck_disable(struct mtk_base_afe *afe, int mck_id)dev_dbg (afe->dev,"mck_id: %d.\n" , mck_id); -if (mck_id <0 ) { -dev_err (afe->dev,"mck_id = %d < 0\n" , mck_id); +if (mck_id >=MT8189_MCK_NUM || mck_id <0 ) { +dev_err (afe->dev,"mck_id = %d\n" , mck_id);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/2651 ASoC: mediatek: mt8189: Propagate reg_rw clock errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 29de6666879997c9dc375344fd046363d0c3bcdb ]
mt8189_afe_enable_reg_rw_clk() currently ignores errors from clock enable and parent operations.
Propagate these errors and clean up the clocks before returning the error.
--- sound/soc/mediatek/mt8189/mt8189-afe-clk.c | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8189/mt8189-afe-clk.c +25 -6
@@ -700,17 +700,36 @@ int mt8189_mck_disable(struct mtk_base_afe *afe, int mck_id)int mt8189_afe_enable_reg_rw_clk (struct mtk_base_afe *afe) {struct mt8189_afe_private *afe_priv = afe->platform_priv; +int ret;/* bus clock for AFE internal access, like AFE SRAM */ -mt8189_afe_enable_clk (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS ]); -mt8189_afe_set_clk_parent (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS ], - afe_priv->clk[MT8189_CLK_TOP_CLK26M ]); + ret =mt8189_afe_enable_clk (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS ]); +if (ret) +return ret; + + ret =mt8189_afe_set_clk_parent (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS ], + afe_priv->clk[MT8189_CLK_TOP_CLK26M ]); +if (ret) + goto err_disable_audiointbus_clk; +/* enable audio clock source */ -mt8189_afe_enable_clk (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H ]); -mt8189_afe_set_clk_parent (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H ], - afe_priv->clk[MT8189_CLK_TOP_CLK26M ]); + ret =mt8189_afe_enable_clk (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H ]); +if (ret) + goto err_disable_audiointbus_clk; + + ret =mt8189_afe_set_clk_parent (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H ], + afe_priv->clk[MT8189_CLK_TOP_CLK26M ]); +if (ret) + goto err_disable_audio_h_clk;return 0 ; + +err_disable_audio_h_clk: +mt8189_afe_disable_clk (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIO_H ]); +err_disable_audiointbus_clk: +mt8189_afe_disable_clk (afe, afe_priv->clk[MT8189_CLK_TOP_MUX_AUDIOINTBUS ]); + +return ret; }int mt8189_afe_disable_reg_rw_clk (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/2651 ASoC: mediatek: mt8189: Propagate runtime resume errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 483e827b005f122755785a3b6094e2bc19eb7685 ]
mt8189_afe_runtime_resume() currently ignores errors from regmap operations and mt8189_afe_enable_main_clock().
Propagate these errors and clean up the state before returning the error.
--- sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8189/mt8189-afe-pcm.c +26 -6
@@ -2332,20 +2332,40 @@ static int mt8189_afe_runtime_resume(struct device *dev) }regcache_cache_only (afe->regmap, false); -regcache_sync (afe->regmap); + ret =regcache_sync (afe->regmap); +if (ret) + goto err_set_cache_only;/* set audio 26M request */ -regmap_update_bits (afe->regmap,AFE_SPM_CONTROL_REQ ,0x1 ,0x1 ); -regmap_update_bits (afe->regmap,AFE_CBIP_CFG0 ,0x1 ,0x1 ); + ret =regmap_update_bits (afe->regmap,AFE_SPM_CONTROL_REQ ,0x1 ,0x1 ); +if (ret) + goto err_set_cache_only; + + ret =regmap_update_bits (afe->regmap,AFE_CBIP_CFG0 ,0x1 ,0x1 ); +if (ret) + goto err_clear_26m_req;/* force cpu use 8_24 format when writing 32bit data */ -regmap_update_bits (afe->regmap,AFE_MEMIF_CON0 , -CPU_HD_ALIGN_MASK_SFT ,0 <<CPU_HD_ALIGN_SFT ); + ret =regmap_update_bits (afe->regmap,AFE_MEMIF_CON0 , +CPU_HD_ALIGN_MASK_SFT ,0 <<CPU_HD_ALIGN_SFT ); +if (ret) + goto err_clear_26m_req;/* enable AFE */ -mt8189_afe_enable_main_clock (afe); + ret =mt8189_afe_enable_main_clock (afe); +if (ret) + goto err_clear_26m_req;return 0 ; + +err_clear_26m_req: +regmap_update_bits (afe->regmap, +AFE_SPM_CONTROL_REQ ,0x1 ,0x0 ); +err_set_cache_only: +regcache_cache_only (afe->regmap, true); +mt8189_afe_disable_reg_rw_clk (afe); + +return ret; }static int mt8189_afe_component_probe (struct snd_soc_component *component)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/2651 ASoC: mediatek: mt8189: Propagate APLL errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 6347f276da8c6c3e6e8262b30b9cd14dfbc48248 ]
mtk_apll_event() currently ignores errors returned by the APLL enable functions.
Propagate these errors.
--- sound/soc/mediatek/mt8189/mt8189-dai-i2s.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8189/mt8189-dai-i2s.c +5 -2
@@ -485,6 +485,7 @@ static int mtk_apll_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;dev_dbg (cmpnt->dev,"%s(), name %s, event 0x%x\n" , __func__, w->name, event);
@@ -492,9 +493,11 @@ static int mtk_apll_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU :if (strcmp (w->name,APLL1_W_NAME ) ==0 ) -mt8189_apll1_enable (afe); + ret =mt8189_apll1_enable (afe);else -mt8189_apll2_enable (afe); + ret =mt8189_apll2_enable (afe); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :if (strcmp (w->name,APLL1_W_NAME ) ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 531/2651 ASoC: mediatek: mt8189: Propagate MCLK errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 65b9d4a783cc266d057a64c1f04f690e9abb1bd3 ]
mtk_mclk_en_event() currently ignores errors returned by the MCK enable and disable functions.
Propagate these errors.
--- sound/soc/mediatek/mt8189/mt8189-dai-i2s.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8189/mt8189-dai-i2s.c +5 -3
@@ -519,6 +519,7 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt);struct mtk_afe_i2s_priv *i2s_priv; +int ret;dev_dbg (cmpnt->dev,"%s(), name %s, event 0x%x\n" , __func__, w->name, event);
@@ -529,17 +530,18 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8189_mck_enable (afe, i2s_priv->mclk_id, i2s_priv->mclk_rate); + ret =mt8189_mck_enable (afe, i2s_priv->mclk_id, i2s_priv->mclk_rate);break ;case SND_SOC_DAPM_POST_PMD : i2s_priv->mclk_rate =0 ; -mt8189_mck_disable (afe, i2s_priv->mclk_id); + ret =mt8189_mck_disable (afe, i2s_priv->mclk_id);break ;default : + ret =0 ;break ; } -return 0 ; +return ret; }static const struct snd_soc_dapm_widget mtk_dai_i2s_widgets[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 532/2651 ASoC: mediatek: mt8189: Validate sysclk frequency
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 9c73b5a43c99f905ebeab4744a8ba0b28232b189 ]
A zero frequency causes a modulo-by-zero error when validating the I2S clock frequency. Reject it before performing the validation.
--- sound/soc/mediatek/mt8189/mt8189-dai-i2s.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/mediatek/mt8189/mt8189-dai-i2s.c +3 -0
@@ -1287,6 +1287,9 @@ static int mtk_dai_i2s_set_sysclk(struct snd_soc_dai *dai, dir != SND_SOC_CLOCK_OUT)return -EINVAL ; +if (!freq) +return -EINVAL ; + i2s_priv = afe_priv->dai_priv[dai->id];if (!i2s_priv)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 533/2651 ASoC: mediatek: mt8189: Propagate TDM clock errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 242d0280eabba05c085a51ad0a9c9a7a3afa7b03 ]
mtk_tdm_bck_en_event() and mtk_tdm_mck_en_event() currently ignore errors returned by the MCK enable and disable functions.
Propagate these errors.
--- sound/soc/mediatek/mt8189/mt8189-dai-tdm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8189/mt8189-dai-tdm.c +10 -6
@@ -261,22 +261,24 @@ static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,struct mt8189_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;dev_dbg (cmpnt->dev,"name %s, event 0x%x, dai_id %d, bck: %d\n" , w->name, event, dai_id, tdm_priv->bck_rate);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8189_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate); + ret =mt8189_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate);break ;case SND_SOC_DAPM_POST_PMD : -mt8189_mck_disable (afe, tdm_priv->bck_id); + ret =mt8189_mck_disable (afe, tdm_priv->bck_id);break ;default : + ret =0 ;break ; } -return 0 ; +return ret; } static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,
@@ -288,23 +290,25 @@ static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,struct mt8189_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;dev_dbg (cmpnt->dev,"name %s, event 0x%x, dai_id %d, mclk %d\n" , w->name, event, dai_id, tdm_priv->mclk_rate);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8189_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); + ret =mt8189_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate);break ;case SND_SOC_DAPM_POST_PMD : tdm_priv->mclk_rate =0 ; -mt8189_mck_disable (afe, tdm_priv->mclk_id); + ret =mt8189_mck_disable (afe, tdm_priv->mclk_id);break ;default : + ret =0 ;break ; } -return 0 ; +return ret; }static const struct snd_soc_dapm_widget mtk_dai_tdm_widgets[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 534/2651 ASoC: mediatek: mt8189: Validate TDM MCLK frequency
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 197ec30e1b608ade5d2eb9271d01c59480a6f9a1 ]
mtk_dai_tdm_cal_mclk() accepts zero or negative frequencies. Reject invalid frequencies before configuring the TDM clock.
--- sound/soc/mediatek/mt8189/mt8189-dai-tdm.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/mediatek/mt8189/mt8189-dai-tdm.c +3 -0
@@ -383,6 +383,9 @@ static int mtk_dai_tdm_cal_mclk(struct mtk_base_afe *afe,int apll;int apll_rate; +if (freq <=0 ) +return -EINVAL ; + apll =mt8189_get_apll_by_rate (afe, freq); apll_rate =mt8189_get_apll_rate (afe, apll);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/2651 spi: virtio: fix max frequency setting
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Valla <[email protected]>
[ Upstream commit 26f42ca8becd01877e762916865a168c1b6c4ff4 ]
The maximum transfer frequency is read from the virtio config space but never propagated to the SPI framework logic. Fix this behavior and drop the useless setting copy from the driver's private data.
--- drivers/spi/spi-virtio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-virtio.c +1 -3
@@ -33,8 +33,6 @@ struct virtio_spi_priv {struct virtqueue *vq;/* Copy of config space mode_func_supported */ u32 mode_func_supported; -/* Copy of config space max_freq_hz */ -u32 max_freq_hz; };static void virtio_spi_msg_done (struct virtqueue *vq)
@@ -304,7 +302,7 @@ static void virtio_spi_read_config(struct virtio_device *vdev)virtio_cread32 (vdev, offsetof(struct virtio_spi_config , bits_per_word_mask)); - priv->max_freq_hz = + ctrl->max_speed_hz =virtio_cread32 (vdev, offsetof(struct virtio_spi_config , max_freq_hz)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 536/2651 perf test: Skip data_type_profiling when the PMU cannot record memory events
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 29f320d221c1c4c082c7eafb2251fedf8a4868ec ]
The test's only guard matches "failed: no PMU supports the memory events", but a PMU that has memory events and refuses them per-thread, such as AMD IBS on kernels without the swfilt filter, falls through:
the script runs under 'set -e' and the bare 'perf mem record' aborts it through the EXIT trap, reporting a signal that never happened and turning "this PMU cannot record these events" into a test failure.
Skip when a trivial per-thread 'perf mem record' fails, and put the record and annotate calls in the condition of an 'if', where 'set -e' leaves them alone, so the remaining cases report their own failures instead of the first one aborting the run.
--- tools/perf/tests/shell/data_type_profiling.sh | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-)
tools/perf/tests/shell/data_type_profiling.sh +36 -10
@@ -19,6 +19,15 @@ perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX) perf mem record -o /dev/null -- true 2>&1 | \ grep -q "failed: no PMU supports the memory events" && exit 2 +# Skip if per-thread mem record is not supported on this PMU (e.g. AMD IBS +# needs system-wide '-a'): it is what the test records with below, and a +# failing record must not be reported as a test failure. +if ! perf mem record -o /dev/null -- true 2>/dev/null +then + echo "Skip: cannot record memory events on this PMU" + exit 2 +fi + cleanup() { rm -rf "${perfdata}" "${perfout}" rm -rf "${perfdata}".old
@@ -52,25 +61,42 @@ test_basic_annotate() { index=1 ;; esac + # Under 'set -e' a bare failing command aborts the script through the EXIT + # trap, so the commands that report a failure have to be the condition of + # an 'if' for that reporting to ever happen. if [ "x${mode}" == "xBasic" ] then - perf mem record -o "${perfdata}" ${testprogs[$index]} 2> /dev/null + if ! perf mem record -o "${perfdata}" ${testprogs[$index]} 2> /dev/null + then + echo "${mode} annotate [Failed: perf record]" + err=1 + return + fi else - perf mem record -o - ${testprogs[$index]} 2> /dev/null > "${perfdata}" - fi - if [ "x$?" != "x0" ] - then - echo "${mode} annotate [Failed: perf record]" - err=1 - return + if ! perf mem record -o - ${testprogs[$index]} 2> /dev/null > "${perfdata}" + then + echo "${mode} annotate [Failed: perf record]" + err=1 + return + fi fi # Generate the annotated output file if [ "x${mode}" == "xBasic" ] then - perf annotate --code-with-type -i "${perfdata}" --stdio --percent-limit 1 2> /dev/null > "${perfout}" + if ! perf annotate --code-with-type -i "${perfdata}" --stdio --percent-limit 1 2> /dev/null > "${perfout}" + then + echo "${mode} annotate [Failed: perf annotate]" + err=1 + return + fi else - perf annotate --code-with-type -i - --stdio 2> /dev/null --percent-limit 1 < "${perfdata}" > "${perfout}" + if ! perf annotate --code-with-type -i - --stdio 2> /dev/null --percent-limit 1 < "${perfdata}" > "${perfout}" + then + echo "${mode} annotate [Failed: perf annotate]" + err=1 + return + fi fi # check if it has the target data type
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/2651 clk: si521xx: correct the SI52147 OF output enable map
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 7a4cc47d715f08309089d40b8c29fb0ba79917db ]
The SI52147 data sheet assigns DIFF0 through DIFF3 output-enable bits to 0x17 in control register 1. The OF match data uses 0x15, leaving the DIFF2 bit out of the map, while the I2C ID table already uses the documented value.
Use 0x17 for the SI52147 OF entry so both enumeration paths expose the documented outputs.
--- drivers/clk/clk-si521xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-si521xx.c +1 -1
@@ -374,7 +374,7 @@ MODULE_DEVICE_TABLE(i2c, si521xx_id);static const struct of_device_id clk_si521xx_of_match[] = { { .compatible ="skyworks,si52144" , .data = (void *)SI521XX_OE_MAP (0x5 ,0xc0 ) }, { .compatible ="skyworks,si52146" , .data = (void *)SI521XX_OE_MAP (0x15 ,0xe0 ) }, - { .compatible ="skyworks,si52147" , .data = (void *)SI521XX_OE_MAP (0x15 ,0xf8 ) }, + { .compatible ="skyworks,si52147" , .data = (void *)SI521XX_OE_MAP (0x17 ,0xf8 ) }, { } };MODULE_DEVICE_TABLE (of, clk_si521xx_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/2651 clk: milbeaut: Return divider update timeouts
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 92d0998090d1716ee6b47174c10eb9415a12fca8 ]
m10v_clk_divider_set_rate() logs when the hardware does not clear its write-valid request, but still returns success to the clock framework. It also uses the sleeping poll helper while holding the divider spinlock.
Use the atomic poll helper under the lock and return its timeout so the rate change is not reported as successful before the hardware accepts it.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/clk/clk-milbeaut.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/clk/clk-milbeaut.c +6 -4
@@ -410,8 +410,8 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct m10v_clk_divider *divider =to_m10v_div (hw); -int value;unsigned long flags =0 ; +int value, ret =0 ;u32 val;u32 write_en =BIT (divider->width -1 );
@@ -433,8 +433,10 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,if (divider->write_valid_reg) {writel (M10V_DCHREQ , divider->write_valid_reg); -if (readl_poll_timeout (divider->write_valid_reg, val, - !val,M10V_UPOLL_RATE ,M10V_UTIMEOUT )) + ret =readl_poll_timeout_atomic (divider->write_valid_reg, val, + !val,M10V_UPOLL_RATE , +M10V_UTIMEOUT ); +if (ret)pr_err ("%s:%s couldn't stabilize\n" , __func__,clk_hw_get_name (hw)); }
@@ -444,7 +446,7 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,else __release (divider->lock); -return 0 ; +return ret; }static const struct clk_ops m10v_clk_divider_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/2651 clk: aspeed: ast2700: select AUXILIARY_BUS
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 4457ee2f99f7286d037ccde8c107481b6105fc15 ]
The AST2700 clock driver also exposes the SoC reset controller: it hands its register base to a reset auxiliary device via devm_auxiliary_device_create(), which the separate ASPEED reset driver (RESET_ASPEED) then binds to. That create call needs the auxiliary bus core (AUXILIARY_BUS), not the reset driver itself, but COMMON_CLK_AST2700 does not select AUXILIARY_BUS.
It builds today only because RESET_ASPEED selects AUXILIARY_BUS and is normally enabled alongside the clock driver. On a randconfig with COMMON_CLK_AST2700=y and RESET_ASPEED=n, nothing pulls the auxiliary bus in and the kernel fails to link:
ld: drivers/clk/aspeed/clk-ast2700.o: in function `ast2700_soc_clk_probe':
clk-ast2700.c:(.text+0x147c): undefined reference to `__devm_auxiliary_device_create'
Select AUXILIARY_BUS directly, as other clock drivers that create auxiliary devices do, so it builds regardless of the reset driver.
--- drivers/clk/aspeed/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/clk/aspeed/Kconfig +1 -0
@@ -15,6 +15,7 @@ config COMMON_CLK_ASPEED config COMMON_CLK_AST2700 bool "Clock driver for AST2700 SoC" depends on ARCH_ASPEED || COMPILE_TEST + select AUXILIARY_BUS help This driver provides support for clock on AST2700 SoC. The driver is responsible for managing the various clocks required
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/2651 perf record: Fix unhandled POLLHUP on non_perf_event descriptors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 3cbb16ccd7d8c7377058195b48c721e99ee158aa ]
When processing POLLHUP on a non_perf_event control descriptor, evlist__finalize_ctlfd() is invoked to finalize the setup, correctly setting the core evlist's poll array file descriptor to -1. However, this finalized teardown state is never propagated back to the individual thread's local replica of the pollfd array.
Consequently, on the next iteration of the main recording loop, record__update_evlist_pollfd_from_thread() performs a strict equivalence check between the core evlist's array and the thread's localized poll array, detecting that the fd values no longer match. This causes an immediate -EINVAL abort and a premature teardown.
Fix the underlying logic within record__update_evlist_pollfd_from_thread() to sustainably propagate the finalized teardown statuses (-1) originating from the core evlist back to the thread's localized poll structure. This correctly maintains synchronization and entirely prevents the unhandled index mismatch crashes.
Additionally, add a unit test that explicitly validates that fdarray__filter() preserves its invariants regarding fdarray_flag__nonfilterable items to guard against regressions.
--- tools/lib/api/fd/array.c | 4 ++++ tools/perf/builtin-record.c | 15 +++++++++++++++ tools/perf/tests/fdarray.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+)
tools/lib/api/fd/array.c +4 -0
@@ -116,6 +116,10 @@ int fdarray__filter(struct fdarray *fda, short revents,return 0 ;for (fd =0 ; fd < fda->nr; ++fd) { +/* +* Explicitly bypass nonfilterable items (e.g. control descriptors). +* This ensures their fd, events, and revents remain completely untouched. +*/ if (fda->priv[fd].flags & fdarray_flag__nonfilterable)continue ;
tools/perf/builtin-record.c +15 -0
@@ -1169,6 +1169,21 @@ static int record__update_evlist_pollfd_from_thread(struct record *rec,int e_pos = rec->index_map[i].evlist_pollfd_index;int t_pos = rec->index_map[i].thread_pollfd_index; +if (e_entries[e_pos].fd ==-1 || e_entries[e_pos].events ==0 ) { +/* +* If the control file descriptor was closed, then evlist__ctlfd_process() +* will have called evlist__finalize_ctlfd() on the PREVIOUS loop iteration +* to cleanly set the core evlist's e_entries[e_pos].fd to -1. +* +* Since nonfilterable items are skipped by fdarray__filter(), the +* thread's local t_entries[t_pos] retains its original state. +* We must explicitly propagate the finalized -1 state to t_entries +* BEFORE evaluating the strict equivalence check below. +*/ + t_entries[t_pos].fd =-1 ; + t_entries[t_pos].events =0 ; + } +if (e_entries[e_pos].fd != t_entries[t_pos].fd || e_entries[e_pos].events != t_entries[t_pos].events) {pr_err ("Thread and evlist pollfd index mismatch\n" );
tools/perf/tests/fdarray.c +32 -0
@@ -80,6 +80,38 @@ static int test__fdarray__filter(struct test_suite *test __maybe_unused, int sub goto out_delete; } +fdarray__init_revents (fda,POLLHUP ); + fda->priv[2 ].flags = fdarray_flag__nonfilterable; + +pr_debug ("\nfiltering all but fda->entries[2] (nonfilterable):" ); +fdarray__fprintf_prefix (fda,"before" , stderr); + +/* +* Note: fdarray__filter() in tools/lib/api/fd/array.c evaluates the +* fdarray_flag__nonfilterable flag at the very top of its loop via an +* early continue. Therefore, it completely skips all processing for this +* descriptor, guaranteeing its fd, events, and revents fields remain +* entirely untouched by the filter mask evaluation below it. +*/ + nr_fds =fdarray__filter (fda,POLLHUP ,NULL ,NULL ); +fdarray__fprintf_prefix (fda," after" , stderr); + +if (nr_fds !=0 ) { +pr_debug ("\nfdarray__filter()=%d != 0, should be 0\n" , + nr_fds); + goto out_delete; + } +if (fda->entries[2 ].fd ==-1 ) { +pr_debug ("\nfdarray__filter() illegally modified nonfilterable fd!" ); + goto out_delete; + } +if (fda->entries[2 ].revents !=POLLHUP ) { +pr_debug ("\nfdarray__filter() illegally modified nonfilterable revents!" ); + goto out_delete; + } + + fda->priv[2 ].flags =0 ;/* reset flags */ +pr_debug ("\n" ); err =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/2651 drm/amd/display: Cast DP DTO pixel clock math to avoid overflow and narrowing
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Lin <[email protected]>
[ Upstream commit 0575f53925e832fba376583cd18667de8f31b13b ]
[Why]
Commit 0421fc6ab3a8 ("drm/amd/display: fix __udivdi3 link error") switched get_dp_dto_frequency_100hz() and dcn401_get_dp_dto_frequency_100hz() to div_u64() but dropped the original explicit casts, leaving two issues:
- In get_dp_dto_frequency_100hz(), "clock_hz * dp_dto_ref_khz * 10" is computed in 32-bit unsigned arithmetic (both operands are unsigned int) before being stored into the u64 temp, so the product can overflow before it is widened (flagged by Coverity OVERFLOW_BEFORE_WIDEN).
- div_u64() returns a u64 that is assigned directly to the unsigned int *pixel_clk_100hz, an implicit narrowing conversion that trips -Wconversion (possible loss of data) on stricter builds.
[How]
Cast clock_hz to unsigned long long so the multiplication is performed in 64-bit, and make the u64 -> unsigned int narrowing explicit with an (unsigned int) cast on the div_u64() results in both functions. The computed values are unchanged.
--- drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +3 -3
@@ -1232,9 +1232,9 @@ static bool get_dp_dto_frequency_100hz(*/ modulo_hz =REG_READ (MODULO [inst]);if (modulo_hz) { - temp = clock_hz * dp_dto_ref_khz *10 ; + temp = (unsigned long long )clock_hz * dp_dto_ref_khz *10 ;ASSERT (temp <=UINT_MAX * modulo_hz *100ULL ); - *pixel_clk_100hz =div_u64 (temp, modulo_hz *100 ); + *pixel_clk_100hz = (unsigned int )div_u64 (temp, modulo_hz *100 ); }else *pixel_clk_100hz =0 ; }else {
@@ -1293,7 +1293,7 @@ static bool dcn401_get_dp_dto_frequency_100hz(const struct clock_source *clock_sBREAK_TO_DEBUGGER (); *pixel_clk_100hz =0 ; }else { - *pixel_clk_100hz =div_u64 (temp,100 ); + *pixel_clk_100hz = (unsigned int )div_u64 (temp,100 ); }return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 542/2651 drm/amdgpu: reserve eviction-fence slot at WPTR caller
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Prosyak <[email protected]>
[ Upstream commit 5e6b21bce9d939b564e1f1c88a429cfa1fe66d3a ]
Root cause analysis showed that the previous workaround was fixing the symptom in the wrong layer.
Problem:
kernel BUG at drivers/dma-buf/dma-resv.c:319!
BUG_ON(fobj->num_fences >= fobj->max_fences)
Workqueue: events amdgpu_userq_restore_worker
- amdgpu_evf_mgr_attach_fence() had been temporarily taught to reserve/add fence bookkeeping internally as a workaround.
- This hid the real contract violation and made reservation policy implicit inside a helper.
Review clarification:
- The helper-side dma_resv_add_fence-related workaround was only an intended proposal sent for review discussion, not the final direction.
- Final fix keeps fence-slot reservation explicit in callers and leaves the helper free of policy decisions.
Findings from investigation:
- drm_exec_prepare_obj() both locks and reserves fence slots.
- drm_exec_lock_obj() only locks and does not reserve slots.
- Existing attach_fence callers in the GEM/userq restore flows already reserve TTM_NUM_MOVE_FENCES + 1 before adding the bookkeeping eviction fence.
- The WPTR mapping path in mes_userq_create_wptr_mapping() used drm_exec_lock_obj() and then called amdgpu_evf_mgr_attach_fence(), so this specific path could add a fence without pre-reserved space.
Fix:
- Switch the WPTR mapping path to drm_exec_prepare_obj(..., TTM_NUM_MOVE_FENCES + 1), restoring the caller-side reservation contract.
- Remove the helper-side reservation workaround from amdgpu_evf_mgr_attach_fence().
Why this is the right layer:
- Reservation policy stays explicit at call sites that define how many fences may be added in that execution context.
- The helper only performs validate + add_fence when called with a properly prepared reservation object, matching the existing drm_exec model.
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +2 -1
@@ -60,7 +60,8 @@ mes_userq_create_wptr_mapping(struct amdgpu_device *adev, } obj = wptr_mapping->bo_va->base.bo; - ret =drm_exec_lock_obj (&exec, &obj->tbo.base); + ret =drm_exec_prepare_obj (&exec, &obj->tbo.base, +TTM_NUM_MOVE_FENCES +1 );drm_exec_retry_on_contention (&exec);if (unlikely (ret)) goto fail_lock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 543/2651 drm/amd/pm: bound SCLK FCW range entries to the table size
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit f35aa5c77f5fca20fc269d6221df19c7b96704a5 ]
atomctrl_get_smc_sclk_range_table() copies ucSclkEntryNum entries from the VBIOS SMU_Info table into pp_atom_ctrl_sclk_range_table. Both the source (asSclkFcwRangeEntry[]) and destination (table->entry[]) arrays are fixed at MAX_SCLK_RANGE (8) entries, but ucSclkEntryNum is an unchecked u8 read straight from the VBIOS, so it can be up to 255. The destination is stack-allocated in both callers (polaris10_get_sclk_range_table(), vegam_get_sclk_range_table()), so a count above 8 overflows a stack buffer, not just a heap read.
Reject counts above MAX_SCLK_RANGE rather than clamping to it. Only one version of this VBIOS struct (ATOM_SMU_INFO_V2_1) has ever existed, so a count above 8 corresponds to no legitimate table format and means either a corrupted or a tampered VBIOS.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +3 -0
@@ -1025,6 +1025,9 @@ int atomctrl_get_smc_sclk_range_table(struct pp_hwmgr *hwmgr, struct pp_atom_ctrif (!psmu_info)return -EINVAL ; +if (psmu_info->ucSclkEntryNum >MAX_SCLK_RANGE ) +return -EINVAL ; +for (i =0 ; i < psmu_info->ucSclkEntryNum; i++) { table->entry[i].ucVco_setting = psmu_info->asSclkFcwRangeEntry[i].ucVco_setting; table->entry[i].ucPostdiv = psmu_info->asSclkFcwRangeEntry[i].ucPostdiv;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 544/2651 drm/amdgpu/atom: bound the VBIOS date, part number, version and build getters
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit aee05c455ad3e72df9a0591baf0b60da518800f3 ]
atom_get_vbios_date(), atom_get_vbios_pn(), atom_get_vbios_version() and atom_get_vbios_build() all walk the BIOS image using offsets and counts taken from the image itself, checked only against each other and never against ctx->bios_size:
- atom_get_vbios_date() reads 14 bytes at a fixed offset that check_atom_bios()'s minimum size (0x49) does not cover.
- atom_get_vbios_pn() dereferences an image-supplied u16 string offset unchecked, then walks and copies from it with only a length cap, not an image cap.
- atom_get_vbios_version() takes its search bounds from image u16s; atom_find_str_in_rom() already clamps the search itself, but the match is then advanced by a fixed 18 bytes and STRLEN_NORMAL bytes are copied from there with no check that this still lands inside the image.
- atom_get_vbios_build() walks from an image-supplied config-string offset toward the ROM header; a config offset at or past the header makes the pointer difference negative, wrapping through the u16 'len' and passing strscpy() a bound far larger than the 32-byte destination.
Bound each getter's reads, walks and copies to ctx->bios_size, falling back to an empty string on a malformed image.
--- drivers/gpu/drm/amd/amdgpu/atom.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +24 -5
@@ -1420,6 +1420,11 @@ static void atom_get_vbios_date(struct atom_context *ctx) p_rom = ctx->bios; +if (ctx->bios_size <OFFSET_TO_VBIOS_DATE +14 ) { + ctx->date[0 ] ='\0' ; +return ; + } + date_in_rom = p_rom +OFFSET_TO_VBIOS_DATE ; ctx->date[0 ] ='2' ;
@@ -1483,10 +1488,15 @@ static void atom_get_vbios_pn(struct atom_context *ctx) vbios_str = p_rom +OFFSET_TO_VBIOS_PART_NUMBER ; } -if (*vbios_str ==0 ) { +if (vbios_str >= p_rom + ctx->bios_size) + vbios_str =NULL ; + +if (vbios_str ==NULL || *vbios_str ==0 ) { vbios_str =atom_find_str_in_rom (ctx,BIOS_ATOM_PREFIX ,3 ,1024 ,64 );if (vbios_str ==NULL ) vbios_str +=sizeof (BIOS_ATOM_PREFIX ) -1 ; +if (vbios_str >= p_rom + ctx->bios_size) + vbios_str =NULL ; }OPTIMIZER_HIDE_VAR (vbios_str);if (vbios_str !=NULL && *vbios_str ==0 )
@@ -1494,7 +1504,9 @@ static void atom_get_vbios_pn(struct atom_context *ctx)if (vbios_str !=NULL ) { count =0 ; -while ((count <BIOS_STRING_LENGTH ) && vbios_str[count] >=' ' && +while ((count <BIOS_STRING_LENGTH ) && + vbios_str + count < p_rom + ctx->bios_size && + vbios_str[count] >=' ' && vbios_str[count] <='z' ) { ctx->vbios_pn[count] = vbios_str[count]; count++;
@@ -1527,9 +1539,10 @@ static void atom_get_vbios_version(struct atom_context *ctx)/* find anchor ATOMBIOSBK-AMD */ vbios_ver =atom_find_str_in_rom (ctx,BIOS_VERSION_PREFIX , start, end,64 ); -if (vbios_ver !=NULL ) { -/* skip ATOMBIOSBK-AMD VER */ - vbios_ver +=18 ; +if (vbios_ver !=NULL ) + vbios_ver +=18 ;/* skip ATOMBIOSBK-AMD VER */ + +if (vbios_ver !=NULL && vbios_ver +STRLEN_NORMAL <= p_rom + ctx->bios_size) {memcpy (ctx->vbios_ver_str, vbios_ver,STRLEN_NORMAL ); }else { ctx->vbios_ver_str[0 ] ='\0' ;
@@ -1545,7 +1558,13 @@ static void atom_get_vbios_build(struct atom_context *ctx) base =CU16 (ATOM_ROM_TABLE_PTR ); atom_rom_hdr =CSTR (base); +if ((uint32_t )base +ATOM_ROM_CFG_PTR +sizeof (uint16_t ) > ctx->bios_size) +return ; + str =CSTR (CU16 (base +ATOM_ROM_CFG_PTR )); +if (str >= atom_rom_hdr) +return ; +/* Skip config string */ while (str < atom_rom_hdr && *str++) ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 545/2651 drm/amd/display: Fix redundant NULL check on dc->clk_mgr in dcn42_prepare_bandwidth
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 346d81ef808ba28465a3f19f2a0d63a758e7409c ]
dc->clk_mgr is already dereferenced inside dcn401_prepare_bandwidth(), so the dc->clk_mgr NULL check that follows is redundant and misleading. Drop it.
--- drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.c +1 -1
@@ -683,7 +683,7 @@ void dcn42_prepare_bandwidth(/* valid C-state watermarks have now been committed to HW, so it * is safe to vote "allow" to PMFW. */ -if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_cstate_disable) +if (dc->clk_mgr->funcs->notify_cstate_disable) dc->clk_mgr->funcs->notify_cstate_disable (dc->clk_mgr, false); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 546/2651 ata: sata_dwc_460ex: Dont enable interrupt if libATA core registration fails
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Borisov <[email protected]>
[ Upstream commit e137035fcd66cb454c479bb989968561bbc60341 ]
Recent 4bbc16a353a9 commit changed the timing when interrupts are enabled. However it didn't account for the libATA registration step. So it's possible that interrupts are enabled when the device is not registered with libATA core.
Resolve the issue by failing the entire registration process in case of failure to register with libATA.
--- drivers/ata/sata_dwc_460ex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/ata/sata_dwc_460ex.c +4 -1
@@ -1185,11 +1185,14 @@ static int sata_dwc_probe(struct platform_device *ofdev)* error_handler() to execute a dummy Softreset EH session */ err =ata_host_activate (host, irq, sata_dwc_isr,0 , &sata_dwc_sht); -if (err) +if (err) {dev_err (dev,"failed to activate host" ); + goto error_out; + }/* Enable SATA Interrupts */ sata_dwc_enable_interrupts (hsdev); +return 0 ; error_out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 547/2651 media: ivsc: Fix csi_dev use-after-free in mei_ace_setup_dev_link()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit f9be93338c2fbaffdbda4f89045e879932e827ca ]
device_link_add() only takes a reference to the supplier when the link is created successfully. When it fails it returns NULL without taking one, so the put_device(csi_dev) before the error check can drop the last reference to csi_dev and dev_name(csi_dev) then dereferences a freed device.
Move the put_device() below the error check and release the reference through the existing err_put label on the failure path so that csi_dev is no longer touched after it has been put.
--- drivers/media/pci/intel/ivsc/mei_ace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ivsc/mei_ace.c +2 -2
@@ -414,13 +414,13 @@ static int mei_ace_setup_dev_link(struct mei_ace *ace)/* setup link between mei_ace and mei_csi */ ace->csi_link =device_link_add (csi_dev, dev,DL_FLAG_PM_RUNTIME |DL_FLAG_RPM_ACTIVE |DL_FLAG_STATELESS ); -put_device (csi_dev);if (!ace->csi_link) { ret = -EINVAL ;dev_err (dev,"failed to link to %s\n" ,dev_name (csi_dev)); - goto err; + goto err_put; } +put_device (csi_dev); ace->csi_dev = csi_dev;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 548/2651 drm: bridge: dw_hdmi: Fix constant truncation warning on phy_mask
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Chang <[email protected]>
[ Upstream commit cb6a133bc75bc4c5b25f7c278b6c74bf46a3d71b ]
In dw_hdmi_probe(), casting the bitwise complement of (HDMI_PHY_HPD | HDMI_PHY_RX_SENSE) directly to u8 triggers a compiler warning (-Wconstant-conversion).
Due to C integer promotion rules, the bitwise OR and bitwise NOT are evaluated as 32-bit signed integers, producing 0xFFFFFF0D before being cast down to u8.
Fix this by explicitly masking the inverted 32-bit result with 0xFF to keep only the lower byte and prevent implicit upper-bit truncation.
Stable-dep-of: ac18f34f5927 ("accel/amdxdna: Fix race between unmap and free BO")
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -1
@@ -3353,7 +3353,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, hdmi->channels =2 ; hdmi->disabled = true; hdmi->rxsense = true; - hdmi->phy_mask = (u8 )~(HDMI_PHY_HPD |HDMI_PHY_RX_SENSE ); + hdmi->phy_mask = ~(HDMI_PHY_HPD |HDMI_PHY_RX_SENSE ) &0xff ; hdmi->mc_clkdis =0x7f ; hdmi->last_connector_result = connector_status_disconnected;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 549/2651 accel/amdxdna: Fully initialize map structure before registering notifier
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 5eee433b5c97821979e7de58476dc245ee168d89 ]
The map structure is currently only partially initialized when the notifier is registered. Although holding mmap_write_lock() prevents the notifier callback from running before the remaining initialization is complete, the ordering can be confusing during code review.
Fully initialize the map structure before registering the notifier so that the structure is completely constructed before it is published.
Stable-dep-of: ac18f34f5927 ("accel/amdxdna: Fix race between unmap and free BO")
--- drivers/accel/amdxdna/amdxdna_gem.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/accel/amdxdna/amdxdna_gem.c +9 -9
@@ -415,6 +415,15 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, goto free_map; } + mapp->range.notifier = &mapp->notifier; + mapp->range.start = vma->vm_start; + mapp->range.end = vma->vm_end; + mapp->range.default_flags =HMM_PFN_REQ_FAULT ; + mapp->abo = abo; +kref_init (&mapp->refcnt); + +INIT_WORK (&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work); + ret = mmu_interval_notifier_insert_locked(&mapp->notifier, current->mm, addr,
@@ -425,15 +434,6 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, goto free_pfns; } - mapp->range.notifier = &mapp->notifier; - mapp->range.start = vma->vm_start; - mapp->range.end = vma->vm_end; - mapp->range.default_flags =HMM_PFN_REQ_FAULT ; - mapp->abo = abo; -kref_init (&mapp->refcnt); - -INIT_WORK (&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work); -down_write (&xdna->notifier_lock);if (list_empty (&abo->mem.umap_list)) abo->mem.uva = addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 550/2651 accel/amdxdna: Fix race between unmap and free BO
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit ac18f34f5927e420ae529be72aec86201a262d04 ]
A userspace process can concurrently trigger an unmap, which queues hmm_unreg_work, and free BO. If amdxdna_hmm_unreg_work() executes list_del(&mapp->node) and is preempted before calling amdxdna_umap_put(), amdxdna_hmm_unregister_all() can fail to find the mapping in the list and return without calling cancel_work_sync(). This allows object destruction to proceed while the worker still holds a pointer to the BO in the umap structure.
Moving the work item from struct amdxdna_umap to struct amdxdna_gem_obj. The worker no longer holds a pointer to an individual mapping, so there is no longer a window where the umap has been unlinked from umap_list but work is still pending against it. The work item now lives in the BO itself, so use a single cancel_work_sync() in the free path to drain the work.
--- drivers/accel/amdxdna/amdxdna_gem.c | 95 +++++++++++++---------------- drivers/accel/amdxdna/amdxdna_gem.h | 3 +- 2 files changed, 42 insertions(+), 56 deletions(-)
drivers/accel/amdxdna/amdxdna_gem.c +41 -54
@@ -164,30 +164,6 @@ void amdxdna_gem_heap_free(struct amdxdna_client *client, struct amdxdna_gem_objmutex_unlock (&client->mm_lock); } -static struct amdxdna_gem_obj * -amdxdna_gem_create_obj (struct drm_device *dev,size_t size) -{ -struct amdxdna_gem_obj *abo; - - abo =kzalloc_obj (*abo); -if (!abo) -return ERR_PTR (-ENOMEM ); - - abo->pinned = false; - abo->assigned_hwctx =AMDXDNA_INVALID_CTX_HANDLE ; -mutex_init (&abo->lock); - - abo->mem.dma_addr =AMDXDNA_INVALID_ADDR ; - abo->mem.uva =AMDXDNA_INVALID_ADDR ; - abo->mem.size = size; - abo->open_ref =0 ; - abo->internal = false; -INIT_LIST_HEAD (&abo->mem.umap_list); -xa_init_flags (&abo->heap_xa,XA_FLAGS_ALLOC ); - -return abo; -} -static void amdxdna_gem_destroy_obj (struct amdxdna_gem_obj *abo) {
@@ -278,10 +254,8 @@ static bool amdxdna_hmm_invalidate(struct mmu_interval_notifier *mni,if (range->event ==MMU_NOTIFY_UNMAP ) {down_write (&xdna->notifier_lock); -if (!mapp->unmapped) { -queue_work (xdna->notifier_wq, &mapp->hmm_unreg_work); - mapp->unmapped = true; - } + mapp->unmapped = true; +queue_work (xdna->notifier_wq, &abo->hmm_unreg_work);up_write (&xdna->notifier_lock); }
@@ -311,13 +285,13 @@ static void amdxdna_hmm_unregister(struct amdxdna_gem_obj *abo,if (!compare_range (mapp, vma->vm_mm, vma->vm_start, vma->vm_end))continue ; -queue_work (xdna->notifier_wq, &mapp->hmm_unreg_work); mapp->unmapped = true; +queue_work (xdna->notifier_wq, &abo->hmm_unreg_work); }up_write (&xdna->notifier_lock); } -static void amdxdna_hmm_unregister_all (struct amdxdna_gem_obj *abo) +static void amdxdna_hmm_unreg_umaps (struct amdxdna_gem_obj *abo,bool force) {struct amdxdna_dev *xdna =to_xdna_dev (to_gobj (abo)->dev);struct amdxdna_umap *mapp, *tmp;
@@ -325,16 +299,18 @@ static void amdxdna_hmm_unregister_all(struct amdxdna_gem_obj *abo)down_write (&xdna->notifier_lock);list_for_each_entry_safe (mapp, tmp, &abo->mem.umap_list, node) { +if (!force && !mapp->unmapped) +continue ; + mapp->unmapped = true; - mapp->cleanup = true;list_move (&mapp->node, &dead); } +if (list_empty (&abo->mem.umap_list)) + abo->mem.uva =AMDXDNA_INVALID_ADDR ;up_write (&xdna->notifier_lock); -list_for_each_entry_safe (mapp, tmp, &dead, node) { -cancel_work_sync (&mapp->hmm_unreg_work); +list_for_each_entry_safe (mapp, tmp, &dead, node)amdxdna_umap_put (mapp); - } }static void amdxdna_umap_release (struct kref *ref)
@@ -353,24 +329,10 @@ void amdxdna_umap_put(struct amdxdna_umap *mapp)static void amdxdna_hmm_unreg_work (struct work_struct *work) { - struct amdxdna_umap *mapp = container_of(work, struct amdxdna_umap, - hmm_unreg_work); -struct amdxdna_gem_obj *abo = mapp->abo; -struct amdxdna_dev *xdna; + struct amdxdna_gem_obj *abo = container_of(work, struct amdxdna_gem_obj, + hmm_unreg_work); - xdna =to_xdna_dev (to_gobj (mapp->abo)->dev); -down_write (&xdna->notifier_lock); -if (mapp->cleanup) { -up_write (&xdna->notifier_lock); -return ; - } - -list_del (&mapp->node); -if (list_empty (&abo->mem.umap_list)) - abo->mem.uva =AMDXDNA_INVALID_ADDR ; -up_write (&xdna->notifier_lock); - -amdxdna_umap_put (mapp); +amdxdna_hmm_unreg_umaps (abo, false); } static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
@@ -422,8 +384,6 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, mapp->abo = abo;kref_init (&mapp->refcnt); -INIT_WORK (&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work); - ret = mmu_interval_notifier_insert_locked(&mapp->notifier, current->mm, addr,
@@ -449,6 +409,31 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,return ret; } +static struct amdxdna_gem_obj * +amdxdna_gem_create_obj (struct drm_device *dev,size_t size) +{ +struct amdxdna_gem_obj *abo; + + abo =kzalloc_obj (*abo); +if (!abo) +return ERR_PTR (-ENOMEM ); + + abo->pinned = false; + abo->assigned_hwctx =AMDXDNA_INVALID_CTX_HANDLE ; +mutex_init (&abo->lock); + + abo->mem.dma_addr =AMDXDNA_INVALID_ADDR ; + abo->mem.uva =AMDXDNA_INVALID_ADDR ; + abo->mem.size = size; + abo->open_ref =0 ; + abo->internal = false; +INIT_LIST_HEAD (&abo->mem.umap_list); +xa_init_flags (&abo->heap_xa,XA_FLAGS_ALLOC ); +INIT_WORK (&abo->hmm_unreg_work, amdxdna_hmm_unreg_work); + +return abo; +} +static void amdxdna_gem_dev_obj_free (struct drm_gem_object *gobj) {struct amdxdna_dev *xdna =to_xdna_dev (gobj->dev);
@@ -756,7 +741,9 @@ static void amdxdna_gem_obj_free(struct drm_gem_object *gobj)struct amdxdna_dev *xdna =to_xdna_dev (gobj->dev);struct amdxdna_gem_obj *abo =to_xdna_obj (gobj); -amdxdna_hmm_unregister_all (abo); +/* No notifier survives this, so no new work can be queued. */ +amdxdna_hmm_unreg_umaps (abo, true); +cancel_work_sync (&abo->hmm_unreg_work);if (abo->pinned)amdxdna_gem_unpin (abo);
drivers/accel/amdxdna/amdxdna_gem.h +1 -2
@@ -14,13 +14,11 @@struct amdxdna_umap {struct mmu_interval_notifier notifier;struct hmm_range range; -struct work_struct hmm_unreg_work;struct amdxdna_gem_obj *abo;struct list_head node;struct kref refcnt;bool invalid;bool unmapped; -bool cleanup; };struct amdxdna_mem {
@@ -44,6 +42,7 @@ struct amdxdna_gem_obj {struct mutex lock;/* Protects: pinned, mem.kva, open_ref */ struct amdxdna_mem mem;int open_ref; +struct work_struct hmm_unreg_work;/* Below members are initialized when needed */ struct drm_mm_node mm_node;/* For AMDXDNA_BO_DEV */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 551/2651 accel/amdxdna: Set HMM_PFN_REQ_WRITE for writable BO faults
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 2d2c4b248bff9ee1ac06054a9138c1a308e2e7b8 ]
When aie2_populate_range() faults in pages, it only sets HMM_PFN_REQ_FAULT. Without HMM_PFN_REQ_WRITE, handle_mm_fault() does not request write permissions and may populate the CPU page tables with read-only PTEs.
Check the VMA flags and set HMM_PFN_REQ_WRITE when the VMA has VM_WRITE.
--- drivers/accel/amdxdna/amdxdna_gem.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/accel/amdxdna/amdxdna_gem.c +8 -0
@@ -380,7 +380,15 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo, mapp->range.notifier = &mapp->notifier; mapp->range.start = vma->vm_start; mapp->range.end = vma->vm_end; +/* +* Access permissions are fixed at mmap() time. Changing them later +* with mprotect() is not supported: the range keeps requesting the +* original permissions, so the application may see a fault failure +* or an IOMMU fault. +*/ mapp->range.default_flags =HMM_PFN_REQ_FAULT ; +if (vma->vm_flags &VM_WRITE ) + mapp->range.default_flags |=HMM_PFN_REQ_WRITE ; mapp->abo = abo;kref_init (&mapp->refcnt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 552/2651 accel/amdxdna: do not warn when a sync request is rejected
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taimuraz Kaitmazov <[email protected]>
[ Upstream commit f2751f8754ae7ca0bba1a9536e153c8cc3aa4aae ]
amdxdna_drm_sync_bo_ioctl() answers a failed amdxdna_flush_bo() with drm_WARN(). Both of that function's error returns are decided by the ioctl's arguments, so SYNC_BO with an offset past the end of the BO splats and taints the kernel from an unprivileged caller.
Log it at debug level, since the same caller can repeat it.
--- drivers/accel/amdxdna/amdxdna_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_gem.c +1 -1
@@ -1503,7 +1503,7 @@ int amdxdna_drm_sync_bo_ioctl(struct drm_device *dev,amdxdna_gem_unpin (abo);if (ret) { -drm_WARN (&xdna->ddev,1 ,"Can not get flush memory" ); +XDNA_DBG (xdna,"Flush BO %d failed, ret %d" , args->handle, ret); goto put_obj; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 553/2651 accel/amdxdna: do not fail a sync for a BO with no debug context
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taimuraz Kaitmazov <[email protected]>
[ Upstream commit b1da2a6cc13d66c03c364f7b72d5a343b3ccdb3c ]
amdxdna_drm_sync_bo_ioctl() calls amdxdna_hwctx_sync_debug_bo() for every FROM_DEVICE sync, which answers -EINVAL when the BO's assigned_hwctx names no context. Only a BO attached with ATTACH_DEBUG_BO is ever given one, so an ordinary read-back sync reports failure after its flush has already run.
Ask for the debug sync only when the BO has a context. An unattached BO carries AMDXDNA_INVALID_CTX_HANDLE and hwctx ids are allocated above it, so the test is exact, -EINVAL keeps meaning that the named context is gone, and the handle is not resolved twice. The field is written under dev_lock and read here without it; the context is still resolved under that lock, so a racing attach only decides whether this sync sees the buffer.
--- drivers/accel/amdxdna/amdxdna_gem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_gem.c +2 -1
@@ -1511,7 +1511,8 @@ int amdxdna_drm_sync_bo_ioctl(struct drm_device *dev,XDNA_DBG (xdna,"Sync bo %d offset 0x%llx, size 0x%llx\n" , args->handle, args->offset, args->size); -if (args->direction ==SYNC_DIRECT_FROM_DEVICE ) +if (abo->assigned_hwctx !=AMDXDNA_INVALID_CTX_HANDLE && + args->direction ==SYNC_DIRECT_FROM_DEVICE ) ret =amdxdna_hwctx_sync_debug_bo (client, args->handle); put_obj:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 554/2651 dt-bindings: interrupt-controller: chrp,open-pic: Typo s/pci/pic/
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit f0597e96a23b0cc7877581cf907407645ca71c03 ]
The device_type for an OpenPIC node is "open-pic", not "open-pci".
--- .../devicetree/bindings/interrupt-controller/chrp,open-pic.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/interrupt-controller/chrp,open-pic.yaml +1 -1
@@ -24,7 +24,7 @@ properties: - const: chrp,open-pic device_type: - const: open-pci + const: open-pic deprecated: true reg:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 555/2651 dt-bindings: interrupt-controller: chrp,open-pic: Fix dangling reference
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 2fb6f1a87cba099b2921fc3e777bf399d4153a39 ]
The target of "[1]" was lost during the conversion to json-schema. Replace it by an inline reference.
--- .../bindings/interrupt-controller/chrp,open-pic.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/interrupt-controller/chrp,open-pic.yaml +3 -2
@@ -12,8 +12,9 @@ maintainers: description: This binding specifies what properties must be available in the device tree representation of an Open PIC compliant interrupt controller. This binding is - based on the binding defined for Open PIC in [1] and is a superset of that - binding. + based on the binding defined for Open PIC in the Devicetree Specification + (available from https://www.devicetree.org/specifications/) and is a superset + of that binding. properties: compatible:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 556/2651 libbpf: Reject local struct_ops bitfields before data access
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingpei CAO <[email protected]>
[ Upstream commit 961b8946acb482b6d7a39c266d623e5f9c4e873f ]
A local struct_ops type can contain a bitfield absent from the corresponding kernel BTF type. bpf_map__init_kern_struct_ops() checks whether data for an absent local member is zero.
For a bitfield, member->offset contains the bit offset and field width. bpf_map__init_kern_struct_ops() used the encoded value to calculate the member data pointer before rejecting the bitfield. The zero-data check could therefore read outside st_ops->data and crash libbpf.
Reject local bitfields before calculating the member data pointer. Keep the existing rejection for bitfields in the kernel type.
--- tools/lib/bpf/libbpf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +7 -2
@@ -1223,6 +1223,12 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map)const char *mname; mname =btf__name_by_offset (btf, member->name_off); +if (btf_member_bitfield_size (type, i)) { +pr_warn ("struct_ops init_kern %s: local bitfield %s is not supported\n" , + map->name, mname); +return -ENOTSUP ; + } + moff = member->offset /8 ; mdata = data + moff; msize =btf__resolve_size (btf, member->type);
@@ -1259,8 +1265,7 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map) } kern_member_idx = kern_member -btf_members (kern_type); -if (btf_member_bitfield_size (type, i) || -btf_member_bitfield_size (kern_type, kern_member_idx)) { +if (btf_member_bitfield_size (kern_type, kern_member_idx)) {pr_warn ("struct_ops init_kern %s: bitfield %s is not supported\n" , map->name, mname);return -ENOTSUP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 557/2651 rcu: fix shrink budget underflow in lazy_rcu_shrink_scan
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Longlong Xia <[email protected]>
[ Upstream commit 4c714f015d9ecc37d7a330b31822ccbcaff5ddc9 ]
The lazy RCU shrinker decremented sc->nr_to_scan (unsigned long) and then tested the result with <= 0. When a single CPU's lazy callback count exceeds the remaining budget, the subtraction wraps to a large positive value and the <= 0 comparison, which is equivalent to == 0 for an unsigned type, never fires again. The scan loop then iterates through every nocb CPU instead of honouring the reclaim budget.
Accumulate into count and stop once count >= nr_to_scan.
--- kernel/rcu/tree_nocb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/rcu/tree_nocb.h +1 -2
@@ -1332,9 +1332,8 @@ lazy_rcu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)rcu_nocb_try_flush_bypass (rdp, jiffies);rcu_nocb_unlock_irqrestore (rdp, flags);wake_nocb_gp (rdp); - sc->nr_to_scan -= _count; count += _count; -if (sc->nr_to_scan <=0 ) +if (count >= sc->nr_to_scan)break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 558/2651 PCI: dra7xx: Remove device links to PHY
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: [email protected] <[email protected]>
[ Upstream commit 52cd9bb3772e82d792cb0def3c2a5a9b6bd24ffb ]
This is a full revert of commit 7a4db656a635 ("PCI: dra7xx: Create functional dependency between PCIe and PHY").
The trouble with this is that a PHY consumer driver dereferences fields from struct phy, which will become no longer possible.
Since commit 987351e1ea77 ("phy: core: Add consumer device link support") from 2019, the PHY core also adds a device link to order PHY provider and consumer suspend/resume operations. The reverted functionality is from 2017 and is redundant with the PHY core now.
Stable-dep-of: 768e5d0936d0 ("PCI: dra7xx: Fix clock enable leak on probe failure")
--- drivers/pci/controller/dwc/pci-dra7xx.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +0 -16
@@ -9,7 +9,6 @@#include <linux/clk.h> #include <linux/delay.h> -#include <linux/device.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -680,7 +679,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)int i;int phy_count;struct phy **phy; -struct device_link **link;void __iomem *base;struct dw_pcie *pci;struct dra7xx_pcie *dra7xx;
@@ -728,10 +726,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)if (!phy)return -ENOMEM ; - link =devm_kcalloc (dev, phy_count,sizeof (*link),GFP_KERNEL ); -if (!link) -return -ENOMEM ; - dra7xx->clk =devm_clk_get_optional (dev,NULL );if (IS_ERR (dra7xx->clk)) return dev_err_probe(dev, PTR_ERR(dra7xx->clk),
@@ -746,12 +740,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) phy[i] =devm_phy_get (dev, name);if (IS_ERR (phy[i]))return PTR_ERR (phy[i]); - - link[i] =device_link_add (dev, &phy[i]->dev,DL_FLAG_STATELESS ); -if (!link[i]) { - ret = -EINVAL ; - goto err_link; - } } dra7xx->base = base;
@@ -853,10 +841,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)pm_runtime_disable (dev);dra7xx_pcie_disable_phy (dra7xx); -err_link: -while (--i >=0 ) -device_link_del (link[i]); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 559/2651 PCI: dra7xx: Fix clock enable leak on probe failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 768e5d0936d00d663ce2b8c192cc6ab0b61ad461 ]
dra7xx_pcie_probe() enables the optional clock but never disables it when probing fails afterwards.
Switch to devm_clk_get_optional_enabled(), which disables the clock automatically on failure.
--- drivers/pci/controller/dwc/pci-dra7xx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +1 -5
@@ -726,15 +726,11 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)if (!phy)return -ENOMEM ; - dra7xx->clk =devm_clk_get_optional (dev,NULL ); + dra7xx->clk =devm_clk_get_optional_enabled (dev,NULL );if (IS_ERR (dra7xx->clk))return dev_err_probe (dev,PTR_ERR (dra7xx->clk),"clock request failed" ); - ret =clk_prepare_enable (dra7xx->clk); -if (ret) -return ret; -for (i =0 ; i < phy_count; i++) {snprintf (name,sizeof (name),"pcie-phy%d" , i); phy[i] =devm_phy_get (dev, name);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 560/2651 kconfig: fix extra output from savedefconfig on out-of-range defaults
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <[email protected]>
[ Upstream commit dbe1ae2304a3b02c3bf6ae82895ff232a29f3fee ]
The Kconfig interpreter currently allows defaults that are outside of the range bounds.
In these cases, the 'sym_validate_range' function will adjust the default value to the nearest range bound. For example, see this example:
config A
int
range 1 2
default 16
Here, since the default value of 16 is greater than the bounds, the effective default value gets adjusted down to the upper bound, 2.
However, 'savedefconfig' writes non-default values, and without being aware of the automatic adjustment to the range bound, it would write: A=2
This limitation is also documented in a comment: "The following fails to handle the situation where a default value is further limited by the valid range."
To resolve this, let's factor out the default-range adjustment logic from the existing 'sym_validate_range' function into its own 'sym_get_near_range_bound' function for 'savedefconfig' to use too, so that it compares against the effective value.
Adds tests, accordingly.
--- scripts/kconfig/symbol.c | 39 ++++++++---- .../kconfig/tests/savedefconfig_range/Kconfig | 60 +++++++++++++++++++ .../tests/savedefconfig_range/__init__.py | 8 +++ .../kconfig/tests/savedefconfig_range/config | 7 +++ .../savedefconfig_range/expected_defconfig | 0 5 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 scripts/kconfig/tests/savedefconfig_range/Kconfig create mode 100644 scripts/kconfig/tests/savedefconfig_range/__init__.py create mode 100644 scripts/kconfig/tests/savedefconfig_range/config create mode 100644 scripts/kconfig/tests/savedefconfig_range/expected_defconfig
scripts/kconfig/symbol.c +27 -12
@@ -157,7 +157,12 @@ static long long sym_get_range_val(struct symbol *sym, int base)return strtoll (sym->curr.val,NULL , base); } -static void sym_validate_range (struct symbol *sym) +/* +* Return the nearest range bound for an out-of-range default value. +* Return NULL if the value is valid or the symbol has no active range. +*/ +static struct symbol *sym_get_near_range_bound (struct symbol *sym, +const char *value) {struct property *prop;struct symbol *range_sym;
@@ -172,21 +177,31 @@ static void sym_validate_range(struct symbol *sym) base =16 ;break ;default : -return ; +return NULL ; } prop =sym_get_range_prop (sym);if (!prop) -return ; - val =strtoll (sym->curr.val,NULL , base); +return NULL ; + val =strtoll (value,NULL , base); range_sym = prop->expr->left.sym; val2 =sym_get_range_val (range_sym, base);if (val >= val2) { range_sym = prop->expr->right.sym; val2 =sym_get_range_val (range_sym, base);if (val <= val2) -return ; +return NULL ; } - sym->curr.val = range_sym->curr.val; + +return range_sym; +} + +static void sym_validate_range (struct symbol *sym) +{ +struct symbol *range_sym; + + range_sym =sym_get_near_range_bound (sym, sym->curr.val); +if (range_sym) + sym->curr.val = range_sym->curr.val; }static void sym_set_changed (struct symbol *sym)
@@ -812,7 +827,7 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)const char *sym_get_string_default (struct symbol *sym) {struct property *prop; -struct symbol *ds; +struct symbol *ds, *range_sym;const char *str ="" ;tristate val;
@@ -830,11 +845,6 @@ const char *sym_get_string_default(struct symbol *sym) val =EXPR_AND (expr_calc_value (prop->expr), prop->visible.tri);break ;default : -/* -* The following fails to handle the situation -* where a default value is further limited by -* the valid range. -*/ ds =prop_get_symbol (prop);if (ds !=NULL ) {sym_calc_value (ds);
@@ -878,6 +888,11 @@ const char *sym_get_string_default(struct symbol *sym)default :break ; } + + range_sym =sym_get_near_range_bound (sym, str); +if (range_sym) + str = range_sym->curr.val; +return str; }
scripts/kconfig/tests/savedefconfig_range/Kconfig new file +60 -0
60 lines not on this page · raw message
scripts/kconfig/tests/savedefconfig_range/__init__.py new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +"""Test savedefconfig with numerical defaults outside of ranges.""" + + +def test(conf): + assert conf._run_conf('--savedefconfig=defconfig', dot_config='config', + out_file='defconfig') == 0 + assert conf.config_matches('expected_defconfig')
scripts/kconfig/tests/savedefconfig_range/config new file +7 -0
@@ -0,0 +1,7 @@ +CONFIG_INT_DEFAULT_ABOVE_RANGE=1 +CONFIG_INT_DEFAULT_BELOW_RANGE=4 +CONFIG_INT_DYNAMIC_RANGE=3 +CONFIG_HEX_DEFAULT_ABOVE_RANGE=0x20 +CONFIG_INT_IMPLICIT_DEFAULT_ZERO=1 +CONFIG_INT_CONDITIONAL_RANGE=2 +CONFIG_INT_CONDITIONAL_DEFAULT=2
scripts/kconfig/tests/savedefconfig_range/expected_defconfig new file +0 -0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/2651 netlink: specs: devlink: describe DEVLINK_ATTR_NESTED_DEVLINK
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 6338e31e68551268fa65b5fb1f67eecb3b7a8e3c ]
The "# TODO: fill in the attributes in between" gap before selftests
(176) hides exactly one attribute, DEVLINK_ATTR_NESTED_DEVLINK (175). devlink_nl_fill() calls devlink_nl_nested_fill() unconditionally, which emits one of these per entry in devlink->nested_rels (mlx5, ice).
Unlike the other TODO gaps this is a single attribute of an already modelled type, so just fill it in.
Stable-dep-of: 150079380e4b ("netlink: specs: devlink: describe the netns id in the parent-dev nest")
--- Documentation/netlink/specs/devlink.yaml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
Documentation/netlink/specs/devlink.yaml +19 -4
@@ -845,13 +845,14 @@ attribute-sets: name: linecard-supported-types type: nest nested-attributes: dl-linecard-supported-types - - # TODO: fill in the attributes in between - + - + name: nested-devlink + type: nest + multi-attr: true + nested-attributes: dl-nested-devlink - name: selftests type: nest - value: 176 nested-attributes: dl-selftest-id - name: rate-tx-priority
@@ -1338,6 +1339,19 @@ attribute-sets: - name: index + - + name: dl-nested-devlink + subset-of: devlink + attributes: + - + name: bus-name + - + name: dev-name + - + name: index + - + name: netns-id + operations: enum-model: directional list:
@@ -1363,6 +1377,7 @@ operations: - index - reload-failed - dev-stats + - nested-devlink dump: reply: *get-reply
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 562/2651 netlink: specs: devlink: describe the netns id in the parent-dev nest
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 150079380e4b13c7ed0e738913937e375259172c ]
devlink_nl_rate_parent_fill() emits DEVLINK_ATTR_PARENT_DEV via devlink_nl_put_nested_handle(), which adds DEVLINK_ATTR_NETNS_ID whenever the parent rate node lives on a devlink instance in another netns. Now that we defined dl-nested-devlink subset, which unlike dl-parent-dev includes netns-id, let's switch to it. The rate APIs input genuinely does not accept the netns-id, so we need to subset them to stick with dl-parent-dev.
--- Documentation/netlink/specs/devlink.yaml | 41 ++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-)
Documentation/netlink/specs/devlink.yaml +38 -3
@@ -899,7 +899,7 @@ attribute-sets: - name: parent-dev type: nest - nested-attributes: dl-parent-dev + nested-attributes: dl-nested-devlink doc: | Identifies the devlink instance which owns the parent rate node. Used with rate-set and rate-new to parent a rate object to a node on
@@ -1331,6 +1331,10 @@ attribute-sets: - name: dl-parent-dev subset-of: devlink + doc: | + Devlink handle accepted as the parent-dev input; the netns id the + kernel reports back is not accepted, the parent is always resolved + in the caller's netns. attributes: - name: bus-name
@@ -1339,6 +1343,37 @@ attribute-sets: - name: index + - + name: dl-rate-set + subset-of: devlink + doc: Attributes accepted by the rate-set and rate-new requests. + attributes: + - + name: bus-name + - + name: dev-name + - + name: index + - + name: port-index + - + name: rate-node-name + - + name: rate-tx-share + - + name: rate-tx-max + - + name: rate-tx-priority + - + name: rate-tx-weight + - + name: rate-parent-node-name + - + name: rate-tc-bws + - + name: parent-dev + nested-attributes: dl-parent-dev + - name: dl-nested-devlink subset-of: devlink
@@ -2320,7 +2355,7 @@ operations: - name: rate-set doc: Set rate instances. - attribute-set: devlink + attribute-set: dl-rate-set dont-validate: [strict] flags: [admin-perm] do:
@@ -2343,7 +2378,7 @@ operations: - name: rate-new doc: Create rate instances. - attribute-set: devlink + attribute-set: dl-rate-set dont-validate: [strict] flags: [admin-perm] do:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/2651 cxl/pci: Skip reset detection for DVSEC emulated decoders
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 17ff3a9fd8669ea53fe83a7013871f30214d5537 ]
HDM decoders are emulated from the DVSEC range registers in two cases:
(a) the component registers expose no HDM decoder capability, or (b) the capability is present but the DVSEC ranges were the ones in use at driver load.
After an FLR or SBR, __cxl_endpoint_decoder_reset_detected() reads the HDM decoder Committed bit for every decoder marked enabled, emulated ones included. In case (a) regs.hdm_decoder is NULL and the read oopses. In case
(b) the Committed bit was never set, so a reset gets reported that never happened.
Use the absence of cxld->commit to elide the check for emulated decoders.
Case (b) tested under QEMU: a reset on an endpoint driven down the DVSEC emulation path no longer reports a reset or strips the decoder flags.
--- drivers/cxl/core/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/cxl/core/pci.c +9 -0
@@ -683,6 +683,15 @@ static int __cxl_endpoint_decoder_reset_detected(struct device *dev, void *data)if ((cxld->flags &CXL_DECODER_F_ENABLE ) ==0 )return 0 ; +/* +* Decoders emulated from the DVSEC range registers have no commit +* callback and no HDM decoder registers to consult. +*/ +if (!cxld->commit) { +dev_warn (dev,"DVSEC emulated decode may have been cleared by reset\n" ); +return 0 ; + } + cxlhdm =dev_get_drvdata (&port->dev); hdm = cxlhdm->regs.hdm_decoder; ctrl =readl (hdm +CXL_HDM_DECODER0_CTRL_OFFSET (cxld->id));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/2651 cxl/cdat: Fix uninitialized stack use in bandwidth gathering
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 97b74de26c81885a6447f5fe87641a2a136f8c7c ]
cxl_endpoint_gather_bandwidth() and cxl_switch_gather_bandwidth() declare access_coordinate arrays on the stack and rely on their helpers to fill them. The helpers assign only the bandwidth members, and the combine step assigns even those only when both inputs are non-zero. The latency members are summed from stack residue on every call, and the bandwidth members keep that residue into the region access coordinate sysfs attributes when the endpoint CDAT reports no bandwidth.
Zero initialize the arrays. Zero is the value this code already uses for "not reported", so an unset member now reads back as unknown rather than as a plausible number.
Found by code inspection. Tested on a QEMU CXL topology with two endpoints sharing a switch upstream link and HMAT generic-port coordinates for the host bridge, which the calculation requires to run at all: with temporary printk at the combine sites, the unpatched kernel summed 0xfefefefe, the CONFIG_INIT_STACK_ALL_PATTERN stack filler, into the latency members, while the patched kernel reports the CDAT latency values there.
--- drivers/cxl/core/cdat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cxl/core/cdat.c +4 -4
@@ -633,9 +633,9 @@ static int cxl_endpoint_gather_bandwidth(struct cxl_region *cxlr,struct cxl_port *endpoint =to_cxl_port (cxled->cxld.dev.parent);struct cxl_port *parent_port =to_cxl_port (endpoint->dev.parent);struct cxl_port *gp_port =to_cxl_port (parent_port->dev.parent); -struct access_coordinate pci_coord[ACCESS_COORDINATE_MAX ]; -struct access_coordinate sw_coord[ACCESS_COORDINATE_MAX ]; -struct access_coordinate ep_coord[ACCESS_COORDINATE_MAX ]; +struct access_coordinate pci_coord[ACCESS_COORDINATE_MAX ] = { }; +struct access_coordinate sw_coord[ACCESS_COORDINATE_MAX ] = { }; +struct access_coordinate ep_coord[ACCESS_COORDINATE_MAX ] = { };struct cxl_memdev *cxlmd =cxled_to_memdev (cxled);struct cxl_dev_state *cxlds = cxlmd->cxlds;struct pci_dev *pdev =to_pci_dev (cxlds->dev);
@@ -757,7 +757,7 @@ static struct xarray *cxl_switch_gather_bandwidth(struct cxl_region *cxlr, { struct xarray *res_xa __free(free_perf_xa) =kzalloc_obj (*res_xa); -struct access_coordinate coords[ACCESS_COORDINATE_MAX ]; +struct access_coordinate coords[ACCESS_COORDINATE_MAX ] = { };struct cxl_perf_ctx *ctx, *us_ctx;unsigned long index, us_index;int dev_count =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/2651 cxl/port: Fix uninitialized coordinates reported for RCDs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 58b2b1ef28024093063de536c05aaea792226e24 ]
cxl_endpoint_get_perf_coordinates() returns success for a Restricted CXL Device without calculating coordinates, so the caller's output array is left uninitialized. Callers treat it as valid and can expose the stack residue as access coordinates.
Initialize the coordinates to zero before returning for an RCD. Zeroing in the helper rather than at the caller keeps the @coord output contract the exported function documents.
Reported by the Sashiko review bot.
--- drivers/cxl/core/port.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cxl/core/port.c +3 -1
@@ -2437,8 +2437,10 @@ int cxl_endpoint_get_perf_coordinates(struct cxl_port *port,* Skip calculation for RCD. Expectation is HMAT already covers RCD case * since RCH does not support hotplug. */ -if (cxlmd->cxlds->rcd) +if (cxlmd->cxlds->rcd) { +memset (coord,0 ,sizeof (*coord) *ACCESS_COORDINATE_MAX );return 0 ; + }/* * Exit the loop when the parent port of the current iter port is cxl
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/2651 cxl/core: Fix dport use-after-free via the einj_inject debugfs file
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 0de71a1ab211694be7e88d56fc35c9bf72078ad1 ]
The per-dport einj_inject debugfs file retains a pointer to the 'struct cxl_dport', but its lifetime is not tied to the dport. Unbinding the dport host frees the dport and leaves einj_inject behind, so writing the file dereferences freed memory.
The stale directory also prevents recreation on rebind.
Remove the per-dport debugfs directory when the dport host is released.
Found by code inspection, then reproduced on a QEMU CXL topology with KASAN (the einj_cxl_is_initialized() guard had to be forced open, as QEMU emits no EINJ table). Unpatched, writing the leftover file after unbind gives a KASAN slab-use-after-free report in cxl_einj_inject(), and rebind hits "already exists in 'cxl'". Patched, the directory goes away with the dport and rebind recreates a working einj_inject.
--- drivers/cxl/core/port.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/cxl/core/port.c +7 -0
@@ -823,6 +823,11 @@ static int cxl_einj_inject(void *data, u64 type)DEFINE_DEBUGFS_ATTRIBUTE (cxl_einj_inject_fops,NULL , cxl_einj_inject,"0x%llx\n" ); +static void remove_debugfs (void *dentry) +{ +debugfs_remove_recursive (dentry); +} +static void cxl_debugfs_create_dport_dir (struct cxl_dport *dport) {struct cxl_port *parent =parent_port_of (dport->port);
@@ -841,6 +846,8 @@ static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport) dir =cxl_debugfs_create_dir (dev_name (dport->dport_dev)); +devm_add_action_or_reset (dport_to_host (dport), remove_debugfs, dir); +debugfs_create_file ("einj_inject" ,0200 , dir, dport, &cxl_einj_inject_fops); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/2651 cxl/region: Unregister the pmem region when the bridge is unbound
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit bb26797c08d408ea7e8d3625045f0fe28714a425 ]
Removing cxl_acpi unbinds the nvdimm bridge before the regions it serves. A region probe can therefore register its cxl_pmem_region and only then find the bridge unbound, which leaves the new device with nothing to remove it.
The orphan outlives the teardown and pins its region and its memdevs, so a later cxl_acpi bind renumbers the root port, ports, endpoints, decoders and the memdev.
Unregister the cxl_pmem_region when the bridge is unbound.
Found by code inspection. Racing a cxl_region bind against a cxl_acpi unbind leaked a pmem_region device on 12 of 12 attempts, and none with this patch.
--- drivers/cxl/core/region_pmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cxl/core/region_pmem.c +4 -2
@@ -168,12 +168,14 @@ int devm_cxl_add_pmem_region(struct cxl_region *cxlr) dev_name(dev)); scoped_guard(device, &cxl_nvb->dev) { -if (cxl_nvb->dev.driver) +if (cxl_nvb->dev.driver) { rc =devm_add_action_or_reset (&cxl_nvb->dev, cxlr_pmem_unregister, cxlr_pmem); -else + }else { rc = -ENXIO ; +cxlr_pmem_unregister (cxlr_pmem); + } }if (rc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/2651 arm64: dts: qcom: glymur: Mark USB controllers dma-coherent
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Ociepka <[email protected]>
[ Upstream commit e62df36f34949aebe016c5c81e34baa7a9eca427 ]
All five USB controller nodes on Glymur (usb_0, usb_1, usb_2, usb_hs, usb_mp) are missing the dma-coherent property, which Hamoa carries on all of its USB controllers. Krishna Kurapati confirmed the Glymur USB controllers are dma-coherent [1].
Without the property the kernel treats USB DMA buffers as non-coherent and performs cache maintenance on every transfer, which coherent hardware makes redundant.
Tested on an Asus Zenbook A16 (UX3607OA): all controllers enumerate their devices as before and a 64 MiB write plus two O_DIRECT read-backs over USB mass storage produce identical checksums.
[1] https://lore.kernel.org/linux-arm-msm/[email protected]/
--- arch/arm64/boot/dts/qcom/glymur.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/glymur.dtsi +10 -0
@@ -4618,6 +4618,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, usb-role-switch; wakeup-source; + dma-coherent; + status = "disabled"; ports {
@@ -4706,6 +4708,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, usb-role-switch; wakeup-source; + dma-coherent; + status = "disabled"; ports {
@@ -4794,6 +4798,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, usb-role-switch; wakeup-source; + dma-coherent; + status = "disabled"; ports {
@@ -4884,6 +4890,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, usb-role-switch; wakeup-source; + dma-coherent; + status = "disabled"; };
@@ -4968,6 +4976,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, dr_mode = "host"; wakeup-source; + dma-coherent; + status = "disabled"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/2651 thermal/drivers/airoha: Request the EN7581 IRQ after zone registration
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaliy Sochnev <[email protected]>
[ Upstream commit 7efceedd23678cd58e98b2c64d4b2b7be03f6cf9 ]
The EN7581 IRQ is requested before the thermal zone is registered, and the handler passes priv->tz to thermal_zone_device_update(). Unbind leaves the monitor interrupt enabled, so an interrupt pending on the next bind fires while priv->tz is NULL. On a Nokia XG-040G-MD this oopses in thermal_zone_device_update(). On unbind, devres also frees the zone before the IRQ.
Request the IRQ in post_probe, after zone registration.
--- drivers/thermal/airoha_thermal.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/thermal/airoha_thermal.c +13 -11
@@ -528,7 +528,7 @@ static int en7581_thermal_probe(struct platform_device *pdev,struct device_node *chip_scu_np;struct device *dev = &pdev->dev;void __iomem *base; -int i, irq, ret; +int i; base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (base))
@@ -567,16 +567,6 @@ static int en7581_thermal_probe(struct platform_device *pdev,of_address_to_resource (chip_scu_np,0 , &priv->scu_adc_res);of_node_put (chip_scu_np); - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; - - ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , - en7581_thermal_irq,IRQF_ONESHOT , - pdev->name, priv); -if (ret) -return ret; -en7581_thermal_setup_monitor (priv);en7581_thermal_setup_adc_val (dev, priv);
@@ -586,6 +576,18 @@ static int en7581_thermal_probe(struct platform_device *pdev,static int en7581_thermal_post_probe (struct platform_device *pdev) {struct airoha_thermal_priv *priv =platform_get_drvdata (pdev); +int irq, ret; + +/* After zone registration: the handler uses priv->tz */ + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + en7581_thermal_irq,IRQF_ONESHOT , + pdev->name, priv); +if (ret) +return ret;/* Enable LOW and HIGH interrupt (if supported) */ regmap_write(priv->map, EN7581_TEMPMONINT,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/2651 crypto: qat - fix active_devs leak on crypto alg registration failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 178829f1b5b259938188a10f4103fdb901b6435e ]
adf_dev_start() registered both alg sets in a single condition. If qat_algs_register() succeeds but qat_asym_algs_register() fails, ADF_STATUS_CRYPTO_ALGS_REGISTERED is left clear, so adf_dev_stop() skips qat_algs_unregister(): the skciphers and aeads stay registered with active_devs stuck at 1, pinning the module.
Both helpers leak active_devs internally as well - they increment it and return without decrementing when a crypto_register_*() call fails, and the asym path also leaves the already-registered akcipher behind.
Split the registration in adf_dev_start() so that an asym failure unregisters qat_algs, and unwind active_devs (and the akcipher) on the error paths of both register helpers. While at it, propagate the error code returned by the register helpers instead of a blanket -EFAULT.
--- .../crypto/intel/qat/qat_common/adf_init.c | 24 ++++++++++++----- .../crypto/intel/qat/qat_common/qat_algs.c | 15 ++++++----- .../intel/qat/qat_common/qat_asym_algs.c | 26 ++++++++++++++----- 3 files changed, 45 insertions(+), 20 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_init.c +17 -7
@@ -260,13 +260,23 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev)clear_bit (ADF_STATUS_STARTING , &accel_dev->status);set_bit (ADF_STATUS_STARTED , &accel_dev->status); -if (!list_empty (&accel_dev->crypto_list) && - (qat_algs_register () ||qat_asym_algs_register ())) { -dev_err (&GET_DEV (accel_dev), -"Failed to register crypto algs\n" ); -set_bit (ADF_STATUS_STARTING , &accel_dev->status); -clear_bit (ADF_STATUS_STARTED , &accel_dev->status); -return -EFAULT ; +if (!list_empty (&accel_dev->crypto_list)) { + ret =qat_algs_register (); +if (ret) { +dev_err (&GET_DEV (accel_dev),"Failed to register crypto algs\n" ); +set_bit (ADF_STATUS_STARTING , &accel_dev->status); +clear_bit (ADF_STATUS_STARTED , &accel_dev->status); +return ret; + } + + ret =qat_asym_algs_register (); +if (ret) { +dev_err (&GET_DEV (accel_dev),"Failed to register crypto asym algs\n" ); +qat_algs_unregister (); +set_bit (ADF_STATUS_STARTING , &accel_dev->status); +clear_bit (ADF_STATUS_STARTED , &accel_dev->status); +return ret; + } }set_bit (ADF_STATUS_CRYPTO_ALGS_REGISTERED , &accel_dev->status);
drivers/crypto/intel/qat/qat_common/qat_algs.c +9 -6
@@ -1320,19 +1320,22 @@ int qat_algs_register(void) ret =crypto_register_skciphers (qat_skciphers,ARRAY_SIZE (qat_skciphers));if (ret) - goto unlock; + goto err_dec; ret =crypto_register_aeads (qat_aeads,ARRAY_SIZE (qat_aeads));if (ret) - goto unreg_algs; + goto err_unreg_skciphers; -unlock:mutex_unlock (&algs_lock); -return ret; +return 0 ; -unreg_algs: +err_unreg_skciphers:crypto_unregister_skciphers (qat_skciphers,ARRAY_SIZE (qat_skciphers)); - goto unlock; +err_dec: + active_devs--; +unlock: +mutex_unlock (&algs_lock); +return ret; }void qat_algs_unregister (void )
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +19 -7
@@ -1340,13 +1340,25 @@ int qat_asym_algs_register(void)int ret =0 ;mutex_lock (&algs_lock); -if (++active_devs ==1 ) { - rsa.base.cra_flags =0 ; - ret =crypto_register_akcipher (&rsa); -if (ret) - goto unlock; - ret =crypto_register_kpp (&dh); - } +if (++active_devs !=1 ) + goto unlock; + + rsa.base.cra_flags =0 ; + ret =crypto_register_akcipher (&rsa); +if (ret) + goto err_dec; + + ret =crypto_register_kpp (&dh); +if (ret) + goto err_unreg_akcipher; + +mutex_unlock (&algs_lock); +return 0 ; + +err_unreg_akcipher: +crypto_unregister_akcipher (&rsa); +err_dec: + active_devs--; unlock:mutex_unlock (&algs_lock);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/2651 crypto: atmel-sha - reject initialization without a device
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit a9a2152d292fd0bc73814eb4a127278ee7dd3f6a ]
A transform may be initialized for the first time after the last device has been removed from the driver list. Return -ENODEV when the lookup is empty, before the debug message reads dd->dev.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- drivers/crypto/atmel-sha.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/atmel-sha.c +3 -0
@@ -422,6 +422,9 @@ static int atmel_sha_init(struct ahash_request *req)struct atmel_sha_reqctx *ctx =ahash_request_ctx (req);struct atmel_sha_dev *dd =atmel_sha_find_dev (tctx); +if (!dd) +return -ENODEV ; + ctx->dd = dd; ctx->flags =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/2651 interconnect: exynos: Remove the PM QoS request on unbind
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 601a54f00723b0b653d76caf26a2a78482d95f00 ]
The Exynos interconnect provider adds a minimum-frequency PM QoS request to its parent devfreq device. The request is embedded in the provider's device-managed private data.
The probe error path removes the request, but the remove callback does not. Unbinding the provider while the parent device remains registered therefore frees the private data with the request still on the parent's QoS list. The child's device cleanup does not remove requests registered against its parent.
Remove the request after deregistering the provider, before the private data is released.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/interconnect/samsung/exynos.c | 1 + 1 file changed, 1 insertion(+)
drivers/interconnect/samsung/exynos.c +1 -0
@@ -98,6 +98,7 @@ static void exynos_generic_icc_remove(struct platform_device *pdev)struct exynos_icc_priv *priv =platform_get_drvdata (pdev);icc_provider_deregister (&priv->provider); +dev_pm_qos_remove_request (&priv->qos_req);icc_nodes_remove (&priv->provider); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 573/2651 interconnect: qcom: icc-rpm: Handle icc_link_create() failures
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit b2079a6b8e8b92c6c45a22930e5b68a9c5c34645 ]
icc_link_create() can return errors. Don't ignore them.
--- drivers/interconnect/qcom/icc-rpm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/interconnect/qcom/icc-rpm.c +9 -2
@@ -583,8 +583,15 @@ int qnoc_probe(struct platform_device *pdev) node->data = qnodes[i];icc_node_add (node, provider); -for (j =0 ; j < qnodes[i]->num_links; j++) -icc_link_create (node, qnodes[i]->links[j]); +for (j =0 ; j < qnodes[i]->num_links; j++) { + ret =icc_link_create (node, qnodes[i]->links[j]); +if (ret) { +icc_nodes_remove (provider); +clk_bulk_disable_unprepare (qp->num_intf_clks, + qp->intf_clks); + goto err_disable_unprepare_clk; + } + }/* Set QoS registers (we only need to do it once, generally) */ if (qnodes[i]->qos.ap_owned &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 574/2651 interconnect: qcom: icc-rpm: Program SMD RPM auxiliary QoS ports
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit ddbacca26d1db5bd9c477253b0af83b028136a24 ]
Some SMD RPM interconnect nodes own two QoS ports. Currently, the code only takes care of one, leaving some endpoints partially unconfigured.
Keep qos_port as the primary port and describe the optional second port with aux_qos_port.
Stable-dep-of: aa4c405d47c5 ("interconnect: qcom: msm8996: Configure auxiliary Venus QoS port")
--- drivers/interconnect/qcom/icc-rpm.c | 82 +++++++++++++++++++++++++---- drivers/interconnect/qcom/icc-rpm.h | 2 + 2 files changed, 73 insertions(+), 11 deletions(-)
drivers/interconnect/qcom/icc-rpm.c +71 -11
@@ -58,15 +58,32 @@ static int qcom_icc_set_qnoc_qos(struct icc_node *src)struct qcom_icc_qos *qos = &qn->qos;int rc; + rc =regmap_update_bits (qp->regmap, + qp->qos_offset +QNOC_QOS_MCTL_LOWn_ADDR (qos->qos_port), +QNOC_QOS_MCTL_DFLT_PRIO_MASK , + qos->areq_prio <<QNOC_QOS_MCTL_DFLT_PRIO_SHIFT ); +if (rc) +return rc; + rc =regmap_update_bits (qp->regmap, qp->qos_offset +QNOC_QOS_MCTL_LOWn_ADDR (qos->qos_port), -QNOC_QOS_MCTL_DFLT_PRIO_MASK , - qos->areq_prio <<QNOC_QOS_MCTL_DFLT_PRIO_SHIFT ); +QNOC_QOS_MCTL_URGFWD_EN_MASK , + !!qos->urg_fwd_en <<QNOC_QOS_MCTL_URGFWD_EN_SHIFT ); +if (rc) +return rc; + +if (!qos->aux_qos_port) +return 0 ; + + rc =regmap_update_bits (qp->regmap, + qp->qos_offset +QNOC_QOS_MCTL_LOWn_ADDR (qos->aux_qos_port), +QNOC_QOS_MCTL_DFLT_PRIO_MASK , + qos->areq_prio <<QNOC_QOS_MCTL_DFLT_PRIO_SHIFT );if (rc)return rc;return regmap_update_bits (qp->regmap, - qp->qos_offset +QNOC_QOS_MCTL_LOWn_ADDR (qos->qos_port), + qp->qos_offset +QNOC_QOS_MCTL_LOWn_ADDR (qos->aux_qos_port),QNOC_QOS_MCTL_URGFWD_EN_MASK , !!qos->urg_fwd_en <<QNOC_QOS_MCTL_URGFWD_EN_SHIFT ); }
@@ -75,8 +92,9 @@ static int qcom_icc_bimc_set_qos_health(struct qcom_icc_provider *qp, struct qcom_icc_qos *qos, int regnum) { -u32 val;u32 mask; +u32 val; +int ret; val = qos->prio_level; mask =M_BKE_HEALTH_CFG_PRIOLVL_MASK ;
@@ -90,8 +108,17 @@ static int qcom_icc_bimc_set_qos_health(struct qcom_icc_provider *qp, mask |=M_BKE_HEALTH_CFG_LIMITCMDS_MASK ; } + ret =regmap_update_bits (qp->regmap, + qp->qos_offset +M_BKE_HEALTH_CFG_ADDR (regnum, qos->qos_port), + mask, val); +if (ret) +return ret; + +if (!qos->aux_qos_port) +return 0 ; +return regmap_update_bits (qp->regmap, - qp->qos_offset +M_BKE_HEALTH_CFG_ADDR (regnum, qos->qos_port), + qp->qos_offset +M_BKE_HEALTH_CFG_ADDR (regnum, qos->aux_qos_port), mask, val); }
@@ -102,7 +129,7 @@ static int qcom_icc_set_bimc_qos(struct icc_node *src)struct icc_provider *provider;u32 mode =NOC_QOS_MODE_BYPASS ;u32 val =0 ; -int i, rc =0 ; +int i, rc; qn = src->data; provider = src->provider;
@@ -116,8 +143,7 @@ static int qcom_icc_set_bimc_qos(struct icc_node *src)*/ if (mode !=NOC_QOS_MODE_BYPASS ) {for (i =3 ; i >=0 ; i--) { - rc =qcom_icc_bimc_set_qos_health (qp, - &qn->qos, i); + rc =qcom_icc_bimc_set_qos_health (qp, &qn->qos, i);if (rc)return rc; }
@@ -126,8 +152,17 @@ static int qcom_icc_set_bimc_qos(struct icc_node *src) val =1 ; } + rc =regmap_update_bits (qp->regmap, + qp->qos_offset +M_BKE_EN_ADDR (qn->qos.qos_port), +M_BKE_EN_EN_BMASK , val); +if (rc) +return rc; + +if (!qn->qos.aux_qos_port) +return 0 ; +return regmap_update_bits (qp->regmap, - qp->qos_offset +M_BKE_EN_ADDR (qn->qos.qos_port), + qp->qos_offset +M_BKE_EN_ADDR (qn->qos.aux_qos_port),M_BKE_EN_EN_BMASK , val); }
@@ -145,8 +180,24 @@ static int qcom_icc_noc_set_qos_priority(struct qcom_icc_provider *qp,if (rc)return rc; + rc =regmap_update_bits (qp->regmap, + qp->qos_offset +NOC_QOS_PRIORITYn_ADDR (qos->qos_port), +NOC_QOS_PRIORITY_P0_MASK , qos->prio_level); +if (rc) +return rc; + +if (!qos->aux_qos_port) +return 0 ; + + val = qos->areq_prio <<NOC_QOS_PRIORITY_P1_SHIFT ; + rc =regmap_update_bits (qp->regmap, + qp->qos_offset +NOC_QOS_PRIORITYn_ADDR (qos->aux_qos_port), +NOC_QOS_PRIORITY_P1_MASK , val); +if (rc) +return rc; +return regmap_update_bits (qp->regmap, - qp->qos_offset +NOC_QOS_PRIORITYn_ADDR (qos->qos_port), + qp->qos_offset +NOC_QOS_PRIORITYn_ADDR (qos->aux_qos_port),NOC_QOS_PRIORITY_P0_MASK , qos->prio_level); }
@@ -182,8 +233,17 @@ static int qcom_icc_set_noc_qos(struct icc_node *src)/* How did we get here? */ } + rc =regmap_update_bits (qp->regmap, + qp->qos_offset +NOC_QOS_MODEn_ADDR (qn->qos.qos_port), + NOC_QOS_MODEn_MASK, mode); +if (rc) +return rc; + +if (!qn->qos.aux_qos_port) +return 0 ; +return regmap_update_bits (qp->regmap, - qp->qos_offset +NOC_QOS_MODEn_ADDR (qn->qos.qos_port), + qp->qos_offset +NOC_QOS_MODEn_ADDR (qn->qos.aux_qos_port), NOC_QOS_MODEn_MASK, mode); }
drivers/interconnect/qcom/icc-rpm.h +2 -0
@@ -77,6 +77,7 @@ struct qcom_icc_provider {* @ap_owned: indicates if the node is owned by the AP or by the RPM * @qos_mode: default qos mode for this node * @qos_port: qos port number for finding qos registers of this node +* @aux_qos_port: optional QoS port in addition to @qos_port. Zero means "none". * @urg_fwd_en: enable urgent forwarding */ struct qcom_icc_qos {
@@ -86,6 +87,7 @@ struct qcom_icc_qos {bool ap_owned;int qos_mode;int qos_port; +u16 aux_qos_port;bool urg_fwd_en; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 575/2651 interconnect: qcom: msm8996: Configure auxiliary Venus QoS port
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit aa4c405d47c54bcf6d62d0f6596aeb555e52ebf7 ]
Enable the secondary QoS port used by the MSM8996 Venus node.
--- drivers/interconnect/qcom/msm8996.c | 1 + 1 file changed, 1 insertion(+)
drivers/interconnect/qcom/msm8996.c +1 -0
@@ -501,6 +501,7 @@ static struct qcom_icc_node mas_venus = { .qos.areq_prio = 0, .qos.prio_level = 0, .qos.qos_port = 3, + .qos.aux_qos_port = 4, .num_links = ARRAY_SIZE(mas_mnoc_bimc_common_links), .links = mas_mnoc_bimc_common_links };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 576/2651 interconnect: qcom: msm8976: Configure auxiliary GPU QoS port
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit cc91c1b99101f2dcd2f624a27bec6f6f557e5421 ]
Enable the secondary QoS port used by the MSM8976 GPU node.
--- drivers/interconnect/qcom/msm8976.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/interconnect/qcom/msm8976.c +2 -1
@@ -454,7 +454,8 @@ static struct qcom_icc_node mas_oxili = { .qos.qos_mode = NOC_QOS_MODE_BYPASS, .qos.areq_prio = 0, .qos.prio_level = 0, - .qos.qos_port = 16, /* [16, 17] */ + .qos.qos_port = 16, + .qos.aux_qos_port = 17, .num_links = ARRAY_SIZE(mas_oxili_links), .links = mas_oxili_links, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 577/2651 interconnect: qcom: use 64-bit SMD RPM bus votes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 24e7422ce31189502d07279c083646aaca513311 ]
SMD RPM bus bandwidth requests carry a 64-bit bandwidth value. The interconnect proxy declared the KVP payload as u32, truncating votes above 4 GiB/s and advertising the wrong payload size to RPM.
Use a little-endian 64-bit payload and accept a u64 value in the proxy API. This has always been the right behavior, even on msm-3.10 and 32-bit SoCs.
--- drivers/interconnect/qcom/icc-rpm.h | 4 ++-- drivers/interconnect/qcom/smd-rpm.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/interconnect/qcom/icc-rpm.h +2 -2
@@ -30,7 +30,7 @@ enum qcom_icc_type {* @resource_type: RPM resource type of the clock resource * @clock_id: index of the clock resource of a specific resource type * @branch: whether the resource represents a branch clock -*/ +*/ struct rpm_clk_resource {u32 resource_type;u32 clock_id;
@@ -169,7 +169,7 @@ int qnoc_probe(struct platform_device *pdev);void qnoc_remove (struct platform_device *pdev);bool qcom_icc_rpm_smd_available (void ); -int qcom_icc_rpm_smd_send (int ctx,int rsc_type,int id,u32 val); +int qcom_icc_rpm_smd_send (int ctx,int rsc_type,int id,u64 val);int qcom_icc_rpm_set_bus_rate (const struct rpm_clk_resource *clk,int ctx,u32 rate);#endif
drivers/interconnect/qcom/smd-rpm.c +4 -4
@@ -20,7 +20,7 @@ static struct qcom_smd_rpm *icc_smd_rpm;struct icc_rpm_smd_req {__le32 key;__le32 nbytes; -__le32 value; +__le64 value; };bool qcom_icc_rpm_smd_available (void )
@@ -29,12 +29,12 @@ bool qcom_icc_rpm_smd_available(void) }EXPORT_SYMBOL_GPL (qcom_icc_rpm_smd_available); -int qcom_icc_rpm_smd_send (int ctx,int rsc_type,int id,u32 val) +int qcom_icc_rpm_smd_send (int ctx,int rsc_type,int id,u64 val) {struct icc_rpm_smd_req req = { .key =cpu_to_le32 (RPM_KEY_BW ), - .nbytes =cpu_to_le32 (sizeof (u32)), - .value =cpu_to_le32 (val), + .nbytes =cpu_to_le32 (sizeof (u64)), + .value =cpu_to_le64 (val), }; return qcom_rpm_smd_write(icc_smd_rpm, ctx, rsc_type, id, &req,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 578/2651 rust: pin-init: internal: init: support tuple structs in `[pin_]init!`
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Alsadhan <[email protected]>
[ Upstream commit d48aa955cb91745ef2e5089f9277a7a95060cce3 ]
Extend the initializer syntax so that a field can be named by an index, addressing tuple struct fields the same way a struct expression does:
pin_init!(Foo { 0: value, 1 <- initializer })Tuple fields are not exposed by a let binding to the fields after them, since they have no name to bind; _0 would shadow a user variable.
Stable-dep-of: e30decc3f9a0 ("rust: pin-init: internal: init: emit slot using mixed site hygiene")
--- rust/pin-init/internal/src/init.rs | 115 +++++++++++++++++------------ rust/pin-init/src/lib.rs | 32 +++++++- 2 files changed, 95 insertions(+), 52 deletions(-)
rust/pin-init/internal/src/init.rs +67 -48
@@ -8,10 +8,13 @@ parse_quote, punctuated::Punctuated, spanned::Spanned, - token, Attribute, Block, Expr, ExprCall, ExprPath, Ident, Path, Token, Type, + token, Attribute, Block, Expr, ExprCall, ExprPath, Ident, LitInt, Member, Path, Token, Type, }; -use crate ::diagnostics::{DiagCtxt ,ErrorGuaranteed }; +use crate ::{ + diagnostics::{DiagCtxt ,ErrorGuaranteed }, + util::*, +};pub (crate )struct Initializer { attrs:Vec <InitializerAttribute >,
@@ -36,11 +39,11 @@ struct InitializerField {enum InitializerKind {Value { - ident:Ident , + member:Member , value:Option <(Token! [:],Expr )>, },Init { - ident:Ident , + member:Member , _left_arrow_token:Token! [<-], value:Expr , },
@@ -52,9 +55,9 @@ enum InitializerKind { }impl InitializerKind { -fn ident (&self) ->Option <&Ident > { +fn member (&self) ->Option <&Member > {match self { -Self ::Value { ident, .. } |Self ::Init { ident, .. } =>Some (ident), +Self ::Value { member, .. } |Self ::Init { member, .. } =>Some (member),Self ::Code { .. } =>None , } }
@@ -229,9 +232,9 @@ fn init_fields( cfgs }; -let ident =match kind { -InitializerKind ::Value { ident, .. } => ident, -InitializerKind ::Init { ident, .. } => ident, +let member =match kind { +InitializerKind ::Value { member, .. } => member, +InitializerKind ::Init { member, .. } => member,InitializerKind ::Code { block, .. } => {let stmt = &block.stmts; res.extend (quote! {
@@ -243,27 +246,28 @@ fn init_fields(continue ; } }; +let ident = member.as_ident ();let slot =if pinned {quote! {// SAFETY: // - `slot` is valid and properly aligned. -// - `make_field_check` checks that `&raw mut (*slot).#ident` is properly aligned. -// - `make_field_check` prevents `#ident` from being used twice, therefore -// `(*slot).#ident` is exclusively accessed and has not been initialized. +// - `make_field_check` checks that `&raw mut (*slot).#member` is properly aligned. +// - `make_field_check` prevents `#member` from being used twice, therefore +// `(*slot).#member` is exclusively accessed and has not been initialized. (unsafe { #data.#ident(#slot) }) } }else {quote! {// For `init!()` macro, everything is unpinned. // SAFETY: -// - `&raw mut (*slot).#ident` is valid. -// - `make_field_check` checks that `&raw mut (*slot).#ident` is properly aligned. -// - `make_field_check` prevents `#ident` from being used twice, therefore -// `(*slot).#ident` is exclusively accessed and has not been initialized. +// - `&raw mut (*slot).#member` is valid. +// - `make_field_check` checks that `&raw mut (*slot).#member` is properly aligned. +// - `make_field_check` prevents `#member` from being used twice, therefore +// `(*slot).#member` is exclusively accessed and has not been initialized. (unsafe { ::pin_init::__internal::Slot ::<::pin_init::__internal::Unpinned ,_ >::new ( - &raw mut (*#slot).#ident + &raw mut (*#slot).#member ) }) }
@@ -273,11 +277,11 @@ fn init_fields(let guard =format_ident! ("__{ident}_guard" , span =Span ::mixed_site ());let init =match kind { -InitializerKind ::Value { ident, value } => { +InitializerKind ::Value { value, .. } => {let value = value .as_ref () .map (|(_, value)|quote! (#value)) - .unwrap_or_else (||quote! (#ident)); + .unwrap_or_else (||quote! (#member));quote! { #(#attrs)*
@@ -294,14 +298,23 @@ fn init_fields( InitializerKind::Code { .. } => unreachable!(), }; +// A tuple field has no name that could be bound here (the `_0` identifiers are considered +// implementation detail and not user-facing). +let binding =match member { +Member ::Named (ident) =>quote! { + #(#cfgs)* +// Allow `non_snake_case` since the same warning is going to be reported for the +// struct field. +#[allow(unused_variables, non_snake_case)] +let #ident = #guard.let_binding(); + }, +Member ::Unnamed (_) =>quote! (), + }; + res.extend (quote! { #init - #(#cfgs)* -// Allow `non_snake_case` since the same warning is going to be reported for the struct -// field. -#[allow(unused_variables, non_snake_case)] -let #ident = #guard.let_binding(); + #binding }); guards.push (guard);
@@ -326,9 +339,9 @@ fn make_field_check( ) -> TokenStream { let field_attrs: Vec<_> = fields .iter () - .filter_map (|f| f.kind.ident ().map (|_| &f.attrs)) + .filter_map (|f| f.kind.member ().map (|_| &f.attrs)) .collect(); -let field_name:Vec <_ > = fields.iter ().filter_map (|f| f.kind.ident ()).collect (); +let field_name:Vec <_ > = fields.iter ().filter_map (|f| f.kind.member ()).collect ();let zeroing_trailer =match init_kind {InitKind ::Normal =>None , InitKind::Zeroing => Some(quote! {
@@ -376,7 +389,8 @@ fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {let lh = content.lookahead1 ();if lh.peek (End ) || lh.peek (Token! [..]) {break ; - }else if lh.peek (Ident ) || lh.peek (Token! [_]) || lh.peek (Token! [#]) { + }else if lh.peek (Ident ) || lh.peek (LitInt ) || lh.peek (Token! [_]) || lh.peek (Token! [#]) + { fields.push_value (content.parse ()?);let lh = content.lookahead1 ();if lh.peek (End ) {
@@ -450,31 +464,36 @@ fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {impl Parse for InitializerKind {fn parse (input: syn::parse::ParseStream <'_>) -> syn::Result <Self > {let lh = input.lookahead1 (); -if lh.peek (Token! [_]) { -Ok (Self ::Code { +let member =if lh.peek (Token! [_]) { +return Ok (Self ::Code { _underscore_token: input.parse ()?, _colon_token: input.parse ()?, block: input.parse ()?, + }); + }else if lh.peek (Ident ) || lh.peek (LitInt ) { + input.parse ::<Member >()? + }else { +return Err (lh.error ()); + }; + +let lh = input.lookahead1 (); +if lh.peek (Token! [<-]) { +Ok (Self ::Init { + member, + _left_arrow_token: input.parse ()?, + value: input.parse ()?, + }) + }else if lh.peek (Token! [:]) { +Ok (Self ::Value { + member, + value:Some ((input.parse ()?, input.parse ()?)), + }) + }else if matches! (member,Member ::Named (_)) && (lh.peek (Token! [,]) || lh.peek (End )) { +// Short-hand syntax, available for named fields only. +Ok (Self ::Value { + member, + value:None , }) - }else if lh.peek (Ident ) { -let ident = input.parse ()?; -let lh = input.lookahead1 (); -if lh.peek (Token! [<-]) { -Ok (Self ::Init { - ident, - _left_arrow_token: input.parse ()?, - value: input.parse ()?, - }) - }else if lh.peek (Token! [:]) { -Ok (Self ::Value { - ident, - value:Some ((input.parse ()?, input.parse ()?)), - }) - }else if lh.peek (Token! [,]) || lh.peek (End ) { -Ok (Self ::Value { ident, value:None }) - }else { -Err (lh.error ()) - } }else {Err (lh.error ()) }
rust/pin-init/src/lib.rs +28 -4
@@ -569,7 +569,7 @@ macro_rules! stack_try_pin_init { }; } -/// Construct an in-place, fallible pinned initializer for `struct`s. +/// Construct an in-place, fallible pinned initializer for structs, including tuple structs. /// /// The error type defaults to [`Infallible`]; if you need a different one, write `? Error` at the /// end, after the struct initializer.
@@ -603,6 +603,28 @@ macro_rules! stack_try_pin_init {/// # Box::pin_init(demo()).unwrap(); /// ``` /// +/// The fields of a tuple struct are addressed by their index: +/// +/// ```rust +/// # use pin_init::*; +/// # use core::pin::Pin; +/// #[pin_data] +/// struct Pair(usize, Bar); +/// +/// #[pin_data] +/// struct Bar { +/// x: u32, +/// } +/// +/// # fn demo() -> impl PinInit<Pair> { +/// let initializer = pin_init!(Pair { +/// 0: 42, +/// 1 <- Bar { x: 64 }, +/// }); +/// # initializer } +/// # Box::pin_init(demo()).unwrap(); +/// ``` +/// /// Arbitrary Rust expressions can be used to set the value of a variable. /// /// The fields are initialized in the order that they appear in the initializer. So it is possible
@@ -721,9 +743,11 @@ macro_rules! stack_try_pin_init {/// /// # Syntax /// -/// As already mentioned in the examples above, inside of `pin_init!` a `struct` initializer with -/// the following modifications is expected: +/// As already mentioned in the examples above, inside of `pin_init!` a struct initializer with the +/// following modifications is expected: /// - Fields that you want to initialize in-place have to use `<-` instead of `:`. +/// - Tuple struct fields are named by their index, as in `0: value` or `0 <- initializer`. They +/// are not exposed by a `let` binding, since they have no name to bind. /// - You can use `_: { /* run any user-code here */ },` anywhere where you can place fields in /// order to run arbitrary code. /// - In front of the initializer you can write `&this in` to have access to a [`NonNull<Self>`]
@@ -762,7 +786,7 @@ macro_rules! stack_try_pin_init {/// [`NonNull<Self>`]: core::ptr::NonNull pub use pin_init_internal::pin_init; -/// Construct an in-place, fallible initializer for `struct`s. +/// Construct an in-place, fallible initializer for structs, including tuple structs. /// /// This macro defaults the error to [`Infallible`]; if you need a different one, write `? Error` /// at the end, after the struct initializer.
Signature · 1 line
2.53.0
Re: [PATCH 7.3 0578/2651] rust: pin-init: internal: init: support tuple structs in `[pin_]init!`
Quoted 34 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Alsadhan <[email protected]>
[ Upstream commit
d48aa955cb91745ef2e5089f9277a7a95060cce3]Extend the initializer syntax so that a field can be named by an index, addressing tuple struct fields the same way a struct expression does:
pin_init!(Foo { 0: value, 1 <- initializer })Tuple fields are not exposed by a
letbinding to the fields after them, since they have no name to bind;_0would shadow a user variable.Signed-off-by Mohamad Alsadhan <[email protected]>[ Fixed incorrect index calculation and cleaned up the code - Gary ]Signed-off-by Gary Guo <[email protected]>Stable-dep-of:
e30decc3f9a0("rust: pin-init: internal: init: emitslotusing mixed site hygiene")Signed-off-by Sasha Levin <[email protected]>--- rust/pin-init/internal/src/init.rs | 115 +++++++++++++++++------------ rust/pin-init/src/lib.rs | 32 +++++++- 2 files changed, 95 insertions(+), 52 deletions(-)rust/pin-init/internal/src/init.rs +0
-0@@ -8,10 +8,13 @@ parse_quote, punctuated::Punctuated,
rust/pin-init/internal/src/init.rs line 17
Quoted 10 lines
rust/pin-init/internal/src/init.rs +5
-2spanned::Spanned, - token, Attribute, Block, Expr, ExprCall, ExprPath, Ident, Path, Token, Type, + token, Attribute, Block, Expr, ExprCall, ExprPath, Ident, LitInt, Member, Path, Token, Type, }; -use crate ::diagnostics::{DiagCtxt ,ErrorGuaranteed }; +use crate ::{ + diagnostics::{DiagCtxt ,ErrorGuaranteed }, + util::*, +};
Now I see:
[ 70s] error[E0432]: unresolved import `crate::util` [ 70s] --> ../rust/pin-init/internal/src/init.rs:17:5 [ 70s] | [ 70s] 17 | util::*, [ 70s] | ^^^^ could not find `util` in the crate root [ 70s]
Signature · 2 lines
js suse labs
Re: [PATCH 7.3 0578/2651] rust: pin-init: internal: init: support tuple structs in `[pin_]init!`
Quoted 47 lines · Jiri Slaby
Quoted 35 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Alsadhan <[email protected]>
[ Upstream commit
d48aa955cb91745ef2e5089f9277a7a95060cce3]Extend the initializer syntax so that a field can be named by an index, addressing tuple struct fields the same way a struct expression does:
pin_init!(Foo { 0: value, 1 <- initializer })
Tuple fields are not exposed by a
letbinding to the fields after them, since they have no name to bind;_0would shadow a user variable.Signed-off-by Mohamad Alsadhan <[email protected]>[ Fixed incorrect index calculation and cleaned up the code - Gary ]Signed-off-by Gary Guo <[email protected]>Stable-dep-of:
e30decc3f9a0("rust: pin-init: internal: init: emitslotusing mixed site hygiene")Signed-off-by Sasha Levin <[email protected]>---
rust/pin-init/internal/src/init.rs| 115 +++++++++++++++++------------ rust/pin-init/src/lib.rs | 32 +++++++-2 files changed, 95 insertions(+), 52 deletions(-)rust/pin-init/internal/src/init.rs +0
-0@@ -8,10 +8,13 @@ parse_quote, punctuated::Punctuated, spanned::Spanned,rust/pin-init/internal/src/init.rs line 18
Quoted 10 lines
rust/pin-init/internal/src/init.rs +5
-2- token, Attribute, Block, Expr, ExprCall, ExprPath, Ident, Path, Token, Type, + token, Attribute, Block, Expr, ExprCall, ExprPath, Ident, LitInt, Member, Path, Token, Type, }; -use crate ::diagnostics::{DiagCtxt ,ErrorGuaranteed }; +use crate ::{ + diagnostics::{DiagCtxt, ErrorGuaranteed}, + util::*, +};
Quoted 8 lines
Now I see:
[ 70s] error[E0432]: unresolved importcrate::util[ 70s] -->../rust/pin-init/internal/src/init.rs:17:5[ 70s] |
[ 70s] 17 | util::*,
[ 70s] | ^^^^ could not findutilin the crate root [ 70s]
And for this one I also see:
[ 70s] error[E0599]: no method named `as_ident` found for reference `&Member` in the current scope [ 70s] --> ../rust/pin-init/internal/src/init.rs:413:28 [ 70s] | [ 70s] 413 | let ident = member.as_ident(); [ 70s] | ^^^^^^^^ method not found in `&Member`
Either you do not pick up rust patches, or you compile-test rust ;).
Signature · 2 lines
js suse labs
Greg Kroah-Hartman
maintainerPATCH 579/2651 rust: pin-init: internal: init: support tuple struct constructor syntax
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Alsadhan <[email protected]>
[ Upstream commit 3b3ff9034a497fb3b8429f6fe8ba5697bc7dcebd ]
A tuple struct whose fields are all set to a value reads better written like a call to its constructor than with the indices spelled out:
pin_init!(Foo(value, value))
Parse the two forms into separate types and rewrite the constructor arguments into the indexed fields they are shorthand for, so that only the parser has to know about the second form.
The arguments have no names, so they cannot use <-. Parse it anyway and reject it afterwards, which reports the position of every offending <- rather than stopping at the first one.
cfg needs different treatment for tuple constructor syntax. As non-derive proc macros are invoked before cfg is resolved, the macro cannot know whether a field survives, and dropping a tuple field renumbers every field after it. That cannot be expressed by attaching a cfg attribute to the initializer of a single field. Thus, resolve tuple field cfgs up front instead, by generating two cfg-gated invocations of the macro with one field resolved in each. This is the approach of commit 5bbf2b2deb94 ("rust:
pin-init: internal: rework how #[pin_data] handles cfg"), and it is linear time because only one of the two branches is ever expanded. Struct expression syntax do not renumber, so using tuple structs with struct syntax can keep using the existing attribute-based handling.
[ Pre-expand cfgs for tuple init syntax. Use generics instead of separate
types for normalization - Gary ]
Stable-dep-of: e30decc3f9a0 ("rust: pin-init: internal: init: emit slot using mixed site hygiene")
--- rust/pin-init/internal/src/init.rs | 381 +++++++++++++++++++++++++++-- rust/pin-init/internal/src/lib.rs | 11 +- rust/pin-init/src/lib.rs | 16 ++ 3 files changed, 383 insertions(+), 25 deletions(-)
rust/pin-init/internal/src/init.rs +359 -22
@@ -1,14 +1,15 @@// SPDX-License-Identifier: Apache-2.0 OR MIT use proc_macro2::{Span ,TokenStream }; -use quote::{format_ident, quote}; +use quote::{format_ident, quote,ToTokens ,TokenStreamExt };use syn::{ - braced, + braced, parenthesized, parse::{End ,Parse }, parse_quote, - punctuated::Punctuated , + punctuated::{Pair ,Punctuated }, spanned::Spanned , - token,Attribute ,Block ,Expr ,ExprCall ,ExprPath ,Ident ,LitInt ,Member ,Path ,Token ,Type , + token,Attribute ,Block ,Expr ,ExprCall ,ExprPath ,Ident ,Index ,LitInt ,Member ,Path ,Token , +Type , };use crate ::{
@@ -16,14 +17,87 @@ util::*, }; -pub (crate )struct Initializer { +pub (crate )struct Initializer <Kind =InitExprKind > { attrs:Vec <InitializerAttribute >, this:Option <This >, + kind:Kind , + error:Option <(Token! [?],Type )>, +} + +pub (crate )struct InitExprStruct { path:Path , brace_token: token::Brace , fields:Punctuated <InitializerField ,Token! [,]>, rest:Option <(Token! [..],Expr )>, - error:Option <(Token! [?],Type )>, +} + +pub (crate )struct InitExprTuple { + path:Path , + paren_token: token::Paren , + fields:Punctuated <InitTupleField ,Token! [,]>, +} + +pub (crate )enum InitExprKind { +Struct (InitExprStruct ), +Tuple (InitExprTuple ), +} + +struct InitTupleField { + attrs:Vec <Attribute >, +/// `<-` is not valid in constructor syntax; it is parsed anyway so that it can be rejected +/// with a proper diagnostic instead of a parse error. + left_arrow_token:Option <Token! [<-]>, + value:Expr , +} + +impl InitExprTuple { +fn normalize (self) ->InitExprStruct { +let InitExprTuple { + path, + paren_token, + fields, + } = self; +InitExprStruct { + path, + brace_token: token::Brace { + span: paren_token.span, + }, + fields: fields + .into_pairs () + .enumerate () + .map (|(index, pair)| { +let (field, comma) = pair.into_tuple (); +let span = field.value.span (); +let field =InitializerField { + attrs: field.attrs, + kind:InitializerKind ::Value { + member:Member ::Unnamed (Index { + index: index.try_into ().unwrap (), + span, + }), + value:Some ((Token! [:](span), field.value)), + }, + }; +Pair ::new (field, comma) + }) + .collect (), + rest:None , + } + } + +fn validate (&self, dcx: &mut DiagCtxt ) ->Result <(),ErrorGuaranteed > { +let mut result =Ok (()); +for fieldin &self.fields { +if let Some (left_arrow_token) = &field.left_arrow_token { + result =Err (dcx.error ( + left_arrow_token, +"`<-` is not supported in tuple constructor syntax; name the fields by index \ +instead, e.g. `Type { 0 <- initializer, 1: value }`" , + )); + } + } + result + } }struct This {
@@ -71,16 +145,103 @@ struct DefaultErrorAttribute { ty: Box<Type>, } -pub (crate )fn expand ( +pub (crate )fn expand_with_cfg ( + initializer:Initializer , + default_error:Option <&'staticstr >, + pinned:bool , + dcx: &mut DiagCtxt , +) ->Result <TokenStream ,ErrorGuaranteed > { +let initializer =match initializer.kind { +InitExprKind ::Tuple (expr) => { + expr.validate (dcx)?; + +let mut initializer =Initializer { + attrs: initializer.attrs, + this: initializer.this, + kind: expr, + error: initializer.error, + }; + +// Removing a tuple field renumbers every field after it, which cannot be expressed with +// a `cfg` attribute on the initializer of a single field. Therefore, resolve tuple +// field cfgs before continuing. Struct expression syntax uses explicit numbers, so +// there is no need to pre-expand them and we only need to emit their cfgs on generated +// code. +for (field_idx, field)in initializer.kind.fields.iter_mut ().enumerate () { +let cfg = field.attrs.extract_cfg_attrs (); + +if cfg.is_empty () { +continue ; + } + +let true_initializer = initializer.to_token_stream (); + initializer.kind.fields = initializer + .kind + .fields + .into_pairs () + .enumerate () + .filter (|&(index, _)| index != field_idx) + .map (|(_, pair)| pair) + .collect (); + +let false_initializer = &initializer; + +let macro_name =if pinned { +quote! (::pin_init::pin_init) + }else { +quote! (::pin_init::init) + }; + +// Resolve one field at a time until we've got no more tuple field cfgs. +// +// This is linear time because macro invocations with false cfg will not be +// expanded. +return Ok (quote! { + { +// Use `{}` delimiter here so semicolon is not required, otherwise the +// expression becomes unit type. +#[cfg(all(#(#cfg,)*))] + #macro_name! { #true_initializer } + +#[cfg(not(all(#(#cfg,)*)))] + #macro_name! { #false_initializer } + } + }); + } + +// No cfgs left, we can normalize the initializer to the struct kind. +Initializer { + attrs: initializer.attrs, + this: initializer.this, + kind: initializer.kind.normalize (), + error: initializer.error, + } + } + +InitExprKind ::Struct (expr) =>Initializer { + attrs: initializer.attrs, + this: initializer.this, + kind: expr, + error: initializer.error, + }, + }; + +expand (initializer, default_error, pinned, dcx) +} + +fn expand (Initializer { attrs, this, - path, - brace_token, - fields, - rest, + kind: +InitExprStruct { + path, + brace_token, + fields, + rest, + }, error, - }:Initializer , + }:Initializer <InitExprStruct >, default_error:Option <&'staticstr >, pinned:bool , dcx: &mut DiagCtxt,
@@ -99,7 +260,10 @@ pub(crate) fn expand( }else if let Some (default_error) = default_error { syn::parse_str (default_error).unwrap () }else { - dcx.error (brace_token.span.close (),"expected `? <type>` after `}`" ); + dcx.error ( + brace_token.span.close (), +"expected `? <type>` after initializer" , + );parse_quote! (::core::convert::Infallible ) } },
@@ -377,11 +541,8 @@ fn make_field_check( } } -impl Parse for Initializer { -fn parse (input: syn::parse::ParseStream <'_>) -> syn::Result <Self > { -let attrs = input.call (Attribute ::parse_outer)?; -let this = input.peek (Token! [&]).then (|| input.parse ()).transpose ()?; -let path = input.parse ()?; +impl InitExprStruct { +fn parse_with_path (path:Path , input: syn::parse::ParseStream <'_>) -> syn::Result <Self > {let content;let brace_token =braced! (content in input);let mut fields =Punctuated ::new ();
@@ -408,6 +569,51 @@ fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> { .peek(Token![..]) .then (||Ok ::<_ , syn::Error >((content.parse ()?, content.parse ()?))) .transpose ()?; +Ok (Self { + path, + brace_token, + fields, + rest, + }) + } +} + +impl InitExprTuple { +fn parse_with_path (path:Path , input: syn::parse::ParseStream <'_>) -> syn::Result <Self > { +let content; +let paren_token =parenthesized! (content in input); +let mut fields =Punctuated ::new (); +while !content.is_empty () { + fields.push_value (InitTupleField { + attrs: content.call (Attribute ::parse_outer)?, + left_arrow_token: content.parse ()?, + value: content.parse ()?, + }); +if content.is_empty () { +break ; + } + fields.push_punct (content.parse ()?); + } +Ok (InitExprTuple { + path, + paren_token, + fields, + }) + } +} + +impl Parse for Initializer { +fn parse (input: syn::parse::ParseStream <'_>) -> syn::Result <Self > { +let attrs = input.call (Attribute ::parse_outer)?; +let this = input.peek (Token! [&]).then (|| input.parse ()).transpose ()?; +let path = input.parse ()?; +let kind =if input.peek (token::Brace ) { +InitExprKind ::Struct (InitExprStruct ::parse_with_path (path, input)?) + }else if input.peek (token::Paren ) { +InitExprKind ::Tuple (InitExprTuple ::parse_with_path (path, input)?) + }else { +return Err (input.error ("expected curly braces or parentheses" )); + };let error = input .peek (Token! [?]) .then (||Ok ::<_ , syn::Error >((input.parse ()?, input.parse ()?)))
@@ -426,10 +632,7 @@ fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {Ok (Self { attrs, this, - path, - brace_token, - fields, - rest, + kind, error, }) }
@@ -499,3 +702,137 @@ fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> { } } } + +impl <Kind :ToTokens >ToTokens for Initializer <Kind > { +fn to_tokens (&self, tokens: &mut TokenStream ) { +let Self { + attrs, + this, + kind, + error, + } = self; + tokens.append_all (attrs); + this.to_tokens (tokens); + kind.to_tokens (tokens); +if let Some ((question, ty)) = error { + question.to_tokens (tokens); + ty.to_tokens (tokens); + } + } +} + +impl ToTokens for InitExprKind { +fn to_tokens (&self, tokens: &mut TokenStream ) { +match self { +Self ::Struct (init) => init.to_tokens (tokens), +Self ::Tuple (init) => init.to_tokens (tokens), + } + } +} + +impl ToTokens for InitExprStruct { +fn to_tokens (&self, tokens: &mut TokenStream ) { +let Self { + path, + brace_token, + fields, + rest, + } = self; + path.to_tokens (tokens); + brace_token.surround (tokens, |tokens| { + fields.to_tokens (tokens); +if let Some ((dotdot, expr)) = rest { + dotdot.to_tokens (tokens); + expr.to_tokens (tokens); + } + }); + } +} + +impl ToTokens for InitExprTuple { +fn to_tokens (&self, tokens: &mut TokenStream ) { +let Self { + path, + paren_token, + fields, + } = self; + path.to_tokens (tokens); + paren_token.surround (tokens, |tokens| fields.to_tokens (tokens)); + } +} + +impl ToTokens for InitTupleField { +fn to_tokens (&self, tokens: &mut TokenStream ) { +let Self { + attrs, + left_arrow_token, + value, + } = self; + tokens.append_all (attrs); + left_arrow_token.to_tokens (tokens); + value.to_tokens (tokens); + } +} + +impl ToTokens for InitializerAttribute { +fn to_tokens (&self, tokens: &mut TokenStream ) { +match self { +Self ::DefaultError (DefaultErrorAttribute { ty }) => { +quote! (#[default_error(#ty)] ).to_tokens (tokens); + } + } + } +} + +impl ToTokens for This { +fn to_tokens (&self, tokens: &mut TokenStream ) { +let Self { + _and_token, + ident, + _in_token, + } = self; + _and_token.to_tokens (tokens); + ident.to_tokens (tokens); + _in_token.to_tokens (tokens); + } +} + +impl ToTokens for InitializerField { +fn to_tokens (&self, tokens: &mut TokenStream ) { +let Self { attrs, kind } = self; + tokens.append_all (attrs); + kind.to_tokens (tokens); + } +} + +impl ToTokens for InitializerKind { +fn to_tokens (&self, tokens: &mut TokenStream ) { +match self { +Self ::Value { member, value } => { + member.to_tokens (tokens); +if let Some ((colon, expr)) = value { + colon.to_tokens (tokens); + expr.to_tokens (tokens); + } + } +Self ::Init { + member, + _left_arrow_token, + value, + } => { + member.to_tokens (tokens); + _left_arrow_token.to_tokens (tokens); + value.to_tokens (tokens); + } +Self ::Code { + _underscore_token, + _colon_token, + block, + } => { + _underscore_token.to_tokens (tokens); + _colon_token.to_tokens (tokens); + block.to_tokens (tokens); + } + } + } +}
rust/pin-init/internal/src/lib.rs +8 -3
@@ -48,12 +48,17 @@ pub fn maybe_derive_zeroable(input: TokenStream) -> TokenStream {#[proc_macro] pub fn init (input:TokenStream ) ->TokenStream {let input =parse_macro_input! (input); -DiagCtxt ::with (|dcx| init::expand (input,Some ("::core::convert::Infallible" ),false , dcx)) - .into () +DiagCtxt ::with (|dcx| { + init::expand_with_cfg (input,Some ("::core::convert::Infallible" ),false , dcx) + }) + .into () }#[proc_macro] pub fn pin_init (input:TokenStream ) ->TokenStream {let input =parse_macro_input! (input); -DiagCtxt ::with (|dcx| init::expand (input,Some ("::core::convert::Infallible" ),true , dcx)).into () +DiagCtxt ::with (|dcx| { + init::expand_with_cfg (input,Some ("::core::convert::Infallible" ),true , dcx) + }) + .into () }
rust/pin-init/src/lib.rs +16 -0
@@ -625,6 +625,20 @@ macro_rules! stack_try_pin_init {/// # Box::pin_init(demo()).unwrap(); /// ``` /// +/// A tuple struct whose fields are all set to a value can also be written like a call to its +/// constructor: +/// +/// ```rust +/// # use pin_init::*; +/// #[pin_data] +/// struct Pair(usize, usize); +/// +/// # fn demo() -> impl PinInit<Pair> { +/// let initializer = pin_init!(Pair(42, 64)); +/// # initializer } +/// # Box::pin_init(demo()).unwrap(); +/// ``` +/// /// Arbitrary Rust expressions can be used to set the value of a variable. /// /// The fields are initialized in the order that they appear in the initializer. So it is possible
@@ -748,6 +762,8 @@ macro_rules! stack_try_pin_init {/// - Fields that you want to initialize in-place have to use `<-` instead of `:`. /// - Tuple struct fields are named by their index, as in `0: value` or `0 <- initializer`. They /// are not exposed by a `let` binding, since they have no name to bind. +/// - A tuple struct can also be initialized with constructor syntax, as in `Type(value, value)`. +/// Since its arguments are not named, they cannot use `<-`; write them out by index instead. /// - You can use `_: { /* run any user-code here */ },` anywhere where you can place fields in /// order to run arbitrary code. /// - In front of the initializer you can write `&this in` to have access to a [`NonNull<Self>`]
Signature · 1 line
2.53.0
Re: [PATCH 7.3 0579/2651] rust: pin-init: internal: init: support tuple struct constructor syntax
Quoted 7 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Alsadhan <[email protected]>
[ Upstream commit
3b3ff9034a497fb3b8429f6fe8ba5697bc7dcebd]
...
Quoted 10 lines
--- rust/pin-init/internal/src/init.rs | 381 +++++++++++++++++++++++++++-- rust/pin-init/internal/src/lib.rs | 11 +- rust/pin-init/src/lib.rs | 16 ++ 3 files changed, 383 insertions(+), 25 deletions(-)rust/pin-init/internal/src/init.rs +0
-0
...
Quoted 19 lines
rust/pin-init/internal/src/init.rs +14
-1@@ -71,16 +145,103 @@ struct DefaultErrorAttribute { ty: Box<Type>, } -pub(crate) fn expand( +pub (crate )fn expand_with_cfg ( + initializer:Initializer , + default_error:Option <&'staticstr >, + pinned:bool , + dcx: &mut DiagCtxt , +) ->Result <TokenStream ,ErrorGuaranteed > { +let initializer =match initializer.kind { +InitExprKind ::Tuple (expr) => { + expr.validate (dcx)?; + +let mut initializer =Initializer { + attrs: initializer.attrs, + this: initializer.this, + kind: expr,
rust/pin-init/internal/src/init.rs struct DefaultErrorAttribute { · line 171
Quoted 10 lines
rust/pin-init/internal/src/init.rs +10
-0+ error: initializer.error, + }; + +// Removing a tuple field renumbers every field after it, which cannot be expressed with +// a `cfg` attribute on the initializer of a single field. Therefore, resolve tuple +// field cfgs before continuing. Struct expression syntax uses explicit numbers, so +// there is no need to pre-expand them and we only need to emit their cfgs on generated +// code. +for (field_idx, field)in initializer.kind.fields.iter_mut ().enumerate () { +let cfg = field.attrs.extract_cfg_attrs ();
This does not fly either:
[ 70s] error[E0599]: no method named `extract_cfg_attrs` found for struct `Vec<Attribute>` in the current scope [ 70s] --> ../rust/pin-init/internal/src/init.rs:171:39 [ 70s] | [ 70s] 171 | let cfg = field.attrs.extract_cfg_attrs(); [ 70s] | ^^^^^^^^^^^^^^^^^ [ 70s] |
Signature · 2 lines
js suse labs
Greg Kroah-Hartman
maintainerPATCH 580/2651 rust: pin-init: internal: init: emit `slot` using mixed site hygiene
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit e30decc3f9a0ded621d5b0f19a5253b84d21be0c ]
Syn/quote's default is the call site hygiene. If user provides a field named slot, it will conflict with pin-init generated slot identifier. Change it to use mixed site hygiene instead.
--- rust/pin-init/internal/src/init.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
rust/pin-init/internal/src/init.rs +5 -5
@@ -1,7 +1,7 @@// SPDX-License-Identifier: Apache-2.0 OR MIT use proc_macro2::{Span ,TokenStream }; -use quote::{format_ident, quote,ToTokens ,TokenStreamExt }; +use quote::{format_ident, quote, quote_spanned,ToTokens ,TokenStreamExt };use syn::{ braced, parenthesized, parse::{End ,Parse },
@@ -269,7 +269,7 @@ fn expand( }, |(_, err)| Box::new(err), ); -let slot =format_ident! ("slot" ); +let slot =Ident ::new ("slot" ,Span ::mixed_site ());let (has_data_trait, get_data, init_from_closure) =if pinned { ( format_ident!("HasPinData"),
@@ -302,7 +302,7 @@ fn assert_zeroable<T: ?::core::marker::Sized>(_: *mut T) };let this =match this {None =>quote! (), -Some (This { ident, .. }) =>quote! { +Some (This { ident, .. }) =>quote_spanned! {Span ::mixed_site () =>// Create the `this` so it can be referenced by the user inside of the // expressions creating the individual fields. let #ident =unsafe { ::core::ptr::NonNull ::new_unchecked (slot) };
@@ -312,7 +312,7 @@ fn assert_zeroable<T: ?::core::marker::Sized>(_: *mut T)let data =Ident ::new ("__data" ,Span ::mixed_site ());let init_fields =init_fields (&fields, pinned, &data, &slot);let field_check =make_field_check (&fields, init_kind, &path); -Ok (quote! {{ +Ok (quote_spanned! {Span ::mixed_site () => {// Get the data about fields from the supplied type. // SAFETY: TODO let #data =unsafe {
@@ -512,7 +512,7 @@ fn make_field_check( ..::core::mem::zeroed () }), }; -quote! { +quote_spanned! {Span ::mixed_site () => #[allow (unreachable_code)]// We use unreachable code to perform field checks. They're still checked by the compiler. // SAFETY: this code is never executed.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 581/2651 RDMA/core: Fix swapped list_add_tail() arguments in ib_add_sub_device()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit fad7b0dcb0821c0f201df3d85065145857a6f55b ]
ib_add_sub_device() links a new sub-device into its parent's sub-device list with:
list_add_tail(&parent->subdev_list_head, &sub->subdev_list);
list_add_tail(new, head) expects the node to insert as the first argument and the list head as the second, so the call above does the opposite of what was intended: it treats the parent's list head as the new node and the sub-device's node as the list head.
Because _ib_alloc_device() initialises subdev_list to a self-referencing empty head, the misplaced insertion does not crash, but it corrupts the parent->subdev_list_head list. After adding two or more sub-devices, only the last one is reachable through the parent's head, and ib_del_sub_device_and_put()'s list_del() on &sub->subdev_list rewrites the head pointers, potentially severing earlier sub-devices from the chain. During parent teardown, the reverse iteration over subdev_list_head then skips the orphaned sub-devices, so their del_sub_dev() callbacks are never invoked and ib_device_put() on the parent is never paired, leaking both the HW sub-devices and a refcount.
Swap the arguments to match the documented intent: insert the sub-device node into the parent's list head.
--- drivers/infiniband/core/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/device.c +1 -1
@@ -3067,7 +3067,7 @@ int ib_add_sub_device(struct ib_device *parent, sub->parent = parent;mutex_lock (&parent->subdev_lock); -list_add_tail (&parent->subdev_list_head, &sub->subdev_list); +list_add_tail (&sub->subdev_list, &parent->subdev_list_head);mutex_unlock (&parent->subdev_lock);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 582/2651 RDMA/restrack: Dont set RESTRACK_DD mark after a failed xa_insert()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 391c5d826fd0a5dacad54613dbef74c50e966f5c ]
When adding a QP to the restrack xarray, rdma_restrack_add() does:
ret = xa_insert(&rt->xa, res->id, res, GFP_KERNEL); if (ret) res->id = 0; if (qp->qp_type >= IB_QPT_DRIVER) xa_set_mark(&rt->xa, res->id, RESTRACK_DD);
The xa_set_mark() call is not guarded by "!ret". When xa_insert() fails (possible on a qp_num collision or memory pressure), res->id is reset to 0, yet the mark is still applied to index 0. If a legitimate QP whose qp_num is 0 already occupies that slot - e.g. a normal QP or the SMI QP
- it is spuriously tagged as driver-private (RESTRACK_DD), and the netlink dump path res_get_common_dumpit() then hides it from "rdma res" output whenever the caller does not request driver details.
Only set the mark when the insertion actually succeeded by folding the mark into the non-failure branch.
--- drivers/infiniband/core/restrack.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/core/restrack.c +1 -2
@@ -250,8 +250,7 @@ void rdma_restrack_add(struct rdma_restrack_entry *res) ret =xa_insert (&rt->xa, res->id, res,GFP_KERNEL );if (ret) res->id =0 ; - -if (qp->qp_type >=IB_QPT_DRIVER ) +else if (qp->qp_type >=IB_QPT_DRIVER )xa_set_mark (&rt->xa, res->id,RESTRACK_DD ); }else if (res->type ==RDMA_RESTRACK_COUNTER ) {/* Special case to ensure that cntn points to right counter */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 583/2651 RDMA/uverbs: Drop restrack ref on ib_init_ucontext() failure in GET_CONTEXT
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 9dcacdc41083cccff74292851bf9fde999e0731a ]
The UVERBS_METHOD_GET_CONTEXT handler allocates the ucontext via ib_alloc_ucontext(), which calls rdma_restrack_new() (initialising the kref to 1) and rdma_restrack_set_name(NULL), the latter attaching the current task and taking a task_struct reference. When ib_init_ucontext() subsequently fails, the error path only does:
kfree(attrs->context); attrs->context = NULL;
without first calling rdma_restrack_put() on &attrs->context->res. The kref therefore never reaches zero, restrack_release() is never invoked, and put_task_struct() is never called, so the task_struct reference taken during set_name is leaked permanently.
A local user with access to an RDMA device can repeat this path (e.g. by hitting an RDMA cgroup limit or supplying invalid ucaps) and leak one task_struct reference per attempt, eventually preventing those processes from being reaped or exhausting memory.
The legacy ib_uverbs_get_context() path already handles this correctly at its err_ucontext label, where rdma_restrack_put() precedes kfree(). Mirror that ordering here.
--- drivers/infiniband/core/uverbs_std_types_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/core/uverbs_std_types_device.c +1 -0
@@ -272,6 +272,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(return ret; ret =ib_init_ucontext (attrs);if (ret) { +rdma_restrack_put (&attrs->context->res);kfree (attrs->context); attrs->context =NULL ;return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/2651 drm/pagemap: Prevent CPU stalls during unbounded pagemap teardown
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Varun Gupta <[email protected]>
[ Upstream commit b66b036c959f49decd2202db4026d3ae21e01388 ]
drm_pagemap_dev_unhold_work() processes an unbatched llist of pagemaps on the system workqueue. This creates potential latency traps during heavy teardown cycles due to two compounding factors:
1. The loop contains a per-item drm_dbg() trace. If dynamic debug is enabled on a slow serial console, synchronous print latency scales linearly with the batch size and can block worker execution.
2. The llist can accumulate large batches during intensive unmap operations, monopolizing worker resources without yielding.
This causes below log warning:
"workqueue: drm_pagemap_dev_unhold_work [drm_gpusvm_helper] hogged CPU for >10000us 19 times, consider switching to WQ_UNBOUND"
Fix this by implementing a latency mitigation strategy:
- Move the teardown work to system_unbound_wq to avoid tying up per-CPU bound worker pools.
- Add cond_resched() inside the teardown loop to yield the CPU during large batch teardowns, ensuring system responsiveness.
- Convert the drm_dbg() trace to drm_dbg_ratelimited() to mitigate serial console bottlenecks while preserving debuggability.
v2:
- Changed workqueue from deprecated system_unbound_wq to system_dfl_wq. (Arvind Yadav)
--- drivers/gpu/drm/drm_pagemap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_pagemap.c +3 -2
@@ -1079,7 +1079,7 @@ static void drm_pagemap_release(struct kref *ref) dpagemap->dev_hold =NULL ;drm_pagemap_shrinker_add (dpagemap);llist_add (&dev_hold->link, &drm_pagemap_unhold_list); -schedule_work (&drm_pagemap_work); +queue_work (system_dfl_wq, &drm_pagemap_work);/* * Here, either the provider device is still alive, since if called from * page_free(), the caller is holding a reference on the dev_pagemap,
@@ -1102,10 +1102,11 @@ static void drm_pagemap_dev_unhold_work(struct work_struct *work)struct drm_device *drm = dev_hold->drm;struct module *module = drm->driver->fops->owner; -drm_dbg (drm,"Releasing reference on provider device and module.\n" ); +drm_dbg_ratelimited (drm,"Releasing reference on provider device and module.\n" );drm_dev_put (drm);module_put (module);kfree (dev_hold); +cond_resched (); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/2651 cxl/region: Create node access attributes for CFMWS-only NUMA nodes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit ef71014055f7b4959e4cb023ca8a18258cb5641c ]
A NUMA node that only backs a CXL fixed memory window and is not enumerated by SRAT has no memory_target in the HMAT code, so hmat_callback() exits early at find_mem_target() and never creates the node's accessN attributes:/sys/devices/system/node/nodeX/accessN/initiators/* stays missing.
Commit debdce20c4f2 ("cxl/region: Deal with numa nodes not enumerated by SRAT") had the CXL region notifier call node_set_perf_attrs() directly for such nodes, but commit 2e454fb8056d ("cxl, acpi/hmat:
Update CXL access coordinates directly instead of through HMAT") replaced it with node_update_perf_attrs(), which only updates attributes that already exist and thus does nothing for these nodes.
Create the attributes with node_set_perf_attrs() when the node is not backed by a real SRAT pxm.
Tested on a QEMU CXL topology with a CFMWS window not described by SRAT or HMAT: node1/access0/initiators/{read,write}_{bandwidth,latency} appear with the calculated coordinates once the region's first memory block comes online.
--- drivers/cxl/core/region.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/cxl/core/region.c +14 -1
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ +#include <linux/acpi.h> #include <linux/memregion.h> #include <linux/genalloc.h> #include <linux/debugfs.h>
@@ -2630,7 +2631,19 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)for (int i =0 ; i <ACCESS_COORDINATE_MAX ; i++) {if (cxlr->coord[i].read_bandwidth) { -node_update_perf_attrs (nid, &cxlr->coord[i], i); +/* +* A CFMWS-only node (not backed by a real SRAT pxm) +* has no HMAT memory_target, so hmat_callback() +* never created the access attributes for it: +* create them here instead of only updating them. +* This is called at most once per node (see +* nodemask_region_seen), so the attributes are not +* created twice. +*/ +if (!acpi_node_backed_by_real_pxm (nid)) +node_set_perf_attrs (nid, &cxlr->coord[i], i); +else +node_update_perf_attrs (nid, &cxlr->coord[i], i); cset++; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/2651 cxl/core: Skip einj_inject creation when devm_add_action_or_reset() fails
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit b25af6afd2f26b455108bab03dfeba52378e8dd2 ]
cxl_debugfs_create_dport_dir() ignores the devm_add_action_or_reset() result and creates the einj_inject file below @dir unconditionally.
When the devres allocation fails, remove_debugfs() has already run before devm_add_action_or_reset() returns, i.e. debugfs_remove() has released @dir. The subsequent debugfs_create_file() would then use that dentry as its parent although its final reference was dropped in the removal and its memory is subject to call_rcu() delayed freeing.
Skip the file creation in that case, consistent with how the rest of the helper tolerates debugfs failures.
--- drivers/cxl/core/port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cxl/core/port.c +2 -1
@@ -846,7 +846,8 @@ static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport) dir =cxl_debugfs_create_dir (dev_name (dport->dport_dev)); -devm_add_action_or_reset (dport_to_host (dport), remove_debugfs, dir); +if (devm_add_action_or_reset (dport_to_host (dport), remove_debugfs, dir)) +return ;debugfs_create_file ("einj_inject" ,0200 , dir, dport, &cxl_einj_inject_fops);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/2651 ACPI: CPPC: Validate the _CPC package header
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Loehle <[email protected]>
[ Upstream commit fb345025f161d17fe7c8a6048c7e80e467fa8ddf ]
The _CPC NumEntries field includes every package element, including NumEntries and Revision. acpi_cppc_processor_probe() nevertheless reads those first two elements before checking that they exist and trusts NumEntries when walking the remaining elements.
Reject packages with fewer than two elements and NumEntries values which exceed the package count before accessing Revision or iterating over register descriptors. Although the specification defines NumEntries as the number of package elements, tolerate additional trailing elements because ignoring them is safe and avoids rejecting padded firmware.
Revision is specified as a BYTE, but the parser assigns its 64-bit AML Integer to an unsigned int before validating it. Reject values above U8_MAX before conversion so, for example, 0x100000004 cannot truncate to revision 4.
--- drivers/acpi/cppc_acpi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/acpi/cppc_acpi.c +18 -4
@@ -804,6 +804,11 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) } out_obj = (union acpi_object *) output.pointer; +if (out_obj->package.count <2 ) { +pr_debug ("Unexpected _CPC package count (%u) for CPU:%d\n" , + out_obj->package.count, pr->id); + goto out_buf_free; + } cpc_ptr = kzalloc_obj(struct cpc_desc);if (!cpc_ptr) {
@@ -814,12 +819,15 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)/* First entry is NumEntries. */ cpc_obj = &out_obj->package.elements[0 ];if (cpc_obj->type ==ACPI_TYPE_INTEGER ) { - num_ent = cpc_obj->integer.value; -if (num_ent <=1 ) { -pr_debug ("Unexpected _CPC NumEntries value (%d) for CPU:%d\n" , - num_ent, pr->id); +if (cpc_obj->integer.value <2 || + cpc_obj->integer.value > out_obj->package.count) { +pr_debug ("Invalid _CPC NumEntries (%llu) for package count (%u) on CPU:%d\n" , + cpc_obj->integer.value, out_obj->package.count, + pr->id); goto out_free; } + + num_ent = cpc_obj->integer.value; }else {pr_debug ("Unexpected _CPC NumEntries entry type (%d) for CPU:%d\n" , cpc_obj->type, pr->id);
@@ -829,6 +837,12 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)/* Second entry should be revision. */ cpc_obj = &out_obj->package.elements[1 ];if (cpc_obj->type ==ACPI_TYPE_INTEGER ) { +if (cpc_obj->integer.value >U8_MAX ) { +pr_debug ("Invalid _CPC Revision (%llu) for CPU:%d\n" , + cpc_obj->integer.value, pr->id); + ret = -EINVAL ; + goto out_free; + } cpc_rev = cpc_obj->integer.value; }else { pr_debug("Unexpected _CPC Revision entry type (%d) for CPU:%d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/2651 ASoC: ab8500: Skip digital microphone support on AB8505
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 0d46182a1be7ef12f85433d91315d4d7091dd8c8 ]
The AB8505 does not have the digital microphone interface, its six input pins or the VDMIC regulator found in AB8500. The shared codec driver nevertheless creates the entire AB8500 DMIC DAPM graph. When an AB8505 sound card binds, the regulator widget requests the nonexistent V-DMIC supply and falls back to a dummy regulator.
Split the digital microphone widgets and routes from the common codec graph and add them only when the parent MFD is an actual AB8500. This also removes the DMIC4-only AD_OUT4 path from AB8505.
--- sound/soc/codecs/ab8500-codec.c | 144 ++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 62 deletions(-)
sound/soc/codecs/ab8500-codec.c +82 -62
@@ -299,7 +299,6 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {SND_SOC_DAPM_REGULATOR_SUPPLY ("V-AUD" ,0 ,0 ),SND_SOC_DAPM_REGULATOR_SUPPLY ("V-AMIC1" ,0 ,0 ),SND_SOC_DAPM_REGULATOR_SUPPLY ("V-AMIC2" ,0 ,0 ), -SND_SOC_DAPM_REGULATOR_SUPPLY ("V-DMIC" ,0 ,0 ),/* Power */ SND_SOC_DAPM_SUPPLY("Audio Power",
@@ -324,7 +323,6 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {SND_SOC_DAPM_AIF_OUT ("AD_OUT1" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_AIF_OUT ("AD_OUT2" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_AIF_OUT ("AD_OUT3" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ), -SND_SOC_DAPM_AIF_OUT ("AD_OUT4" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_AIF_OUT ("AD_OUT57" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ), SND_SOC_DAPM_AIF_OUT("AD_OUT68", NULL, 0, SND_SOC_NOPM, 0, 0),
@@ -584,36 +582,6 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("AD5768 Enable" ,AB8500_ADPATHENA ,AB8500_ADPATHENA_ENAD5768 ,0 ,NULL ,0 ), -/* Digital Microphone path */ - -SND_SOC_DAPM_INPUT ("DMic 1" ), -SND_SOC_DAPM_INPUT ("DMic 2" ), -SND_SOC_DAPM_INPUT ("DMic 3" ), -SND_SOC_DAPM_INPUT ("DMic 4" ), -SND_SOC_DAPM_INPUT ("DMic 5" ), -SND_SOC_DAPM_INPUT ("DMic 6" ), - -SND_SOC_DAPM_MIXER ("DMIC1" , -AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC1 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("DMIC2" , -AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC2 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("DMIC3" , -AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC3 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("DMIC4" , -AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC4 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("DMIC5" , -AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC5 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("DMIC6" , -AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC6 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("AD4 Channel Volume" , -SND_SOC_NOPM ,0 ,0 , -NULL ,0 ),/* Acoustical Noise Cancellation path */ SND_SOC_DAPM_MUX("ANC Source",
@@ -648,6 +616,40 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = { NULL, 0), }; +static const struct snd_soc_dapm_widget ab8500_dmic_dapm_widgets[] = { +SND_SOC_DAPM_REGULATOR_SUPPLY ("V-DMIC" ,0 ,0 ), +SND_SOC_DAPM_AIF_OUT ("AD_OUT4" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ), + +SND_SOC_DAPM_INPUT ("DMic 1" ), +SND_SOC_DAPM_INPUT ("DMic 2" ), +SND_SOC_DAPM_INPUT ("DMic 3" ), +SND_SOC_DAPM_INPUT ("DMic 4" ), +SND_SOC_DAPM_INPUT ("DMic 5" ), +SND_SOC_DAPM_INPUT ("DMic 6" ), + +SND_SOC_DAPM_MIXER ("DMIC1" , +AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC1 ,0 , +NULL ,0 ), +SND_SOC_DAPM_MIXER ("DMIC2" , +AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC2 ,0 , +NULL ,0 ), +SND_SOC_DAPM_MIXER ("DMIC3" , +AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC3 ,0 , +NULL ,0 ), +SND_SOC_DAPM_MIXER ("DMIC4" , +AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC4 ,0 , +NULL ,0 ), +SND_SOC_DAPM_MIXER ("DMIC5" , +AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC5 ,0 , +NULL ,0 ), +SND_SOC_DAPM_MIXER ("DMIC6" , +AB8500_DIGMICCONF ,AB8500_DIGMICCONF_ENDMIC6 ,0 , +NULL ,0 ), +SND_SOC_DAPM_MIXER ("AD4 Channel Volume" , +SND_SOC_NOPM ,0 ,0 , +NULL ,0 ), +}; +/* * DAPM-routes */
@@ -853,35 +855,6 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"AD_OUT68", NULL, "Main Supply"}, {"AD_OUT68", NULL, "AD6 Channel Volume"}, -/* Digital Microphone path */ - - {"DMic 1", NULL, "V-DMIC"}, - {"DMic 2", NULL, "V-DMIC"}, - {"DMic 3", NULL, "V-DMIC"}, - {"DMic 4", NULL, "V-DMIC"}, - {"DMic 5", NULL, "V-DMIC"}, - {"DMic 6", NULL, "V-DMIC"}, - - {"DMIC1", NULL, "DMic 1"}, - {"DMIC2", NULL, "DMic 2"}, - {"DMIC3", NULL, "DMic 3"}, - {"DMIC4", NULL, "DMic 4"}, - {"DMIC5", NULL, "DMic 5"}, - {"DMIC6", NULL, "DMic 6"}, - - {"AD1 Source Select", "DMic 1", "DMIC1"}, - {"AD2 Source Select", "DMic 2", "DMIC2"}, - {"AD3 Source Select", "DMic 3", "DMIC3"}, - {"AD5 Source Select", "DMic 5", "DMIC5"}, - {"AD6 Source Select", "DMic 6", "DMIC6"}, - - {"AD4 Channel Volume", NULL, "DMIC4"}, - {"AD4 Channel Volume", NULL, "AD34 Enable"}, - - {"ab8500_0c", NULL, "AD_OUT4"}, - {"AD_OUT4", NULL, "Main Supply"}, - {"AD_OUT4", NULL, "AD4 Channel Volume"}, -/* LineIn Bypass path */ {"LINL to HSL Volume", NULL, "LINL Enable"},
@@ -911,7 +884,6 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"Sidetone Left Source", "Headset Left", "DA_IN1"}, {"Sidetone Right Source", "LineIn Right", "AD2 Channel Volume"}, {"Sidetone Right Source", "Mic 1", "AD3 Channel Volume"}, - {"Sidetone Right Source", "DMic 4", "AD4 Channel Volume"}, {"Sidetone Right Source", "Headset Right", "DA_IN2"}, {"STFIR1 Control", NULL, "Sidetone Left Source"},
@@ -924,6 +896,37 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"DA2 Enable", NULL, "STFIR2 Volume"}, }; +static const struct snd_soc_dapm_route ab8500_dmic_dapm_routes[] = { + {"DMic 1" ,NULL ,"V-DMIC" }, + {"DMic 2" ,NULL ,"V-DMIC" }, + {"DMic 3" ,NULL ,"V-DMIC" }, + {"DMic 4" ,NULL ,"V-DMIC" }, + {"DMic 5" ,NULL ,"V-DMIC" }, + {"DMic 6" ,NULL ,"V-DMIC" }, + + {"DMIC1" ,NULL ,"DMic 1" }, + {"DMIC2" ,NULL ,"DMic 2" }, + {"DMIC3" ,NULL ,"DMic 3" }, + {"DMIC4" ,NULL ,"DMic 4" }, + {"DMIC5" ,NULL ,"DMic 5" }, + {"DMIC6" ,NULL ,"DMic 6" }, + + {"AD1 Source Select" ,"DMic 1" ,"DMIC1" }, + {"AD2 Source Select" ,"DMic 2" ,"DMIC2" }, + {"AD3 Source Select" ,"DMic 3" ,"DMIC3" }, + {"AD5 Source Select" ,"DMic 5" ,"DMIC5" }, + {"AD6 Source Select" ,"DMic 6" ,"DMIC6" }, + + {"AD4 Channel Volume" ,NULL ,"DMIC4" }, + {"AD4 Channel Volume" ,NULL ,"AD34 Enable" }, + + {"ab8500_0c" ,NULL ,"AD_OUT4" }, + {"AD_OUT4" ,NULL ,"Main Supply" }, + {"AD_OUT4" ,NULL ,"AD4 Channel Volume" }, + + {"Sidetone Right Source" ,"DMic 4" ,"AD4 Channel Volume" }, +}; +static const struct snd_soc_dapm_route ab8500_dapm_routes_mic1a_vamicx[] = { {"MIC1A V-AMICx Enable" ,NULL ,"V-AMIC1" }, {"MIC1A V-AMICx Enable", NULL, "V-AMIC2"},
@@ -2043,13 +2046,30 @@ static int ab8500_codec_probe(struct snd_soc_component *component) {struct device *dev = component->dev;struct device_node *np = dev->of_node; +struct ab8500 *ab8500 =dev_get_drvdata (dev->parent);struct ab8500_codec_platform_data codec_pdata; +struct snd_soc_dapm_context *dapm;int status;dev_dbg (dev,"%s: Enter.\n" , __func__);ab8500_codec_of_probe (dev, np, &codec_pdata); +if (is_ab8500 (ab8500)) { + dapm =snd_soc_component_to_dapm (component); + status =snd_soc_dapm_new_controls (dapm, + ab8500_dmic_dapm_widgets, +ARRAY_SIZE (ab8500_dmic_dapm_widgets)); +if (status) +return status; + + status =snd_soc_dapm_add_routes (dapm, + ab8500_dmic_dapm_routes, +ARRAY_SIZE (ab8500_dmic_dapm_routes)); +if (status) +return status; + } + status =ab8500_audio_init_audioblock (component);if (status <0 ) { dev_err(dev, "%s: failed to init audio-block (%d)!\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/2651 spi: mxic: fix ps_clk leak in runtime resume
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 648e3c436032b675b339662ea9c0edd9221add76 ]
mxic_spi_runtime_resume() enables ps_clk before calling mxic_spi_clk_enable(). If the latter fails, ps_clk was not disabled.
Unwind ps_clk with clk_disable_unprepare() before returning the error.
--- drivers/spi/spi-mxic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-mxic.c +7 -1
@@ -744,7 +744,13 @@ static int mxic_spi_runtime_resume(struct device *dev)return ret; } -return mxic_spi_clk_enable (mxic); + ret =mxic_spi_clk_enable (mxic); +if (ret) { +clk_disable_unprepare (mxic->ps_clk); +return ret; + } + +return 0 ; }static const struct dev_pm_ops mxic_spi_dev_pm_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/2651 driver core: Add conditional guard support for device_trylock()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 18f26958544783b0f30210c41fc0c0da11b8d9a4 ]
Introduce a conditional guard version of device_trylock() for scenarios that must not block on the device lock. device_trylock() returns 1 on success like mutex_trylock(), so the default binary condition applies and ACQUIRE_ERR() reports -EBUSY on contention.
Stable-dep-of: 391bc7ab9be6 ("cxl/memdev: Fix deadlock between poison debugfs and cxl_mem unbind")
--- include/linux/device.h | 1 + 1 file changed, 1 insertion(+)
include/linux/device.h +1 -0
@@ -1126,6 +1126,7 @@ static inline void device_unlock(struct device *dev) DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T)) DEFINE_GUARD_COND(device, _intr, device_lock_interruptible(_T), _RET == 0) +DEFINE_GUARD_COND(device, _try, device_trylock(_T))static inline void device_lock_assert (struct device *dev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/2651 cxl/memdev: Fix deadlock between poison debugfs and cxl_mem unbind
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 391bc7ab9be6635e77a205591b7d30db797f1a0e ]
The poison debugfs handlers take the memdev device lock so that the region lookup sees a stable cxlmd->dev.driver. debugfs holds a reference on the file across the handler, and cxl_mem unbind removes that file while holding the very same device lock, so a handler that waits for the lock deadlocks against a concurrent unbind.
The trigger is any teardown that detaches cxl_mem from the memdev while a poison write is in flight: unbinding or unloading cxl_mem or cxl_pci, or removing the endpoint PCI device, including hot-remove.
Both tasks then hang. The unbind side is uninterruptible, and it also blocks the memdev detach work, which runs on an ordered workqueue and so stalls every other CXL bus work item.
Take the lock with the trylock guard and return -EBUSY instead of waiting. An unbind that wins the race removes the file first and the write fails with -ENOENT.
The poison inject and clear files are a debug ABI for expert users, mostly device vendors, to test the poison capabilities of their devices. Mixing a poison write with cxl_mem teardown is not a supported use of the interface, but when it happens anyway the cost should be a failed write, not a hung kernel.
Found by code inspection. Reproduced by writing inject_poison in a loop while unbinding and rebinding cxl_mem, and confirmed fixed by the same test. Also reproduced the same deadlock with those writes racing a pciehp hot-remove of the memdev; with this patch the hot-remove flow completes normally.
--- drivers/cxl/mem.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/cxl/mem.c +10 -4
@@ -50,8 +50,13 @@ static int cxl_debugfs_poison_inject(void *data, u64 dpa)struct cxl_memdev *cxlmd = data;int rc; -ACQUIRE (device_intr, devlock)(&cxlmd->dev); -if ((rc =ACQUIRE_ERR (device_intr, &devlock))) +/* +* Never wait for this lock: the debugfs proxy holds a file reference +* across the callback and unbind removes the file under the same +* device lock, so waiting here deadlocks against unbind. +*/ +ACQUIRE (device_try, devlock)(&cxlmd->dev); +if ((rc =ACQUIRE_ERR (device_try, &devlock)))return rc;return cxl_inject_poison (cxlmd, dpa);
@@ -65,8 +70,9 @@ static int cxl_debugfs_poison_clear(void *data, u64 dpa)struct cxl_memdev *cxlmd = data;int rc; -ACQUIRE (device_intr, devlock)(&cxlmd->dev); -if ((rc =ACQUIRE_ERR (device_intr, &devlock))) +/* Never wait, per the inject path above. */ +ACQUIRE (device_try, devlock)(&cxlmd->dev); +if ((rc =ACQUIRE_ERR (device_try, &devlock)))return rc;return cxl_clear_poison (cxlmd, dpa);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/2651 ACPI: HMAT: preserve hmat_adist_nb notifier block
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alejandro Lucero <[email protected]>
[ Upstream commit b1c75a77d494298b8dedf46062f2072239bbc33b ]
Remove __meminitdata from hmat_adist_nb declaration preserving it even when CONFIG_MEMORY_HOTPLUG is not set. Otherwise further notifier registrations using register_mt_adistance_algorithm() will find a notifier chain likely corrupted.
This is the case when cxl_region_probe() calls register_mt_adistance_algorithm() what can happen when CXL regions are dynamically created at any time from Type3 device(s) or when a Type2 device is initialized at its driver probe.
--- drivers/acpi/numa/hmat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/numa/hmat.c +1 -1
@@ -995,7 +995,7 @@ static int hmat_calculate_adistance(struct notifier_block *self,return NOTIFY_STOP ; } -static struct notifier_block hmat_adist_nb__meminitdata = { +static struct notifier_block hmat_adist_nb = { .notifier_call = hmat_calculate_adistance, .priority =100 , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/2651 perf topdown: Dont require config1==0 for a slots event
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zide Chen <[email protected]>
[ Upstream commit 0824af00a8d2ede0d8bc70bdc0b493ecfd167900 ]
arch_is_topdown_slots() requires config1 == 0, so it misidentified "cpu/slots,metrics_clear=1/" as not being the slots event, and an additional slots event gets inserted, which fails event scheduling since the group now needs two fixed counter 3.
$ perf stat -e "{cpu/slots,metrics_clear=1/,cpu/topdown-retiring/}" -- sleep 1
WARNING: events were regrouped to match PMUs
<not counted> slots
<not supported> cpu/slots,metrics_clear=1/
<not counted> cpu/topdown-retiring/Drop the config1 == 0 check from arch_is_topdown_slots(). This is
safe: config1 has no bearing on the event's identifying config value (TOPDOWN_SLOTS, 0x0400).
The attr.type == PERF_TYPE_RAW check is what actually matters: only the core PMU is registered with PERF_TYPE_RAW, and on x86, 0x400 is guaranteed to be slots event on core CPU.
arch_is_topdown_metrics() keeps its own config1 == 0 check, since genuine metrics events have no "metrics_clear" and config1 remains 0.
Add a test verifying that an explicit "slots,metrics_clear=1" event in a group does not trigger an extra slots event injection.
--- tools/perf/arch/x86/tests/topdown.c | 30 +++++++++++++++++++++++++++++ tools/perf/arch/x86/util/topdown.c | 3 +-- 2 files changed, 31 insertions(+), 2 deletions(-)
tools/perf/arch/x86/tests/topdown.c +30 -0
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <errno.h> +#include <stdio.h> +#include <string.h> #include "arch-tests.h" #include "../util/topdown.h" #include "debug.h"
@@ -229,10 +231,38 @@ static int test__x86_topdown_slots_injection(struct test_suite *test __maybe_unureturn TEST_OK ; } +/* +* An explicit "slots,metrics_clear=1" event is still the slots event and +* must not cause an extra slots event to be injected into the group. +*/ +static int test__x86_topdown_metrics_clear (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +struct perf_pmu *pmu; +char event_str[128 ]; +int ret; + +if (!topdown_sys_has_perf_metrics ()) +return TEST_OK ; + + pmu =perf_pmus__find_by_type (PERF_TYPE_RAW ); +if (!pmu || !perf_pmu__has_format (pmu,"metrics_clear" )) +return TEST_OK ; + +snprintf (event_str,sizeof (event_str), +"{%s/slots,metrics_clear=1/,%s/topdown-retiring/}" , + pmu->name, pmu->name); + ret =test_sort (event_str,2 ,1 ); +TEST_ASSERT_EQUAL ("explicit metrics_clear slots event isn't duplicated" , ret,TEST_OK ); + +return TEST_OK ; +} +static struct test_case x86_topdown_tests[] = {TEST_CASE ("topdown events" , x86_topdown),TEST_CASE ("topdown sorting" , x86_topdown_sorting),TEST_CASE ("topdown slots injection" , x86_topdown_slots_injection), +TEST_CASE ("topdown metrics_clear no extra slots" , x86_topdown_metrics_clear), { .name =NULL , } };
tools/perf/arch/x86/util/topdown.c +1 -2
@@ -37,8 +37,7 @@ bool topdown_sys_has_perf_metrics(void)bool arch_is_topdown_slots (const struct evsel *evsel) {return evsel->core.attr.type ==PERF_TYPE_RAW && - evsel->core.attr.config ==TOPDOWN_SLOTS && - evsel->core.attr.config1 ==0 ; + evsel->core.attr.config ==TOPDOWN_SLOTS ; }bool arch_is_topdown_metrics (const struct evsel *evsel)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/2651 perf libdw: Fix Dwfl discovery with split files
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit bf96e296d52d74a1ae5254a341175afede8a1963 ]
dso__libdw_dwfl() opens the Dwfl with dso__long_name(), the file the samples came from. When the debug information lives in a separate file, symbol loading finds it and records it as the dso's symsrc filename, but the Dwfl still refers to the original file, so libdw has no DWARF to resolve addresses against.
Open the Dwfl with the symsrc filename when one is known and fall back to the long name when it isn't.
The symsrc file is found while symbols are loaded, which can happen after the Dwfl has been created and cached, so drop the cached Dwfl and the addr2line cache built from it when the symsrc filename is set. That teardown can run while another thread is using the cache, so take the dso lock across both the teardown and the Dwfl accessors, and re-read dso__symsrc_filename() under the dso lock in libbfd__addr2line() and cmd__addr2line() to prevent a TOCTOU race with cache invalidation.
--- .../arch/powerpc/util/skip-callchain-idx.c | 4 +- tools/perf/util/addr2line.c | 42 +++++++++--- tools/perf/util/dso.c | 9 +++ tools/perf/util/dso.h | 5 +- tools/perf/util/libbfd.c | 29 ++++++--- tools/perf/util/libdw.c | 39 +++++++---- tools/perf/util/srcline.c | 62 ++++++++++++------ tools/perf/util/unwind-libdw.c | 2 + tools/perf/util/unwind-libunwind.c | 64 ++++++++++++++----- 9 files changed, 187 insertions(+), 69 deletions(-)
tools/perf/arch/powerpc/util/skip-callchain-idx.c +3 -1
@@ -152,9 +152,10 @@ static int check_return_addr(struct dso *dso, Dwarf_Addr mapped_pc)Dwarf_Addr end = mapped_pc;bool signalp; +mutex_lock (dso__lock (dso)); dwfl =dso__libdw_dwfl (dso);if (!dwfl) -return -1 ; + goto out; mod =dwfl_addrmodule (dwfl, mapped_pc);if (!mod) {
@@ -183,6 +184,7 @@ static int check_return_addr(struct dso *dso, Dwarf_Addr mapped_pc) rc =check_return_reg (ra_regno, frame); out: +mutex_unlock (dso__lock (dso));return rc; }
tools/perf/util/addr2line.c +33 -9
82 lines not on this page · raw message
tools/perf/util/dso.c +9 -0
@@ -2075,3 +2075,12 @@ struct debuginfo *dso__debuginfo(struct dso *dso)free (name);return dinfo; } + +void dso__set_symsrc_filename (struct dso *dso,char *val) +{ +RC_CHK_ACCESS (dso)->symsrc_filename = val; +dso__free_libdw (dso); +dso__free_a2l (dso); +dso__set_has_srcline (dso, true); +dso__set_a2l_fails (dso,0 ); +}
tools/perf/util/dso.h +1 -4
@@ -735,10 +735,7 @@ static inline const char *dso__symsrc_filename(const struct dso *dso)return RC_CHK_ACCESS (dso)->symsrc_filename; } -static inline void dso__set_symsrc_filename (struct dso *dso,char *val) -{ -RC_CHK_ACCESS (dso)->symsrc_filename = val; -} +void dso__set_symsrc_filename (struct dso *dso,char *val);static inline void dso__free_symsrc_filename (struct dso *dso) {
tools/perf/util/libbfd.c +21 -8
@@ -226,7 +226,11 @@ int libbfd__addr2line(const char *dso_name, u64 addr, struct symbol *sym) {int ret =0 ; -struct a2l_data *a2l =dso__a2l (dso); +struct a2l_data *a2l; + +mutex_lock (dso__lock (dso)); + dso_name =dso__symsrc_filename (dso) ?: dso_name; + a2l =dso__a2l (dso);if (!a2l) { a2l =addr2line_init (dso_name);
@@ -236,7 +240,8 @@ int libbfd__addr2line(const char *dso_name, u64 addr,if (a2l ==NULL ) {if (!symbol_conf.addr2line_disable_warn)pr_warning ("addr2line_init failed for %s\n" , dso_name); -return 0 ; + ret =-1 ; + goto out; } a2l->addr = addr;
@@ -244,14 +249,18 @@ int libbfd__addr2line(const char *dso_name, u64 addr,bfd_map_over_sections (a2l->abfd, find_address_in_section, a2l); -if (!a2l->found) -return 0 ; +if (!a2l->found) { + ret =0 ; + goto out; + }if (unwind_inlines) {int cnt =0 ; -if (node &&inline_list__append_dso_a2l (dso, node, sym)) -return 0 ; +if (node &&inline_list__append_dso_a2l (dso, node, sym)) { + ret =0 ; + goto out; + } while (bfd_find_inliner_info(a2l->abfd, &a2l->filename, &a2l->funcname, &a2l->line) &&
@@ -261,8 +270,10 @@ int libbfd__addr2line(const char *dso_name, u64 addr, a2l->filename =NULL ;if (node !=NULL ) { -if (inline_list__append_dso_a2l (dso, node, sym)) -return 0 ; +if (inline_list__append_dso_a2l (dso, node, sym)) { + ret =0 ; + goto out; + }// found at least one inline frame ret =1 ; }
@@ -277,6 +288,8 @@ int libbfd__addr2line(const char *dso_name, u64 addr,if (line) *line = a2l->line; +out: +mutex_unlock (dso__lock (dso));return ret; }
tools/perf/util/libdw.c +27 -12
@@ -35,7 +35,7 @@ struct Dwfl *dso__libdw_dwfl(struct dso *dso)if (dwfl)return dwfl; - dso_name =dso__long_name (dso); + dso_name =dso__symsrc_filename (dso) ?:dso__long_name (dso);/* * Initialize Dwfl session. * We need to open the DSO file to report it to libdw.
@@ -167,32 +167,41 @@ int libdw__addr2line(u64 addr, char **file, unsigned int *line_nr, struct dso *dso, bool unwind_inlines, struct inline_node *node, struct symbol *sym) { - Dwfl *dwfl = dso__libdw_dwfl(dso); + Dwfl *dwfl;Dwfl_Module *mod;Dwfl_Line *dwline;Dwarf_Addr bias;const char *src;int lineno =0 ; +int ret =0 ; +mutex_lock (dso__lock (dso)); + dwfl =dso__libdw_dwfl (dso);if (!dwfl) -return 0 ; + goto out; mod =dwfl_addrmodule (dwfl, addr); -if (!mod) -return 0 ; +if (!mod) { + ret =0 ; + goto out; + }/* * Get/ignore the dwarf information. Determine the bias, difference * between the regular ELF addr2line addresses and those to use with * libdw. */ -if (!dwfl_module_getdwarf (mod, &bias)) -return 0 ; +if (!dwfl_module_getdwarf (mod, &bias)) { + ret =-1 ; + goto out; + }/* Find source line information for the address. */ dwline =dwfl_module_getsrc (mod, addr + bias); -if (!dwline) -return 0 ; +if (!dwline) { + ret =-1 ; + goto out; + }/* Get line information. */ src = dwfl_lineinfo(dwline, /*addr=*/NULL, &lineno, /*col=*/NULL, /*mtime=*/NULL,
@@ -219,7 +228,8 @@ int libdw__addr2line(u64 addr, char **file, unsigned int *line_nr,free (*file); *file =NULL ; } -return 0 ; + ret =0 ; + goto out; }/* Walk from the parent down to the leaf. */
@@ -235,8 +245,13 @@ int libdw__addr2line(u64 addr, char **file, unsigned int *line_nr, *file =NULL ; }inline_node__clear_frames (node); -return 0 ; + ret =0 ; + goto out; } } -return 1 ; + ret =1 ; + +out: +mutex_unlock (dso__lock (dso)); +return ret; }
tools/perf/util/srcline.c +44 -18
153 lines not on this page · raw message
tools/perf/util/unwind-libdw.c +2 -0
@@ -42,8 +42,10 @@ static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata,const struct dso *dso = *userdata;assert (dso); +mutex_lock (dso__lock ((struct dso *)dso));if (dso__symsrc_filename (dso) &&strcmp (file_name,dso__symsrc_filename (dso))) *debuginfo_file_name =strdup (dso__symsrc_filename (dso)); +mutex_unlock (dso__lock ((struct dso *)dso));return -1 ; }
tools/perf/util/unwind-libunwind.c +47 -17
101 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/2651 perf dso: Separate libbfd and cmd addr2line caches to fix confusion
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit f651c02755af85324ad029cd948a8e570d0769fb ]
When a dso executes addr2line via libbfd it instantiates an a2l_data pointer. If the DSO later executes via the command-line fallback due to an inlined bug, the a2l pointer is unconditionally populated with a child_process process wrapper.
If libbfd is queried again, the offline reader attempts to cast struct a2l_data into child_process, coercing random arbitrary instruction addresses and causing silent aborts. This cleanly splits the caches.
--- tools/perf/util/dso.c | 48 +++++++++++++++++++++++---------------- tools/perf/util/dso.h | 21 +++++++++++++++-- tools/perf/util/libbfd.c | 10 ++++---- tools/perf/util/srcline.c | 2 ++ 4 files changed, 54 insertions(+), 27 deletions(-)
tools/perf/util/dso.c +28 -20
@@ -1,38 +1,44 @@// SPDX-License-Identifier: GPL-2.0 +#include "dso.h" + +#include <errno.h> +#include <stdlib.h> +#include <asm/bug.h> +#include <fcntl.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/zalloc.h> -#include <sys/time.h> #include <sys/resource.h> -#include <sys/types.h> #include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> #include <unistd.h> -#include <errno.h> -#include <fcntl.h> -#include <stdlib.h> -#ifdef HAVE_LIBBPF_SUPPORT -#include <bpf/libbpf.h> -#include "bpf-event.h" -#include "bpf-utils.h" -#endif + +#include "annotate-data.h" +#include "auxtrace.h" #include "compress.h" +#include "debug.h" +#include "dsos.h" #include "env.h" +#include "libbfd.h" +#include "libdw.h" +#include "machine.h" +#include "map.h" #include "namespaces.h" #include "path.h" -#include "map.h" -#include "symbol.h" #include "srcline.h" -#include "dso.h" -#include "dsos.h" -#include "machine.h" -#include "auxtrace.h" -#include "util.h" /* O_CLOEXEC for older systems */ -#include "debug.h" #include "string2.h" +#include "symbol.h" +#include "util.h" /* O_CLOEXEC for older systems */ #include "vdso.h" -#include "annotate-data.h" -#include "libdw.h" + +#ifdef HAVE_LIBBPF_SUPPORT +#include <bpf/libbpf.h> + +#include "bpf-event.h" +#include "bpf-utils.h" +#endif static const char *const debuglink_paths[] = {"%.0s%s" ,
@@ -1757,6 +1763,7 @@ void dso__delete(struct dso *dso)auxtrace_cache__free (RC_CHK_ACCESS (dso)->auxtrace_cache);dso_cache__free (dso);dso__free_a2l (dso); +dso__free_a2l_libbfd (dso);dso__free_libdw (dso);dso__free_symsrc_filename (dso);nsinfo__zput (RC_CHK_ACCESS (dso)->nsinfo);
@@ -2081,6 +2088,7 @@ void dso__set_symsrc_filename(struct dso *dso, char *val)RC_CHK_ACCESS (dso)->symsrc_filename = val;dso__free_libdw (dso);dso__free_a2l (dso); +dso__free_a2l_libbfd (dso);dso__set_has_srcline (dso, true);dso__set_a2l_fails (dso,0 ); }
tools/perf/util/dso.h +19 -2
@@ -304,7 +304,12 @@ DECLARE_RC_STRUCT(dso) {const char *short_name;const char *long_name;void *a2l; +#ifdef HAVE_LIBBFD_SUPPORT +void *a2l_libbfd; +#endif +#ifdef HAVE_LIBDW_SUPPORT void *libdw; +#endif char *symsrc_filename;struct nsinfo *nsinfo;struct auxtrace_cache *auxtrace_cache;
@@ -368,6 +373,20 @@ static inline void dso__set_a2l(struct dso *dso, void *val)RC_CHK_ACCESS (dso)->a2l = val; } +#ifdef HAVE_LIBBFD_SUPPORT +static inline void *dso__a2l_libbfd (const struct dso *dso) +{ +return RC_CHK_ACCESS (dso)->a2l_libbfd; +} + +static inline void dso__set_a2l_libbfd (struct dso *dso,void *val) +{ +RC_CHK_ACCESS (dso)->a2l_libbfd = val; +} +#endif + +struct Dwfl ; +#ifdef HAVE_LIBDW_SUPPORT static inline void *dso__libdw (const struct dso *dso) {return RC_CHK_ACCESS (dso)->libdw;
@@ -378,8 +397,6 @@ static inline void dso__set_libdw(struct dso *dso, void *val) RC_CHK_ACCESS(dso)->libdw = val; } -struct Dwfl ; -#ifdef HAVE_LIBDW_SUPPORT struct Dwfl *dso__libdw_dwfl (struct dso *dso);#else static inline struct Dwfl *dso__libdw_dwfl (struct dso *dso__maybe_unused )
tools/perf/util/libbfd.c +5 -5
@@ -210,7 +210,7 @@ static int inline_list__append_dso_a2l(struct dso *dso,struct inline_node *node, struct symbol *sym) { - struct a2l_data *a2l = dso__a2l(dso); + struct a2l_data *a2l = dso__a2l_libbfd(dso);struct symbol *inline_sym =new_inline_sym (dso, sym, a2l->funcname);char *srcline =NULL ;
@@ -230,11 +230,11 @@ int libbfd__addr2line(const char *dso_name, u64 addr,mutex_lock (dso__lock (dso)); dso_name =dso__symsrc_filename (dso) ?: dso_name; - a2l =dso__a2l (dso); + a2l =dso__a2l_libbfd (dso);if (!a2l) { a2l =addr2line_init (dso_name); -dso__set_a2l (dso, a2l); +dso__set_a2l_libbfd (dso, a2l); }if (a2l ==NULL ) {
@@ -295,14 +295,14 @@ int libbfd__addr2line(const char *dso_name, u64 addr,void dso__free_a2l_libbfd (struct dso *dso) { -struct a2l_data *a2l =dso__a2l (dso); +struct a2l_data *a2l =dso__a2l_libbfd (dso);if (!a2l)return ;addr2line_cleanup (a2l); -dso__set_a2l (dso,NULL ); +dso__set_a2l_libbfd (dso,NULL ); }static int bfd_symbols__cmpvalue (const void *a,const void *b)
tools/perf/util/srcline.c +2 -0
@@ -301,6 +301,7 @@ char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,if (dso__a2l_fails (dso) >A2L_FAIL_LIMIT ) {dso__set_has_srcline (dso, false);dso__free_a2l (dso); +dso__free_a2l_libbfd (dso); }mutex_unlock (dso__lock (dso)); out:
@@ -348,6 +349,7 @@ char *get_srcline_split(struct dso *dso, u64 addr, unsigned *line)if (dso__a2l_fails (dso) >A2L_FAIL_LIMIT ) {dso__set_has_srcline (dso, false);dso__free_a2l (dso); +dso__free_a2l_libbfd (dso); }mutex_unlock (dso__lock (dso));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/2651 perf libbfd: Report success when an address is found
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 3d8fb5a4a1d793f6afdfe6df6868f82e610e447e ]
libbfd__addr2line() only reports success when the caller asked for a file name. addr2inlines() passes a NULL file as it just wants the inline_node populating, so libbfd__addr2line() returns 0 for it unless bfd_find_inliner_info() happened to find an inline frame.
addr2line() in srcline.c treats 0 as a failure and tries the next addr2line implementation, which appends its own frames to the inline_node libbfd already appended to.
Every frame that isn't inlined is then reported twice, which happens by default when perf is built with libbfd but without libdw as the fallback order is then libbfd followed by the addr2line command:
$ perf record --call-graph dwarf -- perf test -w inlineloop 1
$ perf script --fields +srcline
...
56051a994f8e parent+0x2e (perf)
inlineloop.c:32
56051a99503a inlineloop+0x8a (perf)
inlineloop.c:47
56051a99503a inlineloop+0x8a (perf)
inlineloop.c:47
56051a95841a cmd_test+0xb7a (perf)
??:0
56051a95841a cmd_test+0xb7a (perf)
??:0
...Report success whenever the address is found, like libdw__addr2line() does, and clear the frames appended so far when appending fails so that a following implementation starts from an empty node.
--- tools/perf/util/libbfd.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/perf/util/libbfd.c +13 -3
@@ -258,6 +258,7 @@ int libbfd__addr2line(const char *dso_name, u64 addr,int cnt =0 ;if (node &&inline_list__append_dso_a2l (dso, node, sym)) { +inline_node__clear_frames (node); ret =0 ; goto out; }
@@ -271,23 +272,32 @@ int libbfd__addr2line(const char *dso_name, u64 addr,if (node !=NULL ) {if (inline_list__append_dso_a2l (dso, node, sym)) { +inline_node__clear_frames (node); ret =0 ; goto out; } -// found at least one inline frame - ret =1 ; } } }if (file) { *file = a2l->filename ?strdup (a2l->filename) :NULL ; - ret = *file ?1 :0 ; +if (!*file) { +/* Leave ret as 0 so that another addr2line is tried. */ + goto out; + } }if (line) *line = a2l->line; +/* +* The address was found, report success so that the caller doesn't try +* another addr2line implementation that would append the inline frames +* above a second time. +*/ + ret =1 ; + out:mutex_unlock (dso__lock (dso));return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/2651 dt-bindings: vendor-prefixes: add ESS Technology
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Asseily <[email protected]>
[ Upstream commit beb56d1d3de522885b30bb97fee83825041d65c2 ]
Add the vendor prefix for ESS Technology, Inc., maker of the SABRE family of audio DACs. The prefix follows the company's domain, esstech.com.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -559,6 +559,8 @@ patternProperties: description: Seiko Epson Corp. "^esp,.*": description: Espressif Systems Co. Ltd. + "^esstech,.*": + description: ESS Technology, Inc. "^est,.*": description: ESTeem Wireless Modems "^eswin,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/2651 clk: raspberrypi: Handle cpufreq device registration failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Triet Hoang <[email protected]>
[ Upstream commit e98e3d712023859af7cd78bb7fdb87ea3a9ffb83 ]
Check the return value of platform_device_register_data() when registering the raspberrypi-cpufreq device and propagate the error if registration fails.
This prevents the clock driver from reporting a successful probe when the cpufreq device could not be registered.
--- drivers/clk/bcm/clk-raspberrypi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/bcm/clk-raspberrypi.c +2 -0
@@ -553,6 +553,8 @@ static int raspberrypi_clk_probe(struct platform_device *pdev) rpi->cpufreq =platform_device_register_data (dev,"raspberrypi-cpufreq" ,-1 ,NULL ,0 ); +if (IS_ERR (rpi->cpufreq)) +return PTR_ERR (rpi->cpufreq);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/2651 clk: versatile: clk-icst: Fix node reference leak in of_syscon_icst_setup()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit c90a50d07f0c38c62ce13a60806ab5e3b841f70f ]
of_get_parent() takes a reference on the syscon parent node. The reference is intentionally kept on the success path, but the error paths return without dropping it, leaking the node reference. Release the reference before returning on the error paths.
--- drivers/clk/versatile/clk-icst.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/versatile/clk-icst.c +4 -0
@@ -516,16 +516,19 @@ static void __init of_syscon_icst_setup(struct device_node *np) map =syscon_node_to_regmap (parent);if (IS_ERR (map)) {pr_err ("no regmap for syscon ICST clock parent\n" ); +of_node_put (parent);return ; }if (of_property_read_u32 (np,"reg" , &icst_desc.vco_offset) &&of_property_read_u32 (np,"vco-offset" , &icst_desc.vco_offset)) {pr_err ("no VCO register offset for ICST clock\n" ); +of_node_put (parent);return ; }if (of_property_read_u32 (np,"lock-offset" , &icst_desc.lock_offset)) {pr_err ("no lock register offset for ICST clock\n" ); +of_node_put (parent);return ; }
@@ -552,6 +555,7 @@ static void __init of_syscon_icst_setup(struct device_node *np) ctype =ICST_INTEGRATOR_CP_CM_MEM ; }else {pr_err ("unknown ICST clock %pOF\n" , np); +of_node_put (parent);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/2651 clk: starfive: jh7110: reject oscillator lookup errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit 54d0b6903921d121fa750546f2b38cc3f5c7e64f ]
Clock lookup may fail while allocating a consumer reference. Return a notifier error rather than passing ERR_PTR as the new clock parent.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- drivers/clk/starfive/clk-starfive-jh7110-sys.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/starfive/clk-starfive-jh7110-sys.c +3 -0
@@ -390,6 +390,9 @@ static int jh7110_pll0_clk_notifier_cb(struct notifier_block *nb,if (action ==PRE_RATE_CHANGE ) {struct clk *osc =clk_get (priv->dev,"osc" ); +if (IS_ERR (osc)) +return notifier_from_errno (PTR_ERR (osc)); + priv->original_clk =clk_get_parent (cpu_root); ret =clk_set_parent (cpu_root, osc);clk_put (osc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/2651 bpf, lsm: Reject writes into the BPF LSM program context
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit c42da1d3ba9d5067cf3f0676b98bcb3f5f9e3ce1 ]
The verifier types a load from a tracing-style context by its offset
alone: btf_ctx_access() looks the offset up in the attach hook's prototype, and check_mem_access() stamps the resulting type onto the destination register. Nothing tracks what the slot actually holds. That is sound only as long as the context is read-only, and for BPF LSM it is not. lsm_verifier_ops wires ->is_valid_access() straight to btf_ctx_access(), which never looks at enum bpf_access_type, so a store into the context passes verification. Every other user of the helper either goes through bpf_tracing_btf_ctx_access() or open-codes the same type != BPF_READ test first; BPF LSM is the only one that does neither.
A program can therefore store a scalar of its choosing into a context slot, read the slot back, and get a register the verifier believes is a trusted pointer of the hook's argument type. Handing that to a kfunc or helper which dereferences a trusted argument turns it into an arbitrary kernel access. Route BPF LSM through bpf_tracing_btf_ctx_access() like everyone else.
--- kernel/bpf/bpf_lsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/bpf_lsm.c +2 -2
@@ -414,8 +414,8 @@ const struct bpf_prog_ops lsm_prog_ops = { };const struct bpf_verifier_ops lsm_verifier_ops = { - .get_func_proto = bpf_lsm_func_proto, - .is_valid_access = btf_ctx_access, + .get_func_proto = bpf_lsm_func_proto, + .is_valid_access = bpf_tracing_btf_ctx_access, };/* hooks return 0 or 1 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/2651 drm/connector: hdmi: Handle reset() state allocation failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit 54acd0c74eba2a2c9a726856f5fdc6f9e74ea2e1 ]
In drmm_connector_hdmi_init(), if the reset callback fails to allocate memory, e.g. inside drm_atomic_helper_connector_reset(), connector->state will remain NULL. This is unconditionally passed to drm_connector_attach_max_bpc_property(), leading to a NULL pointer dereference.
Bail out with -ENOMEM if the reset callback leaves connector->state unset.
--- drivers/gpu/drm/drm_connector.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_connector.c +2 -0
@@ -628,6 +628,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev, connector->state = state; }else if (connector->funcs->reset) { connector->funcs->reset (connector); +if (!connector->state) +return -ENOMEM ; }drm_connector_attach_max_bpc_property (connector,8 , max_bpc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/2651 pinctrl: fix PINCTRL_SPPCTL=m
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Gaylard <[email protected]>
[ Upstream commit 7dcf87d2dbbe8c9c1efb69fe9be728a3dfd51d3d ]
The PINCTRL_SPPCTL option is defined as a tristate in Kconfig, and the help text suggests that the user can build it as a module by setting to 'm'.
However, it cannot currently be set to 'm', because SOC_SP7021, the only platform that supports it, is a bool option that uses 'select' on it. Also, the SP7021 requires this driver to be built in, in order to boot.
Change the tristate to bool and fix the help text.
Tested on linux-next-2026-09-14 on a LTPP3G2 board.
This impossible tristate was detected by kconfirm, a static analysis tool for Kconfig, by Julian Braha <[email protected]>.
--- drivers/pinctrl/sunplus/Kconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pinctrl/sunplus/Kconfig +3 -5
@@ -4,8 +4,8 @@ # config PINCTRL_SPPCTL - tristate "Sunplus SP7021 PinMux and GPIO driver" - depends on SOC_SP7021 + bool "Sunplus SP7021 PinMux and GPIO driver" + depends on SOC_SP7021 || COMPILE_TEST depends on OF && HAS_IOMEM select GENERIC_PINCTRL_GROUPS select GENERIC_PINMUX_FUNCTIONS
@@ -16,6 +16,4 @@ config PINCTRL_SPPCTL help Say Y here to support Sunplus SP7021 pinmux controller. This driver requires the pinctrl framework. - GPIO is provided by the same driver. - To compile this driver as a module, choose M here. - The module will be called sppinctrl. + This driver also provides GPIO.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/2651 ASoC: SDCA: Improve scanning the SWFT during FDL
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Strozek <[email protected]>
[ Upstream commit 4454102d6565afedfcde64b222595f067a5b7e93 ]
Walking through SWFT is now improved to verify if it is not reading past the end of the table.
Introduce file length checks that are done for SWFs from disk to files from SWFT too.
--- sound/soc/sdca/sdca_fdl.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
sound/soc/sdca/sdca_fdl.c +12 -4
@@ -199,7 +199,6 @@ static int fdl_load_file(struct sdca_interrupt *interrupt,struct sdca_fdl_file *fdl_file;char *disk_filename;int ret; -int i;if (!set) {dev_err (dev,"request to load SWF with no set\n" );
@@ -209,9 +208,18 @@ static int fdl_load_file(struct sdca_interrupt *interrupt, fdl_file = &set->files[file_index];if (fdl_data->swft) { - tmp = fdl_data->swft->files; -for (i =0 ; i < fdl_data->swft->header.length; i += tmp->file_length, - tmp = ACPI_ADD_PTR(struct acpi_sw_file, tmp, tmp->file_length)) { +struct acpi_sw_file *table_end, *next; + + table_end = ACPI_ADD_PTR(struct acpi_sw_file, fdl_data->swft, + fdl_data->swft->header.length); +for (tmp = fdl_data->swft->files; tmp +1 <= table_end; tmp = next) { + next = ACPI_ADD_PTR(struct acpi_sw_file, tmp, tmp->file_length); + +if (tmp->file_length <sizeof (*tmp) || next > table_end) { +dev_err (dev,"bad file length in SWFT: %u\n" , tmp->file_length); +break ; + } +if (tmp->vendor_id == fdl_file->vendor_id && tmp->file_id == fdl_file->file_id) { dev_dbg(dev, "located SWF in ACPI: %x-%x-%x\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/2651 ASoC: SDCA: Check return value on a missing FDL_Set_Index Range
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Strozek <[email protected]>
[ Upstream commit dfd8940277c9a07193c2d168760e19d054f5047c ]
In case of a missing FDL_Set_Index control the return value can be NULL, ensure the functions returns before passing it on to range search.
--- sound/soc/sdca/sdca_fdl.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sdca/sdca_fdl.c +2 -0
@@ -301,6 +301,8 @@ static struct sdca_fdl_set *fdl_get_set(struct sdca_interrupt *interrupt) range =sdca_selector_find_range (dev, xu,SDCA_CTL_XU_FDL_SET_INDEX ,SDCA_FDL_SET_INDEX_NCOLS ,0 ); +if (!range) +return NULL ; val =sdca_range_search (range,SDCA_FDL_SET_INDEX_SET_NUMBER , val,SDCA_FDL_SET_INDEX_FILE_SET_ID );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/2651 arm64: dts: mediatek: mt7988a-bpi-r4pro: label gpio-hogs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Wunderlich <[email protected]>
[ Upstream commit bf89276b2db391cbb25d1a0e898280fe85b16fb5 ]
GPIO hogs were tagged with name "?" in recent kernel versions (7.1+) due to commit d1d564ec4992 ("gpio: move hogs into GPIO core").
7.0 showed the unit-name which behaviour is restored by patch [1], but labeling the hog directly makes things easier.
gpiochip0: 84 GPIOs, parent: platform/1001f000.pinctrl, pinctrl_moore:
gpio-0 ( |tx-disable ) in lo gpio-1 ( |mod-def0 ) in hi IRQ ACTIVE LOW gpio-2 ( |los ) in hi IRQ gpio-12 ( |cd ) in lo IRQ ACTIVE LOW gpio-13 ( |reset ) in hi IRQ ACTIVE LOW gpio-14 ( |WPS ) in hi IRQ ACTIVE LOW gpio-21 ( |tx-disable ) in lo gpio-63 ( |? ) out hi gpio-69 ( |mod-def0 ) in hi IRQ ACTIVE LOW gpio-70 ( |los ) in hi IRQ gpio-79 ( |? ) out lo gpio-82 ( |PHY reset ) out hi ACTIVE LOW gpio-83 ( |PHY reset ) out hi ACTIVE LOW
after the change:
root@bpi-r4:~# cat /sys/kernel/debug/gpio gpiochip0: 84 GPIOs, parent: platform/1001f000.pinctrl, pinctrl_moore: gpio-0 ( |tx-disable ) in lo gpio-1 ( |mod-def0 ) in hi IRQ ACTIVE LOW gpio-2 ( |los ) in hi IRQ gpio-12 ( |cd ) in lo IRQ ACTIVE LOW gpio-13 ( |reset ) in hi IRQ ACTIVE LOW gpio-14 ( |WPS ) in hi IRQ ACTIVE LOW gpio-21 ( |tx-disable ) in lo gpio-63 ( |pcie3-cn14-hog ) out hi gpio-69 ( |mod-def0 ) in hi IRQ ACTIVE LOW gpio-70 ( |los ) in hi IRQ gpio-79 ( |pcie2-cn15-hog ) out lo gpio-82 ( |PHY reset ) out hi ACTIVE LOW gpio-83 ( |PHY reset ) out hi ACTIVE LOW
[1] https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git/commit/?id=d54a489c8c4b627775445d54a6cbd32f209bda8f
"gpiolib: use of_node_name if line-name is missing"
--- .../boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn13.dtso | 1 + .../boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn14.dtso | 1 + .../boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn15.dtso | 1 + .../boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn18.dtso | 1 + 4 files changed, 4 insertions(+)
arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn13.dtso +1 -0
@@ -16,5 +16,6 @@ / { }; &{/soc/pinctrl@1001f000/pcie-2-hog} { + line-name = "pcie2-cn13-hog"; output-high; };
arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn14.dtso +1 -0
@@ -16,5 +16,6 @@ / { }; &{/soc/pinctrl@1001f000/pcie-3-hog} { + line-name = "pcie3-cn14-hog"; output-high; };
arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn15.dtso +1 -0
@@ -16,5 +16,6 @@ / { }; &{/soc/pinctrl@1001f000/pcie-2-hog} { + line-name = "pcie2-cn15-hog"; output-low; };
arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-pro-cn18.dtso +1 -0
@@ -16,5 +16,6 @@ / { }; &{/soc/pinctrl@1001f000/pcie-3-hog} { + line-name = "pcie3-cn18-hog"; output-low; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/2651 fs/ntfs3: check INDEX_ROOT resident size before use in ntfs_read_mft()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei (Microsoft) <[email protected]>
[ Upstream commit d0ac69ce3af4dbae01d4f064b7482f0c5440dbde ]
When ntfs_read_mft() parses an ATTR_ROOT attribute it computes
root = Add2Ptr(attr, roff);
using the on-disk resident data offset (roff = attr->res.data_off) and then dereferences root->type and root->rule, and later passes root on to indx_init(). Unlike the ATTR_STD and ATTR_NAME cases, which validate that the resident data is large enough (asize >= sizeof(struct X) + roff and rsize >= sizeof(struct X)) before accessing it, the ATTR_ROOT case has no such check.
mi_enum_attr() only guarantees data_off + data_size <= attribute size, so a crafted image can set data_off such that root lands at (or past) the end of the MFT record's slab allocation while still passing that check (e.g. data_size == 0). The subsequent read of root->type is then a slab-out-of-bounds read, reported by KASAN when mounting the image:
BUG: KASAN: slab-out-of-bounds in ntfs_iget5 (fs/ntfs3/inode.c:283) Read of size 4 at addr ffff88800c06a400 by task exploit/142 Call Trace: ... [KASAN report internals] ntfs_iget5 (fs/ntfs3/inode.c:283 fs/ntfs3/inode.c:542) ntfs_fill_super (fs/ntfs3/super.c:1690) get_tree_bdev_flags (fs/super.c:1634) vfs_get_tree (fs/super.c:1694) fc_mount (fs/namespace.c:1198) path_mount (fs/namespace.c:3765 ...) __x64_sys_mount (fs/namespace.c:4174 ...) do_syscall_64 (arch/x86/entry/syscall_64.c:63) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) The buggy address is located 0 bytes to the right of allocated 1024-byte region [ffff88800c06a000, ffff88800c06a400) which belongs to the cache kmalloc-1k of size 1024
Validate the resident data size in the ATTR_ROOT case the same way the neighbouring cases do, so that a truncated or mis-offset INDEX_ROOT is rejected before root is dereferenced.
--- fs/ntfs3/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ntfs3/inode.c +3 -1
@@ -285,7 +285,9 @@ static int ntfs_read_mft(struct inode *inode, const struct cpu_str *name,break ;case ATTR_ROOT : -if (attr->non_res) +if (attr->non_res || + asize <sizeof (struct INDEX_ROOT ) + roff || + rsize <sizeof (struct INDEX_ROOT )) goto out; root =Add2Ptr (attr, roff);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/2651 fs/ntfs3: fix valid_size not being updated in attr_allocate_frame()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Xusheng <[email protected]>
[ Upstream commit a1972501ffb15313f7ae598989bb2cd32829e625 ]
At the end of attr_allocate_frame() the on-disk valid_size is meant to be updated to the value passed in via @new_valid:
valid_size = le64_to_cpu(attr_b->nres.valid_size);
if (new_valid != valid_size) {
attr_b->nres.valid_size = cpu_to_le64(valid_size);
mi_b->dirty = true;
}but it writes back the old valid_size that was just read instead of new_valid, so the field is never actually changed even though the record is marked dirty -- the intended update is a no-op.
ni_update_parent() spells the same read-compare-write out correctly a few hundred lines away, storing the newly derived value:
valid_le = cpu_to_le64(new_valid);
if (valid_le != attr->nres.valid_size) {
attr->nres.valid_size = valid_le;In practice that path, reached from ni_write_inode(), re-derives nres.valid_size from ni->i_valid on inode write-back, which normally masks this, so the visible impact is limited. The assignment here is still wrong though; store @new_valid as intended.
--- fs/ntfs3/attrib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/attrib.c +1 -1
@@ -2010,7 +2010,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, valid_size =le64_to_cpu (attr_b->nres.valid_size);if (new_valid != valid_size) { - attr_b->nres.valid_size =cpu_to_le64 (valid_size); + attr_b->nres.valid_size =cpu_to_le64 (new_valid); mi_b->dirty = true; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/2651 fs/ntfs3: validate EA entry layout against ef->size in ntfs_read_ea
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit 01e56820ef52d14a5560fb7c0c6f2f75ef6f9393 ]
In ntfs_read_ea(), the ef->size branch only checks that the declared entry size fits the remaining buffer; unlike the zero-size branch it never verifies that the entry's own name and value fit inside ef->size. A crafted image can thus present an in-bounds ef->size with an arbitrary elength, which find_ea()/ntfs_get_ea() later use as the memcpy length, reading past the allocation and leaking adjacent heap memory:
BUG: KASAN: slab-out-of-bounds in ntfs_get_ea (fs/ntfs3/xattr.c:302) Read of size 65535 at addr ffff888010770b0f by task exploit/142 ... __asan_memcpy (mm/kasan/shadow.c:105) ntfs_get_ea (fs/ntfs3/xattr.c:302) ntfs_getxattr (fs/ntfs3/xattr.c:848) __vfs_getxattr (fs/xattr.c:446) vfs_getxattr (fs/xattr.c:479) do_getxattr (fs/xattr.c:808) filename_getxattr (fs/xattr.c:837) path_getxattrat (fs/xattr.c:876) do_syscall_64 (arch/x86/entry/syscall_64.c:94) ... The buggy address is located 15 bytes inside of allocated 20-byte region, cache kmalloc-32
Validate the name/value layout in the ef->size branch too, bounding it against ef->size, as the zero-size branch validates it against the buffer.
--- fs/ntfs3/xattr.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ntfs3/xattr.c +2 -0
@@ -168,6 +168,8 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea, ea_size =le32_to_cpu (ef->size);if (ea_size > bytes || packed_size > ea_size) goto out1; +if (bytes < offsetof(struct EA_FULL , name)) + goto out1;continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/2651 fs/ntfs3: validate $SDH entry size in ntfs_insert_security
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 5b76487f94dacc2884135ce9a7bda61ce7ffa209 ]
ntfs_insert_security() walks the $Secure::$SDH index and reads e->sec_hdr.size for every entry returned by indx_find()/indx_find_sort(). Those only guarantee the NTFS_DE envelope (e->size), so a crafted $SDH entry shorter than a full NTFS_DE_SDH at the tail of an index buffer makes the read of e->sec_hdr.size run past the allocation. Triggerable by an unprivileged setxattr(2) on a crafted NTFS image.
BUG: KASAN: slab-out-of-bounds in ntfs_insert_security (fs/ntfs3/fsntfs.c:2148) Read of size 4 at addr ffff88800fa1de00 by task exploit/142 ntfs_insert_security (fs/ntfs3/fsntfs.c:2148) ntfs_setxattr (fs/ntfs3/xattr.c:947) __vfs_setxattr (fs/xattr.c:223) __vfs_setxattr_noperm (fs/xattr.c:257) vfs_setxattr (fs/xattr.c:344) filename_setxattr (fs/xattr.c:690) path_setxattrat (fs/xattr.c:734) __x64_sys_setxattr (fs/xattr.c:764) [...] The buggy address is located 0 bytes to the right of allocated 512-byte region [ffff88800fa1dc00, ffff88800fa1de00)
Stop the scan when an entry is too small to hold a SECURITY_HDR.
--- fs/ntfs3/fsntfs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/fsntfs.c +3 -0
@@ -2153,6 +2153,9 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi, goto out;while (e) { +if (le16_to_cpu (e->de.size) <SIZEOF_SDH_DIRENTRY ) +break ; +if (le32_to_cpu (e->sec_hdr.size) == new_sec_size) { err = ntfs_read_run_nb(sbi, &ni->file.run, le64_to_cpu(e->sec_hdr.off),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/2651 pmdomain: imx: Propagate SCU provider registration failures
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit d3efba7921f3ebebd91fc481910a428c78414fd8 ]
imx_scu_init_pm_domains() ignores of_genpd_add_provider_onecell() and returns success even when none of the initialized domains are published to DT consumers.
Return the provider error and remove the initialized domains in reverse order before devm releases their backing storage on probe failure.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/pmdomain/imx/scu-pd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pmdomain/imx/scu-pd.c +8 -2
@@ -474,7 +474,7 @@ static int imx_scu_init_pm_domains(struct device *dev,struct genpd_onecell_data *pd_data;struct imx_sc_pm_domain *sc_pd;u32 count =0 ; -int i, j; +int i, j, ret;for (i =0 ; i < pd_soc->num_ranges; i++) count += pd_ranges[i].num;
@@ -503,7 +503,13 @@ static int imx_scu_init_pm_domains(struct device *dev, pd_data->num_domains = count; pd_data->xlate = imx_scu_pd_xlate; -of_genpd_add_provider_onecell (dev->of_node, pd_data); + ret =of_genpd_add_provider_onecell (dev->of_node, pd_data); +if (ret) { +while (count) +pm_genpd_remove (domains[--count]); + +return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/2651 pmdomain: renesas: r8a78000: Fix lockdep false positive
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit ddacdefc38200bafa35e79925bbc1f4b1fdf41a8 ]
Lockdep reports a possible circular locking dependency when attaching devices to an MDLC PM domain:
- During creation of the singleton PM domain:
A. r8a78000_genpd_always_on_singleton() takes r8a78000_mdlc_lock, B. pm_genpd_init() takes gpd_list_lock.
- During attachment of devices to PM domains:
A. pm_genpd_add_device() takes gpd_list_lock, B. r8a78000_mdlc_attach_dev() takes r8a78000_mdlc_lock.
As the former is done only once, before any devices are attached, such a AB-BA deadlock cannot really happen. Fix this false positive by introducing a separate lock to protect the creation of the singleton domain.
--- drivers/pmdomain/renesas/r8a78000-mdlc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pmdomain/renesas/r8a78000-mdlc.c +4 -2
@@ -45,8 +45,9 @@ struct r8a78000_mdlc_priv { };static struct generic_pm_domain *r8a78000_genpd_always_on; +static HLIST_HEAD (r8a78000_mdlc_list); -static DEFINE_MUTEX (r8a78000_mdlc_lock);/* protects the two above */ +static DEFINE_MUTEX (r8a78000_mdlc_lock);/* protects the list above */ static struct generic_pm_domain *r8a78000_genpd_xlate (const struct of_phandle_args *spec,void *data)
@@ -191,10 +192,11 @@ static void r8a78000_genpd_del_provider(void *data)static int r8a78000_genpd_always_on_singleton (struct device *dev) { +static DEFINE_MUTEX (singleton_lock);struct generic_pm_domain *genpd;int ret; -guard (mutex)(&r8a78000_mdlc_lock); +guard (mutex)(&singleton_lock);if (r8a78000_genpd_always_on)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/2651 dt-bindings: vendor-prefixes: add vendor prefix for Nexperia B.V.
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Armstrong <[email protected]>
[ Upstream commit 819a3e62d37a2fe73c1e7f241f2ac086042e7757 ]
Document the vendor prefix for the semiconductor company Nexperia B.V.
The company website is https://www.nexperia.com/
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -1194,6 +1194,8 @@ patternProperties: description: New Vision Display (Shenzhen) Co., Ltd. "^nexbox,.*": description: Nexbox + "^nexperia,.*": + description: Nexperia B.V. "^nextthing,.*": description: Next Thing Co. "^ni,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/2651 drivers/thermal/renesas/rzg3e: Fix signed integer overflow in temp_to_code()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 84f0e14e6261ef718e6a8583073097ad9ea70e14 ]
The thermal core passes -INT_MAX/INT_MAX as low/high trip points, which the driver then converts to code values for programming the registers:
numerator = (temp_mc - info->temp_d_mc) * (priv->trmval1 - priv->trmval0);
Although 'numerator' is defined as s64, the arithmetic is performed as int. Because of this, the multiplication overflows for -INT_MAX and, because temp_d_mc is negative, the subtraction overflows for INT_MAX.
To fix this, cast the temperature to s64, so that the arithmetic is performed as s64.
--- drivers/thermal/renesas/rzg3e_thermal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/thermal/renesas/rzg3e_thermal.c +6 -1
@@ -194,7 +194,12 @@ static u16 rzg3e_thermal_temp_to_code(struct rzg3e_thermal_priv *priv, int temp_s64 numerator, denominator;s64 code; - numerator = (temp_mc - info->temp_d_mc) * (priv->trmval1 - priv->trmval0); +/* +* Perform the arithmetic in 64 bits so that it cannot overflow for +* -INT_MAX/INT_MAX values passed from the thermal core or when +* userspace writes arbitrary trip point temperatures. +*/ + numerator = ((s64 )temp_mc - info->temp_d_mc) * (priv->trmval1 - priv->trmval0); denominator = info->temp_e_mc - info->temp_d_mc; code =div64_s64 (numerator, denominator) + priv->trmval0;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/2651 thermal/drivers/renesas/rzg3e: Fix runtime PM handling of compare irq
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit aa1bc39e45f29a4f56d7e6be7164e100727df465 ]
The TSU hw is limited in the sense that lower and upper trip points can be set, but the hw cannot raise interrupts on its own. It can only signal that the thresholds were passed when the temperature is read, either during polling or on a manual read. Therefore, the interrupt enable state configured by set_trips() must remain active for the next read to trigger an event.
Currently, runtime PM autosuspend puts the chip to sleep and clears the compare interrupt that was enabled during set_trips(). On power up, the compare interrupt enable is not restored, which means that it won't ever fire.
Fix this by caching the contents of the SIER register during runtime power off and restore it during runtime power on.
--- drivers/thermal/renesas/rzg3e_thermal.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/thermal/renesas/rzg3e_thermal.c +7 -1
@@ -93,6 +93,7 @@ struct rzg3e_thermal_info {* @info: chip type specific information * @trmval0: calibration value 0 (b) * @trmval1: calibration value 1 (c) +* @sier: cached interrupt enable register * @lock: protects hardware access during conversions */ struct rzg3e_thermal_priv {
@@ -103,6 +104,7 @@ struct rzg3e_thermal_priv {const struct rzg3e_thermal_info *info;u16 trmval0;u16 trmval1; +u32 sier;struct mutex lock; };
@@ -148,12 +150,16 @@ static int rzg3e_thermal_power_on(struct rzg3e_thermal_priv *priv)return ret; } +/* Restore interrupt enable state */ +writel (priv->sier, priv->base +TSU_SIER ); +return 0 ; }static void rzg3e_thermal_power_off (struct rzg3e_thermal_priv *priv) { -/* Disable all interrupts */ +/* Save and disable all interrupts */ + priv->sier =readl (priv->base +TSU_SIER );writel (0 , priv->base +TSU_SIER );/* Clear pending interrupts */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/2651 thermal/drivers/renesas/rzg3e: Fix race between set_trips() and get_temp()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit acd9bf8f9047b03f023514bceab6a00e037977ca ]
Datasheet section 7.11.9.2 "Conversion Start Trigger" states that a conversion must only be started while no other conversion is in progress:
"Before making the setting to start conversion by software or an ELC
trigger, check that the CONV bit of the sensor status register is 0b."
set_trips() starts a conversion at the end of the function and returns without waiting for it to finish. A get_temp() call arriving right after that starts a conversion while the CONV bit may still be set, violating the requirement above.
Fix this by:
- polling for CONV == 0 in get_temp() before starting a conversion
- not starting a conversion at the end of set_trips() anymore
The conversion started at the end of set_trips() was supposed to check whether the thresholds have been passed, since the hw cannot raise interrupts on its own, but only when the temperature is read. However, the thermal core reads the temperature and computes the trip window from it just before calling into set_trips(), so reading the temperature again straight away is useless.
--- drivers/thermal/renesas/rzg3e_thermal.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/thermal/renesas/rzg3e_thermal.c +11 -2
@@ -225,6 +225,16 @@ static int rzg3e_thermal_get_temp(struct thermal_zone_device *tz, int *temp)guard (mutex)(&priv->lock); +/* Make sure a previous conversion is not in progress */ + ret =readl_poll_timeout (priv->base +TSU_SSR , status, + !(status &TSU_SSR_CONV ), +TSU_POLL_DELAY_US , +USEC_PER_MSEC ); +if (ret) { +dev_err (priv->dev,"Timeout waiting for conversion\n" ); + goto out; + } +/* Clear any previous conversion status */ writel (TSU_SICR_ADCLR , priv->base +TSU_SICR );
@@ -304,9 +314,8 @@ static int rzg3e_thermal_set_trips(struct thermal_zone_device *tz,/* Enable comparison with "out of range" mode (CMPCOND=0) */ writel (TSU_CMSR_CMPEN , priv->base +TSU_CMSR ); -/* Unmask compare IRQ and start a conversion to evaluate window */ +/* Unmask compare IRQ */ writel (TSU_SIER_CMPIE , priv->base +TSU_SIER ); -writel (TSU_STRGR_ADST , priv->base +TSU_STRGR );pm_runtime_mark_last_busy (priv->dev);pm_runtime_put_autosuspend (priv->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/2651 bpftool: Compute map size of light skeletons at runtime
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit a885470df10b1c0dbc011177c19d3fd3bb8af2e9 ]
bpftool rounds memory-mapped data map sizes to the host page size when generating a light skeleton. The generated code therefore uses a 64K mapping size when bpftool runs on a 64K-page host, even if the skeleton runs on a 4K-page target. The target rejects the oversized map mmap(), causing failure of loading the light skeleton.
When try to run 64K-page selftests on 4K-page VM, the error message does not provide the reason about page size.
test_atomics:PASS:atomics skeleton open 0 nsec test_atomics:FAIL:atomics skeleton load unexpected error: -12 (errno 22)
#15 atomics:FAIL
Pass the original map value size and max entries to the generated code and round mmap size to the runtime page size in the user-space light skeleton helpers. This keeps generated light skeletons independent of the build host page size.
--- tools/bpf/bpftool/gen.c | 26 ++++++------------- tools/lib/bpf/skel_internal.h | 48 +++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 32 deletions(-)
tools/bpf/bpftool/gen.c +8 -18
@@ -500,16 +500,6 @@ static void print_hex(const char *data, int data_sz) } } -static size_t bpf_map_mmap_sz (const struct bpf_map *map) -{ -long page_sz =sysconf (_SC_PAGE_SIZE); -size_t map_sz; - - map_sz = (size_t )roundup (bpf_map__value_size (map),8 ) *bpf_map__max_entries (map); - map_sz =roundup (map_sz, page_sz); -return map_sz; -} -/* Emit type size asserts for all top-level fields in memory-mapped internal maps. */ static void codegen_asserts (struct bpf_object *obj,const char *obj_name) {
@@ -686,8 +676,8 @@ static void codegen_destroy(struct bpf_object *obj, const char *obj_name)if (!get_map_ident (map, ident,sizeof (ident)))continue ;if (is_skel_data (map, ident,sizeof (ident))) -printf ("\tskel_free_map_data(skel->%1$s, skel->maps.%1$s.initial_value, %2$zu);\n" , - ident,bpf_map_mmap_sz (map)); +printf ("\tskel_free_map_data(skel->%1$s, skel->maps.%1$s.initial_value, %2$u, %3$u);\n" , + ident,bpf_map__value_size (map),bpf_map__max_entries (map)); codegen("\ \n\ skel_closenz(skel->maps.%1$s.map_fd); \n\
@@ -771,13 +761,13 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *h \n\ \"; \n\\n\ -skel->%1$s = (__typeof__(skel->%1$s))skel_prep_map_data((void *)data, %2$zd,\n\ +skel->%1$s = (__typeof__(skel->%1$s))skel_prep_map_data((void *)data, %2$u, %3$u,\n\ sizeof(data) - 1);\n\ if (!skel->%1$s) \n\ goto cleanup; \n\ skel->maps.%1$s.initial_value = (__u64) (long) skel->%1$s;\n\ } \n\ - ", ident, bpf_map_mmap_sz(map)); + ", ident, bpf_map__value_size(map), bpf_map__max_entries(map)); } codegen("\ \n\
@@ -871,14 +861,14 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *hif (bpf_map__type (map) ==BPF_MAP_TYPE_PERCPU_ARRAY ) {codegen ("\ \n\ -err = skel_protect_map_data(skel->%1$s, &skel->maps.%1$s.initial_value, %2$zd);\n\ +err = skel_protect_map_data(skel->%1$s, &skel->maps.%1$s.initial_value, %2$u, %3$u);\n\ if (err) \n\ return err; \n\ #ifdef __KERNEL__ \n\ skel->%1$s = NULL; \n\ #endif \n\ " , - ident,bpf_map_mmap_sz (map)); + ident,bpf_map__value_size (map),bpf_map__max_entries (map));continue ; }
@@ -890,11 +880,11 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *hcodegen ("\ \n\ skel->%1$s = (__typeof__(skel->%1$s))skel_finalize_map_data(&skel->maps.%1$s.initial_value,\n\ -%2$zd, %3$s, skel->maps.%1$s.map_fd);\n\ +%2$u, %3$u, %4$s, skel->maps.%1$s.map_fd);\n\ if (!skel->%1$s) \n\ return -ENOMEM; \n\ " , - ident,bpf_map_mmap_sz (map), mmap_flags); + ident,bpf_map__value_size (map),bpf_map__max_entries (map), mmap_flags); } codegen("\ \n\
tools/lib/bpf/skel_internal.h +34 -14
110 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/2651 bpf: Add printf attributes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 7f2b0b57a8d7dc0772ab998007d5d8e8f1f94966 ]
Building with extra warnings enabled shows a missing printf attribute:
kernel/bpf/diagnostics.c: In function 'bpf_diag_source':kernel/bpf/diagnostics.c:828:9: error: function 'bpf_diag_source' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
828 | msg = bpf_diag_vfmt(env, fmt, args);
Add these to shut up the warning and allow the compiler to check the format strings.
--- kernel/bpf/diagnostics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/bpf/diagnostics.c +3 -2
@@ -794,8 +794,9 @@ static void diag_print_insn_context(struct bpf_verifier_env *env, u32 insn_idx, } } -static void bpf_diag_source (struct bpf_verifier_env *env,u32 insn_idx,const char *label, -const char *fmt, ...) +static __printf(4, 5) void bpf_diag_source(struct bpf_verifier_env *env, +u32 insn_idx,const char *label, +const char *fmt, ...) {struct bpf_diag_scratch *scratch;struct bpf_linfo_source *source_lines;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/2651 selftests/bpf: Clean up child when task_work__open() fails
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Lu <[email protected]>
[ Upstream commit 8715b13c1a800f34f9d8177837e5244ac8288f60 ]
task_work_run() forks a child that blocks reading a pipe until the parent wakes it. If task_work__open() fails afterwards, the parent returns without closing either pipe fd or waiting for the child. Because the parent retains the write end, the child remains blocked in read() until test_progs exits.
Route this failure through the common cleanup path. At this point cleanup is safe: pe_fd is -1, link is NULL, task_work__destroy() accepts NULL, and the pid > 0 branch closes the read end, wakes the child, closes the write end and waits for it.
This is the last early return after a successful fork. The fork failure path already closes both pipe fds after commit 5730dacb3f17 ("selftests/bpf: Task_work selftest cleanup fixes").
--- tools/testing/selftests/bpf/prog_tests/test_task_work.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/test_task_work.c +1 -1
@@ -85,7 +85,7 @@ static void task_work_run(const char *prog_name, const char *map_name) skel =task_work__open ();if (!ASSERT_OK_PTR (skel,"task_work__open" )) -return ; + goto cleanup;bpf_object__for_each_program (prog, skel->obj) {bpf_program__set_autoload (prog, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 620/2651 i3c: master: Match ACPI targets to the correct bus controller instance
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 25648fb7cebb7e1963afc31c07e650d703cfc140 ]
For ACPI-enumerated I3C targets, _ADR encodes both the zero-based bus controller instance number in bits 51:48 and the Provisioned ID (PID) in bits 47:0, as defined by ACPI 6.6 Table 6.2 and MIPI DisCo for I3C v1.1 section 5.2.
However, i3c_master_add_acpi_dev() treats the entire _ADR value as the PID. On multi-instance controllers this folds the instance number into the PID, causing i3c_master_add_i3c_boardinfo() to reject devices on instance 1 and above with -EINVAL.
The problem is exposed by the MIPI I3C HCI PCI driver, which creates one MFD child device per bus controller instance. Since the child devices do not have their own ACPI companions, they all inherit the parent's ACPI node and therefore enumerate the same set of child devices. As a result, a target belonging to any instance other than 0 prevents registration of all controller instances.
Add an instance number to struct i3c_master_controller, propagate it from the HCI PCI driver, extract the PID from bits 47:0 of _ADR, and ignore ACPI child nodes that belong to a different controller instance.
ACPI-enumerated I2C devices are unaffected. Their controller instance is encoded in the Resource Source Index of the I2cSerialBusV2 descriptor rather than in _ADR and will require separate handling.
--- drivers/i3c/master.c | 19 +++++++++++++++++-- drivers/i3c/master/mipi-i3c-hci/core.c | 4 +++- .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 1 + include/linux/i3c/master.h | 3 +++ include/linux/platform_data/mipi-i3c-hci.h | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-)
drivers/i3c/master.c +17 -2
@@ -8,6 +8,7 @@#include <dt-bindings/i3c/i3c.h> #include <linux/acpi.h> #include <linux/atomic.h> +#include <linux/bitfield.h> #include <linux/bitmap.h> #include <linux/bug.h> #include <linux/delay.h>
@@ -3076,6 +3077,13 @@ static int i3c_master_add_of_dev(struct i3c_master_controller *master,return ret; } +#define I3C_ACPI_ADR_PID GENMASK_U64(47, 0) +/* +* Zero-based instance number of the Bus Controller to which the Target is +* connected. +*/ +#define I3C_ACPI_ADR_INSTANCE GENMASK_U64(51, 48) +#ifdef CONFIG_ACPI static int i3c_master_add_acpi_dev (struct i3c_master_controller *master,struct fwnode_handle *fwnode)
@@ -3083,6 +3091,7 @@ static int i3c_master_add_acpi_dev(struct i3c_master_controller *master,struct acpi_device *adev =to_acpi_device_node (fwnode);acpi_bus_address adr;u32 reg[3 ] = {0 }; +u64 pid;int ret;/*
@@ -3100,9 +3109,15 @@ static int i3c_master_add_acpi_dev(struct i3c_master_controller *master, adr =acpi_device_adr (adev); +/* Match the multi-bus instance number */ +if (FIELD_GET (I3C_ACPI_ADR_INSTANCE , adr) != master->instance) +return 0 ; +/* For I3C devices, _ADR will have the 48 bit PID of the device */ - reg[1 ] =upper_32_bits (adr); - reg[2 ] =lower_32_bits (adr); + pid =FIELD_GET (I3C_ACPI_ADR_PID , adr); + + reg[1 ] =upper_32_bits (pid); + reg[2 ] =lower_32_bits (pid);fwnode_property_read_u32 (fwnode,"mipi-i3c-static-address" , ®[0 ]);
drivers/i3c/master/mipi-i3c-hci/core.c +3 -1
@@ -1142,8 +1142,10 @@ static int i3c_hci_probe(struct platform_device *pdev)* necessarily in separate contiguous sub-ranges. To avoid overlapping * mappings, provide base_regs from the parent mapping. */ -if (pdata) +if (pdata) { hci->base_regs = pdata->base_regs; + hci->master.instance = pdata->instance; + }if (!hci->base_regs) { hci->base_regs =devm_platform_ioremap_resource (pdev,0 );
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +1 -0
@@ -390,6 +390,7 @@ static void mipi_i3c_hci_pci_setup_cell(struct mipi_i3c_hci_pci *hci, int idx, struct mfd_cell *cell) { data->pdata.base_regs = hci->base + hci->info->instance_offset[idx]; + data->pdata.instance = idx; data->res =DEFINE_RES_IRQ (0 );
include/linux/i3c/master.h +3 -0
@@ -536,6 +536,8 @@ struct i3c_master_controller_ops {* Bit 0: SETDASA * Bit 1: SETAASA * All other bits are reserved. +* @instance: Zero-based instance number of the Bus Controller as defined by the +* DisCo specification I3C Target Address (_ADR) Encoding * @wq: freezable workqueue which can be used by master * drivers if they need to postpone operations that need to take place * in a thread context. Typical examples are Hot Join processing which
@@ -573,6 +575,7 @@ struct i3c_master_controller { } boardinfo;struct i3c_bus bus;u8 addr_method; +u8 instance;struct workqueue_struct *wq;struct work_struct hj_work;struct work_struct reg_work;
include/linux/platform_data/mipi-i3c-hci.h +4 -0
@@ -3,13 +3,17 @@#define INCLUDE_PLATFORM_DATA_MIPI_I3C_HCI_H #include <linux/compiler_types.h> +#include <linux/types.h> /** * struct mipi_i3c_hci_platform_data - Platform-dependent data for mipi_i3c_hci * @base_regs: Register set base address (to support multi-bus instances) +* @instance: Zero-based instance number of the Bus Controller as defined by the +* DisCo specification I3C Target Address (_ADR) Encoding */ struct mipi_i3c_hci_platform_data {void __iomem *base_regs; +u8 instance; };#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/2651 i3c: mipi-i3c-hci: Restore controller state if i3c_hci_enable_ibi() returns an error
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit ad869331ac616bf192c04081ef7e206e1d106ad8 ]
i3c_hci_enable_ibi() performs controller-side setup before sending the ENEC CCC to enable IBIs on the target. If the ENEC CCC fails, the function returns an error but leaves the controller configured as if IBI enabling had succeeded.
Fix the error path by undoing the earlier setup when the ENEC CCC fails, ensuring the controller state remains consistent with the failed enable operation.
--- drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/core.c +5 -1
@@ -703,11 +703,15 @@ static int i3c_hci_enable_ibi(struct i3c_dev_desc *dev)struct i3c_master_controller *m =i3c_dev_get_master (dev);struct i3c_hci *hci =to_i3c_hci (m);struct i3c_hci_dev_data *dev_data =i3c_dev_get_master_data (dev); +int ret; mipi_i3c_hci_dat_v1.clear_flags (hci, dev_data->dat_idx,DAT_0_SIR_REJECT ,0 );scoped_guard (spinlock_irqsave, &hci->lock) hci->ibi_devs[dev_data->dat_idx] = dev; -return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); + ret =i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); +if (ret) +__i3c_hci_disable_ibi (hci, dev); +return ret; }static int i3c_hci_disable_ibi (struct i3c_dev_desc *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/2651 i3c: mipi-i3c-hci: Fix runtime PM violation in i3c_hci_free_ibi()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 1570265b225757e3684a7c13c36915823f62675d ]
i3c_hci_free_ibi() calls __i3c_hci_disable_ibi(), but the latter requires runtime PM to be resumed. The ->free_ibi() callback does not guarantee that condition.
The cases where ->free_ibi() may be called without a preceding ->disable_ibi() do not require re-enabling runtime PM handling:
- runtime resume failed in i3c_dev_free_ibi_locked(), so it skips the IBI disable but still proceeds to call ->free_ibi()
- the device has been re-enumerated under a new dynamic address in __i3c_master_add_i3c_dev_locked(), which tears down the old device descriptor and deliberately clears olddev->ibi->enabled (to avoid sending a DISEC to the stale old address) before calling i3c_dev_free_ibi_locked(). As a result ->free_ibi() is reached with neither a hardware IBI disable nor runtime PM resumed.
In both cases the important requirement is to prevent further IBI processing for the device. That can be done without accessing hardware by removing the device from the ibi_devs[] table.
Replace the call to __i3c_hci_disable_ibi() with clearing the corresponding ibi_devs[] entry under the controller lock.
--- drivers/i3c/master/mipi-i3c-hci/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +4 -2
@@ -675,11 +675,13 @@ static void __i3c_hci_disable_ibi(struct i3c_hci *hci, struct i3c_dev_desc *dev)static void i3c_hci_free_ibi (struct i3c_dev_desc *dev) { +struct i3c_hci_dev_data *dev_data =i3c_dev_get_master_data (dev);struct i3c_master_controller *m =i3c_dev_get_master (dev);struct i3c_hci *hci =to_i3c_hci (m); -/* Must ensure the IBI has been disabled */ -__i3c_hci_disable_ibi (hci, dev); +/* Must ensure IBIs for this device will no longer be processed */ +scoped_guard (spinlock_irqsave, &hci->lock) + hci->ibi_devs[dev_data->dat_idx] = NULL; hci->io->free_ibi (hci, dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/2651 i3c: mipi-i3c-hci: Process multiple IBIs per interrupt
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 5fbd0790af9484c251341e3ba2ebbb2887c570c8 ]
INTR_IBI_READY indicates that one or more IBI Status Descriptors are present in the IBI ring. After clearing interrupt status, the interrupt handler processes only a single IBI even though additional IBIs may already be queued.
The controller does not reassert INTR_IBI_READY solely because entries remain in the ring after interrupt status has been cleared. Consequently, the remaining IBIs are not processed until some later interrupt occurs, and can accumulate if IBIs arrive more often than the interrupt handler runs.
Process all IBIs that are pending when the handler runs: capture the IBI enqueue pointer up front and continue until the dequeue pointer reaches that position.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 39 +++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +25 -14
@@ -868,25 +868,24 @@ static void hci_dma_recycle_ibi_slot(struct i3c_hci *hci,i3c_generic_ibi_recycle_slot (dev_ibi->pool, slot); } -static void hci_dma_process_ibi (struct i3c_hci *hci,struct hci_rh_data *rh) +static bool hci_dma_process_ibi (struct i3c_hci *hci,struct hci_rh_data *rh, +u32 *op1_val,unsigned int enq_ptr) {struct hci_rings_data *rings = hci->io_data;struct i3c_dev_desc *dev;struct i3c_hci_dev_data *dev_data;struct hci_dma_dev_ibi_data *dev_ibi;struct i3c_ibi_slot *slot; -u32 op1_val, op2_val, ibi_status_error; -unsigned int ptr, enq_ptr, deq_ptr; +u32 ibi_status_error; +unsigned int ptr, deq_ptr;unsigned int ibi_size, ibi_chunks, ibi_data_offset, first_part;int ibi_addr, last_ptr;void *ring_ibi_data;dma_addr_t ring_ibi_data_dma; - op1_val =rh_reg_read (RING_OPERATION1 ); - deq_ptr =FIELD_GET (RING_OP1_IBI_DEQ_PTR , op1_val); - - op2_val =rh_reg_read (RING_OPERATION2 ); - enq_ptr =FIELD_GET (RING_OP2_IBI_ENQ_PTR , op2_val); + deq_ptr =FIELD_GET (RING_OP1_IBI_DEQ_PTR , *op1_val); +if (deq_ptr == enq_ptr) +return false; ibi_status_error =0 ; ibi_addr =-1 ;
@@ -936,7 +935,7 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh)dev_dbg (&hci->master.dev,"no LAST_STATUS available (e=%d d=%d)" , enq_ptr, deq_ptr); -return ; +return false; } deq_ptr = last_ptr +1 ; deq_ptr %= rh->ibi_status_entries;
@@ -1015,10 +1014,9 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh)i3c_master_queue_ibi (dev, slot); done: - op1_val =rh_reg_read (RING_OPERATION1 ); - op1_val &= ~RING_OP1_IBI_DEQ_PTR ; - op1_val |=FIELD_PREP (RING_OP1_IBI_DEQ_PTR , deq_ptr); -rh_reg_write (RING_OPERATION1 , op1_val); + *op1_val &= ~RING_OP1_IBI_DEQ_PTR ; + *op1_val |=FIELD_PREP (RING_OP1_IBI_DEQ_PTR , deq_ptr); +rh_reg_write (RING_OPERATION1 , *op1_val);/* update the chunk pointer */ rh->ibi_chunk_ptr += ibi_chunks;
@@ -1026,6 +1024,19 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh)/* and tell the hardware about freed chunks */ rh_reg_write (CHUNK_CONTROL ,rh_reg_read (CHUNK_CONTROL ) + ibi_chunks); + +return true; +} + +static void hci_dma_drain_ibi_ring (struct i3c_hci *hci,struct hci_rh_data *rh) +{ +u32 op1_val =rh_reg_read (RING_OPERATION1 ); +u32 op2_val =rh_reg_read (RING_OPERATION2 ); +unsigned int enq_ptr =FIELD_GET (RING_OP2_IBI_ENQ_PTR , op2_val); + +/* Loop is bounded by enq_ptr. Further IBIs will re-assert INTR_IBI_READY */ +while (hci_dma_process_ibi (hci, rh, &op1_val, enq_ptr)) + ; }static bool hci_dma_irq_handler (struct i3c_hci *hci)
@@ -1047,7 +1058,7 @@ static bool hci_dma_irq_handler(struct i3c_hci *hci)rh_reg_write (INTR_STATUS , status);if (status &INTR_IBI_READY ) -hci_dma_process_ibi (hci, rh); +hci_dma_drain_ibi_ring (hci, rh);if (status & (INTR_TRANSFER_COMPLETION |INTR_TRANSFER_ERR ))hci_dma_xfer_done (hci, rh);if (status &INTR_RING_OP )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/2651 i3c: mipi-i3c-hci: Move DMA suspend/resume callbacks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit ae307311a69ed65c6219915d978ae322950ba906 ]
Relocate hci_dma_suspend() and hci_dma_resume() closer to the DMA IO operations table in preparation for upcoming changes.
No functional change.
Stable-dep-of: 9796ccba1254 ("i3c: mipi-i3c-hci: Stop rings gracefully when suspending")
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 46 +++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +23 -23
@@ -273,29 +273,6 @@ static void hci_dma_init_rings(struct i3c_hci *hci)hci_dma_init_rh (hci, &rings->headers[i], i); } -static void hci_dma_suspend (struct i3c_hci *hci) -{ -struct hci_rings_data *rings = hci->io_data; -int n = rings ? rings->total :0 ; - -for (int i =0 ; i < n; i++) { -struct hci_rh_data *rh = &rings->headers[i]; - -rh_reg_write (INTR_SIGNAL_ENABLE ,0 ); -rh_reg_write (RING_CONTROL ,0 ); - } - -i3c_hci_sync_irq_inactive (hci); -} - -static void hci_dma_resume (struct i3c_hci *hci) -{ -struct hci_rings_data *rings = hci->io_data; - -if (rings) -hci_dma_init_rings (hci); -} -static int hci_dma_init (struct i3c_hci *hci) {struct hci_rings_data *rings;
@@ -1075,6 +1052,29 @@ static bool hci_dma_irq_handler(struct i3c_hci *hci)return handled; } +static void hci_dma_suspend (struct i3c_hci *hci) +{ +struct hci_rings_data *rings = hci->io_data; +int n = rings ? rings->total :0 ; + +for (int i =0 ; i < n; i++) { +struct hci_rh_data *rh = &rings->headers[i]; + +rh_reg_write (INTR_SIGNAL_ENABLE ,0 ); +rh_reg_write (RING_CONTROL ,0 ); + } + +i3c_hci_sync_irq_inactive (hci); +} + +static void hci_dma_resume (struct i3c_hci *hci) +{ +struct hci_rings_data *rings = hci->io_data; + +if (rings) +hci_dma_init_rings (hci); +} +const struct hci_io_ops mipi_i3c_hci_dma = { .init = hci_dma_init, .cleanup = hci_dma_cleanup,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/2651 i3c: mipi-i3c-hci: Stop rings gracefully when suspending
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 9796ccba1254f6bd3b7e6b650ad28ffc56daf6e9 ]
hci_dma_suspend() tore the rings down with a single write of zero to RH_RING_CONTROL, clearing the RS and ENABLE fields together and without waiting for the ring to stop. I3C HCI v1.1 section 6.1.2 separates those
steps: clear RS for all running Ring Bundles, and only then clear ENABLE for all enabled Ring Bundles.
The ring registers were also written outside hci->lock, while the interrupt handler, which takes that lock, could still be running on another CPU. i3c_hci_sync_irq_inactive() was called only afterwards.
Finally, an IBI can still be sitting in the IBI Status Ring when suspend runs. Clearing HC_CONTROL.BUS_ENABLE is deferred: per the description of that field, if a disable request occurs while receiving an IBI, the actual disabling does not occur until reception of the IBI is complete.
Instead, clear RS under hci->lock, wait for RING_STATUS_RUNNING to clear, and make the interrupt handler inactive. Only then disable the ring interrupt signals, drain anything left in the IBI ring, and clear ENABLE.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 57 +++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +53 -4
@@ -15,6 +15,7 @@#include <linux/errno.h> #include <linux/i3c/master.h> #include <linux/io.h> +#include <linux/iopoll.h> #include "hci.h" #include "cmd.h"
@@ -1052,19 +1053,67 @@ static bool hci_dma_irq_handler(struct i3c_hci *hci)return handled; } +/* +* With the bus disabled, a ring should stop within a few microseconds. The +* timeout is therefore only expected to expire if the hardware is stuck. +* Allow sufficient margin for slow systems, but keep the delay acceptable +* during suspend. +*/ +#define RING_STOP_TIMEOUT_US (100 * USEC_PER_MSEC) +/* +* The ring is usually already stopped, so polling typically completes on the +* first iteration. Use a modest sleep interval to avoid busy-waiting without +* adding excessive latency. +*/ +#define RING_STOP_SLEEP_US 100 +static void hci_dma_suspend (struct i3c_hci *hci) {struct hci_rings_data *rings = hci->io_data;int n = rings ? rings->total :0 ; +struct hci_rh_data *rh; +u32 regval; -for (int i =0 ; i < n; i++) { -struct hci_rh_data *rh = &rings->headers[i]; +/* Gracefully stop the rings */ + scoped_guard(spinlock_irqsave, &hci->lock) { +for (int i =0 ; i < n; i++) { + rh = &rings->headers[i]; + regval =rh_reg_read (RING_CONTROL ); +if (regval &RING_CTRL_RUN_STOP ) +rh_reg_write (RING_CONTROL , regval & ~RING_CTRL_RUN_STOP ); + } + } -rh_reg_write (INTR_SIGNAL_ENABLE ,0 ); -rh_reg_write (RING_CONTROL ,0 ); +/* Wait for actual stop */ +for (int i =0 ; i < n; i++) { + rh = &rings->headers[i]; +if (readx_poll_timeout (readl, rh->regs +RH_RING_STATUS , regval, + !(regval &RING_STATUS_RUNNING ), +RING_STOP_SLEEP_US ,RING_STOP_TIMEOUT_US )) +dev_err (&hci->master.dev,"%s: Ring did not stop, status %#x\n" , + __func__, regval); } +/* +* With the rings stopped, no more IBIs can be received. Flush and make +* the interrupt handler inactive. +*/ i3c_hci_sync_irq_inactive (hci); + +/* Disable interrupt signals and disable the rings */ + scoped_guard(spinlock_irqsave, &hci->lock) +for (int i =0 ; i < n; i++) { + rh = &rings->headers[i]; +rh_reg_write (INTR_SIGNAL_ENABLE ,0 ); +/* +* Be absolutely certain there is no unprocessed IBI. +* hci_dma_drain_ibi_ring() will do nothing if there is +* none. +*/ +if (i <IBI_RINGS ) +hci_dma_drain_ibi_ring (hci, rh); +rh_reg_write (RING_CONTROL ,0 ); + } }static void hci_dma_resume (struct i3c_hci *hci)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/2651 i3c: Restrict HDR modes to those supported by the bus and target
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit b968be9e719302c6d74beb16224e9d956d26433d ]
I3C v1.1.1 Table 9 defines which HDR Modes are permitted for each Bus Configuration. A Mixed Slow / Limited Bus permits no HDR Modes because Legacy I2C Devices without a 50 ns SCL spike filter cannot be shielded from HDR traffic. A Mixed Fast Bus permits HDR-DDR and HDR-TSL, but not HDR-TSP, since of the two Ternary Modes only HDR-TSL is defined for a Bus that also has Legacy I2C Devices.
However, both i3c_device_get_supported_xfer_mode() and the transfer validation in i3c_dev_do_xfers_locked() currently consider only the controller's hdr_cap. Since hdr_cap reflects controller capability rather than bus or target constraints, HDR Modes can be advertised and used even when the bus configuration forbids them. Likewise, HDR Modes unsupported by the target may be reported as available.
Add i3c_dev_supported_xfer_modes_locked(), which derives the usable transfer modes from the intersection of:
- HDR Modes supported by the controller
- HDR Modes allowed by the bus configuration
- HDR Modes supported by the target
Use this helper both when reporting supported transfer modes and when validating transfers, ensuring that the advertised and permitted modes remain consistent.
GETHDRCAP is queried only when I3C_BCR_HDR_CAP is set, so a target without that bit is treated as supporting no HDR Modes.
i3c_device_get_supported_xfer_mode() now takes the normal-use bus lock in order to access the device descriptor, matching i3c_device_get_info().
Also fix the kernel-doc reference to enum i3c_xfer_mode.
--- drivers/i3c/device.c | 15 ++++++++--- drivers/i3c/internals.h | 2 ++ drivers/i3c/master.c | 57 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 5 deletions(-)
drivers/i3c/device.c +11 -4
@@ -301,16 +301,23 @@ i3c_device_match_id(struct i3c_device *i3cdev,EXPORT_SYMBOL_GPL (i3c_device_match_id);/** -* i3c_device_get_supported_xfer_mode - Returns the supported transfer mode by -* connected master controller. +* i3c_device_get_supported_xfer_mode - Returns the transfer modes supported by +* the connected master controller and @dev, +* and allowed by the bus configuration. * @dev: I3C device * * Return: a bit mask, which supported transfer mode, bit position is defined at -* enum i3c_hdr_mode +* enum i3c_xfer_mode */ u32 i3c_device_get_supported_xfer_mode (struct i3c_device *dev) { -return i3c_bus_to_i3c_master (dev->bus)->this->info.hdr_cap |BIT (I3C_SDR ); +u32 modes; + +i3c_bus_normaluse_lock (dev->bus); + modes =i3c_dev_supported_xfer_modes_locked (dev->desc); +i3c_bus_normaluse_unlock (dev->bus); + +return modes; }EXPORT_SYMBOL_GPL (i3c_device_get_supported_xfer_mode);
drivers/i3c/internals.h +2 -0
@@ -18,6 +18,8 @@ bool i3c_bus_rpm_ibi_allowed(struct i3c_bus *bus);void i3c_bus_normaluse_lock (struct i3c_bus *bus);void i3c_bus_normaluse_unlock (struct i3c_bus *bus); +u32 i3c_dev_supported_xfer_modes_locked (struct i3c_dev_desc *dev); +int i3c_dev_setdasa_locked (struct i3c_dev_desc *dev); int i3c_dev_do_xfers_locked(struct i3c_dev_desc *dev, struct i3c_xfer *xfers,
drivers/i3c/master.c +56 -1
69 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/2651 pstore: dont leave an ERR_PTR in the ramoops zone pointer
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit 70fec428c845216da98041b1ae9f16a8f54b3d68 ]
ramoops_init_prz() stores the result of persistent_ram_new() in *prz and returns the error without clearing it when initialization fails. ramoops_probe() then cleans up through ramoops_free_przs(), which hands *prz to persistent_ram_free(); that treats the ERR_PTR as a valid zone and dereferences it, crashing the kernel.
Clear *prz before returning so that cleanup sees a NULL zone.
--- fs/pstore/ram.c | 1 + 1 file changed, 1 insertion(+)
fs/pstore/ram.c +1 -0
@@ -604,6 +604,7 @@ static int ramoops_init_prz(const char *name,if (IS_ERR (*prz)) {int err =PTR_ERR (*prz); + *prz =NULL ;dev_err (dev,"failed to request %s mem region (0x%zx@0x%llx): %d\n" , name, sz, (unsigned long long )*paddr, err);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/2651 pstore: reject persistent RAM zones too small for the buffer header
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit 1b30df8662ac85a6759be4332f3bec7e3cb28efc ]
persistent_ram_buffer_map() computes
prz->buffer_size = size - sizeof(struct persistent_ram_buffer);
without checking that size is large enough to hold the header. A ramoops zone configured with a tiny size (e.g. ramoops.pmsg_size=1) underflows buffer_size to a huge value, which defeats every bounds check in persistent_ram_write() and persistent_ram_write_user(); a write to /dev/pmsg0 then copies user data far past the end of the zone and corrupts kernel memory.
Reject zones that are not larger than the buffer header.
--- fs/pstore/ram_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/pstore/ram_core.c +6 -0
@@ -505,6 +505,12 @@ static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size, prz->paddr = start; prz->size = size; +if (size <=sizeof (struct persistent_ram_buffer )) { +pr_err ("%s: persistent ram zone too small (%#llx bytes)\n" , + prz->label, (unsigned long long )size); +return -EINVAL ; + } +if (pfn_valid (start >>PAGE_SHIFT )) prz->vaddr =persistent_ram_vmap (start, size, memtype);else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/2651 sfc: fix CONFIG_CXL_MEM dependency
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit c6219deaee41bf35f7f04073f9ef99609d58bba4 ]
A recent patch introduced a call to devm_cxl_probe_mem(), which is only available when CXL_MEM is enabled. If CXL_MEM is in a loadable module, this causes a link failure for a builtin driver:
s390-linux-ld: drivers/net/ethernet/sfc/efx_cxl.o: in function `efx_cxl_init':
efx_cxl.c:(.text+0x156): undefined reference to `devm_cxl_probe_mem'
Adapt the dependency to require CXL_MEM instead of CXL_BUS, which we know is available when CXL_MEM is.
--- drivers/net/ethernet/sfc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sfc/Kconfig +1 -1
@@ -68,7 +68,7 @@ config SFC_MCDI_LOGGING a sysfs file 'mcdi_logging' under the PCI device. config SFC_CXL bool "Solarflare SFC9100-family CXL support" - depends on SFC && CXL_BUS >= SFC + depends on SFC && CXL_MEM >= SFC default SFC help This enables SFC CXL support if the kernel is configuring CXL for
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/2651 md: fix mddev_unlock() called without holding lock in lbs_store()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Wang <[email protected]>
[ Upstream commit 68dab5c14aaff17686df22ba1f1eea3b3433797a ]
lbs_store() jumped to the unlock label on mddev_lock() failure, calling mddev_unlock() on a mutex that was never acquired. Return directly instead.
--- drivers/md/md.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/md.c +1 -2
@@ -6051,11 +6051,10 @@ lbs_store(struct mddev *mddev, const char *buf, size_t len) err =mddev_lock (mddev);if (err) - goto unlock; +return err; err =mddev_set_logical_block_size (mddev, lbs); -unlock:mddev_unlock (mddev);return err ?: len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/2651 KMSAN: fix memset() when using fortify-source, again
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 3555409e524a0279845f91273ba714998658c163 ]
Both kmsan and fortify-source replace the memset function. When both are enabled at the same time, the kmsan version gets used, which triggers a warning about fortify-source being nonfunctional:
warning: unsafe memset() usage lacked '__write_overflow' symbol in /home/arnd/arm-soc/lib/test_fortify/write_overflow-memset.c
warning: unsafe memset() usage lacked '__write_overflow_field' symbol in /home/arnd/arm-soc/lib/test_fortify/write_overflow_field-memset.c
Commit 78a498c3a227 already tried to address this, but this seems to only have worked for memcpy() and memmove() but not memset(), which is still lacking the macro definition when KMSAN is enabled.
Remove the incorrect #ifndef check around the memset() macro.
--- include/linux/fortify-string.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/fortify-string.h +0 -2
@@ -458,10 +458,8 @@ __FORTIFY_INLINE bool fortify_memset_chk(__kernel_size_t size,* __struct_size() vs __member_size() must be captured here to avoid * evaluating argument side-effects further into the macro layers. */ -#ifndef CONFIG_KMSAN #define memset (p, c, s) __fortify_memset_chk(p, c, s, \ __struct_size(p), __member_size(p)) -#endif /* * To make sure the compiler can enforce protection against buffer overflows,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 632/2651 randstruct: fix container_of() false positives after __mptr removal
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 67beeb5621051eda74ca2171ea576c9602bb6cce ]
Commit f9e7a7564834 ("container_of: remove local __mptr variable") dropped the "void *__mptr" temporary from container_of(). The randstruct GCC plugin's find_bad_casts pass recognized the casts container_of() generates by that variable's name:
const_tree ssa_name_var = SSA_NAME_VAR(rhs1); /* skip bogus type casts introduced by container_of */ if (ssa_name_var != NULL_TREE && DECL_NAME(ssa_name_var) && !strcmp(DECL_NAME_POINTER(ssa_name_var), "__mptr")) continue;
With the variable gone the suppression never fires, so every container_of() whose container type is randomized now emits a note:
include/linux/container_of.h:23:9: note: randstruct: casting between
randomized structure pointer types (ssa): 'struct ocfs2_triggers' and 'struct jbd2_buffer_trigger_type'
fs/ocfs2/journal.c:524:16: note: in expansion of macro 'container_of'
The pass runs on GIMPLE, after folding, and for a member at offset 0 the whole expression collapses to a bare copy that is indistinguishable from an unsafe cast:
to_ocfs2_trigger (struct jbd2_buffer_trigger_type * triggers)
{
_2 = triggers_1(D); /* void * cast and subtraction gone */
return _2;
}Match the type relationship instead. A cast from A * to B * is a container_of() if B reaches a field of type A at offset 0 through a chain of by-value members. The chain matters: container_of()'s member argument may be a dotted path, as in ceph_inode(), which is container_of(inode, struct ceph_inode_info, netfs.inode) and needs two levels. The search is depth-bounded to 4 just in case, since real paths are generally one or two members deep.
Requiring the cast happens at offset 0 is done because any other member offset the subtraction survives folding and the cast's rhs is still void *, which the pass already skips a few lines above.
A cast between two randomized types with no containment relationship is still reported. Verified with:
struct cred *f(struct file *f) { return (struct cred *)f; }which is still flagged with the patch applied.
Clang's implementation is unaffected. It checks the cast as written, and both the old and new macros cast from void *, which is always permitted; a genuinely bad cast is rejected there as a hard error rather than a note.
Build tested ARCH=x86_64 defconfig with CONFIG_RANDSTRUCT_FULL=y and GCC 14.2.0: randstruct notes 52 before, 0 after.
--- scripts/gcc-plugins/randomize_layout_plugin.c | 61 ++++++++++++++++++- 1 file changed, 58 insertions(+), 3 deletions(-)
scripts/gcc-plugins/randomize_layout_plugin.c +58 -3
@@ -698,6 +698,63 @@ static void handle_local_var_initializers(void) } } +/* +* Does @container reach a field of type @member_type by a chain of +* by-value members? That is the relationship container_of() expresses -- +* its @member argument may be a dotted path, e.g. +* container_of(inode, struct ceph_inode_info, netfs.inode) -- so a cast +* from @member_type * to @container * is legitimate rather than a +* layout-confusing one. +* +* container_of() used to leave a "void *__mptr" temporary behind, and this +* pass recognised such casts by that name. Commit f9e7a7564834 +* ("container_of: remove local __mptr variable") removed it to stop nested +* container_of() shadowing itself, and the cast now folds to a bare SSA +* copy when the member sits at offset 0, leaving nothing syntactic to key +* on. Match the type relationship instead. +* +* The depth bound keeps this cheap; container_of() paths are one or two +* members deep in practice. +*/ +#define CONTAINER_OF_MAX_DEPTH 4 + +static bool is_container_of_cast (const_tree container,const_tree member_type, +int depth) +{ +const_tree field; + +if (container ==NULL_TREE || depth >CONTAINER_OF_MAX_DEPTH ) +return false; + +if (TREE_CODE (container) !=RECORD_TYPE && +TREE_CODE (container) !=UNION_TYPE ) +return false; + +for (field =TYPE_FIELDS (container); field; field =DECL_CHAIN (field)) { +const_tree field_type; + +if (TREE_CODE (field) !=FIELD_DECL ) +continue ; + +/* +* Only a member at offset 0 can reach here: for any other +* offset container_of()'s subtraction survives folding, the +* cast's rhs stays void *, and the caller skipped it above. +*/ +if (!integer_zerop (byte_position (field))) +continue ; + + field_type =TYPE_MAIN_VARIANT (TREE_TYPE (field)); +if (field_type == member_type) +return true; + +if (is_container_of_cast (field_type, member_type, depth +1 )) +return true; + } + +return false; +} +/* * iterate over all statements to find "bad" casts: * those where the address of the start of a structure is cast
@@ -799,10 +856,8 @@ static unsigned int find_bad_casts_execute(void)#endif MISMATCH (gimple_location (stmt),"op0" , ptr_lhs_type, op0_type); }else { -const_tree ssa_name_var =SSA_NAME_VAR (rhs1);/* skip bogus type casts introduced by container_of */ -if (ssa_name_var !=NULL_TREE &&DECL_NAME (ssa_name_var) && - !strcmp ((const char *)DECL_NAME_POINTER (ssa_name_var),"__mptr" )) +if (is_container_of_cast (ptr_lhs_type, ptr_rhs_type,0 ))continue ;#ifndef __DEBUG_PLUGINif (lookup_attribute ("randomize_performed" ,TYPE_ATTRIBUTES (ptr_rhs_type)))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/2651 md/raid5: give the io_unit slab caches per-array names
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 96858e2308431ff5678e0e6fab1a06e19f3d95da ]
Both raid5 log backends create their io_unit slab cache per array but name it after the struct:
ppl_conf->io_kc = KMEM_CACHE(ppl_io_unit, 0); log->io_kc = KMEM_CACHE(r5l_io_unit, 0);
KMEM_CACHE() passes the stringified type as the cache name, so every array that enables PPL or attaches a journal asks for a cache called "ppl_io_unit" or "r5l_io_unit". With two such arrays live at the same time the second one trips kmem_cache_sanity_check():
kmem_cache of name 'ppl_io_unit' already exists
WARNING: mm/slab_common.c:112 at __kmem_cache_create_args+0xae/0x460 ppl_init_log+0x285/0x1310 drivers/md/raid5-ppl.c:1363 log_init drivers/md/raid5-log.h:138 [inline] raid5_change_consistency_policy+0x255/0x740 drivers/md/raid5.c:9141 consistency_policy_store+0x7f/0x230 drivers/md/md.c:5883 md_attr_store+0x3b7/0x640 drivers/md/md.c:6158
which is reachable by any user that can write "ppl" to md/consistency_policy on two arrays, and equally by assembling two journalled arrays. The cache is created and destroyed correctly on every path, so this is a name collision only - duplicate names confuse slabtop and /proc/slabinfo, which is what the check is there to catch.
Build the name from the array instead, the way grow_stripes() already does for the stripe_head cache in this driver, and fall back to the mddev pointer for dm-raid where mdname() is the constant "mdX". The buffer is sized like conf->cache_name[] because mdname() can return up to DISK_NAME_LEN bytes.
The explicit size/align arguments keep what KMEM_CACHE() expanded to, so object layout does not change.
--- drivers/md/raid5-cache.c | 12 +++++++++++- drivers/md/raid5-ppl.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/md/raid5-cache.c +11 -1
@@ -3084,6 +3084,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) {struct r5l_log *log;struct md_thread *thread; +char cache_name[48 ];int ret; pr_debug("md/raid:%s: using device %pg as journal\n",
@@ -3123,7 +3124,16 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)INIT_LIST_HEAD (&log->flushing_ios);INIT_LIST_HEAD (&log->finished_ios); - log->io_kc =KMEM_CACHE (r5l_io_unit,0 ); +if (mddev_is_dm (conf->mddev)) +snprintf (cache_name,sizeof (cache_name),"r5l_io_unit-%p" , + conf->mddev); +else +snprintf (cache_name,sizeof (cache_name),"r5l_io_unit-%s" , +mdname (conf->mddev)); + + log->io_kc =kmem_cache_create (cache_name,sizeof (struct r5l_io_unit ), + __alignof__(struct r5l_io_unit ), +0 ,NULL );if (!log->io_kc) goto io_kc;
drivers/md/raid5-ppl.c +11 -1
@@ -1318,6 +1318,7 @@ int ppl_init_log(struct r5conf *conf) {struct ppl_conf *ppl_conf;struct mddev *mddev = conf->mddev; +char cache_name[48 ];int ret =0 ;int max_disks;int i;
@@ -1360,7 +1361,16 @@ int ppl_init_log(struct r5conf *conf) ppl_conf->mddev = mddev; - ppl_conf->io_kc =KMEM_CACHE (ppl_io_unit,0 ); +if (mddev_is_dm (mddev)) +snprintf (cache_name,sizeof (cache_name),"ppl_io_unit-%p" , mddev); +else +snprintf (cache_name,sizeof (cache_name),"ppl_io_unit-%s" , +mdname (mddev)); + + ppl_conf->io_kc =kmem_cache_create (cache_name, +sizeof (struct ppl_io_unit ), + __alignof__(struct ppl_io_unit ), +0 ,NULL );if (!ppl_conf->io_kc) { ret = -ENOMEM ; goto err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/2651 mm/gup: honour FOLL_PIN in NOMMU __get_user_pages_locked()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit da01399b90a73cd00b502f7903fa5acbfac4a103 ]
The !CONFIG_MMU implementation of __get_user_pages_locked() takes a bare get_page() reference for each page regardless of foll_flags:
if (pages[i]) get_page(pages[i]);
This is reached from pin_user_pages*() with FOLL_PIN set. unpin_user_page() is shared between MMU and NOMMU configurations and unconditionally calls gup_put_folio(..., FOLL_PIN), which subtracts GUP_PIN_COUNTING_BIAS (1024) from the folio refcount.
This means that pin adds 1, and then unpin will subtract 1024.
If a user maps a page (refcount 1), registers it 1023 times as an io_uring fixed buffer (1023 pin_user_pages calls -> refcount 1024), then
unregisters: the first unpin_user_page subtracts 1024, refcount hits 0, the page is freed and returned to the buddy allocator. The remaining 1022 unpins write into whatever was reallocated, and the user's VMA still maps the freed page (NOMMU has no MMU to invalidate it). Reallocating the page for an io_uring pbuf_ring then lets userspace corrupt the new owner's data through the stale mapping.
Use try_grab_folio() which adds GUP_PIN_COUNTING_BIAS for FOLL_PIN and 1 for FOLL_GET, mirroring the CONFIG_MMU path so pin and unpin are symmetric. Keep supporting the traditional behavior where users specify a pages array but don't set FOLL_GET.
While at it, don't return NULL pointers in the page array,
as this is really not expected for GUP users; instead, just fail and return -EFAULT.
[ david: support traditional behavior with no FOLL_GET, extend
description ]
--- mm/gup.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
mm/gup.c +14 -3
@@ -1987,6 +1987,7 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start,struct vm_area_struct *vma;bool must_unlock = false;vm_flags_t vm_flags; +int ret, err = -EFAULT ;long i;if (!nr_pages)
@@ -2003,6 +2004,10 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start, *locked =1 ; } +/* See the MMU variant: support the traditional behavior. */ +if (pages && !(foll_flags &FOLL_PIN )) + foll_flags |=FOLL_GET ; +/* calculate required read or write permissions. * If FOLL_FORCE is set, we only require the "MAY" flags. */
@@ -2023,8 +2028,14 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start,if (pages) { pages[i] =virt_to_page ((void *)start); -if (pages[i]) -get_page (pages[i]); +if (!pages[i]) +break ; + ret =try_grab_folio (page_folio (pages[i]),1 , foll_flags); +if (unlikely (ret)) { + pages[i] =NULL ; + err = ret; +break ; + } } start = (start +PAGE_SIZE ) &PAGE_MASK ;
@@ -2035,7 +2046,7 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start, *locked = 0; } -return i ? : -EFAULT ; +return i ? : err; }#endif /* !CONFIG_MMU */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/2651 leds: lp8860: Fix device_node leak in lp8860_probe()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miles Krause <[email protected]>
[ Upstream commit f9879086c4eb4b3b0f4baa80139a5720b99b229e ]
lp8860_probe() looks up the driver's single LED child node with of_get_next_available_child() and hands it to the LED core as init_data.fwnode, but never drops the reference that lookup returned:
child_node = of_get_next_available_child(np, NULL); if (!child_node) return -EINVAL; ... init_data.fwnode = of_fwnode_handle(child_node);
of_get_next_available_child() returns the node with its refcount incremented, and the LED core does not take a reference of its own:led_classdev_register_ext() only reads properties out of init_data.fwnode and then stores the bare pointer with device_set_node(). The reference therefore stays owned by the driver for as long as it holds the node.
Nothing in lp8860_probe() ever releases it, so it is leaked on every error return taken after the lookup - the enable GPIO, the vled regulator, devm_mutex_init(), the regmap allocation, the optional EEPROM programming and the LED class registration - and on a fully successful probe alike. A device that binds and unbinds repeatedly leaks one device_node reference per bind.
Sibling drivers already get this right: leds-lm3692x.c, from the same TI LED family, calls fwnode_handle_put(init_data.fwnode) once after devm_led_classdev_register_ext() to cover both outcomes, while leds-ktd2692.c and leds-aat1290.c take the node with __free(device_node).
Use __free(device_node) here too. Unlike a single of_node_put() at the end of probe it also covers the intermediate error returns, and it keeps the node alive for the whole function, which the LED core still needs when it reads the child's properties during registration.
--- drivers/leds/leds-lp8860.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/leds/leds-lp8860.c +3 -2
@@ -7,6 +7,7 @@* Author: Dan Murphy <[email protected]> */ +#include <linux/cleanup.h> #include <linux/i2c.h> #include <linux/init.h> #include <linux/leds.h>
@@ -274,7 +275,6 @@ static int lp8860_probe(struct i2c_client *client)int ret;struct lp8860_led *led;struct device_node *np =dev_of_node (&client->dev); -struct device_node *child_node;struct led_init_data init_data = {};struct gpio_desc *enable_gpio;
@@ -282,7 +282,8 @@ static int lp8860_probe(struct i2c_client *client)if (!led)return -ENOMEM ; - child_node =of_get_next_available_child (np,NULL ); + struct device_node *child_node __free(device_node) = +of_get_next_available_child (np,NULL );if (!child_node)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/2651 selftests/coredump: discard the right amount after the coredump request
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 73337f1ac1379e31cc37868e5a61e4202f095a88 ]
read_coredump_req() gets the leftover wrong twice.
It takes the absolute difference of the two sizes, so a test binary that knows a larger struct coredump_req than the kernel sends tries to discard bytes that were never sent. And it hands recv() sizeof(buffer) instead of the number of bytes it wants. So MSG_WAITALL waits for a whole page. Either one blocks until the kernel closes the socket. Which it won't because it is waiting for the coredump ack...
It's benign today because struct coredump_req hasn't grown. But let's fix it for the future. Compute the leftover as what the kernel sent beyond what was consumed.
--- tools/testing/selftests/coredump/coredump_test_helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/coredump/coredump_test_helpers.c +4 -4
@@ -235,10 +235,10 @@ bool read_coredump_req(int fd, struct coredump_req *req)fprintf (stderr,"Read coredump request with size %u and mask 0x%llx\n" , req->size, (unsigned long long )req->mask); -if (user_size > kernel_size) - remaining_size = user_size - kernel_size; -else +if (kernel_size > user_size) remaining_size = kernel_size - user_size; +else + remaining_size =0 ;if (PAGE_SIZE <= remaining_size)return false;
@@ -250,7 +250,7 @@ bool read_coredump_req(int fd, struct coredump_req *req)if (remaining_size) {char buffer[PAGE_SIZE ]; - ret =recv (fd, buffer,sizeof (buffer),MSG_WAITALL ); + ret =recv (fd, buffer, remaining_size,MSG_WAITALL );if (ret != remaining_size)return false;fprintf (stderr,"Discarded %zu bytes of data after coredump request\n" , remaining_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/2651 leds: pca9532: Check i2c_smbus_read_byte_data() return value
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haibo Chen <[email protected]>
[ Upstream commit 1b75f038e5f71ed32ce6593b5763f9776ec58a25 ]
Coverity report INTEGER_OVERFLOW (tainted_data_return -> cast_underflow -> overflow) in pca9532_getled(). pca9532_getled() stored the return value of i2c_smbus_read_byte_data() into a char and used it directly to compute the LED state without checking for an error. i2c_smbus_read_byte_data() returns a negative error code on failure. On an I2C read error the negative value was assigned to an unsigned type, triggering an integer underflow/overflow, and a meaningless LED state was returned to the caller.
Read the value into an int, check for the error, and fall back to PCA9532_OFF while emitting a warning when the read fails.
--- drivers/leds/leds-pca9532.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/leds/leds-pca9532.c +6 -3
@@ -298,12 +298,15 @@ static enum pca9532_state pca9532_getled(struct pca9532_led *led)struct i2c_client *client = led->client;struct pca9532_data *data =i2c_get_clientdata (client);u8 maxleds = data->chip_info->num_leds; -char reg; -enum pca9532_state ret; +int reg; +enum pca9532_state ret =PCA9532_OFF ;mutex_lock (&data->update_lock); reg =i2c_smbus_read_byte_data (client,LED_REG (maxleds, led->id)); - ret = (reg &LED_MASK (led->id)) >>LED_SHIFT (led->id); +if (reg >=0 ) + ret = (reg &LED_MASK (led->id)) >>LED_SHIFT (led->id); +else +dev_warn (&client->dev,"failed to read LED register: %d\n" , reg);mutex_unlock (&data->update_lock);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/2651 perf synthetic-events: Fix schedstat event lifetime handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Su <[email protected]>
[ Upstream commit cf3d239189da0bd5122ae38c62f5fefdb744eb86 ]
perf_event__synthesize_schedstat() has two event lifetime issues.
After a successful iteration, event is freed but retains its value. If the next iteration starts with an unrecognized schedstat record type, neither synthesizer assigns a new value. The stale pointer then passes the NULL check, may be passed to process(), and is freed again.
In addition, when user_requested_cpus filters out a synthesized event, the continue path skips free(event), leaking the event.
Make event local to each loop iteration so it always starts as NULL. Also avoid the filter continue and unconditionally free each synthesized event at the end of the iteration.
--- tools/perf/util/synthetic-events.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/util/synthetic-events.c +7 -7
@@ -2817,7 +2817,6 @@ int perf_event__synthesize_schedstat(const struct perf_tool *tool, struct perf_cpu_map *user_requested_cpus) {char *line =NULL , path[PATH_MAX ]; -union perf_event *event =NULL ;size_t line_len =0 ;char bf[BUFSIZ ];__u64 timestamp;
@@ -2858,6 +2857,7 @@ int perf_event__synthesize_schedstat(const struct perf_tool *tool,* for filtered out cpus. */ for (ch =io__get_char (&io); !io.eof; ch =io__get_char (&io)) { +union perf_event *event =NULL ;struct perf_cpu this_cpu;if (ch =='c' ) {
@@ -2872,12 +2872,12 @@ int perf_event__synthesize_schedstat(const struct perf_tool *tool, this_cpu.cpu = cpu; -if (user_requested_cpus && !perf_cpu_map__has (user_requested_cpus, this_cpu)) -continue ; - -if (process (tool, event,NULL ,NULL ) <0 ) { -free (event); - goto out_free_line; +if (!user_requested_cpus || +perf_cpu_map__has (user_requested_cpus, this_cpu)) { +if (process (tool, event,NULL ,NULL ) <0 ) { +free (event); + goto out_free_line; + } }free (event);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/2651 perf test: Fix a leaked map reference in the arch dwarf unwind tests
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Pei <[email protected]>
[ Upstream commit 1622c9ae39e2882fcbbae7c9d27dda13f1880b93 ]
maps__find() has returned a reference to the map it finds since commit 42fd623b58db ("perf maps: Get map before returning in maps__find"), which updated arch/x86/tests/dwarf-unwind.c but missed the arm, arm64 and powerpc copies. Release the map after reading its end, as x86 does. All other callers of maps__find() already release what they get.
--- tools/perf/arch/arm/tests/dwarf-unwind.c | 1 + tools/perf/arch/arm64/tests/dwarf-unwind.c | 1 + tools/perf/arch/powerpc/tests/dwarf-unwind.c | 1 + 3 files changed, 3 insertions(+)
tools/perf/arch/arm/tests/dwarf-unwind.c +1 -0
@@ -34,6 +34,7 @@ static int sample_ustack(struct perf_sample *sample, } stack_size =map__end (map) - sp; +map__put (map); stack_size = stack_size >STACK_SIZE ?STACK_SIZE : stack_size;memcpy (buf, (void *) sp, stack_size);
tools/perf/arch/arm64/tests/dwarf-unwind.c +1 -0
@@ -34,6 +34,7 @@ static int sample_ustack(struct perf_sample *sample, } stack_size =map__end (map) - sp; +map__put (map); stack_size = stack_size >STACK_SIZE ?STACK_SIZE : stack_size;memcpy (buf, (void *) sp, stack_size);
tools/perf/arch/powerpc/tests/dwarf-unwind.c +1 -0
@@ -34,6 +34,7 @@ static int sample_ustack(struct perf_sample *sample, } stack_size =map__end (map) - sp; +map__put (map); stack_size = stack_size >STACK_SIZE ?STACK_SIZE : stack_size;memcpy (buf, (void *) sp, stack_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/2651 perf libbfd: Fix the clang -Wthread-safety build failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit c4c43343501bd9fc24ec501ecaf43b7ef2da44d2 ]
perf_bfd_lock() and perf_bfd_unlock() are the callbacks given to bfd_thread_init(), so by design they acquire and release the lock on libbfd's behalf and the lock state differs between entry and exit. clang's thread safety analysis, which perf builds with as an error, flags both:
util/libbfd.c:56:1: error: mutex 'bfd_mutex' is still held at the end of function [-Werror,-Wthread-safety-analysis] util/libbfd.c:60:2: error: releasing mutex 'bfd_mutex' that was not held [-Werror,-Wthread-safety-analysis]
Mark both functions NO_THREAD_SAFETY_ANALYSIS so that libbfd.c compiles with "make CC=clang BUILD_NONDISTRO=1".
--- tools/perf/util/libbfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/libbfd.c +2 -2
@@ -39,13 +39,13 @@ struct a2l_data {asymbol **syms; }; -static bool perf_bfd_lock (void *bfd_mutex) +static bool perf_bfd_lock (void *bfd_mutex)NO_THREAD_SAFETY_ANALYSIS {mutex_lock (bfd_mutex);return true; } -static bool perf_bfd_unlock (void *bfd_mutex) +static bool perf_bfd_unlock (void *bfd_mutex)NO_THREAD_SAFETY_ANALYSIS {mutex_unlock (bfd_mutex);return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/2651 perf symbol: Fix the build when demangling with libbfd
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit ecbc5aac7d9218320f2c734d75798f34c15a9d85 ]
cxx_demangle_sym() calls bfd_demangle() with the DMGL_PARAMS and DMGL_ANSI flags, but nothing declares them. The
"#define PACKAGE 'perf'", "#include <bfd.h>" and the DMGL_ definitions were left behind in symbol-elf.c when the demangling code moved to symbol.c, and libiberty's demangle.h that defines the flags isn't installed by every binutils package. The cplus_demangle() variant is missing a declaration for the same reason.
The code is only built when the C++ ABI's __cxa_demangle() is unavailable, so most builds never compile it:
$ make BUILD_NONDISTRO=1 NO_DEMANGLE=1 util/symbol.c:2714: error: 'DMGL_PARAMS' undeclared util/symbol.c:2714: error: 'DMGL_ANSI' undeclared util/symbol.c:2716: error: implicit declaration of 'bfd_demangle'
Move the libbfd demangling into libbfd.c, which already includes bfd.h, and declare in symbol.c the libiberty interfaces the cplus_demangle() variant needs.
--- tools/perf/util/libbfd.c | 17 +++++++++++++++++ tools/perf/util/libbfd.h | 9 +++++++++ tools/perf/util/symbol.c | 18 +++++++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-)
tools/perf/util/libbfd.c +17 -0
@@ -72,6 +72,23 @@ static void ensure_bfd_init(void)pthread_once (&bfd_init_once, perf_bfd_init); } +/* +* Flags from libiberty's demangle.h. bfd.h declares bfd_demangle but not the +* flags to pass to it, and demangle.h isn't installed by every binutils +* package. +*/ +#ifndef DMGL_PARAMS +#define DMGL_PARAMS (1 << 0)/* Include function arguments. */ +#define DMGL_ANSI (1 << 1)/* Include const, volatile, etc. */ +#endif + +char *libbfd__demangle_sym (const char *str,bool params,bool modifiers) +{ +int flags = (params ?DMGL_PARAMS :0 ) | (modifiers ?DMGL_ANSI :0 ); + +return bfd_demangle (/*abfd=*/ NULL , str, flags); +} +static int bfd_error (const char *string) {const char *errmsg;
tools/perf/util/libbfd.h +9 -0
@@ -31,6 +31,8 @@ int libbfd_filename__read_debuglink(const char *filename, char *debuglink, size_int symbol__disassemble_bpf_libbfd (struct symbol *sym,struct annotate_args *args); +char *libbfd__demangle_sym (const char *str,bool params,bool modifiers); +#else // !defined(HAVE_LIBBFD_SUPPORT) #include "annotate.h"
@@ -77,6 +79,13 @@ static inline int symbol__disassemble_bpf_libbfd(struct symbol *sym __always_unureturn SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF ; } +static inline char *libbfd__demangle_sym (const char *str__always_unused , +bool params__always_unused , +bool modifiers__always_unused ) +{ +return NULL ; +} +#endif // defined(HAVE_LIBBFD_SUPPORT) #endif /* __PERF_LIBBFD_H */
tools/perf/util/symbol.c +15 -3
@@ -27,6 +27,7 @@#include "dso.h" #include "util.h" // lsdir() #include "event.h" +#include "libbfd.h" #include "machine.h" #include "map.h" #include "symbol.h"
@@ -2707,13 +2708,24 @@ static bool want_demangle(bool is_kernel_sym)* version. */ #ifndef HAVE_CXA_DEMANGLE_SUPPORT +#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT +/* +* Declarations from libiberty's demangle.h, the header isn't installed by +* every binutils package. +*/ +#ifndef DMGL_PARAMS +#define DMGL_PARAMS (1 << 0)/* Include function arguments. */ +#define DMGL_ANSI (1 << 1)/* Include const, volatile, etc. */ +#endif + +char *cplus_demangle (const char *mangled,int options); +#endif +char *cxx_demangle_sym (const char *str__maybe_unused ,bool params__maybe_unused ,bool modifiers__maybe_unused ) {#ifdef HAVE_LIBBFD_SUPPORT -int flags = (params ?DMGL_PARAMS :0 ) | (modifiers ?DMGL_ANSI :0 ); - -return bfd_demangle (NULL , str, flags); +return libbfd__demangle_sym (str, params, modifiers);#elif defined(HAVE_CPLUS_DEMANGLE_SUPPORT )int flags = (params ?DMGL_PARAMS :0 ) | (modifiers ?DMGL_ANSI :0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/2651 perf build: Only pass clang flags to CXX when CXX is clang
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit c8592f8da838a07ddd0011eeb444771b64193a0f ]
Building with "make CC=clang" appends clang's --target= and -fintegrated-as to CXX, but CXX is only set to clang++ by "make LLVM=1". With just CC=clang, CXX is still g++ and every C++ feature test dies:
g++: error: unrecognized command-line option '--target=...' g++: error: unrecognized command-line option '-fintegrated-as'
The failures are silent, as feature tests are allowed to fail, so the build quietly loses libllvm and C++ demangling support:
$ make CC=clang && grep LIBLLVM .config-detected (nothing, whereas a gcc build reports CONFIG_LIBLLVM=y)
The block is entered when CC_NO_CLANG says CC is clang, which says nothing about CXX. Probe CXX the same way tools/scripts/Makefile.include probes CC, and only add the flags when CXX really is clang++.
Mixing a clang-built C with a g++-built C++ is fine here, the C++ code is linked with -lstdc++ already.
--- tools/perf/Makefile.config | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/Makefile.config +8 -1
@@ -54,7 +54,14 @@ ifeq ($(CC_NO_CLANG), 0) endif # CROSS_COMPILE CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as - CXX := $(CXX) $(CLANG_FLAGS) -fintegrated-as + + # CC being clang says nothing about CXX: "make LLVM=1" overrides both, but + # "make CC=clang" leaves CXX as g++. Probe CXX the way Makefile.include + # probes CC rather than assuming the two match. + CXX_NO_CLANG := $(shell if command -v $(firstword $(CXX)) >/dev/null 2>&1; then $(CXX) -dM -E -x c++ /dev/null; fi | grep -Fq "__clang__"; echo $$?) + ifeq ($(CXX_NO_CLANG), 0) + CXX := $(CXX) $(CLANG_FLAGS) -fintegrated-as + endif # Enabled Wthread-safety analysis for clang builds. CFLAGS += -Wthread-safety
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/2651 perf build: Use the given CC rather than clang in clang builds
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit bd874cd8356166d8fb262d32f368c0e460910d5d ]
The clang block is entered when CC_NO_CLANG has determined that CC is clang, but it then ignores CC and hard codes $(CLANG), which defaults to plain "clang". Building with a versioned compiler silently switches compiler:
$ make CC=clang-19 # actually builds with "clang"
Worse, the target triple is probed with $(CLANG) too, so on a machine that only has versioned binaries installed the probe produces nothing and the build stops:
$ make CC=clang-19 *** Specify CROSS_COMPILE or add CLANG_TARGET_FLAGS for x86_64
Use $(CC) in both places. Within the block CC is known to be clang, and for "make LLVM=1" CC is already $(CLANG), so nothing changes there.
$(CLANG) is left as it is for BPF skeletons, as bpf_skel.mak builds those with "$(CLANG) --target=bpf" whatever CC happens to be.
--- tools/perf/Makefile.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/Makefile.config +2 -2
@@ -38,7 +38,7 @@ ifeq ($(CC_NO_CLANG), 0) # Default to host architecture if ARCH is not explicitly given. ifeq ($(ARCH), $(HOSTARCH)) - CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple) + CLANG_TARGET_FLAGS := $(shell $(CC) -print-target-triple) else CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH)) endif
@@ -53,7 +53,7 @@ ifeq ($(CC_NO_CLANG), 0) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) endif # CROSS_COMPILE - CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as + CC := $(CC) $(CLANG_FLAGS) -fintegrated-as # CC being clang says nothing about CXX: "make LLVM=1" overrides both, but # "make CC=clang" leaves CXX as g++. Probe CXX the way Makefile.include
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/2651 perf build: Check the version of the compiler that is used
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 4f4387a07f601988e44fc6a4f4663aa1ff264f94 ]
The flex and bison flags are adjusted for clang older than 13.0.0, which doesn't grok -Wno-unused-but-set-variable. The test is reached because CC_NO_CLANG says CC is clang, but the version comes from $(CLANG), which defaults to plain "clang" and needn't be the compiler in use:
$ make CC=clang-19 CLANG=clang-12 version from $(CLANG) -> 12.0.0, flag stripped version from $(CC) -> 19.1.7, flag kept
Dropping the flag lets the warnings it suppresses in the generated flex and bison code through, and those are errors under -Werror.
Ask $(CC) instead, as that is what compiles the code.
--- tools/perf/util/Build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/Build +1 -1
@@ -340,7 +340,7 @@ bison_flags := -DYYENABLE_NLS=0 -Wno-unused-but-set-variable # Old clangs don't grok -Wno-unused-but-set-variable, remove it ifeq ($(CC_NO_CLANG), 0) - CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g') + CLANG_VERSION := $(shell $(CC) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g') ifeq ($(call version-lt3,$(CLANG_VERSION),13.0.0),1) bison_flags := $(subst -Wno-unused-but-set-variable,,$(bison_flags)) flex_flags := $(subst -Wno-unused-but-set-variable,,$(flex_flags))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/2651 perf build: Remove leftovers of removed build options
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit a5cac2df8b4af0410dd6339e6491cb1e4fbc6986 ]
NO_LIBDW_DWARF_UNWIND, NO_SYSCALL_TABLE and the embedded clang/LLVM support were all removed, but each removal left the matching entry in the build test suite behind:
run += make_no_libdw_dwarf_unwind
run += make_no_syscall_tbl
run += make_with_clangllvm
None of these have a make_* variable defining what to build, so $($@) expands to nothing and each one silently repeats the plain "make_pure" build. The suite therefore spends six builds, as every test is also run with O=, appearing to cover options that no longer exist.
Remove them, along with the NO_LIBDW_DWARF_UNWIND comment that is still in Makefile.perf.
--- tools/perf/Makefile.perf | 3 --- tools/perf/tests/make | 3 --- 2 files changed, 6 deletions(-)
tools/perf/Makefile.perf +0 -3
@@ -64,9 +64,6 @@ include ../scripts/utilities.mak # # Define NO_LIBBIONIC if you do not want bionic support # -# Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support -# for dwarf backtrace post unwind. -# # Define NO_LIBTRACEEVENT=1 if you don't want libtraceevent to be linked, # this will remove multiple features and tools, such as 'perf trace', # that need it to read tracefs event format files, etc.
tools/perf/tests/make +0 -3
@@ -155,7 +155,6 @@ run += make_no_demangle run += make_no_libelf run += make_no_libdw run += make_libunwind -run += make_no_libdw_dwarf_unwind run += make_no_backtrace run += make_no_libcapstone run += make_libcapstone_dlopen
@@ -165,10 +164,8 @@ run += make_no_libbpf run += make_no_libbpf_DEBUG run += make_no_libllvm run += make_no_sdt -run += make_no_syscall_tbl run += make_no_babeltrace2 run += make_with_coresight -run += make_with_clangllvm run += make_no_libpfm4 run += make_refcnt_check run += make_help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/2651 leds: lm3692x: Fix regulator/gpio leak and wrong enabled state on last write failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit 145ca6bca2cc5fd8d9c7af216df58a9c75c0e84c ]
Every write in lm3692x_leds_enable() checks its return and jumps to
out: on failure -- except the last one, which falls through and sets led->enabled = true regardless of whether it actually succeeded. Leaks the regulator on a failing probe, and short-circuits later brightness_set() calls without retrying.
Route it through out: like every other write here, and only set enabled = true once it succeeds.
--- drivers/leds/leds-lm3692x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/leds/leds-lm3692x.c +3 -1
@@ -276,9 +276,11 @@ static int lm3692x_leds_enable(struct lm3692x_led *led) ret =regmap_update_bits (led->regmap,LM3692X_EN ,LM3692X_ENABLE_MASK , enable_state |LM3692X_DEVICE_EN ); +if (ret) + goto out; led->enabled = true; -return ret; +return 0 ; out:dev_err (&led->client->dev,"Fail writing initialization values\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/2651 perf annotate-data: Show the sample count in the data-type browser
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 9db4e9d6cc7c7d318fb6d6bb73abe3fed27385a8 ]
The data-type browser has a samples view, selected with -n (or with annotate.show_nr_samples), in which browser__write_overhead() prints a local nr_samples variable that is initialized to zero and never updated, so every member is listed as having no samples while the period and percent columns for the same entry are filled in.
Print the histogram entry's own count instead.
This predates the load/store counter split, so fix it ahead of that
patch: the split then only has to adapt a line that is already correct, and this fix can be picked on its own.
--- tools/perf/ui/browsers/annotate-data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/ui/browsers/annotate-data.c +1 -1
@@ -370,7 +370,7 @@ static void browser__write_overhead(struct ui_browser *uib,u64 period = hist->period;double percent = total->period ? (100.0 * period / total->period) :0 ;bool current =ui_browser__is_current_entry (uib, row); -int nr_samples =0 ; +int nr_samples = hist->nr_samples;ui_browser__set_percent_color (uib, percent, current);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 648/2651 RDMA/core: Fix partial copy of IPv6 flow_lbl in LAG hash skb
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit b63d21631f836528ef660d7b5a0d84890ff6dbd5 ]
rdma_build_skb() constructs a synthetic IPv6 header for LAG slave selection and copies the flow label from the AH attribute:
memcpy(&ip6h->flow_lbl, &ah_attr->grh.flow_label, sizeof(*ip6h->flow_lbl));
ipv6hdr.flow_lbl is __u8[3], so sizeof(*ip6h->flow_lbl) dereferences the array to a single __u8 and yields 1. The memcpy therefore copies only the first byte of the flow label, leaving flow_lbl[1] and flow_lbl[2] uninitialised in the skb buffer (alloc_skb() does not zero the data). The resulting LAG hash is computed over one byte of real flow-label data and two bytes of kmalloc residue, so IPv6 RoCEv2 traffic on a bonded interface can be steered to the wrong slave.
Use sizeof(ip6h->flow_lbl) (the array, 3 bytes) so the whole flow label is copied.
--- drivers/infiniband/core/lag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/lag.c +1 -1
@@ -59,7 +59,7 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev, ip6h->version =6 ; ip6h->nexthdr =IPPROTO_UDP ;memcpy (&ip6h->flow_lbl, &ah_attr->grh.flow_label, -sizeof (*ip6h->flow_lbl)); +sizeof (ip6h->flow_lbl));memcpy (&ip6h->saddr, ah_attr->grh.sgid_attr->gid.raw,sizeof (struct in6_addr )); memcpy(&ip6h->daddr, ah_attr->grh.dgid.raw,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 649/2651 RDMA/irdma: Fix erroneous -ENOMEM for large MR registration
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit 5bb710151753fe53047b1d34b1b54d0f179cec68 ]
Commit cc8997c94bf3 ("RDMA/irdma: Refactor PBLE functions") replaced the explicit level1_only boolean with a bit mask but did not properly convert the "if (level1_only)" check in irdma_get_pble() to be "lvl == PBLE_LEVEL_1" and instead left it as "if (lvl)".
User MR registration passes "lvl = PBLE_LEVEL_1 | PBLE_LEVEL_2" so this check always evaluates to true and causes the loop to bail after grabbing a single SD even if the region actually requires more than one SD (as is the case for regions larger than 1 GiB with 4k pages). As a result, these registrations can fail with -ENOMEM even if there are sufficient PBLE resources.
--- drivers/infiniband/hw/irdma/pble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/pble.c +1 -1
@@ -482,7 +482,7 @@ int irdma_get_pble(struct irdma_hmc_pble_rsrc *pble_rsrc, status =get_lvl1_lvl2_pble (pble_rsrc, palloc, lvl);/* if level1_only, only go through it once */ -if (!status || lvl) +if (!status || lvl ==PBLE_LEVEL_1 )break ; }
Signature · 1 line
2.53.0