Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4214960rwl; Sat, 7 Jan 2023 13:25:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXvJRyKs4bxHF0mVT1OaGzHLfbHWZ7t3KRQV0RmDOTfr09LowcK1OBwUsF0Nk67/XA3bXZRz X-Received: by 2002:a05:6402:1d8a:b0:494:2eb4:89b2 with SMTP id dk10-20020a0564021d8a00b004942eb489b2mr9470746edb.29.1673126739724; Sat, 07 Jan 2023 13:25:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673126739; cv=none; d=google.com; s=arc-20160816; b=tBLkHOsorVKhIHihMesmwDhfy/4s1G5ws+gD6fiuiSaxrr9GmEFMMxzWfC22S6MK/3 tqKNbFJSjveU4uaQ44SpnVRMPuoT2IfrYXgthhkiPAckWJg6OS6zaNNtCs1pHe9R2N5Y tTmHwBZQPEi4AWp3KK3sgb8vC0WaVOpfhaFvyOukcX1ZRNfelJuiMdBvfeob6I9U84Ut /yFrN475N8I9OLCKsK+y6xrYufWMMpz4hQ6x7quYGrHfSduuaMNeP+BADsr4Flw/irsM KeDF8BAl7UlPAp+chZd1glOcwSHbv5VMQGtDc80KCVbLczFDjVZPDGn6bD6YswLzza2J 5bkA== 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=BWbA44Bf2vZY0/3H5jD+i5cHh/WsBY5ereQ2rQNmxw0=; b=Z+t/DEOxbUQNcFwEEQfUXU8lNfX3RlEk3J6fXK1c9AzG7PN2iIw4wMIVypfnpkG5IL J4ywaAgwsf8uR5ypIg+2upxUQloXH487ZOicIjfhWtfh4lD+MvK5La/4OYgsi/X0kpW+ hiWz3/tcKxN2O+jj/MdYV19lhfG0y2exrCQXkLJ8W2gg/HiluXtBGwfxukWeyGfnTPA+ NDZ+KRJHR91BbVHRxYbIm+dx5rkrpD85G5qFF4mAeNRmRkm7YykueHM09zqv7m0ADgSk 7Ry15VWBR0b8fsC2jFYbbS6Yptu7Q0FjOIGqF+zdna7Bnxl1H0Nrs8yBnEGFpS8Qyeol UcOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="JiZ/HqQV"; 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 w9-20020a05640234c900b00478c8cfd5bbsi5976971edc.16.2023.01.07.13.25.26; Sat, 07 Jan 2023 13:25:39 -0800 (PST) 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="JiZ/HqQV"; 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 S232918AbjAGUtq (ORCPT + 53 others); Sat, 7 Jan 2023 15:49:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbjAGUtn (ORCPT ); Sat, 7 Jan 2023 15:49:43 -0500 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5303E847; Sat, 7 Jan 2023 12:49:42 -0800 (PST) Received: by mail-qv1-xf2a.google.com with SMTP id t7so3469463qvv.3; Sat, 07 Jan 2023 12:49:42 -0800 (PST) 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=BWbA44Bf2vZY0/3H5jD+i5cHh/WsBY5ereQ2rQNmxw0=; b=JiZ/HqQVdc9k1RkpydVSZfSB9yHBE8kUolaxxhi/FGwqpiSXdWyoaKzh9QV/8jzIav nAsRCcB2kkejXGWFmb6+03kf6tdfCMCp46/mOyAteWfRZxz/GB23bZTi3b9ckOh1Vug/ 7mSYjOUWM2B9VN1F2V2n1Lu3Qmp5SRL4tDh9TJgxKeuWIJYk9OC4QdhAZmC21NRGPVgg 0smqUsx1sfm/8TQ06rwqpNeeV6W+lUrVSntkWg5OehKMPxEjoA48nNct47iFT3WKnPVK bG0yKIQ1kODGCa+lmnI6catgw7zcsfCZxIh2CbHrfBAt12Te7lvLzCZrRoqNC0mHYnfb dOQg== 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=BWbA44Bf2vZY0/3H5jD+i5cHh/WsBY5ereQ2rQNmxw0=; b=5SY/eef3p5K0JIzrtgdDUSLp+UJaMITi43SL7tSkZZ5rpUYF83yKBxx/kNA+nA55ct wnJwKi1Qj3Zn9OalOB8B4MvbnBAYFcBZYI2PxxkOaTjaDJxDNEtAS9mvyq09Xz2nOUw0 PfTdOyN3lB1tXIKKtRwWJpHMJDsLA+WxthpcDF9UUpGdtmMTurVcF2LIeThYb4TLDdW0 TFI9Ze39FE0CWbcI8zgdEWystT77OW6G7zYdmfQOQsdA9MqUvx8tEIukiKP5MUiWFrXw qRPDnHE368ZnKFaNE/WDzPWf8wPyXkC/VnSe8BJAgXD+IDLPTP4I58/k9og45kq6ePKy xPew== X-Gm-Message-State: AFqh2kol5QJZ82ascXmB94ZigbTqh74fHPVYNmDkXzF0HI1p6NvRuJzb Vbxy97SfX//UL/Vymb3laGxqhiTBPq3sR4E9phk= X-Received: by 2002:a05:6214:2e17:b0:4b1:a359:c204 with SMTP id mx23-20020a0562142e1700b004b1a359c204mr3821567qvb.64.1673124581234; Sat, 07 Jan 2023 12:49:41 -0800 (PST) MIME-Version: 1.0 References: <20230106185526.260163-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20230106185526.260163-6-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Sat, 7 Jan 2023 20:49:14 +0000 Message-ID: Subject: Re: [PATCH v6 5/6] cache: Add L2 cache management for Andes AX45MP RISC-V core To: Conor Dooley Cc: Arnd Bergmann , Conor Dooley , Geert Uytterhoeven , Heiko Stuebner , Guo Ren , Andrew Jones , Paul Walmsley , Palmer Dabbelt , Albert Ou , open list , "open list:RISC-V ARCHITECTURE" , devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lad Prabhakar , Greg Kroah-Hartman , Thomas Zimmermann , Bart Van Assche , "Martin K. Petersen" , Adrian Hunter , Dipen Patel , Oded Gabbay , Iwona Winiarska , "Fabio M. De Francesco" , Mathieu Poirier , Jason M Bills , Yicong Yang , Dan Williams 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 Conor, Thank you for the review. On Sat, Jan 7, 2023 at 12:09 AM Conor Dooley wrote: > > On Fri, Jan 06, 2023 at 06:55:25PM +0000, Prabhakar wrote: > > From: Lad Prabhakar > > > > I/O Coherence Port (IOCP) provides an AXI interface for connecting > > external non-caching masters, such as DMA controllers. The accesses > > from IOCP are coherent with D-Caches and L2 Cache. > > > > IOCP is a specification option and is disabled on the Renesas RZ/Five > > SoC due to this reason IP blocks using DMA will fail. > > > > 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 > > > > More info about PMA (section 10.3): > > Link: http://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf > > > > As a workaround for SoCs with IOCP disabled CMO needs to be handled by > > software. Firstly OpenSBI configures the memory region as > > "Memory, Non-cacheable, Bufferable" and passes this region as a global > > shared dma pool as a DT node. With DMA_GLOBAL_POOL enabled all DMA > > allocations happen from this region and synchronization callbacks are > > implemented to synchronize when doing DMA transactions. > > > > Example PMA region passes as a DT node from OpenSBI: > > reserved-memory { > > #address-cells = <2>; > > #size-cells = <2>; > > ranges; > > > > pma_resv0@58000000 { > > compatible = "shared-dma-pool"; > > reg = <0x0 0x58000000 0x0 0x08000000>; > > no-map; > > linux,dma-default; > > }; > > }; > > > > Signed-off-by: Lad Prabhakar > > > diff --git a/drivers/cache/ax45mp_cache.c b/drivers/cache/ax45mp_cache.c > > new file mode 100644 > > index 000000000000..556e6875627c > > --- /dev/null > > +++ b/drivers/cache/ax45mp_cache.c > > @@ -0,0 +1,279 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * non-coherent cache functions for Andes AX45MP > > + * > > + * Copyright (C) 2022 Renesas Electronics Corp. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > You don't actually need this anymore, do you? > Agreed these can be dropped now. > > +static int ax45mp_l2c_probe(struct platform_device *pdev) > > +{ > > + struct riscv_cache_ops ax45mp_cmo_ops; > > + > > + /* > > + * riscv_cbom_block_size is set very much earlier so we can > > + * definitely rely on it and only if its being set we continue > > + * further in the probe path. > > + */ > > + if (!riscv_cbom_block_size) > > + return 0; > > Return 0? That's because we may actually have the IOCP & do not want to > install ops, right? > If so, please add that to the comment. > OK, I will add that. > > + > > + ax45mp_priv = devm_kzalloc(&pdev->dev, sizeof(*ax45mp_priv), GFP_KERNEL); > > + if (!ax45mp_priv) > > + return -ENOMEM; > > + > > + ax45mp_priv->l2c_base = devm_platform_ioremap_resource(pdev, 0); > > + if (IS_ERR(ax45mp_priv->l2c_base)) > > + return PTR_ERR(ax45mp_priv->l2c_base); > > + > > + ax45mp_get_l2_line_size(pdev); > > + > > + memset(&ax45mp_cmo_ops, 0x0, sizeof(ax45mp_cmo_ops)); > > + ax45mp_cmo_ops.riscv_dma_noncoherent_cmo_ops = &ax45mp_no_iocp_cmo; > > Yah, drop this dance and use a static struct foo_ops construct please. > Will do. > With those two, I'm happy with this I guess.. > Reviewed-by: Conor Dooley > > > + riscv_noncoherent_register_cache_ops(&ax45mp_cmo_ops); > > + > > + return 0; > > +} > > + > > +static const struct of_device_id ax45mp_cache_ids[] = { > > + { .compatible = "andestech,ax45mp-cache" }, > > + { /* sentinel */ } > > +}; > > + > > +static struct platform_driver ax45mp_l2c_driver = { > > + .driver = { > > + .name = "ax45mp-l2c", > > + .of_match_table = ax45mp_cache_ids, > > + }, > > + .probe = ax45mp_l2c_probe, > > +}; > > + > > +static int __init ax45mp_cache_init(void) > > +{ > > + return platform_driver_register(&ax45mp_l2c_driver); > > +} > > +arch_initcall(ax45mp_cache_init); > > + > > +MODULE_AUTHOR("Lad Prabhakar "); > > +MODULE_DESCRIPTION("Andes AX45MP L2 cache driver"); > > +MODULE_LICENSE("GPL"); > > BTW, I think these are surplus-to-requirements since this is never going > to be built as a module. > Agreed, I will drop it. > If you resurrect the directory level maintainers entry from my v5.1, you > can also add: Sure I'll add it in the next version.. > Acked-by: Conor Dooley > ... and also include your ACK. Cheers, Prabhakar