Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2729140rwd; Fri, 26 May 2023 10:18:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7oVKAp3T4QYsOiVSRcmtYdExdshvITRyi4HShaKehAV3+Rm5Ojx1TVr/VrsfcIbQfxRRf3 X-Received: by 2002:a17:902:e542:b0:1ad:f912:c047 with SMTP id n2-20020a170902e54200b001adf912c047mr4063973plf.42.1685121497668; Fri, 26 May 2023 10:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685121497; cv=none; d=google.com; s=arc-20160816; b=AmZQ87lPCMNRsu+W/R31jdbJAQzete95m8wBqGGRRPNcVYUWktZo0fHa4ppPxX2YfU jWiApoueK0uT2yjrLVIWAtYCW0dioYirVPhr1W2p2gqa0e3YQ2Z3vWz96gK8a/+vBgkL Qa0sdfQ9hlTBbVDZPZctp+YbQDCkrurFaFb+wkJj39Csctx2BdSTC4EOET6hf35luI8m HcWwzm2w5j3PQk2yCyTp2ykBZSIcQ9wD554VbNKDEdPJYCxPDH1yNroKjaqnNH0KDizY pm62csBLnXUm65MVK5/0FW0eXY41PCqQ1OJkrYzFKanu8Q168EDAPhQ7LcqlypIlMekI wEsQ== 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 :dkim-signature; bh=7a5nrisB4HASvXjVFb0uagWeWA9+BZXI+KVkyZPP1Qw=; b=BqWPrUfQtiAPuQITg2hSl1OO/x4R9NRCt7V9eONi407COTL5WDZ/e4nRX6dRFlM7TZ R8jctroewlaMHWgnIwpSaqURKUuvfonRrFM4qMHt1vdnry0ZjzRfsm0JPSIYopt6+6mf XWXe2ob2LYoOC5AbsV1ww/VFbtJ4ATH7xVKvADsYjAbusrjnQ7gI5Yy7YOeJ9wMxFrm6 s/t68T/N4d8bftRY2Oiz8lz05ip2zWT5guu+4R/6EXTDJxf8upNuc1Zs5CWq611PgCMv XEwHPbCplfYRUL9MWf9QXpKcDxQDvojdm1nk+sK+Q0mKlPQw/avkpLaTOoIOMWkPEw8O MgAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bNCXjNb4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a170902e54d00b001a6e719421asi4744083plf.366.2023.05.26.10.18.04; Fri, 26 May 2023 10:18:17 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bNCXjNb4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242393AbjEZRLt (ORCPT + 99 others); Fri, 26 May 2023 13:11:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242500AbjEZRLk (ORCPT ); Fri, 26 May 2023 13:11:40 -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 462C1E7F for ; Fri, 26 May 2023 10:11:22 -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 65FE661648 for ; Fri, 26 May 2023 17:11:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D6FC433EF; Fri, 26 May 2023 17:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685121081; bh=Sb+M48Kvrrwe56O2VNb3Wy6c5mOmMps4uXhVYIYGrVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNCXjNb4yjDWVmK8nVob+9hyyY8G6hAJF9rkXgE10A1fmr6dPhyHr82KyXokkoJMh vhYiAMlsJ3rYifkJ0MND8EjH8qski6jZNSGf0igixo1rRawZRSqTIMCAjQ2CT9Puva 9XQTDnC0qD1sU1xQtsN9fHq+BwgScWu+AH510ELfxQhyEvuNEH/PfSoKs/CKXEftJD 4Dahcxl81zim9vpr11kdsU6Wcn2yDzsWmbUWvP1nlzU+KniHqHflKWRRPBiOZVdzoc rNsdUj2cRzxWT/HPUhfPbzbFfSIX1tsT0m2qYe6IGpOBWH1FwFTq3cAp99q2kOeYgM CZTuJ2IuA1tSA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas Subject: [PATCH 6/6] riscv: enable DMA_BOUNCE_UNALIGNED_KMALLOC for !dma_coherent Date: Sat, 27 May 2023 00:59:58 +0800 Message-Id: <20230526165958.908-7-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230526165958.908-1-jszhang@kernel.org> References: <20230526165958.908-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 With the DMA bouncing of unaligned kmalloc() buffers now in place, enable it for riscv when RISCV_DMA_NONCOHERENT=y to allow the kmalloc-{8,16,32,96} caches. Since RV32 doesn't enable SWIOTLB yet, and I didn't see any dma noncoherent RV32 platforms in the mainline, so skip RV32 now by only enabling DMA_BOUNCE_UNALIGNED_KMALLOC if SWIOTLB is available. Once we see such requirement on RV32, we can enable it then. NOTE: we didn't force to create the swiotlb buffer even when the end of RAM is within the 32-bit physical address range. That's to say: For RV64 with > 4GB memory, the feature is enabled. For RV64 with <= 4GB memory, the feature isn't enabled by default. We rely on users to pass "swiotlb=mmnn,force" where mmnn is the Number of I/O TLB slabs, see kernel-parameters.txt for details. Tested on Sipeed Lichee Pi 4A with 8GB DDR and Sipeed M1S BL808 Dock board. Signed-off-by: Jisheng Zhang --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index b958f67f9a12..14f030cd6357 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -260,6 +260,7 @@ config RISCV_DMA_NONCOHERENT select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select DMA_DIRECT_REMAP + select DMA_BOUNCE_UNALIGNED_KMALLOC if SWIOTLB config AS_HAS_INSN def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero) -- 2.40.1