From patchwork Thu Mar 3 12:37:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 8492421 Return-Path: X-Original-To: patchwork-qemu-devel@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 C3C319F2F0 for ; Thu, 3 Mar 2016 12:41:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 270EC202FF for ; Thu, 3 Mar 2016 12:41:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75F3720295 for ; Thu, 3 Mar 2016 12:41:27 +0000 (UTC) Received: from localhost ([::1]:34677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abSZK-0003ez-Uc for patchwork-qemu-devel@patchwork.kernel.org; Thu, 03 Mar 2016 07:41:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abSVp-00066s-MU for qemu-devel@nongnu.org; Thu, 03 Mar 2016 07:37:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abSVj-0004YC-2f for qemu-devel@nongnu.org; Thu, 03 Mar 2016 07:37:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abSVi-0004Xt-TW for qemu-devel@nongnu.org; Thu, 03 Mar 2016 07:37:43 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8B32E627C1; Thu, 3 Mar 2016 12:37:42 +0000 (UTC) Received: from localhost (ovpn-113-82.phx2.redhat.com [10.3.113.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u23Cbeh8025496; Thu, 3 Mar 2016 07:37:41 -0500 From: Amit Shah To: Peter Maydell Date: Thu, 3 Mar 2016 18:07:11 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 03 Mar 2016 12:37:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Amit Shah , thuth@redhat.com, lprosek@redhat.com, qemu list Subject: [Qemu-devel] [PULL 6/6] virtio-rng: ask for more data if queue is not fully drained X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Ladi Prosek This commit effectively reverts: commit 4621c1768ef5d12171cca2aa1473595ecb9f1c9e Author: Amit Shah Date: Wed Nov 21 11:21:19 2012 +0530 virtio-rng: remove extra request for entropy but instead of calling virtio_rng_process unconditionally, it first checks to see if the queue is empty as a little bit of optimization. Signed-off-by: Ladi Prosek Reviewed-by: Amit Shah Message-Id: <1456998514-19271-1-git-send-email-lprosek@redhat.com> Signed-off-by: Amit Shah --- hw/virtio/virtio-rng.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 17da2f8..d713464 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -69,6 +69,13 @@ static void chr_read(void *opaque, const void *buf, size_t size) g_free(elem); } virtio_notify(vdev, vrng->vq); + + if (!virtio_queue_empty(vrng->vq)) { + /* If we didn't drain the queue, call virtio_rng_process + * to take care of asking for more data as appropriate. + */ + virtio_rng_process(vrng); + } } static void virtio_rng_process(VirtIORNG *vrng)