Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3723407pxk; Tue, 8 Sep 2020 00:08:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHfVjzPR63TLnoynd7ppErmBm11J0nGX6m1Z2u2xZAyMzZ91mZis6ib3+0fTVVc/qTkZJl X-Received: by 2002:a17:906:a981:: with SMTP id jr1mr23230842ejb.99.1599548915568; Tue, 08 Sep 2020 00:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599548915; cv=none; d=google.com; s=arc-20160816; b=h85c+uQiuJXDR74rtZaV01YshLuJFP5rn/fy+67enOHWfKneu7JYUvtsXZmR5UeTHS uhraeuADgdBG3UwuCIrcVvvDs2vFs83opOpBSZzu2fzVUUp5mOQNSifLroAnCuXxPQNk iV/nrKD9oelKqLXKbc+xOSeO5D2X6x8cbaRBnBd6sk0m7fZ9CMVDOfQf/gMMefX7CzpN WWesE8J7ZP6uf+wH/IWMIftsTcNP7fFS40cXJXR2YdOfL+mnHPBmuyOpST87v9v6p9hm 0o6y5NS+iVZWX5MnR1SyMSAa6u2e6azEgvSMcezWAi9GO73pZOHSR61Dbeg9XNihvxjR E9jw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8eYsGcUoiEvU+T2+5TumDUWl0H68AlLqE5jQUe9G2ZU=; b=w94WdPXjJsqjuwDXJ58Qy3NFmmrBrgOjzRJtY8QETaR1jp/MRWO35TB35O9TVJOMi8 XrXWSi6HW2Q/x6A15i4JvsRPBGNGYqCwxAA4wZXD1zUIxiTNN/4NDNVr7okh0c5RGEhY rV1N9C+KCBJqL5L+3SiAz+jA169AkiPGBXBcw0wi4FkelMbGqa8dl+LcYsMYDg71bixi ljj5a8bnwJvYCNlplgLjfvrDzRzIGY85g++1rYaux+nYw8L+iOZo8iYuQRmlAdws44JQ eT635RZei8kvpYwu9EWw1omURI6Z9mKGq8+u8PbgZcFpeF3K66Pdc5chzII4W7qFtIDV 2b3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U21jwpDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si4150242eje.64.2020.09.08.00.08.12; Tue, 08 Sep 2020 00:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U21jwpDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729176AbgIHHHg (ORCPT + 99 others); Tue, 8 Sep 2020 03:07:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33402 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728115AbgIHHHe (ORCPT ); Tue, 8 Sep 2020 03:07:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599548853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eYsGcUoiEvU+T2+5TumDUWl0H68AlLqE5jQUe9G2ZU=; b=U21jwpDiMCiu0lVVxJqZe62Gitl+FbQ7RKQY5tdxfeUDyNJv/KUrxkjhN+Ie1hZhMvbbQr fV6bMZi4iUMYwj8HhK+gnPrOxmtDt8jog059L9k2Pv+/KzCBAnUu5hWIXxmuoTZo2y/8LE aW5UQk5N8wBrb2NDvY1D3L6Jy9P3+XA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-lWFDfZj7M-i8X0RP0S3-BA-1; Tue, 08 Sep 2020 03:07:29 -0400 X-MC-Unique: lWFDfZj7M-i8X0RP0S3-BA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D0DF1007466; Tue, 8 Sep 2020 07:07:28 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9973360C17; Tue, 8 Sep 2020 07:07:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D5EF51FCF5; Tue, 8 Sep 2020 09:07:23 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: Gerd Hoffmann , David Airlie , Daniel Vetter , virtualization@lists.linux-foundation.org (open list:VIRTIO GPU DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] drm/virtio: add virtio_gpu_cmd_unref_resource error handling Date: Tue, 8 Sep 2020 09:07:23 +0200 Message-Id: <20200908070723.6394-4-kraxel@redhat.com> In-Reply-To: <20200908070723.6394-1-kraxel@redhat.com> References: <20200908070723.6394-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Usually we wait for the host to complete the unref request, then cleanup the guest-side state of the object in the completion callback. When submitting the unref command failed the completion callback will not be called though, so cleanup right away. Fixes a WARN on stale mm entries on driver shutdown. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_vq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index b1884e6e242c..4d2325bf4aed 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -536,6 +536,7 @@ void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev, { struct virtio_gpu_resource_unref *cmd_p; struct virtio_gpu_vbuffer *vbuf; + int ret; cmd_p = virtio_gpu_alloc_cmd_cb(vgdev, &vbuf, sizeof(*cmd_p), virtio_gpu_cmd_unref_cb); @@ -545,7 +546,9 @@ void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev, cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); vbuf->resp_cb_data = bo; - virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); + ret = virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); + if (ret < 0) + virtio_gpu_cleanup_object(bo); } void virtio_gpu_cmd_set_scanout(struct virtio_gpu_device *vgdev, -- 2.27.0