Received: by 10.192.165.148 with SMTP id m20csp4179458imm; Mon, 30 Apr 2018 13:17:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrPhWK+JHS7jpJncrkF9AZ5XcN0kjKiqEMt0uzgfuLAEaJ8e2tlBHcpLxAkQogNKMsC9PP5 X-Received: by 2002:a63:9c09:: with SMTP id f9-v6mr11166535pge.274.1525119471621; Mon, 30 Apr 2018 13:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119471; cv=none; d=google.com; s=arc-20160816; b=m0Tepf6ezZ01vpSbIGuJfY3wu1DIIbFHYWrRi+bXjH7PW2R1JJX6RqnIbb2ugQyG5H GEdbFoGPtyATusKlvcdjkBdZA4Cf8OHXiIf4opRuHQ+9ySo+J8L+gKIEdu3YGV1/W9a7 nEhQQZC0yQFacyMTlr4/DFxO14N2ia0BTAlUZOhDows8nNpKOelAjzvyREpTn6PyFo9K b7YSKzWhNot8ax1Lz0AL68b8inouhJONKma1uIxetk7jC8PbEGu2juBFwSZaU0XcGHsX q/9cMC506MPIcd/IneG0hvPaEvJP2gcwVdZ1fGhifi+NnZWY+R61MIV8vlR2ThlehNuy qw0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=0Nyo+YZV68eg/+S37+IldbqUzCf8J+SRZ9ItBXaa1IQ=; b=OayEUeKhm4Sx/T08dY3a+8wTfyTwAHJvyGTvN4rdT2USpg4wxFRdjNgskHcX8LjYPd 4mhQ7TFs6H8mio6a/VwkXYbscpQLeP0r1cFK2qJBDkZzJytvRQh3gWBhgUp83baJS8QD 0lswE9eIxhd8MswN168QYnzdZOPSQEeqsj1c9irqmDBNElLMfIy+N9dqaM7r3mWTyWP8 XcYk63XSru6V8m7TI9C7YKAU4JtX3fQ7jGx/RO2n+iiPwSlnHNqMLUBIS2V+0cJiNXcV kNJRiE6ipXtvlaK5zdN7FWcuUfqAFhCMnYmx3VthmaYAhIum3y81sjFcoQILCPvgy00E Dc2w== ARC-Authentication-Results: i=1; mx.google.com; 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 h12-v6si6117911pgp.462.2018.04.30.13.17.07; Mon, 30 Apr 2018 13:17:51 -0700 (PDT) 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; 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 S1755933AbeD3UNA (ORCPT + 99 others); Mon, 30 Apr 2018 16:13:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:33366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754961AbeD3T1K (ORCPT ); Mon, 30 Apr 2018 15:27:10 -0400 Received: from localhost (unknown [104.132.1.102]) (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 4360122DC1; Mon, 30 Apr 2018 19:27:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4360122DC1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" Subject: [PATCH 4.14 26/91] virtio_console: move removal code Date: Mon, 30 Apr 2018 12:24:08 -0700 Message-Id: <20180430184005.549463558@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael S. Tsirkin commit aa44ec867030a72e8aa127977e37dec551d8df19 upstream. Will make it reusable for error handling. Cc: stable@vger.kernel.org Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/char/virtio_console.c | 72 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -1988,6 +1988,42 @@ static void remove_vqs(struct ports_devi kfree(portdev->out_vqs); } +static void virtcons_remove(struct virtio_device *vdev) +{ + struct ports_device *portdev; + struct port *port, *port2; + + portdev = vdev->priv; + + spin_lock_irq(&pdrvdata_lock); + list_del(&portdev->list); + spin_unlock_irq(&pdrvdata_lock); + + /* Disable interrupts for vqs */ + vdev->config->reset(vdev); + /* Finish up work that's lined up */ + if (use_multiport(portdev)) + cancel_work_sync(&portdev->control_work); + else + cancel_work_sync(&portdev->config_work); + + list_for_each_entry_safe(port, port2, &portdev->ports, list) + unplug_port(port); + + unregister_chrdev(portdev->chr_major, "virtio-portsdev"); + + /* + * When yanking out a device, we immediately lose the + * (device-side) queues. So there's no point in keeping the + * guest side around till we drop our final reference. This + * also means that any ports which are in an open state will + * have to just stop using the port, as the vqs are going + * away. + */ + remove_vqs(portdev); + kfree(portdev); +} + /* * Once we're further in boot, we get probed like any other virtio * device. @@ -2116,42 +2152,6 @@ fail: return err; } -static void virtcons_remove(struct virtio_device *vdev) -{ - struct ports_device *portdev; - struct port *port, *port2; - - portdev = vdev->priv; - - spin_lock_irq(&pdrvdata_lock); - list_del(&portdev->list); - spin_unlock_irq(&pdrvdata_lock); - - /* Disable interrupts for vqs */ - vdev->config->reset(vdev); - /* Finish up work that's lined up */ - if (use_multiport(portdev)) - cancel_work_sync(&portdev->control_work); - else - cancel_work_sync(&portdev->config_work); - - list_for_each_entry_safe(port, port2, &portdev->ports, list) - unplug_port(port); - - unregister_chrdev(portdev->chr_major, "virtio-portsdev"); - - /* - * When yanking out a device, we immediately lose the - * (device-side) queues. So there's no point in keeping the - * guest side around till we drop our final reference. This - * also means that any ports which are in an open state will - * have to just stop using the port, as the vqs are going - * away. - */ - remove_vqs(portdev); - kfree(portdev); -} - static struct virtio_device_id id_table[] = { { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, { 0 },