public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Anil Gurumurthy <anil.gurumurthy@qlogic.com>,
	Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH 4/4] scsi: bfa: Rework bfad_reset_sdev_bflags()
Date: Mon, 31 Oct 2022 15:47:28 -0700	[thread overview]
Message-ID: <20221031224728.2607760-5-bvanassche@acm.org> (raw)
In-Reply-To: <20221031224728.2607760-1-bvanassche@acm.org>

Since commit f93ed747e2c7 ("scsi: core: Release SCSI devices
synchronously") it is no longer allowed to call scsi_device_put() from
atomic context. Hence this patch that reworks bfad_reset_sdev_bflags()
such that scsi_device_put() is no longer called. This patch fixes the
following smatch warning:

drivers/scsi/bfa/bfad_bsg.c:2551 bfad_iocmd_lunmask_reset_lunscan_mode() warn: sleeping in atomic context

bfad_iocmd_lunmask() <- disables preempt
-> bfad_iocmd_lunmask_reset_lunscan_mode()
   -> scsi_device_put()

Cc: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Cc: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bfa/bfad_bsg.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 73754032e25c..79d4f7ee5bcb 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -2553,18 +2553,20 @@ static void bfad_reset_sdev_bflags(struct bfad_im_port_s *im_port,
 	const u32 scan_flags = BLIST_NOREPORTLUN | BLIST_SPARSELUN;
 	struct bfad_itnim_s *itnim;
 	struct scsi_device *sdev;
+	unsigned long flags;
 
+	spin_lock_irqsave(im_port->shost->host_lock, flags);
 	list_for_each_entry(itnim, &im_port->itnim_mapped_list, list_entry) {
-		sdev = scsi_device_lookup(im_port->shost, itnim->channel,
-					  itnim->scsi_tgt_id, 0);
+		sdev = __scsi_device_lookup(im_port->shost, itnim->channel,
+					    itnim->scsi_tgt_id, 0);
 		if (sdev) {
 			if (lunmask_cfg == BFA_TRUE)
 				sdev->sdev_bflags |= scan_flags;
 			else
 				sdev->sdev_bflags &= ~scan_flags;
-			scsi_device_put(sdev);
 		}
 	}
+	spin_unlock_irqrestore(im_port->shost->host_lock, flags);
 }
 
 /* Function to reset the LUN SCAN mode */

  parent reply	other threads:[~2022-10-31 22:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 22:47 [PATCH 0/4] Call scsi_device_put() from non-atomic context Bart Van Assche
2022-10-31 22:47 ` [PATCH 1/4] scsi: alua: Move a scsi_device_put() call out of alua_check_vpd() Bart Van Assche
2022-11-02 14:27   ` Hannes Reinecke
2022-10-31 22:47 ` [PATCH 2/4] scsi: alua: Move a scsi_device_put() call out of alua_rtpg_select_sdev() Bart Van Assche
2022-10-31 22:47 ` [PATCH 3/4] scsi: bfa: Convert bfad_reset_sdev_bflags() from a macro into a function Bart Van Assche
2022-10-31 22:47 ` Bart Van Assche [this message]
2022-11-08  3:36 ` [PATCH 0/4] Call scsi_device_put() from non-atomic context Martin K. Petersen
2022-11-17 18:29 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221031224728.2607760-5-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=anil.gurumurthy@qlogic.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sudarsana.kalluru@qlogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox