Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp765621lqp; Wed, 22 May 2024 21:38:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIXXL0SkqO1jZIJ4YgNTwWkEqMtypBjFGRppYpljRXv+XNgcT+m5KBNxJZPRu9Z1t3YcQ8lBPa9BVsyc+9MZBeXtMVhEGujjMsUNCMDQ== X-Google-Smtp-Source: AGHT+IHtvPSPnWzHBxoXGT0BWiNBQasD6BV1xYAVPqlX5HcBjc+92rsGlXcAFqJES9zVNdbAxcpO X-Received: by 2002:a17:90a:e017:b0:2b0:e883:270d with SMTP id 98e67ed59e1d1-2bddce5c0edmr1709689a91.1.1716439092677; Wed, 22 May 2024 21:38:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716439092; cv=pass; d=google.com; s=arc-20160816; b=bADLzTi7SIigA3RqzlGFoauxEs+F97szrMII/1DCXO7miGf87ZTqUjX7DB2a6HGRHO VHh9gU29MdyRoycesx3UcWbzVdW3WCXZB7qtkoPf5d88NMC2vgGQRbPpfWYuvi3txfVl 2ERI3uJo2swgc6Dim4IKdhlp/gCPND66MiioBhRXfoRz9/AeJCiBq96zFC52txFHl/nB hKi9+a+qf5mgOIbayieAj2EgjGyE325VsEN77OhyJE2e4fM6nANqLd8+2w5G172blmFn 3OLOZnf2Dq/CBn8g9K9A2ijR3MZ0JyB2QTibq3ZxN6CEbo29iqNr9ax5fUgLXAEhmpOf nUWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xu+nKR+zDwDPtvipiZucibx/CqLEw2spFtt/wiV1PkM=; fh=rjIumExOyFZLELCXkyu97YURkssXnZvsf5bBLi5Bnnk=; b=JY2A2gnbJrfdiStSouoVQVvS9buSpfj1z+gc6gP5doLooPPI9O4UAM/LSSd2xK/860 W+QPXE0l1OQR1Ig3ytVI/wN0K6/V346nRsFQImmHunFJAGyD85lBJ5uP/HUbnNfKXe3r OvAIBtg7YB+7uquA8pozVIWMkn+ssceO3OY+3DRI4/5SyJxGwv9N3qTnFgT2k00IrFLZ usH/pUpOeIpeWeqjSVFn3PvghbJsHpox5Mpm2HibMTgTv8lntnOvBHAgxSEQ0guSGHuc aqWMLRNEJFUeGZY3eRP+5iWFwDwFJRCvrJcKF9poQBX28eAFxX4LTCYlh4ibqmqpv3nq jqfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=liIPBVxt; 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-186978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdd9ed2711si878452a91.34.2024.05.22.21.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 21:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=liIPBVxt; 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-186978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186978-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4A996281BED for ; Thu, 23 May 2024 04:38:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39C2447F58; Thu, 23 May 2024 04:38:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="liIPBVxt" 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 5226320DF7; Thu, 23 May 2024 04:38:03 +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=1716439085; cv=none; b=nxlZM4fRxSVHYTrYuUjSL7A86jxjfmvkY+URV6flwQomlBigxvpRx8MEz2icAwkiTvtarDsyrjDiRy2E78CxxR1ct9sHTm6lwGFTe4gTFyZlP842Jd1/LQmzBi8RQPkAXFzTrdIs7DQUiOpFLX6QqEFUfTeoIy6F/vLSzG9zJzM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716439085; c=relaxed/simple; bh=Zb53/ycD+rQozQIXsykjBaWlJ41ME07FtWQn9Xg2uc8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DKyWKUh/6gOnWirBArvroSV6zW2XO+kz0fM0c0ejr8RRhgFyTxKk7B3V64wI7kXTjk7N6rD+/VW664431e0C3gakwHdEyITaZDipFfGuKQepKkkxLR/ML/IY1nlm4XcVZh8bjrasjbvru8QWLm9oYVcSIZRrsingdzTzjx7GBPE= 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=liIPBVxt; 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=1716439083; x=1747975083; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Zb53/ycD+rQozQIXsykjBaWlJ41ME07FtWQn9Xg2uc8=; b=liIPBVxtTr9XpiiAoCfuuZesQyaYcsYuIZyiOTY5hMwnMFgYhvl7zl8Z yhNUfxxfHNFBEp0QsuL4g2da3X9S+xt8tdXHV1oHTJ3AKATvkBBsvtB90 7juW1cPfJdutO0TOa+Vw/t9rbwuaNso63qXCY5i8ZYgbSHPVbId1dQ8Y6 h1CqajDedD0P/Twhn8w2u0I/VlScDQBd0/3aJa8WZwbru9onIlRtSPVby vbZy6aWy3Az8zsOhZ7dsV36ZnyO+65mS82xEtBecgU9f8v04k+qZuF1hY fUcyyfW+LtyljKOjfnrPYciSqTQNWFptkEnLSCQ5wfc+iZtMnTr6LgIyL g==; X-CSE-ConnectionGUID: ZrJc9BLIRNS21YbtEHUFFA== X-CSE-MsgGUID: d/NcOA83SPil0DGTLk6xnA== X-IronPort-AV: E=McAfee;i="6600,9927,11080"; a="23299349" X-IronPort-AV: E=Sophos;i="6.08,181,1712646000"; d="scan'208";a="23299349" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2024 21:38:02 -0700 X-CSE-ConnectionGUID: 06AurqnZSRqg7Mv0OH4uLA== X-CSE-MsgGUID: E69/rulbSYaiL4pCyJ4UNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,181,1712646000"; d="scan'208";a="38502052" Received: from aschofie-mobl2.amr.corp.intel.com (HELO aschofie-mobl2) ([10.255.230.167]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2024 21:38:02 -0700 Date: Wed, 22 May 2024 21:38:01 -0700 From: Alison Schofield To: Dave Jiang Cc: Smita Koralahalli , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, Ard Biesheuvel , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Yazen Ghannam , Bowman Terry Subject: Re: [PATCH 3/4] acpi/ghes, cxl/pci: Trace FW-First CXL Protocol Errors Message-ID: References: <20240522150839.27578-1-Smita.KoralahalliChannabasappa@amd.com> <20240522150839.27578-4-Smita.KoralahalliChannabasappa@amd.com> <7dc64418-6821-49c2-b9af-ee4ab148ba9f@intel.com> 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: <7dc64418-6821-49c2-b9af-ee4ab148ba9f@intel.com> On Wed, May 22, 2024 at 11:05:49AM -0700, Dave Jiang wrote: > > > On 5/22/24 8:08 AM, Smita Koralahalli wrote: > > When PCIe AER is in FW-First, OS should process CXL Protocol errors from > > CPER records. > > > > Reuse the existing work queue cxl_cper_work registered with GHES to notify > > the CXL subsystem on a Protocol error. > > > > The defined trace events cxl_aer_uncorrectable_error and > > cxl_aer_correctable_error currently trace native CXL AER errors. Reuse > > them to trace FW-First Protocol Errors. > > > > Signed-off-by: Smita Koralahalli > > --- > > drivers/acpi/apei/ghes.c | 14 ++++++++++++++ > > drivers/cxl/core/pci.c | 24 ++++++++++++++++++++++++ > > drivers/cxl/cxlpci.h | 3 +++ > > drivers/cxl/pci.c | 34 ++++++++++++++++++++++++++++++++-- > > include/linux/cxl-event.h | 1 + > > 5 files changed, 74 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c > > index 1a58032770ee..a31bd91e9475 100644 > > --- a/drivers/acpi/apei/ghes.c > > +++ b/drivers/acpi/apei/ghes.c > > @@ -723,6 +723,20 @@ static void cxl_cper_handle_prot_err(struct acpi_hest_generic_data *gdata) > > > > if (cxl_cper_handle_prot_err_info(gdata, &wd.p_err)) > > return; > > + > > + guard(spinlock_irqsave)(&cxl_cper_work_lock); > > + > > + if (!cxl_cper_work) > > + return; > > + > > + wd.event_type = CXL_CPER_EVENT_PROT_ERR; > > + > > + if (!kfifo_put(&cxl_cper_fifo, wd)) { > > + pr_err_ratelimited("CXL CPER kfifo overflow\n"); > > + return; > > + } > > + > > + schedule_work(cxl_cper_work); > > } > > > > int cxl_cper_register_work(struct work_struct *work) > > diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c > > index 0df09bd79408..ef9438cb1dd6 100644 > > --- a/drivers/cxl/core/pci.c > > +++ b/drivers/cxl/core/pci.c > > @@ -686,6 +686,30 @@ void read_cdat_data(struct cxl_port *port) > > } > > EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL); > > > > +void cxl_trace_prot_err(struct cxl_dev_state *cxlds, > > + struct cxl_cper_prot_err *p_err) > > +{ > > + u32 status, fe; > > + > > + if (p_err->severity == CXL_AER_CORRECTABLE) { > > + status = p_err->cxl_ras.cor_status & ~p_err->cxl_ras.cor_mask; > > + > > + trace_cxl_aer_correctable_error(cxlds->cxlmd, status); > > + } else { > > + status = p_err->cxl_ras.uncor_status & ~p_err->cxl_ras.uncor_mask; > > + > > + if (hweight32(status) > 1) > > + fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK, > > + p_err->cxl_ras.cap_control)); > > + else > > + fe = status; > > + > > + trace_cxl_aer_uncorrectable_error(cxlds->cxlmd, status, fe, > > + p_err->cxl_ras.header_log); > > + } > > +} > > +EXPORT_SYMBOL_NS_GPL(cxl_trace_prot_err, CXL); > > + > > static void __cxl_handle_cor_ras(struct cxl_dev_state *cxlds, > > void __iomem *ras_base) > > { > > diff --git a/drivers/cxl/cxlpci.h b/drivers/cxl/cxlpci.h > > index 93992a1c8eec..0ba3215786e1 100644 > > --- a/drivers/cxl/cxlpci.h > > +++ b/drivers/cxl/cxlpci.h > > @@ -130,4 +130,7 @@ void read_cdat_data(struct cxl_port *port); > > void cxl_cor_error_detected(struct pci_dev *pdev); > > pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, > > pci_channel_state_t state); > > +struct cxl_cper_prot_err; > > +void cxl_trace_prot_err(struct cxl_dev_state *cxlds, > > + struct cxl_cper_prot_err *p_err); > > #endif /* __CXL_PCI_H__ */ > > diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c > > index 74876c9835e8..3e3c36983686 100644 > > --- a/drivers/cxl/pci.c > > +++ b/drivers/cxl/pci.c > > @@ -1011,12 +1011,42 @@ static void cxl_handle_cper_event(enum cxl_event_type ev_type, > > &uuid_null, &rec->event); > > } > > > > +static void cxl_handle_prot_err(struct cxl_cper_prot_err *p_err) > > +{ > > + struct pci_dev *pdev __free(pci_dev_put) = NULL; > > + struct cxl_dev_state *cxlds; > > + unsigned int devfn; > > + > > + devfn = PCI_DEVFN(p_err->device, p_err->function); > > + pdev = pci_get_domain_bus_and_slot(p_err->segment, > > + p_err->bus, devfn); > > + if (!pdev) > > + return; > > + > > + guard(device)(&pdev->dev); > > + if (pdev->driver != &cxl_pci_driver) > > + return; > > + > > + cxlds = pci_get_drvdata(pdev); > > + if (!cxlds) > > + return; > > + > > + if (((u64)p_err->upper_dw << 32 | p_err->lower_dw) != cxlds->serial) > > + pr_warn("CPER-reported device serial number does not match expected value\n"); > > Given that we are operating on a device, perhaps dev_warn(&pdev->dev, ...) may be better served. > > DJ Good point. Providing the dev lets the user look up the serial number, meaning this message doesn't need to include an 'expected' but not found value. -- Alison > > + > > + cxl_trace_prot_err(cxlds, p_err); > > +} > > + > > static void cxl_cper_work_fn(struct work_struct *work) > > { > > struct cxl_cper_work_data wd; > > > > - while (cxl_cper_kfifo_get(&wd)) > > - cxl_handle_cper_event(wd.event_type, &wd.rec); > > + while (cxl_cper_kfifo_get(&wd)) { > > + if (wd.event_type == CXL_CPER_EVENT_PROT_ERR) > > + cxl_handle_prot_err(&wd.p_err); > > + else > > + cxl_handle_cper_event(wd.event_type, &wd.rec); > > + } > > } > > static DECLARE_WORK(cxl_cper_work, cxl_cper_work_fn); > > > > diff --git a/include/linux/cxl-event.h b/include/linux/cxl-event.h > > index 9c7b69e076a0..5562844df850 100644 > > --- a/include/linux/cxl-event.h > > +++ b/include/linux/cxl-event.h > > @@ -122,6 +122,7 @@ struct cxl_event_record_raw { > > } __packed; > > > > enum cxl_event_type { > > + CXL_CPER_EVENT_PROT_ERR, > > CXL_CPER_EVENT_GENERIC, > > CXL_CPER_EVENT_GEN_MEDIA, > > CXL_CPER_EVENT_DRAM,