Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6251116imu; Mon, 21 Jan 2019 05:52:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7h7lZgIHby5w6/ZAKu4eqf+8As0Y9L2fl4HCjUYwF7dse7D/PABgR4btMDMQ0Gg72mAbtR X-Received: by 2002:a17:902:968d:: with SMTP id n13mr30740594plp.109.1548078722766; Mon, 21 Jan 2019 05:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548078722; cv=none; d=google.com; s=arc-20160816; b=gZNCMc+PguQ1uGQKNgaGtOdHlbBjLrUkXoS+AUNvYutOGM926EESsQtbS/MRj2cDdI l9F+Tek/zZR9PyssLAlfgcL9FPuCB3hpay5km8T/cF56ddXZCPaE5y6Lti90XYmiG72B Y/nBoGpsG2Fhte+06H+8/vQ3CTtxOcN2Hs7ma66uzH9b5kBVA4FHIAYcVmwfeESiDc2J rYsuArfDLzTu4QPb9gjiMh40ddOay4KPjbjISmlAaNu0SdcVG8JxlUcyrIG0CSaetB9m YLxRoIlrDfWxLmHMGjGoxpXhmHzCp/eG8U+N1aOTJcAKNGVfdC6WMVDWEIyCdraZmDK1 DGLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TtkkWs8PerCdgsrvqzjHKB3t9VP6mbOvxo/0HMi+ydk=; b=cZHKJ5bJv/sQ79xj7k8Dz6URhzYbyUyRMxM9OjvLdo9t+DfoI+YoEEVf0bkfeeLh65 mrQySIsqENu+4btDLHyTPJ3k1YU0DuusuEBS51trghIGwfQ/bhoU6z0mIjwLJb/QPTIM 6aTdXLvnnxXrhwZ1JOdSYx+oj08n9lVekDXJhslP3y4QsgScqSb0PUfeQgUrwt5O07tK QsG+cn/lfPQwm9SreL34eBfxWrNkAZEf1XsHzYBlb6JNrzGsf/VEqjX3Kt7ryUSsNnfB a+4QT7jCGNRls9CyGqSWQCyZnbkVJoBdRsIuue/A79kvxbQYzuL8Uo62Dbg4hglZbALm /h3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oXnsM5tN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si10759618plt.394.2019.01.21.05.51.46; Mon, 21 Jan 2019 05:52:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oXnsM5tN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730513AbfAUNuS (ORCPT + 99 others); Mon, 21 Jan 2019 08:50:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:32772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729520AbfAUNuP (ORCPT ); Mon, 21 Jan 2019 08:50:15 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6EC412063F; Mon, 21 Jan 2019 13:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078613; bh=47r4ndJCZeAeCK4ugzrLu3/mqFLDFaSnzBUdzxoFPrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXnsM5tNEJCzxKJ/4OuxqzS6O+Qh+dhr27un/uo+jrOmTkX7itqFGrVTZYeNVXuQy dO1Lz71fqZQkGs66FnX2T+uNsQtkD2OFbGikKYrpzR/Avgqpb0RXZ3xqbKQdqbA1B7 zl3Hq0CiFlHguEk4DZ8eSks9LdsruEQTlb8lmBJ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei Wang , "Michael S. Tsirkin" , Cornelia Huck Subject: [PATCH 4.20 046/111] virtio: dont allocate vqs when names[i] = NULL Date: Mon, 21 Jan 2019 14:42:40 +0100 Message-Id: <20190121122501.044710396@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121122455.819406896@linuxfoundation.org> References: <20190121122455.819406896@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wei Wang commit a229989d975eb926076307c1f2f5e4c6111768e7 upstream. Some vqs may not need to be allocated when their related feature bits are disabled. So callers may pass in such vqs with "names = NULL". Then we skip such vq allocations. Signed-off-by: Wei Wang Signed-off-by: Michael S. Tsirkin Signed-off-by: Wei Wang Signed-off-by: Wei Wang Reviewed-by: Cornelia Huck Cc: stable@vger.kernel.org Fixes: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT") Signed-off-by: Greg Kroah-Hartman --- drivers/misc/mic/vop/vop_main.c | 9 +++++++-- drivers/remoteproc/remoteproc_virtio.c | 9 +++++++-- drivers/s390/virtio/virtio_ccw.c | 12 +++++++++--- drivers/virtio/virtio_mmio.c | 9 +++++++-- 4 files changed, 30 insertions(+), 9 deletions(-) --- a/drivers/misc/mic/vop/vop_main.c +++ b/drivers/misc/mic/vop/vop_main.c @@ -381,16 +381,21 @@ static int vop_find_vqs(struct virtio_de struct _vop_vdev *vdev = to_vopvdev(dev); struct vop_device *vpdev = vdev->vpdev; struct mic_device_ctrl __iomem *dc = vdev->dc; - int i, err, retry; + int i, err, retry, queue_idx = 0; /* We must have this many virtqueues. */ if (nvqs > ioread8(&vdev->desc->num_vq)) return -ENOENT; for (i = 0; i < nvqs; ++i) { + if (!names[i]) { + vqs[i] = NULL; + continue; + } + dev_dbg(_vop_dev(vdev), "%s: %d: %s\n", __func__, i, names[i]); - vqs[i] = vop_find_vq(dev, i, callbacks[i], names[i], + vqs[i] = vop_find_vq(dev, queue_idx++, callbacks[i], names[i], ctx ? ctx[i] : false); if (IS_ERR(vqs[i])) { err = PTR_ERR(vqs[i]); --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -153,10 +153,15 @@ static int rproc_virtio_find_vqs(struct const bool * ctx, struct irq_affinity *desc) { - int i, ret; + int i, ret, queue_idx = 0; for (i = 0; i < nvqs; ++i) { - vqs[i] = rp_find_vq(vdev, i, callbacks[i], names[i], + if (!names[i]) { + vqs[i] = NULL; + continue; + } + + vqs[i] = rp_find_vq(vdev, queue_idx++, callbacks[i], names[i], ctx ? ctx[i] : false); if (IS_ERR(vqs[i])) { ret = PTR_ERR(vqs[i]); --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -635,7 +635,7 @@ static int virtio_ccw_find_vqs(struct vi { struct virtio_ccw_device *vcdev = to_vc_device(vdev); unsigned long *indicatorp = NULL; - int ret, i; + int ret, i, queue_idx = 0; struct ccw1 *ccw; ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); @@ -643,8 +643,14 @@ static int virtio_ccw_find_vqs(struct vi return -ENOMEM; for (i = 0; i < nvqs; ++i) { - vqs[i] = virtio_ccw_setup_vq(vdev, i, callbacks[i], names[i], - ctx ? ctx[i] : false, ccw); + if (!names[i]) { + vqs[i] = NULL; + continue; + } + + vqs[i] = virtio_ccw_setup_vq(vdev, queue_idx++, callbacks[i], + names[i], ctx ? ctx[i] : false, + ccw); if (IS_ERR(vqs[i])) { ret = PTR_ERR(vqs[i]); vqs[i] = NULL; --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -468,7 +468,7 @@ static int vm_find_vqs(struct virtio_dev { struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); unsigned int irq = platform_get_irq(vm_dev->pdev, 0); - int i, err; + int i, err, queue_idx = 0; err = request_irq(irq, vm_interrupt, IRQF_SHARED, dev_name(&vdev->dev), vm_dev); @@ -476,7 +476,12 @@ static int vm_find_vqs(struct virtio_dev return err; for (i = 0; i < nvqs; ++i) { - vqs[i] = vm_setup_vq(vdev, i, callbacks[i], names[i], + if (!names[i]) { + vqs[i] = NULL; + continue; + } + + vqs[i] = vm_setup_vq(vdev, queue_idx++, callbacks[i], names[i], ctx ? ctx[i] : false); if (IS_ERR(vqs[i])) { vm_del_vqs(vdev);