Re: [PATCH] iommu/arm-smmu-v3: poll cmdq until it has space

From: John Garry
Date: Tue Sep 21 2021 - 12:20:03 EST


On 21/09/2021 12:43, Fernand Sieber wrote:
do {

I didn't follow the full logic of this change yet ...

llq->val = READ_ONCE(cmdq->q.llq.val);
- if (!queue_full(llq))
+ if (!queue_has_space(llq, n))

But is the polarity really correct? That is, if we don't have space, then exit with success (the function to check for space).

break;

+ /*
+ * We must return here even if there's no space, because the producer
+ * having moved forward could mean that the last thread observing the
+ * SMMU progress has allocated space in the cmdq and moved on, leaving
+ * us in this waiting loop with no other thread updating
+ * llq->state->val.

what is llq->state->val?

+ */
+ if (llq->prod != prod)
+ return -EAGAIN;
+
ret = queue_poll(&qp);

Thanks,
John