public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH V3] nvme-pci: fix sleeping function called from interrupt context
@ 2023-12-19 16:48 Maurizio Lombardi
  2023-12-19 17:21 ` Keith Busch
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maurizio Lombardi @ 2023-12-19 16:48 UTC (permalink / raw)
  To: kbusch; +Cc: axboe, linux-nvme, sagi

the nvme_handle_cqe() interrupt handler calls nvme_complete_async_event()
but the latter may call nvme_auth_stop() which is a blocking function.
Sleeping functions can't be called in interrupt context

 BUG: sleeping function called from invalid context
 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/15
  Call Trace:
     <IRQ>
      __cancel_work_timer+0x31e/0x460
      ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
      ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
      nvme_complete_async_event+0x365/0x480 [nvme_core]
      nvme_poll_cq+0x262/0xe50 [nvme]

Fix the bug by moving nvme_auth_stop() to fw_act_work
(executed by the nvme_wq workqueue)

Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---

V3: add the "fixes" tag

V2: Just move nvme_auth_stop() out of nvme_handle_aen_notice()
so the latter can be safely called from interrupt context

 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8ebdfd623e0f..60f14019f981 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4137,6 +4137,8 @@ static void nvme_fw_act_work(struct work_struct *work)
 				struct nvme_ctrl, fw_act_work);
 	unsigned long fw_act_timeout;
 
+	nvme_auth_stop(ctrl);
+
 	if (ctrl->mtfa)
 		fw_act_timeout = jiffies +
 				msecs_to_jiffies(ctrl->mtfa * 100);
@@ -4192,7 +4194,6 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
 		 * firmware activation.
 		 */
 		if (nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) {
-			nvme_auth_stop(ctrl);
 			requeue = false;
 			queue_work(nvme_wq, &ctrl->fw_act_work);
 		}
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] nvme-pci: fix sleeping function called from interrupt context
  2023-12-19 16:48 [PATCH V3] nvme-pci: fix sleeping function called from interrupt context Maurizio Lombardi
@ 2023-12-19 17:21 ` Keith Busch
  2023-12-19 17:25 ` Jens Axboe
  2023-12-19 20:38 ` Sagi Grimberg
  2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2023-12-19 17:21 UTC (permalink / raw)
  To: Maurizio Lombardi; +Cc: axboe, linux-nvme, sagi

On Tue, Dec 19, 2023 at 05:48:23PM +0100, Maurizio Lombardi wrote:
> the nvme_handle_cqe() interrupt handler calls nvme_complete_async_event()
> but the latter may call nvme_auth_stop() which is a blocking function.
> Sleeping functions can't be called in interrupt context
> 
>  BUG: sleeping function called from invalid context
>  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/15
>   Call Trace:
>      <IRQ>
>       __cancel_work_timer+0x31e/0x460
>       ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
>       ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
>       nvme_complete_async_event+0x365/0x480 [nvme_core]
>       nvme_poll_cq+0x262/0xe50 [nvme]
> 
> Fix the bug by moving nvme_auth_stop() to fw_act_work
> (executed by the nvme_wq workqueue)
> 
> Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>

Looks good to me! I applied this for 6.7 since it's a "fix".


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] nvme-pci: fix sleeping function called from interrupt context
  2023-12-19 16:48 [PATCH V3] nvme-pci: fix sleeping function called from interrupt context Maurizio Lombardi
  2023-12-19 17:21 ` Keith Busch
@ 2023-12-19 17:25 ` Jens Axboe
  2023-12-19 20:38 ` Sagi Grimberg
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2023-12-19 17:25 UTC (permalink / raw)
  To: Maurizio Lombardi, kbusch; +Cc: linux-nvme, sagi

On 12/19/23 9:48 AM, Maurizio Lombardi wrote:
> the nvme_handle_cqe() interrupt handler calls nvme_complete_async_event()
> but the latter may call nvme_auth_stop() which is a blocking function.
> Sleeping functions can't be called in interrupt context
> 
>  BUG: sleeping function called from invalid context
>  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/15
>   Call Trace:
>      <IRQ>
>       __cancel_work_timer+0x31e/0x460
>       ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
>       ? nvme_change_ctrl_state+0xcf/0x3c0 [nvme_core]
>       nvme_complete_async_event+0x365/0x480 [nvme_core]
>       nvme_poll_cq+0x262/0xe50 [nvme]
> 
> Fix the bug by moving nvme_auth_stop() to fw_act_work
> (executed by the nvme_wq workqueue)

Reviewed-by: Jens Axboe <axboe@kernel.dk>

-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] nvme-pci: fix sleeping function called from interrupt context
  2023-12-19 16:48 [PATCH V3] nvme-pci: fix sleeping function called from interrupt context Maurizio Lombardi
  2023-12-19 17:21 ` Keith Busch
  2023-12-19 17:25 ` Jens Axboe
@ 2023-12-19 20:38 ` Sagi Grimberg
  2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2023-12-19 20:38 UTC (permalink / raw)
  To: Maurizio Lombardi, kbusch; +Cc: axboe, linux-nvme

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-19 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 16:48 [PATCH V3] nvme-pci: fix sleeping function called from interrupt context Maurizio Lombardi
2023-12-19 17:21 ` Keith Busch
2023-12-19 17:25 ` Jens Axboe
2023-12-19 20:38 ` Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox