Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp236677lqo; Wed, 27 Mar 2024 11:29:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxjcLT9dF4Sv+o11slGI1s0RE5BD9Vom+VMiRbWpZ0yzsYQvpu18G4y1OvwaCpeTnb71xkfcd6yJdpd3va7/tio22C33ehnPWwRVfx6A== X-Google-Smtp-Source: AGHT+IFJaREzskCDiMYiaFwmx+ENCD0W3zCXVYFgWX2eMcTYyN2vZWs7QC9WLjB6HnJnNiCVk3N1 X-Received: by 2002:a05:6358:63aa:b0:17e:a9b7:2636 with SMTP id k42-20020a05635863aa00b0017ea9b72636mr196454rwh.22.1711564190701; Wed, 27 Mar 2024 11:29:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711564190; cv=pass; d=google.com; s=arc-20160816; b=YTa2JwndHYI56FNjZ3plrWUDBv2SVD4N+c25crs7uFUv7BpAqgNihOeG83BD00VgJX 4sF9jXQwv6GpOte0iSJI8WzZG6KOdfQi+2MUJ2M8ze9jirQPJUAHA2aNz+LuxCcm+rsx v69PECAKbHqWCNpJxY2DDycefuX1gy2PfbP54UJ9CQXLaF4WhqAKuFWQPtO6rMTO7pN2 QXt63z8zvNrcA5BW8+SXz7sDp+P/HOtKyPZlYPOnNCKnOnEwqG58oUmSXbhnq0WFxiL5 gP/SbL1T/rvnIspKBMI7l6v8ByGh8w0A7ys62hjNF9d1UzgJoJ/jqWV5+XF/srmjUs2u VWqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=DK+6oPFG2RAmbNnZxniLjxIRVPvlCMr65C5gbEfn7VY=; fh=A8Xdo62dPjxPUjvMEPYCSFU6uftyl3eTB3Ci3rbQV+E=; b=Xp7PUsggPLX5pY5j0/ejcNuaENNgUJrQJ7+Yd8Yj1W8kx9aOB+AG++L5f8zhCr4Rh8 DqlPPVQoXnwZqdUbcqAzDr6tb1mAKBGm7ApaU+LAs8DvzWbWoZI7gtb0TjWN2cN6WW0G 4IGKBCEIYfs8/YxwW828s4cShVzahB6r6sk5BGi9r+Ak/y5ozxB16i7Vu/rCyXDRpNEP cauaDhrwrfQkn6mIq76fQ6kvJJiZkJdXSVr+FW5pCSQCnyrcfuA50lAaXygHzd+sHXqU 7CwYroqSuddi/quMCfkizuF8l/i2dOwESJytuYwR/PpgLNe27GlJgwNx4j/pHCN6X2W8 HgvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bwfIBsBC; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-121767-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q22-20020a656856000000b005f05c95f71dsi2972444pgt.358.2024.03.27.11.29.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 11:29:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121767-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bwfIBsBC; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-121767-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1B2D8B2ADC6 for ; Wed, 27 Mar 2024 17:59:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F4F915098B; Wed, 27 Mar 2024 17:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bwfIBsBC" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31A5014A619; Wed, 27 Mar 2024 17:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711562088; cv=none; b=lKsOMFbcmI78ZZnk2ytRDPHfTEnJfpgZgHnvVfqlNpuA+E4i0GqOk9AFwwlDpN51obTXOITMraqEHUTjRpKt4W6tCjzHxIktQGpugtG4AUGPp9SNj7xk2COuIEwkUcfWoqwmje2uq4aSpdYKcB2DhGCbYHhQkEJ5e+qq1/I6a1s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711562088; c=relaxed/simple; bh=Y1bhxjDzoIZZFfz+FLsosaOpnFT2r7ewvgsRT3Bdh2s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uXccMHM1nRw3EkY1vL4H25RprtkZunk71gW6fdRXlyz/HWBkpJw53WeA3EZNnbWSwoW8BTag9v1kT8MC7Hn858hcCYx8BK4qObghGkMJGj4PVrlTOuLH5mTYMBCFLJBLkG/sxIpRMvPpC3GOIiLWZ8ROzer3jBBHZurpbiwoJMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bwfIBsBC; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711562085; x=1743098085; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Y1bhxjDzoIZZFfz+FLsosaOpnFT2r7ewvgsRT3Bdh2s=; b=bwfIBsBCuinJ16muosregmZAj1ACI19CW2EcOkuVy4N2l/VHB79FE7i+ ukoJpwumXJ07347aXSGCRFAQ49ndnNjCt5nVsiqkex6xPw8iZ8oSQO4tL 3tyyrtnGcLXGVWbdAVy+A2rpB0gK3PCdW2RIUeeLHeMCfllisD+w4+3Dr ZE5J4zyuT0VO1iSGBqh2vBG5MdNQJa0fFB9OG4NH7ocIxVE2B5y+DilOq gNFUSiZsbgUbbJuVK0VIKN/9aIyXY/MHJm+N/axHr26xoz8dDxwy5mqCK 93KE2ImN1bCnbHTf1Q8l6WyJYijxRkn/W6S4uIaRIDFs9fM92DmCXMhWZ w==; X-CSE-ConnectionGUID: /3CUXroWSB2umFsrP1NuXA== X-CSE-MsgGUID: hQHZNJQXTUeqRFN307Dumg== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="17234713" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="17234713" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 10:54:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="20914465" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [10.212.56.222]) ([10.212.56.222]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 10:54:34 -0700 Message-ID: <918e6a48-10e1-42c4-86aa-ddd63d785e16@intel.com> Date: Wed, 27 Mar 2024 10:54:33 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 13/26] cxl/mem: Configure dynamic capacity interrupts Content-Language: en-US To: ira.weiny@intel.com, Fan Ni , Jonathan Cameron , Navneet Singh Cc: Dan Williams , Davidlohr Bueso , Alison Schofield , Vishal Verma , linux-btrfs@vger.kernel.org, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240324-dcd-type2-upstream-v1-0-b7b00d623625@intel.com> <20240324-dcd-type2-upstream-v1-13-b7b00d623625@intel.com> From: Dave Jiang In-Reply-To: <20240324-dcd-type2-upstream-v1-13-b7b00d623625@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/24/24 4:18 PM, ira.weiny@intel.com wrote: > From: Navneet Singh > > Dynamic Capacity Devices (DCD) support extent change notifications > through the event log mechanism. The interrupt mailbox commands were > extended in CXL 3.1 to support these notifications. > > Firmware can't configure DCD events to be FW controlled but can retain > control of memory events. Split irq configuration of memory events and > DCD events to allow for FW control of memory events while DCD is host > controlled. > > Configure DCD event log interrupts on devices supporting dynamic > capacity. Disable DCD if interrupts are not supported. > > Signed-off-by: Navneet Singh > Co-developed-by: Ira Weiny > Signed-off-by: Ira Weiny A few minor comments. The rest LGTM. > > --- > Changes for v1 > [iweiny: rebase to upstream irq code] > [iweiny: disable DCD if irqs not supported] > --- > drivers/cxl/core/mbox.c | 9 ++++++- > drivers/cxl/cxl.h | 4 ++- > drivers/cxl/cxlmem.h | 4 +++ > drivers/cxl/pci.c | 71 ++++++++++++++++++++++++++++++++++++++++--------- > 4 files changed, 74 insertions(+), 14 deletions(-) > > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c > index 14e8a7528a8b..58b31fa47b93 100644 > --- a/drivers/cxl/core/mbox.c > +++ b/drivers/cxl/core/mbox.c > @@ -1323,10 +1323,17 @@ static int cxl_get_dc_config(struct cxl_memdev_state *mds, u8 start_region, > return rc; > } > > -static bool cxl_dcd_supported(struct cxl_memdev_state *mds) > +bool cxl_dcd_supported(struct cxl_memdev_state *mds) > { > return test_bit(CXL_DCD_ENABLED_GET_CONFIG, mds->dcd_cmds); > } > +EXPORT_SYMBOL_NS_GPL(cxl_dcd_supported, CXL); > + > +void cxl_disable_dcd(struct cxl_memdev_state *mds) > +{ > + clear_bit(CXL_DCD_ENABLED_GET_CONFIG, mds->dcd_cmds); > +} > +EXPORT_SYMBOL_NS_GPL(cxl_disable_dcd, CXL); Should these one-liners just go into a header file? > > /** > * cxl_dev_dynamic_capacity_identify() - Reads the dynamic capacity > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index 15d418b3bc9b..d585f5fdd3ae 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -164,11 +164,13 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw) > #define CXLDEV_EVENT_STATUS_WARN BIT(1) > #define CXLDEV_EVENT_STATUS_FAIL BIT(2) > #define CXLDEV_EVENT_STATUS_FATAL BIT(3) > +#define CXLDEV_EVENT_STATUS_DCD BIT(4) extra tab? DJ > > #define CXLDEV_EVENT_STATUS_ALL (CXLDEV_EVENT_STATUS_INFO | \ > CXLDEV_EVENT_STATUS_WARN | \ > CXLDEV_EVENT_STATUS_FAIL | \ > - CXLDEV_EVENT_STATUS_FATAL) > + CXLDEV_EVENT_STATUS_FATAL| \ > + CXLDEV_EVENT_STATUS_DCD) > > /* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 */ > #define CXLDEV_EVENT_INT_MODE_MASK GENMASK(1, 0) > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h > index 4624cf612c1e..01bee6eedff3 100644 > --- a/drivers/cxl/cxlmem.h > +++ b/drivers/cxl/cxlmem.h > @@ -225,7 +225,9 @@ struct cxl_event_interrupt_policy { > u8 warn_settings; > u8 failure_settings; > u8 fatal_settings; > + u8 dcd_settings; > } __packed; > +#define CXL_EVENT_INT_POLICY_BASE_SIZE 4 /* info, warn, failure, fatal */ > > /** > * struct cxl_event_state - Event log driver state > @@ -890,6 +892,8 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd, > enum cxl_event_log_type type, > enum cxl_event_type event_type, > const uuid_t *uuid, union cxl_event *evt); > +bool cxl_dcd_supported(struct cxl_memdev_state *mds); > +void cxl_disable_dcd(struct cxl_memdev_state *mds); > int cxl_set_timestamp(struct cxl_memdev_state *mds); > int cxl_poison_state_init(struct cxl_memdev_state *mds); > int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len, > diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c > index 12cd5d399230..ef482eae09e9 100644 > --- a/drivers/cxl/pci.c > +++ b/drivers/cxl/pci.c > @@ -669,22 +669,33 @@ static int cxl_event_get_int_policy(struct cxl_memdev_state *mds, > } > > static int cxl_event_config_msgnums(struct cxl_memdev_state *mds, > - struct cxl_event_interrupt_policy *policy) > + struct cxl_event_interrupt_policy *policy, > + bool native_cxl) > { > struct cxl_mbox_cmd mbox_cmd; > + size_t size_in; > int rc; > > - *policy = (struct cxl_event_interrupt_policy) { > - .info_settings = CXL_INT_MSI_MSIX, > - .warn_settings = CXL_INT_MSI_MSIX, > - .failure_settings = CXL_INT_MSI_MSIX, > - .fatal_settings = CXL_INT_MSI_MSIX, > - }; > + if (native_cxl) { > + *policy = (struct cxl_event_interrupt_policy) { > + .info_settings = CXL_INT_MSI_MSIX, > + .warn_settings = CXL_INT_MSI_MSIX, > + .failure_settings = CXL_INT_MSI_MSIX, > + .fatal_settings = CXL_INT_MSI_MSIX, > + .dcd_settings = 0, > + }; > + } > + size_in = CXL_EVENT_INT_POLICY_BASE_SIZE; > + > + if (cxl_dcd_supported(mds)) { > + policy->dcd_settings = CXL_INT_MSI_MSIX; > + size_in += sizeof(policy->dcd_settings); > + } > > mbox_cmd = (struct cxl_mbox_cmd) { > .opcode = CXL_MBOX_OP_SET_EVT_INT_POLICY, > .payload_in = policy, > - .size_in = sizeof(*policy), > + .size_in = size_in, > }; > > rc = cxl_internal_send_cmd(mds, &mbox_cmd); > @@ -731,6 +742,31 @@ static int cxl_event_irqsetup(struct cxl_memdev_state *mds, > return 0; > } > > +static int cxl_irqsetup(struct cxl_memdev_state *mds, > + struct cxl_event_interrupt_policy *policy, > + bool native_cxl) > +{ > + struct cxl_dev_state *cxlds = &mds->cxlds; > + int rc; > + > + if (native_cxl) { > + rc = cxl_event_irqsetup(mds, policy); > + if (rc) > + return rc; > + } > + > + if (cxl_dcd_supported(mds)) { > + rc = cxl_event_req_irq(cxlds, policy->dcd_settings); > + if (rc) { > + dev_err(cxlds->dev, "Failed to get interrupt for DCD event log\n"); > + cxl_disable_dcd(mds); > + return rc; > + } > + } > + > + return 0; > +} > + > static bool cxl_event_int_is_fw(u8 setting) > { > u8 mode = FIELD_GET(CXLDEV_EVENT_INT_MODE_MASK, setting); > @@ -757,17 +793,25 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge, > struct cxl_memdev_state *mds, bool irq_avail) > { > struct cxl_event_interrupt_policy policy = { 0 }; > + bool native_cxl = host_bridge->native_cxl_error; > int rc; > > /* > * When BIOS maintains CXL error reporting control, it will process > * event records. Only one agent can do so. > + * > + * If BIOS has control of events and DCD is not supported skip event > + * configuration. > */ > - if (!host_bridge->native_cxl_error) > + if (!native_cxl && !cxl_dcd_supported(mds)) > return 0; > > if (!irq_avail) { > dev_info(mds->cxlds.dev, "No interrupt support, disable event processing.\n"); > + if (cxl_dcd_supported(mds)) { > + dev_info(mds->cxlds.dev, "DCD requires interrupts, disable DCD\n"); > + cxl_disable_dcd(mds); > + } > return 0; > } > > @@ -775,10 +819,10 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge, > if (rc) > return rc; > > - if (!cxl_event_validate_mem_policy(mds, &policy)) > + if (native_cxl && !cxl_event_validate_mem_policy(mds, &policy)) > return -EBUSY; > > - rc = cxl_event_config_msgnums(mds, &policy); > + rc = cxl_event_config_msgnums(mds, &policy, native_cxl); > if (rc) > return rc; > > @@ -786,12 +830,15 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge, > if (rc) > return rc; > > - rc = cxl_event_irqsetup(mds, &policy); > + rc = cxl_irqsetup(mds, &policy, native_cxl); > if (rc) > return rc; > > cxl_mem_get_event_records(mds, CXLDEV_EVENT_STATUS_ALL); > > + dev_dbg(mds->cxlds.dev, "Event config : %d %d\n", > + native_cxl, cxl_dcd_supported(mds)); > + > return 0; > } > >