Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1068785pxb; Wed, 15 Sep 2021 21:46:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRm1LUlsvWMAGlR1HB0Dao7Woaxg2noFliZTSteTsKABjM5XaOsYqWas7I4F9iiyMy7zzg X-Received: by 2002:a50:d8c9:: with SMTP id y9mr2412134edj.79.1631767593776; Wed, 15 Sep 2021 21:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631767593; cv=none; d=google.com; s=arc-20160816; b=j4+MCS8mDOcqxUF2nP93VYY84uz20ZB7wcXwlDc7wJc0iAvXQFvftKZoFeZRfVZ9L5 tjKSHAyznT87uHIT6sWNRIwzB9woh+OXnnh6sKxWbDojZV5Xn6+O1g1KQev6BwT1f/Ws 59YsWTNBMmQRI7LPgnA8HIrkaV1gY5SgoInSR4SuCvGz87SaMhV5FpmJoepr4lw+S40N 74wBF8oGN1BMRaIvSk9qhdMOs8BovtiE0f4jWz17UvWEyEj0PSvSKkjw49fCMXEBfSwr JEZrgZxTge7fYxcsimq86rfnD5HaMLenU91h/CSHr65N9AUHyeYpSDXJvSaQV0CW9RsY MD3Q== 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=FI6YcgDTwmh92T2Tz0zE+YLI6Tc+4Fm0YSTJ17PXswQ=; b=xiOjfDMdDLOtJcBtflizrZOoav3RqQF6gEJZExrZV4MJi/pSP7Vm/sOR5Hr9oZFBsw IyworQLh6RtY6PLx0T1Cv7YpjCRYtnbwvDHdyrD3FyGTeWG9TFf05pNjhDL0z+2DuNCU +sGbfnpPkkz/qWpe89k6xhHmF6Lt5MfC0G2h7zPvy85dniXkp7eLT8jTREWxLqH7a/ob hlcruQ11MqymnZHhl4haygwBXO42cPKS+3lWe+j+nVd/m/u5jbiTyA/pLUSfz+YIxsv8 DLOLFoL5QeRx+OxocXtoXKHdQUaJLS95dg08jhPmGGy9pexskYCYX6sGPv4l5QCpUqGA K53g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=becGQyFp; 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 g2si2332823edk.133.2021.09.15.21.46.09; Wed, 15 Sep 2021 21:46:33 -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=becGQyFp; 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 S234270AbhIPEoA (ORCPT + 99 others); Thu, 16 Sep 2021 00:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230344AbhIPEn7 (ORCPT ); Thu, 16 Sep 2021 00:43:59 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E244C061574 for ; Wed, 15 Sep 2021 21:42:39 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id a93so10474325ybi.1 for ; Wed, 15 Sep 2021 21:42:39 -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=FI6YcgDTwmh92T2Tz0zE+YLI6Tc+4Fm0YSTJ17PXswQ=; b=becGQyFpbtC4G/09KFN7ZM9j4ZAjZDFIlLPI4icTAnOAuMMuV2pUbVZIQmpnBXmzNq H/zKbZzlXSBmQJJrNIKm4qqwLXN3fjm1VAK6sRBLEo3JGbF9B+68TG9LV/Q1DWCT1PIa G3FfSyFoelepOtGOkEZF+ugdBNbcwyiigfW9o= 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=FI6YcgDTwmh92T2Tz0zE+YLI6Tc+4Fm0YSTJ17PXswQ=; b=AAtMkGuXoTttApLzea6+CJkwQpOt/Qi47LiirjtofAk8m1VeZh3Cv25/mEOQoyBjUI 8ou8pRi6qGlR+19Gto8TizSMZOU8Y4a3Vw8FQQojuUCgwwxUwkd5OaFYvtqT256msUYq oqU8vYHkIYKY61iJdgn+p8A6EZ1xJ54gPPhDhzjgpVmk2YSYrpTnuIuEN3UVshnG3UyZ wqIsvcDBqIjnjxM9bpsbDxv8C34e8SzAwGgjFjVIsPp7rFOHcjvzXq5GjMKjd0iU0FB0 eSW8Z4JyyVIPms9/9ER3oWxM8HZk90UPwl6lHKwXEKCSS2EoJ7wXjZ90Nai+v8PnjyXl CH4w== X-Gm-Message-State: AOAM530B7ObJ3C2t8qx808TQR76nu/Bj404UQxFCDZn1sKTcvUjBQK6L v9Pj5fIq82tLDQLGlV2qOPUxrpmQR/IUasIpboV1 X-Received: by 2002:a25:9d83:: with SMTP id v3mr4465092ybp.97.1631767358505; Wed, 15 Sep 2021 21:42:38 -0700 (PDT) MIME-Version: 1.0 References: <20210911092139.79607-1-guoren@kernel.org> <20210911092139.79607-5-guoren@kernel.org> <20210915075007.GD20024@lst.de> In-Reply-To: From: Atish Patra Date: Wed, 15 Sep 2021 21:42:27 -0700 Message-ID: Subject: Re: [RFC PATCH V4 4/6] RISC-V: Implement arch_sync_dma* functions To: Anup Patel Cc: Guo Ren , 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 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 9:25 PM Anup Patel wrote: > > On Thu, Sep 16, 2021 at 7:03 AM Guo Ren wrote: > > > > On Wed, Sep 15, 2021 at 3:50 PM Christoph Hellwig wrote: > > > > > > On Sat, Sep 11, 2021 at 05:21:37PM +0800, guoren@kernel.org wrote: > > > > +static void __dma_sync(phys_addr_t paddr, size_t size, enum dma_data_direction dir) > > > > +{ > > > > + if ((dir == DMA_FROM_DEVICE) && (dma_cache_sync->cache_invalidate)) > > > > + dma_cache_sync->cache_invalidate(paddr, size); > > > > + else if ((dir == DMA_TO_DEVICE) && (dma_cache_sync->cache_clean)) > > > > + dma_cache_sync->cache_clean(paddr, size); > > > > + else if ((dir == DMA_BIDIRECTIONAL) && dma_cache_sync->cache_flush) > > > > + dma_cache_sync->cache_flush(paddr, size); > > > > +} > > > > > > Despite various snipplets this is a still pretty much the broken previous > > > versions. These need to use the CMO instructions directly which are > > > about to go into review, and then your SBI can trap on those can call > > > whatever non-standard mess you're using. > > I think you mean put an ALTERNATIVE slot in the prologue of __dma_sync? > > > > #define ALT_DMA_SYNC() \ > > asm(ALTERNATIVE(".rept 64\n nop\n .endr\n", "", > > XXX_VENDOR_ID, \ > > ERRATA_XXX, CONFIG_ERRATA_XXX) \ > > : : : "memory") > > > > static void __dma_sync(phys_addr_t paddr, size_t size, enum > > dma_data_direction dir) > > { > > ALT_DMA_SYNC(); > > > > /* future cmo codes */ > > } > > I think Christoph is suggesting to always use CMO instructions for > implementing arch specific DMA sync functions. The SBI implementation > will trap-n-emulate CMO instructions when underlying HW does not > have it. This means custom cache instructions on D1 can reside in > the platform support code of OpenSBI. > > I also agree with the above suggestion. At least, this will ensure that we > have only one way of doing cache operations from S-mode perspective > which is CMO instructions. > Sounds good to me. For stralight Socs, we may need to add a l2 cache controller driver in OpenSBI as well. IIRC, sifive cores do have some M-mode only CMO instructions as well but they may not align with CMO spec. I have to double check. > Regards, > Anup > > > > > > > > > > > -- > > 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