public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: nick.hawkins@hpe.com, verdun@hpe.com, nick.hawkins@hpe.com,
	joel@jms.id.au, arnd@arndb.de, openbmc@lists.ozlabs.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 04/11] clocksource/drivers: Add HPE GXP timer
Date: Fri, 22 Apr 2022 16:56:26 +0200	[thread overview]
Message-ID: <87o80t5fqd.ffs@tglx> (raw)
In-Reply-To: <20220421192132.109954-5-nick.hawkins@hpe.com>

On Thu, Apr 21 2022 at 14:21, nick hawkins wrote:
> +
> +static struct gxp_timer *local_gxp_timer;

What is local about that time?

> +static void __iomem *system_clock __read_mostly;

__ro_after_init perhaps?

> +static inline struct gxp_timer *to_gxp_timer(struct clock_event_device *evt_dev)
> +{
> +	return container_of(evt_dev, struct gxp_timer, evt);
> +}
> +
> +static u64 notrace gxp_sched_read(void)
> +{
> +	return readl_relaxed(system_clock);
> +}
> +
> +static int gxp_time_set_next_event(unsigned long event,	struct clock_event_device *evt_dev)

Stray TAB in arguments

> +static int __init gxp_timer_init(struct device_node *node)
> +{
> +	void __iomem *base;
> +	struct clk *clk;
> +	u32 freq;
> +	int ret, irq;
> +	struct gxp_timer *gxp_timer;
> +
> +	base = of_iomap(node, 0);
> +	if (!base) {
> +		pr_err("Can't remap timer base register");
> +		ret = -ENXIO;
> +		return ret;
> +	}
> +
> +	/*Set the offset to the clock register*/
> +	system_clock = base + GXP_TIMESTAMP_OFS;
> +
> +	clk = of_clk_get(node, 0);
> +	if (IS_ERR(clk)) {
> +		pr_err("%pOFn clock not found: %d\n", node, (int)PTR_ERR(clk));
> +		ret = -EIO;
> +		goto err_iounmap;
> +	}
> +
> +	ret = clk_prepare_enable(clk);
> +
> +	freq = clk_get_rate(clk);
> +
> +	sched_clock_register(gxp_sched_read, 32, freq);
> +	clocksource_mmio_init(system_clock, node->name, freq,
> +			      300, 32, clocksource_mmio_readl_up);

So this registers sched clock and clocksource and if one of the
following fails....

> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0) {
> +		ret = -EINVAL;
> +		pr_err("GXP Timer Can't parse IRQ %d", irq);
> +		goto err_iounmap;

... the error path unmaps 'system_clock'

> +	}
> +
> +	gxp_timer = kzalloc(sizeof(*gxp_timer), GFP_KERNEL);
> +	if (!gxp_timer) {
> +		ret = -ENOMEM;
> +		goto err_iounmap;
> +	}
> +
> +	gxp_timer->counter = base + GXP_TIMER_CNT_OFS;
> +	gxp_timer->control = base + GXP_TIMER_CTRL_OFS;
> +	gxp_timer->evt.name = node->name;
> +	gxp_timer->evt.rating = 300;
> +	gxp_timer->evt.features = CLOCK_EVT_FEAT_ONESHOT;
> +	gxp_timer->evt.set_next_event = gxp_time_set_next_event;
> +	gxp_timer->evt.cpumask = cpumask_of(0);
> +
> +	local_gxp_timer = gxp_timer;
> +
> +	ret = request_irq(irq, gxp_timer_interrupt, IRQF_TIMER | IRQF_SHARED,
> +			  node->name, gxp_timer);
> +	if (ret) {
> +		pr_err("%s: request_irq() failed %pe\n", "GXP Timer Tick", ERR_PTR(ret));
> +		goto err_iounmap;

... and here as a bonus leaks gxp_timer.

> +	}
> +
> +	clockevents_config_and_register(&gxp_timer->evt, TIMER0_FREQ,
> +					0xf, 0xffffffff);
> +
> +	pr_debug("gxp: system timer (irq = %d)\n", irq);
> +	return 0;
> +
> +err_iounmap:
> +	iounmap(system_clock);
> +	iounmap(base);
> +	return ret;
> +}

Thanks,

        tglx

  parent reply	other threads:[~2022-04-22 14:56 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 19:21 [PATCH v5 01/11] aach: arm: mach-hpe: Introduce the HPE GXP architecture nick.hawkins
2022-04-21 19:21 ` [PATCH v5 01/11] archh: " nick.hawkins
2022-04-22 13:20   ` Arnd Bergmann
2022-04-21 19:21 ` [PATCH v5 02/11] arch: arm: configs: multi_v7_defconfig nick.hawkins
2022-04-23 11:06   ` Krzysztof Kozlowski
2022-04-29 20:34     ` Hawkins, Nick
2022-04-30 11:40       ` Krzysztof Kozlowski
2022-04-23 11:08   ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 03/11] drivers: wdt: Introduce HPE GXP SoC Watchdog nick.hawkins
2022-04-21 19:21 ` [PATCH v5 04/11] clocksource/drivers: Add HPE GXP timer nick.hawkins
2022-04-22 13:16   ` Arnd Bergmann
2022-04-25 20:38     ` Linus Walleij
2022-04-25 21:05       ` Jonathan Neuschäfer
2022-04-26  6:00       ` Arnd Bergmann
2022-04-26 21:38         ` Rob Herring
2022-04-26 21:55           ` Arnd Bergmann
2022-04-26 22:04             ` Rob Herring
2022-04-26 22:26               ` Arnd Bergmann
2022-04-22 14:56   ` Thomas Gleixner [this message]
2022-04-21 19:21 ` [PATCH v5 05/11] dt-bindings: timer: Add HPE GXP Timer Binding nick.hawkins
2022-04-23 10:50   ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 06/11] dt-bindings: watchdog: Add HPE GXP Watchdog timer binding nick.hawkins
2022-04-23 10:52   ` Krzysztof Kozlowski
2022-04-25 22:04   ` Rob Herring
2022-04-26 13:21     ` Hawkins, Nick
2022-04-26 13:34       ` Krzysztof Kozlowski
2022-04-26 13:52         ` Hawkins, Nick
2022-04-26 15:44           ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 07/11] dt-bindings: arm: Add HPE GXP Binding nick.hawkins
2022-04-23 10:58   ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 08/11] dt-bindings: usb: generic-ehci: Add HPE GXP ehci binding nick.hawkins
2022-04-23 10:52   ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 09/11] dt-bindings: usb: generic-ohci: Add HPE GXP ohci binding nick.hawkins
2022-04-23 10:53   ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 10/11] arch: arm: boot: dts: Introduce HPE GXP Device tree nick.hawkins
2022-04-22 13:06   ` Arnd Bergmann
2022-04-23 11:01   ` Krzysztof Kozlowski
2022-04-26  7:22   ` Krzysztof Kozlowski
2022-04-21 19:21 ` [PATCH v5 11/11] maintainers: Introduce HPE GXP Architecture nick.hawkins
2022-04-23 11:04 ` [PATCH v5 01/11] aach: arm: mach-hpe: Introduce the HPE GXP architecture Krzysztof Kozlowski
2022-04-25 15:00   ` Hawkins, Nick
2022-04-26  8:25 ` Paul Menzel
2022-04-26 17:28   ` Hawkins, Nick
2022-04-26 17:50     ` Paul Menzel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o80t5fqd.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=daniel.lezcano@linaro.org \
    --cc=joel@jms.id.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick.hawkins@hpe.com \
    --cc=openbmc@lists.ozlabs.org \
    --cc=verdun@hpe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox