All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexnader Kuleshov <kuleshovmail@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sh@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v6 2/2] clocksource: add J-Core timer/clocksource driver
Date: Thu, 04 Aug 2016 08:24:51 +0000	[thread overview]
Message-ID: <20160804082451.GA2509@localhost> (raw)
In-Reply-To: <f127e6d3f3ef64ea286b7b8f485e5d0c7f3faa6f.147018b3518.git.dalias@libc.org>

Hello Rich,

On 08-04-16, Rich Felker wrote:
> At the hardware level, the J-Core PIT is integrated with the interrupt
> controller, but it is represented as its own device and has an
> independent programming interface. It provides a 12-bit countdown
> timer, which is not presently used, and a periodic timer. The interval
> length for the latter is programmable via a 32-bit throttle register
> whose units are determined by a bus-period register. The periodic
> timer is used to implement both periodic and oneshot clock event
> modes; in oneshot mode the interrupt handler simply disables the timer
> as soon as it fires.
>
> Despite its device tree node representing an interrupt for the PIT,
> the actual irq generated is programmable, not hard-wired. The driver
> is responsible for programming the PIT to generate the hardware irq
> number that the DT assigns to it.
>
> On SMP configurations, J-Core provides cpu-local instances of the PIT;
> no broadcast timer is needed. This driver supports the creation of the
> necessary per-cpu clock_event_device instances. The code has been
> tested and works on SMP, but will not be usable without additional
> J-Core SMP-support patches and appropriate hardware capable of running
> SMP.
>
> A nanosecond-resolution clocksource is provided using the J-Core "RTC"
> registers, which give a 64-bit seconds count and 32-bit nanoseconds.
> The driver converts these to a 64-bit nanoseconds count.
>
> Signed-off-by: Rich Felker <dalias@libc.org>
> ...
> ...
> ...
> +
> +static int jcore_pit_set_state_shutdown(struct clock_event_device *ced)
> +{
> +	struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
> +
> +	return jcore_pit_disable(pit);
> +}
> +
> +static int jcore_pit_set_state_oneshot(struct clock_event_device *ced)
> +{
> +	struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
> +
> +	return jcore_pit_disable(pit);
> +}

Maybe to use only jcore_pit_set_state_shutdown() for both shutdown/oneshot
states as it is implemented for some of others clocksource drivers?

all the more so as described in your commit message, they do the same:

> in oneshot mode the interrupt handler simply disables the timer
> as soon as it fires

right?

> +static int __init jcore_pit_init(struct device_node *node)
> +{
> +	int err;
> +	unsigned pit_irq, cpu;
> +	unsigned long hwirq;
> +	u32 irqprio, enable_val;
> +
> +	jcore_pit_base = of_iomap(node, 0);
> +	if (!jcore_pit_base) {
> +		pr_err("Error: Cannot map base address for J-Core PIT\n");
> +		return -ENXIO;
> +	}
> +
> +	pit_irq = irq_of_parse_and_map(node, 0);
> +	if (!pit_irq) {
> +		pr_err("Error: J-Core PIT has no IRQ\n");
> +		return -ENXIO;
> +	}
> +
> +	pr_info("Initializing J-Core PIT at %p IRQ %d\n",
> +		jcore_pit_base, pit_irq);
> +
> +	jcore_cs.name = "jcore_pit_cs";
> +	jcore_cs.rating = 400;
> +	jcore_cs.read = jcore_clocksource_read;
> +	jcore_cs.mult = 1;
> +	jcore_cs.shift = 0;
> +	jcore_cs.mask = CLOCKSOURCE_MASK(32);
> +	jcore_cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
> +
> +	err = clocksource_register_hz(&jcore_cs, NSEC_PER_SEC);
> +	if (err) {
> +		pr_err("Error registering clocksource device: %d\n", err);
> +		return err;
> +	}
> +
> +	sched_clock_register(jcore_sched_clock_read, 32, NSEC_PER_SEC);
> +
> +	jcore_pit_percpu = alloc_percpu(struct jcore_pit);
> +	if (!jcore_pit_percpu) {
> +		pr_err("Failed to allocate memory for clock event device\n");
> +		return -ENOMEM;
> +	}
> +
> +	err = request_irq(pit_irq, jcore_timer_interrupt,
> +			  IRQF_TIMER | IRQF_PERCPU,
> +			  "jcore_pit", jcore_pit_percpu);
> +	if (err) {
> +		pr_err("pit irq request failed: %d\n", err);
> +		return err;
> +	}

free_percpu() missed in a case when request_irq() failed.


WARNING: multiple messages have this Message-ID (diff)
From: Alexnader Kuleshov <kuleshovmail@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sh@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v6 2/2] clocksource: add J-Core timer/clocksource driver
Date: Thu, 4 Aug 2016 14:24:51 +0600	[thread overview]
Message-ID: <20160804082451.GA2509@localhost> (raw)
In-Reply-To: <f127e6d3f3ef64ea286b7b8f485e5d0c7f3faa6f.147018b3518.git.dalias@libc.org>

Hello Rich,

On 08-04-16, Rich Felker wrote:
> At the hardware level, the J-Core PIT is integrated with the interrupt
> controller, but it is represented as its own device and has an
> independent programming interface. It provides a 12-bit countdown
> timer, which is not presently used, and a periodic timer. The interval
> length for the latter is programmable via a 32-bit throttle register
> whose units are determined by a bus-period register. The periodic
> timer is used to implement both periodic and oneshot clock event
> modes; in oneshot mode the interrupt handler simply disables the timer
> as soon as it fires.
>
> Despite its device tree node representing an interrupt for the PIT,
> the actual irq generated is programmable, not hard-wired. The driver
> is responsible for programming the PIT to generate the hardware irq
> number that the DT assigns to it.
>
> On SMP configurations, J-Core provides cpu-local instances of the PIT;
> no broadcast timer is needed. This driver supports the creation of the
> necessary per-cpu clock_event_device instances. The code has been
> tested and works on SMP, but will not be usable without additional
> J-Core SMP-support patches and appropriate hardware capable of running
> SMP.
>
> A nanosecond-resolution clocksource is provided using the J-Core "RTC"
> registers, which give a 64-bit seconds count and 32-bit nanoseconds.
> The driver converts these to a 64-bit nanoseconds count.
>
> Signed-off-by: Rich Felker <dalias@libc.org>
> ...
> ...
> ...
> +
> +static int jcore_pit_set_state_shutdown(struct clock_event_device *ced)
> +{
> +	struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
> +
> +	return jcore_pit_disable(pit);
> +}
> +
> +static int jcore_pit_set_state_oneshot(struct clock_event_device *ced)
> +{
> +	struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
> +
> +	return jcore_pit_disable(pit);
> +}

Maybe to use only jcore_pit_set_state_shutdown() for both shutdown/oneshot
states as it is implemented for some of others clocksource drivers?

all the more so as described in your commit message, they do the same:

> in oneshot mode the interrupt handler simply disables the timer
> as soon as it fires

right?

> +static int __init jcore_pit_init(struct device_node *node)
> +{
> +	int err;
> +	unsigned pit_irq, cpu;
> +	unsigned long hwirq;
> +	u32 irqprio, enable_val;
> +
> +	jcore_pit_base = of_iomap(node, 0);
> +	if (!jcore_pit_base) {
> +		pr_err("Error: Cannot map base address for J-Core PIT\n");
> +		return -ENXIO;
> +	}
> +
> +	pit_irq = irq_of_parse_and_map(node, 0);
> +	if (!pit_irq) {
> +		pr_err("Error: J-Core PIT has no IRQ\n");
> +		return -ENXIO;
> +	}
> +
> +	pr_info("Initializing J-Core PIT at %p IRQ %d\n",
> +		jcore_pit_base, pit_irq);
> +
> +	jcore_cs.name = "jcore_pit_cs";
> +	jcore_cs.rating = 400;
> +	jcore_cs.read = jcore_clocksource_read;
> +	jcore_cs.mult = 1;
> +	jcore_cs.shift = 0;
> +	jcore_cs.mask = CLOCKSOURCE_MASK(32);
> +	jcore_cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
> +
> +	err = clocksource_register_hz(&jcore_cs, NSEC_PER_SEC);
> +	if (err) {
> +		pr_err("Error registering clocksource device: %d\n", err);
> +		return err;
> +	}
> +
> +	sched_clock_register(jcore_sched_clock_read, 32, NSEC_PER_SEC);
> +
> +	jcore_pit_percpu = alloc_percpu(struct jcore_pit);
> +	if (!jcore_pit_percpu) {
> +		pr_err("Failed to allocate memory for clock event device\n");
> +		return -ENOMEM;
> +	}
> +
> +	err = request_irq(pit_irq, jcore_timer_interrupt,
> +			  IRQF_TIMER | IRQF_PERCPU,
> +			  "jcore_pit", jcore_pit_percpu);
> +	if (err) {
> +		pr_err("pit irq request failed: %d\n", err);
> +		return err;
> +	}

free_percpu() missed in a case when request_irq() failed.

  reply	other threads:[~2016-08-04  8:24 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03  0:18 [PATCH v6 0/2] J-Core timer support Rich Felker
2016-08-03  0:18 ` Rich Felker
     [not found] ` <cover.1470183518.git.dalias-8zAoT0mYgF4@public.gmane.org>
2016-03-17 23:12   ` [PATCH v6 2/2] clocksource: add J-Core timer/clocksource driver Rich Felker
2016-03-17 23:12     ` Rich Felker
2016-03-17 23:12     ` Rich Felker
2016-05-17 23:18 ` [PATCH v6 1/2] of: add J-Core timer bindings Rich Felker
2016-08-04  4:30 ` [PATCH v6 0/2] J-Core timer support Rich Felker
2016-08-04  4:30   ` Rich Felker
2016-08-04  4:30   ` Rich Felker
     [not found]   ` <cover.147018b3518.git.dalias-8zAoT0mYgF4@public.gmane.org>
2016-08-04  4:30     ` [PATCH v6 1/2] of: add J-Core timer bindings Rich Felker
2016-08-04  4:30       ` Rich Felker
2016-08-04  4:30       ` Rich Felker
     [not found]       ` <5e1d4f3346f69bdd9d840c8b5a855c1f93ff93f6.147018b3518.git.dalias-8zAoT0mYgF4@public.gmane.org>
2016-08-04 18:16         ` Rob Herring
2016-08-04 18:16           ` Rob Herring
2016-08-04 18:16           ` Rob Herring
2016-08-04  4:30     ` [PATCH v6 2/2] clocksource: add J-Core timer/clocksource driver Rich Felker
2016-08-04  4:30       ` Rich Felker
2016-08-04  4:30       ` Rich Felker
2016-08-04  8:24       ` Alexnader Kuleshov [this message]
2016-08-04  8:24         ` Alexnader Kuleshov
2016-08-04 19:42         ` Rich Felker
2016-08-04 19:42           ` Rich Felker
2016-08-24 16:42       ` Daniel Lezcano
2016-08-24 16:42         ` Daniel Lezcano
2016-08-24 17:40         ` Rich Felker
2016-08-24 17:40           ` Rich Felker
     [not found]           ` <20160824174001.GW15995-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2016-08-24 19:01             ` Marc Zyngier
2016-08-24 19:01               ` Marc Zyngier
2016-08-24 19:01               ` Marc Zyngier
2016-08-24 19:20               ` Rich Felker
2016-08-24 19:20                 ` Rich Felker
     [not found]                 ` <20160824192009.GX15995-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2016-08-24 22:21                   ` Mark Rutland
2016-08-24 22:21                     ` Mark Rutland
2016-08-24 22:21                     ` Mark Rutland
2016-08-24 20:01           ` Arnd Bergmann
2016-08-24 20:01             ` Arnd Bergmann
2016-08-24 20:52             ` Rich Felker
2016-08-24 20:52               ` Rich Felker
2016-08-24 21:22               ` Mark Rutland
2016-08-24 21:22                 ` Mark Rutland
2016-08-24 21:44                 ` Rich Felker
2016-08-24 21:44                   ` Rich Felker
2016-08-24 21:44                   ` Rich Felker
2016-08-24 21:57                   ` Arnd Bergmann
2016-08-24 21:57                     ` Arnd Bergmann
2016-08-25 10:23                     ` Arnd Bergmann
2016-08-25 10:23                       ` Arnd Bergmann
2016-08-24 22:54                   ` Mark Rutland
2016-08-24 22:54                     ` Mark Rutland
2016-08-25  8:07           ` Thomas Gleixner
2016-08-25  8:07             ` Thomas Gleixner
2016-08-25 14:56             ` Rich Felker
2016-08-25 14:56               ` Rich Felker
2016-08-25 14:56               ` Rich Felker
2016-08-25 15:41               ` Thomas Gleixner
2016-08-25 15:41                 ` Thomas Gleixner
2016-08-25 17:45                 ` Rich Felker
2016-08-25 17:45                   ` Rich Felker
2016-08-25 16:38               ` Mark Rutland
2016-08-25 16:38                 ` Mark Rutland
2016-08-25 17:51                 ` Rich Felker
2016-08-25 17:51                   ` Rich Felker
2016-08-25 18:21                   ` Mark Rutland
2016-08-25 18:21                     ` Mark Rutland
2016-08-25 19:20                     ` Rich Felker
2016-08-25 19:20                       ` Rich Felker
2016-08-26  9:04           ` Daniel Lezcano
2016-08-26  9:04             ` Daniel Lezcano

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=20160804082451.GA2509@localhost \
    --to=kuleshovmail@gmail.com \
    --cc=dalias@libc.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.