Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3424255ioa; Tue, 26 Apr 2022 03:29:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylYuJkmij908xu2Ta3mHTbGp6sxKPH1gzLc003k/lZWPgD7/2xqeO0X/aQKRKOZnN7CAC/ X-Received: by 2002:a17:906:9b85:b0:6db:ab80:7924 with SMTP id dd5-20020a1709069b8500b006dbab807924mr20748016ejc.160.1650968975476; Tue, 26 Apr 2022 03:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650968975; cv=none; d=google.com; s=arc-20160816; b=dFI3Ik/EuSTGMVpaKsVvAwiMjG/WWGzO7JvWWdwGNQbIfJjGm1S9L7f57gR5PZeAQd WZxUMS6TPZu7UKISNBjF3BqA2uxxjZWYBu7h33Gbe8MxgMQFcwWych3gaSHkQqVwu+yh gBehlop7DWC58u3t0G6RQrzvLpgqa0c1zVVn/VBDLRTeLpHxT5KJiJJwCYJy7fGxSQIm pGSJ08A9gcVrPf0fqXmph2ohhxuEbnPVFpCmd6r8UT51HPrEG8u+RzJUT5gqS5KzC9dA VgtOFPpNW6v6xJIIpyWATSL1gzBelOIPMVZVQ1ZklQONJjSgMVxofIOiAOOK3DNOu1TW Ighw== 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; bh=6Y9C4jl3Bp88BlIhj/usQSVhy8ERpu+fkzEmtY4+0E8=; b=AUfCA2N64ODTc4XoK2nrRk0AA3OsQe3nY8/1Djfqe6rphQkoPYWXBpunIxEZvLQHzE ZQ8w9jSpuNWgELxM3J3l1xBj4h4kjNBoCRSEe03aUTbeCzpVDas3DRhRQgQvOIlisYTl zA3jWy+p3VVsAkiQtWtd1RDen4aKaMOl8ntEpLdW6OmHueUL2dJyNQ4HpQZePvjvzaCJ CGYeO/FnOitg4nJ8dS8BVNo40mRKL6MHstWi/bWPibUDngfl++IWT6dTeAok92clVUxy DBpuY8rWd8avD2dA1C+w9Q8E+b6CMJgHrSyMuOXaMKl8vGLZBxjqz2NAOVIuEegddUit K03g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id en19-20020a056402529300b00425d432b98esi6368332edb.294.2022.04.26.03.29.10; Tue, 26 Apr 2022 03:29:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241382AbiDZGDs (ORCPT + 99 others); Tue, 26 Apr 2022 02:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236019AbiDZGDq (ORCPT ); Tue, 26 Apr 2022 02:03:46 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DD461403F for ; Mon, 25 Apr 2022 23:00:39 -0700 (PDT) Received: from mail-wm1-f54.google.com ([209.85.128.54]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MhlbM-1oMhnx2qzA-00dpqY for ; Tue, 26 Apr 2022 08:00:37 +0200 Received: by mail-wm1-f54.google.com with SMTP id a14-20020a7bc1ce000000b00393fb52a386so189630wmj.1 for ; Mon, 25 Apr 2022 23:00:37 -0700 (PDT) X-Gm-Message-State: AOAM5332PPBj6JFqHeTpTpw1AGbZ9BDpRHt9Zvo2CsOt/ukxypXO0+zI Xgs3UKa0jupYQFn8dX+foPCGfDYdEgr9KsM+DdY= X-Received: by 2002:a1c:f219:0:b0:38c:782c:3bb with SMTP id s25-20020a1cf219000000b0038c782c03bbmr28016089wmc.94.1650952837280; Mon, 25 Apr 2022 23:00:37 -0700 (PDT) MIME-Version: 1.0 References: <20220421192132.109954-1-nick.hawkins@hpe.com> <20220421192132.109954-5-nick.hawkins@hpe.com> In-Reply-To: From: Arnd Bergmann Date: Tue, 26 Apr 2022 08:00:20 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 04/11] clocksource/drivers: Add HPE GXP timer To: Linus Walleij Cc: Arnd Bergmann , "Hawkins, Nick" , "Verdun, Jean-Marie" , Joel Stanley , OpenBMC Maillist , Daniel Lezcano , Thomas Gleixner , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:F+NFwuLXS6I9UmDvbjVRMD/vYazHkoSCiI07zytWSzv2FW5FnNs J5xWhK4YMKsukdmB90kv9kx7ua49jPlWwVYFgmiMctVWhuYGuMqxM9PV9nt1Zi0aEXvcxWh 6ybDUNu2tkne+TT8sK4CTQFFUQmm1836hzv78LRzELDwGEcY6jnS+iUEkRfsWBKJfhW5C8X qxa8AUxgE1AsDc6rWxrMg== X-UI-Out-Filterresults: notjunk:1;V03:K0:6nR1b0EwYGw=:5cvFw57fTOrLA9Y6AofL7V A9Hlrhr78PkASx0E4550Ij0rv75xbDEckyrOvOpP3nLYHzj9LDm+u8451R57GiwcyxrxokjEX axVwEjKEdYGeH/JDm3EXT2dwZrfKHCrJ3gVgQsZPQOOEQEQ2FsfllH+keoIbzoX7afFeATfBd yBTHxQ3w70bkmDcVAGH3WlgFziNnGDxD0jsyl8w1nG1h6X6KsBZ1Cv9GstJXRb9KuwrRDx1DC +9eUmEP3SSoyLN9VUBcvFVlvSPPGmYg0gk3zk+v/bujlCYsG4/PBFCBtsXdPBNOJBTUREgsZ9 IbYv25gim4n+UcR5op3l7Y2E0kqNsQuNk3yJI5HG7PUPM5el6SQyOD4y8GYVw/R9D1bixv3Eq jAKK7rfgmAOvr/Bgj7dFbi2xvoNYfETXcd2vVKil/1CMkegbq6oJYHJWFb3IZ8E6DUfx+GsLx 0Hr3hn1be5wS3bLISCDoc9yWdrOj2O5yvKeULsQe5YZssuIYARSNmu34hwPoCbj2xEHjzbxU0 2zSbZAPfPYcY4WkTKQKPUtuo3rnQUxjpRZJ+NE77XppqLg7ByCDRi/s2oq4d+tll7dniaK24n eLLDm9Crg5ZYemwpxRuWVuT2QwZGtgWZBAWO9iz5xPbS7BCN+2FmHEU2M1LZF+WAayJYwo5xF C1MQ7kNZzNw8xbsJ8mwUyQnbO3vVbX0c8hc0MkdS9Xo3SdY3CkApCP1RAWsDMCWq7tJk= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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 Mon, Apr 25, 2022 at 10:38 PM Linus Walleij wrote: > On Fri, Apr 22, 2022 at 3:16 PM Arnd Bergmann wrote: > > On Thu, Apr 21, 2022 at 9:21 PM wrote: > > > > > + > > > +static struct platform_device gxp_watchdog_device = { > > > + .name = "gxp-wdt", > > > + .id = -1, > > > +}; > > > +/* > > > + * This probe gets called after the timer is already up and running. This will create > > > + * the watchdog device as a child since the registers are shared. > > > + */ > > > + > > > +static int gxp_timer_probe(struct platform_device *pdev) > > > +{ > > > + struct device *dev = &pdev->dev; > > > + > > > + /* Pass the base address (counter) as platform data and nothing else */ > > > + gxp_watchdog_device.dev.platform_data = local_gxp_timer->counter; > > > + gxp_watchdog_device.dev.parent = dev; > > > + return platform_device_register(&gxp_watchdog_device); > > > +} > > > > I don't understand what this is about: the device should be created from > > DT, not defined statically in the code. There are multiple ways of creating > > a platform_device from a DT node, or you can allocate one here, but static > > definitions are generally a mistake. > > > > I see that you copied this from the ixp4xx driver, so I think we should fix this > > there as well. > > The ixp4xx driver looks like that because the register range used for > the timer and the watchdog is combined, i.e. it is a single IP block: > > timer@c8005000 { > compatible = "intel,ixp4xx-timer"; > reg = <0xc8005000 0x100>; > interrupts = <5 IRQ_TYPE_LEVEL_HIGH>; > }; > > Device tree probing does not allow two devices to probe from the same > DT node, so this was solved by letting the (less important) watchdog > be spawn as a platform device from the timer. > > I don't know if double-probing for the same register range can be fixed, > but I was assuming that the one-compatible-to-one-driver assumption > was pretty hard-coded into the abstractions. Maybe it isn't? Having a child device is fine, my objection was about the way the device is created from a 'static platform_device ...' definition rather than having the device structure allocated at probe time. > Another way is of course to introduce an MFD. That becomes > problematic in another way: MFD abstractions are supposed to > be inbetween the resource and the devices it spawns, and with > timers/clocksources this creates a horrible special-casing since the > MFD bus (the parent may be providing e.g. an MMIO regmap) > then need to be early-populated and searched by the timer core > from TIMER_OF_DECLARE() early in boot. > > So this solution was the lesser evil that I could think about. There are multiple ways of doing this that we already discussed in the thread. The easiest is probably to have a child node without custom registers in the DT and then use the DT helpers to populate the linux devices with the correct data. Arnd