Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2022032imm; Tue, 10 Jul 2018 11:46:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc4LifCnEcyQrEAnrxVXye6SUkxmi+Ryu2ySbh6eu0xovWNxDaG28QN+R8EXlMHRDjrC8Ob X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr25975774plh.291.1531248379422; Tue, 10 Jul 2018 11:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248379; cv=none; d=google.com; s=arc-20160816; b=wRgV2tVznzgHJU4wOyv6uAZoJqumrtKZy3ZbjjSztNBxdh+iMmXFpgt9uAMi2A592d qVoGIzw9KvQQkMRibwPxiYpr8XigbDfllnH1FtvuY562tPVC3MopPwNfJ7cpxz1wrhbY ptOkE7QVMHyFWlyryOasQvK4B+2N2SuvBe3IlkUD+hhZQU3bxITS+jdZt1xjYvhkDKAL hiQnOmDcY7m/io/Sb7rnX9ldhRiiCJKltbitR032Sm1Y9Yc4NbbRXReCtqYjvqVTxiI3 8paJwHk+vQRYO9661CtFvHE0OpjJ9vwQi1Fa3uSJjRZJ6j9hw0NAgELDdbqGkrZ+vmVx yoXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8DaQFy0iBAYyxBrBM/sz8Nh/kiLcAIZmNL2AOVrOPBo=; b=P7MNn6j/vyXZWzVEmyyKjERBZ8DSv5m7nJRsLltphT9MZJziKufZAyTm9imch7ArPl 7AJxyY5BpYWnav07mWnXrSXWxPbjgVCDMH4cT9gJ1/+DWWiUME6rw54YiN9XxvLTtpqj ttUS5Xsjla4tpDkWDW49DM1+GLZStiTZj04YCWa1+yqo3HHi8ZgrCjh+OPa6VrlTAJxU Ln1PN9tt4lJ5lyZXmb5WBIw78dlbfUINYOf/WKRw6We3BexoqiUrQHbU2gMU6gYIjW5N yUwTLxlzbvJk7Od2DPaiHPUbLFGnBtD6WsZh4WE30CASbnTlwhhpGXKrcUIJC4wuz9ew oN6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n125-v6si16725230pga.376.2018.07.10.11.46.04; Tue, 10 Jul 2018 11:46:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389485AbeGJSns (ORCPT + 99 others); Tue, 10 Jul 2018 14:43:48 -0400 Received: from foss.arm.com ([217.140.101.70]:51806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389002AbeGJSdm (ORCPT ); Tue, 10 Jul 2018 14:33:42 -0400 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 D52E280D; Tue, 10 Jul 2018 10:17:27 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.210.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 59B3B3F589; Tue, 10 Jul 2018 10:17:25 -0700 (PDT) From: Robin Murphy To: hch@lst.de, m.szyprowski@samsung.com, iommu@lists.linux-foundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org, sudeep.holla@arm.com, robh+dt@kernel.org, frowand.list@gmail.com, gregkh@linuxfoundation.org, joro@8bytes.org, x86@kernel.org Subject: [RFC PATCH 0/4] Stop losing firmware-set DMA masks Date: Tue, 10 Jul 2018 18:17:15 +0100 Message-Id: X-Mailer: git-send-email 2.17.1.dirty Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Whilst the common firmware code invoked by dma_configure() initialises devices' DMA masks according to limitations described by the respective properties ("dma-ranges" for OF and _DMA/IORT for ACPI), the nature of the dma_set_mask() API leads to that information getting lost when well-behaved drivers probe and set a 64-bit mask, since in general there's no way to tell the difference between a firmware-described mask (which should be respected) and whatever default may have come from the bus code (which should be replaced outright). This can break DMA on systems with certain IOMMU topologies (e.g. [1]) where the IOMMU driver only knows its maximum supported address size, not how many of those address bits might actually be wired up between any of its input interfaces and the associated DMA master devices. Similarly, some PCIe root complexes only have a 32-bit native interface on their host bridge, which leads to the same DMA-address-truncation problem in systems with a larger physical memory map and RAM above 4GB (e.g. [2]). These patches attempt to deal with this in the simplest way possible by generalising the specific quirk for 32-bit bridges into an arbitrary mask which can then also be plumbed into the firmware code. In the interest of being minimally invasive, I've only included a point fix for the IOMMU issue as seen on arm64 - there may be further tweaks needed in DMA ops to catch all possible incarnations of this problem, but this initial RFC is mostly about the impact beyond the dma-mapping subsystem itself. Robin. [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-May/580804.html [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-December/474443.html Robin Murphy (4): dma-mapping: Generalise dma_32bit_limit flag ACPI/IORT: Set bus DMA mask as appropriate of/device: Set bus DMA mask as appropriate iommu/dma: Respect bus DMA limit for IOVAs arch/x86/kernel/pci-dma.c | 2 +- drivers/acpi/arm64/iort.c | 1 + drivers/iommu/dma-iommu.c | 3 +++ drivers/of/device.c | 1 + include/linux/device.h | 6 +++--- kernel/dma/direct.c | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) -- 2.17.1.dirty