Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp986406rdb; Wed, 1 Nov 2023 08:17:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHd7OGN+QKl8kjSLZ3QrY1MwelyrJ6negruzEqQNsOGHedjxs1s2/XQ0d5D2LqB0vq7Afy7 X-Received: by 2002:a92:d709:0:b0:359:42fc:41ce with SMTP id m9-20020a92d709000000b0035942fc41cemr1874404iln.18.1698851854968; Wed, 01 Nov 2023 08:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698851854; cv=none; d=google.com; s=arc-20160816; b=AnzM2DbnjBMsDlrkZsEXz9NBmVOHUHtFIbru7wWibq3OKcvrdnkVTlVTmF6CbDJk6S x3Oka7G0Sdq3c9KjtKoV+jxfEXbkNpZrpfDhaDMujYTJ+E4FrhPpShxTTmlS7M9s16RQ ng5zEKcwbCRZ5ABayk7tbLV4M06PNpVUxmia/PAw0s5DPmJKJpVLM4zkBVv3Zeyfjyxa x8Kv4T1SuT3O/Nc2tXIw9MpMHnfz2WSb0W/nzMpwDXVIISuKZjnX8JbQj+NwYpqjOQbC XrEpg16Kh1tiiPb+XYrYztx34S8seCCP7Hw7rjwy0VPG2j/UxLlCeq7+nmb2cOEjzfr0 8rvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :feedback-id:dkim-signature:dkim-signature; bh=mi/1bIt+Wi3Xu7dZdtAdadElR9m1kdodNDSn+OFK8VA=; fh=7IIVG7Z5uBUiGqF92YYc9bge9oWMe+bYNkQEjjS1HU8=; b=oK0Guyo8PNIr5V1N4TVB7r/cngbzlytX7fYbkv3hBb2l4f4/ICwo3+nEbEQs6rMP/M ZHE+J10WkbqDZDNWYSy8KHu4nYpFWkJaFsTc6b7Ay2q7KlcpRaSR++HscBCCsEL35Y6w rzyEO8hyO5+K3sxqPhgTnVoC1qkaoCynKzb/Uk4s0AVJHfOMPR9rXA6zi5x0r7GltUNE mQQbzqfin8nc/DZwOkNIiod6vd6CVAJhX65yNQClSzP96QgQLX7rLfjTnIGZhoMAkXl7 xyHVPij5Vo7oeC0uTAHMntKdOGKN5q7HEoXSTOwVlsf2vXqGNdkMYDeZPIBjqXSDAIs4 Nu5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=ajhg2tQd; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=rV5qMkzf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id cl6-20020a056a02098600b005acd5108042si85612pgb.521.2023.11.01.08.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 08:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=ajhg2tQd; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=rV5qMkzf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F02E9812A94C; Wed, 1 Nov 2023 08:17:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233946AbjKAPR0 (ORCPT + 99 others); Wed, 1 Nov 2023 11:17:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233622AbjKAPRU (ORCPT ); Wed, 1 Nov 2023 11:17:20 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C27D12F; Wed, 1 Nov 2023 08:16:48 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 767B45C0272; Wed, 1 Nov 2023 11:16:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 01 Nov 2023 11:16:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1698851807; x=1698938207; bh=mi/1bIt+Wi3Xu7dZdtAdadElR9m1kdodNDS n+OFK8VA=; b=ajhg2tQdp2pNsnNcvSch/5K7YmLxTP/ZUdoW3WE20Kp9ybXnZbq f6Ik7Kt/qypiKrcHNQJkg7h4GkXFBBvwod619VGA1oH/VgKfZ/ouf0ZtzkHNcvoK ZGWb2GKslkvjOe2u6VnDsRMHFTut6GA52tFx2BOQMqCZBtw4kZEf+xsGv8UFLfXK e073r8CM7rBtpgZzrp+R6xPceqr5QxbvLjeKk0oF+w4CWHqXo8ZmE7O4cu/vwnCP DEsIgtOWcN1WN+HAWYNbsvr1p8nD53nQ7OedctrQacAr5P8OhYOTGKn80S3JA4lz 3AGWjCeJ5+hL1CXd5Wr/Pd7Ijh6oe6l4aXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1698851807; x=1698938207; bh=mi/1bIt+Wi3Xu7dZdtAdadElR9m1kdodNDS n+OFK8VA=; b=rV5qMkzfb1iSOJtDx7GwG3ghF6+egzjgEXc8FSLp0cVfHoemdhp 9kFbmgCC0F+C+VE5YJeVZxpBHCyvvqRiDfUayLS58vK5QVwldzN73962d8fcpoQ/ Hbb33z82xCumuq5Hrqe9yzyvy+Vxy9lWQcObOXX0NBALr1ianPY6H2ADifKRv2rm NsmRiDbX62XCzavxRbGV2FwROqVewYZpv9N2tHkKFYL+ye9hqjq413U9uqO2ZPrG BFUJyEafnFu/aioW+WhsU4Vx8B39OjLJ91g+RrweyPbRGK68+wSpWPeB20998sbj K7ztSW/OydIFyOcwtRrneKJLEVTcKzKmvVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddtgedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 1 Nov 2023 11:16:46 -0400 (EDT) From: Jiaxun Yang Date: Wed, 01 Nov 2023 11:39:08 +0000 Subject: [PATCH fixes 2/3] MIPS: Loongson64: Enable DMA noncoherent support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231101-loongson64_fixes-v1-2-2a2582a4bfa9@flygoat.com> References: <20231101-loongson64_fixes-v1-0-2a2582a4bfa9@flygoat.com> In-Reply-To: <20231101-loongson64_fixes-v1-0-2a2582a4bfa9@flygoat.com> To: Thomas Bogendoerfer Cc: Huacai Chen , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang , stable@vger.kernel.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 08:17:34 -0700 (PDT) There are some Loongson64 systems come with broken coherent DMA support, firmware will set a bit in boot_param and pass nocoherentio in cmdline. However nonconherent support was missed out when spin off Loongson-2EF form Loongson64, and that boot_param change never made itself into upstream. Support DMA noncoherent properly to get those systems work. Cc: stable@vger.kernel.org Fixes: 71e2f4dd5a65 ("MIPS: Fork loongson2ef from loongson64") Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig | 2 ++ arch/mips/include/asm/mach-loongson64/boot_param.h | 3 ++- arch/mips/loongson64/env.c | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 76db82542519..797ae590ebdb 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -460,6 +460,7 @@ config MACH_LOONGSON2EF config MACH_LOONGSON64 bool "Loongson 64-bit family of machines" + select ARCH_DMA_DEFAULT_COHERENT select ARCH_SPARSEMEM_ENABLE select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO @@ -1251,6 +1252,7 @@ config CPU_LOONGSON64 select CPU_SUPPORTS_MSA select CPU_DIEI_BROKEN if !LOONGSON3_ENHANCEMENT select CPU_MIPSR2_IRQ_VI + select DMA_NONCOHERENT select WEAK_ORDERING select WEAK_REORDERING_BEYOND_LLSC select MIPS_ASID_BITS_VARIABLE diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index 035b1a69e2d0..c454ef734c45 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -117,7 +117,8 @@ struct irq_source_routing_table { u64 pci_io_start_addr; u64 pci_io_end_addr; u64 pci_config_addr; - u32 dma_mask_bits; + u16 dma_mask_bits; + u16 dma_noncoherent; } __packed; struct interface_info { diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index c961e2999f15..df0e92cd3920 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -13,6 +13,8 @@ * Copyright (C) 2009 Lemote Inc. * Author: Wu Zhangjin, wuzhangjin@gmail.com */ + +#include #include #include #include @@ -147,8 +149,13 @@ void __init prom_lefi_init_env(void) loongson_sysconf.dma_mask_bits = eirq_source->dma_mask_bits; if (loongson_sysconf.dma_mask_bits < 32 || - loongson_sysconf.dma_mask_bits > 64) + loongson_sysconf.dma_mask_bits > 64) { loongson_sysconf.dma_mask_bits = 32; + dma_default_coherent = true; + } else + dma_default_coherent = !eirq_source->dma_noncoherent; + + pr_info("DMA coherent: %s\n", dma_default_coherent ? "on" : "off"); loongson_sysconf.restart_addr = boot_p->reset_system.ResetWarm; loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown; -- 2.34.1