From patchwork Tue Mar 22 06:51:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Chen X-Patchwork-Id: 8638271 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9BB79F44D for ; Tue, 22 Mar 2016 06:51:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C42D82034E for ; Tue, 22 Mar 2016 06:51:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E80992038F for ; Tue, 22 Mar 2016 06:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754191AbcCVGvU (ORCPT ); Tue, 22 Mar 2016 02:51:20 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35214 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbcCVGvS (ORCPT ); Tue, 22 Mar 2016 02:51:18 -0400 Received: by mail-pf0-f173.google.com with SMTP id n5so296989663pfn.2; Mon, 21 Mar 2016 23:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=EQ950DhNq/0mxC/C0wJLIml/ZEzGUlFY8fTeKRKK/Cg=; b=m6G5wXh2+eeBIX24f99f71SyP6lG5ix7KKMCRGydLAd9BI9+S12zFpESIUorg9D7o5 xTr4kInlVtbgqd6/ALJeBm3lTBjlJI3KWlcyv1s7nHjj4VV9tx6kG7+3WF/RR+fwuWZU RXvMGwvdtGcipF5xKwaBir7pWtiz8mUApdSLUIqsG+iBooq/XwMvgDjePGkJ0Sw964D1 oswjaNeGD7qf37BHalbPhNvQXD8lxyr4m5+nQ4YqTdNlDPvcRsMf/Ar31wQeYgs6OMmJ 9CAnVTTPbmJ4Gz8Ahme09YWXz//sUvme9bp0FHMU251vknMhDMEvarUEkNqve4Q6K74Y 4z8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EQ950DhNq/0mxC/C0wJLIml/ZEzGUlFY8fTeKRKK/Cg=; b=fxmnj2V4lfTiBkb0wf2TXCBRI2DQ/nUhlkNF3gYIDYT1ocXYZBbLDKZiKKTvIIm3aG atsmzntvxfoha4L6LmWGhPwl+Yot7HFCSM38Sq21or641JW137y2zQp5xvIar0CccPEz YdevC1GLd+a2v8tNz+bP9GVQBFpfy1Etr6f0TUNZd1cJjBh0Cj0n7ZlJ8cJ/PH4ve1dG 8m3/XJoeFHBqOeTFfCrzcf1nIBTrOtzKrAnLjh75NQXuQZxdH9A0VYypaxEoY9zC4lWb qgxfRRr2EcZEPb0S50GsE9C3xkz4sfADeJIeYyD9ryYwyAXMI4c219UsZhhmZXUjGXXa giwQ== X-Gm-Message-State: AD7BkJJZgG4Ky94ZIoONu8Ep5UFNzpLKX/EeByCVqLo5uxRY6PzX13c2WJvlkDiVx9VbKg== X-Received: by 10.67.24.104 with SMTP id ih8mr51797193pad.124.1458629477606; Mon, 21 Mar 2016 23:51:17 -0700 (PDT) Received: from localhost.localdomain ([23.252.122.22]) by smtp.gmail.com with ESMTPSA id ux2sm45433534pac.46.2016.03.21.23.51.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Mar 2016 23:51:17 -0700 (PDT) From: Liang Chen To: kvm@vger.kernel.org Cc: mst@redhat.com, linux-kernel@vger.kernel.org, pbonzini@redhat.com, jay.vosburgh@canonical.com, Liang Chen , Gavin Guo Subject: [PATCH] virtio-pci: use possible fallback queue size Date: Tue, 22 Mar 2016 14:51:08 +0800 Message-Id: <1458629468-27184-1-git-send-email-liangchen.linux@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Virtio 1.0 spec allows driver to modify queue size to reduce momery requeirments. So the driver should write back the queue size actually allocated, instead of the original value read from the common config for the queue. Signed-off-by: Liang Chen Signed-off-by: Gavin Guo Suggested-by: Jay Vosburgh --- drivers/virtio/virtio_pci_common.h | 2 +- drivers/virtio/virtio_pci_modern.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h index 2cc2522..32ee993 100644 --- a/drivers/virtio/virtio_pci_common.h +++ b/drivers/virtio/virtio_pci_common.h @@ -36,7 +36,7 @@ struct virtio_pci_vq_info { struct virtqueue *vq; /* the number of entries in the queue */ - int num; + u16 num; /* the virtual address of the ring queue */ void *queue; diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 7760fc1..7f9ccac 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -293,7 +293,7 @@ static size_t vring_pci_size(u16 num) return PAGE_ALIGN(vring_size(num, SMP_CACHE_BYTES)); } -static void *alloc_virtqueue_pages(int *num) +static void *alloc_virtqueue_pages(u16 *num) { void *pages; @@ -360,7 +360,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, } /* activate the queue */ - vp_iowrite16(num, &cfg->queue_size); + vp_iowrite16(info->num, &cfg->queue_size); vp_iowrite64_twopart(virt_to_phys(info->queue), &cfg->queue_desc_lo, &cfg->queue_desc_hi); vp_iowrite64_twopart(virt_to_phys(virtqueue_get_avail(vq)),