Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3165854pxb; Tue, 12 Oct 2021 23:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0CvrxrHAdqSsncBL6yxKmJcBRz1FLVXCOF1iBKBSF9+sxwbg0Jh0c3e5D5rDzzWaj5Z9T X-Received: by 2002:a17:906:a0d7:: with SMTP id bh23mr9996031ejb.82.1634107387207; Tue, 12 Oct 2021 23:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634107387; cv=none; d=google.com; s=arc-20160816; b=qrLLwpw5lUqiyBTbN/aBNtO6TGsz8oWmMGaUfWa2sV6mV+DAuqqmLDgGazF8P0+535 WH4FKtPkFZO1U0OQ3RoflngVtB2AM2O5jhxzw3UabU3rTZQ2bT8vau9YUkX/Mez7lFHx rc2lnDmm2uu7RTUHxwv9eApdbvZsgusrNOthxAL7+ZQ8DH+AfbSsMk0/EKdSMSWoagw7 B2wQtDVsPuvMBxrOySD3/sTTDtNEVHvbUL6xqZ0bTIxVsk2kEiwY0uuS+w/A947eePXN CQNW0A16yTeyF6GD/41IAurMaBj1ifba0xsMUXvVPRMnxHly88uKcDoX/ZWCm5nLVP0S jI9w== 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=JFKXpjkDhtVnm6IkJkdjYKakqOtPLgYi0aNPdA2rWjTQYJrUQS0quIAK3Ej+BcqFY3 R8co9RGGQ0tq8MrXK0GdNOI7aLPeNdv6j50k5fDGmsaSlZn8gW0x47cd8a8TD3AzDdgR i2KvaH2UpISqUzZZ6UaKzipBpJkrLGyL5GzF9GIMmX9DsBCOqCMvDxs7YeK/hQiN25Kz ix6IKh5ctYhfChNj5puIPYGpKqYh4Qzm49yG1ujBGgoC4S9dm+qt3etJJETqMVpzuIoq BiXDg7DenPmAGL5pyw3uTKU0y1pJm/+X5YN41LamqDw/tQUOdDbzE+jkcPF0iY+9xlfB 0LCA== 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 u20si17057079edv.439.2021.10.12.23.42.41; Tue, 12 Oct 2021 23:43:07 -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 S237918AbhJMGnE (ORCPT + 99 others); Wed, 13 Oct 2021 02:43:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:39678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230138AbhJMGnD (ORCPT ); Wed, 13 Oct 2021 02:43:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 417EA60FDC; Wed, 13 Oct 2021 06:40:57 +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 V5 04/22] LoongArch: Add writecombine support for drm Date: Wed, 13 Oct 2021 14:36:38 +0800 Message-Id: <20211013063656.3084555-5-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211013063656.3084555-1-chenhuacai@loongson.cn> References: <20211013063656.3084555-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