From: Michael S. Tsirkin Date: Thu, 1 Nov 2012 09:16:42 +0000 (+0000) Subject: vhost: track zero copy failures using DMA length X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c4fcb586c337f8b8de3a3d7ba8514eed03695f6e;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git vhost: track zero copy failures using DMA length This will be used to disable zerocopy when error rate is high. Signed-off-by: Michael S. Tsirkin Signed-off-by: David S. Miller --- diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index f23cf8956d19..5affce325031 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -425,7 +425,7 @@ int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq) int j = 0; for (i = vq->done_idx; i != vq->upend_idx; i = (i + 1) % UIO_MAXIOV) { - if ((vq->heads[i].len == VHOST_DMA_DONE_LEN)) { + if (VHOST_DMA_IS_DONE(vq->heads[i].len)) { vq->heads[i].len = VHOST_DMA_CLEAR_LEN; vhost_add_used_and_signal(vq->dev, vq, vq->heads[i].id, 0); @@ -1600,13 +1600,14 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs) kfree(ubufs); } -void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool status) +void vhost_zerocopy_callback(struct ubuf_info *ubuf, int status) { struct vhost_ubuf_ref *ubufs = ubuf->ctx; struct vhost_virtqueue *vq = ubufs->vq; vhost_poll_queue(&vq->poll); /* set len to mark this desc buffers done DMA */ - vq->heads[ubuf->desc].len = VHOST_DMA_DONE_LEN; + vq->heads[ubuf->desc].len = status ? + VHOST_DMA_FAILED_LEN : VHOST_DMA_DONE_LEN; kref_put(&ubufs->kref, vhost_zerocopy_done_signal); } diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index b6538eef7468..464469d901d5 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -17,6 +17,8 @@ * For transmit, used buffer len is unused; we override it to track buffer * status internally; used for zerocopy tx only. */ +/* Lower device DMA failed */ +#define VHOST_DMA_FAILED_LEN 3 /* Lower device DMA done */ #define VHOST_DMA_DONE_LEN 2 /* Lower device DMA in progress */ @@ -24,6 +26,8 @@ /* Buffer unused */ #define VHOST_DMA_CLEAR_LEN 0 +#define VHOST_DMA_IS_DONE(len) ((len) >= VHOST_DMA_DONE_LEN) + struct vhost_device; struct vhost_work;