Re: [PATCH 1/4] iommu: Add virtio-iommu driver

From
Jean-Philippe Brucker <hidden>
Date
2018-02-20 11:30:41
On 19/02/18 12:23, Tomasz Nowicki wrote:
[...]
quoted
+static int viommu_receive_resp(struct viommu_dev *viommu, int nr_sent,
+			       struct list_head *sent)
+{
+
+	unsigned int len;
+	int nr_received = 0;
+	struct viommu_request *req, *pending;
+
+	pending = list_first_entry_or_null(sent, struct viommu_request, list);
+	if (WARN_ON(!pending))
+		return 0;
+
+	while ((req = virtqueue_get_buf(viommu->vq, &len)) != NULL) {
+		if (req != pending) {
+			dev_warn(viommu->dev, "discarding stale request\n");
+			continue;
+		}
+
+		pending->written = len;
+
+		if (++nr_received == nr_sent) {
+			WARN_ON(!list_is_last(&pending->list, sent));
+			break;
+		} else if (WARN_ON(list_is_last(&pending->list, sent))) {
+			break;
+		}
+
+		pending = list_next_entry(pending, list);
We should remove current element from the pending list. There is no 
guarantee we get response for each while loop so when we get back for 
more the _viommu_send_reqs_sync() caller will pass pointer to the out of 
date head next time.
Right, I'll fix this

Thanks,
Jean
Thread (1 message) 1 message, 1 author, last reply 2018-02-20
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help