From nobody Tue Jun 16 15:54:21 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 707CD3AEF33 for ; Thu, 30 Apr 2026 21:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777582986; cv=none; b=ubDXxM8rgjVzk3EZpDHHvZ5VkvPMh+r4SVJguw4GR0lZTW5Mvrwl3WiqwDnD6bpbRtslYhAm/CIie//ndplUtQa+Y1B6HjieQ7HGoYckwSJ9SVP+pD96P7M/g+8mcuVy39vWAbfPmBNPo5GfBaBObHEEHrmp5FEzeoFP3z+o2lY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777582986; c=relaxed/simple; bh=2+a8FjqR6Y8l6luOjOutV2eo5zpCnfifP9LtBYYSgm0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hBtJ4Iy4hp1upvegbBPcYizJ+gjpKEosnHvqA0pCQhO4qcu/uc6EzrnnQEil18hQZ5lsaZ+TSPG7pvfxEj+f9w61J+MUlrjPJmzRuFAzXvdv8JnmoB1muvo2KhuqJgz/u+Y25HdXWV4Y17wwVCNPq0nCdbrjVja4DdD+kQ7gosM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=htB5ViNG; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="htB5ViNG" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-82f8bf96b46so644385b3a.2 for ; Thu, 30 Apr 2026 14:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777582985; x=1778187785; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7Hm+SYroWp743tKYAFyC841yKgS6flDuKxy8fma+JfM=; b=htB5ViNGOMuPldvGHiDrR4/Zzv2gHVHeFoyLlZHrsbki92XHK1pyalj0H7eEfJ8852 8u76WE/b7tOnOzguDNoNkVvNI2ieCybNlcwLDqs5wBtMBb9htrAdwFAgSvCaDzv01qhZ wFGwQVu4ovwm9YexutBcib0jsps7K8hjnvKhU9DZqWROn3A8qZn7QmOXeJB65PGv5BN5 Bd7xP29Y8TbxDALHvfRBcpEOcIXdOE0toRSw7wQb4GGH+13JbnF10E2xRJhTT+UzBaSM ZA95bcP4MEejUc11L3SCAumAxoTpLTlG6ojnvDs7UBZDZrUVoiL6Dmw+7982k/8AatL/ ObyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777582985; x=1778187785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7Hm+SYroWp743tKYAFyC841yKgS6flDuKxy8fma+JfM=; b=QhbupAhWJ4aYOmXsI0lZ9hgQ7XCQrgttVgO2PpohSg2uRS+VYGcv9w8U7AT3z8qANw SajBYiv6yI6wd8JV9cj/dwdnIeyTId4K0HrwI/qjGac/y2uxHL2nxonVdp+A0u3XXoXo ZwgIiFo2PSuXYHIo+J5LWuw/pbKJPHsni8+Upb3lwYdxnebirlxcBXwP4b2nllX2aoBq L5ZoVnZVMnD+5yHnXcmXb48h4mcUQCzvrSrySrWqvb/R8PET6oDUvhcFKiuWU5k89+c6 3BqEYM+y+jaRkruAPf7kmSsQsrSG6+GUonm6g1GuLiuiM8p/9FwZub26U2BkGQklb7MD O/Cg== X-Forwarded-Encrypted: i=1; AFNElJ8rGERrAeHh7D0pmyLKH/JhTlHf+JRpzVf4YRlWykD7ZAKd7IRWUbYScBC+MX4MQlvakFuJKvWTwbpifLI=@vger.kernel.org X-Gm-Message-State: AOJu0YzAI3O+ddz7GSqn+mr3TiSH8nPebAVRfcfx09V/L8/QI866bWi7 w6Bvv8j30Su1Fg0MHenZDaBZNL41eFYS6wpzkxHx8KXQf2pt8m7ddKle X-Gm-Gg: AeBDievYytCR6soLWR0HcoQu7WajvGqqMQSo/s2CJpAmHmK3LY8v59pAB777a3oaVCW SjdkYmlMZ8GewQdIn2eAIYD/cTsfH9AgOTjJR7OrY5WSDjPnt6AtBND4LXRlfsNWtS6Bru2XBsX EbNvkeiLDmblC1fWw9Ut1iSkmE0sx4v9R1D+daO84o+ZoAlHM4YripqPMchdTWqwHqw58r0LnQV JSwAHnAzqM5C7/J6894wBqEB5uQ72Cet/akyZfoHIAujvsFnuPsGoT9CuyEH06+EvFYlUDOuu9V +ODfRuGwKd07c2VxeMZjJ+yrT+TI48HyUHW41NNBS1hqS/An2BdYHpUtvsQymkLmodetgjeitZ/ OIQm9DLXGE3pmoC5+CsBMaEU/zVb88PPhCJsdc//sMJ6hSWIdNFQQkh+43lnQdskXYfLS3aEy9O gPaWq99Ge7SxCR462QIvHjQGVnH9FVwFNRNPXTOTKceJsy8AeNCts52E2fLE4PhpI9B5W/DwK3H RSaY/p8n9s+iF7l5HkmWt+pnhSsMsgEo+By3Q1Wf06ZLQ== X-Received: by 2002:a05:6a00:4c9a:b0:82f:28da:ec7 with SMTP id d2e1a72fcca58-834fdc0ddd5mr5212627b3a.27.1777582984774; Thu, 30 Apr 2026 14:03:04 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515b4f7c1sm516809b3a.51.2026.04.30.14.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 14:03:04 -0700 (PDT) From: Rosen Penev To: linux-scsi@vger.kernel.org Cc: Saurav Kashyap , Javed Hasan , GR-QLogic-Storage-Upstream@marvell.com (maintainer:BROADCOM BNX2FC 10 GIGABIT FCOE DRIVER), "James E.J. Bottomley" , "Martin K. Petersen" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/3] scsi: bnx2fc: simplify allocation of cmgr Date: Thu, 30 Apr 2026 14:02:43 -0700 Message-ID: <20260430210245.29840-2-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260430210245.29840-1-rosenp@gmail.com> References: <20260430210245.29840-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch to flexible array member for cmds so that all members can be referenced properly instead of using + 1 hacks. Allocate io_bdt_pool, free_list, and free_list_lock with the struct to avoid separate kfrees. Remove mem_size variable. It's just open coding kzalloc_objs. Signed-off-by: Rosen Penev --- drivers/scsi/bnx2fc/bnx2fc.h | 2 +- drivers/scsi/bnx2fc/bnx2fc_io.c | 52 +++++---------------------------- 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 8c8968ec8cb4..30d8b563db0c 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -281,7 +281,7 @@ struct bnx2fc_cmd_mgr { struct list_head *free_list; spinlock_t *free_list_lock; struct io_bdt **io_bdt_pool; - struct bnx2fc_cmd **cmds; + struct bnx2fc_cmd *cmds[]; }; =20 struct bnx2fc_rport { diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_i= o.c index 9c7a541a4523..4810999976b6 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -214,7 +214,6 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2= fc_hba *hba) struct io_bdt *bdt_info; struct bnx2fc_cmd *io_req; size_t len; - u32 mem_size; u16 xid; int i; int num_ios, num_pri_ios; @@ -231,8 +230,10 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx= 2fc_hba *hba) BNX2FC_MISC_DBG("min xid 0x%x, max xid 0x%x\n", min_xid, max_xid); =20 num_ios =3D max_xid - min_xid + 1; - len =3D (num_ios * (sizeof(struct bnx2fc_cmd *))); - len +=3D sizeof(struct bnx2fc_cmd_mgr); + len =3D struct_size(cmgr, cmds, num_ios); + len +=3D sizeof(*cmgr->io_bdt_pool) * num_ios; + len +=3D sizeof(*cmgr->free_list) * arr_sz; + len +=3D sizeof(*cmgr->free_list_lock) * arr_sz; =20 cmgr =3D kzalloc(len, GFP_KERNEL); if (!cmgr) { @@ -241,21 +242,9 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx= 2fc_hba *hba) } =20 cmgr->hba =3D hba; - cmgr->free_list =3D kzalloc_objs(*cmgr->free_list, arr_sz); - if (!cmgr->free_list) { - printk(KERN_ERR PFX "failed to alloc free_list\n"); - goto mem_err; - } - - cmgr->free_list_lock =3D kzalloc_objs(*cmgr->free_list_lock, arr_sz); - if (!cmgr->free_list_lock) { - printk(KERN_ERR PFX "failed to alloc free_list_lock\n"); - kfree(cmgr->free_list); - cmgr->free_list =3D NULL; - goto mem_err; - } - - cmgr->cmds =3D (struct bnx2fc_cmd **)(cmgr + 1); + cmgr->io_bdt_pool =3D (struct io_bdt **)(cmgr->cmds + num_ios); + cmgr->free_list =3D (struct list_head *)(cmgr->io_bdt_pool + num_ios); + cmgr->free_list_lock =3D (spinlock_t *)(cmgr->free_list + arr_sz); =20 for (i =3D 0; i < arr_sz; i++) { INIT_LIST_HEAD(&cmgr->free_list[i]); @@ -291,17 +280,8 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx= 2fc_hba *hba) io_req++; } =20 - /* Allocate pool of io_bdts - one for each bnx2fc_cmd */ - mem_size =3D num_ios * sizeof(struct io_bdt *); - cmgr->io_bdt_pool =3D kzalloc(mem_size, GFP_KERNEL); - if (!cmgr->io_bdt_pool) { - printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n"); - goto mem_err; - } - - mem_size =3D sizeof(struct io_bdt); for (i =3D 0; i < num_ios; i++) { - cmgr->io_bdt_pool[i] =3D kmalloc(mem_size, GFP_KERNEL); + cmgr->io_bdt_pool[i] =3D kmalloc_obj(struct io_bdt); if (!cmgr->io_bdt_pool[i]) { printk(KERN_ERR PFX "failed to alloc " "io_bdt_pool[%d]\n", i); @@ -343,10 +323,6 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr) =20 num_ios =3D max_xid - min_xid + 1; =20 - /* Free fcoe_bdt_ctx structures */ - if (!cmgr->io_bdt_pool) - goto free_cmd_pool; - bd_tbl_sz =3D BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx); for (i =3D 0; i < num_ios; i++) { bdt_info =3D cmgr->io_bdt_pool[i]; @@ -364,16 +340,6 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr) cmgr->io_bdt_pool[i] =3D NULL; } =20 - kfree(cmgr->io_bdt_pool); - cmgr->io_bdt_pool =3D NULL; - -free_cmd_pool: - kfree(cmgr->free_list_lock); - - /* Destroy cmd pool */ - if (!cmgr->free_list) - goto free_cmgr; - for (i =3D 0; i < num_possible_cpus() + 1; i++) { struct bnx2fc_cmd *tmp, *io_req; =20 @@ -383,8 +349,6 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr) kfree(io_req); } } - kfree(cmgr->free_list); -free_cmgr: /* Free command manager itself */ kfree(cmgr); } --=20 2.54.0 From nobody Tue Jun 16 15:54:21 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50ACF3B27F5 for ; Thu, 30 Apr 2026 21:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777582988; cv=none; b=bPJ5bj2EuohTQahg1a5uhdpndrXuD0eQDraqf2QkEI7+5PoU/SwZlhjTu+Yd3WseQ4EerRX3mVwPkT7P1osLaQ4duZinmrgvtA/1AqalaratjSt3HTaVohBk8SwN3gws6ZbzaPsU4jUFR0dkxRf1eB3am8Z/yJT8oOmsMNtgTs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777582988; c=relaxed/simple; bh=O9DERP0tk+0f7A1tMchJccbrA3qiv/19kFTs5r8KkB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BkQI0qAiLQXZcPFYgODXrVIJNc3KInr4NHv7ccj5+3u8qIwfbUvoG1eaQ09kkpf12YaZjFQtSceQ1ULwEpwPZCcRfEPdSBmHX8pU+5Yg4yY5ZVEWCb7jSpOWc45nSZDQWF2cUja9awYsXBXbAfMbUUCGzETwRB02CM6kdJ7W+WQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OWBdJzSo; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OWBdJzSo" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82f943870baso667292b3a.1 for ; Thu, 30 Apr 2026 14:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777582986; x=1778187786; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LnqOGqDPHVUackkq9ZkSS/lfsrgEZLctighrNH7cCSs=; b=OWBdJzSodSicsRM8SXi4L9Y/oLazstFNn/GUPd+3HIHXLRvoyQQiT1KIzvAIeQZHde GfjDRHfjZ6DhaDGIu1Z7xWJBfFO4aQqAg6DLhBZTkNy3WyfAwq1d3kkxJhCxX21guRGi e3vRBYTzH0kG9MlVQUJMUyAxKUztgpfZTP0sfbUEVa0QP7HnslePT4KgcPEJNQBPMKPd 77fq1WViwi4dGwWPOdntdbhHL9XDmMjMOB0ikTG5SvMEygMWG0bT0SAmLCj8xH0hYOnW 7+PAelq4bWEvlMQ1fbdNFRVPNd1ASQnbgFhsFgr7St9cye7mCNjk0YnmgY/bu/yoA00V +jcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777582986; x=1778187786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LnqOGqDPHVUackkq9ZkSS/lfsrgEZLctighrNH7cCSs=; b=Y5cpq1Qc8PdpYD1AyYlcHa0BpsGa91N29bOrZq0hrPOaaBbIQcc0UpjTbN8RimHJfB hKal6SkVeXAjaQB50MWMdzYKnm7EoLJGkUoRZ/K5q3uws1K1i2o+WXHyA3eD7h9fKbqc eVywguX9iD9BJmUAUEi9KtWgFa1QQWkTliOg2Rbw4tderGQu0Nw6KyoroQHs52qFvkrW rZiIsQwzisOX5bBHsaiRSMqBGtUaqx6bD+MOSHz8SAt+FjsG6VCV+mBhtoTeHvF+396M dFILTlCM+TCE+cyfJD+Vmv1Rl3+4JGX3Wf5RF9m47cet8RmWPN7pUQ5FH+h0KmxESw+S Co1w== X-Forwarded-Encrypted: i=1; AFNElJ/zAYV/66Mt3iQ76t6wLmZNI2gEil7fQBW0mazKOICr7e79BzQWGGfbE+cVkBJCun2a+uMQ2/OdC1i+LBQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyLmfcuMC04t5YPBqFPWmMhbFRqMQ2952t2QCJFvY5w0FzL+F4i rT5FVBvtfVQXVQc/qpPI2vXkzbxcD+U0dbKkWsXuD4yV9+nHDm+IBohsjdv2cQ== X-Gm-Gg: AeBDietSW2FLUwtx8FTFnpiLs0M/TjTOw20tFoiqMuH58qf976khd0CWVzgOZMNelEy DlUWrOPr/yxz5GKNV291udLP5B/Q3yejW524nd2fjW49V9zuqqDawqHusxlUBIcrH5U1WPUQPxV QLCSACYx9jkBOTx2C83hO3A5bu0fyxfdxpwsluapZw+KFJ96qsb5vAgJZ3BOwbzX6Ye4wIcHZLS DhrdUopM+M/hA5E+HgDqh2N6Io07ZfuDQONEhXtyaYVQmMjmhS8IaDB7w4gRnywog8Jyueo0tUm SbBdfHYV8qznFgBhyi3mzZ8Eo7HZbCZSJopyWHgncE4aoUaasl11DWCo1a+/SnKBOOEr2+wrCHa HeH5hqQe6MUMDGam9faxAVzjbBHY993zU7TIMLspHNMNesferdU+ZK0YTynBCr8mh6FD/eL5cO6 J1E2gqRxPikP/xlpa0m2KSFmx4K31w9ugRIerPnjrY6gLW7mJUC7CrR2O29iVrB/jii6wUo7aRp frRjjvJKzs5Sy6dfgADHXLWamHqk0BDaYsbqXXIeyz7I+WHb6PTjgRl X-Received: by 2002:a05:6a00:228f:b0:82f:6640:7229 with SMTP id d2e1a72fcca58-8351a58db66mr192650b3a.23.1777582986450; Thu, 30 Apr 2026 14:03:06 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515b4f7c1sm516809b3a.51.2026.04.30.14.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 14:03:05 -0700 (PDT) From: Rosen Penev To: linux-scsi@vger.kernel.org Cc: Saurav Kashyap , Javed Hasan , GR-QLogic-Storage-Upstream@marvell.com (maintainer:BROADCOM BNX2FC 10 GIGABIT FCOE DRIVER), "James E.J. Bottomley" , "Martin K. Petersen" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] scsi: bnx2fc: no double pointer for io_bdt_pool Date: Thu, 30 Apr 2026 14:02:44 -0700 Message-ID: <20260430210245.29840-3-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260430210245.29840-1-rosenp@gmail.com> References: <20260430210245.29840-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of allocating a double pointer, allocate a single and avoid extra malloc and free. It's not needed anyway. Signed-off-by: Rosen Penev --- drivers/scsi/bnx2fc/bnx2fc.h | 2 +- drivers/scsi/bnx2fc/bnx2fc_io.c | 25 +++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 30d8b563db0c..9a5de1048542 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -280,7 +280,7 @@ struct bnx2fc_cmd_mgr { u16 next_idx; struct list_head *free_list; spinlock_t *free_list_lock; - struct io_bdt **io_bdt_pool; + struct io_bdt *io_bdt_pool; struct bnx2fc_cmd *cmds[]; }; =20 diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_i= o.c index 4810999976b6..6773f8d5d84e 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -242,7 +242,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2= fc_hba *hba) } =20 cmgr->hba =3D hba; - cmgr->io_bdt_pool =3D (struct io_bdt **)(cmgr->cmds + num_ios); + cmgr->io_bdt_pool =3D (struct io_bdt *)(cmgr->cmds + num_ios); cmgr->free_list =3D (struct list_head *)(cmgr->io_bdt_pool + num_ios); cmgr->free_list_lock =3D (spinlock_t *)(cmgr->free_list + arr_sz); =20 @@ -280,19 +280,10 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bn= x2fc_hba *hba) io_req++; } =20 - for (i =3D 0; i < num_ios; i++) { - cmgr->io_bdt_pool[i] =3D kmalloc_obj(struct io_bdt); - if (!cmgr->io_bdt_pool[i]) { - printk(KERN_ERR PFX "failed to alloc " - "io_bdt_pool[%d]\n", i); - goto mem_err; - } - } - /* Allocate an map fcoe_bdt_ctx structures */ bd_tbl_sz =3D BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx); for (i =3D 0; i < num_ios; i++) { - bdt_info =3D cmgr->io_bdt_pool[i]; + bdt_info =3D &cmgr->io_bdt_pool[i]; bdt_info->bd_tbl =3D dma_alloc_coherent(&hba->pcidev->dev, bd_tbl_sz, &bdt_info->bd_tbl_dma, @@ -325,7 +316,7 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr) =20 bd_tbl_sz =3D BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx); for (i =3D 0; i < num_ios; i++) { - bdt_info =3D cmgr->io_bdt_pool[i]; + bdt_info =3D &cmgr->io_bdt_pool[i]; if (bdt_info->bd_tbl) { dma_free_coherent(&hba->pcidev->dev, bd_tbl_sz, bdt_info->bd_tbl, @@ -334,12 +325,6 @@ void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr) } } =20 - /* Destroy io_bdt pool */ - for (i =3D 0; i < num_ios; i++) { - kfree(cmgr->io_bdt_pool[i]); - cmgr->io_bdt_pool[i] =3D NULL; - } - for (i =3D 0; i < num_possible_cpus() + 1; i++) { struct bnx2fc_cmd *tmp, *io_req; =20 @@ -415,7 +400,7 @@ struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rpo= rt *tgt, int type) =20 /* Bind io_bdt for this io_req */ /* Have a static link between io_req and io_bdt_pool */ - bd_tbl =3D io_req->bd_tbl =3D cmd_mgr->io_bdt_pool[xid]; + bd_tbl =3D io_req->bd_tbl =3D &cmd_mgr->io_bdt_pool[xid]; bd_tbl->io_req =3D io_req; =20 /* Hold the io_req against deletion */ @@ -468,7 +453,7 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport= *tgt) =20 /* Bind io_bdt for this io_req */ /* Have a static link between io_req and io_bdt_pool */ - bd_tbl =3D io_req->bd_tbl =3D cmd_mgr->io_bdt_pool[xid]; + bd_tbl =3D io_req->bd_tbl =3D &cmd_mgr->io_bdt_pool[xid]; bd_tbl->io_req =3D io_req; =20 /* Hold the io_req against deletion */ --=20 2.54.0 From nobody Tue Jun 16 15:54:21 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B85953B0AF3 for ; Thu, 30 Apr 2026 21:03:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777582990; cv=none; b=hwMEMBX4MlLV1/v2/fNqgilnigvp6kJsirKv5hF/B04Cmv+M4jFiiglxFy49ddgZru7ZyoCDDUXggR6tlpiu69g0+UPBXc1HGRVHA+xMbL7zSui7625kce+wu2rUh3m7HHchdGxRK2qIp9ctbHGqRWnF2GcHVlVMO6/TRVvIDuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777582990; c=relaxed/simple; bh=dKcQ9gofc1MkJSPdgtxtQwz2NADeQERcN6d2YDBtYD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l+u6yaEu6cW8Xgxd+qrt8fzyihVcpDYq6jgsdRhQIxIS3IsRCZKtEhnuQGq0WNCx014kJb84zaJLkAKX9OFRzR9XduB8ZYLnLlq18G7ZvLpaY+qS2lOomVPWjSJJhsMZqNE8OQfFSlFKu3pnNC8Y+8Q6wGLbUegdkjYxN0dzXN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=G+m1PWBo; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G+m1PWBo" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82f69a286dbso979100b3a.2 for ; Thu, 30 Apr 2026 14:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777582988; x=1778187788; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1rtPqpREBagzBSxsaqoRtZ+VHKYl1bjv3s2ciLoIpvw=; b=G+m1PWBot3m8CpTFUgTkvAUJAZt0kNqxzUiULb8Lm+YJ85fydV/eYUMXPQ9u4GZQHe GgATFrZUnIlwcFT1N66vsT9w4vLY4um2CMdqnB4T2Ndyesn70oY7X7DWsx74zmi2MXUq qvqQARxyWTNnoV1k/odN7Uh1F+cSGyc+frr+V8rdQ6DBoGf9NV5hVIOaNLUmh45FGrq6 IBKzxLe9NkcCe6hmMY8eWGpnuOC48CcZzUFFbc/sKg4Qb3CDtZy1A/OWU6o86MzIcqKN qyxuUUMC/45kpv3vLPVPgsx7zopmIuH3UJxEU3WELl8sztugVKJamZAofcU4hIYsAGL/ OxlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777582988; x=1778187788; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1rtPqpREBagzBSxsaqoRtZ+VHKYl1bjv3s2ciLoIpvw=; b=HIxH8hTrws3xr6PHyWStT+5vKS7bQP+HlAcyr8PHbS4yKfMUmkhKWwfJQJF/Qqdiwm XeJcnkgtOFHgrtSew2jEMaPC95RpxsNw4Gfi9r1bq1BwAxevis/egDDu07xdooGnAwhn luOXJXp5igBbAnDYz0waSzNXTNTzgbMqaVOlvsyZBmK1EplGH4CmMLCcWMDmq70+XQC/ Cf6uR8oe9uUurwyAXWnQ3LeaU3zc95jdnFFm555kxV30nvxWwruQ8INTbvjkn0izjTjL guAz8za+NyNQATuh4rxJuj9EXK7k8LHFlhopX49FVemgudfJmoBjLtbHPqB2b+cPsB2v J8hw== X-Forwarded-Encrypted: i=1; AFNElJ9xEITavQC+rgtK+ApWHFn/yBAfJfbjSeYa8XoB5AZs2t5Jo+tuEYIVtSl7smcqcxhVNwm+RXAbKRXsIWw=@vger.kernel.org X-Gm-Message-State: AOJu0YxtihYFPuke27mduRPSYSwYMWGgGcAwx+wc9o0nGuQkRnoEyLlR DAfXOrEqmZtjWSFIgCXJ+qgp2Fcsa7ou94+rFGhbvP02OVKlqI8wC5LJ X-Gm-Gg: AeBDievphzw0oDT1zchCEdAZ0jGoJqUjVvrIhw1YkTiHjx5oxx0kWswovVtxMKZIm1y HCle4Q1ZiPjn5zj/ZJZrYQgPIWm8QY8J9WAE5Wuuh75Af1KnnLwaOB+EhZnHB5XaikK0rCgka3P beXRDWih8oQjQEMI4vpyVOr+yuxuxKlru1ebD7PAoUF/rPzRArRHPUb1lzz0QDBnrTaCnWU+Bfz gXD9k7fO/160kHFXh3J77LFp/Os1P1hPh69c1AG4CPg8ePyywfoWckYMBrbH37C+nv1oLNxJNq9 MtckDbtFwfej6ngdMzyI2lVT9HquX/aIt6TPtzKeNUUezUx02m/APYdiTYUmZtAZrc+14gORJwR C+EQ/0goj3198Y8dYFQpjgTXJm8LBJTKSyeIbT1ScV6FbOZ/OnnJQ5rPKkNkqoHVYKQIpLViydb R/28znACAAYSfaLf88GFiAqaZsZyxCSY8oZMuH5acCabRtIjkO6Z5bagPasuT20M9NNYw1lv4P3 KDk5UWIEWKpnAfbVAawocSj/DkfgVcHfpZXGExu/uFaEg== X-Received: by 2002:a05:6a00:408c:b0:82f:5051:f024 with SMTP id d2e1a72fcca58-834fdbd91cbmr5717378b3a.27.1777582987982; Thu, 30 Apr 2026 14:03:07 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515b4f7c1sm516809b3a.51.2026.04.30.14.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 14:03:07 -0700 (PDT) From: Rosen Penev To: linux-scsi@vger.kernel.org Cc: Saurav Kashyap , Javed Hasan , GR-QLogic-Storage-Upstream@marvell.com (maintainer:BROADCOM BNX2FC 10 GIGABIT FCOE DRIVER), "James E.J. Bottomley" , "Martin K. Petersen" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] scsi: bnx2fc: tgt_ofld_list to FAM Date: Thu, 30 Apr 2026 14:02:45 -0700 Message-ID: <20260430210245.29840-4-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260430210245.29840-1-rosenp@gmail.com> References: <20260430210245.29840-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify allocation slightly by allocating tgt_ofld_list with hba. No need to kfree separately. Signed-off-by: Rosen Penev --- drivers/scsi/bnx2fc/bnx2fc.h | 6 +++--- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 14 ++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index 9a5de1048542..31bb701cc5ea 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -224,9 +224,6 @@ struct bnx2fc_hba { char *dummy_buffer; dma_addr_t dummy_buf_dma; =20 - /* Active list of offloaded sessions */ - struct bnx2fc_rport **tgt_ofld_list; - /* statistics */ struct bnx2fc_fw_stats bfw_stats; struct fcoe_statistics_params prev_stats; @@ -246,6 +243,9 @@ struct bnx2fc_hba { struct list_head vports; =20 char chip_num[BCM_CHIP_LEN]; + + /* Active list of offloaded sessions */ + struct bnx2fc_rport *tgt_ofld_list[]; }; =20 struct bnx2fc_interface { diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc= _fcoe.c index 26e0ff380860..7e740ac6bf1b 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -1337,7 +1337,6 @@ static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) bnx2fc_cmd_mgr_free(hba->cmd_mgr); hba->cmd_mgr =3D NULL; } - kfree(hba->tgt_ofld_list); bnx2fc_unbind_pcidev(hba); kfree(hba); } @@ -1356,7 +1355,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct cn= ic_dev *cnic) struct fcoe_capabilities *fcoe_cap; int rc; =20 - hba =3D kzalloc_obj(*hba); + hba =3D kzalloc_flex(*hba, tgt_ofld_list, BNX2FC_NUM_MAX_SESS); if (!hba) { printk(KERN_ERR PFX "Unable to allocate hba structure\n"); return NULL; @@ -1380,19 +1379,12 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct = cnic_dev *cnic) hba->phys_dev =3D cnic->netdev; hba->next_conn_id =3D 0; =20 - hba->tgt_ofld_list =3D - kzalloc_objs(struct bnx2fc_rport *, BNX2FC_NUM_MAX_SESS); - if (!hba->tgt_ofld_list) { - printk(KERN_ERR PFX "Unable to allocate tgt offload list\n"); - goto tgtofld_err; - } - hba->num_ofld_sess =3D 0; =20 hba->cmd_mgr =3D bnx2fc_cmd_mgr_alloc(hba); if (!hba->cmd_mgr) { printk(KERN_ERR PFX "em_config:bnx2fc_cmd_mgr_alloc failed\n"); - goto cmgr_err; + goto tgtofld_err; } fcoe_cap =3D &hba->fcoe_cap; =20 @@ -1416,8 +1408,6 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct cn= ic_dev *cnic) =20 return hba; =20 -cmgr_err: - kfree(hba->tgt_ofld_list); tgtofld_err: bnx2fc_unbind_pcidev(hba); bind_err: --=20 2.54.0