Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1942092rwb; Wed, 5 Oct 2022 07:04:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TDhtgEIkDcCn9164TbONXMber5dZRMkycd91R5dU5eDUUTdsl6CM/PjbOkYic9lBy81KX X-Received: by 2002:a17:907:744:b0:741:36b9:d2cc with SMTP id xc4-20020a170907074400b0074136b9d2ccmr22905163ejb.613.1664978644727; Wed, 05 Oct 2022 07:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664978644; cv=none; d=google.com; s=arc-20160816; b=Cl9u7999Ai3eAUNiTUpAo8Qaxpm4s5PxmKNqdSdP0LF/uj/bpsDs8K5Lb1W4Jf2zr9 1zImbuc+jdNJUqMlBX+cN+ui173X2zwGgSH1BxlfJqw8oCW2uIepTw7avd/7QJRG9vXY RIWbYxwov5bsvTxUXfLq34EzdcA15sS9ccdJWlTUkKz9RXujliqvOIpnvfyf1soD3wU9 G7ahy6ttkZsDXlwPSFaq9J6V6G0UeyxkvpljBqgLlIryqDKZT0LzKN8urF35k+FGq9wJ XEBTyeyy0X36/go+4O9RRUl65REiTg7G/nGTBigBZiCitNtPRn76IqD6Zh4QIQIMOI1k wdcw== 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=RXw6zATnsmcUdNJCBDtKAI7UAvNpEXVIHqhEL/cDEW4=; b=bIU5/oXgWbO9kQhPh8XHYQ2DUO61ulrfwfpHAAY8cEZabsKdcVO/ClJBdNEAplayp9 7MYjtPsPrrDxXiKDAklHvRpEXRUyXAZXEc//V0DF6l2EpfNshT3PRlVdtNdIeX4XWA5l BbmJmM5NOg9zEfGjsZiy60ZXyUVvtN/cdV1eiIntCEulrBTfmrUl4j/YF1yzzNDeiaKq efsA8Sm8XvpPHARubRX/PPaabK+P6otn0frLsDHXOyH6oD3pI/+3XxRiaSyxTnvFnibl K8sOAb0ox6e8tM6UyOjPoyikcW0H+JnQAhoqG4e834cLhzvO4j9l9lw+cq/VqF1EaunR aXrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Ya9Bxn9L; 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=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt18-20020a1709072d9200b007823754ecd5si15986933ejc.43.2022.10.05.07.03.37; Wed, 05 Oct 2022 07:04:04 -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=@canonical.com header.s=20210705 header.b=Ya9Bxn9L; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230188AbiJENzk (ORCPT + 99 others); Wed, 5 Oct 2022 09:55:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiJENzi (ORCPT ); Wed, 5 Oct 2022 09:55:38 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A596567C for ; Wed, 5 Oct 2022 06:55:37 -0700 (PDT) Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B6FB1420E6 for ; Wed, 5 Oct 2022 13:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1664978135; bh=RXw6zATnsmcUdNJCBDtKAI7UAvNpEXVIHqhEL/cDEW4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ya9Bxn9LDCiSFgrHNGbAFpRMRMKfLV0ORX48trzqvWSVaaSbgDHx6ZVPP5hyAkG9o TbeCOpDhEnjWKQvZpH+SR8b3hFRblQccyQ4EousekgnqrXi42ZJYi/Sl8feS3IKyBR KgvbvYcxuDhwJgtXPKLvE7+fhB/MUOyQ99ErZY4WCTbiLkBDXP3L2F8V5Hxq60ZALS 6eTyvpY5SdeqQ58GvLUDuyhTz3k6LdUoaCIdOb3YGDPQRmXn/2aNgKVhuTtAT5xVpX dRSTV9Wl7hhyTa5g0DH8lX40224hZMI5JyE+Qzp3wypmYR4ghpOsP3ZdYzS2xeNh2r uAGAyErI2pLyA== Received: by mail-qt1-f199.google.com with SMTP id fv21-20020a05622a4a1500b0035cc9b4fc20so11286486qtb.12 for ; Wed, 05 Oct 2022 06:55:35 -0700 (PDT) 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; bh=RXw6zATnsmcUdNJCBDtKAI7UAvNpEXVIHqhEL/cDEW4=; b=WTfc0dpkGLnpzKUhbKge5UNkwg6R4hjXp73EmlvpVQks+2uNOcAkZ2RxZtQjrYTcq8 UkZ3WDu2ZEvrxEF26TAsd8DAQ04xG2QTT9SjpGwKpexrytf3mgTlKSHVQLq/Yvp5zq3U SlmXsex7gNxf3CNyQaptciiwEhkrEyTuy0Qx5kayjXoXw6b7r1Awz3AqAj8NIgiUI2MJ 7XQyBhSLURi6fq14gAo2b5u+51denaIb/5fxyjgmR26YqFOxvcZPqjf4YJ2EuLRchkW2 vYUTyUmCKona+dye8n5999B0NXIUSBWet5mDn5bfcD8YUyAb8VAaYghEIPqHbJSq8Kck dfdw== X-Gm-Message-State: ACrzQf3aN+NZatiqX3xMl8gwoUuJls/X2ZkOrCnFRNPZfx2/CfNfJviB NPbuC5PYeRjZRZFZmJHNxGEE/KrHQeT1CX6m7sO7ZLrf4Z/jIU0kY8V/fMFzK0wNEwa5SGXDjmY 1eDueWs8Xw5EhwkTbu9Y3rjod0fPQIwTHgk6mcHfnG8sa2gJGU9qgIqYU9w== X-Received: by 2002:a05:622a:11cc:b0:35c:d955:db23 with SMTP id n12-20020a05622a11cc00b0035cd955db23mr23696229qtk.660.1664978133981; Wed, 05 Oct 2022 06:55:33 -0700 (PDT) X-Received: by 2002:a05:622a:11cc:b0:35c:d955:db23 with SMTP id n12-20020a05622a11cc00b0035cd955db23mr23696207qtk.660.1664978133742; Wed, 05 Oct 2022 06:55:33 -0700 (PDT) MIME-Version: 1.0 References: <20220929143225.17907-1-hal.feng@linux.starfivetech.com> <20220929143225.17907-6-hal.feng@linux.starfivetech.com> <40d0abb6-88dc-d315-f768-27a623f60986@sifive.com> <4d8a199b-f22a-a421-aae4-64e538cb97f4@codethink.co.uk> In-Reply-To: <4d8a199b-f22a-a421-aae4-64e538cb97f4@codethink.co.uk> From: Emil Renner Berthing Date: Wed, 5 Oct 2022 15:55:17 +0200 Message-ID: Subject: Re: [PATCH v1 05/30] soc: sifive: l2 cache: Convert to platform driver To: Ben Dooks Cc: Ben Dooks , Hal Feng , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Daniel Lezcano , Thomas Gleixner , Marc Zyngier , Philipp Zabel , Stephen Boyd , Michael Turquette , Linus Walleij , Emil Renner Berthing , linux-kernel@vger.kernel.org, Zong Li Content-Type: text/plain; charset="UTF-8" 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 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 On Wed, 5 Oct 2022 at 15:48, Ben Dooks wrote: > > On 05/10/2022 14:44, Emil Renner Berthing wrote: > > On Thu, 29 Sept 2022 at 19:59, Ben Dooks wrote: > >> > >> On 29/09/2022 15:32, Hal Feng wrote: > >>> From: Emil Renner Berthing > >>> > >>> This converts the driver to use the builtin_platform_driver_probe macro > >>> to initialize the driver. This macro ends up calling device_initcall as > >>> was used previously, but also allocates a platform device which gives us > >>> access to much nicer APIs such as platform_ioremap_resource, > >>> platform_get_irq and dev_err_probe. > >> > >> This is useful, but also there are other changes currently being sorted > >> out by Zong Li (cc'd into this message) which have already been reviewed > >> and are hopefully queued for the next kernel release. > >> > >>> Signed-off-by: Emil Renner Berthing > >>> Signed-off-by: Hal Feng > > > > I'm ok with something like this being merged, but please note that if > > we ever want to support the JH7100 which uses registers in this > > peripheral to flush the cache for its non-coherent DMAs then this > > driver needs to be loaded before other peripherals or we will trigger > > the 2nd warning in arch/riscv/mm/dma-noncoherent.c. I'm not sure we > > can do that when it's a platform driver. See this patch for an > > alternative to support the JH71x0s: > > https://github.com/esmil/linux/commit/9c5b29da56ae29159c9572c5bb195fe3a1b535c5 > > > > /Emil > > Are you replying to your own patch that does the conversion to > platform driver and then saying that it could actually cause > issues? Yes, I can see it seems odd, but this patch lived for a while in the kernel repo for the JH7100 until I rebased on 6.0-rc1 and realized the above. Hal Feng must have based his patches on a version of the code before that when preparing this series. > I'm all for dropping this for the moment and keeping the old > early init for the ccache. Cool. /Emil > >>> drivers/soc/sifive/sifive_l2_cache.c | 79 ++++++++++++++-------------- > >>> 1 file changed, 40 insertions(+), 39 deletions(-) > >>> > >>> diff --git a/drivers/soc/sifive/sifive_l2_cache.c b/drivers/soc/sifive/sifive_l2_cache.c > >>> index 59640a1d0b28..010d612f7420 100644 > >>> --- a/drivers/soc/sifive/sifive_l2_cache.c > >>> +++ b/drivers/soc/sifive/sifive_l2_cache.c > >>> @@ -7,9 +7,9 @@ > >>> */ > >>> #include > >>> #include > >>> -#include > >>> -#include > >>> -#include > >>> +#include > >>> +#include > >>> +#include > >>> #include > >>> #include > >>> > >>> @@ -96,12 +96,6 @@ static void l2_config_read(void) > >>> pr_info("L2CACHE: Index of the largest way enabled: %d\n", regval); > >>> } > >>> > >>> -static const struct of_device_id sifive_l2_ids[] = { > >>> - { .compatible = "sifive,fu540-c000-ccache" }, > >>> - { .compatible = "sifive,fu740-c000-ccache" }, > >>> - { /* end of table */ }, > >>> -}; > >>> - > >>> static ATOMIC_NOTIFIER_HEAD(l2_err_chain); > >>> > >>> int register_sifive_l2_error_notifier(struct notifier_block *nb) > >>> @@ -192,36 +186,29 @@ static irqreturn_t l2_int_handler(int irq, void *device) > >>> return IRQ_HANDLED; > >>> } > >>> > >>> -static int __init sifive_l2_init(void) > >>> +static int __init sifive_l2_probe(struct platform_device *pdev) > >>> { > >>> - struct device_node *np; > >>> - struct resource res; > >>> - int i, rc, intr_num; > >>> - > >>> - np = of_find_matching_node(NULL, sifive_l2_ids); > >>> - if (!np) > >>> - return -ENODEV; > >>> - > >>> - if (of_address_to_resource(np, 0, &res)) > >>> - return -ENODEV; > >>> - > >>> - l2_base = ioremap(res.start, resource_size(&res)); > >>> - if (!l2_base) > >>> - return -ENOMEM; > >>> - > >>> - intr_num = of_property_count_u32_elems(np, "interrupts"); > >>> - if (!intr_num) { > >>> - pr_err("L2CACHE: no interrupts property\n"); > >>> - return -ENODEV; > >>> - } > >>> - > >>> - for (i = 0; i < intr_num; i++) { > >>> - g_irq[i] = irq_of_parse_and_map(np, i); > >>> - rc = request_irq(g_irq[i], l2_int_handler, 0, "l2_ecc", NULL); > >>> - if (rc) { > >>> - pr_err("L2CACHE: Could not request IRQ %d\n", g_irq[i]); > >>> - return rc; > >>> - } > >>> + struct device *dev = &pdev->dev; > >>> + int nirqs; > >>> + int ret; > >>> + int i; > >>> + > >>> + l2_base = devm_platform_ioremap_resource(pdev, 0); > >>> + if (IS_ERR(l2_base)) > >>> + return PTR_ERR(l2_base); > >>> + > >>> + nirqs = platform_irq_count(pdev); > >>> + if (nirqs <= 0) > >>> + return dev_err_probe(dev, -ENODEV, "no interrupts\n"); > >> > >> I wonder if zero irqs is an actual issue here? > >> > >>> + for (i = 0; i < nirqs; i++) { > >>> + g_irq[i] = platform_get_irq(pdev, i); > >> > >> I wonder if we need to keep g_irq[] around now? Is it going to be useful > >> in the future? > >> > >>> + if (g_irq[i] < 0) > >>> + return g_irq[i]; > >>> + > >>> + ret = devm_request_irq(dev, g_irq[i], l2_int_handler, 0, pdev->name, NULL); > >>> + if (ret) > >>> + return dev_err_probe(dev, ret, "Could not request IRQ %d\n", g_irq[i]); > >>> } > >>> > >>> l2_config_read(); > >>> @@ -234,4 +221,18 @@ static int __init sifive_l2_init(void) > >>> #endif > >>> return 0; > >>> } > >>> -device_initcall(sifive_l2_init); > >>> + > >>> +static const struct of_device_id sifive_l2_match[] = { > >>> + { .compatible = "sifive,fu540-c000-ccache" }, > >>> + { .compatible = "sifive,fu740-c000-ccache" }, > >>> + { /* sentinel */ } > >>> +}; > >>> + > >>> +static struct platform_driver sifive_l2_driver = { > >>> + .driver = { > >>> + .name = "sifive_l2_cache", > >>> + .of_match_table = sifive_l2_match, > >>> + .suppress_bind_attrs = true, > >>> + }, > >>> +}; > >>> +builtin_platform_driver_probe(sifive_l2_driver, sifive_l2_probe); > >> > >> > >> _______________________________________________ > >> linux-riscv mailing list > >> linux-riscv@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/linux-riscv > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv > > > > -- > Ben Dooks http://www.codethink.co.uk/ > Senior Engineer Codethink - Providing Genius > > https://www.codethink.co.uk/privacy.html >