Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2483048pxb; Mon, 18 Jan 2021 20:44:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXABVS7JOFOqvKjV2D08fYfIgAM7hYUA35bXEn1r4kFO1omTF7i4DkAWbEf83f3FvleePU X-Received: by 2002:aa7:d489:: with SMTP id b9mr1996726edr.374.1611031495352; Mon, 18 Jan 2021 20:44:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611031495; cv=none; d=google.com; s=arc-20160816; b=V8rpTXUV5BQ4q0N13U/b5wGcWwS+pU3qYhxbU1kjH5pFNXBGmnHvYd1dey5S25P9UV lJdVTu5ZaQ6ynm22Y+oURT+nVxydHEdUA3NF8NikTKLUcxeFurRX1f+PCP2G08aOi8pc fCpNnDnZLJOI0RHZPT+oHav8POqx5i1Ws0sM8G+x173c2rVySncBshsycPawywCjWqAZ LNgvY6wANu5m12dxTcs1OSbUnWzMRHyyTlYuNn074hHJyXe/a3T51K1hyy8Zu/Meo+eD uZk7ZC4K8kt9jbyDlTuyF1sHzv0X+C4M6mM7HyOX+5JEIjqleyS70iPUoFRcg61td367 rJGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=VVpaOYyT/WX2JWWctve7GaYsStF3c2VgxUY0h+HlUuo=; b=OwDZ559z8xZACeDnoprBQv8xxOI3TGUVvdElJBMYcbyJZEMYJ3jAr0sbK2138Exd7H AiAe6YH11pHAoIBfzgrwaSdt+A0h1GVEV72UaoQV/lmwRqXbrCDU3oOn9gWMyxaAoRfT sNhK0VZN7VbDmAdQvmt5a88+1SzqwoOXRARicr1kl/khIfWh6SLnkCAmFVFQhdPDS1iT jNmRZCUk9/yuoa0D+s9YgHgM57mbmHyu7rMxA9kDKDuZQE2R9sz1eY9OKndaDD2tX/79 ixTN5kZdXjDkdaQDPwjW5SaDGK+zZn02Au/ts1tFa+XJPkGc4iAOiunz9zbHxehnR0Sj mIPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce15si2103273edb.546.2021.01.18.20.44.32; Mon, 18 Jan 2021 20:44:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405990AbhARPwL (ORCPT + 99 others); Mon, 18 Jan 2021 10:52:11 -0500 Received: from foss.arm.com ([217.140.110.172]:38298 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390778AbhARPt4 (ORCPT ); Mon, 18 Jan 2021 10:49:56 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2B7641FB; Mon, 18 Jan 2021 07:49:09 -0800 (PST) Received: from [10.57.39.58] (unknown [10.57.39.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 559E53F68F; Mon, 18 Jan 2021 07:49:06 -0800 (PST) Subject: Re: [PATCH v6 06/33] of/device: Move dma_range_map before of_iommu_configure To: Yong Wu , Rob Herring Cc: youlin.pei@mediatek.com, devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, chao.hao@mediatek.com, Will Deacon , Frank Rowand , linux-kernel@vger.kernel.org, Evan Green , Tomasz Figa , iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski , Matthias Brugger , anan.sun@mediatek.com, linux-arm-kernel@lists.infradead.org, Paul Kocialkowski References: <20210111111914.22211-1-yong.wu@mediatek.com> <20210111111914.22211-7-yong.wu@mediatek.com> <20210114192732.GA3401278@robh.at.kernel.org> <1610688626.4578.1.camel@mhfsdcap03> From: Robin Murphy Message-ID: <1853732d-0efd-171e-9e1f-7ee7ed72a98f@arm.com> Date: Mon, 18 Jan 2021 15:49:06 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <1610688626.4578.1.camel@mhfsdcap03> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-15 05:30, Yong Wu wrote: > On Thu, 2021-01-14 at 13:27 -0600, Rob Herring wrote: >> On Mon, Jan 11, 2021 at 07:18:47PM +0800, Yong Wu wrote: >>> "dev->dma_range_map" contains the devices' dma_ranges information, >>> This patch moves dma_range_map before of_iommu_configure. The iommu >>> driver may need to know the dma_address requirements of its iommu >>> consumer devices. >>> >>> CC: Rob Herring >>> CC: Frank Rowand >>> Signed-off-by: Yong Wu >>> --- >>> drivers/of/device.c | 3 ++- >>> 1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/of/device.c b/drivers/of/device.c >>> index aedfaaafd3e7..1d84636149df 100644 >>> --- a/drivers/of/device.c >>> +++ b/drivers/of/device.c >>> @@ -170,9 +170,11 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, >>> dev_dbg(dev, "device is%sdma coherent\n", >>> coherent ? " " : " not "); >>> >>> + dev->dma_range_map = map; >>> iommu = of_iommu_configure(dev, np, id); >>> if (PTR_ERR(iommu) == -EPROBE_DEFER) { >>> kfree(map); >>> + dev->dma_range_map = NULL; >> >> Not really going to matter, but you should probably clear dma_range_map >> before what it points to is freed. >> >> With that, >> >> Reviewed-by: Rob Herring > > Thanks for the review. I will move it before "kfree(map)" in next > version. Paul noticed that we already have a bug in assigning to this unconditionally[1] - I'd totally forgotten about this series when I theorised about IOMMU drivers wanting the information earlier, but sweeping my inbox now only goes to show I was right to think of it :) We should really get something in as a fix independent of this series, taking both angles into account. Robin. [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be097c7ceb32@arm.com/ >> >>> return -EPROBE_DEFER; >>> } >>> >>> @@ -181,7 +183,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, >>> >>> arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); >>> >>> - dev->dma_range_map = map; >>> return 0; >>> } >>> EXPORT_SYMBOL_GPL(of_dma_configure_id); >>> -- >>> 2.18.0 >>> > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu >