Received: by 10.223.164.221 with SMTP id h29csp139549wrb; Fri, 3 Nov 2017 06:52:47 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qrh5tz11A4i5ifpwnY9+zxd/wJmOeGLUd9Mgn/zQ+Tk88kD9scMq27NM+FdNH9dhqKFwn2 X-Received: by 10.159.195.7 with SMTP id bd7mr6942333plb.366.1509717166946; Fri, 03 Nov 2017 06:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509717166; cv=none; d=google.com; s=arc-20160816; b=ZzH9NBa72YShW20yTs0OFFBtVYAJx219rtZ8GqVPSiPHnM1nHfNS9Lw/UxcCS8gz4z 53uFriO7z/21ZLSNbs9hmgBuAsh38x86560vr5lDNrF5UVNarApfImscBEeGs6Yi2nWo Y5jLyJRYtlIhXWZ+6CUcYI9f+V3GN2GyTasOtZHfNgTn0Zy72JZnAh4+6XB6nOAYXGrr VpWtzk3wX7rAO+OxTL7/3I2jXuGwg80MpIc9ZSbc5JjEXYnCmMDBkmoe/Qqz4A3tgjeF K6Uvz2eFgzjnGkByrokueL8zn+qGcgO1C2VZg/qPWip+aNAt29WZXpMZnj54wrN3qR8F ECqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=B1CjwiCiW5Lttny0KtPnQAx2RN/+E+Up/MNFd61wI7I=; b=wW4H5oNH2m67VtyoTdx4mDnO0rSanl4Wv0FNfbTefo1L1qHgZZBCMIuJVJeZBTEMYh NwUaFj74bq2GNQicMJiv2VquIBFYBusSMmk5VmLpkT5lgW6ltCDcV8YqWndCf4BtkQfm SGwdzG/2sUD/INY7GiQFMFPI9LVaT1wMyXd02kXB3bxnKvjiChu/21r0LB3XBD4dwFIw 8VfZ7V9OGR7h1W0pxOjEn8Tzse06CUohoc9HQY4TQh9aENzMIW2pOszhaqZ8UMyGLNrG VkH/pIHZvh8chX8/YnI2mK1TXbqoFz8lMtZEUEMYLH0Uax83rb5WerPmnDcQy3IJY179 WbeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61si4874677plb.218.2017.11.03.06.52.33; Fri, 03 Nov 2017 06:52:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756420AbdKCNsJ (ORCPT + 95 others); Fri, 3 Nov 2017 09:48:09 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:51564 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756402AbdKCNsH (ORCPT ); Fri, 3 Nov 2017 09:48:07 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 7A08218955; Fri, 3 Nov 2017 14:48:06 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id KaCz6ZciEbIb; Fri, 3 Nov 2017 14:48:05 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 9C04C1839E; Fri, 3 Nov 2017 14:48:05 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71AA31A08A; Fri, 3 Nov 2017 14:48:05 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64BD41A088; Fri, 3 Nov 2017 14:48:05 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Fri, 3 Nov 2017 14:48:05 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id 5884F25F2; Fri, 3 Nov 2017 14:48:05 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 54DF040101; Fri, 3 Nov 2017 14:48:05 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/17] PCI: designware-ep: Add generic function for raising MSI irq Date: Fri, 3 Nov 2017 14:47:10 +0100 Message-Id: <20171103134722.5532-7-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171103134722.5532-1-niklas.cassel@axis.com> References: <20171103134722.5532-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a generic function for raising MSI irqs that can be used by all DWC based controllers. Note that certain controllers, like DRA7xx, have a special convenience register for raising MSI irqs that doesn't require you to explicitly map the MSI address. Therefore, it is likely that certain drivers will not use this generic function, even if they can. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-designware-ep.c | 34 ++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.h | 9 +++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index 9c3820ca6358..be874df8003d 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -282,6 +282,40 @@ static const struct pci_epc_ops epc_ops = { .stop = dw_pcie_ep_stop, }; +int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, + u8 interrupt_num) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct pci_epc *epc = ep->epc; + u16 msg_ctrl, msg_data; + u32 msg_addr_lower, msg_addr_upper; + u64 msg_addr; + bool has_upper; + int ret; + + /* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */ + msg_ctrl = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); + has_upper = !!(msg_ctrl & PCI_MSI_FLAGS_64BIT); + msg_addr_lower = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); + if (has_upper) { + msg_addr_upper = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); + msg_data = dw_pcie_readw_dbi(pci, MSI_MESSAGE_DATA_64); + } else { + msg_addr_upper = 0; + msg_data = dw_pcie_readw_dbi(pci, MSI_MESSAGE_DATA_32); + } + msg_addr = ((u64) msg_addr_upper) << 32 | msg_addr_lower; + ret = dw_pcie_ep_map_addr(epc, ep->msi_mem_phys, msg_addr, PAGE_SIZE); + if (ret) + return ret; + + writel(msg_data | (interrupt_num - 1), ep->msi_mem); + + dw_pcie_ep_unmap_addr(epc, ep->msi_mem_phys); + + return 0; +} + void dw_pcie_ep_exit(struct dw_pcie_ep *ep) { struct pci_epc *epc = ep->epc; diff --git a/drivers/pci/dwc/pcie-designware.h b/drivers/pci/dwc/pcie-designware.h index 37dfad8d003f..24edac035160 100644 --- a/drivers/pci/dwc/pcie-designware.h +++ b/drivers/pci/dwc/pcie-designware.h @@ -106,6 +106,8 @@ #define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) #define MSI_MESSAGE_ADDR_L32 0x54 #define MSI_MESSAGE_ADDR_U32 0x58 +#define MSI_MESSAGE_DATA_32 0x58 +#define MSI_MESSAGE_DATA_64 0x5C /* * Maximum number of MSI IRQs can be 256 per controller. But keep @@ -338,6 +340,7 @@ static inline int dw_pcie_host_init(struct pcie_port *pp) void dw_pcie_ep_linkup(struct dw_pcie_ep *ep); int dw_pcie_ep_init(struct dw_pcie_ep *ep); void dw_pcie_ep_exit(struct dw_pcie_ep *ep); +int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 interrupt_num); void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar); #else static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep) @@ -353,6 +356,12 @@ static inline void dw_pcie_ep_exit(struct dw_pcie_ep *ep) { } +static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, + u8 interrupt_num) +{ + return 0; +} + static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) { } -- 2.14.2 From 1583223795001859329@xxx Sun Nov 05 11:04:30 +0000 2017 X-GM-THRID: 1583223795001859329 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread