Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp309244iob; Wed, 18 May 2022 02:41:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztG3rZInOE0loreZU4i4pIZ1cO5aH7aybS0g0OE98KI1Ycvo/kR6FUSpwr1y+a7APNtDhZ X-Received: by 2002:a17:902:7781:b0:161:c85a:8fff with SMTP id o1-20020a170902778100b00161c85a8fffmr1731131pll.97.1652866909747; Wed, 18 May 2022 02:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652866909; cv=none; d=google.com; s=arc-20160816; b=rQ2b+XGotvoLZI/Y0LcVpTOcXbk6m7A9dCTrD+x1SDnxKH2354oxQh0Vioqs0iPnlt bRVkcS2bhK+kIl1nXierED/9qKyeia7j1BRuVvJ6PYWMJOIg9zfKIzpnb2JSSNZUPlpP Tr7Qje1GAmNK1PsKf0Jo6SLI8O0InP/wuN1smh/nKn95mQ+/zRowsmBXv9W34hZREgl2 t3UKQdJg6sicbB00vlerufxxZlbm7GmUtYSH2E0b9zwPOg3mHjn6WL9DDGQzWgqvo0z3 yVkny4WSa+DyUOKaHJ/o8S/TUosygSXnF/RQeDQX2PFVlJJ4aOtUHKXklzm4H517SGy8 rGIQ== 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=82ZtAFUWhjLh8m4Glj8YijSQTJ7FXBlxIQLyezWCCTE=; b=ZmOhb7h653j8hPRQfGqT6RQxiLaqpre2jZ0omaYQE4oEV+6zd+4k3eghKzBiEzcoGA wiHxxmBt3L0Jw+GKWBquHYMXEPQSyO7u3bDmzEjxBF3TDU6b7m6jsZivpxTwUnCEjVZc bCrrovzLvTzTR0uSyZMrdR3N5Tlwl5ZDFGQGNKVFwPjvF2YQe850UFkxylW2gZKUuRBe oNYA1TBxascIClzP2BetmMtqsx6EkdjwrYteGOqr/hcqxRAhRqbgD7dDYhn4ZuxyE2UA KbF0huyVEBwHsw6CJ3tMJvTVWOjMbmT0c969L0Q+e6KLGmxtcgRqDIpvB0o+PpUtDXtA y/ow== 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 q4-20020a656844000000b0039cf337f6c6si1790715pgt.546.2022.05.18.02.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:41:49 -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 41C2D5F9C; Wed, 18 May 2022 02:30:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234270AbiERJaR (ORCPT + 99 others); Wed, 18 May 2022 05:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234268AbiERJaP (ORCPT ); Wed, 18 May 2022 05:30:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC7D62DDC; Wed, 18 May 2022 02:30:06 -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 6E11DB81EEF; Wed, 18 May 2022 09:30:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F46DC385A5; Wed, 18 May 2022 09:29:58 +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 , Stephen Rothwell , Huacai Chen , dri-devel@lists.freedesktop.org, WANG Xuerui Subject: [PATCH V11 04/22] LoongArch: Add writecombine support for drm Date: Wed, 18 May 2022 17:26:01 +0800 Message-Id: <20220518092619.1269111-5-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220518092619.1269111-1-chenhuacai@loongson.cn> References: <20220518092619.1269111-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. Cc: dri-devel@lists.freedesktop.org Reviewed-by: WANG Xuerui 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