From patchwork Sat Jun 14 21:21:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4353551 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 897B1BEEAA for ; Sat, 14 Jun 2014 21:21:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA0B62020E for ; Sat, 14 Jun 2014 21:21:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 824DF20219 for ; Sat, 14 Jun 2014 21:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753425AbaFNVVW (ORCPT ); Sat, 14 Jun 2014 17:21:22 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:61983 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753034AbaFNVVV (ORCPT ); Sat, 14 Jun 2014 17:21:21 -0400 Received: by mail-ie0-f170.google.com with SMTP id tr6so3688188ieb.29 for ; Sat, 14 Jun 2014 14:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=GAzDTdAdilXFLbj44Qb4ep15ndLO1LqcJMsyL+9uyb8=; b=j4L+lDzehpqiEXFxlaMtetAgy6kYvxRt7j+1GT/xYpRqbHYcC0U/EQT5yYwvX2PKSc kAJtlr5p6UGr3sfprAtHGnBSbmDRZjEvZw+VPPIjsTiFv4A837eWjRBAkkbL6BjZq90w B9EusXb4WvkdSrqUBvLQsSFDVmvtJTR+X+ESmD8OCwypOoO2iWavlvmowKLT9V2nvT8R t5jm923O8OeDUoo+qDtCkhWpekS3BYwE2BcLLjvcYXQr+zsSdXtppJYVvpfDmhtnWSQT jWUZAKDj8JOSMTz57zfsx1H4rvbfoYq00uwk3YOuk2CZMFz54prz0XkHaOBMmdTHO4Qx ojag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=GAzDTdAdilXFLbj44Qb4ep15ndLO1LqcJMsyL+9uyb8=; b=TQMu4ISzSgdkP0CbU3cvMxDDYbRzQeUgREeAoIFNuS2BIyL7oX6rlQmbWlAlIzhHr5 maA7folldsl07pxBAdXLU3SB3XyrDPsmiY+MnxZRPpxb9ksj7DIHQ/xt2zc9rYiLmv/7 6fIBwLADHpQmNN9tic8zaXmSUmJ1JlJqehcPypr04S8TAxS5YX4f04VbM/t7z3F1Wv7w pszL+w8c3Ss3d2Nleh2ahBXtseWu+9NSKzVs5I/tBIDIiqGlqvvKTZswSdH0SsWjOj6o MqDLHLuH+hAdIAmLUTZxekeFLG63Uoh1jMvtGoJ87YedVum9onV0g7zKpOav20RwmF8P 2gbw== X-Gm-Message-State: ALoCoQljSdR4b7WflFFR2e8s1RDnuvkb4WnHtTPZoqb89eFFx32LcHFLB6aL4+DWNT9Oo6DRPf70 X-Received: by 10.50.4.5 with SMTP id g5mr14879053igg.14.1402780880682; Sat, 14 Jun 2014 14:21:20 -0700 (PDT) Received: from localhost ([172.16.51.103]) by mx.google.com with ESMTPSA id v9sm6635988igd.14.2014.06.14.14.21.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 14 Jun 2014 14:21:20 -0700 (PDT) Subject: [PATCH RFC 1/4] PCI: pciehp: Make pcie_wait_cmd() self-contained To: Yinghai Lu From: Bjorn Helgaas Cc: "Jan C. Nordholz" , Kenji Kaneshige , Rajat Jain , linux-pci@vger.kernel.org Date: Sat, 14 Jun 2014 15:21:20 -0600 Message-ID: <20140614212120.15202.61424.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20140614210740.15202.84719.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20140614210740.15202.84719.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 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, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 pcie_wait_cmd() waits for the controller to finish a hotplug command. Move the associated logic (to determine whether waiting is required and whether we're using interrupts or polling) from pcie_write_cmd() to pcie_wait_cmd(). No functional change. Signed-off-by: Bjorn Helgaas --- drivers/pci/hotplug/pciehp.h | 1 + drivers/pci/hotplug/pciehp_hpc.c | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" 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/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 8e9012dca450..f7bc886c20be 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -92,6 +92,7 @@ struct controller { struct slot *slot; wait_queue_head_t queue; /* sleep & wake process */ u32 slot_cap; + u32 slot_ctrl; struct timer_list poll_timer; unsigned int cmd_busy:1; unsigned int no_cmd_complete:1; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 056841651a80..0e76e9d9d134 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -129,16 +129,24 @@ static int pcie_poll_cmd(struct controller *ctrl) return 0; /* timeout */ } -static void pcie_wait_cmd(struct controller *ctrl, int poll) +static void pcie_wait_cmd(struct controller *ctrl) { unsigned int msecs = pciehp_poll_mode ? 2500 : 1000; unsigned long timeout = msecs_to_jiffies(msecs); int rc; - if (poll) - rc = pcie_poll_cmd(ctrl); - else + /* + * If the controller does not generate notifications for command + * completions, we never need to wait between writes. + */ + if (ctrl->no_cmd_complete) + return; + + if (ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE && + ctrl->slot_ctrl & PCI_EXP_SLTCTL_CCIE) rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout); + else + rc = pcie_poll_cmd(ctrl); if (!rc) ctrl_dbg(ctrl, "Command not completed in 1000 msec\n"); } @@ -187,22 +195,12 @@ static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) ctrl->cmd_busy = 1; smp_mb(); pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, slot_ctrl); + ctrl->slot_ctrl = slot_ctrl; /* * Wait for command completion. */ - if (!ctrl->no_cmd_complete) { - int poll = 0; - /* - * if hotplug interrupt is not enabled or command - * completed interrupt is not enabled, we need to poll - * command completed event. - */ - if (!(slot_ctrl & PCI_EXP_SLTCTL_HPIE) || - !(slot_ctrl & PCI_EXP_SLTCTL_CCIE)) - poll = 1; - pcie_wait_cmd(ctrl, poll); - } + pcie_wait_cmd(ctrl); mutex_unlock(&ctrl->ctrl_lock); }