Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3688089pxb; Sun, 26 Sep 2021 23:47:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+Gi3Fump2OUdBVfUAylns0FItq1rQL4sv3iBXp2kEFDPTlJTWmF3HpTb4nMNdiqsaxTGe X-Received: by 2002:a17:90a:dc81:: with SMTP id j1mr10684392pjv.155.1632725258221; Sun, 26 Sep 2021 23:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632725258; cv=none; d=google.com; s=arc-20160816; b=uKaCNYAG+Pq94Jam4UMrrZriiI/xtEZ9jQEPXpNH2SQy62APcMN5HBjC8n2d6UVXb8 hLdOiLN8TAVc2s6/bctjOjTw/h3xTLTbsHbX5IGXHyj/zi+b7P76a/UAHJxSdneGI5Wh voYRnjqGhPweZnop8v1RUPI4alSP+mfhdIp5rL1Yw4MhpIolLX09LK4E/7hVaZQjHcY7 oq0ZSCE8qO8VZswv82lg7JNpTLJQjQ9QydWFEug1HjbhLO5dFY23yYTtxcCXTbDYqHVJ gJcBfsrf9YBmZqgdUx/rceugwWyiv1cD+eG+YWJxwhE1aSQL5VyL5iBsTW5p5RNwguGs gJ6A== 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=juCPAS9rt42H3tt+8BZ9+J2od5yOi+mneV/cUzY7ysQ=; b=lBuJOHqSoXEtlrCMEAZd9FLOh3cePqdbbdPcMrq3ZcsJnEo6j+j4ILyIiYbwcun31U 9T/JL+UvK8EKzzeh6piNMZ9/AxWyrdhrDf4lNqUJBXpAKe40sLUNagKffabE4UULFxsz 9EBAoRYskNJuYmUovwGSuyT8yFUvi7WnvIbTXq9Fu5N6Bjx0dYaofRyFmpLOQgerPIqV t5s86EoRoUMbn771KOoTzOMV7cDHDQONzy0lrdzqMOfQ1BLQLiPMrtjb2J5qjYIXp/26 C6m/uoPI/qmWrzzChzCXAhk8WaJoGfBL42eZHAJB1uwCJ4+jeE3bz//xdTltHRpKI3tG PK7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k136si24163595pgc.294.2021.09.26.23.47.26; Sun, 26 Sep 2021 23:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbhI0GsA (ORCPT + 99 others); Mon, 27 Sep 2021 02:48:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:39540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232996AbhI0GsA (ORCPT ); Mon, 27 Sep 2021 02:48:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD37260F4A; Mon, 27 Sep 2021 06:46:18 +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 , Jiaxun Yang , Huacai Chen Subject: [PATCH V4 04/22] LoongArch: Add writecombine support for drm Date: Mon, 27 Sep 2021 14:42:41 +0800 Message-Id: <20210927064300.624279-5-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210927064300.624279-1-chenhuacai@loongson.cn> References: <20210927064300.624279-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 7fcdef278c74..3dc43390e76b 100644 --- a/drivers/gpu/drm/ttm/ttm_module.c +++ b/drivers/gpu/drm/ttm/ttm_module.c @@ -60,7 +60,7 @@ pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp) tmp = pgprot_noncached(tmp); #endif #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 cc9de1632dd3..5c1059435369 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