From patchwork Thu May 30 14:39:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Betty Dall X-Patchwork-Id: 2637061 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 16A2440276 for ; Thu, 30 May 2013 14:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933302Ab3E3OqY (ORCPT ); Thu, 30 May 2013 10:46:24 -0400 Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:3490 "EHLO g5t0008.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933252Ab3E3OqT (ORCPT ); Thu, 30 May 2013 10:46:19 -0400 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0008.atlanta.hp.com (Postfix) with ESMTP id A68C52444E; Thu, 30 May 2013 14:46:18 +0000 (UTC) Received: from linux1.fc.hp.com (linux1.fc.hp.com [16.71.12.34]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 235FE1469F; Thu, 30 May 2013 14:46:18 +0000 (UTC) From: Betty Dall To: rjw@sisk.pl, bhelgaas@google.com Cc: ying.huang@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Betty Dall Subject: [PATCH v2 3/3] PCI/AER: Provide reset_link for firmware first root port Date: Thu, 30 May 2013 08:39:29 -0600 Message-Id: <1369924769-17183-4-git-send-email-betty.dall@hp.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1369924769-17183-1-git-send-email-betty.dall@hp.com> References: <1369924769-17183-1-git-send-email-betty.dall@hp.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The firmware first path does not install the aerdrv root port service driver, so the firmware first root port does not have a reset_link callback. When a firmware first root port does not have a reset_link callback, use a new default reset_link similar to what we already do for the default_downstream_reset_link(). The firmware first default reset_link brings the root port out of SBR if firmware left it in SBR. Changes since v1: Removed incorrect setting of p2p_ctrl after the read. Signed-off-by: Betty Dall --- drivers/pci/pcie/aer/aerdrv_core.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 8ec8b4f..72f76cd 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c @@ -413,6 +413,39 @@ static pci_ers_result_t default_downstream_reset_link(struct pci_dev *dev) return PCI_ERS_RESULT_RECOVERED; } +/** + * default_ff_root_port_reset_link - default reset function for firmware + * first Root Port + * @dev: pointer to root port's pci_dev data structure + * + * Invoked when performing link reset at Root Port w/ no aer driver. + * This happens through the firmware first path. Firmware may leave + * the Root Port in SBR and it is the OS responsiblity to bring it out + * of SBR. + */ +static pci_ers_result_t default_ff_root_port_reset_link(struct pci_dev *dev) +{ + u16 p2p_ctrl; + + /* Read Secondary Bus Reset */ + pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &p2p_ctrl); + + /* De-assert Secondary Bus Reset, if it is set */ + if (p2p_ctrl & PCI_BRIDGE_CTL_BUS_RESET) { + p2p_ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET; + pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); + + /* + * System software must wait for at least 100ms from the end + * of a reset of one or more device before it is permitted + * to issue Configuration Requests to those devices. + */ + msleep(200); + dev_dbg(&dev->dev, "Root Port link has been reset\n"); + } + return PCI_ERS_RESULT_RECOVERED; +} + static int find_aer_service_iter(struct device *device, void *data) { struct pcie_port_service_driver *service_driver, **drv; @@ -460,6 +493,9 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) status = driver->reset_link(udev); } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) { status = default_downstream_reset_link(udev); + } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_ROOT_PORT && + pcie_aer_get_firmware_first(udev)) { + status = default_ff_root_port_reset_link(udev); } else { dev_printk(KERN_DEBUG, &dev->dev, "no link-reset support at upstream device %s\n",