From patchwork Wed Mar 29 14:24:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 1762780 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Clzgspvu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PmplC6gwBz1yYb for ; Thu, 30 Mar 2023 01:26:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B471E85E45; Wed, 29 Mar 2023 16:26:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Clzgspvu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A994285D74; Wed, 29 Mar 2023 16:25:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B998E85858 for ; Wed, 29 Mar 2023 16:25:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=paul.liu@linaro.org Received: by mail-pj1-x102c.google.com with SMTP id q102so14195760pjq.3 for ; Wed, 29 Mar 2023 07:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680099910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qZKRTe43fTUAf6jNqgVqthTcj5zQAj6pnK6PTXqrmTM=; b=Clzgspvu2FzckY5ssnenYFHh/4q2xT/kquwCSwbi7fkUWoZXjKccgtBI6eLo7TUlek ZWG7Frct4uGicDcjpmNW71J2mmj33fhwdykh07kSK8ZohC9KRl+EM4DkDjNjpKcWZ1Jy K1m7BvCarBwZPHD//G3QMdZ+kKyCfCQjEQH9kenzgQezWrEWF3iMSIyQ9rxtefdaK/7a QHGcTAOSEYdH4IMZR18Dqh4WbsqVTM7fHCh7Mo2NEpysftGiKqFwrhOPnT11YZKF5Frr W2ArOn0Kdjvs9Be7ZM2hnBC1WV607gTE8XEJpfRx2OLahnvMtUoYxt8smGjdogPNmMqF obtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680099910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qZKRTe43fTUAf6jNqgVqthTcj5zQAj6pnK6PTXqrmTM=; b=T/sppBiMpr6y0AdrGSsa1ECTzWzU7vq0L29A6W1azP4yeSzYwKOWI3sjYz6BakMIoE PtmqWubcxqvhMMrwaOTQDxm9qMDYZkE3Vda6/1aVmpXNEhYZvO+rol14zzoIL45ykORE ULxXarInpwDOQQH2CNfUYiOf2pGaAo3tyKGRWWfPJU88n7M43oF0MPBIsXVfL6q57khI Xx4eutGVTnPnQ07udGxxCN7WvRGNxkSkdpZba6e9zv/Gt5tKJZbHVWgaNiMNj9doRvS0 WB4R6GVjrh8Psk6OCj68whXbQSrphoay76vUYXzsJjfCYW7RxPQDBCAqmd6reT0j+67q 0UAQ== X-Gm-Message-State: AAQBX9ecIfHZDfnijYSfLHAvfaUhRPYrds8WuacnSy2KmWGMmMj+FAQN 43l81AmdBl96BE18lzLfRtrlbBkE5ReP0JLj9s8= X-Google-Smtp-Source: AKy350a2EpvXEZzzDOKK4aKDKGDgKXy0elHh+B1t4xWJREZMbrVbfR1HUYKGVRqsF3eElPbIQwtmhA== X-Received: by 2002:a17:90b:3b8a:b0:23f:9be4:9bb7 with SMTP id pc10-20020a17090b3b8a00b0023f9be49bb7mr21600333pjb.9.1680099909801; Wed, 29 Mar 2023 07:25:09 -0700 (PDT) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id ge18-20020a17090b0e1200b00234e6d2de3dsm1503744pjb.11.2023.03.29.07.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 07:25:09 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: Will Deacon , Ying-Chun Liu , Bin Meng Subject: [PATCH 2/6] virtio: pci: Tear down VQs in virtio_pci_reset() Date: Wed, 29 Mar 2023 22:24:56 +0800 Message-Id: <20230329142500.682922-3-paul.liu@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230329142500.682922-1-paul.liu@linaro.org> References: <20230329142500.682922-1-paul.liu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Will Deacon The pages backing the virtqueues for virtio PCI devices are not freed on reset, despite the virtqueue structure being freed as part of the driver '->priv_auto' destruction at ->remove() time. Call virtio_pci_del_vqs() from virtio_pci_reset() to free the virtqueue pages before freeing the virtqueue structure itself. Signed-off-by: Will Deacon [ Paul: pick from the Android tree. Rebase to the upstream ] Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Bin Meng Link: https://android.googlesource.com/platform/external/u-boot/+/5ed54ccd83cbffd0d8719ce650604b4e44b5b0d8 Reviewed-by: Simon Glass --- drivers/virtio/virtio_pci_modern.c | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index cfde4007f5..3cdc2d2d6f 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -218,25 +218,6 @@ static int virtio_pci_set_status(struct udevice *udev, u8 status) return 0; } -static int virtio_pci_reset(struct udevice *udev) -{ - struct virtio_pci_priv *priv = dev_get_priv(udev); - - /* 0 status means a reset */ - iowrite8(0, &priv->common->device_status); - - /* - * After writing 0 to device_status, the driver MUST wait for a read - * of device_status to return 0 before reinitializing the device. - * This will flush out the status write, and flush in device writes, - * including MSI-X interrupts, if any. - */ - while (ioread8(&priv->common->device_status)) - udelay(1000); - - return 0; -} - static int virtio_pci_get_features(struct udevice *udev, u64 *features) { struct virtio_pci_priv *priv = dev_get_priv(udev); @@ -363,6 +344,25 @@ static int virtio_pci_find_vqs(struct udevice *udev, unsigned int nvqs, return 0; } +static int virtio_pci_reset(struct udevice *udev) +{ + struct virtio_pci_priv *priv = dev_get_priv(udev); + + /* 0 status means a reset */ + iowrite8(0, &priv->common->device_status); + + /* + * After writing 0 to device_status, the driver MUST wait for a read + * of device_status to return 0 before reinitializing the device. + * This will flush out the status write, and flush in device writes, + * including MSI-X interrupts, if any. + */ + while (ioread8(&priv->common->device_status)) + udelay(1000); + + return virtio_pci_del_vqs(udev); +} + static int virtio_pci_notify(struct udevice *udev, struct virtqueue *vq) { struct virtio_pci_priv *priv = dev_get_priv(udev);