[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231118155105.25678-16-yury.norov@gmail.com>
Date: Sat, 18 Nov 2023 07:50:46 -0800
From: Yury Norov <yury.norov@...il.com>
To: linux-kernel@...r.kernel.org,
Sathya Prakash Veerichetty <sathya.prakash@...adcom.com>,
Kashyap Desai <kashyap.desai@...adcom.com>,
Sumit Saxena <sumit.saxena@...adcom.com>,
Sreekanth Reddy <sreekanth.reddy@...adcom.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Nilesh Javali <njavali@...vell.com>,
Manish Rangankar <mrangankar@...vell.com>,
GR-QLogic-Storage-Upstream@...vell.com,
mpi3mr-linuxdrv.pdl@...adcom.com, linux-scsi@...r.kernel.org
Cc: Yury Norov <yury.norov@...il.com>, Jan Kara <jack@...e.cz>,
Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
Matthew Wilcox <willy@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@...aro.org>,
Alexey Klimov <klimov.linux@...il.com>
Subject: [PATCH 15/34] scsi: use atomic find_bit() API where appropriate
SCSI code opencodes atomic bit allocation/traversing generic routines.
Switch it to use dedicated functions.
Signed-off-by: Yury Norov <yury.norov@...il.com>
---
drivers/scsi/mpi3mr/mpi3mr_os.c | 21 ++++++---------------
drivers/scsi/qedi/qedi_main.c | 9 +--------
drivers/scsi/scsi_lib.c | 5 ++---
3 files changed, 9 insertions(+), 26 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 040031eb0c12..11139a2008fd 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -2276,13 +2276,9 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle,
if (drv_cmd)
goto issue_cmd;
do {
- cmd_idx = find_first_zero_bit(mrioc->devrem_bitmap,
- MPI3MR_NUM_DEVRMCMD);
- if (cmd_idx < MPI3MR_NUM_DEVRMCMD) {
- if (!test_and_set_bit(cmd_idx, mrioc->devrem_bitmap))
- break;
- cmd_idx = MPI3MR_NUM_DEVRMCMD;
- }
+ cmd_idx = find_and_set_bit(mrioc->devrem_bitmap, MPI3MR_NUM_DEVRMCMD);
+ if (cmd_idx < MPI3MR_NUM_DEVRMCMD)
+ break;
} while (retrycount--);
if (cmd_idx >= MPI3MR_NUM_DEVRMCMD) {
@@ -2417,14 +2413,9 @@ static void mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
"sending event ack in the top half for event(0x%02x), event_ctx(0x%08x)\n",
event, event_ctx);
do {
- cmd_idx = find_first_zero_bit(mrioc->evtack_cmds_bitmap,
- MPI3MR_NUM_EVTACKCMD);
- if (cmd_idx < MPI3MR_NUM_EVTACKCMD) {
- if (!test_and_set_bit(cmd_idx,
- mrioc->evtack_cmds_bitmap))
- break;
- cmd_idx = MPI3MR_NUM_EVTACKCMD;
- }
+ cmd_idx = find_and_set_bit(mrioc->evtack_cmds_bitmap, MPI3MR_NUM_EVTACKCMD);
+ if (cmd_idx < MPI3MR_NUM_EVTACKCMD)
+ break;
} while (retrycount--);
if (cmd_idx >= MPI3MR_NUM_EVTACKCMD) {
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index cd0180b1f5b9..2f940c6898ef 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -1824,20 +1824,13 @@ int qedi_get_task_idx(struct qedi_ctx *qedi)
{
s16 tmp_idx;
-again:
- tmp_idx = find_first_zero_bit(qedi->task_idx_map,
- MAX_ISCSI_TASK_ENTRIES);
+ tmp_idx = find_and_set_bit(qedi->task_idx_map, MAX_ISCSI_TASK_ENTRIES);
if (tmp_idx >= MAX_ISCSI_TASK_ENTRIES) {
QEDI_ERR(&qedi->dbg_ctx, "FW task context pool is full.\n");
tmp_idx = -1;
- goto err_idx;
}
- if (test_and_set_bit(tmp_idx, qedi->task_idx_map))
- goto again;
-
-err_idx:
return tmp_idx;
}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index cf3864f72093..4460a37f4864 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2499,9 +2499,8 @@ void scsi_evt_thread(struct work_struct *work)
sdev = container_of(work, struct scsi_device, event_work);
- for (evt_type = SDEV_EVT_FIRST; evt_type <= SDEV_EVT_LAST; evt_type++)
- if (test_and_clear_bit(evt_type, sdev->pending_events))
- sdev_evt_send_simple(sdev, evt_type, GFP_KERNEL);
+ for_each_test_and_clear_bit(evt_type, sdev->pending_events, SDEV_EVT_LAST)
+ sdev_evt_send_simple(sdev, evt_type, GFP_KERNEL);
while (1) {
struct scsi_event *evt;
--
2.39.2
Powered by blists - more mailing lists