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: 668117 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp394331wrt; Wed, 29 Mar 2023 07:26:33 -0700 (PDT) X-Google-Smtp-Source: AK7set97E9Uc6CZ9a96UfT8GHExNAFHRObRrXdaWJsXouLDkfUMAD44crHBYIVmq+/cdLIe2Xupq X-Received: by 2002:a05:6a20:29b:b0:d9:e6a9:d3e2 with SMTP id 27-20020a056a20029b00b000d9e6a9d3e2mr18217449pza.3.1680099993562; Wed, 29 Mar 2023 07:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680099993; cv=none; d=google.com; s=arc-20160816; b=lWuizSjzkNWTaj1hCjzLugg+owgIyetnt1S4hlojEeCPe61/avq5Q3BOgmMXF/+6H7 Qqfi1sj/DnKiv0n0TNTIOxyUIVyT5vJ4NV68UICMM9VtIMJHK4W8TBBC4Km3z3bIMtkn ducG9Wj/eo3f/P+iyJOkyH04eMkHAfFVgp3WQIEo6R1N/WHk0X/YW573p8MN5wes7Lp2 FlIJz6+rjnR3ODXRmCsDI2e7M2qFdILDkPCXXyqfbCXMvilkjOrJGuxtyJpcCEsqITOv L0iZ/TLsrv39qJIZmZ8J4vQ4LGf5mduQzb/goendGWLZVzz6Oa5XkVfNae+CwQKNt1Va fOWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qZKRTe43fTUAf6jNqgVqthTcj5zQAj6pnK6PTXqrmTM=; b=c1UkTfQUG71l6xWAyeq58AEXz+fJKD9Lan+xqoQPIvPo9u185cSIc+/qTyAFeP7ITd SrDlB17wxo1GMU6F5T97jrb+fnJxg6Hrv0Y3UWvud54qA3CurA10P935szS3lhCCzYW0 0Cz7GEoNjAla0MxH2aJBrvG41dhrwUc2hPsydaOmOiJl68KrBGE0yHAXLV1V9sIlPt8a EplyNLaYTLIUzw6Iym3dNqiWHiQVNrNsXgtmrmcBMGDYs4VB4qr0PTvUtB0AvdMK2eqz 4hTiSCk9vLE5BVJQpzKfePIBiCdWawsKv54+phGGxuh5ije78pid0e0KNXSL8MKYmUQA x4tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Clzgspvu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id q1-20020a056a00084100b006257c287ddcsi32881969pfk.45.2023.03.29.07.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 07:26:33 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Clzgspvu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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);