From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAB72C43381 for ; Sun, 31 Mar 2019 12:36:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7981B20989 for ; Sun, 31 Mar 2019 12:36:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Sxe/mb0Y"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="NJDPQrfO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7981B20989 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=2A/CCTCt4WEybu41PKs68sALMImv+f34FdrkJJI99mQ=; b=Sxe/mb0YUvvulZ mt1QiCuWYSx6Dhny5E6oPRyEYhZbqrsG9qi+BtRY6uc4VyM/bje/S4qiG+UDyqXMqK17XFQjFSHcb kQtnecWwCePhohr+UORScDBmVbbjeNLnstCrBjCYFnQoHWJO13JGucygXcpp2otgT67z6+e1u2cXm EdF+yAj/wSnoSBBWx2DLhR7cX+iMMhrUpPGdf6IiU1CxofsM/4siKCJc/we2LhLNz2d4MSkFZVDIL wIsE9DyFGpxgi7PkElJe2btFWmkUbarJAjBDqOZU618112J7VAtWNuz9is9fMFZbSQWfF5V3Ppuc4 groSAyR3i68SOPRBfJJg==; 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 1hAZhk-00081r-VP; Sun, 31 Mar 2019 12:36:52 +0000 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hAZhA-0007Fb-Nc for linux-arm-kernel@lists.infradead.org; Sun, 31 Mar 2019 12:36:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1554035776; x=1585571776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Xxf/XCRLhaUzHncFkuCeHY/pyfBo0qcyLkgrrUxQFzg=; b=NJDPQrfOeHudUiXbEEcd9ZczhlFZ6t/+RICtfT70CcbLIAoQilJ4nHy8 sh/GXicqglI/OWtHbSFPUM6bQx8UQumHgguW1aBJlH3PvpyopKBO6io+f qvj+6ddRPr5O80C1mUU5AUhtR1sOXMNtj0DHuMfMKlvWwEhN4dhvv+sYh w=; X-IronPort-AV: E=Sophos;i="5.60,292,1549929600"; d="scan'208";a="796653391" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2a-119b4f96.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Mar 2019 12:36:16 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2a-119b4f96.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id x2VCaCrb130523 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Sun, 31 Mar 2019 12:36:15 GMT Received: from EX13D19EUB003.ant.amazon.com (10.43.166.69) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 31 Mar 2019 12:36:14 +0000 Received: from ub6d44c9ce3e25c.ant.amazon.com (10.43.161.164) by EX13D19EUB003.ant.amazon.com (10.43.166.69) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 31 Mar 2019 12:36:04 +0000 From: Hanna Hawa To: , , , , , , , , , Subject: [PATCH 7/7] irqchip/al-msi: Add ACPI support Date: Sun, 31 Mar 2019 15:35:33 +0300 Message-ID: <1554035733-11827-3-git-send-email-hhhawa@amazon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554035733-11827-1-git-send-email-hhhawa@amazon.com> References: <1554035733-11827-1-git-send-email-hhhawa@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.161.164] X-ClientProxiedBy: EX13D20UWC002.ant.amazon.com (10.43.162.163) To EX13D19EUB003.ant.amazon.com (10.43.166.69) Precedence: Bulk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190331_053617_382776_BA8885C4 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, barakw@amazon.com, hhhawa@amazon.com, vaerov@amazon.com, linux-kernel@vger.kernel.org, hanochu@amazon.com, linux-acpi@vger.kernel.org, zeev@amazon.com, dwmw@amazon.co.uk, jonnyc@amazon.com, ronenk@amazon.com, talel@amazon.com, alisaidi@amazon.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds ACPI support for AL-MSIx driver. The AL-MSIx controller is not standard, is not included in the UEFI specification, and will not be added. The driver ACPI binding is performed when the following conditions are true: - OEM ID is AMAZON - MADT table type is 0x80 (part of the OEM reserved range). Signed-off-by: Hanna Hawa Co-developed-by: Vladimir Aerov Signed-off-by: Vladimir Aerov --- drivers/irqchip/irq-al-msi.c | 118 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-al-msi.c b/drivers/irqchip/irq-al-msi.c index ec27455..cb80c1e 100644 --- a/drivers/irqchip/irq-al-msi.c +++ b/drivers/irqchip/irq-al-msi.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -126,14 +127,20 @@ static int al_msix_gic_domain_alloc(struct irq_domain *domain, struct irq_data *d; int ret; - if (!is_of_node(domain->parent->fwnode)) + if (is_of_node(domain->parent->fwnode)) { + fwspec.fwnode = domain->parent->fwnode; + fwspec.param_count = 3; + fwspec.param[0] = 0; + fwspec.param[1] = spi; + fwspec.param[2] = IRQ_TYPE_EDGE_RISING; + } else if (is_fwnode_irqchip(domain->parent->fwnode)) { + fwspec.fwnode = domain->parent->fwnode; + fwspec.param_count = 2; + fwspec.param[0] = spi + 32; + fwspec.param[1] = IRQ_TYPE_EDGE_RISING; + } else { return -EINVAL; - - fwspec.fwnode = domain->parent->fwnode; - fwspec.param_count = 3; - fwspec.param[0] = 0; - fwspec.param[1] = spi; - fwspec.param[2] = IRQ_TYPE_EDGE_RISING; + } ret = irq_domain_alloc_irqs_parent(domain, virq, 1, &fwspec); if (ret) @@ -304,3 +311,100 @@ static int al_msix_init(struct device_node *node, struct device_node *parent) } IRQCHIP_DECLARE(alpine_msix, "al,alpine-msix", al_msix_init); IRQCHIP_DECLARE(al_msix, "amazon,al-msix", al_msix_init); + +#ifdef CONFIG_ACPI +static struct al_msix_data *priv; + +#define ACPI_AMZN_MADT_OEM_TYPE 0x80 +#define ACPI_AMZN_OEM_ID "AMAZON" + +struct acpi_madt_msix_oem_frame { + struct acpi_subtable_header header; + u64 base_address; + u32 base_address_len; + u16 spi_count; + u16 spi_base; +}; + +static struct fwnode_handle *al_msi_get_fwnode(struct device *dev) +{ + return priv->msi_domain_handle; +} + +static int __init al_msix_acpi_probe(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct irq_domain *gic_domain; + struct fwnode_handle *gic_domain_handle; + struct acpi_madt_msix_oem_frame *m; + int ret; + + m = container_of(header, struct acpi_madt_msix_oem_frame, header); + if (BAD_MADT_ENTRY(m, end)) + return -EINVAL; + + gic_domain_handle = acpi_get_gsi_domain_id(); + if (!gic_domain_handle) { + pr_err("Failed to find the GIC domain handle\n"); + return -ENXIO; + } + + gic_domain = irq_find_matching_fwnode(gic_domain_handle, + DOMAIN_BUS_ANY); + if (!gic_domain) { + pr_err("Failed to find the GIC domain\n"); + return -ENXIO; + } + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->spi_first = m->spi_base; + priv->num_spis = m->spi_count; + + priv->msi_domain_handle = irq_domain_alloc_fwnode((void *) + m->base_address); + if (!priv->msi_domain_handle) { + pr_err("Unable to allocate msi domain token\n"); + ret = -EINVAL; + goto err_acpi_priv; + } + + ret = al_msix_init_common(priv, m->base_address); + if (ret) + goto err_acpi_priv; + + ret = al_msix_init_domains(priv, gic_domain); + if (ret) + goto err_acpi_map; + + pci_msi_register_fwnode_provider(&al_msi_get_fwnode); + + return 0; + +err_acpi_map: + kfree(priv->msi_map); +err_acpi_priv: + kfree(priv); + return ret; +} + +static int __init al_msix_acpi_init(void) +{ + static struct acpi_table_madt *madt; + acpi_status status; + + /* if ACPI MADT table is not Amazon defined return */ + status = acpi_get_table(ACPI_SIG_MADT, 0, + (struct acpi_table_header **)&madt); + if (ACPI_FAILURE(status) || (madt && memcmp(madt->header.oem_id, + ACPI_AMZN_OEM_ID, + ACPI_OEM_ID_SIZE))) + return -ENODEV; + + return acpi_table_parse_madt(ACPI_AMZN_MADT_OEM_TYPE, + al_msix_acpi_probe, 0); +} +early_initcall(al_msix_acpi_init); +#endif /* CONFIG_ACPI */ -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel