From: ladis@linux-mips.org (Ladislav Michl)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/6] Implement event capture for OMAP (draft)
Date: Fri, 23 Feb 2018 11:12:54 +0100 [thread overview]
Message-ID: <20180223101254.GA5746@lenoch> (raw)
Hi,
this patchset based on next-20180223 first cleans up playground (patches
1-4 which I'd appreciate to be reviewed and merged eventually) and then
adds event capture functionality which is just good for doing:
$ echo 0 > /sys/class/pwm/pwmchip4/export
$ cat /sys/class/pwm/pwmchip4/pwm0/capture
1000000 500000
$ cat /sys/class/pwm/pwmchip4/pwm0/capture
100000 50000
$ cat /sys/class/pwm/pwmchip4/pwm0/capture
100000 75000
Above measured frequencies are 1kHz and 10kHz with 50% duty cycle,
the last one is with 75% duty cycle. However with 100kHz it sometimes
ends with:
$ cat /sys/class/pwm/pwmchip4/pwm0/capture
omap_dm_timer_read_status: timer not available or enabled.
12462 6231
So locking is probably not done right, therefore patches 5 and 6 are sent
only for reference, as there's also another fundamental problem:
Hardware can be told to capture both edges, but there's no way to tell it
which one should be captured first. Other posibility would be first
configure for rising edge and reconfigure in interrupt for falling one.
Here we meet latency problem again:
https://www.spinics.net/lists/linux-omap/msg140081.html
Attached test patch shows average diff around 150us (sometimes over 300us)
which pretty much limits maximum measurable frequency.
I tried to misuse PM_QOS_CPU_DMA_LATENCY to overcome latency issue, but
with no luck.
Ladislav Michl (6):
clocksource: timer-ti-dm: Make unexported functions static
clocksource: timer-ti-dm: Consolidate set source
clocksource: timer-ti-dm: Check prescaler value
pwm: pwm-omap-dmtimer: Fix frequency when using prescaler
clocksource: timer-ti-dm: Add event capture
pwm: pwm-omap-dmtimer: Add capture functionality
drivers/clocksource/timer-ti-dm.c | 263 ++++++++++++++++-------------
drivers/pwm/pwm-omap-dmtimer.c | 220 +++++++++++++++++++-----
include/clocksource/timer-ti-dm.h | 33 ----
include/linux/platform_data/dmtimer-omap.h | 8 +
4 files changed, 340 insertions(+), 184 deletions(-)
Latency test patch:
diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c
index 5a2fc0e0a1c5..c1a94740079a 100644
--- a/drivers/pwm/pwm-omap-dmtimer.c
+++ b/drivers/pwm/pwm-omap-dmtimer.c
@@ -46,7 +46,7 @@ struct pwm_omap_dmtimer_chip {
const struct omap_dm_timer_ops *pdata;
struct platform_device *dm_timer_pdev;
unsigned long freq;
- unsigned int ev_cnt, overflow, width;
+ unsigned int ev_cnt, overflow, width, counter_irq, counter_captured;
};
static inline struct pwm_omap_dmtimer_chip *
@@ -280,6 +280,8 @@ static int pwm_omap_dmtimer_capture(struct pwm_chip *chip,
omap->ev_cnt = omap->width = 0;
spin_unlock_irqrestore(&omap->lock, flags);
+ printk("diff: %d\n", pwm_omap_dmtimer_ticks_to_ns(omap, omap->counter_irq - omap->counter_captured));
+
res = wait_event_interruptible_timeout(omap->wait,
omap->width > 0,
timeout);
@@ -317,6 +319,8 @@ static irqreturn_t pwm_omap_dmtimer_irq(int irq, void *dev_id)
if (l & OMAP_TIMER_INT_CAPTURE) {
if (!omap->width && omap->ev_cnt == 1) {
omap->pdata->read_capture(omap->dm_timer, &c1, &c2);
+ omap->counter_irq = omap->pdata->read_counter(omap->dm_timer);
+ omap->counter_captured = c2;
omap->width = pwm_omap_dmtimer_get_width(omap, c1, c2);
wake_up(&omap->wait);
}
--
2.16.1
next reply other threads:[~2018-02-23 10:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 10:12 Ladislav Michl [this message]
2018-02-23 10:13 ` [PATCH 1/6] clocksource: timer-ti-dm: Make unexported functions static Ladislav Michl
2018-02-27 18:06 ` Tony Lindgren
2018-02-27 19:07 ` Ladislav Michl
2018-02-27 19:23 ` Tony Lindgren
2018-02-28 22:11 ` Tony Lindgren
2018-02-23 10:14 ` [PATCH 2/6] clocksource: timer-ti-dm: Consolidate set source Ladislav Michl
2018-02-23 10:15 ` [PATCH 3/6] clocksource: timer-ti-dm: Check prescaler value Ladislav Michl
2018-02-23 10:15 ` [PATCH 4/6] pwm: pwm-omap-dmtimer: Fix frequency when using prescaler Ladislav Michl
2018-03-27 21:53 ` Thierry Reding
2018-03-27 22:14 ` Thierry Reding
2018-03-27 22:23 ` Tony Lindgren
2018-03-28 0:34 ` Ladislav Michl
2018-02-23 10:16 ` [PATCH 5/6] clocksource: timer-ti-dm: Add event capture Ladislav Michl
2018-02-23 10:17 ` [PATCH 6/6] pwm: pwm-omap-dmtimer: Add capture functionality Ladislav Michl
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=20180223101254.GA5746@lenoch \
--to=ladis@linux-mips.org \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).