From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f42.google.com (mail-dl1-f42.google.com [74.125.82.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BFE43EF0A2 for ; Tue, 31 Mar 2026 16:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976114; cv=none; b=P8ZWKgTDKBwZZ14c7n/sYo8eigYQ7J4MMCxzLAqnL7c1dJQ8SowFXwV5/DJXhIkmmRTiCHkj8+WjSzYTK1oqvaECSPxMIqjYfRzGXA8c5HBoQb8PkmfeagYMG2FU1eM8BL8GnBtGtPCd+Cc3N23deKQkiwaMyr/IFJBYxUxNQHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774976114; c=relaxed/simple; bh=49rC3p5JeV+B6X0x41vFKhg6bCx8jlBl7kqZ4rscGbY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W6PfT3r/lHv6eFspf29YUrQDWQZVDAWccSyXM3T/XcIqK64ZVLwMcqLqOI6/zv290nR9yeHC2/WJbVZfGf/8DtVutFvCgAsVQsxA7+d0xIfIr/+vUu4MPOh1TsoXklrjgbCk9pywjqV3axU/GAiPjxvnqUdmrb+9ksXp581CcYQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=HP+hoJml; arc=none smtp.client-ip=74.125.82.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="HP+hoJml" Received: by mail-dl1-f42.google.com with SMTP id a92af1059eb24-126ea4e9694so628189c88.1 for ; Tue, 31 Mar 2026 09:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1774976112; x=1775580912; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=q20Cac3clgAqBT/P1Zedui6ELXRh9/Rh5lb+mmpfWzM=; b=HP+hoJmlabNEXv7NiPlKs1cbBmj7iVhyLdMZ+fBe6+o2vYr59J8BnNIapScw9Gv9ml M544k1ANaGFR0zV5bd6UhTpLwZfo5jeXzQ+n64OGCbRvucaC3E65Vf6MzW65XplRhhFR Vvl6bd1FYtetqHuZuVH/RrIa/QrZY2ExboJ4Gux3BnDvED9bN31rKsV+7HDeaRf/i4ie fs/hapkCcx13PceZDewg+jL/RFq8vGWnEO7c3aY9RcQodLTmGFOKFNFK07vhX4+SQH4K TypH1k1BQ2jrX9l7rd5a9r/YKBF5fGUV81JGS/QZbsYQKLSpvjUhIPt3uf33zYhcTRWP 2l+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774976112; x=1775580912; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=q20Cac3clgAqBT/P1Zedui6ELXRh9/Rh5lb+mmpfWzM=; b=rSCn8ywImL0yJIcC8XZbaur5u9DewAlul6I3sTLCXXs3h7zS+zIgU5vMmrIk6hXEd4 ZMNRtjhr9PNYRhtmyhMawaxvN0g5BkTZk/4HWGPF1TSVBcMdlpLI5RGWZVMQoCOVS4Ra GPBmWLkJJsuSZ6y2njiohpQACZq+n/iqUBXziAwfiBB5v0j3Oz6b2k+8Eu/++sqEu4TI Nheg8Cbw6EqslaBTTnOhTsRjijBLJb7EdO2Y/l6o8X3efJdDMVCsDkYQjxr2RP3YwOvp NyqYrn5UVMcNbCl5WNCE9udxltkyprMZb/plcVKhqqDqWSK9VMngbQD/9RccYjn7lV2H FFXA== X-Forwarded-Encrypted: i=1; AJvYcCUGPncvbKFOmI5McbUHJWI6h2/E1jwc+DWmHVKrikdpfFhKlC2ovl6gRcAbF/WSnNFMFG/P4lLOfssM8Rk=@vger.kernel.org X-Gm-Message-State: AOJu0YzG02ZQHr8atA/YaZXFzQburSY5TvVHlS7JdSnxEnfiefHW6UR3 Un7YIqinSudX85vAern+e+6pIsSPtvn4PJaQ4kiOs/0MESDwtEutj03sAcu/fG+sgKY= X-Gm-Gg: ATEYQzz6LLGuvTzm57JsKuAexVQSofLwBjISdjnYeUAVPMaI8dicP9w5Fz4vpX5FfSa RouIIjFkLI74VDEVXd7v9SssiU4ST9ISzO/MLh7roC78XPum0fMLSZ5rE4izHPw5DBfCsosMacl S6+opTJgXWKZivZB1Q4yR51DmN/413Ziu/rRnvUycmnTF/4yiz/wqQ6JlYGD/ChSS9uA5fw7Ayv Ta26gDvo3CgZHGqBekbIYyPimmI2jUROr4N2vk/ReRcGfXw4DdFXmE5NtHQX3dKu3NnoRhKARxP JSKLuU0ny5qYoWv7wHvH+jwqheITgzPwhX9rn1YMhgsGv6nkvY4369BptOdM3dNdV2IhobxoVj/ s/WIlF7uqNf13YAheM1/sVfjTUZVE1e33XBWw0aKFYC7jARAm7+UTR7HRulaaHLCaIqjF67kfYO wfHneCxld5eBeiN5aHe4r0YO4GEMGk1ju1gsXrbF086xnV X-Received: by 2002:a05:7022:618a:b0:11b:7970:ea3f with SMTP id a92af1059eb24-12be6578552mr136255c88.25.1774976112230; Tue, 31 Mar 2026 09:55:12 -0700 (PDT) Received: from medusa.lab.kspace.sh ([208.88.152.253]) by smtp.googlemail.com with UTF8SMTPSA id a92af1059eb24-12aba581027sm16280630c88.4.2026.03.31.09.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 09:55:11 -0700 (PDT) Date: Tue, 31 Mar 2026 09:55:10 -0700 From: Mohamed Khalfella To: Hannes Reinecke Cc: Justin Tee , Naresh Gottumukkala , Paul Ely , Chaitanya Kulkarni , Jens Axboe , Keith Busch , Sagi Grimberg , James Smart , Aaron Dailey , Randy Jennings , Dhaval Giani , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 09/15] nvme: Implement cross-controller reset completion Message-ID: <20260331165510.GD2861-mkhalfella@purestorage.com> References: <20260328004518.1729186-1-mkhalfella@purestorage.com> <20260328004518.1729186-10-mkhalfella@purestorage.com> <73a9c0e2-ecd0-4170-8723-259529617ec0@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <73a9c0e2-ecd0-4170-8723-259529617ec0@suse.de> On Mon 2026-03-30 12:53:07 +0200, Hannes Reinecke wrote: > On 3/28/26 01:43, Mohamed Khalfella wrote: > > An nvme source controller that issues CCR command expects to receive an > > NVME_AER_NOTICE_CCR_COMPLETED when pending CCR succeeds or fails. Add > > sctrl->ccr_work to read NVME_LOG_CCR logpage and wakeup any thread > > waiting on CCR completion. > > > > Signed-off-by: Mohamed Khalfella > > --- > > drivers/nvme/host/core.c | 49 +++++++++++++++++++++++++++++++++++++++- > > drivers/nvme/host/nvme.h | 1 + > > 2 files changed, 49 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > > index 5603ae36444f..793f203bfc38 100644 > > --- a/drivers/nvme/host/core.c > > +++ b/drivers/nvme/host/core.c > > @@ -1920,7 +1920,8 @@ EXPORT_SYMBOL_GPL(nvme_set_queue_count); > > > > #define NVME_AEN_SUPPORTED \ > > (NVME_AEN_CFG_NS_ATTR | NVME_AEN_CFG_FW_ACT | \ > > - NVME_AEN_CFG_ANA_CHANGE | NVME_AEN_CFG_DISC_CHANGE) > > + NVME_AEN_CFG_ANA_CHANGE | NVME_AEN_CFG_CCR_COMPLETE | \ > > + NVME_AEN_CFG_DISC_CHANGE) > > > > static void nvme_enable_aen(struct nvme_ctrl *ctrl) > > { > > @@ -4873,6 +4874,47 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl) > > kfree(log); > > } > > > > +static void nvme_ccr_work(struct work_struct *work) > > +{ > > + struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, ccr_work); > > + struct nvme_ccr_entry *ccr; > > + struct nvme_ccr_log_entry *entry; > > + struct nvme_ccr_log *log; > > + unsigned long flags; > > + int ret, i; > > + > > + log = kmalloc(sizeof(*log), GFP_KERNEL); > > + if (!log) > > + return; > > + > > + ret = nvme_get_log(ctrl, 0, NVME_LOG_CCR, 0x01, > > + 0x00, log, sizeof(*log), 0); > > + if (ret) > > + goto out; > > + > > + spin_lock_irqsave(&ctrl->lock, flags); > > + for (i = 0; i < le16_to_cpu(log->ne); i++) { > > + entry = &log->entries[i]; > > + if (entry->ccrs == NVME_CCR_STATUS_IN_PROGRESS) > > + continue; > > + > > + list_for_each_entry(ccr, &ctrl->ccr_list, list) { > > + struct nvme_ctrl *ictrl = ccr->ictrl; > > + > > + if (ictrl->cntlid != le16_to_cpu(entry->icid) || > > + ictrl->ciu != entry->ciu) > > + continue; > > + > > + /* Complete matching entry */ > > + ccr->ccrs = entry->ccrs; > > + complete(&ccr->complete); > > + } > > + } > > + spin_unlock_irqrestore(&ctrl->lock, flags); > > +out: > > + kfree(log); > > +} > > + > > static void nvme_fw_act_work(struct work_struct *work) > > { > > struct nvme_ctrl *ctrl = container_of(work, > > @@ -4949,6 +4991,9 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result) > > case NVME_AER_NOTICE_DISC_CHANGED: > > ctrl->aen_result = result; > > break; > > + case NVME_AER_NOTICE_CCR_COMPLETED: > > + queue_work(nvme_wq, &ctrl->ccr_work); > > + break; > > default: > > dev_warn(ctrl->device, "async event result %08x\n", result); > > } > > @@ -5144,6 +5189,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) > > nvme_stop_failfast_work(ctrl); > > flush_work(&ctrl->async_event_work); > > cancel_work_sync(&ctrl->fw_act_work); > > + cancel_work_sync(&ctrl->ccr_work); > > if (ctrl->ops->stop_ctrl) > > ctrl->ops->stop_ctrl(ctrl); > > } > > @@ -5267,6 +5313,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, > > ctrl->quirks = quirks; > > ctrl->numa_node = NUMA_NO_NODE; > > INIT_WORK(&ctrl->scan_work, nvme_scan_work); > > + INIT_WORK(&ctrl->ccr_work, nvme_ccr_work); > > INIT_WORK(&ctrl->async_event_work, nvme_async_event_work); > > INIT_WORK(&ctrl->fw_act_work, nvme_fw_act_work); > > INIT_WORK(&ctrl->delete_work, nvme_delete_ctrl_work); > > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > > index f2bcff9ccd25..776ee8aa5a93 100644 > > --- a/drivers/nvme/host/nvme.h > > +++ b/drivers/nvme/host/nvme.h > > @@ -419,6 +419,7 @@ struct nvme_ctrl { > > struct nvme_effects_log *effects; > > struct xarray cels; > > struct work_struct scan_work; > > + struct work_struct ccr_work; > > struct work_struct async_event_work; > > struct delayed_work ka_work; > > struct delayed_work failfast_work; > > Hmm. The 'nvme_fence_ctrl' operation introduced in the previous patch > is synchronous, yet in this patch we're looking a a log page to figure > out if the cross-controller reset is complete. > Which is slightly irritating. > Wouldn't it be better to make the 'nvme_fence_ctrl' operation > asynchronous, and then have a separate function to wait for the fence > operation to complete (which then could look at log pages etc)? True nvme_fence_ctrl() is synchronous, but it runs in from ctrl->fencing_work. What is it that you find irritating about nvme_fence_ctrl()? > > Cheers, > > Hannes > -- > Dr. Hannes Reinecke Kernel Storage Architect > hare@suse.de +49 911 74053 688 > SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg > HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich