On Thu, Aug 27, 2015 at 03:21:17PM +0100, Qais Yousef wrote:
On 08/26/2015 07:43 PM, Mark Brown wrote:Any comments need to be comprehensible.
On Mon, Aug 24, 2015 at 01:39:14PM +0100, Qais Yousef wrote:This comment needs fixing. What it is trying to say is that if we reached
+ /*In what way will sempahores ensure that we will only read after a
+ * must ensure we have one access at a time to the queue and rd_idx
+ * to be preemption and SMP safe
+ * Sempahores will ensure that we will only read after a complete write
+ * has finished, so we will never read and write from the same location.
+ */
complete write?
this point of the code then we're certainly allowed to modify the buffer
queue and {rd, wr}_idx because the semaphore would have gone to sleep
otherwise if the queue is full/empty.
Should I just remove the reference to Semaphores from the comment or worth
rephrasing it?
Would it be better to rename {rd, wr}_{idx, sem} to {take, put}_{idx, sem}?I'm not sure that helps to be honest, the main issue is that the scheme
is fairly complex and unexplained.
Retiring buffers in the order they are acquired means that buffers areI don't think I get you here. axd_bufferq_take() and axd_bufferq_put() could+ buf = bufferq->queue[bufferq->rd_idx];So buffers are always retired in the same order that they are acquired?
be called in any order.
always freed in the same order they are acquired, you can't free one
buffer before another that was acquired first.
What this code is trying to do is make a contiguous memory area behave as aNo. Why are we doing this? Essentially all ALSA buffers are ring
ring buffer. Then this ring buffer behave as a queue. We use semaphore
counts to control how many are available to take/put. rd_idx and wr_idx
should always point at the next location to take/put from/to.
Does this help answering your question?
buffers handled in blocks, why does this one need this complex locking
scheme?
I'm not questioning what the functionns are doing, I'm questioning theirIf we want to restart the firmware we will need to abort any blocking reads+void axd_bufferq_abort_put(struct axd_bufferq *bufferq)These look *incredibly* racy. Why are they here and why are they safe?
+{
+ if (axd_bufferq_is_full(bufferq)) {
+ bufferq->abort_put = 1;
+ up(&bufferq->wr_sem);
+ }
+}
or writes for the user space to react. I also needed that to implement
implementation - it doesn't look like they are safe or reliable. They
just set a flag, relying on something else to notice that the flag has
been set and act appropriately before it goes on and corrupts data.
That just screams concurrency issues.
nonblocking access in user space when this was a sysfs based driver. It wasNobody cares about OMX ILs in mainline or sysfs based interfaces.
important then to implement omx IL component correctly.
Do I need to support nonblock reads and writes in ALSA? If I use SIGKILL asIt would be better to support non blocking access.
you suggested in the other email when restarting and nonblock is not
important then I can remove this.