From patchwork Mon Oct 4 14:06:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534001 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84221C433EF for ; Mon, 4 Oct 2021 14:08:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D47161216 for ; Mon, 4 Oct 2021 14:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232941AbhJDOKQ (ORCPT ); Mon, 4 Oct 2021 10:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbhJDOKQ (ORCPT ); Mon, 4 Oct 2021 10:10:16 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 919C5C061745; Mon, 4 Oct 2021 07:08:27 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id p1so8541016pfh.8; Mon, 04 Oct 2021 07:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pG3mj4bKDd7l8ZFqHwjB1MgvpFgzE+2HiTROeiz4Dcw=; b=lilGDKkKstiY05E5PyE6eTWtE6sIolLARmbbIcr/hqOA8+se7jC/6nCaMMxpRTSwVK UeugaZA+ONPjmn8b7h3jTo6EWExYu9ijMWFU//wEGelNg79uZwL0xe4SBkDT8c0evCBV vnYV47fu3GZkLLBReTPf/YnjCzvvOkKOFy/3uEVFQQAyrBBrx633MXBGh4QOWFFcBC6p ugF4m9gGPaEQyA6xHFbo3xSP+HRVs0zaWtZybBOaNMJbIOR5ihBDblAIC408n29OvxJN mlddVJqrtP9y1cs+I8juih3VPe2CvbZvu+c52hM36JIhR74DyDqzsXyq47rYZl0QU5oe WvQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pG3mj4bKDd7l8ZFqHwjB1MgvpFgzE+2HiTROeiz4Dcw=; b=pbaW0pSK5KD6LvGZM1gle+r8qKV1AgsEmLVWfo3saswD7J6RoN0q0DcnFW/UfPq9Bd e9QtGm2TmJm+32iqV6Lecsv/r7b1OfFnW/zkoYF3D4+9PVoMucVRy+FctSDfurtFQEsC VRBEdMhup1p5jTzIiWmRUD6vBUo3ppbLzZj/t0bIo8GtsCD0EFjrW4YI+TVMfYwPd2FR 6Z4Y9eauyC9BN758JViqlRTY/AyHI6jDxTDCGKn+hivnmSDEl4azQTJrLD2qsc5T5TeI IAcj9MZ+KQKLCjmEE92dP/IMEikeiutizWXSHRdnWwfj1b2RXtWwzF1YoV1TInoZRkj6 txDg== X-Gm-Message-State: AOAM533FMZpPsh9hHRFtdJUiZyJpYFcgAJskIU7TBZBTFyieNhrwPXZx NcNhnoI8yx0bM4unqhxVNpw= X-Google-Smtp-Source: ABdhPJxi5ObVFVVBq0INJgWYPzDSEXSeO16X87FcHRyfY9VfsWk60eCRTs+ik8NdZ3TgjzfU1+S0PA== X-Received: by 2002:a05:6a00:140c:b0:447:96be:2ade with SMTP id l12-20020a056a00140c00b0044796be2ademr25904944pfu.26.1633356507042; Mon, 04 Oct 2021 07:08:27 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:08:26 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH v2 1/8] PCI/AER: Remove ID from aer_agent_string[] Date: Mon, 4 Oct 2021 19:36:27 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Before 010caed4ccb6 ("PCI/AER: Decode Error Source RequesterID") the AER error logs looked like: pcieport 0000:00:03.0: AER: Corrected error received: id=0018 pcieport 0000:00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, id=0018 (Receiver ID) pcieport 0000:00:03.0: device [1b36:000c] error status/mask=00000040/0000e000 pcieport 0000:00:03.0: [ 6] BadTLP In 010caed4ccb6 ("PCI/AER: Decode Error Source Requester ID"), the "id" field was removed from the AER error logs, so currently AER logs look like: pcieport 0000:00:03.0: AER: Corrected error received: 0000:00:03:0 pcieport 0000:00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Receiver ID) pcieport 0000:00:03.0: device [1b36:000c] error status/mask=00000040/0000e000 pcieport 0000:00:03.0: [ 6] BadTLP The second line in the above logs prints "(Receiver ID)", even when there is no "id" in the log line. This is confusing. Remove the "ID" from the aer_agent_string[]. The error logs will look as follows (Sample from dummy error injected by aer-inject): pcieport 0000:00:03.0: AER: Corrected error received: 0000:00:03.0 pcieport 0000:00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Receiver) pcieport 0000:00:03.0: device [1b36:000c] error status/mask=00000040/0000e000 pcieport 0000:00:03.0: [ 6] BadTLP Signed-off-by: Naveen Naidu --- drivers/pci/pcie/aer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 9784fdcf3006..241ff361b43c 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -516,10 +516,10 @@ static const char *aer_uncorrectable_error_string[] = { }; static const char *aer_agent_string[] = { - "Receiver ID", - "Requester ID", - "Completer ID", - "Transmitter ID" + "Receiver", + "Requester", + "Completer", + "Transmitter" }; #define aer_stats_dev_attr(name, stats_array, strings_array, \ @@ -703,7 +703,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) const char *level; if (!info->status) { - pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n", + pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent)\n", aer_error_severity_string[info->severity]); goto out; } From patchwork Mon Oct 4 14:06:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534003 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABC78C433F5 for ; Mon, 4 Oct 2021 14:08:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F57761264 for ; Mon, 4 Oct 2021 14:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233723AbhJDOK1 (ORCPT ); Mon, 4 Oct 2021 10:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233906AbhJDOKZ (ORCPT ); Mon, 4 Oct 2021 10:10:25 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D06C061783; Mon, 4 Oct 2021 07:08:36 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 133so16665225pgb.1; Mon, 04 Oct 2021 07:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FR6K5YUYcCv1FDH4y5DK0PhIoCQEDWlRf94cnPNCwds=; b=E+TFvkLSQJvOplJzbRd6c4bA6eLdXlCzyriCZA5Wqc5TF+e74RZsBLXqc+tXDXAo/q UT8xkQl/rR1/w3AnnhPL/CbF0ZIkA/LvQ6x6fuWClo9NoC4MJwQXx0YQhvAs5AaXZf/I qkoxe/YLVKpRnpMmU1vZUjYBdXK5GaAJn1g0qNajQ0H5Dom4MkRP2/ffU1Y2vqx6hmhs EJcNuEt7Rfc6ie3j7rn6pJHwM8SeyKzzZPY87cBOiVYdWOY3FAeNnddsOtEJc5Cwm7rm fJQVevf8GK/Lm14YRbw5ihnNv7QdHEn1R2+B/FhHolky0LEd05k0bvAmqWrQZ/0+rwjS rSRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FR6K5YUYcCv1FDH4y5DK0PhIoCQEDWlRf94cnPNCwds=; b=QFMZCuu5bh6JrV1XRQgS61alA86YntT3b3zZdyPWQPAFB9THwaDGLUK/ZUDVMy4lvy rEOp3qtcb7DaiAgLL+GoKIELCQ5V4oLvWBi8+fAAsMTxlhrZq9q4eMlcJgT9PvvBnXtp mhlRZr22T0/6zbBp/L5X7fmV9miZDjuTikwoeJDVTeWzkhIpJgjBHW0gix9nU7+94bs6 l2x8cxuS9To4SeO3NjG2pcw8mXqoNmNFUcr9F6nleC/t3M8nLxrtQtiYMR3uW9/saNy0 nMoDM3D3I/vCq8RakMrFdz38ys+qI9bjUiQsUCnNcQwWCeYXz/B30CC5GFntuFcssUXG WpiQ== X-Gm-Message-State: AOAM530OnSDnAdYHf2rJSzy7kcjGpx/JJpgX2vHCpRJC2Pm2yAWwCUs4 1aiBBRWjdnOke/1vId9DLEY= X-Google-Smtp-Source: ABdhPJyck3KTFEhO5ILC3yxxjpAI2DOPtg7DvJQM0OSyr64tht7atYOar8FVU3irGbi8qaG1HdUo1A== X-Received: by 2002:a63:7543:: with SMTP id f3mr11075085pgn.449.1633356515744; Mon, 04 Oct 2021 07:08:35 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:08:35 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH v2 2/8] PCI: Cleanup struct aer_err_info Date: Mon, 4 Oct 2021 19:36:28 +0530 Message-Id: <247efb0e4168393f4aee5e267a9aa8b3a8adff0f.1633353468.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The id, status and the mask fields of the struct aer_err_info comes directly from the registers, hence their sizes should be explicit. The length of these registers are: - id: 16 bits - Represents the Error Source Requester ID - status: 32 bits - COR/UNCOR Error Status - mask: 32 bits - COR/UNCOR Error Mask Since the length of the above registers are even, use u16 and u32 to represent their values. Also remove the __pad fields. "pahole" was run on the modified struct aer_err_info and the size remains unchanged. Signed-off-by: Naveen Naidu --- drivers/pci/pci.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 1cce56c2aea0..9be7a966fda7 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -427,18 +427,16 @@ struct aer_err_info { struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; int error_dev_num; - unsigned int id:16; + u16 id; unsigned int severity:2; /* 0:NONFATAL | 1:FATAL | 2:COR */ - unsigned int __pad1:5; unsigned int multi_error_valid:1; unsigned int first_error:5; - unsigned int __pad2:2; unsigned int tlp_header_valid:1; - unsigned int status; /* COR/UNCOR Error Status */ - unsigned int mask; /* COR/UNCOR Error Mask */ + u32 status; /* COR/UNCOR Error Status */ + u32 mask; /* COR/UNCOR Error Mask */ struct aer_header_log_regs tlp; /* TLP Header */ }; From patchwork Mon Oct 4 14:06:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534005 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A020C433F5 for ; Mon, 4 Oct 2021 14:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 230C361216 for ; Mon, 4 Oct 2021 14:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232395AbhJDOKi (ORCPT ); Mon, 4 Oct 2021 10:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbhJDOKi (ORCPT ); Mon, 4 Oct 2021 10:10:38 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86A70C061745; Mon, 4 Oct 2021 07:08:49 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 66so16231292pgc.9; Mon, 04 Oct 2021 07:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0szOl/Q5keJYQjPtxy9YApfb7ftHWXnTXQ4eoRdC7oM=; b=UODKNW+w6JqcRGrC4Q+SVrXJIBvZuiGgsC1CnbvFZLuTfE39R4UJV67JbABZzdikL7 mbf/YH18xaYDC4DEhaBL1l/7kL+PPmddU6e0mLCjiEMNJLlla87mWMrFKFtf1VIdJP6Z 8hTr95oy6ZMBtFcP4npA9+nhSNHkORukwWwwBs7KBd7OPB4jOGCxIp2nsrdw4iuknFxi 79MjUOuX1W7exN3NFv48g+qpKefAvdzMKoJzeXyoND565RYILsbPR1kQ7btVh5BhRhJk SUehVB3Hk6HGg7A04lxfaLvQgr2Z7qDgcyQm7lGvJqIbabUTKuW6S2MOwUsWadLc2rgD CORw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0szOl/Q5keJYQjPtxy9YApfb7ftHWXnTXQ4eoRdC7oM=; b=mpseafZKeCalV/AHdOKuMOvmh16fBFJz3llODRQZJNvfbz+t5Y9gmvEglhggNM6fC4 1HRFr5znqUlxqATmyerXGl3ZYBp6G/GPWl8vSZG7HXaKSHc9f4Bi4IMFGh5GfjQhyslM ckv1Hku3BdyUC69dxG4C8Xl0TObsxA99MHh7GfxJ0JXg1EiWvbM7l7bC9WYODCeKjdQX 9w5d2lshNFdpiN4MWROaTdz2IlkmUGoa2+5tHbFY6JJPrKCOea7NvqPgsWOArwJw5S/u 3sNd9QBtt19p10dUtKRccCqOm6TvRJFQ9eX+E77VVt8QDHaZEPCsoFWAqPzRoqSBwFis a5IA== X-Gm-Message-State: AOAM533cNfNMLrECpy0ppzL2b3Dhi15kMw4dKAPw06TEMvufuIUV1B+Q oun2w+exNoU6UJ+f0SSeDAL6C9ShSjxw0S+c X-Google-Smtp-Source: ABdhPJxV2DJd3rBZSk13rzcbJOxYwFHvBZ/bK3s81EUKzlHhfCA8nMN5Z1RjiYiLyETYzXzaMnN0DQ== X-Received: by 2002:a63:ed03:: with SMTP id d3mr11116397pgi.24.1633356529107; Mon, 04 Oct 2021 07:08:49 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:08:48 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v2 3/8] PCI/DPC: Initialize info->id in dpc_process_error() Date: Mon, 4 Oct 2021 19:36:29 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In the dpc_process_error() path, info->id isn't initialized before being passed to aer_print_error(). In the corresponding AER path, it is initialized in aer_isr_one_error(). The error message shown during Coverity Scan is: Coverity #1461602 CID 1461602 (#1 of 1): Uninitialized scalar variable (UNINIT) 8. uninit_use_in_call: Using uninitialized value info.id when calling aer_print_error. Initialize the "info->id" before passing it to aer_print_error() Fixes: 8aefa9b0d910 ("PCI/DPC: Print AER status in DPC event handling") Signed-off-by: Naveen Naidu --- drivers/pci/pcie/dpc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index c556e7beafe3..df3f3a10f8bc 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -262,14 +262,14 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev, void dpc_process_error(struct pci_dev *pdev) { - u16 cap = pdev->dpc_cap, status, source, reason, ext_reason; + u16 cap = pdev->dpc_cap, status, reason, ext_reason; struct aer_err_info info; pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); - pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &source); + pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &info.id); pci_info(pdev, "containment event, status:%#06x source:%#06x\n", - status, source); + status, info.id); reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1; ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5; From patchwork Mon Oct 4 14:06:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534007 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71BC2C433EF for ; Mon, 4 Oct 2021 14:08:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C71561216 for ; Mon, 4 Oct 2021 14:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233900AbhJDOKp (ORCPT ); Mon, 4 Oct 2021 10:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234023AbhJDOKn (ORCPT ); Mon, 4 Oct 2021 10:10:43 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AD1C061749; Mon, 4 Oct 2021 07:08:54 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id v19so11641869pjh.2; Mon, 04 Oct 2021 07:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WgoZ9+KpQrZR7tDkQXfhNUVljLBFuOfZzG3U49+7PlA=; b=WEUa66Fd7WtoDf/7Q8UM0ovCljnLKeI51nGJW39td75KXO3U8ACM8fup/QKb83eEnY 5We5vSmFdYsjyhUd+BXEy6X5npUgLcRVji1T8id5/IdsPYDffHPrdeaJG0vcp92GFYgi /6cPJrhvm3IRtDg+CimNj7eF2wU/5hwajfSjBiZFgJUU2FKT/HNmgWrawEp913St+qtS /UehFaW02zzrxLTQPZT3rPz0B/JK9PUF3MRNhNTHfHAXJCZIMrSKgiNUCGjl/4AKrB2a uvfiedlgTlMHTIz3lNS7YMTHLlXplBBRz1W+93YjBV8x+zquGy421afJsMPsjOnaue6V ZNLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WgoZ9+KpQrZR7tDkQXfhNUVljLBFuOfZzG3U49+7PlA=; b=Wl3+duQdMbBgEy0KFkJHMVsfqUj4pMFqQYLD4m37h+8IzsIz2XX+mB63ONQ33YZqNa 3Bir36OOmk+qhLsuUKKN39zbTfiHj4iwwUILkvlh9XuJV872vBHQysT/LtgSJU2Ee0dI vJU4SUJTB6tMTQqPER3RlEm72Ec9YDARzVBRJGkvxUnB8apsD1SxtA5CwwbO9/aDJeW5 +cPbtJR73CeNrORheSW6zSFPRrJ6+wI57XDZwFYl4SsfEbUMigTWJFx8vucpu/cbFXdq h1qSKR84JeH0QZkpCvECsQj0EXqKjt3uBYVT9j1j453t2jrAkyn1Gzi7FPXpSUnPzaGV 2yCQ== X-Gm-Message-State: AOAM531+wnIxmk/BYFGJO/nMJrOcoJYkgngRriYCzD85ivkzXVXB+x0e ckzlZMdykCUH9jy3kVpuZ1Q= X-Google-Smtp-Source: ABdhPJxiXt3ftOJK3flYITskQM3Ai/Q5NEFZd6Kg0s9wJr1Y2Z0LU5DHKJF6ULES21X3Rgeej6QwzQ== X-Received: by 2002:a17:903:246:b0:13a:22d1:88b with SMTP id j6-20020a170903024600b0013a22d1088bmr23318540plh.16.1633356534168; Mon, 04 Oct 2021 07:08:54 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:08:53 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH v2 4/8] PCI/DPC: Use pci_aer_clear_status() in dpc_process_error() Date: Mon, 4 Oct 2021 19:36:30 +0530 Message-Id: <71cec6aef2535b48911bd98bd010012643eb0bd0.1633353468.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org dpc_process_error() clears both AER fatal and non fatal status registers. Instead of clearing each status registers via a different function call use pci_aer_clear_status(). This helps clean up the code a bit. Signed-off-by: Naveen Naidu --- drivers/pci/pcie/dpc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index df3f3a10f8bc..faf4a1e77fab 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -288,8 +288,7 @@ void dpc_process_error(struct pci_dev *pdev) dpc_get_aer_uncorrect_severity(pdev, &info) && aer_get_device_error_info(pdev, &info)) { aer_print_error(pdev, &info); - pci_aer_clear_nonfatal_status(pdev); - pci_aer_clear_fatal_status(pdev); + pci_aer_clear_status(pdev); } } From patchwork Mon Oct 4 14:06:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534009 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76024C433FE for ; Mon, 4 Oct 2021 14:09:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60C9661269 for ; Mon, 4 Oct 2021 14:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbhJDOKy (ORCPT ); Mon, 4 Oct 2021 10:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233174AbhJDOKw (ORCPT ); Mon, 4 Oct 2021 10:10:52 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C3DC061783; Mon, 4 Oct 2021 07:09:01 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id b22so11199639pls.1; Mon, 04 Oct 2021 07:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w+NqgXClATM2+U/6pmcAe6ttC1b34HIq6gozyTG/Fag=; b=Ozwj5eo+JQr13kbgISfT/YYcy0EwCY30LXLUlWlbVkJd67t6s5mPWeUrFyYkyLrScw QE30Lg2AZumU/Mp/g+pSA4HdJXE5l4IgxgYCrtImGnxcdEtEgn31D4eskl5WNWLfmoiP dwSqeOT1wboM4W0ANBUZwjRBI9rpiG7hFCcqlsROuhtqYyrXOjk7zuSd+Ijok4MTEt/8 w4lb6EAAX7Fe0Frs8sNL9k/0JYK2UkkTdD1D0cj2HqZgpxjOjGHa7KywPAQ+vt5wkMcd Z+6A3E5K8CejOdX7iWB+K5ko0IFiqV343d0OD2eUzDncwhqD8kIy7on3eSNpIFI1BHle 3woA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w+NqgXClATM2+U/6pmcAe6ttC1b34HIq6gozyTG/Fag=; b=8DLJtJhMwcAkaoRXGEshEbDteXVq6OHqsRwk1wGDMidRM1+drdvJodJ028A4vXS7Iu fxAyiG1XYLxmrsKB6w/gDPKthVdiA05AAufBEMMclI8/lvZoUvUc0z2tsQGQbQt/hFlO 4LrMSSWkQpRvIgQcZi3iBPgTAatK4b1sdey66J3ijWNCA2cdCAkLhNRoGGWoK8SHlnFc ZvhC0oRWUUU9hXetShJH9HGI0XG6JPzsFIz2wclwem5XyeFkM1Z3YFYzDbiGixDT6qm/ H5Xfi62hqMhdzsoYX6v1uR+dQLVklNGwbHYuVtSOI9W4OUbUvwLrpf/vcWjCoYt219Hp qFoA== X-Gm-Message-State: AOAM5308Je7LRweL2th6HmjrQFJr42r2eVVpossGILdlp9I69DWYY+71 w+WN6Y6Z8PmFqanbIR8/LNDXqU6FbqL28oT+ X-Google-Smtp-Source: ABdhPJz9tTa1vY09/ksLF7xk0Y6tU/8x10h8zOlbMuBmOEpd9L/4e0/Z5IuE/XsKNuFAeKf6CCpFYg== X-Received: by 2002:a17:902:b691:b029:12d:2b6:d116 with SMTP id c17-20020a170902b691b029012d02b6d116mr23418269pls.71.1633356541150; Mon, 04 Oct 2021 07:09:01 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:09:00 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH v2 5/8] PCI/DPC: Converge EDR and DPC Path of clearing AER registers Date: Mon, 4 Oct 2021 19:36:31 +0530 Message-Id: <14df904c301dc417485f5a7563053b81ab1d3c76.1633353468.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In the EDR path, AER registers are cleared *after* DPC error event is processed. The process stack in EDR is: edr_handle_event() dpc_process_error() pci_aer_raw_clear_status() pcie_do_recovery() But in DPC path, AER status registers are cleared *while* processing the error. The process stack in DPC is: dpc_handler() dpc_process_error() pci_aer_clear_status() pcie_do_recovery() In EDR path, AER status registers are cleared irrespective of whether the error was an RP PIO or unmasked uncorrectable error. But in DPC, the AER status registers are cleared only when it's an unmasked uncorrectable error. This leads to two different behaviours for the same task (handling of DPC errors) in FFS systems and when native OS has control. Bring the same semantics for clearing the AER status register in EDR path and DPC path. Signed-off-by: Naveen Naidu --- drivers/pci/pcie/dpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index faf4a1e77fab..68899a3db126 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -288,7 +288,6 @@ void dpc_process_error(struct pci_dev *pdev) dpc_get_aer_uncorrect_severity(pdev, &info) && aer_get_device_error_info(pdev, &info)) { aer_print_error(pdev, &info); - pci_aer_clear_status(pdev); } } @@ -297,6 +296,7 @@ static irqreturn_t dpc_handler(int irq, void *context) struct pci_dev *pdev = context; dpc_process_error(pdev); + pci_aer_clear_status(pdev); /* We configure DPC so it only triggers on ERR_FATAL */ pcie_do_recovery(pdev, pci_channel_io_frozen, dpc_reset_link); From patchwork Mon Oct 4 14:06:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534011 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C685C433EF for ; Mon, 4 Oct 2021 14:09:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17B9D6128A for ; Mon, 4 Oct 2021 14:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234162AbhJDOK5 (ORCPT ); Mon, 4 Oct 2021 10:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233174AbhJDOK4 (ORCPT ); Mon, 4 Oct 2021 10:10:56 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1BDEC061745; Mon, 4 Oct 2021 07:09:07 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id 187so10190970pfc.10; Mon, 04 Oct 2021 07:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BLwd+ei/6xpK2zg1bz0/dW3QBzh0TkkX9RDyyV7sGhM=; b=BehV55rbm2Bor/S0Zz2tYUInDkfTwC3do1y6xsPBOikLs2AltFygP0OCRbq6/mEdD7 Wxg/cT11Mx+0Fst6mG/IOzsasQPbiGG3rss114Oii0uVOwxxiDP7eY1Szil6gEG/bDXD njFOtm4hbTXrtTE5XX9kNPYhKEp4aFTp7p3y1CKki0HOTdb2csOxURuYLk9V/57c4uXw KUCq29CMwtFetWjLFL1aTUt94GisQ55QP7xs6e4YY2ibQtzz04021/2uGmNMzEp1Aj0R YlvoBtuseQ/f4ka4c+pGismLIDAPfMNEGoojktsMl7iIiBpK8n491P9aPEo8iHtmnXVK EARA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BLwd+ei/6xpK2zg1bz0/dW3QBzh0TkkX9RDyyV7sGhM=; b=di5X61FRvgscTO7t1Vf8+AnkTDEjTlGxk1cUz6aRKhzVmKuV8o+sOalFrDEKyaVHJo HY0e1iAOsSEpQwO/ZxNGYTI9hJsaMIMY3YD3pwejecW4kuDX54Vh5n/rwJjENUoiJvN1 mzAD12aRYxbkabvZa3ucr8ZpS2C7OE6OHrrhumDhoidPcKM8aFEcNootRvL5+l3PH2tK /Ri84JPEhnRec/kIuMfYDCQJNnZm9m18Us9rgPBWekwKCTedCRK2CrJi7AvPTbfixEmQ TcHBpo00aGcIWM28y0SgxMfYe1bUBbPJHNo2ULyPaOo7RbmlqtOu7DcwnDa+nJkxYeJ1 7RaQ== X-Gm-Message-State: AOAM531B/0OAv2tA36kgBDIwYXP9/ZkNqdlQJICoXAw0j7MwzYQ13iKY Plg4rS9jWxpfM/1E4646pcs= X-Google-Smtp-Source: ABdhPJzq5kCdlc1M4HYW9TIr2fkZXdiaMDpfrATLDWDU8M1wTj83ik48wXXwsrVy44m5YKUkAqrx2A== X-Received: by 2002:a63:b007:: with SMTP id h7mr10802295pgf.443.1633356547275; Mon, 04 Oct 2021 07:09:07 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:09:06 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH v2 6/8] PCI/AER: Clear error device AER registers in aer_irq() Date: Mon, 4 Oct 2021 19:36:32 +0530 Message-Id: <74c7e46635aa32446fb569dbc20dfb6e7a772bcb.1633353468.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Converge the APEI path and native AER path of clearing the AER registers of the error device. In APEI path, the system firmware clears the AER registers before handing off the record to OS. But in "native AER" path, the execution path of clearing the AER register is as follows: aer_isr_one_error aer_print_port_info if (find_source_device()) aer_process_err_devices handle_error_source pci_write_config_dword(dev, PCI_ERR_COR_STATUS, ...) The above path has a bug, if the find_source_device() fails, AER registers are not cleared from the error device. This means, the error device will keep reporting the error again and again and would lead to message spew. Related Bug Report: https://lore.kernel.org/linux-pci/20151229155822.GA17321@localhost/ https://bugzilla.kernel.org/show_bug.cgi?id=109691 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1521173 The above bug could be avoided, if the AER registers are cleared during the AER IRQ handler aer_irq(), which would provide guarantee that the AER error registers are always cleared. This is similar to how APEI handles these errors. The main aim is that: When an interrupt handler deals with a interrupt, it must *always* clear the source of the interrupt. Signed-off-by: Naveen Naidu --- drivers/pci/pci.h | 13 ++- drivers/pci/pcie/aer.c | 245 ++++++++++++++++++++++++++++------------- 2 files changed, 182 insertions(+), 76 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 9be7a966fda7..eb88d8bfeaf7 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -424,7 +424,6 @@ static inline bool pci_dev_is_added(const struct pci_dev *dev) #define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */ struct aer_err_info { - struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; int error_dev_num; u16 id; @@ -440,6 +439,18 @@ struct aer_err_info { struct aer_header_log_regs tlp; /* TLP Header */ }; +/* Preliminary AER error information processed from Root port */ +struct aer_devices_err_info { + struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; + struct aer_err_info err_info; +}; + +/* AER information associated with each error device */ +struct aer_dev_err_info { + struct pci_dev *dev; + struct aer_err_info err_info; +}; + int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info); void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); #endif /* CONFIG_PCIEAER */ diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 241ff361b43c..91f91d6ab052 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -36,6 +36,18 @@ #define AER_ERROR_SOURCES_MAX 128 +/* + * There can be 128 maximum error sources (AER_ERROR_SOURCES_MAX) and each + * error source can have maximum of 5 error devices (AER_MAX_MULTI_ERR_DEVICES) + * so the maximum error devices we can report is: + * + * AER_ERROR_DEVICES_MAX = AER_ERROR_SOURCES_MAX * AER_MAX_MULTI_ERR_DEVICES == (128 * 5) == 640 + * + * But since, the size in KFIFO should be a power of two, the closest value + * to 640 is 1024 + */ +# define AER_ERROR_DEVICES_MAX 1024 + #define AER_MAX_TYPEOF_COR_ERRS 16 /* as per PCI_ERR_COR_STATUS */ #define AER_MAX_TYPEOF_UNCOR_ERRS 27 /* as per PCI_ERR_UNCOR_STATUS*/ @@ -46,7 +58,7 @@ struct aer_err_source { struct aer_rpc { struct pci_dev *rpd; /* Root Port device */ - DECLARE_KFIFO(aer_fifo, struct aer_err_source, AER_ERROR_SOURCES_MAX); + DECLARE_KFIFO(aer_fifo, struct aer_dev_err_info, AER_ERROR_DEVICES_MAX); }; /* AER stats for the device */ @@ -806,11 +818,11 @@ void cper_print_aer(struct pci_dev *dev, int aer_severity, * @e_info: pointer to error info * @dev: pointer to pci_dev to be added */ -static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev) +static int add_error_device(struct aer_devices_err_info *e_dev, struct pci_dev *dev) { - if (e_info->error_dev_num < AER_MAX_MULTI_ERR_DEVICES) { - e_info->dev[e_info->error_dev_num] = pci_dev_get(dev); - e_info->error_dev_num++; + if (e_dev->err_info.error_dev_num < AER_MAX_MULTI_ERR_DEVICES) { + e_dev->dev[e_dev->err_info.error_dev_num] = pci_dev_get(dev); + e_dev->err_info.error_dev_num++; return 0; } return -ENOSPC; @@ -877,18 +889,18 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info) static int find_device_iter(struct pci_dev *dev, void *data) { - struct aer_err_info *e_info = (struct aer_err_info *)data; + struct aer_devices_err_info *e_dev = (struct aer_devices_err_info *)data; - if (is_error_source(dev, e_info)) { + if (is_error_source(dev, &e_dev->err_info)) { /* List this device */ - if (add_error_device(e_info, dev)) { + if (add_error_device(e_dev, dev)) { /* We cannot handle more... Stop iteration */ /* TODO: Should print error message here? */ return 1; } /* If there is only a single error, stop iteration */ - if (!e_info->multi_error_valid) + if (!e_dev->err_info.multi_error_valid) return 1; } return 0; @@ -907,26 +919,26 @@ static int find_device_iter(struct pci_dev *dev, void *data) * e_info->error_dev_num and e_info->dev[], based on the given information. */ static bool find_source_device(struct pci_dev *parent, - struct aer_err_info *e_info) + struct aer_devices_err_info *e_dev) { struct pci_dev *dev = parent; int result; /* Must reset in this function */ - e_info->error_dev_num = 0; + e_dev->err_info.error_dev_num = 0; /* Is Root Port an agent that sends error message? */ - result = find_device_iter(dev, e_info); + result = find_device_iter(dev, e_dev); if (result) return true; if (pci_pcie_type(parent) == PCI_EXP_TYPE_RC_EC) - pcie_walk_rcec(parent, find_device_iter, e_info); + pcie_walk_rcec(parent, find_device_iter, e_dev); else - pci_walk_bus(parent->subordinate, find_device_iter, e_info); + pci_walk_bus(parent->subordinate, find_device_iter, e_dev); - if (!e_info->error_dev_num) { - pci_info(parent, "can't find device of ID%04x\n", e_info->id); + if (!e_dev->err_info.error_dev_num) { + pci_info(parent, "can't find device of ID%04x\n", e_dev->err_info.id); return false; } return true; @@ -940,24 +952,42 @@ static bool find_source_device(struct pci_dev *parent, * Invoked when an error being detected by Root Port. */ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) +{ + /* + * Correctable error does not need software intervention. + * No need to go through error recovery process. + */ + if (info->severity == AER_NONFATAL) + pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset); + else if (info->severity == AER_FATAL) + pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset); + pci_dev_put(dev); +} + +/** + * clear_error_source_aer_registers - clear AER registers of the error source device + * @dev: pointer to pci_dev data structure of error source device + * @info: comprehensive error information + * + * Invoked when an error being detected by Root Port but before we handle the + * error. + */ +static void clear_error_source_aer_registers(struct pci_dev *dev, struct aer_err_info info) { int aer = dev->aer_cap; - if (info->severity == AER_CORRECTABLE) { - /* - * Correctable error does not need software intervention. - * No need to go through error recovery process. - */ + if (info.severity == AER_CORRECTABLE) { if (aer) pci_write_config_dword(dev, aer + PCI_ERR_COR_STATUS, - info->status); + info.status); if (pcie_aer_is_native(dev)) pcie_clear_device_status(dev); - } else if (info->severity == AER_NONFATAL) - pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset); - else if (info->severity == AER_FATAL) - pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset); - pci_dev_put(dev); + } else if (info.severity == AER_NONFATAL) { + pci_aer_clear_nonfatal_status(dev); + } else if (info.severity == AER_FATAL) { + pci_aer_clear_fatal_status(dev); + } + } #ifdef CONFIG_ACPI_APEI_PCIEAER @@ -1093,70 +1123,112 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) return 1; } -static inline void aer_process_err_devices(struct aer_err_info *e_info) -{ - int i; - - /* Report all before handle them, not to lost records by reset etc. */ - for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { - if (aer_get_device_error_info(e_info->dev[i], e_info)) - aer_print_error(e_info->dev[i], e_info); - } - for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { - if (aer_get_device_error_info(e_info->dev[i], e_info)) - handle_error_source(e_info->dev[i], e_info); - } -} - /** - * aer_isr_one_error - consume an error detected by root port - * @rpc: pointer to the root port which holds an error + * aer_find_corr_error_source_device - find the error source which detected the corrected error + * @rp: pointer to Root Port pci_dev data structure * @e_src: pointer to an error source + * @e_info: including detailed error information such like id + * + * Return true if found. + * + * Process the error information received at the Root Port, set these values + * in the aer_devices_err_info and find all the devices that are related to + * the error. */ -static void aer_isr_one_error(struct aer_rpc *rpc, - struct aer_err_source *e_src) +static bool aer_find_corr_error_source_device(struct pci_dev *rp, + struct aer_err_source *e_src, + struct aer_devices_err_info *e_info) { - struct pci_dev *pdev = rpc->rpd; - struct aer_err_info e_info; - - pci_rootport_aer_stats_incr(pdev, e_src); - - /* - * There is a possibility that both correctable error and - * uncorrectable error being logged. Report correctable error first. - */ if (e_src->status & PCI_ERR_ROOT_COR_RCV) { - e_info.id = ERR_COR_ID(e_src->id); - e_info.severity = AER_CORRECTABLE; + e_info->err_info.id = ERR_COR_ID(e_src->id); + e_info->err_info.severity = AER_CORRECTABLE; if (e_src->status & PCI_ERR_ROOT_MULTI_COR_RCV) - e_info.multi_error_valid = 1; + e_info->err_info.multi_error_valid = 1; else - e_info.multi_error_valid = 0; - aer_print_port_info(pdev, &e_info); + e_info->err_info.multi_error_valid = 0; - if (find_source_device(pdev, &e_info)) - aer_process_err_devices(&e_info); + if (!find_source_device(rp, e_info)) + return false; } + return true; +} +/** + * aer_find_corr_error_source_device - find the error source which detected the uncorrected error + * @rp: pointer to Root Port pci_dev data structure + * @e_src: pointer to an error source + * @e_info: including detailed error information such like id + * + * Return true if found. + * + * Process the error information received at the Root Port, set these values + * in the aer_devices_err_info and find all the devices that are related to + * the error. + */ +static bool aer_find_uncorr_error_source_device(struct pci_dev *rp, + struct aer_err_source *e_src, + struct aer_devices_err_info *e_info) +{ if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) { - e_info.id = ERR_UNCOR_ID(e_src->id); + e_info->err_info.id = ERR_UNCOR_ID(e_src->id); if (e_src->status & PCI_ERR_ROOT_FATAL_RCV) - e_info.severity = AER_FATAL; + e_info->err_info.severity = AER_FATAL; else - e_info.severity = AER_NONFATAL; + e_info->err_info.severity = AER_NONFATAL; if (e_src->status & PCI_ERR_ROOT_MULTI_UNCOR_RCV) - e_info.multi_error_valid = 1; + e_info->err_info.multi_error_valid = 1; else - e_info.multi_error_valid = 0; + e_info->err_info.multi_error_valid = 0; + + if (!find_source_device(rp, e_info)) + return false; + } - aer_print_port_info(pdev, &e_info); + return true; +} - if (find_source_device(pdev, &e_info)) - aer_process_err_devices(&e_info); +/** + * aer_isr_one_error - consume an error detected by root port + * @rp: pointer to Root Port pci_dev data structure + * @e_dev: pointer to an error device + */ +static void aer_isr_one_error(struct pci_dev *rp, struct aer_dev_err_info *e_dev) +{ + aer_print_port_info(rp, &e_dev->err_info); + aer_print_error(e_dev->dev, &e_dev->err_info); + handle_error_source(e_dev->dev, &e_dev->err_info); +} + +static bool aer_add_err_devices_to_queue(struct aer_rpc *rpc, + struct aer_devices_err_info *e_info) +{ + int i; + struct aer_dev_err_info *e_dev; + + e_dev = kzalloc(sizeof(*e_dev), GFP_ATOMIC); + if (!e_dev) + return false; + + for (i = 0; i < e_info->err_info.error_dev_num && e_info->dev[i]; i++) { + e_dev->err_info = e_info->err_info; + e_dev->dev = e_info->dev[i]; + + /* + * Store the AER register information for each error device on + * the queue + */ + if (aer_get_device_error_info(e_dev->dev, &e_dev->err_info)) { + if (!kfifo_put(&rpc->aer_fifo, *e_dev)) + return false; + + clear_error_source_aer_registers(e_dev->dev, e_dev->err_info); + } } + + return true; } /** @@ -1170,13 +1242,13 @@ static irqreturn_t aer_isr(int irq, void *context) { struct pcie_device *dev = (struct pcie_device *)context; struct aer_rpc *rpc = get_service_data(dev); - struct aer_err_source e_src; + struct aer_dev_err_info e_dev; if (kfifo_is_empty(&rpc->aer_fifo)) return IRQ_NONE; - while (kfifo_get(&rpc->aer_fifo, &e_src)) - aer_isr_one_error(rpc, &e_src); + while (kfifo_get(&rpc->aer_fifo, &e_dev)) + aer_isr_one_error(rpc->rpd, &e_dev); return IRQ_HANDLED; } @@ -1194,6 +1266,11 @@ static irqreturn_t aer_irq(int irq, void *context) struct pci_dev *rp = rpc->rpd; int aer = rp->aer_cap; struct aer_err_source e_src = {}; + struct aer_devices_err_info *e_info; + + e_info = kzalloc(sizeof(*e_info), GFP_ATOMIC); + if (!e_info) + return IRQ_NONE; pci_read_config_dword(rp, aer + PCI_ERR_ROOT_STATUS, &e_src.status); if (!(e_src.status & (PCI_ERR_ROOT_UNCOR_RCV|PCI_ERR_ROOT_COR_RCV))) @@ -1202,8 +1279,26 @@ static irqreturn_t aer_irq(int irq, void *context) pci_read_config_dword(rp, aer + PCI_ERR_ROOT_ERR_SRC, &e_src.id); pci_write_config_dword(rp, aer + PCI_ERR_ROOT_STATUS, e_src.status); - if (!kfifo_put(&rpc->aer_fifo, e_src)) - return IRQ_HANDLED; + pci_rootport_aer_stats_incr(rp, &e_src); + + /* + * There is a possibility that both correctable error and + * uncorrectable error are being logged. Find the devices which caused + * correctable errors first so that they can be added to the queue first + * and will be reported first. + * + * Before adding the error device to the queue to be handled, clear the + * AER status registers. + */ + if (aer_find_corr_error_source_device(rp, &e_src, e_info)) { + if (!aer_add_err_devices_to_queue(rpc, e_info)) + return IRQ_NONE; + } + + if (aer_find_uncorr_error_source_device(rp, &e_src, e_info)) { + if (!aer_add_err_devices_to_queue(rpc, e_info)) + return IRQ_NONE; + } return IRQ_WAKE_THREAD; } From patchwork Mon Oct 4 14:06:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534025 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0355C433EF for ; Mon, 4 Oct 2021 14:09:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B729F61269 for ; Mon, 4 Oct 2021 14:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbhJDOLC (ORCPT ); Mon, 4 Oct 2021 10:11:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233480AbhJDOLC (ORCPT ); Mon, 4 Oct 2021 10:11:02 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 552F5C061746; Mon, 4 Oct 2021 07:09:13 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id rm6-20020a17090b3ec600b0019ece2bdd20so67642pjb.1; Mon, 04 Oct 2021 07:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GUEhHrxHzVocYPRDueBy4ZqExPBHlS+x/5Sx/kTwk+s=; b=Si7JSd/KCOLunLi8xM0VLOx2PfEG1rYw8Zg126ccHtdjh+YTOhxwYlmk3G+Z+iOuCf MHWlQfDnN9L3IAYokhBuv6RzMXNEwGLY39mOQKAm8xzjypeTvKVCQTCx8KM/NezRyTGI TSa03Y3eVG7e/CJ/pJUta1TShaEHhnDHumTQlJwYJCf3Q/8DVlgTE815cyGKa8qtRTXc AlfIFxKrM1KIkTARnCET6lxWANzMKgN1pEKjXGsMgdHENp5Cl8NwGBRFQCzr1Myh4Isq Ut5lkCVNfJF0Ebmmzx6NwBkhmaW5aH0OLSSbRBazBfBfQ9eZBBVpn0zOlK0pEBRJiJnb iP1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GUEhHrxHzVocYPRDueBy4ZqExPBHlS+x/5Sx/kTwk+s=; b=UunAz5UicH1Da6LoQSaTBI09yuD50Nq9Ij3PJTtACCpJvPbxgyqb3JXyG6bveEHMbT rK9UzOH9KbETBQarGI6x8G4M5K1PKJYiQsejDDYozHXq8xR35JV9DEIqoemKe08I/dnT EGXUqaFUes3rT4pRQP5IjzlhOqCWB+rZBKQJm3jTM88ydcTqnpUp/13p6d0TmhaWEhuN IQfeYYQd3ld+hVLX6xTR6yktoeCJ8+T9ifC9IwgfGLSEtJpP1lb1bUD1FZBP4nuiN5x+ 8n6WQ4gW/SLyjqSesMEUtDE+LrVxdwfxkgfnlViDWrV7Bo8UYXXn3Y/Hm6LXIN4iSvz1 GzdA== X-Gm-Message-State: AOAM533umiXU9wVPoDOkBDXQx6CwU6MQUVxkTxn2W2l1RsqKdimouEec NuHYCQh+fr5hYpE//+h+kkM= X-Google-Smtp-Source: ABdhPJzZI+MfrURo1cZfuN3jk5UmArmhStUAiLlG7jckDZv+60lz4zNDTU5W6sSrwZ9tVHHecR8OSQ== X-Received: by 2002:a17:902:7ec8:b0:13b:9d7a:6396 with SMTP id p8-20020a1709027ec800b0013b9d7a6396mr23741711plb.86.1633356552819; Mon, 04 Oct 2021 07:09:12 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:09:12 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH v2 7/8] PCI/ERR: Remove redundant clearing of AER register in pcie_do_recovery() Date: Mon, 4 Oct 2021 19:36:33 +0530 Message-Id: <2360908d0f8406ed63a17a733c4d1defb49ee3d3.1633353468.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pcie_do_recovery() is shared across the following paths: - ACPI APEI - Native AER path - EDR - DPC ACPI APEI ========== ghes_handle_aer() aer_recover_queue() kfifo_in_spinlocked(aer_recover_ring) aer_recover_work_func() while (kfifo_get(aer_recover_ring)) pcie_do_recovery() In this path the system firmware clears the AER registers before handing off the record to the OS in ghes_handle_aer() Native AER ========== aer_irq() aer_add_err_devices_to_queue() kfifo_put(&rpc->aer_fifo, *e_dev) clear_error_source_aer_registers() <---- AER registers are cleard aer_isr() aer_isr_one_error() handle_error_source() pcie_do_recovery() The AER registers are cleared during the handling of IRQ, i.e before we the recovery starts. DPC ===== dpc_handler() dpc_process_error() pci_aer_clear_status() <---- AER registers are cleared pcie_do_recovery() EDR ==== edr_handle_event() dpc_process_error() pci_aer_raw_clear_status() <---- AER registers are cleared pcie_do_recovery() In all the above paths, the AER registers are cleared before pcie_do_recovery(). The non fatal status AER registers are again cleared in pcie_do_recovery(). This is redundant. Remove redundant clearing of AER register in pcie_do_recovery() Signed-off-by: Naveen Naidu --- drivers/pci/pcie/err.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index b576aa890c76..fe04b0ae22f4 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -231,14 +231,11 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, /* * If we have native control of AER, clear error status in the device - * that detected the error. If the platform retained control of AER, - * it is responsible for clearing this status. In that case, the - * signaling device may not even be visible to the OS. + * that detected the error. */ - if (host->native_aer || pcie_ports_native) { + if (host->native_aer || pcie_ports_native) pcie_clear_device_status(dev); - pci_aer_clear_nonfatal_status(dev); - } + pci_info(bridge, "device recovery successful\n"); return status; From patchwork Mon Oct 4 14:06:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12534027 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C454C433F5 for ; Mon, 4 Oct 2021 14:09:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A24A611C1 for ; Mon, 4 Oct 2021 14:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234219AbhJDOLK (ORCPT ); Mon, 4 Oct 2021 10:11:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233111AbhJDOLI (ORCPT ); Mon, 4 Oct 2021 10:11:08 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB98C0613EC; Mon, 4 Oct 2021 07:09:18 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id a73so13709617pge.0; Mon, 04 Oct 2021 07:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6pWZxY1yQdsUwMEG6Is0voI7d8xdXhwobuZZscOdeBw=; b=Js7Xodu0nHhuvSavGENRD7gNVR5pT8HpUmkI/DCIAemabFBiB2j8txmoJi60UN2wz7 SplCKi1ivWiqz5DQU22S3UdHDUHlnjT50HUj57rb6cHL8lv1FIQ+tk0TtBFT/aSdngIM PLPwGvq3+XePTs1Ct0w5u2n7g1U3huhkAl5C2b3msfBXagXusMaGsOqVsqik9AHNCQ/V Uzya6SJ483hXPTgTNhFV9AoCaBADy1Q1hYjvMF2EtTGqPrHPWs+vMD/hzYDrfbM5xY5x eIcH1co5ByBIMW8+kZJkl1tpY+QoDvdpmB9lycLskfFBmiAAzj1W8URYEw5OfPRpcsIM qvIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6pWZxY1yQdsUwMEG6Is0voI7d8xdXhwobuZZscOdeBw=; b=h5cyBmbdV051zQIctqLytUE1FpMdvPPZBTYapgWroinjcRTGb4xPloNICG6FaxomnO q2CaII1Mpt38AAwaXy/6Sw/btwUGNLuoAtQyKilFuT+Jqm4nDbxVly/NQTJmqFj6sWjq HFzPS43N49vYtyQYddbHazoKiJDWo8Pq5AL/Kdo2A0/XTAw9UKKvdQ4fXVhJcfNCiFfK ZCr24HK/Br8rRxCW3+aBeSmaa8taxjVcAlb8DJmiJbiZ1GKCUo+T0nmBKKNlKrCjUICw A/wa4r1DCi/WAX1FcLOhCm8mliHtw1XMWZ8FXAGyUduiHe5OuA+yX4MhTB7otjrHc8kO CeMg== X-Gm-Message-State: AOAM533w/2tZA+1ClXtvlEGJb1x0TAzDzMM8TDeghvUnCBF2XIWMuiIg Ew/D4dRyBxpp2ScWFkaRPDE= X-Google-Smtp-Source: ABdhPJxnSXAXJi5hIp0lOUtzf1x/yRQWj+SNX87vbBVD0ZjCAXsG4FzalqJCMIQUHnpIX3Je5Wswcw== X-Received: by 2002:a63:a112:: with SMTP id b18mr11069605pgf.387.1633356557863; Mon, 04 Oct 2021 07:09:17 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:e8f0:c2a7:3579:5fe8:31d9]) by smtp.gmail.com with ESMTPSA id p2sm15274135pgd.84.2021.10.04.07.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:09:17 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH 8/8] PCI/AER: Include DEVCTL in aer_print_error() Date: Mon, 4 Oct 2021 19:36:34 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Print the contents of Device Control Register of the device which detected the error. This might help in faster error diagnosis. Sample output from dummy error injected by aer-inject: pcieport 0000:00:03.0: AER: Corrected error received: 0000:00:03.0 pcieport 0000:00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, (Receiver) pcieport 0000:00:03.0: device [1b36:000c] error status/mask=00000040/0000e000, devctl=0x000f pcieport 0000:00:03.0: [ 6] BadTLP Signed-off-by: Naveen Naidu --- drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aer.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index eb88d8bfeaf7..48ed7f91113b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -437,6 +437,8 @@ struct aer_err_info { u32 status; /* COR/UNCOR Error Status */ u32 mask; /* COR/UNCOR Error Mask */ struct aer_header_log_regs tlp; /* TLP Header */ + + u16 devctl; }; /* Preliminary AER error information processed from Root port */ diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 91f91d6ab052..42cae01b6887 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -729,8 +729,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) aer_error_severity_string[info->severity], aer_error_layer[layer], aer_agent_string[agent]); - pci_printk(level, dev, " device [%04x:%04x] error status/mask=%08x/%08x\n", - dev->vendor, dev->device, info->status, info->mask); + pci_printk(level, dev, " device [%04x:%04x] error status/mask=%08x/%08x, devctl=%#06x\n", + dev->vendor, dev->device, info->status, info->mask, info->devctl); __aer_print_error(dev, info); @@ -1083,6 +1083,12 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) if (!aer) return 0; + /* + * Cache the value of Device Control Register now, because later the + * device might not be available + */ + pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &info->devctl); + if (info->severity == AER_CORRECTABLE) { pci_read_config_dword(dev, aer + PCI_ERR_COR_STATUS, &info->status);