From: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
To: Rich Felker <dalias-8zAoT0mYgF4@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Daniel Lezcano
<daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH v5 2/2] clocksource: add J-Core timer/clocksource driver
Date: Thu, 28 Jul 2016 16:44:05 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.11.1607281515330.19896@nanos> (raw)
In-Reply-To: <ed156509aed631486decf1828acb4f0afa61dd31.1469688975.git.dalias-8zAoT0mYgF4@public.gmane.org>
> +
> +#define PIT_IRQ_SHIFT 12
> +#define PIT_PRIO_SHIFT 20
> +#define PIT_ENABLE_SHIFT 26
> +#define PIT_IRQ_MASK 0x3f
> +#define PIT_PRIO_MASK 0xf
Can you please align the numbers as nicely as you did below and please use
TABS not spaces to seperate them.
> +#define REG_PITEN 0x00
> +#define REG_THROT 0x10
> +#define REG_COUNT 0x14
> +#define REG_BUSPD 0x18
> +#define REG_SECHI 0x20
> +#define REG_SECLO 0x24
> +#define REG_NSEC 0x28
> +
> +struct jcore_clocksource {
> + struct clocksource cs;
> + __iomem void *base;
> +};
> +
> +struct jcore_pit {
> + struct clock_event_device ced;
> + __iomem void *base;
> + unsigned long periodic_delta;
> + unsigned cpu;
> + u32 enable_val;
> +};
Again. Please align the struct members as I asked in the other mail.
> +
> +struct jcore_pit_nb {
> + struct notifier_block nb;
> + struct jcore_pit __percpu *pit_percpu;
> +};
> +
> +static struct clocksource *jcore_cs;
> +
> +static cycle_t jcore_clocksource_read(struct clocksource *cs)
> +{
> + __iomem void *base =
> + container_of(cs, struct jcore_clocksource, cs)->base;
> + u32 sechi, seclo, nsec, sechi0, seclo0;
It would be way simpler to read if you avoid that line break by doing:
u32 sechi, seclo, nsec, sechi0, seclo0;
__iomem void *base;
base = container_of(cs, struct jcore_clocksource, cs)->base;
Hmm?
> +
> + sechi = __raw_readl(base + REG_SECHI);
> + seclo = __raw_readl(base + REG_SECLO);
> + do {
> + sechi0 = sechi;
> + seclo0 = seclo;
> + nsec = __raw_readl(base + REG_NSEC);
> + sechi = __raw_readl(base + REG_SECHI);
> + seclo = __raw_readl(base + REG_SECLO);
> + } while (sechi0 != sechi || seclo0 != seclo);
> +
> + return ((u64)sechi << 32 | seclo) * NSEC_PER_SEC + nsec;
Wow, that's an expensive thing for a hotpath operation. You really don't have
binary readout register for that clock thingy?
> +}
> +
> +static notrace u64 jcore_sched_clock_read(void)
> +{
> + return jcore_clocksource_read(jcore_cs);
Why don't you stuff the above code into this function?
> +}
> +
> +static int jcore_pit_disable(struct jcore_pit *pit)
> +{
> + __raw_writel(0, pit->base + REG_PITEN);
> + return 0;
> +}
> +
> +static int jcore_pit_set(unsigned long delta, struct jcore_pit *pit)
> +{
> + jcore_pit_disable(pit);
> + __raw_writel(delta, pit->base + REG_THROT);
> + __raw_writel(pit->enable_val, pit->base + REG_PITEN);
> + return 0;
> +}
> +
> +static int jcore_pit_set_state_shutdown(struct clock_event_device *ced)
> +{
> + struct jcore_pit *pit = container_of(ced, struct jcore_pit, ced);
Newline between declaration and code please....
> + return jcore_pit_disable(pit);
> +}
> +static int jcore_pit_cpu_notify(struct notifier_block *self,
> + unsigned long action, void *hcpu)
> +{
> + struct jcore_pit_nb *nb = container_of(self, struct jcore_pit_nb, nb);
> + switch (action & ~CPU_TASKS_FROZEN) {
> + case CPU_STARTING:
> + jcore_pit_local_init(this_cpu_ptr(nb->pit_percpu));
> + break;
> + }
> + return NOTIFY_OK;
Please convert this to the new state machine model of cpu
hotplug. CPU_STARTING will be gone very soon. Here is an example:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=smp/hotplug&id=7e86e8bd8dd67649d176e08d8dfb90039f0a1e98
> +static int __init jcore_pit_init(struct device_node *node)
> +{
> + int err;
> + __iomem void *pit_base;
> + unsigned pit_irq;
> + unsigned cpu;
Please put the same data types into a single line
> + struct jcore_pit_nb *nb = 0;
= NULL;
Please
> + struct jcore_clocksource *cs = 0;
> + struct jcore_pit __percpu *pit_percpu = 0;
> +
> + err = request_irq(pit_irq, jcore_timer_interrupt,
> + IRQF_TIMER | IRQF_PERCPU, "jcore_pit", pit_percpu);
If you need line breaks, then please keep the arguments aligned:
err = request_irq(pit_irq, jcore_timer_interrupt,
IRQF_TIMER | IRQF_PERCPU, "jcore_pit", pit_percpu);
> + /* The J-Core PIT is not hard-wired to a particular IRQ, but
> + * integrated with the interrupt controller such that the IRQ it
> + * generates is programmable. The programming interface has a
> + * legacy field which was an interrupt priority for AIC1, but
> + * which is OR'd onto bits 2-5 of the generated IRQ number when
> + * used with J-Core AIC2, so set it to match these bits. */
Proper multiline comments please
> + return 0;
> +
> +out:
> + pr_err("Could not initialize J-Core PIT driver\n");
So you have a pr_err in every error path and that goto just to pr_err the
obvious? Well, yes ...
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-07-28 14:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 6:56 [PATCH v5 0/2] J-Core timer support Rich Felker
2016-03-17 23:12 ` [PATCH v5 2/2] clocksource: add J-Core timer/clocksource driver Rich Felker
[not found] ` <ed156509aed631486decf1828acb4f0afa61dd31.1469688975.git.dalias-8zAoT0mYgF4@public.gmane.org>
2016-07-28 14:44 ` Thomas Gleixner [this message]
2016-07-28 16:37 ` Rich Felker
[not found] ` <20160728163748.GI15995-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2016-07-28 16:44 ` Thomas Gleixner
2016-07-28 19:34 ` Rich Felker
2016-07-28 20:00 ` Rich Felker
2016-07-28 20:18 ` Rich Felker
2016-07-31 16:08 ` Rich Felker
2016-05-17 23:18 ` [PATCH v5 1/2] of: add J-Core timer bindings Rich Felker
2016-07-29 20:49 ` Rob Herring
[not found] ` <afa8eaaebc9216e83e542e9bcad8fa1dd659d489.1469688975.git.dalias-8zAoT0mYgF4@public.gmane.org>
2016-08-02 22:57 ` Rich Felker
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=alpine.DEB.2.11.1607281515330.19896@nanos \
--to=tglx-hfztesqfncyowbw4kg4ksq@public.gmane.org \
--cc=dalias-8zAoT0mYgF4@public.gmane.org \
--cc=daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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