Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1266262lfc; Wed, 1 Jun 2022 13:35:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztpblSht0kCs9C7za9FIt/b52IklZ5G3+/0HpI2HajjDRsPhZMbqV6+VRPKITc/nN/Ad58 X-Received: by 2002:a17:902:d481:b0:162:4f1f:3f82 with SMTP id c1-20020a170902d48100b001624f1f3f82mr1212060plg.52.1654115709099; Wed, 01 Jun 2022 13:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115709; cv=none; d=google.com; s=arc-20160816; b=kE+UjPBCecVkrtg6cRqwT5iUH/k8Qst5AtzmT0LXXU/wzlTe5cAutHBZsj/tfBIxbl cuED8a9ryRAogDc01bcc5tK92zdv7a24AHqz9Xkdyop1sA55xfVa9I1tNfhjXd7SDYQb ykcsZLvyImp2p3sN8F4CEoBcXTd1O6imi5vrqoKh4IChPYGziKBtwOEDAAdZPhVDfI7o UKRe6jle9i1f8k183yN+t/Hu0M7zyvYP9dL+JICcAnw9ZeUEfnj5oupo1Zs9Zr0tmJoy aCk2IfJWu6GGPmnJaXW6+2O4WwlIKtxQpKcy3IyPlLgiO2kD8M/2Q9zNl1/ARVNEdT6d FtXQ== 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=FDlHQSUxoGz9H7FNj3i4m4tHfH/DYa9CjXnViI9Izzs=; b=UL1laZWYfXHyB1wl40DAwj/I1kcSygqpSr/ceXb6HkswfbulD4JZubOhxlCQVpCWgV OFUTZwhuYjaWPhKS1wvDpWM/aEjV095bnubhHWU5XXd2ZWNt3d1GgOX4di/LNdNi49bS F/0Iwc6hM2mZ7mnOv95RXoAku3PXOhsUOn/6p0U12TBVJB4Suxk/L0wVpv9z1jEy3E7Y q4Neo5x58g9Kphgjn+YV5p6G+JDraVePcrBRpwj2HkwJha+wggNGRyrZl8K+ztqn4f4F UR1BqXXRURsGndHqqi9CGZO6BGA03cyHOIF9hzsS3UuZIEyb33Dwt2GedSJl56z5v3cl D2RQ== 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 em21-20020a17090b015500b001df6e5f1985si3042454pjb.120.2022.06.01.13.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:35:09 -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 ABF081D9B79; Wed, 1 Jun 2022 12:45:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351595AbiFAKAx (ORCPT + 99 others); Wed, 1 Jun 2022 06:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351590AbiFAKAu (ORCPT ); Wed, 1 Jun 2022 06:00:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053258B0AF; Wed, 1 Jun 2022 03:00:49 -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 99E1BB81853; Wed, 1 Jun 2022 10:00:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8FA8C385A5; Wed, 1 Jun 2022 10:00:40 +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 , Daniel Vetter , dri-devel@lists.freedesktop.org, WANG Xuerui Subject: [PATCH V12 06/24] LoongArch: Add writecombine support for drm Date: Wed, 1 Jun 2022 17:59:47 +0800 Message-Id: <20220601100005.2989022-7-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220601100005.2989022-1-chenhuacai@loongson.cn> References: <20220601100005.2989022-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: Daniel Vetter 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