From: Stefan Roese <stefan.roese@gmail.com>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] [PATCH] mpc5200: Add RTDM LPBFIFO driver and demo RTDM FPGA device driver
Date: Mon, 19 Nov 2012 13:58:57 +0100 [thread overview]
Message-ID: <50AA2D11.2060505@gmail.com> (raw)
In-Reply-To: <50A67BB8.2070903@xenomai.org>
Hi Gilles,
On 11/16/2012 06:45 PM, Gilles Chanteperdrix wrote:
> On 11/15/2012 03:19 PM, stefan.roese@gmail.com wrote:
>> +/*
>> + * NO_DMA:
>> + *
>> + * Define to enable memcpy() for blockdata transfer instead of DMA
>> + * support. This is available only for test purposes. Should be disabled
>> + * or even removed in the final driver version.
>> + */
>> +#if 0
>> +#define NO_DMA
>> +#endif
>> +
>> +/*
>> + * PRINT_READ_TIME:
>> + *
>> + * Print min and max times consumed by the blockdata transfer, either
>> + * per DMA or per memcpy. Should be disbaled or even removed in the
>> + * final driver version.
>> + */
>> +#if 1
>> +#define PRINT_READ_TIME
>> +#endif
>> +
>> +/*
>> + * DEBUG:
>> + *
>> + * Define to print debug informations. Should be disabled in the
>> + * final driver of course.
>> + */
>> +#if 0
>> +#define DEBUG
>> +#endif
>
> This is dead code, please use Kconfig or remove the dead code entirely.
Yes. Will move to Kconfig option.
>> + /*
>> + * Block until the blockdata is completely read into
>> + * the buffer (done in interrupt)
>> + */
>> + ret = rtdm_event_timedwait(&fpga_ctx->read_event,
>> + fpga_ctx->info->timeout, NULL);
>> +
>> + /*
>> + * Mark blockdata as read
>> + */
>> + fpga_ctx->blockdata_ready = 0;
>> +
>> + if (ret)
>> + return ret;
>
> You set blockdata_ready whatever the return value of
> rtdm_event_timedwait so, what if rtdm_event_timedwait fails?
Even when rtdm_event_timedwait() fails (timeout) the blockdata_ready
flag needs to be reset. As it marks the last read access from the
application (task) to be finished. So re-setting it to 0 even in the
timeout case was done intentionally here.
> and you do it without any kind of mutual exclusion, so, what if another
> thread or an irq is doing something between the call to
> rtdm_event_timedwait and the moment where that variable is set to 0?
Only one thread can access the read function at a time (synchronized
with ctx->reading). So there can be no clashes with other read-threads
here. And the interrupt shall set the blockdata_ready flag upon the
cycle data interrupt. To signal new data ready for reading. So I don't
see where some synchronization method is needed here.
Thanks for the review,
Stefan
prev parent reply other threads:[~2012-11-19 12:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 14:19 [Xenomai] [PATCH] mpc5200: Add RTDM LPBFIFO driver and demo RTDM FPGA device driver stefan.roese
2012-11-16 17:45 ` Gilles Chanteperdrix
2012-11-19 12:58 ` Stefan Roese [this message]
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=50AA2D11.2060505@gmail.com \
--to=stefan.roese@gmail.com \
--cc=gilles.chanteperdrix@xenomai.org \
--cc=xenomai@xenomai.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 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.