Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1066506pxb; Wed, 15 Sep 2021 21:41:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLAjyRZdDQefRVcbdqiTI7e89WGHb456uezKl6OtrOvkKMhgfoPp417+DBtWuiEgTXhj7m X-Received: by 2002:a50:eac4:: with SMTP id u4mr4150632edp.259.1631767283717; Wed, 15 Sep 2021 21:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631767283; cv=none; d=google.com; s=arc-20160816; b=uF2jh9OorToP0uxcSUWAdHUN2OXV8I3ElQOjLimHAm8F3fFCL7xZyE7T5wWqRYPGNO vXE/YJ5P7UfTUSDe/H9rIfm8yf5JZXSBC3iFZBBSyJ2dYmnSvZfsvScz4m2HpCpM5tu+ y8uugNDGlkdpD5jJoY8Sb+YxxebRHP0PR8W2nd/nvzT96g1V/ROWsn0xrSc58hlQopXw fey+/mxvLDWl0g5AFjoJllfgfUfeonV0Kr4EZlgKV0Kp+hT8Sov/eUtq2sLQ/NFhM2jp ctk6unNCBEAqkKdSWVNhxO1nQEJ34c+FIu2yc+3vtBz/zSNBDhPsq3Wz9h48EgndHLWn PGSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ObPDTmZPpxAdnjCpIiAd46RqCXfB5lsbopxNimw2AIA=; b=IS6AafwiqGtrH2pCgqRY27nLXbKrmM0wd/mPh2SuFCR6xsEUfhqoXCnJYnLweaZZAE K/TV3QXOVO7Ukmp6iu5HUaaWrRxN24UQyDHYymQhZseZEevAQr6YJdzES+eN8TkI0A2N Q/cKfRecmBA+oxQD5UJ4zul4F70Y2D6BDRu5ryUDmmHdZw7ZkkPux0Og4J14Exbcywug IJK/l/qol4uqI4elZy+eqDdm1W9OyN3VDzwWuwrFuJRTOVAl/XXLaAszJFccvc520tTD u7DcHkab2NdPZTSvYlGolMOvyfsAX5NJgAVdD4uXRwgc69OHt8MLPWBVQfV8ZFvRCByY NM2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=N5t7V90q; 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 di3si2462877ejc.490.2021.09.15.21.40.59; Wed, 15 Sep 2021 21:41:23 -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; dkim=pass header.i=@atishpatra.org header.s=google header.b=N5t7V90q; 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 S234221AbhIPEkw (ORCPT + 99 others); Thu, 16 Sep 2021 00:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbhIPEkv (ORCPT ); Thu, 16 Sep 2021 00:40:51 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D38BC061574 for ; Wed, 15 Sep 2021 21:39:31 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id m70so10399863ybm.5 for ; Wed, 15 Sep 2021 21:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ObPDTmZPpxAdnjCpIiAd46RqCXfB5lsbopxNimw2AIA=; b=N5t7V90qffEF/ZhejZl+iBxrOA9sHwERjgwzmWS5h7qdVdKU0pCnOwskRNvjv5IsAW t82nIlvBzHnlUO8WxoEYOy3aLivxLUC4VdaYWOQgbsfLaC9+idrFwDycT8PQHGfm4kYD baFSptL9j5MNf9Plt3p8I/WmjueldYPgLYwrA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ObPDTmZPpxAdnjCpIiAd46RqCXfB5lsbopxNimw2AIA=; b=fHyEfTUDM1TYPk3gENYCJJkPmXjzOWfEMMVweDOxNJRWhzjgyv2lWBiJ3rpUiTib+7 rpR6i6MgRcIIpjNWTBC4NGcj2dTkoC+RnKgXeiV/dUK9HYP2735RK8UsQCn+wvzQ08+y YZ2TuvrIwsw+eVjQXA8Sm4OM5JFfEIHqmGF60i4OI8MQ5yk69RWS2PzHXPTVzpDbEg2p PgNeBhU3/s3fD4/kxc4889Kxw5jNtm4MxsttwDb0GRgmuI96VLclQBW+pkpuxuZZ9nsS PiuBOsJD2EtYx+L0YmxELQlE1u/9jZa3BIofWlKMP0fITr7pvNp9L2BOpz1ithFro881 RcxQ== X-Gm-Message-State: AOAM530Wj+rspqSLUYKc+6qC5vS4VmatNpBgIodl+bHErBI2sCKtbK14 n509zvoOsFpejTJEoD7NImokIWRhHz/oMCIlzowM X-Received: by 2002:a25:1683:: with SMTP id 125mr4347701ybw.164.1631767170718; Wed, 15 Sep 2021 21:39:30 -0700 (PDT) MIME-Version: 1.0 References: <20210911092139.79607-1-guoren@kernel.org> <20210911092139.79607-4-guoren@kernel.org> <20210915074827.GC20024@lst.de> In-Reply-To: From: Atish Patra Date: Wed, 15 Sep 2021 21:39:19 -0700 Message-ID: Subject: Re: [RFC PATCH V4 3/6] RISC-V: Support a new config option for non-coherent DMA To: Guo Ren Cc: Christoph Hellwig , Anup Patel , Atish Patra , Palmer Dabbelt , =?UTF-8?Q?Christoph_M=C3=BCllner?= , Philipp Tomsich , liush , wefu@redhat.com, =?UTF-8?B?V2VpIFd1ICjlkLTkvJ8p?= , Drew Fustini , linux-riscv , Linux Kernel Mailing List , taiten.peng@canonical.com, aniket.ponkshe@canonical.com, Heinrich Schuchardt , gordan.markus@canonical.com, Guo Ren Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 15, 2021 at 6:21 PM Guo Ren wrote: > > On Wed, Sep 15, 2021 at 3:48 PM Christoph Hellwig wrote: > > > > On Sat, Sep 11, 2021 at 05:21:36PM +0800, guoren@kernel.org wrote: > > > + select DMA_GLOBAL_POOL > > > + select DMA_DIRECT_REMAP > > > > No need to select DMA_GLOBAL_POOL when DMA_DIRECT_REMAP is select. > If we want to support PBMT & global_dma_pool both in riscv. Could they > work together in arch/riscv with [1]? We don't have to worry about it as the next version of my series will use the simpler dma_uncached functionality to support uncached window approach taken by starlight socs. I was supposed to send it sooner but got busy with PMU stuff and a bad flu :(. > > [1]: https://lore.kernel.org/lkml/20210818142715.GA10755@lst.de/T/ > > > > > Also a patch just to add a option that is not selected and won't build > > if selected does not make sense. > I just want to rebase on Atish's patch and append DMA_DIRECT_REMAP. > Okay, DMA_DIRECT_REMAP & DMA_GLOBAL_POOL should be separated from the > patch. > > > > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -156,9 +156,14 @@ void *dma_direct_alloc(struct device *dev, size_t size, > > if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED) && > !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) && > + !IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) && > !dev_is_dma_coherent(dev)) > return arch_dma_alloc(dev, size, dma_handle, gfp, attrs); > > + if (IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) && > + !dev_is_dma_coherent(dev)) > + return dma_alloc_from_global_coherent(dev, size, dma_handle); > + > /* > * Remapping or decrypting memory may block. If either is required and > * we can't block, allocate the memory from the atomic pools. > @@ -255,11 +260,19 @@ void dma_direct_free(struct device *dev, size_t size, > > if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED) && > !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) && > + !IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) && > !dev_is_dma_coherent(dev)) { > arch_dma_free(dev, size, cpu_addr, dma_addr, attrs); > return; > } > > + if (IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) && > + !dev_is_dma_coherent(dev)) { > + if (!dma_release_from_global_coherent(page_order, cpu_addr)) > + WARN_ON_ONCE(1); > + return; > + } > + > Here CONFIG_DMA_GLOBAL_POOL is independent from CONFIG_DMA_DIRECT_REMAP. > > /* If cpu_addr is not from an atomic pool, dma_free_from_pool() fails */ > if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) && > dma_free_from_pool(dev, cpu_addr, PAGE_ALIGN(size))) > > -- > Best Regards > Guo Ren > > ML: https://lore.kernel.org/linux-csky/ > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv -- Regards, Atish