Received: by 10.223.164.202 with SMTP id h10csp3820217wrb; Mon, 20 Nov 2017 05:38:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMZqyhbM+rWiv0jWMV04hixHpg3hgQA6pCsU4PHrVnJeQPwtefBVHgiOnM//Y6+AXgTja8nD X-Received: by 10.84.241.15 with SMTP id a15mr14300853pll.103.1511185093142; Mon, 20 Nov 2017 05:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511185093; cv=none; d=google.com; s=arc-20160816; b=t3XFlRwSsmkp4qKFv+fGrrC1cOVmfc9BIUkLE5WbTIgpBT/QoU+GAlNcZNm36CMB99 j+37xp/jSYPjnhQT7zkQvNJMP4kntfpLdLCaijb+ogQIRgigo6OGfWt0FqHkaoMouVed 7bb7gZHNcEp+Ht3WN7lnsynHhP4qvEeZVuBUgDtnye7T+IGRkxuUeA1lxJyie1FOpSXe TPg4mLFNWF+/aXgzRvqgZWgzb3Qa3nIUPemYT91aJPecKdMi13e9L1ICjFzUPsOXnYHk CZP/04xTEegvQSTgihHlpK5suO0OLNqh2YXyr+H5XBiInUh0CuZGcwq/j5hZ6mN+jsHr 8wKA== 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=HKdB41eJI+BEyn5gbups8TRCnSzbJHdObddH5h8Z9sY=; b=k+cZdBqqSKh3/HIagRuPvJEr8S5/a79lnjueRUiaP7y/VJ4WxIP+6+ZRoHqAJAwiIR 0zM4u/izXQYQBCzyis7V6WFUt1LPItucUCxGd/O8VuLvVPDC5iNNqfOGNz2m/Gv4AJWj cYbwFBNsnhCRwIBclYZ0ths4EK5zmwAT/n8ErRFdiBl6id0+a8C24XKMUjSbBE/rZCxK 4LZ/HS1XpWz9ZW563HpcCDubsYu4HEbwnqQ7czzZh+Qz2RXsi3qbNCktWgoZDb/8MBZh uRv33iGpR2h5x1kBJP7s0gDz/PUWC0AW9bHPy9e6GI1A3wSkGR6xCcv7Z98Cj0PR+Jdd XkgA== 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 v3si8100495pgr.802.2017.11.20.05.38.03; Mon, 20 Nov 2017 05:38:13 -0800 (PST) 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 S1751357AbdKTNdP (ORCPT + 66 others); Mon, 20 Nov 2017 08:33:15 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:39586 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbdKTNdN (ORCPT ); Mon, 20 Nov 2017 08:33:13 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 920F7183B6; Mon, 20 Nov 2017 14:33:11 +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 svc54cMdVVNf; Mon, 20 Nov 2017 14:33:09 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id DAF29183AC; Mon, 20 Nov 2017 14:33:09 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C5F3E1E07F; Mon, 20 Nov 2017 14:33:09 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B98AE1E07D; Mon, 20 Nov 2017 14:33:09 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 20 Nov 2017 14:33:09 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id AD326198F; Mon, 20 Nov 2017 14:33:09 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id A9AD0400FE; Mon, 20 Nov 2017 14:33:09 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 06/18] PCI: designware-ep: Add generic function for raising MSI irq Date: Mon, 20 Nov 2017 14:32:09 +0100 Message-Id: <20171120133222.27771-7-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171120133222.27771-1-niklas.cassel@axis.com> References: <20171120133222.27771-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 | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.h | 9 +++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index 700ed2f4becf..c5aa1cac5041 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -282,6 +282,41 @@ 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, + epc->mem->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 1584592304410834263@xxx Mon Nov 20 13:36:22 +0000 2017 X-GM-THRID: 1584592304410834263 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread