public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.15 09/23] scsi: ufs: core: Reduce the power mode change timeout
       [not found] <20220830172141.581086-1-sashal@kernel.org>
@ 2022-08-30 17:21 ` Sasha Levin
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 13/23] arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level Sasha Levin
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames Sasha Levin
  2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2022-08-30 17:21 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Bart Van Assche, Stanley Chu, Martin K . Petersen, Sasha Levin,
	jejb, matthias.bgg, beanhuo, avri.altman, adrian.hunter,
	j-young.choi, linux-scsi, linux-arm-kernel, linux-mediatek

From: Bart Van Assche <bvanassche@acm.org>

[ Upstream commit 8f2c96420c6ec3dcb18c8be923e24c6feaa5ccf6 ]

The current power mode change timeout (180 s) is so large that it can cause
a watchdog timer to fire. Reduce the power mode change timeout to 10
seconds.

Link: https://lore.kernel.org/r/20220811234401.1957911-1-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/ufs/ufshcd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 2f6468f22b489..dae1a85f1512c 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8476,6 +8476,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	struct scsi_device *sdp;
 	unsigned long flags;
 	int ret, retries;
+	unsigned long deadline;
+	int32_t remaining;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
 	sdp = hba->sdev_ufs_device;
@@ -8508,9 +8510,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 	 * callbacks hence set the RQF_PM flag so that it doesn't resume the
 	 * already suspended childs.
 	 */
+	deadline = jiffies + 10 * HZ;
 	for (retries = 3; retries > 0; --retries) {
+		ret = -ETIMEDOUT;
+		remaining = deadline - jiffies;
+		if (remaining <= 0)
+			break;
 		ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
-				START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL);
+				   remaining / HZ, 0, 0, RQF_PM, NULL);
 		if (!scsi_status_is_check_condition(ret) ||
 				!scsi_sense_valid(&sshdr) ||
 				sshdr.sense_key != UNIT_ATTENTION)
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH AUTOSEL 5.15 13/23] arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level
       [not found] <20220830172141.581086-1-sashal@kernel.org>
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 09/23] scsi: ufs: core: Reduce the power mode change timeout Sasha Levin
@ 2022-08-30 17:21 ` Sasha Levin
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames Sasha Levin
  2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2022-08-30 17:21 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Sudeep Holla, Bruno Goncalves, Will Deacon, Sasha Levin,
	catalin.marinas, peterz, tglx, linux-arm-kernel

From: Sudeep Holla <sudeep.holla@arm.com>

[ Upstream commit e75d18cecbb3805895d8ed64da4f78575ec96043 ]

Though acpi_find_last_cache_level() always returned signed value and the
document states it will return any errors caused by lack of a PPTT table,
it never returned negative values before.

Commit 0c80f9e165f8 ("ACPI: PPTT: Leave the table mapped for the runtime usage")
however changed it by returning -ENOENT if no PPTT was found. The value
returned from acpi_find_last_cache_level() is then assigned to unsigned
fw_level.

It will result in the number of cache leaves calculated incorrectly as
a huge value which will then cause the following warning from __alloc_pages
as the order would be great than MAX_ORDER because of incorrect and huge
cache leaves value.

  |  WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:5407 __alloc_pages+0x74/0x314
  |  Modules linked in:
  |  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-10393-g7c2a8d3ac4c0 #73
  |  pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  |  pc : __alloc_pages+0x74/0x314
  |  lr : alloc_pages+0xe8/0x318
  |  Call trace:
  |   __alloc_pages+0x74/0x314
  |   alloc_pages+0xe8/0x318
  |   kmalloc_order_trace+0x68/0x1dc
  |   __kmalloc+0x240/0x338
  |   detect_cache_attributes+0xe0/0x56c
  |   update_siblings_masks+0x38/0x284
  |   store_cpu_topology+0x78/0x84
  |   smp_prepare_cpus+0x48/0x134
  |   kernel_init_freeable+0xc4/0x14c
  |   kernel_init+0x2c/0x1b4
  |   ret_from_fork+0x10/0x20

Fix the same by changing fw_level to be signed integer and return the
error from init_cache_level() early in case of error.

Reported-and-Tested-by: Bruno Goncalves <bgoncalv@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Link: https://lore.kernel.org/r/20220808084640.3165368-1-sudeep.holla@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/kernel/cacheinfo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c
index 587543c6c51cb..97c42be71338a 100644
--- a/arch/arm64/kernel/cacheinfo.c
+++ b/arch/arm64/kernel/cacheinfo.c
@@ -45,7 +45,8 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
 
 int init_cache_level(unsigned int cpu)
 {
-	unsigned int ctype, level, leaves, fw_level;
+	unsigned int ctype, level, leaves;
+	int fw_level;
 	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 
 	for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) {
@@ -63,6 +64,9 @@ int init_cache_level(unsigned int cpu)
 	else
 		fw_level = acpi_find_last_cache_level(cpu);
 
+	if (fw_level < 0)
+		return fw_level;
+
 	if (level < fw_level) {
 		/*
 		 * some external caches not specified in CLIDR_EL1
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames
       [not found] <20220830172141.581086-1-sashal@kernel.org>
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 09/23] scsi: ufs: core: Reduce the power mode change timeout Sasha Levin
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 13/23] arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level Sasha Levin
@ 2022-08-30 17:21 ` Sasha Levin
  2022-08-30 17:58   ` Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2022-08-30 17:21 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Mark Brown, Catalin Marinas, Will Deacon, Sasha Levin, seanjc,
	mark.rutland, elver, david.engraf, linux-arm-kernel

From: Mark Brown <broonie@kernel.org>

[ Upstream commit 7ddcaf78e93c9282b4d92184f511b4d5bee75355 ]

The signal code has a limit of 64K on the size of a stack frame that it
will generate, if this limit is exceeded then a process will be killed if
it receives a signal. Unfortunately with the advent of SME this limit is
too small - the maximum possible size of the ZA register alone is 64K. This
is not an issue for practical systems at present but is easily seen using
virtual platforms.

Raise the limit to 256K, this is substantially more than could be used by
any current architecture extension.

Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20220817182324.638214-2-broonie@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index b3e1beccf4588..8fdb89afd2b85 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -91,7 +91,7 @@ static size_t sigframe_size(struct rt_sigframe_user_layout const *user)
  * not taken into account.  This limit is not a guarantee and is
  * NOT ABI.
  */
-#define SIGFRAME_MAXSZ SZ_64K
+#define SIGFRAME_MAXSZ SZ_256K
 
 static int __sigframe_alloc(struct rt_sigframe_user_layout *user,
 			    unsigned long *offset, size_t size, bool extend)
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames
  2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames Sasha Levin
@ 2022-08-30 17:58   ` Mark Brown
  2022-09-14 17:59     ` Sasha Levin
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2022-08-30 17:58 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Catalin Marinas, Will Deacon, seanjc,
	mark.rutland, elver, david.engraf, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 395 bytes --]

On Tue, Aug 30, 2022 at 01:21:31PM -0400, Sasha Levin wrote:
> From: Mark Brown <broonie@kernel.org>
> 
> [ Upstream commit 7ddcaf78e93c9282b4d92184f511b4d5bee75355 ]
> 
> The signal code has a limit of 64K on the size of a stack frame that it
> will generate, if this limit is exceeded then a process will be killed if

I don't believe this is relevant to kernels without SME support.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames
  2022-08-30 17:58   ` Mark Brown
@ 2022-09-14 17:59     ` Sasha Levin
  0 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2022-09-14 17:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, stable, Catalin Marinas, Will Deacon, seanjc,
	mark.rutland, elver, david.engraf, linux-arm-kernel

On Tue, Aug 30, 2022 at 06:58:09PM +0100, Mark Brown wrote:
>On Tue, Aug 30, 2022 at 01:21:31PM -0400, Sasha Levin wrote:
>> From: Mark Brown <broonie@kernel.org>
>>
>> [ Upstream commit 7ddcaf78e93c9282b4d92184f511b4d5bee75355 ]
>>
>> The signal code has a limit of 64K on the size of a stack frame that it
>> will generate, if this limit is exceeded then a process will be killed if
>
>I don't believe this is relevant to kernels without SME support.

Ack, I'll drop it.

-- 
Thanks,
Sasha

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-09-14 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20220830172141.581086-1-sashal@kernel.org>
2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 09/23] scsi: ufs: core: Reduce the power mode change timeout Sasha Levin
2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 13/23] arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level Sasha Levin
2022-08-30 17:21 ` [PATCH AUTOSEL 5.15 14/23] arm64/signal: Raise limit on stack frames Sasha Levin
2022-08-30 17:58   ` Mark Brown
2022-09-14 17:59     ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox