Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1154200iob; Sat, 14 May 2022 01:07:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSVn2fAsDPSATMIpvY3StIOK2Cv7UTpnoonj9xVCkmPQ0CcmJstfmODWTG4kFbBqRs4xuq X-Received: by 2002:a5d:47ca:0:b0:20c:72c9:d3be with SMTP id o10-20020a5d47ca000000b0020c72c9d3bemr6752041wrc.114.1652515625285; Sat, 14 May 2022 01:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652515625; cv=none; d=google.com; s=arc-20160816; b=wVeBlsL5LuvFuVxvPyg3Ln6jno2TROnkbRXMSwzVKpf3IJz7jib4R4pQDyFeM1O0GV Io2RFbqbdPO/m4zTEDdx+xye6Hq2JVO+zG8mw/uy36n5/JWKfAe7bXpwt7QKuEi3tiL0 fhYHxThu1hZWJPmocb2/8qUX16Fr+XauY3M6+ghfPZA/IGxtr2mXmhTw0JAjsjN1hTOk mAUmDAUMAJgEGtTSDtNPG4iNp+ukO/lsJDb8eELT/G7JKMYHE93sejJAV7Mm2+XOZK1H dMUdwnDAIXGq9KwjTuVx8rGd4wURYa0UXmOznFOdT6vLeCR1ztoUnNYOzdX20WXdl9mT HFEg== 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=Smlr9WrgSqEh0yFdbUHy8x9Aly8F04o8MiZkKQebJkPx4c+Zkgb+rRUK4dbUCfg8g6 GCsJY7EDMer3jZLry3ZTg/PgBVSh4nwWSYGTM9qUqmyBUdFMZARjqDT5IVI9X8rGj5ro r54NNlxXB2+7diNxI18ghee/SUPKMsMqHqup/7DxaYABxa8MaYF3Ld1Aq7d/igWShxXH EOGZtO5XlvhH5UQ8lLqNs0Y5ewrK+qnupSN5DAIq4njSES6DUkEDMry/ZuOuVJyxyzz/ V78W/tgsI3G9fi/8WgAKR0uZNRv8Opgcbv/d4d8wulB7sltUjch5RnFnhBM6ysAgl9Ri 252Q== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a056000168d00b0020c93ebd66fsi6006603wrd.1046.2022.05.14.01.06.38; Sat, 14 May 2022 01:07:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiENIFF (ORCPT + 99 others); Sat, 14 May 2022 04:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiENIEl (ORCPT ); Sat, 14 May 2022 04:04:41 -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 D5302396A1; Sat, 14 May 2022 01:04:40 -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 6217460B50; Sat, 14 May 2022 08:04:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 959F4C34118; Sat, 14 May 2022 08:04:33 +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 Subject: [PATCH V10 04/22] LoongArch: Add writecombine support for drm Date: Sat, 14 May 2022 16:03:44 +0800 Message-Id: <20220514080402.2650181-5-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220514080402.2650181-1-chenhuacai@loongson.cn> References: <20220514080402.2650181-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 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