Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp195551iob; Mon, 2 May 2022 16:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZtCJwKFsf9eksqN/tp9rvj/qi/E00HgUIT8M7SeUzbjYTrsFuSGD1sknoH4gCkGoG4ako X-Received: by 2002:a17:903:248:b0:155:e8c6:8770 with SMTP id j8-20020a170903024800b00155e8c68770mr13636449plh.129.1651535694182; Mon, 02 May 2022 16:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651535694; cv=none; d=google.com; s=arc-20160816; b=ihHRAP3qBwNGXYesiWkImktFCOKlnb8O37ZzDcj+ZUsPjV4FD1DFAhVlosP1abJKPI 9pF1uQp/xCpvRE067rezwQ9z0aZoU8oEWoXTBEhVdDKSpt7eAuhltW2PYWIG5xd1cRlV LnTd0rkLQgG0Fch/00LaiyBzLz9PJuEA47Kd7aZ+3no50Sm3KJMXicZ652RJ8+Ad1Ll4 +AEbw0pa9///iQCb1mix0dzFWueYyD4cgNqbazXuxVI1bbklJxgx609V9RBcwsTcLTVv hRIFdGRRW1aAFkiHnXo4/XWn3AqkSrZOjPEzTBgbOiFvTAH19OnNGimXhTFZQBqgq1LN ly3A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hyVb68wbRww4yMKVATzeiRvI5ifdVeNLiWVwQarqO5I=; b=JDm/qy90FWPsvN3RFoD48qEXDDLeDt8iAweZrcFJEuV4/vlwlCa56hA1FCWw+kPHgk Nh/uxf2Y5t3US9fMlGAyI64MIYP9k6+yalhqN44329IpfpNwcuEuIUUsv6agmrNlQB/n 2fZ/Ck8xeDqWDMem5w5FmaXg2QErzMP4q17LCSbN90ngIQ/w86zOXnkN8r87mTZ929Re 8hkrB2LgT0D3UNWZ/lhrswhBftKD+5coqdMpTra6A5PMgMrgNdVKH441VxrABs40I7bB QO93z0mGvCq8WfMddiUU0X3cXUtqg+ActDfSqPsaEe7dxNaypTZpZl4oMatYXDzu2P3t X+Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n11-20020a170902f60b00b0015d3a9ee940si15236010plg.149.2022.05.02.16.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:54:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0300A340FA; Mon, 2 May 2022 16:54:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382419AbiD3JMc (ORCPT + 99 others); Sat, 30 Apr 2022 05:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240179AbiD3JMa (ORCPT ); Sat, 30 Apr 2022 05:12:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D2A388B0A; Sat, 30 Apr 2022 02:09:09 -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 ams.source.kernel.org (Postfix) with ESMTPS id E5FE1B81A53; Sat, 30 Apr 2022 09:09:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6E0CC385A7; Sat, 30 Apr 2022 09:08:59 +0000 (UTC) From: Huacai Chen To: Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds Cc: linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li , Yanteng Si , Huacai Chen , Guo Ren , Xuerui Wang , Jiaxun Yang , Huacai Chen Subject: [PATCH V9 04/24] LoongArch: Add writecombine support for drm Date: Sat, 30 Apr 2022 17:04:58 +0800 Message-Id: <20220430090518.3127980-5-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220430090518.3127980-1-chenhuacai@loongson.cn> References: <20220430090518.3127980-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 LoongArch maintains cache coherency in hardware, but its WUC attribute (Weak-ordered UnCached, which is similar to WC) is out of the scope of cache coherency machanism. This means WUC can only used for write-only memory regions. Signed-off-by: Huacai Chen --- drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/ttm/ttm_module.c | 2 +- include/drm/drm_cache.h | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index e957d4851dc0..f024dc93939e 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -69,7 +69,7 @@ static pgprot_t drm_io_prot(struct drm_local_map *map, pgprot_t tmp = vm_get_page_prot(vma->vm_flags); #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \ - defined(__mips__) + defined(__mips__) || defined(__loongarch__) if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) tmp = pgprot_noncached(tmp); else diff --git a/drivers/gpu/drm/ttm/ttm_module.c b/drivers/gpu/drm/ttm/ttm_module.c index a3ad7c9736ec..b3fffe7b5062 100644 --- a/drivers/gpu/drm/ttm/ttm_module.c +++ b/drivers/gpu/drm/ttm/ttm_module.c @@ -74,7 +74,7 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) #endif /* CONFIG_UML */ #endif /* __i386__ || __x86_64__ */ #if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__mips__) + defined(__powerpc__) || defined(__mips__) || defined(__loongarch__) if (caching == ttm_write_combined) tmp = pgprot_writecombine(tmp); else diff --git a/include/drm/drm_cache.h b/include/drm/drm_cache.h index 22deb216b59c..08e0e3ffad13 100644 --- a/include/drm/drm_cache.h +++ b/include/drm/drm_cache.h @@ -67,6 +67,14 @@ static inline bool drm_arch_can_wc_memory(void) * optimization entirely for ARM and arm64. */ return false; +#elif defined(CONFIG_LOONGARCH) + /* + * LoongArch maintains cache coherency in hardware, but its WUC attribute + * (Weak-ordered UnCached, which is similar to WC) is out of the scope of + * cache coherency machanism. This means WUC can only used for write-only + * memory regions. + */ + return false; #else return true; #endif -- 2.27.0