From patchwork Wed Oct 19 08:32:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp223614wrs; Wed, 19 Oct 2022 02:37:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jW+aPrveF2ow0kgakceYCQq8I+VNqzVGj4Jvf28eliewPSDG7EcqqnRtW1l2y4k1D6g0W X-Received: by 2002:a05:6a00:acc:b0:530:e79e:fc27 with SMTP id c12-20020a056a000acc00b00530e79efc27mr7792178pfl.61.1666172279193; Wed, 19 Oct 2022 02:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172279; cv=none; d=google.com; s=arc-20160816; b=qc2S0AcAS1xGgCgF3gLc298haoVLj02dGi9C8vz/0qChpuoaJmhtKKD5+6iUMeerUF DEB/2lOqG5MY5h8eC1O5c4tWFRwOIN1m1reO0iFQOLV0uwZMXUtGc2gMAO+3w+2U6ScO UXCZnYvmmC5BhZlhQuBEpi+2zewi92U8WYboP+hCLHvzjtgcbIoDPYdezPVUS90hVZvt 7h/2dIcNKX81VGYms8UPaxgEJc9uveP695rLQdzpi0A7I0i5YWMR0TD8T1N3o/uxP3wM r9MssTDxd32X1YTXFf8UJ3GeL24zIgxqpKpyXk7BXkypyOnwUko7TDEw5mFOopY/zDqE puMw== 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=Nn1bq1XydD7Av+Tg0eY7e6rQp/IqgnDFMJNB5XDygVc=; b=nfWE7kUZ+jJMaqEI7MHixwXC5josuOn8drZnAVAnK1htCAeI0VEcwkLrh2jNn+zn/Z RyoN5Rb0Huf20LRAwl9LEvZJxYalLEjCcbbwIwRJjCtgZPyU9EhHmTPfArIrOr73KavX vKVUHRpDL5e6fZyoaqoS4fd4v//KDi+KW3p7TvKq5o55sTF/kcGo5aqAucg2l0fPOFRj WhakJGFmGwTks/t3M6XPgdG69knIwCVgngeJc+h4sEFQNQ47rb1UuN2DOFT8g3HhTVU8 UY7XbgTySLPodsMVnG7RU9Z7yXl/3VyMNvA6CS5oM3UA3JA5uFqGGpJp9+HguNFoRvyN G+mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FeNp7U5k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a630c10000000b0043ce223c86dsi19838951pgl.843.2022.10.19.02.37.44; Wed, 19 Oct 2022 02:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FeNp7U5k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233481AbiJSJZi (ORCPT + 99 others); Wed, 19 Oct 2022 05:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233675AbiJSJYZ (ORCPT ); Wed, 19 Oct 2022 05:24:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDFE2C4D9A; Wed, 19 Oct 2022 02:11:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C597B61750; Wed, 19 Oct 2022 09:07:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD321C433D7; Wed, 19 Oct 2022 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170449; bh=CDFKxDXed4seug1ukSk9Zm+SmC8qh5flXF0DuqIbwBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FeNp7U5kpEwGIQSux/oUB7J9rZ1sgOgQJ+3A/cQqS7aS4e13GoNXxTYzfK3Qmz5uT c7G2ThgjRlE1UoZxg3o570gtgCgtXdAW4TsMx6lDTTf31b+K+5hRUp1ezG3uNs+21v 6T73J3U44xhRWO4EX8OHrC/fTOHLsdWGKuDGf8tk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Christoph Hellwig , "Russell King (Oracle)" , Sasha Levin Subject: =?utf-8?b?W1BBVENIIDYuMCA2NTkvODYyXSA9P1VURi04P3E/QVJNL2RtYS1tYXBw?= =?utf-8?b?PUQxPTk2bmc6PTIwZG9udD0yMG92ZXJyaWRlPTIwLT5kbWE9NUZjb2hlPz0gPT9V?= =?utf-8?b?VEYtOD9xP3JlbnQ9MjB3aGVuPTIwc2V0PTIwZnJvbT0yMGE9MjBidXM9MjBub3Rp?= =?utf-8?b?Zmllcj89?= Date: Wed, 19 Oct 2022 10:32:26 +0200 Message-Id: <20221019083319.087440003@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747108263458293945?= X-GMAIL-MSGID: =?utf-8?q?1747108263458293945?= From: Christoph Hellwig [ Upstream commit 49bc8bebae79c8516cb12f91818f3a7907e3ebce ] Commit ae626eb97376 ("ARM/dma-mapping: use dma-direct unconditionally") caused a regression on the mvebu platform, wherein devices that are dma-coherent are marked as dma-noncoherent, because although mvebu_hwcc_notifier() after that commit still marks then as coherent, the arm_coherent_dma_ops() function, which is called later, overwrites this setting, since it is being called from drivers/of/device.c with coherency parameter determined by of_dma_is_coherent(), and the device-trees do not declare the 'dma-coherent' property. Fix this by defaulting never clearing the dma_coherent flag in arm_coherent_dma_ops(). Fixes: ae626eb97376 ("ARM/dma-mapping: use dma-direct unconditionally") Reported-by: Marek BehĂșn Signed-off-by: Christoph Hellwig Reviewed-by: Russell King (Oracle) Tested-by: Marek BehĂșn Signed-off-by: Sasha Levin --- arch/arm/mm/dma-mapping.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 089c9c644cce..bfc7476f1411 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1769,8 +1769,16 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { } void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, const struct iommu_ops *iommu, bool coherent) { - dev->archdata.dma_coherent = coherent; - dev->dma_coherent = coherent; + /* + * Due to legacy code that sets the ->dma_coherent flag from a bus + * notifier we can't just assign coherent to the ->dma_coherent flag + * here, but instead have to make sure we only set but never clear it + * for now. + */ + if (coherent) { + dev->archdata.dma_coherent = true; + dev->dma_coherent = true; + } /* * Don't override the dma_ops if they have already been set. Ideally