Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp725094pxb; Tue, 2 Feb 2021 16:48:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+70/WgF7mNcjswUpQV4my15SG2YnSS4hM/8UPT+0+CPw0qOxknD7B3aMPOeFzwym10tW/ X-Received: by 2002:aa7:cdc7:: with SMTP id h7mr630846edw.353.1612313286795; Tue, 02 Feb 2021 16:48:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313286; cv=none; d=google.com; s=arc-20160816; b=t4ifrLUUwyBNcvlmF7Emitmbb7djSl2Q+kNyt10hTVpWvkr63LSo3DTNggUuHqiJLI 1UiN2r25hM7SNyoRHzFfYjDRR53qpKfOp6Rb/M2kX/C9HHA+oEjOZ6/RgL/zLcNy4aFk ZK63XEuClb+emR594QzMHmCP+1rQJj8hCMd1Vgdjsh9MmsX1Lfvq4zh6tpJ/w7lP5Ntw 17V61nzZrfLU/IhDaQAb2AsE6EDEoYYzPUAQDLCAOLFZ9YTwOpVe2ejiMzosEOvMjeXK cmFnZNajotPXvZQA4bkdkvMe3gSMfE0ceFLRPdc7rZ2dI4lzRLn90936hysjJKwh5hAO O6pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UkM6t4GTwTXyB/EAbrRCzoxmp7JglTXE/bGEbcRa/3g=; b=oIZnBWR7sLhEMaW5nzjs88t3NcPzd2Vxzs452Gb5n79/1phL6HCsDYXn3HLuwqSn1D wMx7+lCsixJgTpYwoA4UP29cMtWKYODVDKuJPEm4fMQ8TWucFMusSe2fqDq+DijzQErs R9/fXA7lfti6ta328EWbge00S+vvcjEnYIEpkPEHCjRNDbkOeGKmHjM2GwSBxpeascVj rjiHfNc1Dw3WMh9moiO2HRD4UuzPMrAzRyZB1r0Gd5chNWNEbJO48zZ1hxf0fk0wcAk2 j0l+j7qbaIbyyxCYFUng1uSOk+8hl+j+BjyP8fF8BgKwKP6j0ziGaeAXnq4MjO5c6+Ss OMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dKHza6Lq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si241348edw.42.2021.02.02.16.47.41; Tue, 02 Feb 2021 16:48:06 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dKHza6Lq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239810AbhBBThw (ORCPT + 99 others); Tue, 2 Feb 2021 14:37:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:45012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbhBBNzs (ORCPT ); Tue, 2 Feb 2021 08:55:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 461CC64F6D; Tue, 2 Feb 2021 13:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273490; bh=na+4D5poYsMqroUihQDj3Ziyc+EQ/HWCRjKo6etYIgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKHza6LqdKdSioaaW9L2vI6+sXwgCceudOa0ovbbXdP+Ygx+uLx/FJwfQA9DkkNLM GiQSxiM0AUuKbmS1xkMJiArlc/o2M/BwH/p7eA+y9OKlgizwuyFQ3Ou1SIJo3uaOd1 fMxovJEyOQ0nTUp7UVm//RDCeipF/rtHyXruqzIg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Rowand , Robin Murphy , Yong Wu , Paul Kocialkowski , Rob Herring , Sasha Levin Subject: [PATCH 5.10 127/142] of/device: Update dma_range_map only when dev has valid dma-ranges Date: Tue, 2 Feb 2021 14:38:10 +0100 Message-Id: <20210202133002.937091939@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yong Wu [ Upstream commit 89c7cb1608ac3c7ecc19436469f35ed12da97e1d ] The commit e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset") always update dma_range_map even though it was already set, like in the sunxi_mbus driver. the issue is reported at [1]. This patch avoid this(Updating it only when dev has valid dma-ranges). Meanwhile, 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. [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be097c7ceb32@arm.com/ CC: Frank Rowand Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset"), Suggested-by: Robin Murphy Signed-off-by: Yong Wu Signed-off-by: Paul Kocialkowski Reviewed-by: Rob Herring Reviewed-by: Robin Murphy Signed-off-by: Rob Herring Link: https://lore.kernel.org/r/20210119105203.15530-1-yong.wu@mediatek.com Signed-off-by: Sasha Levin --- drivers/of/device.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index aedfaaafd3e7e..1122daa8e2736 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, mask = DMA_BIT_MASK(ilog2(end) + 1); dev->coherent_dma_mask &= mask; *dev->dma_mask &= mask; - /* ...but only set bus limit if we found valid dma-ranges earlier */ - if (!ret) + /* ...but only set bus limit and range map if we found valid dma-ranges earlier */ + if (!ret) { dev->bus_dma_limit = end; + dev->dma_range_map = map; + } coherent = of_dma_is_coherent(np); dev_dbg(dev, "device is%sdma coherent\n", @@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, iommu = of_iommu_configure(dev, np, id); if (PTR_ERR(iommu) == -EPROBE_DEFER) { + /* Don't touch range map if it wasn't set from a valid dma-ranges */ + if (!ret) + dev->dma_range_map = NULL; kfree(map); return -EPROBE_DEFER; } @@ -181,7 +186,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.27.0