Message ID | 20240123130754.2011469-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-35316-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp323872dyi; Tue, 23 Jan 2024 05:15:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/xERi7gT16TluWSOT5hJC/MJ/mONOXrvvNJVPe6aLTHzEVOe1IN8hcyUIjn5Cf9jp47NY X-Received: by 2002:a05:6a20:3627:b0:19b:7d50:fe8f with SMTP id r39-20020a056a20362700b0019b7d50fe8fmr2112526pze.40.1706015736728; Tue, 23 Jan 2024 05:15:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706015736; cv=pass; d=google.com; s=arc-20160816; b=CnJeq7n3RGM10kEw1KUiqF0dMErbRHdg+SuaMSgOSkYKf/KSdICwPoMzrUgK5OwSgl sEfnQj/d0Dc80APliSG/QlES4mY4AHiyqAlI85JX5A1uMETfbMOdYKrEYvjgWWdxNjBY vVuISHVw872XbHzKEWQH2fHP36FMedz2CvxYeofqcMJonKUeD8DPGtyAq8uT98QeFxZ7 mGqUfJd1YMFmwY37Y7FOnn4u4LexoTrcD3ZYE4dsmkwpRDrG9Xa9+tf8cJbgA3p+MJv8 +2tYjIp2e7E/ggur5qqJkueDX9MuLNy/keymiP2nVhImmhNUrhgE9Vx6II2IC5Ppcq9i +NiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=AIJWV5w1Ybx5CbpYSS1IM5BjdYElk8JBsv3WPKob3K8=; fh=Rq0S7grTGzOvq/yin1HRiRk3yDC4JMssewzC1oRpw28=; b=VJgxKzkfthcC3Gefu8se4Fz3W2LlHebxdx2QUUFO2z8iufw0YMzev30JbCAFg9NCj5 EAAU105rHlT6u/en0nWc48k3dTv4ptwGNKTz6LEim4S/n03t5UA+6ZY54P/pjyIONl7g eq61roBwOZxjYpQMsQSrZC4fRcLjRYBipSyGwy3YisD09QxC4DgWlewCnV8H/dlqw5s6 7Bg+Aouq64/AaidOpSsFE2ZNIrB5gmanEp1CkCBcElfGyzEakjCWwPRMBPzutf+CZIvf mT4D98+o8QgrmjvmXwu7IKZRbfOQenWUfYK7wgl/U1CpA+HhlbrJ45DAf4nHyoq3uxIe sFIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eY5FiRHb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35316-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t1-20020a056a00138100b006dbac97dfccsi9447755pfg.141.2024.01.23.05.15.36 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 05:15:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35316-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eY5FiRHb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35316-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 42ABF28D91D for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 13:09:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76D115FBBD; Tue, 23 Jan 2024 13:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eY5FiRHb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D19A55FB93; Tue, 23 Jan 2024 13:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706015284; cv=none; b=UMnnzkmmoRbyQe5OSs2CFe/E7+clpHKCO/5Kav4BrShTBMCfC6YbWkWl4o2OQhhfW4tq9DN7lAnJjgBof+8kaiD5G0m+O/5xvrs67kRoDc/5KRtwiF2vU+3LwPvdV/dMf5TVtQUr/bLXdm/3t6FI8lfNXT83Osubu0erI97L+A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706015284; c=relaxed/simple; bh=Iht0LmkPxLLHVKnMAeIfFdEQMIe3jvBDV9Mk4EEPtBk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=t8PtjW8XrBuF3DbhqFw3UK78QV4BKBgQIfqRfGtBfyzZuQMyd76L8I2bOq+x6O3Hj5R3MwY3akeMabtbnrN63ESk4iNpK8bF+b3hd9ZjXIIj7UpMknZ2MViPsSinssmHYjYiKdwLjlX3C9s0w33nGy6kqmcvVnIhU6xGlaQSKOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eY5FiRHb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EB40C433C7; Tue, 23 Jan 2024 13:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706015284; bh=Iht0LmkPxLLHVKnMAeIfFdEQMIe3jvBDV9Mk4EEPtBk=; h=From:To:Cc:Subject:Date:From; b=eY5FiRHb6bU/8LTk7eX7LiBJrz/Ai4un0wTvOGZvNySeTHdpGIeKwR0RNBM4Qbb/z mKM3RifQvpuWh+6CY+opvNFiBRrb9pRM0p15uGHADLRUfSNwOvGiFWNwtyYD+2qtDJ PTzCu7zbx6xfNGUi524CsNnMDUEB07vJCloaKeTCn0XC63Sv8avlB6dkgC4CN0GSTJ F7oukveaBmtZsOpIYFcqBIUFQDPG4fNhRvRXODkjVp6A5QN36nvqwI18mtdXP2vQ6x ssa3yIO34lnp5m+SFKsqHmvIo+cMfqjg8CVOdy0wFHWpAMjc8qWc+rxG+5IL8T3n9I 5WEn9irEz6IfA== From: Arnd Bergmann <arnd@kernel.org> To: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>, Kashyap Desai <kashyap.desai@broadcom.com>, Sumit Saxena <sumit.saxena@broadcom.com>, Sreekanth Reddy <sreekanth.reddy@broadcom.com> Cc: Arnd Bergmann <arnd@arndb.de>, Johannes Thumshirn <johannes.thumshirn@wdc.com>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, Ranjan Kumar <ranjan.kumar@broadcom.com>, Tomas Henzl <thenzl@redhat.com>, Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>, mpi3mr-linuxdrv.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports() Date: Tue, 23 Jan 2024 14:07:36 +0100 Message-Id: <20240123130754.2011469-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788887157202839830 X-GMAIL-MSGID: 1788887157202839830 |
Series |
[v2] scsi: mpi3mr: reduce stack usage in mpi3mr_refresh_sas_ports()
|
|
Commit Message
Arnd Bergmann
Jan. 23, 2024, 1:07 p.m. UTC
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(-)
Comments
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
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.
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
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!
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
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); }