From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796147816; b=eXavZEnpy8b6LPaEwAAM1B/lkgqGvnVxU4H2q8aWsfK9/mRbfbhj5lROFR0IC5Cik5u2 IymeotEVd0Dza7ZBN2B7WDA7OSrVmjYSR/7v5ZwekmjnB2IhhNKbnYFCP+hBA2ybwxEZD TYPFhyC4AuBy1oKMa9nTV5VNo+Hld7yXSVML8qogZHaE7nObd0hIaT0Hs0/uFe1sG7Lwz Nn/ujAQbPeD/y2nKtBwVjTzSyGqy8IAU+o94ygItnYM38u86ab2ZKjqtgcvpE9HamPzwI viuIGE8G7JakdwoY+Xk4gV1/lAfcKBDZy1AsrSxemsmYzfQTu+EhPODYrx9X9MHxnBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796147816; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=8L9yMKWaH4c2wOjI7GTtHdHMr9ITr/ZBcGmgLcEDdRo=; b=MnyBNGU+6dzsaDVn/DARNBKMDD+leHrAgFZKT9SN2+CA1T3jy5iFg3b7KG15XfxJ27Du Y7DQgnwVE1wGCSwm2rA5dt30PZrTPkrT5FTLFip4x7ZQpjlLwbhGN2ZMaGfLFP4Ya3J1D zOgAqY/0Tgfv+0kpJVTcVE0W/FyMCxINKRPJ3fUyCT35q82HB9/PpKH+g1KGHy/1HCWAV 72TGsDmgOo0ea7vJLXP7k9S74OWOdvbkZ0hIDJTyGzy4VSmvqJMvhPlYCUZZQNao/0tpy ZCPPzdJ0HxcQ+Tu1DoXcFDtP4uLDECq8aAErLI3QozLztSB1GU/SPRW2NB2Ckoyi9CQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=2eG9LvaX; arc=none smtp.remote-ip=199.89.1.16 Received: from 013.lax.mailroute.net (013.lax.mailroute.net [199.89.1.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CCCD606A327 for ; Tue, 1 Dec 2026 17:56:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0CCCD606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=2eG9LvaX Received: from localhost (localhost [127.0.0.1]) by 013.lax.mailroute.net (Postfix) with ESMTP id 4jf7r15dLnzlfvqR; Tue, 1 Dec 2026 17:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:from:from:received:received; s=mr01; t= 1796147807; x=1798739808; bh=8L9yMKWaH4c2wOjI7GTtHdHMr9ITr/ZBcGm gLcEDdRo=; b=2eG9LvaXpBkOWt+zONFdczgwGe5zveG2nceGRnSM7SLjO5uqcB4 X5wlrh0eiK/yO+fD19rY7qU3miI9LCMovQl5s/VxE2m7KZ8Lbu5ZbjzkeQoTZZU2 fyHHcZm2t1UGtWQxsqkhTW4CBwSEi0LAjzGbo0sLgcHmObrlQB9XSX8oXUChC2IR dzhXLP4m6/uIgf2sz3f1osG43MVrJ+RhYQd4+vya3matYBVFFHImAsdw3cvPjeHR +syEYQo/IdJ94d7PRSTRJNAnFTWEC63uwiiPZjOfxvmj0KBiZ6U3zJIdrDoXhJ5K qlj+dpl8wtQEGq6cSrQ3vaP0/YZIrNuchPA== X-Virus-Scanned: by MailRoute Received: from 013.lax.mailroute.net ([127.0.0.1]) by localhost (013.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id F8927nCpPY2p; Tue, 1 Dec 2026 17:56:47 +0000 (UTC) Received: from bvanassche.c.googlers.com.com (57.237.82.34.bc.googleusercontent.com [34.82.237.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 013.lax.mailroute.net (Postfix) with ESMTPSA id 4jf7qz0ZBZzlfvqM; Tue, 1 Dec 2026 17:56:47 +0000 (UTC) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Bart Van Assche Subject: [PATCH v2 0/3] mtip32xx: fix surprise removal handling Date: Tue, 1 Dec 2026 09:56:08 -0800 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Jens, This series fixes an initialization order issue and two surprise removal bugs in the mtip32xx driver: 1. Initialize port->svc_wait immediately after allocating dd->port in mtip_hw_init(), before requesting the interrupt and enabling HOST_IRQ_EN, so early interrupts cannot wake an uninitialized waitqueue. 2. Avoid calling blk_mark_disk_dead() from interrupt context in mtip_check_surprise_removal(). Record the removal with MTIP_DDF_DEAD_BIT, wake the service thread with MTIP_PF_SR_BIT, abort in-flight commands via blk_mq_complete_request(), and mark the disk dead only afterward so holder callbacks acquiring s_umount cannot deadlock waiting on those commands. 3. Keep the service thread running across del_gendisk() and abort in-flight commands from mtip_pci_remove() if surprise removal has already occurred, preventing del_gendisk() from hanging indefinitely. Compile-tested only (x86_64, LLVM=3D1 W=3D1 with CONFIG_WERROR=3Dy). Please consider these two patches for the next merge window. Thanks, Bart. Changes compared to v1: - Add patch 1/3 to initialize port->svc_wait immediately after allocating dd->port so mtip_check_surprise_removal() cannot wake an uninitialized waitqueue during mtip_hw_init(). - Place mtip_handle_surprise_removal() above the mtip_service_thread() function comment instead of between that comment and the function. - Replace the unsynchronized bool dd->sr with MTIP_DDF_DEAD_BIT across mtip_check_surprise_removal(), mtip_standby_drive(), mtip_hw_exit(), and mtip_pci_remove(), and remove dd->sr from struct driver_data. - Initialize int_cmd->status to BLK_STS_OK and check the return value of blk_execute_rq() in mtip_exec_internal_command() so direct BLK_STS_IOERR returns on MTIP_DDF_DEAD_BIT are not ignored or misreported using stale status. - Clear the tag bit in port->cmds_to_issue before testing blk_mq_request_completed() in mtip_abort_cmd() so no stale bit remains for an already completed request. - Call synchronize_irq() and flush dd->isr_workq in mtip_handle_surprise_removal() before iterating busy tags to abort in-flight commands, preventing races with concurrent completions. - When MTIP_DDF_REMOVE_PENDING_BIT is set in mtip_handle_surprise_removal(), wait for in-progress mtip_queue_rq() calls with synchronize_rcu() instead of quiescing and unquiescing the queue, and skip blk_mark_disk_dead() while mtip_pci_remove() tears down the disk. - Serialize mtip_handle_surprise_removal() with a new dd->sr_mutex initialized in mtip_pci_probe(). - In mtip_pci_remove(), call mtip_handle_surprise_removal() whenever MTIP_DDF_DEAD_BIT is set (instead of only when dd->sr && !dd->mtip_svc_handler), and otherwise lock and unlock dd->sr_mutex before del_gendisk() to wait for any in-flight mtip_handle_surprise_removal() that started before MTIP_DDF_REMOVE_PENDING_BIT was set. - Add my Signed-off-by tag to all patches. Bart Van Assche (3): mtip32xx: initialize svc_wait right after allocating the port mtip32xx: don't mark the disk dead in the irq handler mtip32xx: abort commands in flight on surprise removal drivers/block/mtip32xx/mtip32xx.c | 93 +++++++++++++++++++++++++------ drivers/block/mtip32xx/mtip32xx.h | 10 +++- 2 files changed, 82 insertions(+), 21 deletions(-)