Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp953747imm; Wed, 11 Jul 2018 14:08:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNBvpCVVZx7J+ypw5AH6PKlkWTl8sTCecdZbBL+yj8ubA0nAJTtQ3Gyu1tLZ1oafJtmV15 X-Received: by 2002:a65:6143:: with SMTP id o3-v6mr241802pgv.52.1531343295342; Wed, 11 Jul 2018 14:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531343295; cv=none; d=google.com; s=arc-20160816; b=G2OYN9j0Um6hOAIdmRMCTIQnEb80tTqDXTQj3gpuCWEXgom5h7zBhwZHyF4DXkSjQ1 vHU0pclJW8QuCXc/HGPzEAHo4ebl65jO6fj/UWBIvPI1c/mOVKCE92uwEQ9NIuPU5pf1 d7iqopWWCcFaudgvdk5d/ozLneZaOOIOh7+yPscqyibdOw+vKRjeMAl9/8t2jYufegDI UKzabBazMqz4A+nUObHDmh1qOtp79zDlxmz/pKUthQtEvLJiKWMwEPnWJGlvylA8ih1I ocqo2qArNq0R0pcjtjIF9+oqoYhkxFpzpgx9MnR6W6SdtxyXBKHnJPTw6aUEd96fpbLx mUJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=rWABlycOp/Iw0TEAl7I1KQmCSENkMQXJ12Y41i7IDHg=; b=eDRANfy+s14xUimZoOAxpDelMSzUDsbQnTYxp/G6187xBPtYb6tNv7jsWxlgmLUbSr aIurfq81Z/OXJ4cY6+zNWXCDoVdgnRrlfKWDYzfWNMdZI4jtcyVHivnDIoZXn3PzFHCQ 9EtSXrn66d4Ju6HIcBydg+gEL5GqoDLerv0b7Syt1qheYD/NTaHAmBUTL4clSPSbXmqN 0/EmKN3HMYalO7tCO4ImQZksEz+YQYFFuzDJscNAqhZIEn0Cuy0MCeqXQxAiJ9aTj6aY j1Tjsxyb81Wgd1FSAiMqs0F3Z35qozoqW/ssqt19Fz6TEEy2HYRrawjzegf+uCM4odW4 Pu+w== 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 y187-v6si1561070pfy.151.2018.07.11.14.08.00; Wed, 11 Jul 2018 14:08:15 -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 S2387479AbeGKQIi (ORCPT + 99 others); Wed, 11 Jul 2018 12:08:38 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39388 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbeGKQIi (ORCPT ); Wed, 11 Jul 2018 12:08:38 -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 01F797A9; Wed, 11 Jul 2018 09:03:38 -0700 (PDT) Received: from [10.1.210.23] (e110467-lin.cambridge.arm.com [10.1.210.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 73EA33F5B1; Wed, 11 Jul 2018 09:03:35 -0700 (PDT) Subject: Re: [RFC PATCH 0/4] Stop losing firmware-set DMA masks To: Rob Herring Cc: Christoph Hellwig , m.szyprowski@samsung.com, iommu@lists.linux-foundation.org, linux-arm-kernel , linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, Linux Kernel Mailing List , Lorenzo Pieralisi , hanjun.guo@linaro.org, Sudeep Holla , Rob Herring , Frank Rowand , Greg Kroah-Hartman , joro@8bytes.org, x86@kernel.org References: From: Robin Murphy Message-ID: <9a54d956-927e-68f7-5c3b-af7cd0616dc2@arm.com> Date: Wed, 11 Jul 2018 17:03:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07/18 15:40, Rob Herring wrote: > On Tue, Jul 10, 2018 at 12:43 PM Robin Murphy wrote: >> >> 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. > > Couldn't you set and use the device's parent's dma_mask instead. At > least for DT, we should always have a parent device representing the > bus. That would avoid further bloating of struct device. But then if the parent device did have a non-trivial driver which calls dma_set_mask(), we'd be back at square 1 :/ More realistically, I don't think that's viable for ACPI, at least with IORT, since the memory address size limit belongs to the endpoint itself, thus two devices with the same nominal parent in the Linux device model could still have different limits (where in DT you'd have to have to insert intermediate simple-bus nodes to model the same topology with dma-ranges). Plus either way it seems somewhat fragile for PCI where the host bridge may be some distance up the hierarchy. Robin.