Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp96733rdg; Tue, 10 Oct 2023 05:27:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5psEwp0doArFiFZ6e+sNsPrePnHvVmyKdXysgbokDETBzdrccOrv8qfQp8Ih5H6cjUiO6 X-Received: by 2002:a05:6358:441d:b0:143:8574:4311 with SMTP id z29-20020a056358441d00b0014385744311mr19821926rwc.12.1696940855064; Tue, 10 Oct 2023 05:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696940855; cv=none; d=google.com; s=arc-20160816; b=vdj8xZGOMxioIus/V//K1HdKkqZZZgeOoGsXPe6fuT84TGbOlcwfh4NO4Rz6wMD9wg HmkzS/d1K9TefeDNxX7rCOUtCXe4GYgbfTRXLMrGtJSRQUUERtB4vzYALRGYAJgr4oi1 XmPupl437DqW32R1eSKWcDvfTpDzPgbRyYiLEa0RzNJ6B00Wdy66Idq83YXsNzGqL+UA Q9p1Px8yt+wkBzztHzJ7sNtS/J3wAd+/u4OgB55Ap6QTR1Xr8n8KTfiqWSL90Ylb3YBK 2+e05OgoeEbwonFaCPObICNgi6Zjd8PWD9t88X9S/ubZF58ZFd7a76uBaww0vq7+vGbU cWvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:autocrypt:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=6jeJ9eqyX8x4lwTm6Hsdmir5FdBasfUA+Ua2MXOHrko=; fh=D6fQlISpfmXbTy7HXJFRYXkNw9DL3oF8KoP+AKmc9iA=; b=xq6T5tGA2VfurmDNkTXSzYN8uNthDRqvYCprcQ08KrFBhd7+sK2rvlMPRiNsNQoF4x 8Of2acIUO9CCGSslkxwftrmvir4wiDrbtHCTLjfe0skuQ3djigdFGMXTaqvCnmfMGQs9 0pUm95e46LdEWdt5N974XiLMYhCkJ3YkR2qZIIFfUj6ALUKToFoMoQMwK9Wyr5InEiHB weq8Hfha/qRDI7hKLJBKYAY9cb3mQbXNbG6ZLGZKQpqDsWMkREH+zaQAIhTe5nRL18n1 U35mupZnZiUo46n8hJ0RjzfOEVYFvqvIVqW216lK2ViWcTcoJZNlRgjx2lscbDpfHylG NwFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=an2pRto4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x5-20020a654145000000b0059779ae589dsi3603035pgp.828.2023.10.10.05.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:27:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=an2pRto4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AED5E8374CB3; Tue, 10 Oct 2023 05:27:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbjJJM1O (ORCPT + 99 others); Tue, 10 Oct 2023 08:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbjJJM1N (ORCPT ); Tue, 10 Oct 2023 08:27:13 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DC36A9 for ; Tue, 10 Oct 2023 05:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1696940825; bh=BLQz0b68UI9xKLLuezR5Ro6in6MfcDCmm75k9I9eZJc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=an2pRto4L/7BLmClMTvjeW3qmgUeuVqknrB8vMq/5uVvQx3YBkRY4yqCac982+n/p r5LRIJnt07VsgTcfsBfA/HnM9pzeNIC6fs9da6FKd8y6MppJ0tUVkzR/Usxkw5dFXw kG9sXOrRUZBrFAcWMIvNDI6CorO8FZgMXVm43Ryo= Received: from [192.168.124.13] (unknown [113.140.11.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id DCE0B66B2D; Tue, 10 Oct 2023 08:27:01 -0400 (EDT) Message-ID: <8373ccfd93b0402caf9f5c06a2d9b93b3c0d0b49.camel@xry111.site> Subject: Re: [PATCH v2] loongarch/mm: disable WUC for pgprot_writecombine as same as ioremap_wc From: Xi Ruoyao To: Sui Jingfeng , WANG Xuerui , Icenowy Zheng , Huacai Chen Cc: Andrew Morton , Weihao Li , "Mike Rapoport (IBM)" , Jun Yi , Baoquan He , "Matthew Wilcox (Oracle)" , David Hildenbrand , Hongchen Zhang , Binbin Zhou , Zhen Lei , Tiezhu Yang , Thomas Gleixner , Zhihong Dong , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Date: Tue, 10 Oct 2023 20:26:59 +0800 In-Reply-To: <3641d3fe-c2e7-868f-ab0d-3951c9a78b6d@loongson.cn> References: <20231009042841.635366-1-uwu@icenowy.me> <4f1af31b-15be-cb47-6b34-45de1b5696be@loongson.cn> <42b0e6f6-c2b5-49c6-b1f2-0200bef913da@xen0n.name> <3641d3fe-c2e7-868f-ab0d-3951c9a78b6d@loongson.cn> Autocrypt: addr=xry111@xry111.site; prefer-encrypt=mutual; keydata=mDMEYnkdPhYJKwYBBAHaRw8BAQdAsY+HvJs3EVKpwIu2gN89cQT/pnrbQtlvd6Yfq7egugi0HlhpIFJ1b3lhbyA8eHJ5MTExQHhyeTExMS5zaXRlPoiTBBMWCgA7FiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQrKrSDhnnEOPHFgD8D9vUToTd1MF5bng9uPJq5y3DfpcxDp+LD3joA3U2TmwA/jZtN9xLH7CGDHeClKZK/ZYELotWfJsqRcthOIGjsdAPuDgEYnkdPhIKKwYBBAGXVQEFAQEHQG+HnNiPZseiBkzYBHwq/nN638o0NPwgYwH70wlKMZhRAwEIB4h4BBgWCgAgFiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwwACgkQrKrSDhnnEOPjXgD/euD64cxwqDIqckUaisT3VCst11RcnO5iRHm6meNIwj0BALLmWplyi7beKrOlqKfuZtCLbiAPywGfCNg8LOTt4iMD Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.0 MIME-Version: 1.0 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 05:27:32 -0700 (PDT) X-Spam-Level: ** On Tue, 2023-10-10 at 11:02 +0800, Sui Jingfeng wrote: >=20 > On LoongArch, cached mapping and uncached mappings are DMA-coherent and g= uaranteed by > the hardware. While WC mappings is *NOT* DMA-coherent when 3D GPU is invo= lved. Therefore, > On downstream kernel, We disable write combine(WC) mappings at the drm dr= ivers side. Why it's only an issue when 3D GPU is involved? What's the difference between 3D GPUs and other devices? Is it possible that the other devices (say neural accelerators) start to perform DMA accesses in a similar way and then suddenly broken? > - For buffers at VRAM(device memory), we replace the WC mappings with unc= ached mappings. > - For buffers reside in RAM, we replace the WC mappings with cached mappi= ngs. >=20 > By this way, we were able to minimum the side effects, and meet the usabl= e requirements > for all of the GPU drivers. AFAIK there has been some clear NAK from DRM maintainers towards this "approach". So it's not possible to be applied upstream. > For DMA non-coherent buffers, we should try to implement arch-specific dm= a_map_ops, > invalidate the CPU cache and flush the CPU write buffer before the device= do DMA. Instead > of pretend to be DMA coherent for all buffers, a kernel cmdline is not a = system level > solution for all of GPU drivers and OS release. IIUC this is a hardware bug of 7A1000 and 7A2000, so the proper location of the workaround is in the bridge chip driver. Or am I misunderstanding something? --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University