From patchwork Mon Mar 31 23:51:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 3918171 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECED69F1E1 for ; Mon, 31 Mar 2014 23:51:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD571203B4 for ; Mon, 31 Mar 2014 23:51:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3AB3201C8 for ; Mon, 31 Mar 2014 23:51:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751508AbaCaXv4 (ORCPT ); Mon, 31 Mar 2014 19:51:56 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:42365 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751439AbaCaXvz (ORCPT ); Mon, 31 Mar 2014 19:51:55 -0400 Received: by mail-pa0-f52.google.com with SMTP id rd3so8997265pab.11 for ; Mon, 31 Mar 2014 16:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=FQRX/owvIIKf1wZMchC0Jr8hbpsPtWkwg93uOMrd9Ek=; b=Vk5jMQ9hr9nvbFP3/Ee+ej20UddBtkkqnfaYMiwteQx3PIyrYEVWy0XjU7NSOHknKh geqxsAYmErowvy/jQeONSx99EXPFdiHftXfAQY6T4/MFHeWqnftlvgWQDwhoFHSjYFYm ENPasKa7xHQB+NBVMTCWbKAycl+WgC4AH2nbHgSRMWQAq27J8AMVG3YxfrhTAm32gMx0 3pRk0LCattpEWY/JDZiK53aA3s2r+dGa/QCIigvza22A7EIHIYtq4IjUd2f0NFEKPhSj 6gE0nfRFSIjZs15lMZKdWsLf/nKy0+xoE/VQpKD9zEeV42dcQ4EEa7Li6ZFAC629WAnt ahpw== X-Received: by 10.66.226.145 with SMTP id rs17mr6351551pac.144.1396309914953; Mon, 31 Mar 2014 16:51:54 -0700 (PDT) Received: from [192.168.95.129] ([66.129.239.13]) by mx.google.com with ESMTPSA id xk3sm45832683pbb.65.2014.03.31.16.51.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 31 Mar 2014 16:51:54 -0700 (PDT) Message-ID: <5339FF99.2050200@gmail.com> Date: Mon, 31 Mar 2014 16:51:53 -0700 From: Rajat Jain User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org CC: Rajat Jain , Guenter Roeck Subject: [PATCH] pci/pciehp: Allow polling/irq mode to be decided on a per-port basis Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Today, there is a global pciehp_poll_mode module parameter using which either _all_ the hot-pluggable ports are to use polling, or _all_ the ports are to use interrupts. In a system where a certain port has IRQ issues, today the only option is to use the parameter that converts ALL the ports to use polling mode. This is not good, and hence this patch intruduces a bit field that can be set using a PCI quirk that indicates that polling should always be used for this particular PCIe port. The remaining ports can still hoose to continue to operate in whatever mode they wish to. Signed-off-by: Rajat Jain Signed-off-by: Rajat Jain Signed-off-by: Guenter Roeck --- drivers/pci/hotplug/pciehp.h | 1 + drivers/pci/hotplug/pciehp_hpc.c | 16 ++++++++++------ include/linux/pci.h | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index d208791..753a3b4 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -98,6 +98,7 @@ struct controller { unsigned int no_cmd_complete:1; unsigned int link_active_reporting:1; unsigned int notification_enabled:1; + unsigned int use_polling:1; /* Always uses polling for this slot */ unsigned int power_fault_detected; }; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index d7d058f..d210d23 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -82,7 +82,7 @@ static inline int pciehp_request_irq(struct controller *ctrl) int retval, irq = ctrl->pcie->irq; /* Install interrupt polling timer. Start with 10 sec delay */ - if (pciehp_poll_mode) { + if (ctrl->use_polling) { init_timer(&ctrl->poll_timer); start_int_poll_timer(ctrl, 10); return 0; @@ -98,7 +98,7 @@ static inline int pciehp_request_irq(struct controller *ctrl) static inline void pciehp_free_irq(struct controller *ctrl) { - if (pciehp_poll_mode) + if (ctrl->use_polling) del_timer_sync(&ctrl->poll_timer); else free_irq(ctrl->pcie->irq, ctrl); @@ -131,7 +131,7 @@ static int pcie_poll_cmd(struct controller *ctrl) static void pcie_wait_cmd(struct controller *ctrl, int poll) { - unsigned int msecs = pciehp_poll_mode ? 2500 : 1000; + unsigned int msecs = ctrl->use_polling ? 2500 : 1000; unsigned long timeout = msecs_to_jiffies(msecs); int rc; @@ -595,7 +595,7 @@ void pcie_enable_notification(struct controller *ctrl) cmd |= PCI_EXP_SLTCTL_PDCE; if (MRL_SENS(ctrl)) cmd |= PCI_EXP_SLTCTL_MRLSCE; - if (!pciehp_poll_mode) + if (!ctrl->use_polling) cmd |= PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE; mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE | @@ -642,14 +642,14 @@ int pciehp_reset_slot(struct slot *slot, int probe) stat_mask |= PCI_EXP_SLTSTA_DLLSC; pcie_write_cmd(ctrl, 0, ctrl_mask); - if (pciehp_poll_mode) + if (ctrl->use_polling) del_timer_sync(&ctrl->poll_timer); pci_reset_bridge_secondary_bus(ctrl->pcie->port); pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); pcie_write_cmd(ctrl, ctrl_mask, ctrl_mask); - if (pciehp_poll_mode) + if (ctrl->use_polling) int_poll_timeout(ctrl->poll_timer.data); return 0; @@ -789,6 +789,10 @@ struct controller *pcie_init(struct pcie_device *dev) ctrl_dbg(ctrl, "Link Active Reporting supported\n"); ctrl->link_active_reporting = 1; } + if (pciehp_poll_mode || dev->port->hotplug_polling) { + ctrl_info(ctrl, "will use polling\n"); + ctrl->use_polling = 1; + } /* Clear all remaining event bits in Slot Status register */ pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, diff --git a/include/linux/pci.h b/include/linux/pci.h index a13d682..b2ec72e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -336,6 +336,7 @@ struct pci_dev { unsigned int is_virtfn:1; unsigned int reset_fn:1; unsigned int is_hotplug_bridge:1; + unsigned int hotplug_polling:1; /* Port uses polling for hotplug */ unsigned int __aer_firmware_first_valid:1; unsigned int __aer_firmware_first:1; unsigned int broken_intx_masking:1;