Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1580311lql; Wed, 13 Mar 2024 02:05:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1+wlP1XTeocICjJSDaqiLGE0lRJ7Bax56lt5JSmKBzzfwxPG+/+nK5xh8nUwWookDiGwyEFwVkJSWoz9t/E4jdzHx2lU2nFedKmE3dg== X-Google-Smtp-Source: AGHT+IHSVoHF+Sd/aDMitdL2HBLKCmtwALSSQFiIHSwXO/Ogjxd7Mw0Qy8f8ssmUnACNqBrCRqR9 X-Received: by 2002:a05:6808:3021:b0:3c2:1881:f015 with SMTP id ay33-20020a056808302100b003c21881f015mr14454151oib.15.1710320709648; Wed, 13 Mar 2024 02:05:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710320709; cv=pass; d=google.com; s=arc-20160816; b=LK9gxbRvG+SUnljE1Oe4Yv5pCB8K+cxMkfPVLvpX3tIZ+jMhEp2Yu4u9jldgbKn0CE qtIuTOUNTYImPXa85k/g/EyxP7tUDPG03gEzMQGfhVfCnxPLD2iuJwDCH8WHZpWiUl6p gRYvgEjfErLnW4QGyrim431pJu51ogx6xiDVaKUyi2Fcbb1sZJ0Aul0upwfqIquCrCYU WXzpSLDJ2/M9oa2csZCj3k1Ce8kNfa0Jp/3OB3fT5RR+o3QmCTEDFJHiwcz1UT3v8WCI HlfUngq+38vwcfEgWPN5zLuckFIhtULVXtqdI4vEWrhc//mke1rT4TofOflK7UBEztc1 GxLQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FJc8wW4Bg06C9qERxqWPwXslzbjyr3pcBzGcviSJjOo=; fh=uPaLVQj+KmAVzYbxwtywzcxAbzH/KMpkj1KScQzRg7A=; b=AIFDh8/HjYvphOy66CkROXOKXeyihApEPFd8ErRiyF75uBeExi58Re4FfP08Zw5oVy FZlY3WG0n9tq6rBqNsKKMzq4RRFdUrHvxOOoa1sCe+5oGKjqjRhcepBUExx0/aNQtKOn A6z3xmnOWTdcaZk+AqsQ25pjdqRjlXOuccbNuHVBSG4q9frmkjenJ2DlbZUhqUNsGQ34 alwdvTq5wFrZrhe4shZ/IyJwn1Nssqe4wysibCyER+hmzVyBA745nFQM0PRq2qHfVnpX fxuqlDMRRCJTJHvJEHYFKCnnpwYQEAr4afQap3f8A8CYDn/97Wtfj+paQJBdYRwMGDt2 xOeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mKJu4bla; 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-101245-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y9-20020a05620a09c900b007884201422esi9157311qky.545.2024.03.13.02.05.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 02:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101245-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mKJu4bla; 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-101245-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101245-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 46E621C21BBE for ; Wed, 13 Mar 2024 09:05:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58BE1210E9; Wed, 13 Mar 2024 09:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mKJu4bla" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 9671B1B971; Wed, 13 Mar 2024 09:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710320679; cv=none; b=kWBGO1njxQS1Od1vq37cyqi5/05mEjn940efOjgudvQD9Bo50AOrhezVJtSaO2/OguVEHKIvs11XgVn6GDKTmi6ytVqZSku0niDb4lf08zMv0JlJA2fMA3OhfSM79HjH8pFvlKuE9udheAz+3MdDcVyctPBAMNgWzZJa2IqnUSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710320679; c=relaxed/simple; bh=ABNAIctSLDSs2aKwynQcOBhqzG8RDByD/Ji7/NnXqQ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QnmUmzz6mGxXWSvgs44Ifz5cqy70nxGc7ADDUCjk4NA6IYlmIBd+52Ke56DWwJDu5cFL7WFfcjLB7Q1dMR9MJpfbCu06xK55E1covxjiB/4KV9XBlGAdHSO0mhOlTXwOZyTU4R9o4ifAE1FtbNQHFhxoUMePLyZiUvW5bUGCnf4= 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=mKJu4bla; arc=none smtp.client-ip=192.198.163.8 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=1710320678; x=1741856678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ABNAIctSLDSs2aKwynQcOBhqzG8RDByD/Ji7/NnXqQ4=; b=mKJu4blau5iuziEVhvO2F6ba/SKn/hp9OSiCdEkU/vJIddSTwkRyORV4 AI1l/ouK/y5s/i4Gpu7GywrNci8zbFivQIS1Gd7pMZkoYgFhS4w0YSIIz gvajT7337zlugxeH9Awq4AsgMskHWKFR7FYecji0hXHjnQkInjEV+54NC +E0+lQYIu1CvdjVIVYsXBN6dW/jxikXSK+QTbXicr54RmTzdNNwbq5mJx DR0ub0yYzj4y1bE0pNtKECp5r/lvRhMIboLf3q3nsYDBwUT2gynewoTuF EZY8E38tn6eK94CqTfhE5M7R5ljfGvLXe8dVRI296YlsbNYTkpL5hJRvS Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11011"; a="22586876" X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="22586876" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2024 02:04:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="12265607" Received: from s2600wttr.bj.intel.com ([10.240.192.113]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2024 02:04:35 -0700 From: Li Ming To: dan.j.williams@intel.com, rrichter@amd.com, terry.bowman@amd.com Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, Li Ming Subject: [RFC PATCH 1/6] PCI/RCEC: Introduce pcie_walk_rcec_all() Date: Wed, 13 Mar 2024 08:35:57 +0000 Message-Id: <20240313083602.239201-2-ming4.li@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240313083602.239201-1-ming4.li@intel.com> References: <20240313083602.239201-1-ming4.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit PCIe RCEC core only provides pcie_walk_rcec() to walk all RCiEP devices associating with RCEC, but CXL subsystem needs a helper function which can walk all devices in RCEC associated bus range other than RCiEPs for below RAS error case. CXL r3.1 section 12.2.2 mentions that the CXL.cachemem protocol errors detected by a CXL root port could be logged in RCEC AER Extended Capability. The recommendation solution from CXL r3.1 section 9.18.1.5 is: "Probe all CXL Downstream Ports and determine whether they have logged an error in the CXL.io or CXL.cachemem status registers." The new helper function called pcie_walk_rcec_all(), CXL RAS error handler can use it to locate all CXL root ports or CXL devices in RCEC associated bus range. Signed-off-by: Li Ming --- drivers/pci/pci.h | 6 ++++++ drivers/pci/pcie/rcec.c | 44 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 5ecbcf041179..a068f2d7dd28 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -444,6 +444,9 @@ void pcie_link_rcec(struct pci_dev *rcec); void pcie_walk_rcec(struct pci_dev *rcec, int (*cb)(struct pci_dev *, void *), void *userdata); +void pcie_walk_rcec_all(struct pci_dev *rcec, + int (*cb)(struct pci_dev *, void *), + void *userdata); #else static inline void pci_rcec_init(struct pci_dev *dev) { } static inline void pci_rcec_exit(struct pci_dev *dev) { } @@ -451,6 +454,9 @@ static inline void pcie_link_rcec(struct pci_dev *rcec) { } static inline void pcie_walk_rcec(struct pci_dev *rcec, int (*cb)(struct pci_dev *, void *), void *userdata) { } +static inline void pcie_walk_rcec_all(struct pci_dev *rcec, + int (*cb)(struct pci_dev *, void *), + void *userdata) { } #endif #ifdef CONFIG_PCI_ATS diff --git a/drivers/pci/pcie/rcec.c b/drivers/pci/pcie/rcec.c index d0bcd141ac9c..189de280660c 100644 --- a/drivers/pci/pcie/rcec.c +++ b/drivers/pci/pcie/rcec.c @@ -65,6 +65,15 @@ static int walk_rcec_helper(struct pci_dev *dev, void *data) return 0; } +static int walk_rcec_all_helper(struct pci_dev *dev, void *data) +{ + struct walk_rcec_data *rcec_data = data; + + rcec_data->user_callback(dev, rcec_data->user_data); + + return 0; +} + static void walk_rcec(int (*cb)(struct pci_dev *dev, void *data), void *userdata) { @@ -83,7 +92,7 @@ static void walk_rcec(int (*cb)(struct pci_dev *dev, void *data), nextbusn = rcec->rcec_ea->nextbusn; lastbusn = rcec->rcec_ea->lastbusn; - /* All RCiEP devices are on the same bus as the RCEC */ + /* All devices are on the same bus as the RCEC */ if (nextbusn == 0xff && lastbusn == 0x00) return; @@ -96,7 +105,7 @@ static void walk_rcec(int (*cb)(struct pci_dev *dev, void *data), if (!bus) continue; - /* Find RCiEP devices on the given bus ranges */ + /* Find devices on the given bus ranges */ pci_walk_bus(bus, cb, rcec_data); } } @@ -146,6 +155,37 @@ void pcie_walk_rcec(struct pci_dev *rcec, int (*cb)(struct pci_dev *, void *), walk_rcec(walk_rcec_helper, &rcec_data); } +/** + * pcie_walk_rcec_all - Walk all devices in RCEC's bus range. + * @rcec: RCEC whose devices should be walked + * @cb: Callback to be called for each device found + * @userdata: Arbitrary pointer to be passed to callback + * + * It is implemented only for CXL cases. + * Per CXL r3.1 section 12.2.2, CXL protocol errors detected by + * CXL root port could be logged in an RCEC's AER Extended Capability. + * And per CXL r3.1 section 9.18.1.5, the recommendation is that probing + * all CXL root ports to determine whether they have logged an error. + * So provide this function for CXL to walk the given RCEC, CXL driver + * will figure out which CXL root ports detected errors. + * + * If @cb returns anything other than 0, break out. + */ +void pcie_walk_rcec_all(struct pci_dev *rcec, int (*cb)(struct pci_dev *, void *), + void *userdata) +{ + struct walk_rcec_data rcec_data; + + if (!rcec->rcec_ea) + return; + + rcec_data.rcec = rcec; + rcec_data.user_callback = cb; + rcec_data.user_data = userdata; + + walk_rcec(walk_rcec_all_helper, &rcec_data); +} + void pci_rcec_init(struct pci_dev *dev) { struct rcec_ea *rcec_ea; -- 2.40.1