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: 9972897 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 ADE0160393 for ; Wed, 27 Sep 2017 01:20:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD6C2903A for ; Wed, 27 Sep 2017 01:20:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92B9A2903C; Wed, 27 Sep 2017 01:20:42 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 357392903B for ; Wed, 27 Sep 2017 01:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969162AbdI0BUl (ORCPT ); Tue, 26 Sep 2017 21:20:41 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:46472 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969164AbdI0BUj (ORCPT ); Tue, 26 Sep 2017 21:20:39 -0400 Received: by mail-pf0-f169.google.com with SMTP id r68so6420254pfj.3 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=gqGoAydTimXotfgAl966GnVUEogvVtu1vZZ+dwWjizbz/GIqFG438OjHyYadRj19rm A32gYr0Z94HtnA8jGw8/QFr11Mzc9DBHtAYUJ6CaNVV1LHt7ycptWMbgsGw9RjTSTrND 50cbMFoVsXAvbq0l4tUY5hZ9jCkZTHipzJiqCsyKjwDSngFzPKT4kfK/C6u1a3T2AHQT 3EmEM9XnQwk4jfh4wHDPhTyf5OWoK4Dm1Ue3+XvKIUVmy3Hgahrui4yfVJWzbC8NOvEQ +wmhe6PNjOvV4E4PYGyMTmXJUT5u/uFJbzg3Pt2KGwN41SH+z8gpSdRr9iwRVwQ+3Y+W XDRA== X-Gm-Message-State: AHPjjUg3Uql8kFMESoPMw/DzifEcTuZggxK9RLkVNK7S4C0dlcyGDULl KgsxOYO9TsWSw9/ncdvwIgkfuQ== 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 Cc: "Rafael J. Wysocki" , Marc Zyngier , Lv Zheng , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Hanjun Guo 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> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.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;