From patchwork Mon Jul 2 22:52:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10502609 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 41DCC60284 for ; Mon, 2 Jul 2018 22:53:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3069F28BE1 for ; Mon, 2 Jul 2018 22:53:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23A9028BF1; Mon, 2 Jul 2018 22:53:59 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B649D28BE1 for ; Mon, 2 Jul 2018 22:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dODOX6hVMgIgRwuLxEQbGWQGkDoBBLgnFmSFV2ojwdA=; b=QHnG5J3k9Om9Do beeQEQ1Y9rbgTX86kdorTwpDejeSWs7yugZm/gIkDeHWK0FKJr97GKQR2zgK/0CQPrc3ERlMES1tV M29QLpIcMF8Rdq+Pvv4SOUy0B/Bw0aPwT1cVcdZQxmEYf2gt73k5Ua2En14Nwrvhhlp/TjFwb0q4L uBTi615WjwrHYrAjzLAkk4hvxfwk7h4A/Sz6Orh47E+a9+szC7Sje3srKK2EvPJi5ojc0GYbCCBsR n9V/BFEvJmihPu+ccCSjxrGo1mCwcKReIL3vKqcvSXbK+e6tTLdYTjIKCby0Tv6alzPW4+v5j3Itg /5m99o0GyolGj+BEFspQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fa7hf-0004gt-6U; Mon, 02 Jul 2018 22:53:51 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fa7h5-00049m-5S for linux-arm-kernel@lists.infradead.org; Mon, 02 Jul 2018 22:53:22 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D397760B3C; Mon, 2 Jul 2018 22:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530571984; bh=RTtqANtiw+9us5A2G10gOXKgoQLMAb4TTs2B1EkUJ24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzi0AWIuoJeQN3lXD5MomIf2mUq1TeeTWVjmv89TA0sNLEqLTX7czpEdKUbncX6t9 Y5biYJ/WR189DXuYD5gm9jPaacPK8G3fv48pmnDuuTbM+CYwCweZX4t6SD6SqPJ836 rWN5C/90+61x3oOwdRrFuJQzWY6OdQ2NtQkAImrs= 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 0221D60B13; Mon, 2 Jul 2018 22:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530571983; bh=RTtqANtiw+9us5A2G10gOXKgoQLMAb4TTs2B1EkUJ24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KT/FICQdgI1746yD3ZN3nIujf/PDGlD+jc9TDjqjnvkNDhPuG3/41EcHXwAFr76hW iVpXxnZ21G+dS3f/kRA/x6M3sG2u61ILnSR2NGM2JhxHj27n2LCyxsIU8wqTT3gBnQ 8np8auVShN4aiWzaHFrttjzJgmDeLWbIGdpPc7XE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0221D60B13 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org Subject: [PATCH V5 1/3] PCI: pciehp: implement mask and unmask interrupt functions Date: Mon, 2 Jul 2018 18:52:45 -0400 Message-Id: <1530571967-19099-2-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530571967-19099-1-git-send-email-okaya@codeaurora.org> References: <1530571967-19099-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180702_155315_913940_DBDF866D X-CRM114-Status: GOOD ( 13.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Oza Pawandeep , Kees Cook , Frederick Lawler , linux-arm-msm@vger.kernel.org, "Rafael J. Wysocki" , open list , Sinan Kaya , Lukas Wunner , Greg Kroah-Hartman , Bjorn Helgaas , Andy Shevchenko , Mika Westerberg , Markus Elfring , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Adding pciehp_mask_irq() and pciehp_unmask_irq() to be called from struct pcie_device as mask_irq() and unmask_irq() callbacks. Signed-off-by: Sinan Kaya --- drivers/pci/hotplug/pciehp.h | 2 ++ drivers/pci/hotplug/pciehp_core.c | 19 +++++++++++++++++++ drivers/pci/hotplug/pciehp_hpc.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/pci/pcie/portdrv.h | 2 ++ 4 files changed, 62 insertions(+) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 5f89206..c579d03 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -138,6 +138,8 @@ int pciehp_check_link_status(struct controller *ctrl); bool pciehp_check_link_active(struct controller *ctrl); void pciehp_release_ctrl(struct controller *ctrl); int pciehp_reset_slot(struct slot *slot, int probe); +void pciehp_mask_irq(struct slot *slot); +void pciehp_unmask_irq(struct slot *slot); int pciehp_set_raw_indicator_status(struct hotplug_slot *h_slot, u8 status); int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status); diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 44a6a63..ca2faa1 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -299,6 +299,22 @@ static int pciehp_resume(struct pcie_device *dev) } #endif /* PM */ +static void pciehp_mask_int(struct pcie_device *dev) +{ + struct controller *ctrl = get_service_data(dev); + struct slot *slot = ctrl->slot; + + pciehp_mask_irq(slot); +} + +static void pciehp_unmask_int(struct pcie_device *dev) +{ + struct controller *ctrl = get_service_data(dev); + struct slot *slot = ctrl->slot; + + pciehp_unmask_irq(slot); +} + static struct pcie_port_service_driver hpdriver_portdrv = { .name = PCIE_MODULE_NAME, .port_type = PCIE_ANY_PORT, @@ -311,6 +327,9 @@ static struct pcie_port_service_driver hpdriver_portdrv = { .suspend = pciehp_suspend, .resume = pciehp_resume, #endif /* PM */ + + .mask_irq = pciehp_mask_int, + .unmask_irq = pciehp_unmask_int, }; static int __init pcied_init(void) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 8dae232..d44e2c6 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -757,6 +757,45 @@ int pciehp_reset_slot(struct slot *slot, int probe) return rc; } +void pciehp_mask_irq(struct slot *slot) +{ + struct controller *ctrl = slot->ctrl; + u16 ctrl_mask = 0; + + if (!ATTN_BUTTN(ctrl)) + ctrl_mask |= PCI_EXP_SLTCTL_PDCE; + + ctrl_mask |= PCI_EXP_SLTCTL_DLLSCE; + + pcie_write_cmd(ctrl, 0, ctrl_mask); + ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, + pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, 0); + if (pciehp_poll_mode) + del_timer_sync(&ctrl->poll_timer); +} + +void pciehp_unmask_irq(struct slot *slot) +{ + struct controller *ctrl = slot->ctrl; + struct pci_dev *pdev = ctrl_dev(ctrl); + u16 stat_mask = 0, ctrl_mask = 0; + + if (!ATTN_BUTTN(ctrl)) { + ctrl_mask |= PCI_EXP_SLTCTL_PDCE; + stat_mask |= PCI_EXP_SLTSTA_PDC; + } + ctrl_mask |= PCI_EXP_SLTCTL_DLLSCE; + stat_mask |= PCI_EXP_SLTSTA_DLLSC; + + pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); + pcie_write_cmd_nowait(ctrl, ctrl_mask, ctrl_mask); + ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, + pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, ctrl_mask); + if (pciehp_poll_mode) + int_poll_timeout(&ctrl->poll_timer); +} + + int pcie_init_notification(struct controller *ctrl) { if (pciehp_request_irq(ctrl)) diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index 6ffc797..40bb6f2 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -51,6 +51,8 @@ struct pcie_port_service_driver { void (*remove) (struct pcie_device *dev); int (*suspend) (struct pcie_device *dev); int (*resume) (struct pcie_device *dev); + void (*mask_irq)(struct pcie_device *dev); + void (*unmask_irq)(struct pcie_device *dev); /* Device driver may resume normal operations */ void (*error_resume)(struct pci_dev *dev);