From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796044895; b=pX7BFITjZuw3dSO2aDWqYcBBJaB6cNKoQRNPidUPm5niboGWcy/xXo9KoFm+M0DD1qBv c+DlGmnSq/MkNifzGTqElFQWsAoVONUcz8oo39HBgxXM23WyUZ042XgJaiqa/PnY9CQPU t8TaYNu5RH1NYJsZow1JCTRq21VtR3u9368l7ma6TrAIfIozIDUH+qz+cwe0covv1kMRI Twh45RDSodY/gL5adwJyYbqYrthhQLzYXdT05jN5yDk28brYwzO1qhFNedfzRHIU2Gdzc yLoA+RyMcGgQRvJmGvY+P9o2siSs1Cw/k5M13RYlBl3PZLdoRMlh46CtFHA1hEsOhag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796044895; h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=PiWd9gvd9SPzpHFkI0tFJq9qrM8qzF+kiWDZvRxAEFs=; b=Kk0q0Z5uJwajGdhJq4I23U8kFbBbbdB4UnHLQXKznbFtM5Xt5DfJUgSh3PlUSUaUKTTI VwFUjbsyiRxu2F71Fwg15TNBxTx5J/kj19ewTJkVPrEg7goi3/tuyd0ZJHFgQXYzTsnhi XjkLo/E+1WIhBTREhdZEWoNojm0suBjfBlEKILOdnKIUAlyAk+F0ifpIw0EIjBtAXuXIu arV8KiI3E9N9IFnRIvkQ/KwUSItN1CxMuZMz+K8V8cJQ2yaO8Fl4/egHVMh8Hyu7TanTz zZ3T+1Vk30UsSjn9/bndX9TPOcQCEFsDK9UK2v53TBGHtRluxDJTwiUsJUau55HdwXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=REmTiQBM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FEA4606A684; Mon, 30 Nov 2026 13:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=REmTiQBM Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4E1B1F00924; Mon, 30 Nov 2026 13:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796044894; bh=PiWd9gvd9SPzpHFkI0tFJq9qrM8qzF+kiWDZvRxAEFs=; h=From:Subject:Date:To:Cc; b=REmTiQBMBsie4lIykcYwCK5z3W/BYXfxUJs8kFMzc8l9kdHHg29VQ9wlPxU34SZQ6 z+AqUBzmGS+m+ejtFObLuiRF4wkmZ5B2eFV3q/nwWEMooXvQtrSYpz2TMxZax8myrb k2fnl8TBhbBahCe/3WlwCiJTRFeKpRfAdE7aHVEPJP1EztQfWP4oTERrdVqsQWb47T C0lRO1HvA0C2idnokJSQU7HF8mvSl0kvpowPtQPmS7TZ6NW23bXEpH/rVs09fPsN+a AnZooTJVBjcabYXYoamyoSIVJqxf/ddGN55q4zIjWVimGzayAxzEZAIhGrrv1axu6W jp7LsZy9gPq6w== From: Jeff Layton Subject: [PATCH v5 00/12] scsi: mpt3sas: Fix delayed not-responding block deadlock and related bugs Date: Mon, 30 Nov 2026 08:21:02 -0500 Message-Id: <20261130-sas-abba-v5-0-487c39d1114f@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/23MTQ6CMBCG4auYrq3p9A9w5T2Mi2kZoNGAaQ3RG O5uZSOKy28yz/tkiWKgxPabJ4s0hhSGPg+z3TDfYd8SD3XeTAppQSjBEyaOziEn9I332jSkLMv v10hNuM+p4ynvLqTbEB9zeYT39U9kBA7clb6uC9CoCn84U+zpshtiy96VUX4kCLmQkgvulKscl oV2BldSLaVdSJWlKcCVRptK41rqhYTyVxora1sJ31j4ktM0vQCajHCtTwEAAA== X-Change-ID: 20261030-sas-abba-eacfcc45fe36 To: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Ranjan Kumar , "James E.J. Bottomley" , "Martin K. Petersen" , Nagalakshmi Nandigama , James Bottomley Cc: Keith Busch , Sreekanth Reddy , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6293; i=jlayton@kernel.org; h=from:subject:message-id; bh=JPKbqPFF4kzeIOhofqnTDJfrNCWrynduwRVix9XJLaM=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBrDXhUR0c3CUGfGnioB9gGUjTPyT4Lq17purCR7 TUQUHq4vzSJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaw14VAAKCRAADmhBGVaC FV6GEADGVa/A9a21sLQbHWX48NPMQeJnz9NAsuxKebXL2lOq42MGkUZZYOKp9+gtRFekF9xD1Ir nYA7WcZeyQ/SrT4XVeDakr/QzyAvYdYfor6rhvrfWzmnN0rKyVtB9PbmcpAn/Y5CYRNXuVuajt6 z+JeJ0fg+jHUtAAboOiEif+LQ9vSqCXntpwXXhzm3RZ54p9Y03NJU9dSCEq8b4YstwRSEsZKiqP 8EFaFtJnU1avgHyoyDNfsONYws8Qe0HWbU+M4yvVCtsrRfGMHaqhKVZUpuZ6PLEWe6rlsFMP14Z RT4lp4Q1a8ddXZYmu1XvArbWCImeBT8FBNWCkwJ5k1rrOGSfgWRLLwZSzZtuxpLwDXrcEcUxinL Fc7B8kGBPiO3AgWcesj1Ry/a41tq1BlkMEZKlEBODm0ZIW8b69tDfINdRDiz2xVV4zWQHSVxtSL QH0iw55Gza+718uq594hRkN4MuCIJhXlo9zklxWfozTh/DdQ4BXdPzCT5lzylqM9lG2bvRFTwLP snDSe6y7zS1VaAq0FzswA8LSx5C+n+XBHXesg5VAqXJTNLhZAcygoUty3vzpOucW1GNdZ9F3qiE s1NgcBupnFp+V5v4vYEMqx4l3xySrkeBdQmRakrgq6EqX4OxN2e0g1cRGCQYlF1TkdJ/SUHXIA6 gI0gUiHIsovPp2g== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 This version fixes a few more bugs that sashiko and other agentic review spotted: The main impetus of this set is to fix a deadlock that occurs regularly in Meta's fleet. We have an agent that writes "- - -" to the sysfs scan attribute at regular intervals to check for new devices. Sometimes that triggers a deadlock in the driver (see the last patch for details on that). Along the way, agentic review spotted a pile of other bugs in these areas, which I also patched. This patchset mostly affects firmware event handling, device block/unblock, TUR polling after a reset, and teardown. Notably, the general I/O path should be unaffected. I don't do much SCSI driver work, but this problem fell into my lap. I relied heavily on AI agents for this series. If this series is acceptable, I would like to see it in linux-next soon. Extra testing would also be welcome. Thanks, Jeff Signed-off-by: Jeff Layton --- Changes in v5: - Rebase onto next-20261120. - New patch 2: disarm the timer of a requeued event when dequeue_next_fw_event() takes the event off the list. Otherwise a reset cleanup that overlaps with teardown can let the timer fire after the workqueue is destroyed. Patch 3 is updated for this change. - Patch 7: - Do not count a TUR check that is skipped during a host reset as a retry. - When the scan is cancelled, also skip the rest of the MPT3SAS_REMOVE_UNRESPONDING_DEVICES handler. Its config requests stall the reset, or deadlock on reset_in_progress_mutex while the driver loads. - Patch 11: select the sdevs to poll or unblock under block_lock. - Patch 12: - A DNR on an sdev that the worker polls, or will poll later in the same pass, makes a new timed block. The worker leaves that sdev to the new deadline. - Set an sdev that fails its TUR check offline under block_lock, and remove the priv->deleted check before a timed block. Thus an sdev that is set running again through sysfs can be blocked again. - Reword all commit messages. - v4 went out with a "PATCH v3" subject by mistake. - Link to v4: https://lore.kernel.org/r/20261118-sas-abba-v3-0-5562d690cf61@kernel.org Changes in v4: - New patches 1-8 and 10 fix pre-existing bugs in the code that this series changes: - 1-2: fix UAFs and refcounting in the cleanup of the fw event queue. Do not leave requeued events pending at teardown. - 3: requeue topology events only for busy devices. Do not requeue them for devices that the driver cannot add. - 4-7: fix these TUR polling bugs: - a pcie_device leak - a lost unblock retry - polling that continues after the scan is cancelled - a retry count that is not per device - 8: cache the missing delays that the IOC actually uses - 10: do not use freed hostdata while the driver polls devices - Patch 11: - Use the PCIe missing delay (from PCIe IO Unit Page 1) for NVMe devices. - Arm dnr_unblock_work for the earliest deadline. - Skip the timed unblock during host reset, but not during SCSI EH. - Do not put a timed block on offline sdevs. - When a hard reset cancels polling, give new deadlines to the sdevs that stay blocked. - Give deadlines to the sdevs that a broadcast primitive pass blocks. Prevent dnr_unblock_work from unblocking them while the pass runs. - A repeat DNR restarts the deadline, at most MPT3SAS_DNR_BLOCK_MAX_EXTENDS times. - At the next worker unblock, do a TUR check on expired sdevs. - Keep the blocks that the driver makes during polling. - Use system_dfl_wq instead of system_wq. - Link to v3: https://lore.kernel.org/r/20261106-sas-abba-v3-0-571b854594aa@kernel.org Changes in v3: - Patch 1: publish sdev->hostdata under ioc->block_lock in scsih_sdev_init(), so the interrupt-time block can't see it before its sas_target store - Clear block_deadline on all affected sdevs, under ioc->block_lock, before the fw event worker starts TUR polling, not per-sdev mid-poll - Take ioc->block_lock in _scsih_block_io_all_device() and clear block_deadline on already-blocked sdevs, so dnr_unblock_work can't unblock them during broadcast primitive TM - Defer dnr_unblock_work while scsi_host_in_recovery(), and use mod_delayed_work() for the retry - Link to v2: https://lore.kernel.org/r/20261102-sas-abba-v2-0-b3b9ba874b5a@kernel.org Changes in v2: - New patch 1: use a new ioc->block_lock to serialize the interrupt-time sdev block with the hostdata teardown in scsih_sdev_destroy(). This fixes a pre-existing UAF. - Do the timed unblock under ioc->block_lock. This prevents a race with an interrupt-time block. - Clear block_deadline before the fw event worker polls a returning device with TURs. Then dnr_unblock_work cannot unblock the device during the poll. - Link to v1: https://lore.kernel.org/r/20261030-sas-abba-v1-1-b8cdd714a37c@kernel.org --- Jeff Layton (12): scsi: mpt3sas: Don't leave requeued firmware events pending at teardown scsi: mpt3sas: Disarm a requeued event's timer when it leaves the event list scsi: mpt3sas: Hold event references while cleaning up the event queue scsi: mpt3sas: Requeue topology events only for busy devices scsi: mpt3sas: Fix pcie_device leak in _scsih_ublock_io_device_wait() scsi: mpt3sas: Restore unblock retry in _scsih_ublock_io_device_wait() scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled scsi: mpt3sas: Reset the TUR retry count for each device scsi: mpt3sas: Cache the missing delays the IOC actually uses scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown scsi: mpt3sas: Don't use freed hostdata while polling devices scsi: mpt3sas: Time out delayed not-responding device blocks drivers/scsi/mpt3sas/mpt3sas_base.c | 62 ++- drivers/scsi/mpt3sas/mpt3sas_base.h | 25 + drivers/scsi/mpt3sas/mpt3sas_scsih.c | 939 +++++++++++++++++++++++++++++------ 3 files changed, 867 insertions(+), 159 deletions(-) --- base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726 change-id: 20261030-sas-abba-eacfcc45fe36 Best regards, -- Jeff Layton