Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3256543rwi; Tue, 1 Nov 2022 18:27:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wmO1jpzJl3Ko+kKrcpfajj+ajNIaTFjZSAncRKSyI+LqNOU4wkkDXZm73S5A6D1ru2Mlo X-Received: by 2002:a62:874f:0:b0:56c:45eb:1ffa with SMTP id i76-20020a62874f000000b0056c45eb1ffamr22861442pfe.58.1667352420412; Tue, 01 Nov 2022 18:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667352420; cv=none; d=google.com; s=arc-20160816; b=TQIqEfIy94SSTGEeMhS6gExpi2hsTRrncAd4KzC3DjPDuM+8pOXo0H2L1Pj5+jSckX HV+p64/HAycmvreDfi8Hq1vq05Mon5bJCPeoyaWEGEWkewNE5W+tC143K13Y1HuZbtdW hifuMGb9H4rdgHpJU0ivS310vEvnw+sHmxh+mMA9n5YpXKoKKHqakKrTdcgb1RjTreyp +xRSNjADFdBASw044g/XuH/8Qic5KS07CeWeRlVVz49xgRQUiiiNTG0cb7BFBjWe50wO wnwXCVPf9xsy4WuHrBqkw4bAz4Dqsz4AszxYCjTkYc+WxAHlXBB0bJAd6pahZalMJRnh lOcw== 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=1NL65ctDu7Unb6G0NzPXkABlskH655QCWon4X0fuchI=; b=vA8ubaPYwndQrcHCYQX7OPJgMrITZraoPJtKA6ju47xQsYGIzBCnepmfbjJaf0xwdV CXttRL+Rfvi/cq3EyfHP/HZY9l/GUhket1hhbPG97/Q+8iWWHaH9f/s1/mVlnWaW86Lr OEsa8VwnewXpGf5/f0eZZRF8nwAYZTnhztFdVC/fiF5oytZHraunJLawkV6YnmTA/hw1 PQDwXnTn4BQWA8JMO0jJNhK67vY0dd7JiOpb6lBh8ciHVz9pFbzRMLFqIXi3BRsKN/4p IhqJdAIJJs3m7hvFtN6wJjFnXhpXYoFog6+fPiT98r6lREzMvHabc+nnRt9RAjPLt4gc qE/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hGawBFzd; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e38-20020a630f26000000b0042be0a584cfsi15093574pgl.698.2022.11.01.18.26.47; Tue, 01 Nov 2022 18:27:00 -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=@gmail.com header.s=20210112 header.b=hGawBFzd; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiKBBCf (ORCPT + 96 others); Tue, 1 Nov 2022 21:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbiKBBCd (ORCPT ); Tue, 1 Nov 2022 21:02:33 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178B31F61D; Tue, 1 Nov 2022 18:02:32 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id kt23so41375284ejc.7; Tue, 01 Nov 2022 18:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1NL65ctDu7Unb6G0NzPXkABlskH655QCWon4X0fuchI=; b=hGawBFzd27Ll/+ulBi0YThZo+OCE5WQppu6U/JIsgVX9F19ZlS0csCHGEXm0OgpvMb wpYrl+6aUFV00YDV+ZM14r6Vi1whkq7+IAblyUccWIXB7RouuehTaVLg/caaSzrgsxs5 zUetBOVuUl1O3Uh6fz0NprxI1JBc6ArkdhCC8skOvJMQqBStALqoeKSSUCLr1VnqSvpL OzE5sWKTb8zxNC0/bUuy30pbNRr7J1Ry4ykBUCezoybx7125w1dwjSN/49CUF38idloA SPuuSJOUUC2k8xQHm0A5eJ/C80NcViOSrRgHjQ+NbOBjTQDO0NlB46bvWWSXrjm2YRsx w/tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1NL65ctDu7Unb6G0NzPXkABlskH655QCWon4X0fuchI=; b=Gs/inZsBzVTYE3OkT98bTjVGEcltopBPu9dHr6Q+AZJz2TSYWNpxfNcWLshgyWDcA8 7fKBtK7Jij1thZNMPHvBp9kKkw7RgPEvXHZezaaESNutuZVPpqWUeJ38LCX0f7yruqar vX4UQsNVicI6l8v8IetkJdB3jvFmMtSBuCPR6VyME7rVInpL8kvCnwkT8x0+mKzLPTO5 GgSXkJmlUTVOOTKGVt7shqpPziYz9c/Sba9R18APxuI62XGaRWNNkedk/JBGBv28aH/g pt+lJ5LTSXXOzR4MTewDGcGa2+r9eoZOXsYNwySwblVcsj76kQPbk/qS0B7Ta5/EYXJr znpg== X-Gm-Message-State: ACrzQf3KTMnsThgVsQrtqRjSDDsly4dCTbpC5pGrDLz7foeaSDDaSGHE tsp0aY7tTSxqz408eahkJvbn600KqZKXca7pUG4= X-Received: by 2002:a17:906:371a:b0:7ad:c01c:6fa0 with SMTP id d26-20020a170906371a00b007adc01c6fa0mr16456257ejc.267.1667350950657; Tue, 01 Nov 2022 18:02:30 -0700 (PDT) MIME-Version: 1.0 References: <20221019220242.4746-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20221019220242.4746-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Wed, 2 Nov 2022 01:02:04 +0000 Message-ID: Subject: Re: [RFC PATCH v3 2/2] soc: renesas: Add L2 cache management for RZ/Five SoC To: Geert Uytterhoeven Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Conor Dooley , Guo Ren , Nick Desaulniers , Nathan Chancellor , Atish Patra , Anup Patel , Andrew Jones , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Biju Das , Lad Prabhakar Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Hi Geert, On Tue, Nov 1, 2022 at 12:43 PM Geert Uytterhoeven wrote: > > Hi Prabhakar, > > On Thu, Oct 20, 2022 at 12:02 AM Prabhakar wrote: > > From: Lad Prabhakar > > > > On the AX45MP core, cache coherency is a specification option so it may > > not be supported. In this case DMA will fail. As a workaround, firstly we > > allocate a global dma coherent pool from which DMA allocations are taken > > and marked as non-cacheable + bufferable using the PMA region as specified > > in the device tree. Synchronization callbacks are implemented to > > synchronize when doing DMA transactions. > > > > The Andes AX45MP core has a Programmable Physical Memory Attributes (PMA) > > block that allows dynamic adjustment of memory attributes in the runtime. > > It contains a configurable amount of PMA entries implemented as CSR > > registers to control the attributes of memory locations in interest. > > > > Below are the memory attributes supported: > > * Device, Non-bufferable > > * Device, bufferable > > * Memory, Non-cacheable, Non-bufferable > > * Memory, Non-cacheable, Bufferable > > * Memory, Write-back, No-allocate > > * Memory, Write-back, Read-allocate > > * Memory, Write-back, Write-allocate > > * Memory, Write-back, Read and Write-allocate > > > > This patch adds support to configure the memory attributes of the memory > > regions as passed from the l2 cache node and exposes the cache management > > ops. > > > > More info about PMA (section 10.3): > > http://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf > > > > This feature is based on the work posted [0] by Vincent Chen > > for the Andes AndeStart RISC-V CPU. > > > > [0] https://lore.kernel.org/lkml/1540982130-28248-1-git-send-email-vincentc@andestech.com/ > > > > Signed-off-by: Lad Prabhakar > > Thanks for your patch! > > > --- a/arch/riscv/mm/dma-noncoherent.c > > +++ b/arch/riscv/mm/dma-noncoherent.c > > @@ -24,13 +24,25 @@ void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, > > > > switch (dir) { > > case DMA_TO_DEVICE: > > +#ifdef CONFIG_ERRATA_THEAD_CMO > > ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size); > > +#elif CONFIG_AX45MP_L2_CACHE > > "#elif defined(CONFIG_AX45MP_L2_CACHE)" (everywhere) > > Else it may fail with: > > error: "CONFIG_AX45MP_L2_CACHE" is not defined, evaluates to 0 > [-Werror=undef] > Agreed, thanks for pointing this out. Said that I plan to get rid of these checks in the next version (only after getting around the ALTERNATIVE() macro). Cheers, Prabhakar