From patchwork Wed Sep 27 01:20:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 9972901 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 92D4C60393 for ; Wed, 27 Sep 2017 01:22:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87E782892A for ; Wed, 27 Sep 2017 01:22:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 774702903E; Wed, 27 Sep 2017 01:22:58 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 089432903C for ; Wed, 27 Sep 2017 01:22:57 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=9+ouqJbm3z1oIAxMjJv8GeQ/l+OEp6o71V5h74b1cN8=; b=BFOVTZbQfFQ3j5KCxppSYiVHoY VvAVZ016OwXDNw/frJ9ZieJr6PCzPHqvhUHg9pwb/fSyYdDoWxIyALleCQgZ0NGsAtwDUEfy9DlHe 83AWxWPXwIyXMKFFR26k8GmxW/l7rzjOcb11ZGOW0tznpaokztyd5tCci2Gfc2++XOJqvaQoxaWD+ xPxNAmXOdApTcV+WwzgiDlPKOPDBbz7JBcdJE7Y981Cw9jmchlCEN7gtVfHEDcOq4nRY3LlmRUinv XzuyujjaZg7uELIlRg7D7pD+egdE1u0mh6zrkw7bZNgmE1DHWb6+J9JwrUHYds6gWItkx4sgNqiM9 8bvgziMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dx13X-0003lt-Kk; Wed, 27 Sep 2017 01:22:31 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dx124-0002Ir-8F for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2017 01:21:12 +0000 Received: by mail-pf0-x22c.google.com with SMTP id g65so6409743pfe.13 for ; Tue, 26 Sep 2017 18:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JxUmcNWfBOvcuMFZHaNgUZ0HPgafnQxRqCK687y/6z4=; b=Hn40YGetDrbOfSRMAlLSLstitzC4/gOmaTsDrGQ9OAzgt42osf+qJbEp3t/yoD4Kul k45H3dbtrr7GhmWGhD5tn8etwRUXROfdg6j+H9fzTys1cvMfmgNRfeT8Jv0MFMYhT6C9 Y2CpRqoAoCTn5OkOD41PzRkFQloXDNSgUJs3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JxUmcNWfBOvcuMFZHaNgUZ0HPgafnQxRqCK687y/6z4=; b=itvPXjz9lWkxt59SZTIQVBpxcqypxpQP875seF5sxFf8jvM/9t02VYne0nCJQP2ufA WY1b+nGLWhlnBgmzQ9FYBDRv5Nd/BvscTvonw+Gwt6+W3WXlJW2m3EESfYdSGIzXM6wq DK7uLpvr5z506UXySHtg0t/l8FW0YaG1+D2zgbMcI/fI8Hpz1iqMwswcJEqM+FUtXyi5 QRcVrJ0I9n9sKZu/Xq73aaStrlMaDal4Rr204SN+uzhbBmudu7R0GCNIY5widhZLbnB+ g1TnIQdY+IFEE6M0Y7DZsQyS1KVbvw8nJdgApxyQssFrHOY86IKfxFY9S6IbVTYco6uA rjTw== X-Gm-Message-State: AHPjjUjwRwkCe3rd56CtOO1MwGgEMOnHgKgpKUgVhDu1c2cal3Oba8Oh 1usEtxEEE5j9d6/N8nYGZojrJw== X-Google-Smtp-Source: AOwi7QBUs2Gzx9fyPe5AYLypM/zUpIt0dA3D4+fbjkIUYOwOxfjtuEtdQ54WQPtvaHHQ1Ort4BoIoA== X-Received: by 10.99.115.93 with SMTP id d29mr13013319pgn.333.1506475239354; Tue, 26 Sep 2017 18:20:39 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.googlemail.com with ESMTPSA id p1sm18065617pfb.53.2017.09.26.18.20.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 18:20:38 -0700 (PDT) From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy Subject: [PATCH 4/4] ACPI: IORT: SMMUv3 nodes MSI support Date: Wed, 27 Sep 2017 09:20:15 +0800 Message-Id: <1506475215-2731-5-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> References: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170926_182100_899571_99B9D151 X-CRM114-Status: GOOD ( 12.37 ) 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: Marc Zyngier , "Rafael J. Wysocki" , linuxarm@huawei.com, linux-acpi@vger.kernel.org, Lv Zheng , linux-arm-kernel@lists.infradead.org, Hanjun Guo MIME-Version: 1.0 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 From: Lorenzo Pieralisi Since we make single mappings valid for SMMUv3 (and PMCG), also we have a mapping index for SMMUv3 MSI, we can directly use that index to get the map entry, then retrieve ITS parent to add SMMUv3 MSI support. Introduce a new API iort_set_device_domain() to find the MSI domain for an SMMUv3 (or any other IORT table node) to reduce the complex of doing that via acpi_configure_pmsi_domain(). Signed-off-by: Lorenzo Pieralisi Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 1c1160e..06b38de 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -633,6 +633,49 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id) return irq_find_matching_fwnode(handle, DOMAIN_BUS_PCI_MSI); } +static void iort_set_device_domain(struct device *dev, + struct acpi_iort_node *node) +{ + struct acpi_iort_its_group *its; + struct acpi_iort_node *msi_parent; + struct acpi_iort_id_mapping *map; + struct fwnode_handle *iort_fwnode; + struct irq_domain *domain; + int index; + + index = iort_get_id_mapping_index(node); + if (index < 0) + return; + + map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, + node->mapping_offset + index * sizeof(*map)); + + /* Firmware bug! */ + if (!map->output_reference || + !(map->flags & ACPI_IORT_ID_SINGLE_MAPPING)) { + pr_err(FW_BUG "[node %p type %d] Invalid MSI mapping\n", + node, node->type); + return; + } + + msi_parent = ACPI_ADD_PTR(struct acpi_iort_node, iort_table, + map->output_reference); + + if (!msi_parent || msi_parent->type != ACPI_IORT_NODE_ITS_GROUP) + return; + + /* Move to ITS specific data */ + its = (struct acpi_iort_its_group *)msi_parent->node_data; + + iort_fwnode = iort_find_domain_token(its->identifiers[0]); + if (!iort_fwnode) + return; + + domain = irq_find_matching_fwnode(iort_fwnode, DOMAIN_BUS_PLATFORM_MSI); + if (domain) + dev_set_msi_domain(dev, domain); +} + /** * iort_get_platform_device_domain() - Find MSI domain related to a * platform device @@ -1259,6 +1302,8 @@ static int __init iort_add_smmu_platform_device(struct acpi_iort_node *node) /* Configure DMA for the page table walker */ acpi_dma_configure(&pdev->dev, attr); + iort_set_device_domain(&pdev->dev, node); + ret = platform_device_add(pdev); if (ret) goto dma_deconfigure;