From patchwork Mon Apr 20 09:27:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 11498507 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C8EA14B4 for ; Mon, 20 Apr 2020 09:28:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8E8721473 for ; Mon, 20 Apr 2020 09:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587374882; bh=jSEKGWqsrT6A07i0d90hlri1Jat4wE9wmFvoKlPRqM0=; h=From:To:Cc:Subject:Date:List-ID:From; b=XmgUnqw4glo1IUZ9MtgQ6el1ZL3t1QLnr6PeUIWQmQWhiEx2q7szdlju1E8HzRv1k 8ffNgPUOwOn86Lcj8P4Kl7LDEYJreORl5WqDpOb//S0ypRoGSfsq9jbONjdst2cC+D xriavHpjKRAJssNVZuxPfkeTAtTST6l4Jn3gvVuA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725773AbgDTJ2C (ORCPT ); Mon, 20 Apr 2020 05:28:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:46016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgDTJ2C (ORCPT ); Mon, 20 Apr 2020 05:28:02 -0400 Received: from sudo.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF6FA20CC7; Mon, 20 Apr 2020 09:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587374881; bh=jSEKGWqsrT6A07i0d90hlri1Jat4wE9wmFvoKlPRqM0=; h=From:To:Cc:Subject:Date:From; b=mq0viWMww53XTmD3oHdx/2kondNR/5TNTFZTHZwB2Z0xNMl2NYS8b/nODRRi1efll RB5Fg9YGAMc0RWZoTh6xo3htp7Sth3FH6fcbBmZeVBgO6XNp776QwlzJOKRN8rJggr 6rwkChmt9mJdPIkHqaGcLonX4zt4hwP/wyFGvJRE= From: Ard Biesheuvel To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, Ard Biesheuvel , Andrei Warkentin Subject: [PATCH v2] ACPI/IORT: take _DMA methods into account for named components Date: Mon, 20 Apr 2020 11:27:53 +0200 Message-Id: <20200420092753.9819-1-ardb@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Where IORT nodes for named components can describe simple DMA limits expressed as the number of address bits a device can drive, _DMA methods in AML can express more complex topologies, involving DMA translation in particular. Currently, we only take this _DMA method into account if it appears on a ACPI device node describing a PCIe root complex, but it is perfectly acceptable to use them for named components as well, so let's ensure we take them into account in those cases too. Note that such named components are expected to reside under a pseudo-bus node such as the ACPI0004 container device, which should be providing the _DMA method as well as a _CRS (as mandated by the ACPI spec). This is not enforced by the code however. Reported-by: Andrei Warkentin Acked-by: Lorenzo Pieralisi Signed-off-by: Ard Biesheuvel --- drivers/acpi/arm64/iort.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index ed3d2d1a7ae9..07eb78baf198 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -1146,13 +1146,10 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size) else size = 1ULL << 32; - if (dev_is_pci(dev)) { - ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size); - if (ret == -ENODEV) - ret = rc_dma_get_range(dev, &size); - } else { - ret = nc_dma_get_range(dev, &size); - } + ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size); + if (ret == -ENODEV) + ret = dev_is_pci(dev) ? rc_dma_get_range(dev, &size) + : nc_dma_get_range(dev, &size); if (!ret) { /*