Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2550032rdb; Wed, 21 Feb 2024 11:02:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNHcrsYvWAHsGw+XoOVhqxE+c1NjMmBj22RfgzXYu7CXNrQm2NPxmCvM0g2RREwcVeBaVBpuRAEOPAyk0/JwjDPo6TaI1usF/T7JWULg== X-Google-Smtp-Source: AGHT+IGe8wv+HEeELwhooeU8sdXDwfW3+g5v1DEia81bCExp6aWBqWfppVLzsIG5F9TfvgirkqHb X-Received: by 2002:a17:90b:344f:b0:299:2038:11e5 with SMTP id lj15-20020a17090b344f00b00299203811e5mr14171378pjb.27.1708542156307; Wed, 21 Feb 2024 11:02:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708542156; cv=pass; d=google.com; s=arc-20160816; b=qC7SrPaaOkHSXv18CwE4D0++lGZl7Dfs7n2fHIQKOt9PSIDOHf3o1PLUO0cJ5cm3G0 HCwE5FlGxOrQJ561tbR4SnSC4FbKeIU8w0QMTzXIJjGniKxZ5ZRXuxflZYgcrftPqAao 4dR5t0VTJqEHYYSFIfiOeuUbPJKvTIY5VCWdDWLdrsMWgrqff9NYvggeWLtHaS5qNqjp 6nuDBnGaSxxpkcrYpe9rUoEcvjctdYq73CNDYpjiDgcqnGkqiugBC3PsvP8BLedcCqIk xSoWt094kkmc+azPO5I9dkIBdpiXMRbXtnRr2/Ig0zZKv0q58sPbAi8/8Ix+RSEWe6EE 6Y9A== 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:message-id:subject:cc:to:from :date:dkim-signature; bh=wbQCNNF9Q86k3CbRhlJc53MTn2My/Dk3nUheksa1RcY=; fh=7WgjzgAD0yv7WTjyBLXgGiaHp/trrXTW0kds5oSd9F8=; b=rcBJ93zxm6QTrcMX+SmEVTIRIJP6q8wEdZVBFFGn838Ym9TkPM2CxSk+mvMpAbCFXD eHztWvpNabdENK8esCgtYTvUfpyg6FQml8MQKdRBb0FgJb2IBqLTilCt65qY0likAw+E k2q6h8kuBZ0P4z+M9uWg9NrOuc7O7B5MVrJOTNMU2QJcaS8wE3hkS+kk76t6dvQ+inS1 u04ELKi7P1SJQPqE3t5nE9dwgr1rMOhPiHGdbKJdBTbfaG4uNcmC8WWteK720kU1os17 m0na0bIaYc5325VUuAkOa99rEFzEyb4LRjAgTBqwlLmzYfaRHwc8zpKRwA5gRlrefWtO VyFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kAxQtPEU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75328-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75328-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id sh6-20020a17090b524600b00298d6a78c8fsi8734964pjb.62.2024.02.21.11.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 11:02:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75328-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=@kernel.org header.s=k20201202 header.b=kAxQtPEU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75328-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75328-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 2FAFF28555E for ; Wed, 21 Feb 2024 18:50:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1577085945; Wed, 21 Feb 2024 18:50:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kAxQtPEU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2A21D82D97; Wed, 21 Feb 2024 18:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708541419; cv=none; b=dw1Aox30q75X91HwGKm+5vk4STv/oAW+iaSejtBphQjfC6Qc2bdZwBr+ys1bBnmGeADZo0SkTKbuntCE1w1iALD8NVoJRBTxO6flO/M/OK4XsKO+GxJ4euPK7i+Z/uLmPjjsK8JniUsSLsmUS9YLILvtDeOXXIBTxpZ6wGqGW8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708541419; c=relaxed/simple; bh=berq+dLx79W8QR0JZxbmG5z5E9hVyr2TYj6ftH2W+DU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=i2xN8LqpPXCrfJ8GvRd0euugK9PlPAhTUFmpkwdoM3Fep5BPO36/zuDByFfF3P7NkvzWuaOSt+D3hq5g9PccBOdqqB62kt7TEOQoEPKPXfGNiVyzjA0jo2Oy4+KCYaWlPKx8a8LOhmMveCMMJYs4f9vFtSjL8GM0gCSNUtCMC4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kAxQtPEU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D4A9C433F1; Wed, 21 Feb 2024 18:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708541418; bh=berq+dLx79W8QR0JZxbmG5z5E9hVyr2TYj6ftH2W+DU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=kAxQtPEUYCxY9bKxoBer0CmYny/X0JyU63M+Zl/i/VzgkRePbL+RgKth1AS9f84aJ pipANzIjhKdTzS7DuhOhXkPkSD1YzBrGIemEDirSKyujLbCuin7x1iPed2ztjiZTWa JI7kRYnpbDTzV6EcGMrHY90bQVK49to7toCJ8LwEHG+RKisqOzK4VVyTukMxcs7w8V k4rUkFsTBKcM9LW6Z2t4h/YyQTVwNvTSFBNDN9hQe4WvmguAgsUV6FUbJdjqnqpS+Y xMYCW7OQMmNIkzxu56Iu6qvGRr60fbvqSGuTpAX2zMjhfgfy0DYN0deFfYqeUuuYIP nY/uFVgop4ysQ== Date: Wed, 21 Feb 2024 12:50:17 -0600 From: Bjorn Helgaas To: root Cc: andersson@kernel.org, krzysztof.kozlowski+dt@linaro.org, jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, konrad.dybcio@linaro.org, manivannan.sadhasivam@linaro.org, conor+dt@kernel.org, quic_nitegupt@quicinc.com, quic_shazhuss@quicinc.com, quic_ramkri@quicinc.com, quic_nayiluri@quicinc.com, quic_krichai@quicinc.com, quic_vbadigan@quicinc.com, Nitesh Gupta , Mrinmay Sarkar , Bjorn Helgaas , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 3/3] PCI: qcom: Add support for detecting controller level PCIe errors Message-ID: <20240221185017.GA1536431@bhelgaas> 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: <20240221140405.28532-4-root@hu-msarkar-hyd.qualcomm.com> On Wed, Feb 21, 2024 at 07:34:04PM +0530, root wrote: > From: Nitesh Gupta > > Synopsys Controllers provide capabilities to detect various controller "Synopsys controllers"? "Synopsys" refers to the DesignWare core, but most of this code is in the qcom driver. If it's qcom-specific, this should say "Qualcomm controllers". > level errors. These can range from controller interface error to random > PCIe configuration errors. This patch intends to add support to detect > these errors and report it to userspace entity via sysfs, which can take > appropriate actions to mitigate the errors. s/This patch intends to add/Add/, so the commit log says what the patch *does*, not "what it intends to do". > + > +/* > + * Error Reporting DBI register > + */ Typical style in this file (granted, it's not 100% consistent) is to make these single-line comments, i.e., /* Error Reporting DBI register */ > +#define DBI_DEVICE_CONTROL_DEVICE_STATUS 0x78 > +#define DBI_ROOT_CONTROL_ROOT_CAPABILITIES_REG 0x8c Most other #defines in this file use upper-case hex. > +#define PCIE_AER_EXT_CAP_ID 0x01 Why not the existing PCI_EXT_CAP_ID_ERR? If this is the standard PCIe AER stuff, we shouldn't make it needlessly device-specific. > +#define PCI_EXT_CAP_RASDP_ID 0x0b Looks like possibly PCI_EXT_CAP_ID_VNDR? Capability IDs are definitely not device-specific. The fact that a PCI_EXT_CAP_ID_VNDR capability in a device with Vendor ID PCI_VENDOR_ID_QCOM has a qcom-specific meaning is obviously specific to qcom, but the Capability ID itself is not. > +/* DBI_ROOT_CONTROL_ROOT_CAPABILITIES_REG register fields */ > +#define PCIE_CAP_SYS_ERR_ON_CORR_ERR_EN BIT(0) > +#define PCIE_CAP_SYS_ERR_ON_NON_FATAL_ERR_EN BIT(1) > +#define PCIE_CAP_SYS_ERR_ON_FATAL_ERR_EN BIT(2) > + > +/* DBI_DEVICE_CONTROL_DEVICE_STATUS register fields */ > +#define PCIE_CAP_UNSUPPORT_REQ_REP_EN BIT(3) > +#define PCIE_CAP_FATAL_ERR_REPORT_EN BIT(2) > +#define PCIE_CAP_NON_FATAL_ERR_REPORT_EN BIT(1) > +#define PCIE_CAP_CORR_ERR_REPORT_EN BIT(0) These look like alternate ways to access the generic PCIe Capability. If that's the case, either use the existing PCI_EXP_RTCTL_SECEE, PCI_EXP_DEVCTL_CERE, etc., or at least match the "RTCTL_SECEE" parts of the names so we can see the connection. > +/* DBI_ADV_ERR_CAP_CTRL_OFF register fields */ > +#define ECRC_GEN_EN BIT(6) > +#define ECRC_CHECK_EN BIT(8) Do these correspond to PCI_ERR_CAP_ECRC_GENE, PCI_ERR_CAP_ECRC_CHKE? > +/* DBI_ROOT_ERR_CMD_OFF register fields */ > +#define CORR_ERR_REPORTING_EN BIT(0) > +#define NON_FATAL_ERR_REPORTING_EN BIT(1) > +#define FATAL_ERR_REPORTING_EN BIT(2) PCI_ERR_ROOT_CMD_COR_EN, etc? > +static void qcom_pcie_enable_error_reporting_2_7_0(struct qcom_pcie *pcie) > +{ > + ... > + val = readl(pci->dbi_base + DBI_DEVICE_CONTROL_DEVICE_STATUS); > + val |= (PCIE_CAP_CORR_ERR_REPORT_EN | PCIE_CAP_NON_FATAL_ERR_REPORT_EN | > + PCIE_CAP_FATAL_ERR_REPORT_EN | PCIE_CAP_UNSUPPORT_REQ_REP_EN); > + writel(val, pci->dbi_base + DBI_DEVICE_CONTROL_DEVICE_STATUS); Is there any way to split the AER part (specified by the PCIe spec) from the qcom-specific (or dwc-specific) part? This looks an awful lot like pci_enable_pcie_error_reporting(), and we should do this in the PCI core in a generic way if possible. > + val = readl(pci->dbi_base + DBI_ROOT_CONTROL_ROOT_CAPABILITIES_REG); > + val |= (PCIE_CAP_SYS_ERR_ON_CORR_ERR_EN | PCIE_CAP_SYS_ERR_ON_NON_FATAL_ERR_EN | > + PCIE_CAP_SYS_ERR_ON_FATAL_ERR_EN); > + writel(val, pci->dbi_base + DBI_ROOT_CONTROL_ROOT_CAPABILITIES_REG); Bjorn