From patchwork Fri Sep 16 20:06:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9336615 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F288A6089F for ; Fri, 16 Sep 2016 20:07:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35FA2A096 for ; Fri, 16 Sep 2016 20:07:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDDAE2A091; Fri, 16 Sep 2016 20:07:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C09C2A091 for ; Fri, 16 Sep 2016 20:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965507AbcIPUHD (ORCPT ); Fri, 16 Sep 2016 16:07:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:46789 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965171AbcIPUGw (ORCPT ); Fri, 16 Sep 2016 16:06:52 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B97E461701; Fri, 16 Sep 2016 20:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1474056411; bh=7iiOQE0FjuT2J0dqdfo5wiZVm2VxNH8V15b85vx01Y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jy+uFh8ZVWPAtZ2FBRTAdO3HsN5VVZxRr4HHAEb5Rp4WEcLC/WX5vJTnoZh6ER8tH oUvm9n/qaHpznpl2jk563O1tg11WegsUm8/TrDjFZiNolxhcrfyCb1Ucmb99qjx9li 3A+MUtUCK5sxQydyvMWD4y2PEIso4ZDRWEX0ODxk= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2909F61800; Fri, 16 Sep 2016 20:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1474056411; bh=7iiOQE0FjuT2J0dqdfo5wiZVm2VxNH8V15b85vx01Y0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jy+uFh8ZVWPAtZ2FBRTAdO3HsN5VVZxRr4HHAEb5Rp4WEcLC/WX5vJTnoZh6ER8tH oUvm9n/qaHpznpl2jk563O1tg11WegsUm8/TrDjFZiNolxhcrfyCb1Ucmb99qjx9li 3A+MUtUCK5sxQydyvMWD4y2PEIso4ZDRWEX0ODxk= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 2909F61800 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org, cov@codeaurora.org, alex.williamson@redhat.com, vikrams@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , linux-kernel@vger.kernel.org Subject: [PATCH V2 4/5] PCI: add CRS support to error handling path Date: Fri, 16 Sep 2016 16:06:33 -0400 Message-Id: <1474056395-21843-5-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1474056395-21843-1-git-send-email-okaya@codeaurora.org> References: <1474056395-21843-1-git-send-email-okaya@codeaurora.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The PCIE spec allows an endpoint device to extend the initialization time beyond 1 second by issuing Configuration Request Retry Status (CRS) for a vendor ID read request. This basically means "I'm busy now, please call me back later". There are two moving parts to CRS support from the SW perspective. One part is to determine if CRS is supported or not. The second part is to set the CRS visibility register. As part of the probe, the Linux kernel sets the above two conditions in pci_enable_crs function. The kernel is also honoring the returned CRS in pci_bus_read_dev_vendor_id function if supported. The function will poll up to specified amount of time while endpoint is returning CRS response. The PCIe spec also allows CRS to be issued during cold, warm, hot and FLR resets. The hot reset is initiated by starting a secondary bus reset. This patch is adding vendor ID read immediately after a bus reset so that the initialization procedure can be extended by the amount of time endpoint requires. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8aecab1..e913467 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3833,6 +3833,16 @@ static int pci_pm_reset(struct pci_dev *dev, int probe) return 0; } +static int pci_dev_probe_crs(struct pci_dev *dev, void *data) +{ + u32 l; + + pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &l, + 60 * 1000); + + return 0; +} + void pci_reset_secondary_bus(struct pci_dev *dev) { u16 ctrl; @@ -3874,6 +3884,7 @@ void __weak pcibios_reset_secondary_bus(struct pci_dev *dev) void pci_reset_bridge_secondary_bus(struct pci_dev *dev) { pcibios_reset_secondary_bus(dev); + pci_walk_bus(dev->subordinate, pci_dev_probe_crs, NULL); } EXPORT_SYMBOL_GPL(pci_reset_bridge_secondary_bus);