Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1078033rdg; Wed, 11 Oct 2023 13:52:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLkTcy/ZY8ZBobikDL6DuPRgdjq4xHqeE02FohOirZ/8XF73s3JefSkoZXgk8yG5ycLaYA X-Received: by 2002:a05:6e02:1bc9:b0:34f:a4c5:8e78 with SMTP id x9-20020a056e021bc900b0034fa4c58e78mr28073934ilv.6.1697057534440; Wed, 11 Oct 2023 13:52:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697057534; cv=pass; d=google.com; s=arc-20160816; b=RP6z3RPpRKXjL1qHpogfhdtG8EavU0a/7EaSSNY2enJYRTeLlsAiZWhbuSuKhol7u/ nNobiiBrTur57tPBHJNx+9gE+ou0cSNp5AvO2xu8kRUNOt1JMtkcekHCvo4/GfGDdpuZ yfezr87ZC95PlbVXh/WNHTlSDgAjKfuYEomknsWBEM/iG8IH2k42LPz9TvDtHPx2wX7+ Zhjiha0RuhLTxJ1bUfNPbagYHOl39hEOCcfQgvIfOFuP+hYXyb88zNWz3mUgyecq2O7I faxihBaQIDLGzPN12bWqpukGLL5Q/71V5+ZORE2IjU7CytqnB2hXyLYU2eVmzKHGXezo EswA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=ytiJJg11YjqLRqMEb5V5MR+9QTrVIPjOKW8DjfmymA8=; fh=TtkEd8jeG+KPxYiRLKlAQGAR1TeHKe96uLLrUFduGd8=; b=NOHlGzDk70C238LpevdZhEesRX/UDkx2k0YagDFSeUm8Wh6JQ0dqW3W7Jw/2UO0gJ5 i3kiWBX+mABrb1EX7eGg1rrU5bOdunGcr8jo9pKmE+q7udq5X1uT+C9vOGA/371QiJlk aOZv6Mflh+hGkzLWuHCwxPJQQh8TJNqp4cVp8dNPHekPO3pyHHzcWZAy0c0e44IvKH35 YtkVV4R0BIAYzWp5OPyKctUgeA3HeexmaOu3PEaMSo2xF36ANFkqpebkITV0VuE/t8HZ ES0ydQxfIetPyqDUJNave+IRBduWHp7vAoROuuWws3XSp0+B2gTGD95l1s2NCsPD5kFa lVfg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=sgErhysu; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x5-20020a654145000000b0059b71fb1472si550230pgp.39.2023.10.11.13.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:52:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=sgErhysu; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BA354807D8C9; Wed, 11 Oct 2023 13:52:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233588AbjJKUv5 (ORCPT + 99 others); Wed, 11 Oct 2023 16:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233550AbjJKUv4 (ORCPT ); Wed, 11 Oct 2023 16:51:56 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E4B93; Wed, 11 Oct 2023 13:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PGm5EsoIda8/yCySyJ+qy+EWUIKGa0VcFYKkNZ0orcshBXgPYdvMO3y8o2L9PtsdUvCZMgySQN8hvxbsn3+V7gRi5ilP54r+GQJTMKKjIM2FXo7XWmci5bKfmfbmT7YMvqeGTFwB4Dkvbzijca37tBrFcg/aCVbFTfUk/Z6EssF73wL2HVzjSln0yER1D62NdUw/p6DmcLiMtsBA7ekFLUhn3HJSbOzuwxTnXVFjrE8YkvhNovklEvg4LNspeCnxkz9Lqkqv8ZrEUoH3DbM4Ose5L2ZTXGp8yemmCJypAHGGt5gQts9r6GPp4iIq4EGat0BoTNOe5oyKIclED4DIeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ytiJJg11YjqLRqMEb5V5MR+9QTrVIPjOKW8DjfmymA8=; b=FVnpVvvCMlia7M8ckXUAbebluNgNCfPW5KDUmsvQbc46lUucmQ26540y66LYR0NJ6sOah7vjdRrigW4/G1CbMRiQjq7hjmZ4O2HYfnlEUdUuoEXQpJ8QpMFgdTgSf5YuihxOJGATgTKMamy330NmFh4U6Mqx3Rf294WqqjX+mdNqB5smJtjE3h7/7SGEQbHnqp6QfKY+qVz8ZI7Z//mSLkLqjnu+qpTGgC8HmIXNeOS3wHKzIK41Mxp/AYHCpmRD7M2D7ISv4moVmBubdiCz3gC1h9VICLjx0YROg8p5IUbPkpp5lAz3xZSLig1nJuMhUqEZt1YVu/Nm4IxI8H65TA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ytiJJg11YjqLRqMEb5V5MR+9QTrVIPjOKW8DjfmymA8=; b=sgErhysu9GqMBTUfdZSt+i+eWH3YLy17zyNP8pthGUneDKeZSTHyI8frvac7j1CAUGDUplZ8WZ0dMBFfYYZEXPRFogoFfTXaQvcBfiXeqsFNr/T1kewu9kO4N4eTo15vMJvDr5ObaDgtlaLnGCmshd+VkDGfJXxkbGEv52IhfIM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB2869.namprd12.prod.outlook.com (2603:10b6:a03:132::30) by IA1PR12MB6212.namprd12.prod.outlook.com (2603:10b6:208:3e4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Wed, 11 Oct 2023 20:51:48 +0000 Received: from BYAPR12MB2869.namprd12.prod.outlook.com ([fe80::2709:2c34:f842:ce33]) by BYAPR12MB2869.namprd12.prod.outlook.com ([fe80::2709:2c34:f842:ce33%5]) with mapi id 15.20.6838.028; Wed, 11 Oct 2023 20:51:48 +0000 Message-ID: Date: Wed, 11 Oct 2023 13:51:45 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v5] PCI/DPC: Ignore Surprise Down error on hot removal Content-Language: en-US To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bjorn Helgaas , Mahesh J Salgaonkar , Lukas Wunner , Kuppuswamy Sathyanarayanan , Yazen Ghannam References: <20231011204554.120574-1-Smita.KoralahalliChannabasappa@amd.com> From: Smita Koralahalli In-Reply-To: <20231011204554.120574-1-Smita.KoralahalliChannabasappa@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PH8PR02CA0010.namprd02.prod.outlook.com (2603:10b6:510:2d0::21) To BYAPR12MB2869.namprd12.prod.outlook.com (2603:10b6:a03:132::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2869:EE_|IA1PR12MB6212:EE_ X-MS-Office365-Filtering-Correlation-Id: 519b41d6-d2d0-4b8b-dc9f-08dbca9be32d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G5vauevA2jOv1lLWZ1bl5Ij5mfWxpYn8eO58WDvDL/g2Y+XNw7zvK7N36ZEutH9PlnUqDBsyYCU/YVOEjeWf/3oUyS08b//8SHEcmDplipSo76WHjUIdmtD5RdGmwIUdNW/mLTBrvDydSMUJ2gY5ODTUd5J/UUAzlvtniNDh5l73HP8FEcgISMOA+e1aVNPk5sdoVRhJ+dgKQxj+eONXrWwdte9GycVX1H0627PAeslCBBu+GYcq23nvMh9XCXw/1FRttJJA21o0sgUOL8NhHNNifM0DW6R/ge+xCuXPaf9B2AyrRHZ5EQCxSREitLC4uK0OfGFSgPRrle8Zeu2RFr6cH/ZXuPqTtnHbOUUuhM/Xo2aiCiip6hFwS/36RIXxBqGvwuFLjbqX5/KX/+ZHOr2l7IScYgd5dlUOwlVacIM/2GWEpjf2IpEYnG91yzeqBj3WVYq1CSAPN8YtG7fRRRpRcgrN5eHew9zD9zmF2/6382LwFyhFbJujTK6eeF02XPnYGAc5ZNZpcenWMF5qCGHTjY1qiWL61bww+JL4yLPHqK8uV5QsUQg+NuDWkHXaNeqi076cKjO69KvUnBNTVJy34jKsPOfefcOxo59ZJZgJSBnZU9hQUwGoU2wzYZdWP8ru53eZRxifchvRsDNTIg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(39860400002)(376002)(346002)(366004)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6512007)(26005)(6506007)(53546011)(83380400001)(2616005)(31686004)(6666004)(6486002)(966005)(478600001)(36756003)(8936002)(41300700001)(5660300002)(38100700002)(4326008)(31696002)(2906002)(86362001)(8676002)(66476007)(54906003)(66556008)(66946007)(316002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bVRKUlJZNFlUZ084N3VoVjJIRGdESS96UTNBRjRCTkl6ZjJwelJZWXNwZXI5?= =?utf-8?B?TG84K0UxdC9VVGVFSzdJaHRuSjN6TGxDWkgxQmZnWHlkY2E1dXgrTjNXb1hN?= =?utf-8?B?cTZXVG1MeXNNMEFYY2s0aDlrekRxU014NXluWUl6NCtURHZ2M0RYd3BNdlNX?= =?utf-8?B?YTBPSUhiWXNjWFNzU0xZVXN0SmpOVWJ2VEJZOGVQWkNLM0FJQWFtN3ROc0VP?= =?utf-8?B?a1VmVUV4SklENVVzS281UVU1NVNMeWt4bkhpdjlrZ3hvRHBPVk1BNEtLWlZV?= =?utf-8?B?UWovRzlFNkdma0NCZUtveGlrWG5BNkVUclpZQXgvamV4M3FtVzgyamFJckhI?= =?utf-8?B?dTA4a1JHU0xvY3I0RUIxZUt6VjZ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message-Id: 519b41d6-d2d0-4b8b-dc9f-08dbca9be32d X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2023 20:51:48.4889 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DXIKdTrQ/0qErjoZv1ZvUgcCMFcLhz2dEUFPAiDkH6/xlB2ZMdVRWY0BBzTNTRuxTbOMq+y2p+BeTg76pZGK4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6212 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 13:52:11 -0700 (PDT) No code changes, rebased on latest tree to seek Bjorn's attention with $SUBJECT change and "Reviewed-by" tag. Meanwhile I will continue working on 10-bit tag enumeration. Thanks, Smita On 10/11/2023 1:45 PM, Smita Koralahalli wrote: > According to PCIe r6.0 sec 6.7.6 [1], async removal with DPC may result in > surprise down error. This error is expected and is just a side-effect of > async remove. > > Ignore surprise down error generated as a side-effect of async remove. > Typically, this error is benign as the pciehp handler invoked by PDC > or/and DLLSC alongside DPC, de-enumerates and brings down the device > appropriately. But the error messages might confuse users. Get rid of > these irritating log messages with a 1s delay while pciehp waits for > dpc recovery. > > The implementation is as follows: On an async remove a DPC is triggered > along with a Presence Detect State change and/or DLL State Change. > Determine it's an async remove by checking for DPC Trigger Status in DPC > Status Register and Surprise Down Error Status in AER Uncorrected Error > Status to be non-zero. If true, treat the DPC event as a side-effect of > async remove, clear the error status registers and continue with hot-plug > tear down routines. If not, follow the existing routine to handle AER and > DPC errors. > > Please note that, masking Surprise Down Errors was explored as an > alternative approach, but left due to the odd behavior that masking only > avoids the interrupt, but still records an error per PCIe r6.0.1 Section > 6.2.3.2.2. That stale error is going to be reported the next time some > error other than Surprise Down is handled. > > Dmesg before: > > pcieport 0000:00:01.4: DPC: containment event, status:0x1f01 source:0x0000 > pcieport 0000:00:01.4: DPC: unmasked uncorrectable error detected > pcieport 0000:00:01.4: PCIe Bus Error: severity=Uncorrected (Fatal), type=Transaction Layer, (Receiver ID) > pcieport 0000:00:01.4: device [1022:14ab] error status/mask=00000020/04004000 > pcieport 0000:00:01.4: [ 5] SDES (First) > nvme nvme2: frozen state error detected, reset controller > pcieport 0000:00:01.4: DPC: Data Link Layer Link Active not set in 1000 msec > pcieport 0000:00:01.4: AER: subordinate device reset failed > pcieport 0000:00:01.4: AER: device recovery failed > pcieport 0000:00:01.4: pciehp: Slot(16): Link Down > nvme2n1: detected capacity change from 1953525168 to 0 > pci 0000:04:00.0: Removing from iommu group 49 > > Dmesg after: > > pcieport 0000:00:01.4: pciehp: Slot(16): Link Down > nvme1n1: detected capacity change from 1953525168 to 0 > pci 0000:04:00.0: Removing from iommu group 37 > > [1] PCI Express Base Specification Revision 6.0, Dec 16 2021. > https://members.pcisig.com/wg/PCI-SIG/document/16609 > > Signed-off-by: Smita Koralahalli > Reviewed-by: Lukas Wunner > --- > v2: > Indentation is taken care. (Bjorn) > Unrelevant dmesg logs are removed. (Bjorn) > Rephrased commit message, to be clear on native vs FW-First > handling. (Bjorn and Sathyanarayanan) > Prefix changed from pciehp_ to dpc_. (Lukas) > Clearing ARI and AtomicOp Requester are performed as a part of > (de-)enumeration in pciehp_unconfigure_device(). (Lukas) > Changed to clearing all optional capabilities in DEVCTL2. > OS-First -> native. (Sathyanarayanan) > > v3: > Added error message when root port become inactive. > Modified commit description to add more details. > Rearranged code comments and function calls with no functional > change. > Additional check for is_hotplug_bridge. > dpc_completed_waitqueue to wakeup pciehp handler. > Cleared only Fatal error detected in DEVSTA. > > v4: > Made read+write conditional on "if (pdev->dpc_rp_extensions)" > for DPC_RP_PIO_STATUS. > Wrapped to 80 chars. > Code comment for clearing PCI_STATUS and PCI_EXP_DEVSTA. > Added pcie_wait_for_link() check. > Removed error message for root port inactive as the message > already existed. > Check for is_hotplug_bridge before registers read. > Section 6.7.6 of the PCIe Base Spec 6.0 -> PCIe r6.0 sec 6.7.6. > Made code comment more meaningful. > > v5: > $SUBJECT correction. > Added "Reviewed-by" tag. > No code changes. Re-spin on latest base to get Bjorn's > attention. > --- > drivers/pci/pcie/dpc.c | 69 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) > > diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c > index 3ceed8e3de41..25e9ddeeb271 100644 > --- a/drivers/pci/pcie/dpc.c > +++ b/drivers/pci/pcie/dpc.c > @@ -292,10 +292,79 @@ void dpc_process_error(struct pci_dev *pdev) > } > } > > +static void pci_clear_surpdn_errors(struct pci_dev *pdev) > +{ > + u16 reg16; > + u32 reg32; > + > + if (pdev->dpc_rp_extensions) { > + pci_read_config_dword(pdev, pdev->dpc_cap + PCI_EXP_DPC_RP_PIO_STATUS, > + ®32); > + pci_write_config_dword(pdev, pdev->dpc_cap + PCI_EXP_DPC_RP_PIO_STATUS, > + reg32); > + } > + > + /* > + * In practice, Surprise Down errors have been observed to also set > + * error bits in the Status Register as well as the Fatal Error > + * Detected bit in the Device Status Register. > + */ > + pci_read_config_word(pdev, PCI_STATUS, ®16); > + pci_write_config_word(pdev, PCI_STATUS, reg16); > + > + pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, PCI_EXP_DEVSTA_FED); > +} > + > +static void dpc_handle_surprise_removal(struct pci_dev *pdev) > +{ > + if (!pcie_wait_for_link(pdev, false)) { > + pci_info(pdev, "Data Link Layer Link Active not cleared in 1000 msec\n"); > + goto out; > + } > + > + if (pdev->dpc_rp_extensions && dpc_wait_rp_inactive(pdev)) > + goto out; > + > + pci_aer_raw_clear_status(pdev); > + pci_clear_surpdn_errors(pdev); > + > + pci_write_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_STATUS, > + PCI_EXP_DPC_STATUS_TRIGGER); > + > +out: > + clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags); > + wake_up_all(&dpc_completed_waitqueue); > +} > + > +static bool dpc_is_surprise_removal(struct pci_dev *pdev) > +{ > + u16 status; > + > + if (!pdev->is_hotplug_bridge) > + return false; > + > + pci_read_config_word(pdev, pdev->aer_cap + PCI_ERR_UNCOR_STATUS, > + &status); > + > + if (!(status & PCI_ERR_UNC_SURPDN)) > + return false; > + > + return true; > +} > + > static irqreturn_t dpc_handler(int irq, void *context) > { > struct pci_dev *pdev = context; > > + /* > + * According to PCIe r6.0 sec 6.7.6, errors are an expected side effect > + * of async removal and should be ignored by software. > + */ > + if (dpc_is_surprise_removal(pdev)) { > + dpc_handle_surprise_removal(pdev); > + return IRQ_HANDLED; > + } > + > dpc_process_error(pdev); > > /* We configure DPC so it only triggers on ERR_FATAL */