From: sashiko-bot@kernel.org
To: "Jeff Layton" <jlayton@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 10/12] scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown
Date: Mon, 30 Nov 2026 13:46:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-241295@kernel.org> (raw)
In-Reply-To: <20261130-sas-abba-v5-10-487c39d1114f@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] scsi: mpt3sas: sleeping in IRQ context via
shost_for_each_device()
--
commit 1a4b089456cad5e9b57e64d60c29eab7e4c9da7f
Author: Jeff Layton <jlayton@kernel.org>
scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown
This commit adds ioc->block_lock to serialize _scsih_block_io_device()
against sdev->hostdata initialization and teardown in scsih_sdev_init() and
scsih_sdev_destroy().
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index e2973fbb8814c..de77bf0137f3b 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
[ ... ]
> @@ -4403,26 +4412,30 @@ _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle)
> struct MPT3SAS_DEVICE *sas_device_priv_data;
> struct scsi_device *sdev;
> struct _sas_device *sas_device;
> + unsigned long flags;
>
> sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
>
> shost_for_each_device(sdev, ioc->shost) {
> + spin_lock_irqsave(&ioc->block_lock, flags);
> sas_device_priv_data = sdev->hostdata;
> if (!sas_device_priv_data)
> - continue;
> + goto next;
> if (sas_device_priv_data->sas_target->handle != handle)
> - continue;
> + goto next;
> if (sas_device_priv_data->block)
> - continue;
> + goto next;
> if (sas_device && sas_device->pend_sas_rphy_add)
> - continue;
> + goto next;
> if (sas_device_priv_data->ignore_delay_remove) {
> sdev_printk(KERN_INFO, sdev,
> "%s skip device_block for SES handle(0x%04x)\n",
> __func__, sas_device_priv_data->sas_target->handle);
> - continue;
> + goto next;
> }
> _scsih_internal_device_block(sdev, sas_device_priv_data);
> +next:
> + spin_unlock_irqrestore(&ioc->block_lock, flags);
> }
[Severity: High]
Can shost_for_each_device() in _scsih_block_io_device() drop the final
reference on sdev in interrupt context?
shost_for_each_device() pins sdev via scsi_device_get() and releases it on
the next iteration via scsi_device_put(). In the race with
__scsi_remove_device() that this patch addresses, __scsi_remove_device()
calls ->sdev_destroy(sdev) and immediately drops its own reference with
put_device():
CPU0 CPU1 (<hardirq>)
__scsi_remove_device() _scsih_block_io_device()
__scsi_iterate_devices()
scsi_device_get(sdev)
scsih_sdev_destroy(sdev)
spin_lock_irqsave(&ioc->block_lock)
sdev->hostdata = NULL
spin_unlock_irqrestore(&ioc->block_lock)
...
put_device(&sdev->sdev_gendev)
spin_lock_irqsave(&ioc->block_lock)
...
spin_unlock_irqrestore(&ioc->block_lock)
__scsi_iterate_devices()
scsi_device_put(sdev)
scsi_device_dev_release()
might_sleep() <-- sleep in irq
scsi_device_dev_release() calls might_sleep(), cancel_work_sync(),
blk_put_queue() and mutex_lock(&sdev->inquiry_mutex) from hard interrupt
context.
Using __shost_for_each_device() under shost->host_lock avoids taking and
dropping sdev references in interrupt context.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-sas-abba-v5-0-487c39d1114f@kernel.org?part=10
next prev parent reply other threads:[~2026-11-30 13:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 13:21 [PATCH v5 00/12] scsi: mpt3sas: Fix delayed not-responding block deadlock and related bugs Jeff Layton
2026-11-30 13:21 ` [PATCH v5 01/12] scsi: mpt3sas: Don't leave requeued firmware events pending at teardown Jeff Layton
2026-11-30 13:21 ` [PATCH v5 02/12] scsi: mpt3sas: Disarm a requeued event's timer when it leaves the event list Jeff Layton
2026-11-30 13:21 ` [PATCH v5 03/12] scsi: mpt3sas: Hold event references while cleaning up the event queue Jeff Layton
2026-11-30 13:21 ` [PATCH v5 04/12] scsi: mpt3sas: Requeue topology events only for busy devices Jeff Layton
2026-11-30 13:21 ` [PATCH v5 05/12] scsi: mpt3sas: Fix pcie_device leak in _scsih_ublock_io_device_wait() Jeff Layton
2026-11-30 13:21 ` [PATCH v5 06/12] scsi: mpt3sas: Restore unblock retry " Jeff Layton
2026-11-30 13:21 ` [PATCH v5 07/12] scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled Jeff Layton
2026-11-30 13:51 ` sashiko-bot
2026-11-30 13:21 ` [PATCH v5 08/12] scsi: mpt3sas: Reset the TUR retry count for each device Jeff Layton
2026-11-30 13:21 ` [PATCH v5 09/12] scsi: mpt3sas: Cache the missing delays the IOC actually uses Jeff Layton
2026-11-30 13:21 ` [PATCH v5 10/12] scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown Jeff Layton
2026-11-30 13:46 ` sashiko-bot [this message]
2026-11-30 13:21 ` [PATCH v5 11/12] scsi: mpt3sas: Don't use freed hostdata while polling devices Jeff Layton
2026-11-30 13:21 ` [PATCH v5 12/12] scsi: mpt3sas: Time out delayed not-responding device blocks Jeff Layton
2026-11-30 13:55 ` sashiko-bot
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=sashiko-outbox-241295@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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