From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f181.google.com (mail-dy1-f181.google.com [74.125.82.181]) (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 AFA9633CE80 for ; Tue, 7 Apr 2026 19:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775588984; cv=none; b=Boi51bnayd6a4X2Y0XjrxfmS/Y4fPMGjqGLbO1oEuZFjhgntCHFgox7CDMqtTb0VqyUcsJT+gfp7ks4P8c798RNeiYKbJW1CPdMKygDfF40O2jZd8qOlcfWkPyi/POhvNF8Z//ulcVdlAJWwMbJSuFp0wFtTAk4HJeP6h0Jxkbw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775588984; c=relaxed/simple; bh=F7Ik5GvzqSho+qGhW3m+nyZ4xgQ6Q5bdYf0D+QXANv0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QMO87SASf2KhnBYTlT2E6udtuvcIZZZyea63HnbG518W12v29c7a54nFPb1Z/Lf2GVwPRIn7cmGD+fjaYnuK4DFvWJkHc5aZMgtVZ06nAYNm2RVUks8sc+Tb4PobH348js0RpCXeSlKSRkn79lm1IAGtvSiRUNaQ3ygxGyuPtA0= 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=WzFvaf5m; arc=none smtp.client-ip=74.125.82.181 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="WzFvaf5m" Received: by mail-dy1-f181.google.com with SMTP id 5a478bee46e88-2ce7d6fd2c5so114423eec.0 for ; Tue, 07 Apr 2026 12:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1775588982; x=1776193782; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NjiBDaNfLbZqQ4CQfzb2FfNQVqaLxJoOlYZcmUe9dL8=; b=WzFvaf5mYlovw7TaxItK5TL/kAF7CGBHt40k33ji61v9PX9wMLdmOwgHFDUmSD4vbG rmmees8BbASE3/cAUM7e9u1k2mlDtgJnnXYE3/0/V+hJDGeMzdT8f8DGb32gJLWoMaX7 Kg8f3reQHYeZD/jhBcAGwru3HBDFOpLirzvlmfH3jtmpsQLaDE/wF3+m+pxsAXnwFij1 c0OIK0rQT/IQmYzFsJiqzgLLKr5cF/dCaBpxh+2hXcumkRL7lENVXhBulT2YdQiDro6S Rzq6sl5HpyzB7uDazx2UbKP4iGhu25+7iWsnAFsLg+tiLfdGAfo+xixBHCmOKtLv/NQf 1EUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775588982; x=1776193782; h=in-reply-to: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=NjiBDaNfLbZqQ4CQfzb2FfNQVqaLxJoOlYZcmUe9dL8=; b=FGyhzEExmxovR2EBqbY9sBY5Lw3TO3T4iSbunpnJiSXtqRkkIoRgkVG1K+Om49Y/d9 oCqFUE4qTRy4wpju9SiYt1sD2sWGPzYYOay+zJGc2RCEomsfKG/aWChnL33G5vs4dHZO b7hNeL97ITkv7bjSJiAL07p0wTvlTHTPnUozvv2xe4vf6b/yys1rvfD/1esPweDXnhel 3Ew31jAU4JoktkiaZFypFehMgqnm3pAz2NOIWC6p4S97vwtS8LIHpr9ONFzBt0QPXkog o1ys3E4a1DH4xX8KDWC28gbGxA9xbkvlW5vakki8l0dosr0fkSVKIPwLiVjfEfK6HsIM oLgw== X-Forwarded-Encrypted: i=1; AJvYcCWK+q+9MjbNGyvb8mHlj3grsjrSuViYlN1yAIFaxUyWCS8aYbkvh2GLp+rp3/UoLIMPzdnoPB3zxoelbsI=@vger.kernel.org X-Gm-Message-State: AOJu0YytJXlALGRS56ClqS+Ayd97Ay0ygI6S3YHMfuJFeViaGQfiI5DL bm/AoVCOzNyyyTIsxw0bFcqJPQB+PXVHSMzyK9Gtu3TpggLOCMm/z0SmRz3P9nmwhzYcvYMF5Qm U5OGi X-Gm-Gg: AeBDievCFYf1hU0fFzGRsZ+LHzH145X2/WDEkEoNuXsWgyQu5xKmMLmHW6/mTRLu0Fi QUYKrsJ8AICD6Dz0D7fhvnr9XF9lkJ6gDDRf6QCsXwiQ/iuJzg/WCPh11HJyjiaVoXksPFSiCsU hWBOzbNPtocvtTHg7Fy281jRUS5P5268oRnUDK/uqGRMHZS048YuYqAKA8bWfE1TsGRvKxxwGMd gMPX9jHrD9PLuke0AJiflriC0jeuRzLaVgtsD6HtZM4bij0LeYuzxnwazIt7Y2aK6pK3nlacq2t g/o7GaMpBHGXb/Kw4uld0n1zv8zyAVPaXFZmRczxkjGETN8TSDFRIvXjFOngSgcKCIN8T7UCOhD g89we+ue3vE+V6wlQ/tKucC6gez0ZCqR4d+SHu0slNOR8p7piPM4GWCZsTuOiEeKHQ0EHtcgrb8 GGE3FWCgjryd8229nzRWSdWkoAzvPoDX76nG3P2aoNTv7s X-Received: by 2002:a05:7300:ce95:b0:2d1:45d7:53ec with SMTP id 5a478bee46e88-2d145d791afmr1672067eec.19.1775588981443; Tue, 07 Apr 2026 12:09:41 -0700 (PDT) Received: from medusa.lab.kspace.sh ([208.88.152.253]) by smtp.googlemail.com with UTF8SMTPSA id 5a478bee46e88-2d2cb4a7cdbsm573197eec.19.2026.04.07.12.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 12:09:41 -0700 (PDT) Date: Tue, 7 Apr 2026 12:09:40 -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: <20260407190940.GF2861-mkhalfella@purestorage.com> References: <20260328004518.1729186-1-mkhalfella@purestorage.com> <20260328004518.1729186-10-mkhalfella@purestorage.com> <73a9c0e2-ecd0-4170-8723-259529617ec0@suse.de> <20260331165510.GD2861-mkhalfella@purestorage.com> <019cf04f-8988-46fd-aecd-0f77ac5f8b8a@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=us-ascii Content-Disposition: inline In-Reply-To: <019cf04f-8988-46fd-aecd-0f77ac5f8b8a@suse.de> On Tue 2026-04-07 07:48:50 +0200, Hannes Reinecke wrote: > On 3/31/26 18:55, Mohamed Khalfella wrote: > > 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()? > > > > Thins is, in order to make nvme_fence_ctrl() synchronous we have to > wait for the operation itself (which is asynchronous) to complete. > And that wait in itself is implemented by a wait queue. > So we're having a wait queue calling nvme_fence_ctrl(), which calls > another wait queue waiting for a completion. > And then (if the IRS bit is not set) calling another waitqueue for > checking the log page. There is no point of checking the CCR logpage before getting AEN. Sure we can implement some sort of polling, but I do not think this is the right approach. > > I think we could simplify this by simply making nvme_fence_ctrl() > asynchronous, which could do away with all the workqueue handling. I am not sure I understand exactly how nvme_fence_ctrl() can be make asynchronous. Can you provide example code?