* [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
@ 2024-01-23 13:07 Arnd Bergmann
2024-02-19 12:08 ` John Garry
2024-02-27 2:47 ` Martin K. Petersen
0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2024-01-23 13:07 UTC (permalink / raw)
To: Sathya Prakash Veerichetty, Kashyap Desai, Sumit Saxena,
Sreekanth Reddy
Cc: Arnd Bergmann, Johannes Thumshirn, James E.J. Bottomley,
Martin K. Petersen, Ranjan Kumar, Tomas Henzl,
Harshit Mogalapalli, mpi3mr-linuxdrv.pdl, linux-scsi,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Doubling the number of PHYs also doubled the stack usage of this function,
exceeding the 32-bit limit of 1024 bytes:
drivers/scsi/mpi3mr/mpi3mr_transport.c: In function 'mpi3mr_refresh_sas_ports':
drivers/scsi/mpi3mr/mpi3mr_transport.c:1818:1: error: the frame size of 1636 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
Since the sas_io_unit_pg0 structure is already allocated dynamically, use
the same method here. The size of the allocation can be smaller based on the
actual number of phys now, so use this as an upper bound.
Fixes: cb5b60894602 ("scsi: mpi3mr: Increase maximum number of PHYs to 64 from 32")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: fix number of ports to be always 64 rather than num_phys
---
drivers/scsi/mpi3mr/mpi3mr_transport.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c
index c0c8ab586957..d32ad46318cb 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_transport.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c
@@ -1671,7 +1671,7 @@ mpi3mr_update_mr_sas_port(struct mpi3mr_ioc *mrioc, struct host_port *h_port,
void
mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc)
{
- struct host_port h_port[64];
+ struct host_port *h_port = NULL;
int i, j, found, host_port_count = 0, port_idx;
u16 sz, attached_handle, ioc_status;
struct mpi3_sas_io_unit_page0 *sas_io_unit_pg0 = NULL;
@@ -1685,6 +1685,10 @@ mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc)
sas_io_unit_pg0 = kzalloc(sz, GFP_KERNEL);
if (!sas_io_unit_pg0)
return;
+ h_port = kcalloc(64, sizeof(struct host_port), GFP_KERNEL);
+ if (!h_port)
+ goto out;
+
if (mpi3mr_cfg_get_sas_io_unit_pg0(mrioc, sas_io_unit_pg0, sz)) {
ioc_err(mrioc, "failure at %s:%d/%s()!\n",
__FILE__, __LINE__, __func__);
@@ -1814,6 +1818,7 @@ mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc)
}
}
out:
+ kfree(h_port);
kfree(sas_io_unit_pg0);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
2024-01-23 13:07 [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports() Arnd Bergmann
@ 2024-02-19 12:08 ` John Garry
2024-02-23 1:16 ` Martin K. Petersen
2024-02-27 2:47 ` Martin K. Petersen
1 sibling, 1 reply; 6+ messages in thread
From: John Garry @ 2024-02-19 12:08 UTC (permalink / raw)
To: Arnd Bergmann, Sathya Prakash Veerichetty, Kashyap Desai,
Sumit Saxena, Sreekanth Reddy
Cc: Arnd Bergmann, Johannes Thumshirn, James E.J. Bottomley,
Martin K. Petersen, Ranjan Kumar, Tomas Henzl,
Harshit Mogalapalli, mpi3mr-linuxdrv.pdl, linux-scsi,
linux-kernel
On 23/01/2024 13:07, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Doubling the number of PHYs also doubled the stack usage of this function,
> exceeding the 32-bit limit of 1024 bytes:
>
> drivers/scsi/mpi3mr/mpi3mr_transport.c: In function 'mpi3mr_refresh_sas_ports':
> drivers/scsi/mpi3mr/mpi3mr_transport.c:1818:1: error: the frame size of 1636 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
>
> Since the sas_io_unit_pg0 structure is already allocated dynamically, use
> the same method here. The size of the allocation can be smaller based on the
> actual number of phys now, so use this as an upper bound.
>
> Fixes: cb5b60894602 ("scsi: mpi3mr: Increase maximum number of PHYs to 64 from 32")
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Cc: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Has this patch been missed?
I have this same build issue for i386 allmodconfig on v6.8-rc5 and earlier
Tested-by: John Garry <john.g.garry@oracle.com> #build only
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
2024-02-19 12:08 ` John Garry
@ 2024-02-23 1:16 ` Martin K. Petersen
2024-02-23 8:53 ` John Garry
0 siblings, 1 reply; 6+ messages in thread
From: Martin K. Petersen @ 2024-02-23 1:16 UTC (permalink / raw)
To: John Garry
Cc: Arnd Bergmann, Sathya Prakash Veerichetty, Kashyap Desai,
Sumit Saxena, Sreekanth Reddy, Arnd Bergmann, Johannes Thumshirn,
James E.J. Bottomley, Martin K. Petersen, Ranjan Kumar,
Tomas Henzl, Harshit Mogalapalli, mpi3mr-linuxdrv.pdl, linux-scsi,
linux-kernel
John,
> Has this patch been missed?
>
> I have this same build issue for i386 allmodconfig on v6.8-rc5 and earlier
>
> Tested-by: John Garry <john.g.garry@oracle.com> #build only
Broadcom requested changes and I haven't seen a v3.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
2024-02-23 1:16 ` Martin K. Petersen
@ 2024-02-23 8:53 ` John Garry
2024-02-27 1:35 ` Martin K. Petersen
0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2024-02-23 8:53 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Arnd Bergmann, Sathya Prakash Veerichetty, Kashyap Desai,
Sumit Saxena, Sreekanth Reddy, Arnd Bergmann, Johannes Thumshirn,
James E.J. Bottomley, Ranjan Kumar, Tomas Henzl,
Harshit Mogalapalli, mpi3mr-linuxdrv.pdl, linux-scsi,
linux-kernel
On 23/02/2024 01:16, Martin K. Petersen wrote:
>
> John,
>
>> Has this patch been missed?
>>
>> I have this same build issue for i386 allmodconfig on v6.8-rc5 and earlier
>>
>> Tested-by: John Garry <john.g.garry@oracle.com> #build only
>
> Broadcom requested changes and I haven't seen a v3.
From checking the history, changes were requested for the v1, and Arnd
addressed them in this v2. Since then, there has been no activity.
Thanks,
John
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
2024-02-23 8:53 ` John Garry
@ 2024-02-27 1:35 ` Martin K. Petersen
0 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2024-02-27 1:35 UTC (permalink / raw)
To: John Garry
Cc: Martin K. Petersen, Arnd Bergmann, Sathya Prakash Veerichetty,
Kashyap Desai, Sumit Saxena, Sreekanth Reddy, Arnd Bergmann,
Johannes Thumshirn, James E.J. Bottomley, Ranjan Kumar,
Tomas Henzl, Harshit Mogalapalli, mpi3mr-linuxdrv.pdl, linux-scsi,
linux-kernel
John,
>> Broadcom requested changes and I haven't seen a v3.
>
> From checking the history, changes were requested for the v1, and Arnd
> addressed them in this v2. Since then, there has been no activity.
Interesting. For some reason I kept getting the previous version when I
queried this patch.
Applied to 6.8/scsi-fixes, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
2024-01-23 13:07 [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports() Arnd Bergmann
2024-02-19 12:08 ` John Garry
@ 2024-02-27 2:47 ` Martin K. Petersen
1 sibling, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2024-02-27 2:47 UTC (permalink / raw)
To: Sathya Prakash Veerichetty, Kashyap Desai, Sumit Saxena,
Sreekanth Reddy, Arnd Bergmann
Cc: Martin K . Petersen, Arnd Bergmann, Johannes Thumshirn,
James E.J. Bottomley, Ranjan Kumar, Tomas Henzl,
Harshit Mogalapalli, mpi3mr-linuxdrv.pdl, linux-scsi,
linux-kernel
On Tue, 23 Jan 2024 14:07:36 +0100, Arnd Bergmann wrote:
> Doubling the number of PHYs also doubled the stack usage of this function,
> exceeding the 32-bit limit of 1024 bytes:
>
> drivers/scsi/mpi3mr/mpi3mr_transport.c: In function 'mpi3mr_refresh_sas_ports':
> drivers/scsi/mpi3mr/mpi3mr_transport.c:1818:1: error: the frame size of 1636 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
>
> Since the sas_io_unit_pg0 structure is already allocated dynamically, use
> the same method here. The size of the allocation can be smaller based on the
> actual number of phys now, so use this as an upper bound.
>
> [...]
Applied to 6.8/scsi-fixes, thanks!
[1/1] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
https://git.kernel.org/mkp/scsi/c/5cc2da0b60e5
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-27 2:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 13:07 [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports() Arnd Bergmann
2024-02-19 12:08 ` John Garry
2024-02-23 1:16 ` Martin K. Petersen
2024-02-23 8:53 ` John Garry
2024-02-27 1:35 ` Martin K. Petersen
2024-02-27 2:47 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox