linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict
@ 2021-11-26  2:33 Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 02/28] gfs2: Fix length of holes reported at end-of-file Sasha Levin
                   ` (26 more replies)
  0 siblings, 27 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Bob Peterson, Andreas Gruenbacher, Sasha Levin, cluster-devel

From: Bob Peterson <rpeterso@redhat.com>

[ Upstream commit 49462e2be119d38c5eb5759d0d1b712df3a41239 ]

Before this patch, evict would clear the iopen glock's gl_object after
releasing the inode glock.  In the meantime, another process could reuse
the same block and thus glocks for a new inode.  It would lock the inode
glock (exclusively), and then the iopen glock (shared).  The shared
locking mode doesn't provide any ordering against the evict, so by the
time the iopen glock is reused, evict may not have gotten to setting
gl_object to NULL.

Fix that by releasing the iopen glock before the inode glock in
gfs2_evict_inode.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>gl_object
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/gfs2/super.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 6a355e1347d7f..d2b7ecbd1b150 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1438,13 +1438,6 @@ static void gfs2_evict_inode(struct inode *inode)
 	gfs2_ordered_del_inode(ip);
 	clear_inode(inode);
 	gfs2_dir_hash_inval(ip);
-	if (ip->i_gl) {
-		glock_clear_object(ip->i_gl, ip);
-		wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
-		gfs2_glock_add_to_lru(ip->i_gl);
-		gfs2_glock_put_eventually(ip->i_gl);
-		ip->i_gl = NULL;
-	}
 	if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
 		struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
 
@@ -1457,6 +1450,13 @@ static void gfs2_evict_inode(struct inode *inode)
 		gfs2_holder_uninit(&ip->i_iopen_gh);
 		gfs2_glock_put_eventually(gl);
 	}
+	if (ip->i_gl) {
+		glock_clear_object(ip->i_gl, ip);
+		wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
+		gfs2_glock_add_to_lru(ip->i_gl);
+		gfs2_glock_put_eventually(ip->i_gl);
+		ip->i_gl = NULL;
+	}
 }
 
 static struct inode *gfs2_alloc_inode(struct super_block *sb)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 02/28] gfs2: Fix length of holes reported at end-of-file
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 03/28] powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory" Sasha Levin
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Andreas Gruenbacher, Sasha Levin, rpeterso, cluster-devel

From: Andreas Gruenbacher <agruenba@redhat.com>

[ Upstream commit f3506eee81d1f700d9ee2d2f4a88fddb669ec032 ]

Fix the length of holes reported at the end of a file: the length is
relative to the beginning of the extent, not the seek position which is
rounded down to the filesystem block size.

This bug went unnoticed for some time, but is now caught by the
following assertion in iomap_iter_done():

  WARN_ON_ONCE(iter->iomap.offset + iter->iomap.length <= iter->pos)

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/gfs2/bmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index a1f9dde33058f..b34c02985d9d2 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -940,7 +940,7 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
 		else if (height == ip->i_height)
 			ret = gfs2_hole_size(inode, lblock, len, mp, iomap);
 		else
-			iomap->length = size - pos;
+			iomap->length = size - iomap->offset;
 	} else if (flags & IOMAP_WRITE) {
 		u64 alloc_size;
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 03/28] powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory"
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 02/28] gfs2: Fix length of holes reported at end-of-file Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 04/28] drm/sun4i: fix unmet dependency on RESET_CONTROLLER for PHY_SUN6I_MIPI_DPHY Sasha Levin
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Alexey Kardashevskiy, Michael Ellerman, Sasha Levin, leobras.c,
	fbarrat, linuxppc-dev

From: Alexey Kardashevskiy <aik@ozlabs.ru>

[ Upstream commit 2d33f5504490a9d90924476dbccd4a5349ee1ad0 ]

This reverts commit 54fc3c681ded9437e4548e2501dc1136b23cfa9a
which does not allow 1:1 mapping even for the system RAM which
is usually possible.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211108040320.3857636-2-aik@ozlabs.ru
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/powerpc/platforms/pseries/iommu.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index e4198700ed1a3..245f1f8df6563 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1034,15 +1034,6 @@ static phys_addr_t ddw_memory_hotplug_max(void)
 	phys_addr_t max_addr = memory_hotplug_max();
 	struct device_node *memory;
 
-	/*
-	 * The "ibm,pmemory" can appear anywhere in the address space.
-	 * Assuming it is still backed by page structs, set the upper limit
-	 * for the huge DMA window as MAX_PHYSMEM_BITS.
-	 */
-	if (of_find_node_by_type(NULL, "ibm,pmemory"))
-		return (sizeof(phys_addr_t) * 8 <= MAX_PHYSMEM_BITS) ?
-			(phys_addr_t) -1 : (1ULL << MAX_PHYSMEM_BITS);
-
 	for_each_node_by_type(memory, "memory") {
 		unsigned long start, size;
 		int n_mem_addr_cells, n_mem_size_cells, len;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 04/28] drm/sun4i: fix unmet dependency on RESET_CONTROLLER for PHY_SUN6I_MIPI_DPHY
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 02/28] gfs2: Fix length of holes reported at end-of-file Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 03/28] powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory" Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 05/28] mac80211: do not access the IV when it was stripped Sasha Levin
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Julian Braha, Jernej Skrabec, Maxime Ripard, Sasha Levin,
	mripard, wens, airlied, daniel, dri-devel, linux-arm-kernel,
	linux-sunxi

From: Julian Braha <julianbraha@gmail.com>

[ Upstream commit bb162bb2b4394108c8f055d1b115735331205e28 ]

When PHY_SUN6I_MIPI_DPHY is selected, and RESET_CONTROLLER
is not selected, Kbuild gives the following warning:

WARNING: unmet direct dependencies detected for PHY_SUN6I_MIPI_DPHY
  Depends on [n]: (ARCH_SUNXI [=n] || COMPILE_TEST [=y]) && HAS_IOMEM [=y] && COMMON_CLK [=y] && RESET_CONTROLLER [=n]
  Selected by [y]:
  - DRM_SUN6I_DSI [=y] && HAS_IOMEM [=y] && DRM_SUN4I [=y]

This is because DRM_SUN6I_DSI selects PHY_SUN6I_MIPI_DPHY
without selecting or depending on RESET_CONTROLLER, despite
PHY_SUN6I_MIPI_DPHY depending on RESET_CONTROLLER.

These unmet dependency bugs were detected by Kismet,
a static analysis tool for Kconfig. Please advise if this
is not the appropriate solution.

v2:
Fixed indentation to match the rest of the file.

Signed-off-by: Julian Braha <julianbraha@gmail.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20211109032351.43322-1-julianbraha@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/sun4i/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/sun4i/Kconfig b/drivers/gpu/drm/sun4i/Kconfig
index 5755f0432e774..8c796de53222c 100644
--- a/drivers/gpu/drm/sun4i/Kconfig
+++ b/drivers/gpu/drm/sun4i/Kconfig
@@ -46,6 +46,7 @@ config DRM_SUN6I_DSI
 	default MACH_SUN8I
 	select CRC_CCITT
 	select DRM_MIPI_DSI
+	select RESET_CONTROLLER
 	select PHY_SUN6I_MIPI_DPHY
 	help
 	  Choose this option if you want have an Allwinner SoC with
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 05/28] mac80211: do not access the IV when it was stripped
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (2 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 04/28] drm/sun4i: fix unmet dependency on RESET_CONTROLLER for PHY_SUN6I_MIPI_DPHY Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 06/28] tun: fix bonding active backup with arp monitoring Sasha Levin
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Xing Song, Johannes Berg, Sasha Levin, johannes, davem, kuba,
	matthias.bgg, linux-wireless, netdev, linux-arm-kernel,
	linux-mediatek

From: Xing Song <xing.song@mediatek.com>

[ Upstream commit 77dfc2bc0bb4b8376ecd7a430f27a4a8fff6a5a0 ]

ieee80211_get_keyid() will return false value if IV has been stripped,
such as return 0 for IP/ARP frames due to LLC header, and return -EINVAL
for disassociation frames due to its length... etc. Don't try to access
it if it's not present.

Signed-off-by: Xing Song <xing.song@mediatek.com>
Link: https://lore.kernel.org/r/20211101024657.143026-1-xing.song@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/mac80211/rx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index b7979c0bffd0f..6a24431b90095 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1945,7 +1945,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
 		int keyid = rx->sta->ptk_idx;
 		sta_ptk = rcu_dereference(rx->sta->ptk[keyid]);
 
-		if (ieee80211_has_protected(fc)) {
+		if (ieee80211_has_protected(fc) &&
+		    !(status->flag & RX_FLAG_IV_STRIPPED)) {
 			cs = rx->sta->cipher_scheme;
 			keyid = ieee80211_get_keyid(rx->skb, cs);
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 06/28] tun: fix bonding active backup with arp monitoring
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (3 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 05/28] mac80211: do not access the IV when it was stripped Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 07/28] net/smc: Transfer remaining wait queue entries during fallback Sasha Levin
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Nicolas Dichtel, David S . Miller, Sasha Levin, kuba, netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>

[ Upstream commit a31d27fbed5d518734cb60956303eb15089a7634 ]

As stated in the bonding doc, trans_start must be set manually for drivers
using NETIF_F_LLTX:
 Drivers that use NETIF_F_LLTX flag must also update
 netdev_queue->trans_start. If they do not, then the ARP monitor will
 immediately fail any slaves using that driver, and those slaves will stay
 down.

Link: https://www.kernel.org/doc/html/v5.15/networking/bonding.html#arp-monitor-operation
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/tun.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index c671d8e257741..ffbc7eda95eed 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1021,6 +1021,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct tun_struct *tun = netdev_priv(dev);
 	int txq = skb->queue_mapping;
+	struct netdev_queue *queue;
 	struct tun_file *tfile;
 	int len = skb->len;
 
@@ -1065,6 +1066,10 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (ptr_ring_produce(&tfile->tx_ring, skb))
 		goto drop;
 
+	/* NETIF_F_LLTX requires to do our own update of trans_start */
+	queue = netdev_get_tx_queue(dev, txq);
+	queue->trans_start = jiffies;
+
 	/* Notify and wake up reader process */
 	if (tfile->flags & TUN_FASYNC)
 		kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 07/28] net/smc: Transfer remaining wait queue entries during fallback
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (4 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 06/28] tun: fix bonding active backup with arp monitoring Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 08/28] atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_wait Sasha Levin
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wen Gu, Tony Lu, David S . Miller, Sasha Levin, kgraul, kuba,
	linux-s390, netdev

From: Wen Gu <guwen@linux.alibaba.com>

[ Upstream commit 2153bd1e3d3dbf6a3403572084ef6ed31c53c5f0 ]

The SMC fallback is incomplete currently. There may be some
wait queue entries remaining in smc socket->wq, which should
be removed to clcsocket->wq during the fallback.

For example, in nginx/wrk benchmark, this issue causes an
all-zeros test result:

server: nginx -g 'daemon off;'
client: smc_run wrk -c 1 -t 1 -d 5 http://11.200.15.93/index.html

  Running 5s test @ http://11.200.15.93/index.html
     1 threads and 1 connections
     Thread Stats   Avg      Stdev     Max   ± Stdev
     	Latency     0.00us    0.00us   0.00us    -nan%
	Req/Sec     0.00      0.00     0.00      -nan%
	0 requests in 5.00s, 0.00B read
     Requests/sec:      0.00
     Transfer/sec:       0.00B

The reason for this all-zeros result is that when wrk used SMC
to replace TCP, it added an eppoll_entry into smc socket->wq
and expected to be notified if epoll events like EPOLL_IN/
EPOLL_OUT occurred on the smc socket.

However, once a fallback occurred, wrk switches to use clcsocket.
Now it is clcsocket->wq instead of smc socket->wq which will
be woken up. The eppoll_entry remaining in smc socket->wq does
not work anymore and wrk stops the test.

This patch fixes this issue by removing remaining wait queue
entries from smc socket->wq to clcsocket->wq during the fallback.

Link: https://www.spinics.net/lists/netdev/msg779769.html
Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/smc/af_smc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index cfb5b9be0569d..9714c779adf0a 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -513,12 +513,26 @@ static void smc_link_save_peer_info(struct smc_link *link,
 
 static void smc_switch_to_fallback(struct smc_sock *smc)
 {
+	wait_queue_head_t *smc_wait = sk_sleep(&smc->sk);
+	wait_queue_head_t *clc_wait = sk_sleep(smc->clcsock->sk);
+	unsigned long flags;
+
 	smc->use_fallback = true;
 	if (smc->sk.sk_socket && smc->sk.sk_socket->file) {
 		smc->clcsock->file = smc->sk.sk_socket->file;
 		smc->clcsock->file->private_data = smc->clcsock;
 		smc->clcsock->wq.fasync_list =
 			smc->sk.sk_socket->wq.fasync_list;
+
+		/* There may be some entries remaining in
+		 * smc socket->wq, which should be removed
+		 * to clcsocket->wq during the fallback.
+		 */
+		spin_lock_irqsave(&smc_wait->lock, flags);
+		spin_lock(&clc_wait->lock);
+		list_splice_init(&smc_wait->head, &clc_wait->head);
+		spin_unlock(&clc_wait->lock);
+		spin_unlock_irqrestore(&smc_wait->lock, flags);
 	}
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 08/28] atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_wait
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (5 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 07/28] net/smc: Transfer remaining wait queue entries during fallback Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 09/28] net: return correct error code Sasha Levin
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Zekun Shen, Brendan Dolan-Gavitt, David S . Miller, Sasha Levin,
	irusskikh, kuba, netdev

From: Zekun Shen <bruceshenzk@gmail.com>

[ Upstream commit b922f622592af76b57cbc566eaeccda0b31a3496 ]

This bug report shows up when running our research tools. The
reports is SOOB read, but it seems SOOB write is also possible
a few lines below.

In details, fw.len and sw.len are inputs coming from io. A len
over the size of self->rpc triggers SOOB. The patch fixes the
bugs by adding sanity checks.

The bugs are triggerable with compromised/malfunctioning devices.
They are potentially exploitable given they first leak up to
0xffff bytes and able to overwrite the region later.

The patch is tested with QEMU emulater.
This is NOT tested with a real device.

Attached is the log we found by fuzzing.

BUG: KASAN: slab-out-of-bounds in
	hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
Read of size 4 at addr ffff888016260b08 by task modprobe/213
CPU: 0 PID: 213 Comm: modprobe Not tainted 5.6.0 #1
Call Trace:
 dump_stack+0x76/0xa0
 print_address_description.constprop.0+0x16/0x200
 ? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
 ? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
 __kasan_report.cold+0x37/0x7c
 ? aq_hw_read_reg_bit+0x60/0x70 [atlantic]
 ? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
 kasan_report+0xe/0x20
 hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
 hw_atl_utils_fw_rpc_call+0x95/0x130 [atlantic]
 hw_atl_utils_fw_rpc_wait+0x176/0x210 [atlantic]
 hw_atl_utils_mpi_create+0x229/0x2e0 [atlantic]
 ? hw_atl_utils_fw_rpc_wait+0x210/0x210 [atlantic]
 ? hw_atl_utils_initfw+0x9f/0x1c8 [atlantic]
 hw_atl_utils_initfw+0x12a/0x1c8 [atlantic]
 aq_nic_ndev_register+0x88/0x650 [atlantic]
 ? aq_nic_ndev_init+0x235/0x3c0 [atlantic]
 aq_pci_probe+0x731/0x9b0 [atlantic]
 ? aq_pci_func_init+0xc0/0xc0 [atlantic]
 local_pci_probe+0xd3/0x160
 pci_device_probe+0x23f/0x3e0

Reported-by: Brendan Dolan-Gavitt <brendandg@nyu.edu>
Signed-off-by: Zekun Shen <bruceshenzk@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c   | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index 404cbf60d3f2f..da1d185f6d226 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -559,6 +559,11 @@ int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
 			goto err_exit;
 
 		if (fw.len == 0xFFFFU) {
+			if (sw.len > sizeof(self->rpc)) {
+				printk(KERN_INFO "Invalid sw len: %x\n", sw.len);
+				err = -EINVAL;
+				goto err_exit;
+			}
 			err = hw_atl_utils_fw_rpc_call(self, sw.len);
 			if (err < 0)
 				goto err_exit;
@@ -567,6 +572,11 @@ int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
 
 	if (rpc) {
 		if (fw.len) {
+			if (fw.len > sizeof(self->rpc)) {
+				printk(KERN_INFO "Invalid fw len: %x\n", fw.len);
+				err = -EINVAL;
+				goto err_exit;
+			}
 			err =
 			hw_atl_utils_fw_downld_dwords(self,
 						      self->rpc_addr,
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 09/28] net: return correct error code
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (6 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 08/28] atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_wait Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI Sasha Levin
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: liuguoqiang, David S . Miller, Sasha Levin, yoshfuji, dsahern,
	kuba, netdev

From: liuguoqiang <liuguoqiang@uniontech.com>

[ Upstream commit 6def480181f15f6d9ec812bca8cbc62451ba314c ]

When kmemdup called failed and register_net_sysctl return NULL, should
return ENOMEM instead of ENOBUFS

Signed-off-by: liuguoqiang <liuguoqiang@uniontech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv4/devinet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 7c18597774297..148ef484a66ce 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2582,7 +2582,7 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name,
 free:
 	kfree(t);
 out:
-	return -ENOBUFS;
+	return -ENOMEM;
 }
 
 static void __devinet_sysctl_unregister(struct net *net,
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (7 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 09/28] net: return correct error code Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-29 14:47   ` Limonciello, Mario
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 11/28] pinctrl: qcom: fix unmet dependencies on GPIOLIB for GPIOLIB_IRQCHIP Sasha Levin
                   ` (17 subsequent siblings)
  26 siblings, 1 reply; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Mario Limonciello, Joerie de Gram, Basavaraj Natikar,
	Linus Walleij, Sasha Levin, Shyam-sundar.S-k, linux-gpio

From: Mario Limonciello <mario.limonciello@amd.com>

[ Upstream commit 2d54067fcd23aae61e23508425ae5b29e973573d ]

On some Lenovo AMD Gen2 platforms the IRQ for the SCI and pinctrl drivers
are shared.  Due to how the s2idle loop handling works, this case needs
an extra explicit check whether the interrupt was caused by SCI or by
the GPIO controller.

To fix this rework the existing IRQ handler function to function as a
checker and an IRQ handler depending on the calling arguments.

BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1738
Reported-by: Joerie de Gram <j.de.gram@gmail.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Link: https://lore.kernel.org/r/20211101014853.6177-2-mario.limonciello@amd.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/pinctrl/pinctrl-amd.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index e20bcc835d6a8..54dfa0244422c 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -520,14 +520,14 @@ static struct irq_chip amd_gpio_irqchip = {
 
 #define PIN_IRQ_PENDING	(BIT(INTERRUPT_STS_OFF) | BIT(WAKE_STS_OFF))
 
-static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
+static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
 {
 	struct amd_gpio *gpio_dev = dev_id;
 	struct gpio_chip *gc = &gpio_dev->gc;
-	irqreturn_t ret = IRQ_NONE;
 	unsigned int i, irqnr;
 	unsigned long flags;
 	u32 __iomem *regs;
+	bool ret = false;
 	u32  regval;
 	u64 status, mask;
 
@@ -549,6 +549,14 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
 		/* Each status bit covers four pins */
 		for (i = 0; i < 4; i++) {
 			regval = readl(regs + i);
+			/* caused wake on resume context for shared IRQ */
+			if (irq < 0 && (regval & BIT(WAKE_STS_OFF))) {
+				dev_dbg(&gpio_dev->pdev->dev,
+					"Waking due to GPIO %d: 0x%x",
+					irqnr + i, regval);
+				return true;
+			}
+
 			if (!(regval & PIN_IRQ_PENDING) ||
 			    !(regval & BIT(INTERRUPT_MASK_OFF)))
 				continue;
@@ -574,9 +582,12 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
 			}
 			writel(regval, regs + i);
 			raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
-			ret = IRQ_HANDLED;
+			ret = true;
 		}
 	}
+	/* did not cause wake on resume context for shared IRQ */
+	if (irq < 0)
+		return false;
 
 	/* Signal EOI to the GPIO unit */
 	raw_spin_lock_irqsave(&gpio_dev->lock, flags);
@@ -588,6 +599,16 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
 	return ret;
 }
 
+static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
+{
+	return IRQ_RETVAL(do_amd_gpio_irq_handler(irq, dev_id));
+}
+
+static bool __maybe_unused amd_gpio_check_wake(void *dev_id)
+{
+	return do_amd_gpio_irq_handler(-1, dev_id);
+}
+
 static int amd_get_groups_count(struct pinctrl_dev *pctldev)
 {
 	struct amd_gpio *gpio_dev = pinctrl_dev_get_drvdata(pctldev);
@@ -958,6 +979,7 @@ static int amd_gpio_probe(struct platform_device *pdev)
 		goto out2;
 
 	platform_set_drvdata(pdev, gpio_dev);
+	acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
 
 	dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
 	return ret;
@@ -975,6 +997,7 @@ static int amd_gpio_remove(struct platform_device *pdev)
 	gpio_dev = platform_get_drvdata(pdev);
 
 	gpiochip_remove(&gpio_dev->gc);
+	acpi_unregister_wakeup_handler(amd_gpio_check_wake, gpio_dev);
 
 	return 0;
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 11/28] pinctrl: qcom: fix unmet dependencies on GPIOLIB for GPIOLIB_IRQCHIP
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (8 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 12/28] platform/x86: thinkpad_acpi: Add support for dual fan control Sasha Levin
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Julian Braha, Linus Walleij, Sasha Levin, agross,
	bjorn.andersson, linux-arm-msm, linux-gpio

From: Julian Braha <julianbraha@gmail.com>

[ Upstream commit 60430d4c4eddcdf8eac2bdbec9704f84a436eedf ]

When PINCTRL_QCOM_SPMI_PMIC or PINCTRL_QCOM_SSBI_PMIC
is selected, and GPIOLIB is not selected, Kbuild
gives the following warnings:

WARNING: unmet direct dependencies detected for GPIOLIB_IRQCHIP
  Depends on [n]: GPIOLIB [=n]
  Selected by [y]:
  - PINCTRL_QCOM_SPMI_PMIC [=y] && PINCTRL [=y] && (ARCH_QCOM [=n] || COMPILE_TEST [=y]) && OF [=y] && SPMI [=y]

WARNING: unmet direct dependencies detected for GPIOLIB_IRQCHIP
  Depends on [n]: GPIOLIB [=n]
  Selected by [y]:
  - PINCTRL_QCOM_SSBI_PMIC [=y] && PINCTRL [=y] && (ARCH_QCOM [=n] || COMPILE_TEST [=y]) && OF [=y]

This is because these config options enable GPIOLIB_IRQCHIP
without selecting or depending on GPIOLIB, despite
GPIOLIB_IRQCHIP depending on GPIOLIB.

These unmet dependency bugs were detected by Kismet,
a static analysis tool for Kconfig. Please advise if this
is not the appropriate solution.

Signed-off-by: Julian Braha <julianbraha@gmail.com>
Link: https://lore.kernel.org/r/20211029004610.35131-1-julianbraha@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/pinctrl/qcom/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig
index 5fe7b8aaf69d8..a209eb1f189ab 100644
--- a/drivers/pinctrl/qcom/Kconfig
+++ b/drivers/pinctrl/qcom/Kconfig
@@ -169,6 +169,7 @@ config PINCTRL_QCOM_SPMI_PMIC
 	select PINMUX
 	select PINCONF
 	select GENERIC_PINCONF
+  select GPIOLIB
 	select GPIOLIB_IRQCHIP
 	select IRQ_DOMAIN_HIERARCHY
 	help
@@ -183,6 +184,7 @@ config PINCTRL_QCOM_SSBI_PMIC
 	select PINMUX
 	select PINCONF
 	select GENERIC_PINCONF
+  select GPIOLIB
 	select GPIOLIB_IRQCHIP
 	select IRQ_DOMAIN_HIERARCHY
 	help
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 12/28] platform/x86: thinkpad_acpi: Add support for dual fan control
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (9 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 11/28] pinctrl: qcom: fix unmet dependencies on GPIOLIB for GPIOLIB_IRQCHIP Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 13/28] platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep Sasha Levin
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jimmy Wang, Hans de Goede, Sasha Levin, hmh, markgross,
	ibm-acpi-devel, platform-driver-x86

From: Jimmy Wang <jimmy221b@163.com>

[ Upstream commit 1f338954a5fbe21eb22b4223141e31f2a26366d5 ]

   This adds dual fan control for P1 / X1 Extreme Gen4

Signed-off-by: Jimmy Wang <jimmy221b@163.com>
Link: https://lore.kernel.org/r/20211105090528.39677-1-jimmy221b@163.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/platform/x86/thinkpad_acpi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 2a313643e0388..840bbc312aedd 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8805,6 +8805,7 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = {
 	TPACPI_Q_LNV3('N', '2', 'E', TPACPI_FAN_2CTL),	/* P1 / X1 Extreme (1st gen) */
 	TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL),	/* P1 / X1 Extreme (2nd gen) */
 	TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL),	/* P1 / X1 Extreme (3nd gen) */
+	TPACPI_Q_LNV3('N', '4', '0', TPACPI_FAN_2CTL),	/* P1 / X1 Extreme (4nd gen) */
 	TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL),	/* P15 (1st gen) / P15v (1st gen) */
 	TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL),	/* X1 Carbon (9th gen) */
 };
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 13/28] platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (10 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 12/28] platform/x86: thinkpad_acpi: Add support for dual fan control Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 14/28] s390/setup: avoid using memblock_enforce_memory_limit Sasha Levin
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Slark Xiao, Hans de Goede, Sasha Levin, hmh, markgross,
	ibm-acpi-devel, platform-driver-x86

From: Slark Xiao <slark_xiao@163.com>

[ Upstream commit 39f53292181081d35174a581a98441de5da22bc9 ]

When WWAN device wake from S3 deep, under thinkpad platform,
WWAN would be disabled. This disable status could be checked
by command 'nmcli r wwan' or 'rfkill list'.

Issue analysis as below:
  When host resume from S3 deep, thinkpad_acpi driver would
call hotkey_resume() function. Finnaly, it will use
wan_get_status to check the current status of WWAN device.
During this resume progress, wan_get_status would always
return off even WWAN boot up completely.
  In patch V2, Hans said 'sw_state should be unchanged
after a suspend/resume. It's better to drop the
tpacpi_rfk_update_swstate call all together from the
resume path'.
  And it's confimed by Lenovo that GWAN is no longer
 available from WHL generation because the design does not
 match with current pin control.

Signed-off-by: Slark Xiao <slark_xiao@163.com>
Link: https://lore.kernel.org/r/20211108060648.8212-1-slark_xiao@163.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/platform/x86/thinkpad_acpi.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 840bbc312aedd..d8d241344d22d 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1170,15 +1170,6 @@ static int tpacpi_rfk_update_swstate(const struct tpacpi_rfk *tp_rfk)
 	return status;
 }
 
-/* Query FW and update rfkill sw state for all rfkill switches */
-static void tpacpi_rfk_update_swstate_all(void)
-{
-	unsigned int i;
-
-	for (i = 0; i < TPACPI_RFK_SW_MAX; i++)
-		tpacpi_rfk_update_swstate(tpacpi_rfkill_switches[i]);
-}
-
 /*
  * Sync the HW-blocking state of all rfkill switches,
  * do notice it causes the rfkill core to schedule uevents
@@ -3121,9 +3112,6 @@ static void tpacpi_send_radiosw_update(void)
 	if (wlsw == TPACPI_RFK_RADIO_OFF)
 		tpacpi_rfk_update_hwblock_state(true);
 
-	/* Sync sw blocking state */
-	tpacpi_rfk_update_swstate_all();
-
 	/* Sync hw blocking state last if it is hw-unblocked */
 	if (wlsw == TPACPI_RFK_RADIO_ON)
 		tpacpi_rfk_update_hwblock_state(false);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 14/28] s390/setup: avoid using memblock_enforce_memory_limit
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (11 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 13/28] platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 15/28] btrfs: check-integrity: fix a warning on write caching disabled disk Sasha Levin
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Vasily Gorbik, Heiko Carstens, Sasha Levin, borntraeger,
	agordeev, svens, egorenar, linux-s390

From: Vasily Gorbik <gor@linux.ibm.com>

[ Upstream commit 5dbc4cb4667457b0c53bcd7bff11500b3c362975 ]

There is a difference in how architectures treat "mem=" option. For some
that is an amount of online memory, for s390 and x86 this is the limiting
max address. Some memblock api like memblock_enforce_memory_limit()
take limit argument and explicitly treat it as the size of online memory,
and use __find_max_addr to convert it to an actual max address. Current
s390 usage:

memblock_enforce_memory_limit(memblock_end_of_DRAM());

yields different results depending on presence of memory holes (offline
memory blocks in between online memory). If there are no memory holes
limit == max_addr in memblock_enforce_memory_limit() and it does trim
online memory and reserved memory regions. With memory holes present it
actually does nothing.

Since we already use memblock_remove() explicitly to trim online memory
regions to potential limit (think mem=, kdump, addressing limits, etc.)
drop the usage of memblock_enforce_memory_limit() altogether. Trimming
reserved regions should not be required, since we now use
memblock_set_current_limit() to limit allocations and any explicit memory
reservations above the limit is an actual problem we should not hide.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/setup.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 5cd9d20af31e9..f9f8721dc5321 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -845,9 +845,6 @@ static void __init setup_memory(void)
 		storage_key_init_range(start, end);
 
 	psw_set_key(PAGE_DEFAULT_KEY);
-
-	/* Only cosmetics */
-	memblock_enforce_memory_limit(memblock_end_of_DRAM());
 }
 
 /*
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 15/28] btrfs: check-integrity: fix a warning on write caching disabled disk
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (12 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 14/28] s390/setup: avoid using memblock_enforce_memory_limit Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 16/28] thermal: core: Reset previous low and high trip during thermal zone init Sasha Levin
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wang Yugui, Filipe Manana, David Sterba, Sasha Levin, clm, josef,
	linux-btrfs

From: Wang Yugui <wangyugui@e16-tech.com>

[ Upstream commit a91cf0ffbc244792e0b3ecf7d0fddb2f344b461f ]

When a disk has write caching disabled, we skip submission of a bio with
flush and sync requests before writing the superblock, since it's not
needed. However when the integrity checker is enabled, this results in
reports that there are metadata blocks referred by a superblock that
were not properly flushed. So don't skip the bio submission only when
the integrity checker is enabled for the sake of simplicity, since this
is a debug tool and not meant for use in non-debug builds.

fstests/btrfs/220 trigger a check-integrity warning like the following
when CONFIG_BTRFS_FS_CHECK_INTEGRITY=y and the disk with WCE=0.

  btrfs: attempt to write superblock which references block M @5242880 (sdb2/5242880/0) which is not flushed out of disk's write cache (block flush_gen=1, dev->flush_gen=0)!
  ------------[ cut here ]------------
  WARNING: CPU: 28 PID: 843680 at fs/btrfs/check-integrity.c:2196 btrfsic_process_written_superblock+0x22a/0x2a0 [btrfs]
  CPU: 28 PID: 843680 Comm: umount Not tainted 5.15.0-0.rc5.39.el8.x86_64 #1
  Hardware name: Dell Inc. Precision T7610/0NK70N, BIOS A18 09/11/2019
  RIP: 0010:btrfsic_process_written_superblock+0x22a/0x2a0 [btrfs]
  RSP: 0018:ffffb642afb47940 EFLAGS: 00010246
  RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000
  RDX: 00000000ffffffff RSI: ffff8b722fc97d00 RDI: ffff8b722fc97d00
  RBP: ffff8b5601c00000 R08: 0000000000000000 R09: c0000000ffff7fff
  R10: 0000000000000001 R11: ffffb642afb476f8 R12: ffffffffffffffff
  R13: ffffb642afb47974 R14: ffff8b5499254c00 R15: 0000000000000003
  FS:  00007f00a06d4080(0000) GS:ffff8b722fc80000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 00007fff5cff5ff0 CR3: 00000001c0c2a006 CR4: 00000000001706e0
  Call Trace:
   btrfsic_process_written_block+0x2f7/0x850 [btrfs]
   __btrfsic_submit_bio.part.19+0x310/0x330 [btrfs]
   ? bio_associate_blkg_from_css+0xa4/0x2c0
   btrfsic_submit_bio+0x18/0x30 [btrfs]
   write_dev_supers+0x81/0x2a0 [btrfs]
   ? find_get_pages_range_tag+0x219/0x280
   ? pagevec_lookup_range_tag+0x24/0x30
   ? __filemap_fdatawait_range+0x6d/0xf0
   ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
   ? find_first_extent_bit+0x9b/0x160 [btrfs]
   ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
   write_all_supers+0x1b3/0xa70 [btrfs]
   ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
   btrfs_commit_transaction+0x59d/0xac0 [btrfs]
   close_ctree+0x11d/0x339 [btrfs]
   generic_shutdown_super+0x71/0x110
   kill_anon_super+0x14/0x30
   btrfs_kill_super+0x12/0x20 [btrfs]
   deactivate_locked_super+0x31/0x70
   cleanup_mnt+0xb8/0x140
   task_work_run+0x6d/0xb0
   exit_to_user_mode_prepare+0x1f0/0x200
   syscall_exit_to_user_mode+0x12/0x30
   do_syscall_64+0x46/0x80
   entry_SYSCALL_64_after_hwframe+0x44/0xae
  RIP: 0033:0x7f009f711dfb
  RSP: 002b:00007fff5cff7928 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
  RAX: 0000000000000000 RBX: 000055b68c6c9970 RCX: 00007f009f711dfb
  RDX: 0000000000000001 RSI: 0000000000000000 RDI: 000055b68c6c9b50
  RBP: 0000000000000000 R08: 000055b68c6ca900 R09: 00007f009f795580
  R10: 0000000000000000 R11: 0000000000000246 R12: 000055b68c6c9b50
  R13: 00007f00a04bf184 R14: 0000000000000000 R15: 00000000ffffffff
  ---[ end trace 2c4b82abcef9eec4 ]---
  S-65536(sdb2/65536/1)
   -->
  M-1064960(sdb2/1064960/1)

Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/disk-io.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9051bb47cbdd9..bab2091c81683 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3692,11 +3692,23 @@ static void btrfs_end_empty_barrier(struct bio *bio)
  */
 static void write_dev_flush(struct btrfs_device *device)
 {
-	struct request_queue *q = bdev_get_queue(device->bdev);
 	struct bio *bio = device->flush_bio;
 
+#ifndef CONFIG_BTRFS_FS_CHECK_INTEGRITY
+	/*
+	 * When a disk has write caching disabled, we skip submission of a bio
+	 * with flush and sync requests before writing the superblock, since
+	 * it's not needed. However when the integrity checker is enabled, this
+	 * results in reports that there are metadata blocks referred by a
+	 * superblock that were not properly flushed. So don't skip the bio
+	 * submission only when the integrity checker is enabled for the sake
+	 * of simplicity, since this is a debug tool and not meant for use in
+	 * non-debug builds.
+	 */
+	struct request_queue *q = bdev_get_queue(device->bdev);
 	if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags))
 		return;
+#endif
 
 	bio_reset(bio);
 	bio->bi_end_io = btrfs_end_empty_barrier;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 16/28] thermal: core: Reset previous low and high trip during thermal zone init
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (13 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 15/28] btrfs: check-integrity: fix a warning on write caching disabled disk Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 17/28] scsi: iscsi: Unblock session then wake up error handler Sasha Levin
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Manaf Meethalavalappu Pallikunhi, Thara Gopinath,
	Rafael J . Wysocki, Sasha Levin, rafael, daniel.lezcano,
	linux-pm

From: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>

[ Upstream commit 99b63316c39988039965693f5f43d8b4ccb1c86c ]

During the suspend is in process, thermal_zone_device_update bails out
thermal zone re-evaluation for any sensor trip violation without
setting next valid trip to that sensor. It assumes during resume
it will re-evaluate same thermal zone and update trip. But when it is
in suspend temperature goes down and on resume path while updating
thermal zone if temperature is less than previously violated trip,
thermal zone set trip function evaluates the same previous high and
previous low trip as new high and low trip. Since there is no change
in high/low trip, it bails out from thermal zone set trip API without
setting any trip. It leads to a case where sensor high trip or low
trip is disabled forever even though thermal zone has a valid high
or low trip.

During thermal zone device init, reset thermal zone previous high
and low trip. It resolves above mentioned scenario.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
Reviewed-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/thermal/thermal_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 17de8a9b991e9..d9e34ac376626 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -474,6 +474,8 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
 {
 	struct thermal_instance *pos;
 	tz->temperature = THERMAL_TEMP_INVALID;
+	tz->prev_low_trip = -INT_MAX;
+	tz->prev_high_trip = INT_MAX;
 	list_for_each_entry(pos, &tz->thermal_instances, tz_node)
 		pos->initialized = false;
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 17/28] scsi: iscsi: Unblock session then wake up error handler
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (14 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 16/28] thermal: core: Reset previous low and high trip during thermal zone init Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 18/28] drm/amd/amdkfd: Fix kernel panic when reset failed and been triggered again Sasha Levin
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Mike Christie, Lee Duncan, Martin K . Petersen, Sasha Levin,
	cleech, jejb, open-iscsi, linux-scsi

From: Mike Christie <michael.christie@oracle.com>

[ Upstream commit a0c2f8b6709a9a4af175497ca65f93804f57b248 ]

We can race where iscsi_session_recovery_timedout() has woken up the error
handler thread and it's now setting the devices to offline, and
session_recovery_timedout()'s call to scsi_target_unblock() is also trying
to set the device's state to transport-offline. We can then get a mix of
states.

For the case where we can't relogin we want the devices to be in
transport-offline so when we have repaired the connection
__iscsi_unblock_session() can set the state back to running.

Set the device state then call into libiscsi to wake up the error handler.

Link: https://lore.kernel.org/r/20211105221048.6541-2-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/scsi_transport_iscsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 3f7fa8de36427..a5759d0e388a8 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1909,12 +1909,12 @@ static void session_recovery_timedout(struct work_struct *work)
 	}
 	spin_unlock_irqrestore(&session->lock, flags);
 
-	if (session->transport->session_recovery_timedout)
-		session->transport->session_recovery_timedout(session);
-
 	ISCSI_DBG_TRANS_SESSION(session, "Unblocking SCSI target\n");
 	scsi_target_unblock(&session->dev, SDEV_TRANSPORT_OFFLINE);
 	ISCSI_DBG_TRANS_SESSION(session, "Completed unblocking SCSI target\n");
+
+	if (session->transport->session_recovery_timedout)
+		session->transport->session_recovery_timedout(session);
 }
 
 static void __iscsi_unblock_session(struct work_struct *work)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 18/28] drm/amd/amdkfd: Fix kernel panic when reset failed and been triggered again
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (15 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 17/28] scsi: iscsi: Unblock session then wake up error handler Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 19/28] drm/amd/amdgpu: fix potential memleak Sasha Levin
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: shaoyunl, Felix Kuehling, Alex Deucher, Sasha Levin,
	christian.koenig, Xinhui.Pan, airlied, daniel, amd-gfx,
	dri-devel

From: shaoyunl <shaoyun.liu@amd.com>

[ Upstream commit 2cf49e00d40d5132e3d067b5aa6d84791929ab15 ]

In SRIOV configuration, the reset may failed to bring asic back to normal but stop cpsch
already been called, the start_cpsch will not be called since there is no resume in this
case.  When reset been triggered again, driver should avoid to do uninitialization again.

Signed-off-by: shaoyunl <shaoyun.liu@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 352a32dc609b2..2645ebc63a14d 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1207,6 +1207,11 @@ static int stop_cpsch(struct device_queue_manager *dqm)
 	bool hanging;
 
 	dqm_lock(dqm);
+	if (!dqm->sched_running) {
+		dqm_unlock(dqm);
+		return 0;
+	}
+
 	if (!dqm->is_hws_hang)
 		unmap_queues_cpsch(dqm, KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES, 0);
 	hanging = dqm->is_hws_hang || dqm->is_resetting;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 19/28] drm/amd/amdgpu: fix potential memleak
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (16 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 18/28] drm/amd/amdkfd: Fix kernel panic when reset failed and been triggered again Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 20/28] ata: ahci: Add Green Sardine vendor ID as board_ahci_mobile Sasha Levin
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Bernard Zhao, Felix Kuehling, Alex Deucher, Sasha Levin,
	christian.koenig, Xinhui.Pan, airlied, daniel, Hawking.Zhang,
	john.clements, jonathan.kim, candice.li, tao.zhou1, kevin1.wang,
	shaoyun.liu, amd-gfx, dri-devel

From: Bernard Zhao <bernard@vivo.com>

[ Upstream commit 27dfaedc0d321b4ea4e10c53e4679d6911ab17aa ]

In function amdgpu_get_xgmi_hive, when kobject_init_and_add failed
There is a potential memleak if not call kobject_put.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 0526dec1d736e..042c85fc528bb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -358,6 +358,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)
 			"%s", "xgmi_hive_info");
 	if (ret) {
 		dev_err(adev->dev, "XGMI: failed initializing kobject for xgmi hive\n");
+		kobject_put(&hive->kobj);
 		kfree(hive);
 		hive = NULL;
 		goto pro_end;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 20/28] ata: ahci: Add Green Sardine vendor ID as board_ahci_mobile
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (17 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 19/28] drm/amd/amdgpu: fix potential memleak Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 21/28] ata: libahci: Adjust behavior when StorageD3Enable _DSD is set Sasha Levin
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Mario Limonciello, Nehal-bakulchandra Shah, Damien Le Moal,
	Sasha Levin, linux-ide

From: Mario Limonciello <mario.limonciello@amd.com>

[ Upstream commit 1527f69204fe35f341cb599f1cb01bd02daf4374 ]

AMD requires that the SATA controller be configured for devsleep in order
for S0i3 entry to work properly.

commit b1a9585cc396 ("ata: ahci: Enable DEVSLP by default on x86 with
SLP_S0") sets up a kernel policy to enable devsleep on Intel mobile
platforms that are using s0ix.  Add the PCI ID for the SATA controller in
Green Sardine platforms to extend this policy by default for AMD based
systems using s0i3 as well.

Cc: Nehal-bakulchandra Shah <Nehal-bakulchandra.Shah@amd.com>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214091
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/ata/ahci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 33192a8f687d6..ff2add0101fe5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -442,6 +442,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	/* AMD */
 	{ PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD Hudson-2 */
 	{ PCI_VDEVICE(AMD, 0x7900), board_ahci }, /* AMD CZ */
+	{ PCI_VDEVICE(AMD, 0x7901), board_ahci_mobile }, /* AMD Green Sardine */
 	/* AMD is using RAID class only for ahci controllers */
 	{ PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
 	  PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci },
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 21/28] ata: libahci: Adjust behavior when StorageD3Enable _DSD is set
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (18 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 20/28] ata: ahci: Add Green Sardine vendor ID as board_ahci_mobile Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 22/28] ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port() Sasha Levin
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Mario Limonciello, Nehal-bakulchandra Shah, Damien Le Moal,
	Sasha Levin, linux-ide

From: Mario Limonciello <mario.limonciello@amd.com>

[ Upstream commit 7c5f641a5914ce0303b06bcfcd7674ee64aeebe9 ]

The StorageD3Enable _DSD is used for the vendor to indicate that the disk
should be opted into or out of a different behavior based upon the platform
design.

For AMD's Renoir and Green Sardine platforms it's important that any
attached SATA storage has transitioned into DevSlp when s2idle is used.

If the disk is left in active/partial/slumber, then the system is not able
to resume properly.

When the StorageD3Enable _DSD is detected, check the system is using s2idle
and DevSlp is enabled and if so explicitly wait long enough for the disk to
enter DevSlp.

Cc: Nehal-bakulchandra Shah <Nehal-bakulchandra.Shah@amd.com>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214091
Link: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/power-management-for-storage-hardware-devices-intro
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/ata/libahci.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index fec2e9754aed2..d0d6efc9370d0 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -2304,6 +2304,18 @@ int ahci_port_resume(struct ata_port *ap)
 EXPORT_SYMBOL_GPL(ahci_port_resume);
 
 #ifdef CONFIG_PM
+static void ahci_handle_s2idle(struct ata_port *ap)
+{
+	void __iomem *port_mmio = ahci_port_base(ap);
+	u32 devslp;
+
+	if (pm_suspend_via_firmware())
+		return;
+	devslp = readl(port_mmio + PORT_DEVSLP);
+	if ((devslp & PORT_DEVSLP_ADSE))
+		ata_msleep(ap, devslp_idle_timeout);
+}
+
 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
 {
 	const char *emsg = NULL;
@@ -2317,6 +2329,9 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
 		ata_port_freeze(ap);
 	}
 
+	if (acpi_storage_d3(ap->host->dev))
+		ahci_handle_s2idle(ap);
+
 	ahci_rpm_put_port(ap);
 	return rc;
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 22/28] ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port()
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (19 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 21/28] ata: libahci: Adjust behavior when StorageD3Enable _DSD is set Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 23/28] ipv6: check return value of ipv6_skip_exthdr Sasha Levin
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Teng Qi, TOTE Robot, David S . Miller, Sasha Levin, yisen.zhuang,
	salil.mehta, kuba, huangguangbin2, lipeng321, zhengyongjun3,
	shenyang39, liuyonglong, netdev

From: Teng Qi <starmiku1207184332@gmail.com>

[ Upstream commit a66998e0fbf213d47d02813b9679426129d0d114 ]

The if statement:
  if (port >= DSAF_GE_NUM)
        return;

limits the value of port less than DSAF_GE_NUM (i.e., 8).
However, if the value of port is 6 or 7, an array overflow could occur:
  port_rst_off = dsaf_dev->mac_cb[port]->port_rst_off;

because the length of dsaf_dev->mac_cb is DSAF_MAX_PORT_NUM (i.e., 6).

To fix this possible array overflow, we first check port and if it is
greater than or equal to DSAF_MAX_PORT_NUM, the function returns.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Teng Qi <starmiku1207184332@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
index a9aca8c24e90d..aa87e4d121532 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
@@ -400,6 +400,10 @@ static void hns_dsaf_ge_srst_by_port(struct dsaf_device *dsaf_dev, u32 port,
 		return;
 
 	if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) {
+		/* DSAF_MAX_PORT_NUM is 6, but DSAF_GE_NUM is 8.
+		   We need check to prevent array overflow */
+		if (port >= DSAF_MAX_PORT_NUM)
+			return;
 		reg_val_1  = 0x1 << port;
 		port_rst_off = dsaf_dev->mac_cb[port]->port_rst_off;
 		/* there is difference between V1 and V2 in register.*/
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 23/28] ipv6: check return value of ipv6_skip_exthdr
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (20 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 22/28] ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port() Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 24/28] net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound Sasha Levin
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Jordy Zomer, David S . Miller, Sasha Levin, steffen.klassert,
	yoshfuji, dsahern, kuba, netdev

From: Jordy Zomer <jordy@pwning.systems>

[ Upstream commit 5f9c55c8066bcd93ac25234a02585701fe2e31df ]

The offset value is used in pointer math on skb->data.
Since ipv6_skip_exthdr may return -1 the pointer to uh and th
may not point to the actual udp and tcp headers and potentially
overwrite other stuff. This is why I think this should be checked.

EDIT:  added {}'s, thanks Kees

Signed-off-by: Jordy Zomer <jordy@pwning.systems>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/esp6.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 8d001f665fb15..7f2ffc7b1f75a 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -808,6 +808,12 @@ int esp6_input_done2(struct sk_buff *skb, int err)
 		struct tcphdr *th;
 
 		offset = ipv6_skip_exthdr(skb, offset, &nexthdr, &frag_off);
+
+		if (offset < 0) {
+			err = -EINVAL;
+			goto out;
+		}
+
 		uh = (void *)(skb->data + offset);
 		th = (void *)(skb->data + offset);
 		hdr_len += offset;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 24/28] net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (21 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 23/28] ipv6: check return value of ipv6_skip_exthdr Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 25/28] net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock() Sasha Levin
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: zhangyue, David S . Miller, Sasha Levin, kuba, arnd, tanghui20,
	starmiku1207184332, netdev, linux-parisc

From: zhangyue <zhangyue1@kylinos.cn>

[ Upstream commit 61217be886b5f7402843677e4be7e7e83de9cb41 ]

In line 5001, if all id in the array 'lp->phy[8]' is not 0, when the
'for' end, the 'k' is 8.

At this time, the array 'lp->phy[8]' may be out of bound.

Signed-off-by: zhangyue <zhangyue1@kylinos.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/dec/tulip/de4x5.c | 30 +++++++++++++++-----------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
index 683e328b5461d..ffc25ecfa8d6a 100644
--- a/drivers/net/ethernet/dec/tulip/de4x5.c
+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
@@ -4997,19 +4997,23 @@ mii_get_phy(struct net_device *dev)
 	}
 	if ((j == limit) && (i < DE4X5_MAX_MII)) {
 	    for (k=0; k < DE4X5_MAX_PHY && lp->phy[k].id; k++);
-	    lp->phy[k].addr = i;
-	    lp->phy[k].id = id;
-	    lp->phy[k].spd.reg = GENERIC_REG;      /* ANLPA register         */
-	    lp->phy[k].spd.mask = GENERIC_MASK;    /* 100Mb/s technologies   */
-	    lp->phy[k].spd.value = GENERIC_VALUE;  /* TX & T4, H/F Duplex    */
-	    lp->mii_cnt++;
-	    lp->active++;
-	    printk("%s: Using generic MII device control. If the board doesn't operate,\nplease mail the following dump to the author:\n", dev->name);
-	    j = de4x5_debug;
-	    de4x5_debug |= DEBUG_MII;
-	    de4x5_dbg_mii(dev, k);
-	    de4x5_debug = j;
-	    printk("\n");
+	    if (k < DE4X5_MAX_PHY) {
+		lp->phy[k].addr = i;
+		lp->phy[k].id = id;
+		lp->phy[k].spd.reg = GENERIC_REG;      /* ANLPA register         */
+		lp->phy[k].spd.mask = GENERIC_MASK;    /* 100Mb/s technologies   */
+		lp->phy[k].spd.value = GENERIC_VALUE;  /* TX & T4, H/F Duplex    */
+		lp->mii_cnt++;
+		lp->active++;
+		printk("%s: Using generic MII device control. If the board doesn't operate,\nplease mail the following dump to the author:\n", dev->name);
+		j = de4x5_debug;
+		de4x5_debug |= DEBUG_MII;
+		de4x5_dbg_mii(dev, k);
+		de4x5_debug = j;
+		printk("\n");
+	    } else {
+		goto purgatory;
+	    }
 	}
     }
   purgatory:
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 25/28] net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock()
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (22 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 24/28] net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 26/28] perf inject: Fix ARM SPE handling Sasha Levin
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Teng Qi, TOTE Robot, Arnd Bergmann, David S . Miller,
	Sasha Levin, kuba, tanghui20, zhangyue1, netdev, linux-parisc

From: Teng Qi <starmiku1207184332@gmail.com>

[ Upstream commit 0fa68da72c3be09e06dd833258ee89c33374195f ]

The definition of macro MOTO_SROM_BUG is:
  #define MOTO_SROM_BUG    (lp->active == 8 && (get_unaligned_le32(
  dev->dev_addr) & 0x00ffffff) == 0x3e0008)

and the if statement
  if (MOTO_SROM_BUG) lp->active = 0;

using this macro indicates lp->active could be 8. If lp->active is 8 and
the second comparison of this macro is false. lp->active will remain 8 in:
  lp->phy[lp->active].gep = (*p ? p : NULL); p += (2 * (*p) + 1);
  lp->phy[lp->active].rst = (*p ? p : NULL); p += (2 * (*p) + 1);
  lp->phy[lp->active].mc  = get_unaligned_le16(p); p += 2;
  lp->phy[lp->active].ana = get_unaligned_le16(p); p += 2;
  lp->phy[lp->active].fdx = get_unaligned_le16(p); p += 2;
  lp->phy[lp->active].ttm = get_unaligned_le16(p); p += 2;
  lp->phy[lp->active].mci = *p;

However, the length of array lp->phy is 8, so array overflows can occur.
To fix these possible array overflows, we first check lp->active and then
return -EINVAL if it is greater or equal to ARRAY_SIZE(lp->phy) (i.e. 8).

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Teng Qi <starmiku1207184332@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/dec/tulip/de4x5.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
index ffc25ecfa8d6a..8edd394bc3358 100644
--- a/drivers/net/ethernet/dec/tulip/de4x5.c
+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
@@ -4706,6 +4706,10 @@ type3_infoblock(struct net_device *dev, u_char count, u_char *p)
         lp->ibn = 3;
         lp->active = *p++;
 	if (MOTO_SROM_BUG) lp->active = 0;
+	/* if (MOTO_SROM_BUG) statement indicates lp->active could
+	 * be 8 (i.e. the size of array lp->phy) */
+	if (WARN_ON(lp->active >= ARRAY_SIZE(lp->phy)))
+		return -EINVAL;
 	lp->phy[lp->active].gep = (*p ? p : NULL); p += (2 * (*p) + 1);
 	lp->phy[lp->active].rst = (*p ? p : NULL); p += (2 * (*p) + 1);
 	lp->phy[lp->active].mc  = get_unaligned_le16(p); p += 2;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 26/28] perf inject: Fix ARM SPE handling
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (23 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 25/28] net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock() Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 27/28] perf hist: Fix memory leak of a perf_hpp_fmt Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 28/28] perf report: Fix memory leaks around perf_tip() Sasha Levin
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: German Gomez, James Clark, Alexander Shishkin, Jiri Olsa,
	John Garry, Leo Yan, Mark Rutland, Mathieu Poirier, Namhyung Kim,
	Will Deacon, linux-arm-kernel, Arnaldo Carvalho de Melo,
	Sasha Levin, peterz, mingo, acme, andrew.kilroy,
	linux-perf-users

From: German Gomez <german.gomez@arm.com>

[ Upstream commit 9e1a8d9f683260d50e0a14176d3f7c46a93b2700 ]

'perf inject' is currently not working for Arm SPE. When you try to run
'perf inject' and 'perf report' with a perf.data file that contains SPE
traces, the tool reports a "Bad address" error:

  # ./perf record -e arm_spe_0/ts_enable=1,store_filter=1,branch_filter=1,load_filter=1/ -a -- sleep 1
  # ./perf inject -i perf.data -o perf.inject.data --itrace
  # ./perf report -i perf.inject.data --stdio

  0x42c00 [0x8]: failed to process type: 9 [Bad address]
  Error:
  failed to process sample

As far as I know, the issue was first spotted in [1], but 'perf inject'
was not yet injecting the samples. This patch does something similar to
what cs_etm does for injecting the samples [2], but for SPE.

[1] https://patchwork.kernel.org/project/linux-arm-kernel/cover/20210412091006.468557-1-leo.yan@linaro.org/#24117339
[2] https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/cs-etm.c?h=perf/core&id=133fe2e617e48ca0948983329f43877064ffda3e#n1196

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: German Gomez <german.gomez@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20211105104130.28186-2-german.gomez@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/util/arm-spe.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 3882a5360ada4..0350020acb96f 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -48,6 +48,7 @@ struct arm_spe {
 	u8				timeless_decoding;
 	u8				data_queued;
 
+	u64				sample_type;
 	u8				sample_flc;
 	u8				sample_llc;
 	u8				sample_tlb;
@@ -244,6 +245,12 @@ static void arm_spe_prep_sample(struct arm_spe *spe,
 	event->sample.header.size = sizeof(struct perf_event_header);
 }
 
+static int arm_spe__inject_event(union perf_event *event, struct perf_sample *sample, u64 type)
+{
+	event->header.size = perf_event__sample_event_size(sample, type, 0);
+	return perf_event__synthesize_sample(event, type, 0, sample);
+}
+
 static inline int
 arm_spe_deliver_synth_event(struct arm_spe *spe,
 			    struct arm_spe_queue *speq __maybe_unused,
@@ -252,6 +259,12 @@ arm_spe_deliver_synth_event(struct arm_spe *spe,
 {
 	int ret;
 
+	if (spe->synth_opts.inject) {
+		ret = arm_spe__inject_event(event, sample, spe->sample_type);
+		if (ret)
+			return ret;
+	}
+
 	ret = perf_session__deliver_synth_event(spe->session, event, sample);
 	if (ret)
 		pr_err("ARM SPE: failed to deliver event, error %d\n", ret);
@@ -809,6 +822,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)
 	else
 		attr.sample_type |= PERF_SAMPLE_TIME;
 
+	spe->sample_type = attr.sample_type;
+
 	attr.exclude_user = evsel->core.attr.exclude_user;
 	attr.exclude_kernel = evsel->core.attr.exclude_kernel;
 	attr.exclude_hv = evsel->core.attr.exclude_hv;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 27/28] perf hist: Fix memory leak of a perf_hpp_fmt
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (24 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 26/28] perf inject: Fix ARM SPE handling Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 28/28] perf report: Fix memory leaks around perf_tip() Sasha Levin
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Ian Rogers, Kajol Jain, Alexander Shishkin, Jiri Olsa,
	Mark Rutland, Namhyung Kim, Peter Zijlstra, Stephane Eranian,
	Arnaldo Carvalho de Melo, Sasha Levin, mingo, acme, kan.liang,
	ak, atrajeev, linux-perf-users

From: Ian Rogers <irogers@google.com>

[ Upstream commit 0ca1f534a776cc7d42f2c33da4732b74ec2790cd ]

perf_hpp__column_unregister() removes an entry from a list but doesn't
free the memory causing a memory leak spotted by leak sanitizer.

Add the free while at the same time reducing the scope of the function
to static.

Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20211118071247.2140392-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/ui/hist.c   | 28 ++++++++++++++--------------
 tools/perf/util/hist.h |  1 -
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index c1f24d0048527..5075ecead5f3d 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -535,6 +535,18 @@ struct perf_hpp_list perf_hpp_list = {
 #undef __HPP_SORT_ACC_FN
 #undef __HPP_SORT_RAW_FN
 
+static void fmt_free(struct perf_hpp_fmt *fmt)
+{
+	/*
+	 * At this point fmt should be completely
+	 * unhooked, if not it's a bug.
+	 */
+	BUG_ON(!list_empty(&fmt->list));
+	BUG_ON(!list_empty(&fmt->sort_list));
+
+	if (fmt->free)
+		fmt->free(fmt);
+}
 
 void perf_hpp__init(void)
 {
@@ -598,9 +610,10 @@ void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
 	list_add(&format->sort_list, &list->sorts);
 }
 
-void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
+static void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
 {
 	list_del_init(&format->list);
+	fmt_free(format);
 }
 
 void perf_hpp__cancel_cumulate(void)
@@ -672,19 +685,6 @@ void perf_hpp__append_sort_keys(struct perf_hpp_list *list)
 }
 
 
-static void fmt_free(struct perf_hpp_fmt *fmt)
-{
-	/*
-	 * At this point fmt should be completely
-	 * unhooked, if not it's a bug.
-	 */
-	BUG_ON(!list_empty(&fmt->list));
-	BUG_ON(!list_empty(&fmt->sort_list));
-
-	if (fmt->free)
-		fmt->free(fmt);
-}
-
 void perf_hpp__reset_output_field(struct perf_hpp_list *list)
 {
 	struct perf_hpp_fmt *fmt, *tmp;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 96b1c13bbccc5..919f2c6c48142 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -362,7 +362,6 @@ enum {
 };
 
 void perf_hpp__init(void);
-void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
 void perf_hpp__cancel_cumulate(void);
 void perf_hpp__setup_output_field(struct perf_hpp_list *list);
 void perf_hpp__reset_output_field(struct perf_hpp_list *list);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH AUTOSEL 5.10 28/28] perf report: Fix memory leaks around perf_tip()
  2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
                   ` (25 preceding siblings ...)
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 27/28] perf hist: Fix memory leak of a perf_hpp_fmt Sasha Levin
@ 2021-11-26  2:33 ` Sasha Levin
  26 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-11-26  2:33 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Ian Rogers, Alexander Shishkin, Jiri Olsa, Mark Rutland,
	Namhyung Kim, Peter Zijlstra, Stephane Eranian,
	Arnaldo Carvalho de Melo, Sasha Levin, mingo, acme,
	linux-perf-users

From: Ian Rogers <irogers@google.com>

[ Upstream commit d9fc706108c15f8bc2d4ccccf8e50f74830fabd9 ]

perf_tip() may allocate memory or use a literal, this means memory
wasn't freed if allocated. Change the API so that literals aren't used.

At the same time add missing frees for system_path. These issues were
spotted using leak sanitizer.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20211118073804.2149974-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/builtin-report.c | 15 +++++++++------
 tools/perf/util/util.c      | 14 +++++++-------
 tools/perf/util/util.h      |  2 +-
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 5824aa24acfcc..91cab5cdfbc16 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -610,14 +610,17 @@ static int report__browse_hists(struct report *rep)
 	int ret;
 	struct perf_session *session = rep->session;
 	struct evlist *evlist = session->evlist;
-	const char *help = perf_tip(system_path(TIPDIR));
+	char *help = NULL, *path = NULL;
 
-	if (help == NULL) {
+	path = system_path(TIPDIR);
+	if (perf_tip(&help, path) || help == NULL) {
 		/* fallback for people who don't install perf ;-) */
-		help = perf_tip(DOCDIR);
-		if (help == NULL)
-			help = "Cannot load tips.txt file, please install perf!";
+		free(path);
+		path = system_path(DOCDIR);
+		if (perf_tip(&help, path) || help == NULL)
+			help = strdup("Cannot load tips.txt file, please install perf!");
 	}
+	free(path);
 
 	switch (use_browser) {
 	case 1:
@@ -644,7 +647,7 @@ static int report__browse_hists(struct report *rep)
 		ret = perf_evlist__tty_browse_hists(evlist, rep, help);
 		break;
 	}
-
+	free(help);
 	return ret;
 }
 
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 37a9492edb3eb..df3c4671be72a 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -379,32 +379,32 @@ fetch_kernel_version(unsigned int *puint, char *str,
 	return 0;
 }
 
-const char *perf_tip(const char *dirpath)
+int perf_tip(char **strp, const char *dirpath)
 {
 	struct strlist *tips;
 	struct str_node *node;
-	char *tip = NULL;
 	struct strlist_config conf = {
 		.dirname = dirpath,
 		.file_only = true,
 	};
+	int ret = 0;
 
+	*strp = NULL;
 	tips = strlist__new("tips.txt", &conf);
 	if (tips == NULL)
-		return errno == ENOENT ? NULL :
-			"Tip: check path of tips.txt or get more memory! ;-p";
+		return -errno;
 
 	if (strlist__nr_entries(tips) == 0)
 		goto out;
 
 	node = strlist__entry(tips, random() % strlist__nr_entries(tips));
-	if (asprintf(&tip, "Tip: %s", node->s) < 0)
-		tip = (char *)"Tip: get more memory! ;-)";
+	if (asprintf(strp, "Tip: %s", node->s) < 0)
+		ret = -ENOMEM;
 
 out:
 	strlist__delete(tips);
 
-	return tip;
+	return ret;
 }
 
 char *perf_exe(char *buf, int len)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index ad737052e5977..9f0d36ba77f2d 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -39,7 +39,7 @@ int fetch_kernel_version(unsigned int *puint,
 #define KVER_FMT	"%d.%d.%d"
 #define KVER_PARAM(x)	KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)
 
-const char *perf_tip(const char *dirpath);
+int perf_tip(char **strp, const char *dirpath);
 
 #ifndef HAVE_SCHED_GETCPU_SUPPORT
 int sched_getcpu(void);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* RE: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI
  2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI Sasha Levin
@ 2021-11-29 14:47   ` Limonciello, Mario
  2021-11-29 18:53     ` Limonciello, Mario
  0 siblings, 1 reply; 31+ messages in thread
From: Limonciello, Mario @ 2021-11-29 14:47 UTC (permalink / raw)
  To: Sasha Levin, linux-kernel, stable
  Cc: Joerie de Gram, Natikar, Basavaraj, Linus Walleij, S-k,
	Shyam-sundar, linux-gpio



> -----Original Message-----
> From: Sasha Levin <sashal@kernel.org>
> Sent: Thursday, November 25, 2021 20:33
> To: linux-kernel@vger.kernel.org; stable@vger.kernel.org
> Cc: Limonciello, Mario <Mario.Limonciello@amd.com>; Joerie de Gram
> <j.de.gram@gmail.com>; Natikar, Basavaraj <Basavaraj.Natikar@amd.com>;
> Linus Walleij <linus.walleij@linaro.org>; Sasha Levin <sashal@kernel.org>; S-
> k, Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-
> gpio@vger.kernel.org
> Subject: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is
> shared with SCI
> 
> From: Mario Limonciello <mario.limonciello@amd.com>
> 
> [ Upstream commit 2d54067fcd23aae61e23508425ae5b29e973573d ]
> 
> On some Lenovo AMD Gen2 platforms the IRQ for the SCI and pinctrl drivers
> are shared.  Due to how the s2idle loop handling works, this case needs
> an extra explicit check whether the interrupt was caused by SCI or by
> the GPIO controller.
> 
> To fix this rework the existing IRQ handler function to function as a
> checker and an IRQ handler depending on the calling arguments.
> 
> BugLink:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
> b.freedesktop.org%2Fdrm%2Famd%2F-
> %2Fissues%2F1738&amp;data=04%7C01%7Cmario.limonciello%40amd.com%
> 7Ce14b7ddf8d1143b6649208d9b0853519%7C3dd8961fe4884e608e11a82d994
> e183d%7C0%7C0%7C637734908448086367%7CUnknown%7CTWFpbGZsb3d8
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> D%7C3000&amp;sdata=BHHY3gLu2pQIJ1nvSE0VNQOaioTC0QdBM44ze3HXrtk
> %3D&amp;reserved=0
> Reported-by: Joerie de Gram <j.de.gram@gmail.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> Link:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Fr%2F20211101014853.6177-2-
> mario.limonciello%40amd.com&amp;data=04%7C01%7Cmario.limonciello%4
> 0amd.com%7Ce14b7ddf8d1143b6649208d9b0853519%7C3dd8961fe4884e608
> e11a82d994e183d%7C0%7C0%7C637734908448086367%7CUnknown%7CTWF
> pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV
> CI6Mn0%3D%7C3000&amp;sdata=zUkTF851CdUmrY1z3YZbYrnVrjHQaVfb1%
> 2Bg2dx28ZNA%3D&amp;reserved=0
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/pinctrl/pinctrl-amd.c | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
> index e20bcc835d6a8..54dfa0244422c 100644
> --- a/drivers/pinctrl/pinctrl-amd.c
> +++ b/drivers/pinctrl/pinctrl-amd.c
> @@ -520,14 +520,14 @@ static struct irq_chip amd_gpio_irqchip = {
> 
>  #define PIN_IRQ_PENDING	(BIT(INTERRUPT_STS_OFF) |
> BIT(WAKE_STS_OFF))
> 
> -static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
> +static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
>  {
>  	struct amd_gpio *gpio_dev = dev_id;
>  	struct gpio_chip *gc = &gpio_dev->gc;
> -	irqreturn_t ret = IRQ_NONE;
>  	unsigned int i, irqnr;
>  	unsigned long flags;
>  	u32 __iomem *regs;
> +	bool ret = false;
>  	u32  regval;
>  	u64 status, mask;
> 
> @@ -549,6 +549,14 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void
> *dev_id)
>  		/* Each status bit covers four pins */
>  		for (i = 0; i < 4; i++) {
>  			regval = readl(regs + i);
> +			/* caused wake on resume context for shared IRQ */
> +			if (irq < 0 && (regval & BIT(WAKE_STS_OFF))) {
> +				dev_dbg(&gpio_dev->pdev->dev,
> +					"Waking due to GPIO %d: 0x%x",
> +					irqnr + i, regval);
> +				return true;
> +			}
> +
>  			if (!(regval & PIN_IRQ_PENDING) ||
>  			    !(regval & BIT(INTERRUPT_MASK_OFF)))
>  				continue;
> @@ -574,9 +582,12 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void
> *dev_id)
>  			}
>  			writel(regval, regs + i);
>  			raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
> -			ret = IRQ_HANDLED;
> +			ret = true;
>  		}
>  	}
> +	/* did not cause wake on resume context for shared IRQ */
> +	if (irq < 0)
> +		return false;
> 
>  	/* Signal EOI to the GPIO unit */
>  	raw_spin_lock_irqsave(&gpio_dev->lock, flags);
> @@ -588,6 +599,16 @@ static irqreturn_t amd_gpio_irq_handler(int irq, void
> *dev_id)
>  	return ret;
>  }
> 
> +static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
> +{
> +	return IRQ_RETVAL(do_amd_gpio_irq_handler(irq, dev_id));
> +}
> +
> +static bool __maybe_unused amd_gpio_check_wake(void *dev_id)
> +{
> +	return do_amd_gpio_irq_handler(-1, dev_id);
> +}
> +
>  static int amd_get_groups_count(struct pinctrl_dev *pctldev)
>  {
>  	struct amd_gpio *gpio_dev = pinctrl_dev_get_drvdata(pctldev);
> @@ -958,6 +979,7 @@ static int amd_gpio_probe(struct platform_device
> *pdev)
>  		goto out2;
> 
>  	platform_set_drvdata(pdev, gpio_dev);
> +	acpi_register_wakeup_handler(gpio_dev->irq,
> amd_gpio_check_wake, gpio_dev);
> 
>  	dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
>  	return ret;
> @@ -975,6 +997,7 @@ static int amd_gpio_remove(struct platform_device
> *pdev)
>  	gpio_dev = platform_get_drvdata(pdev);
> 
>  	gpiochip_remove(&gpio_dev->gc);
> +	acpi_unregister_wakeup_handler(amd_gpio_check_wake,
> gpio_dev);
> 
>  	return 0;
>  }
> --
> 2.33.0

Sasha,

No concerns for me to 5.10, but would you mind also sending this to 5.14.y and 5.15.y too?  I didn't see it sent up for either.

Thanks,

^ permalink raw reply	[flat|nested] 31+ messages in thread

* RE: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI
  2021-11-29 14:47   ` Limonciello, Mario
@ 2021-11-29 18:53     ` Limonciello, Mario
  2021-12-03 18:25       ` Sasha Levin
  0 siblings, 1 reply; 31+ messages in thread
From: Limonciello, Mario @ 2021-11-29 18:53 UTC (permalink / raw)
  To: Sasha Levin, linux-kernel, stable
  Cc: Joerie de Gram, Natikar, Basavaraj, Linus Walleij, S-k,
	Shyam-sundar, linux-gpio



> -----Original Message-----
> From: Limonciello, Mario
> Sent: Monday, November 29, 2021 08:48
> To: Sasha Levin <sashal@kernel.org>; linux-kernel@vger.kernel.org;
> stable@vger.kernel.org
> Cc: Joerie de Gram <j.de.gram@gmail.com>; Natikar, Basavaraj
> <Basavaraj.Natikar@amd.com>; Linus Walleij <linus.walleij@linaro.org>; S-k,
> Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-gpio@vger.kernel.org
> Subject: RE: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ
> is shared with SCI
> 
> 
> 
> > -----Original Message-----
> > From: Sasha Levin <sashal@kernel.org>
> > Sent: Thursday, November 25, 2021 20:33
> > To: linux-kernel@vger.kernel.org; stable@vger.kernel.org
> > Cc: Limonciello, Mario <Mario.Limonciello@amd.com>; Joerie de Gram
> > <j.de.gram@gmail.com>; Natikar, Basavaraj
> <Basavaraj.Natikar@amd.com>;
> > Linus Walleij <linus.walleij@linaro.org>; Sasha Levin <sashal@kernel.org>;
> S-
> > k, Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-
> > gpio@vger.kernel.org
> > Subject: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ
> is
> > shared with SCI
> >
> > From: Mario Limonciello <mario.limonciello@amd.com>
> >
> > [ Upstream commit 2d54067fcd23aae61e23508425ae5b29e973573d ]
> >
> > On some Lenovo AMD Gen2 platforms the IRQ for the SCI and pinctrl
> drivers
> > are shared.  Due to how the s2idle loop handling works, this case needs
> > an extra explicit check whether the interrupt was caused by SCI or by
> > the GPIO controller.
> >
> > To fix this rework the existing IRQ handler function to function as a
> > checker and an IRQ handler depending on the calling arguments.
> >
> > BugLink:
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
> > b.freedesktop.org%2Fdrm%2Famd%2F-
> >
> %2Fissues%2F1738&amp;data=04%7C01%7Cmario.limonciello%40amd.com%
> >
> 7Ce14b7ddf8d1143b6649208d9b0853519%7C3dd8961fe4884e608e11a82d994
> >
> e183d%7C0%7C0%7C637734908448086367%7CUnknown%7CTWFpbGZsb3d8
> >
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> >
> D%7C3000&amp;sdata=BHHY3gLu2pQIJ1nvSE0VNQOaioTC0QdBM44ze3HXrtk
> > %3D&amp;reserved=0
> > Reported-by: Joerie de Gram <j.de.gram@gmail.com>
> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> > Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> > Link:
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> > kernel.org%2Fr%2F20211101014853.6177-2-
> >
> mario.limonciello%40amd.com&amp;data=04%7C01%7Cmario.limonciello%4
> >
> 0amd.com%7Ce14b7ddf8d1143b6649208d9b0853519%7C3dd8961fe4884e608
> >
> e11a82d994e183d%7C0%7C0%7C637734908448086367%7CUnknown%7CTWF
> >
> pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV
> >
> CI6Mn0%3D%7C3000&amp;sdata=zUkTF851CdUmrY1z3YZbYrnVrjHQaVfb1%
> > 2Bg2dx28ZNA%3D&amp;reserved=0
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: Sasha Levin <sashal@kernel.org>
> > ---
> >  drivers/pinctrl/pinctrl-amd.c | 29 ++++++++++++++++++++++++++---
> >  1 file changed, 26 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
> > index e20bcc835d6a8..54dfa0244422c 100644
> > --- a/drivers/pinctrl/pinctrl-amd.c
> > +++ b/drivers/pinctrl/pinctrl-amd.c
> > @@ -520,14 +520,14 @@ static struct irq_chip amd_gpio_irqchip = {
> >
> >  #define PIN_IRQ_PENDING	(BIT(INTERRUPT_STS_OFF) |
> > BIT(WAKE_STS_OFF))
> >
> > -static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
> > +static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
> >  {
> >  	struct amd_gpio *gpio_dev = dev_id;
> >  	struct gpio_chip *gc = &gpio_dev->gc;
> > -	irqreturn_t ret = IRQ_NONE;
> >  	unsigned int i, irqnr;
> >  	unsigned long flags;
> >  	u32 __iomem *regs;
> > +	bool ret = false;
> >  	u32  regval;
> >  	u64 status, mask;
> >
> > @@ -549,6 +549,14 @@ static irqreturn_t amd_gpio_irq_handler(int irq,
> void
> > *dev_id)
> >  		/* Each status bit covers four pins */
> >  		for (i = 0; i < 4; i++) {
> >  			regval = readl(regs + i);
> > +			/* caused wake on resume context for shared IRQ */
> > +			if (irq < 0 && (regval & BIT(WAKE_STS_OFF))) {
> > +				dev_dbg(&gpio_dev->pdev->dev,
> > +					"Waking due to GPIO %d: 0x%x",
> > +					irqnr + i, regval);
> > +				return true;
> > +			}
> > +
> >  			if (!(regval & PIN_IRQ_PENDING) ||
> >  			    !(regval & BIT(INTERRUPT_MASK_OFF)))
> >  				continue;
> > @@ -574,9 +582,12 @@ static irqreturn_t amd_gpio_irq_handler(int irq,
> void
> > *dev_id)
> >  			}
> >  			writel(regval, regs + i);
> >  			raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
> > -			ret = IRQ_HANDLED;
> > +			ret = true;
> >  		}
> >  	}
> > +	/* did not cause wake on resume context for shared IRQ */
> > +	if (irq < 0)
> > +		return false;
> >
> >  	/* Signal EOI to the GPIO unit */
> >  	raw_spin_lock_irqsave(&gpio_dev->lock, flags);
> > @@ -588,6 +599,16 @@ static irqreturn_t amd_gpio_irq_handler(int irq,
> void
> > *dev_id)
> >  	return ret;
> >  }
> >
> > +static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
> > +{
> > +	return IRQ_RETVAL(do_amd_gpio_irq_handler(irq, dev_id));
> > +}
> > +
> > +static bool __maybe_unused amd_gpio_check_wake(void *dev_id)
> > +{
> > +	return do_amd_gpio_irq_handler(-1, dev_id);
> > +}
> > +
> >  static int amd_get_groups_count(struct pinctrl_dev *pctldev)
> >  {
> >  	struct amd_gpio *gpio_dev = pinctrl_dev_get_drvdata(pctldev);
> > @@ -958,6 +979,7 @@ static int amd_gpio_probe(struct platform_device
> > *pdev)
> >  		goto out2;
> >
> >  	platform_set_drvdata(pdev, gpio_dev);
> > +	acpi_register_wakeup_handler(gpio_dev->irq,
> > amd_gpio_check_wake, gpio_dev);
> >
> >  	dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
> >  	return ret;
> > @@ -975,6 +997,7 @@ static int amd_gpio_remove(struct platform_device
> > *pdev)
> >  	gpio_dev = platform_get_drvdata(pdev);
> >
> >  	gpiochip_remove(&gpio_dev->gc);
> > +	acpi_unregister_wakeup_handler(amd_gpio_check_wake,
> > gpio_dev);
> >
> >  	return 0;
> >  }
> > --
> > 2.33.0
> 
> Sasha,
> 
> No concerns for me to 5.10, but would you mind also sending this to 5.14.y
> and 5.15.y too?  I didn't see it sent up for either.

One more thought on this - please also take this (which wasn't part of autosel)
when this comes back:

e9380df85187 ACPI: Add stubs for wakeup handler functions

That prevents some compile errors in certain configurations.

> 
> Thanks,

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI
  2021-11-29 18:53     ` Limonciello, Mario
@ 2021-12-03 18:25       ` Sasha Levin
  0 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2021-12-03 18:25 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: linux-kernel, stable, Joerie de Gram, Natikar, Basavaraj,
	Linus Walleij, S-k, Shyam-sundar, linux-gpio

On Mon, Nov 29, 2021 at 06:53:01PM +0000, Limonciello, Mario wrote:
>
>
>> -----Original Message-----
>> From: Limonciello, Mario
>> Sent: Monday, November 29, 2021 08:48
>> To: Sasha Levin <sashal@kernel.org>; linux-kernel@vger.kernel.org;
>> stable@vger.kernel.org
>> Cc: Joerie de Gram <j.de.gram@gmail.com>; Natikar, Basavaraj
>> <Basavaraj.Natikar@amd.com>; Linus Walleij <linus.walleij@linaro.org>; S-k,
>> Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-gpio@vger.kernel.org
>> Subject: RE: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ
>> is shared with SCI
>>
>>
>>
>> > -----Original Message-----
>> > From: Sasha Levin <sashal@kernel.org>
>> > Sent: Thursday, November 25, 2021 20:33
>> > To: linux-kernel@vger.kernel.org; stable@vger.kernel.org
>> > Cc: Limonciello, Mario <Mario.Limonciello@amd.com>; Joerie de Gram
>> > <j.de.gram@gmail.com>; Natikar, Basavaraj
>> <Basavaraj.Natikar@amd.com>;
>> > Linus Walleij <linus.walleij@linaro.org>; Sasha Levin <sashal@kernel.org>;
>> S-
>> > k, Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-
>> > gpio@vger.kernel.org
>> > Subject: [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ
>> is
>> > shared with SCI
>> >
>> > From: Mario Limonciello <mario.limonciello@amd.com>
>> >
>> > [ Upstream commit 2d54067fcd23aae61e23508425ae5b29e973573d ]
>> >
>> > On some Lenovo AMD Gen2 platforms the IRQ for the SCI and pinctrl
>> drivers
>> > are shared.  Due to how the s2idle loop handling works, this case needs
>> > an extra explicit check whether the interrupt was caused by SCI or by
>> > the GPIO controller.
>> >
>> > To fix this rework the existing IRQ handler function to function as a
>> > checker and an IRQ handler depending on the calling arguments.
>> >
>> > BugLink:
>> >
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
>> > b.freedesktop.org%2Fdrm%2Famd%2F-
>> >
>> %2Fissues%2F1738&amp;data=04%7C01%7Cmario.limonciello%40amd.com%
>> >
>> 7Ce14b7ddf8d1143b6649208d9b0853519%7C3dd8961fe4884e608e11a82d994
>> >
>> e183d%7C0%7C0%7C637734908448086367%7CUnknown%7CTWFpbGZsb3d8
>> >
>> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
>> >
>> D%7C3000&amp;sdata=BHHY3gLu2pQIJ1nvSE0VNQOaioTC0QdBM44ze3HXrtk
>> > %3D&amp;reserved=0
>> > Reported-by: Joerie de Gram <j.de.gram@gmail.com>
>> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> > Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
>> > Link:
>> >
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
>> > kernel.org%2Fr%2F20211101014853.6177-2-
>> >
>> mario.limonciello%40amd.com&amp;data=04%7C01%7Cmario.limonciello%4
>> >
>> 0amd.com%7Ce14b7ddf8d1143b6649208d9b0853519%7C3dd8961fe4884e608
>> >
>> e11a82d994e183d%7C0%7C0%7C637734908448086367%7CUnknown%7CTWF
>> >
>> pbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV
>> >
>> CI6Mn0%3D%7C3000&amp;sdata=zUkTF851CdUmrY1z3YZbYrnVrjHQaVfb1%
>> > 2Bg2dx28ZNA%3D&amp;reserved=0
>> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> > Signed-off-by: Sasha Levin <sashal@kernel.org>
>> > ---
>> >  drivers/pinctrl/pinctrl-amd.c | 29 ++++++++++++++++++++++++++---
>> >  1 file changed, 26 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
>> > index e20bcc835d6a8..54dfa0244422c 100644
>> > --- a/drivers/pinctrl/pinctrl-amd.c
>> > +++ b/drivers/pinctrl/pinctrl-amd.c
>> > @@ -520,14 +520,14 @@ static struct irq_chip amd_gpio_irqchip = {
>> >
>> >  #define PIN_IRQ_PENDING	(BIT(INTERRUPT_STS_OFF) |
>> > BIT(WAKE_STS_OFF))
>> >
>> > -static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
>> > +static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
>> >  {
>> >  	struct amd_gpio *gpio_dev = dev_id;
>> >  	struct gpio_chip *gc = &gpio_dev->gc;
>> > -	irqreturn_t ret = IRQ_NONE;
>> >  	unsigned int i, irqnr;
>> >  	unsigned long flags;
>> >  	u32 __iomem *regs;
>> > +	bool ret = false;
>> >  	u32  regval;
>> >  	u64 status, mask;
>> >
>> > @@ -549,6 +549,14 @@ static irqreturn_t amd_gpio_irq_handler(int irq,
>> void
>> > *dev_id)
>> >  		/* Each status bit covers four pins */
>> >  		for (i = 0; i < 4; i++) {
>> >  			regval = readl(regs + i);
>> > +			/* caused wake on resume context for shared IRQ */
>> > +			if (irq < 0 && (regval & BIT(WAKE_STS_OFF))) {
>> > +				dev_dbg(&gpio_dev->pdev->dev,
>> > +					"Waking due to GPIO %d: 0x%x",
>> > +					irqnr + i, regval);
>> > +				return true;
>> > +			}
>> > +
>> >  			if (!(regval & PIN_IRQ_PENDING) ||
>> >  			    !(regval & BIT(INTERRUPT_MASK_OFF)))
>> >  				continue;
>> > @@ -574,9 +582,12 @@ static irqreturn_t amd_gpio_irq_handler(int irq,
>> void
>> > *dev_id)
>> >  			}
>> >  			writel(regval, regs + i);
>> >  			raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
>> > -			ret = IRQ_HANDLED;
>> > +			ret = true;
>> >  		}
>> >  	}
>> > +	/* did not cause wake on resume context for shared IRQ */
>> > +	if (irq < 0)
>> > +		return false;
>> >
>> >  	/* Signal EOI to the GPIO unit */
>> >  	raw_spin_lock_irqsave(&gpio_dev->lock, flags);
>> > @@ -588,6 +599,16 @@ static irqreturn_t amd_gpio_irq_handler(int irq,
>> void
>> > *dev_id)
>> >  	return ret;
>> >  }
>> >
>> > +static irqreturn_t amd_gpio_irq_handler(int irq, void *dev_id)
>> > +{
>> > +	return IRQ_RETVAL(do_amd_gpio_irq_handler(irq, dev_id));
>> > +}
>> > +
>> > +static bool __maybe_unused amd_gpio_check_wake(void *dev_id)
>> > +{
>> > +	return do_amd_gpio_irq_handler(-1, dev_id);
>> > +}
>> > +
>> >  static int amd_get_groups_count(struct pinctrl_dev *pctldev)
>> >  {
>> >  	struct amd_gpio *gpio_dev = pinctrl_dev_get_drvdata(pctldev);
>> > @@ -958,6 +979,7 @@ static int amd_gpio_probe(struct platform_device
>> > *pdev)
>> >  		goto out2;
>> >
>> >  	platform_set_drvdata(pdev, gpio_dev);
>> > +	acpi_register_wakeup_handler(gpio_dev->irq,
>> > amd_gpio_check_wake, gpio_dev);
>> >
>> >  	dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
>> >  	return ret;
>> > @@ -975,6 +997,7 @@ static int amd_gpio_remove(struct platform_device
>> > *pdev)
>> >  	gpio_dev = platform_get_drvdata(pdev);
>> >
>> >  	gpiochip_remove(&gpio_dev->gc);
>> > +	acpi_unregister_wakeup_handler(amd_gpio_check_wake,
>> > gpio_dev);
>> >
>> >  	return 0;
>> >  }
>> > --
>> > 2.33.0
>>
>> Sasha,
>>
>> No concerns for me to 5.10, but would you mind also sending this to 5.14.y
>> and 5.15.y too?  I didn't see it sent up for either.

5.14 was EOL at that time.

>One more thought on this - please also take this (which wasn't part of autosel)
>when this comes back:
>
>e9380df85187 ACPI: Add stubs for wakeup handler functions
>
>That prevents some compile errors in certain configurations.

I'll grab it, thanks!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2021-12-03 18:25 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26  2:33 [PATCH AUTOSEL 5.10 01/28] gfs2: release iopen glock early in evict Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 02/28] gfs2: Fix length of holes reported at end-of-file Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 03/28] powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory" Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 04/28] drm/sun4i: fix unmet dependency on RESET_CONTROLLER for PHY_SUN6I_MIPI_DPHY Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 05/28] mac80211: do not access the IV when it was stripped Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 06/28] tun: fix bonding active backup with arp monitoring Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 07/28] net/smc: Transfer remaining wait queue entries during fallback Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 08/28] atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_wait Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 09/28] net: return correct error code Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 10/28] pinctrl: amd: Fix wakeups when IRQ is shared with SCI Sasha Levin
2021-11-29 14:47   ` Limonciello, Mario
2021-11-29 18:53     ` Limonciello, Mario
2021-12-03 18:25       ` Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 11/28] pinctrl: qcom: fix unmet dependencies on GPIOLIB for GPIOLIB_IRQCHIP Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 12/28] platform/x86: thinkpad_acpi: Add support for dual fan control Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 13/28] platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 14/28] s390/setup: avoid using memblock_enforce_memory_limit Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 15/28] btrfs: check-integrity: fix a warning on write caching disabled disk Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 16/28] thermal: core: Reset previous low and high trip during thermal zone init Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 17/28] scsi: iscsi: Unblock session then wake up error handler Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 18/28] drm/amd/amdkfd: Fix kernel panic when reset failed and been triggered again Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 19/28] drm/amd/amdgpu: fix potential memleak Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 20/28] ata: ahci: Add Green Sardine vendor ID as board_ahci_mobile Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 21/28] ata: libahci: Adjust behavior when StorageD3Enable _DSD is set Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 22/28] ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port() Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 23/28] ipv6: check return value of ipv6_skip_exthdr Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 24/28] net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 25/28] net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock() Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 26/28] perf inject: Fix ARM SPE handling Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 27/28] perf hist: Fix memory leak of a perf_hpp_fmt Sasha Levin
2021-11-26  2:33 ` [PATCH AUTOSEL 5.10 28/28] perf report: Fix memory leaks around perf_tip() Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).