Received: by 10.192.165.148 with SMTP id m20csp4157481imm; Mon, 30 Apr 2018 12:52:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpaVapvqcjWfbY8nIUkBfsXfNAJRpT08k1H/+VUCQ5hjSYAS0MNfbpXiEvmnKu+WwoTnCj2 X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr11071747pgu.222.1525117949120; Mon, 30 Apr 2018 12:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117949; cv=none; d=google.com; s=arc-20160816; b=HMtAOATjiDraXedNp2q5WsVyt4I9WI/tkcNhjlRRQSNFdbjc7sR5GMIFROt5fD25cb DdfEEa/vsBpS0fOmC6wb+yogZvW5ctFmX6JuH/6vR7OH5xyidLEjJ4EBf1bPjPHNr8aH OLuO+Wqc7I662ZoKE+ROpxhnKKEj3EXdDMtRL7E5jBHoqjVKS0pgSZX6auiNU4Jtttkz OmSX7koGaCqCJRQE7LqQYZTxhmiNPzcdytgWUFnXXOxeJ4giEF8fwzdvWy/O+fX64Dic XDCO3b8g4rA2lnSA17J5RKjk2NAeL4E+exs8iVYufXyDlwY0Vc3i763FL2ENsKHTb/Ps z5rA== 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=eOQ8Gmyg5wGJZcbae1czQbizyn9Mq4d4lfZ3vphn81g=; b=mW8jSmWJVdyIpcTSkovjDmpC/jS3BDmq4GHTxJMf4lheOSd8oAdqSbRNzbt8jQeJnO Z20UXP67sGtBYfhZVN1fgFXMQl2ySgXDQg08RNwk0WkAIH71npV5ZYC3mgQ/DUJYcFb0 Wqkd/sTLbAphTegyxDj1d9oM1Jsh51hluajbz2G6eOjwqpEu9+nAdZPK4DdELh8Ye7FG LJfQdm92+SyUSRt6tWVnQ4ooqKSzngTq5sBgSP5OaiaP/n73j078OOdNzH4vHTtWuBYL /gW0nRyUvuUCx/x4CeXIEQA7NvUbHhGefJ9DiAd/8/T9FUFc55PDYrSMeWM2LH64xWAS 39Jg== 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 m2-v6si7759588plt.55.2018.04.30.12.52.15; Mon, 30 Apr 2018 12:52:29 -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 S1756218AbeD3Tvf (ORCPT + 99 others); Mon, 30 Apr 2018 15:51:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:35348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756154AbeD3T2F (ORCPT ); Mon, 30 Apr 2018 15:28:05 -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 B8F1022DC1; Mon, 30 Apr 2018 19:28:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8F1022DC1 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.16 028/113] virtio_console: move removal code Date: Mon, 30 Apr 2018 12:23:59 -0700 Message-Id: <20180430184016.257130742@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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 },