From patchwork Mon Jul 31 15:23:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9872345 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 60336602F0 for ; Mon, 31 Jul 2017 15:49:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 502F920564 for ; Mon, 31 Jul 2017 15:49:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4500828533; Mon, 31 Jul 2017 15:49:19 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE 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 D7CC6285DB for ; Mon, 31 Jul 2017 15:49:17 +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=y+/CU0rG7vhw4uI08md4WG5wU9gSxDEFZ9cy0mcVT6w=; b=fyLLDtB2d7BAP5idySgh/ckVzy wrYVAwaSQcgBMd4jTA1OU1o00MIzlo4I9ZVBUgD1xsf7kFXwrP3RhaFXolgrmmXNbqiirjyAOe220 jXp2jn9QbXj6+pUwo+266VLxKhazI7V3g4ZZH7ly8S6T6PVqCjkZ1bC4CXpmHFjTNPpnGe38Jycu1 G2gauHH/ML3KKXm9tI/L7hIpb1lDO/mgO2OZTZ7JQEmZbOfx3RfK80RyeDVE7+m6xn56Dsywej3qC rfQXCJMyPLD8ElffCR7Vd+33KOcnBrWadxLs3N9wlfuUDOTcx8g3qmqH5kNIN3vEAmPa9IrI2nbbT +Q3EVGxA==; 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 1dcCwR-0003xo-TJ; Mon, 31 Jul 2017 15:49:11 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcCib-0004uc-CZ for linux-arm-kernel@bombadil.infradead.org; Mon, 31 Jul 2017 15:34:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=u8K4ZKzwhVgiYsgpt8qaS+gud71KgSr7gGSN9zm1My4=; b=LQ8uEN/x6Z+IZinZI8HBbMpy5 mP2Wwkx5vBlBW5RM3Gf4jhndln+qHCqJnv9sePf3OkdXXwx2GjMdNouZINcw8atCtRzzLuTLLCr3L D4u1zELy2Qj83zn4op0lEey1Yd/QQAd+GS5Mtv1oQ3Kt+MdEAU9xq2dC3+DB+oPq0yiJdiSNzHnW+ D9NbQw2tD84QtiWW/HlQC5EuB9TfcgSo47SbQ31ArTsxA38gGndLB1a/W8RdMzJYXL+61YzocHhUU snZgH2SA+Kd+1GJlg7qoy+CaVT9gC73O3MKAYTK2kLvdnstsLVSDC1BnxOu9HFJut+YNR+jMezd1r oorvgEcAA==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dcCWW-0000aI-QG for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2017 15:22:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D4A6165C; Mon, 31 Jul 2017 08:21:49 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E001F3F540; Mon, 31 Jul 2017 08:21:46 -0700 (PDT) From: Lorenzo Pieralisi To: linux-acpi@vger.kernel.org Subject: [PATCH v2 5/5] ACPI/IORT: Add IORT named component memory address limits Date: Mon, 31 Jul 2017 16:23:23 +0100 Message-Id: <20170731152323.32488-6-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170731152323.32488-1-lorenzo.pieralisi@arm.com> References: <20170731152323.32488-1-lorenzo.pieralisi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170731_162224_987559_2F77605C X-CRM114-Status: GOOD ( 15.06 ) 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: Feng Kan , Lorenzo Pieralisi , "Rafael J. Wysocki" , Jon Masters , Will Deacon , linux-kernel@vger.kernel.org, Robert Moore , Nate Watterson , Zhang Rui , Robin Murphy , 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 IORT named components provide firmware configuration describing how many address bits a given device is capable of generating to address memory. Add code to the kernel to retrieve memory address limits configuration for IORT named components and configure DMA masks accordingly. Signed-off-by: Lorenzo Pieralisi Cc: Will Deacon Cc: Robin Murphy Cc: Nate Watterson --- drivers/acpi/arm64/iort.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 67b85ae..b85d19f 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -680,6 +680,24 @@ static const struct iommu_ops *iort_iommu_xlate(struct device *dev, return ret ? NULL : ops; } +static int nc_dma_get_range(struct device *dev, u64 *size) +{ + struct acpi_iort_node *node; + struct acpi_iort_named_component *ncomp; + + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, + iort_match_node_callback, dev); + if (!node) + return -ENODEV; + + ncomp = (struct acpi_iort_named_component *)node->node_data; + + *size = ncomp->memory_address_limit >= 64 ? ~0ULL : + 1ULL<memory_address_limit; + + return 0; +} + /** * iort_dma_setup() - Set-up device DMA parameters. * @@ -708,17 +726,19 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1); - if (dev_is_pci(dev)) { + if (dev_is_pci(dev)) ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size); - if (!ret) { - mask = __roundup_pow_of_two(dmaaddr + size) - 1; - /* - * Limit coherent and dma mask based on size - * retrieved from firmware. - */ - dev->coherent_dma_mask = mask; - *dev->dma_mask = mask; - } + else + ret = nc_dma_get_range(dev, &size); + + if (!ret) { + mask = __roundup_pow_of_two(dmaaddr + size) - 1; + /* + * Limit coherent and dma mask based on size + * retrieved from firmware. + */ + dev->coherent_dma_mask = mask; + *dev->dma_mask = mask; } *dma_addr = dmaaddr;