Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp366383ybz; Wed, 29 Apr 2020 01:31:05 -0700 (PDT) X-Google-Smtp-Source: APiQypL+NGSNx5NveHif765j0uFVBUWVUnW9jUQPhyM3HjlAwbpqZQ3bY6kqWZj7vyBs/F7L+5jP X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr1477007eji.234.1588149065746; Wed, 29 Apr 2020 01:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588149065; cv=none; d=google.com; s=arc-20160816; b=yUtPNzZJqyicVaM9V4sVtjaEKuXZj2Y228oeIlvyxrq7sKRfQhK5ykecrVwgFxIfMS cRJ58Ykz2/UjUGcCStdU46zsxOc2ozt+BlW+zr81Vs7kZjKL1gJ6N6C3OMTzxq5Yhb6K yw1CY2/vrHLJDzvUGz74HFH3yfzG+gcbv6zbCnijJPjIteCVESvTjCcahv1nKzdufVcV dJB5bLqQ2UsnyUPLsl7/HAiUaES0nhcqguDH5HDzUZvQD+UqdaOtGWdHnoDujkZd2aLq 0nCuU6cEQyGOHS7lWRCVZUugwQjej+DWdfFAcAa50Jo1xxNfBWgjFkxk3th/aHTreOBu bLdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=307isNnvbFBLVIHqWZVI02AT/E09cU5NkzO3QxAC0lI=; b=Em9NmY08wb24hJmI88jfbIqFf/55kT2mBNZU4+r6iE3GKgEDhfGJKA68xZBdEXQlTj vApviv9XlvQZgki6RakuNqeLz1nIZILSjN+Jhel2WQzoBnZDBek8PBguVSFqiz4sm+jD oOYO4ZN2W0QOQWSPTil0wimFxsGzyqjJe4ML0/STcHP4N93g84VRD/HY5ah3ktm7iOjj pykxhHT019TySXIXIl9btUQ7BudDxKyzXkaffRLKEvAIikB8dgFSpWD2jhzU9Futq8Wl SxW5g//2QQd6Pk2KWp6fF3JbZnkkHbviEbT0ZFekc/G7b6zY2PuL2BJBBkWVImfJElbL Ms2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ApM0VH+7; 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 ch13si3434181ejb.338.2020.04.29.01.30.42; Wed, 29 Apr 2020 01:31:05 -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=ApM0VH+7; 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 S1726511AbgD2I2q (ORCPT + 99 others); Wed, 29 Apr 2020 04:28:46 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49234 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726355AbgD2I2q (ORCPT ); Wed, 29 Apr 2020 04:28:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588148924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=307isNnvbFBLVIHqWZVI02AT/E09cU5NkzO3QxAC0lI=; b=ApM0VH+7FcEfCho3QdDp0fQwK825YhYpkXnXpT24Wwb/iV4QSEQmMd2fMkhDMTvBhFp0EV msDadlnz1mqKJ4R9xoT/Gmb8/SjVWAaj2a7kcNjSs/rYbhXXJWDHfxTGNxBQ9pG2zGnYqO lpN/IjSI4PvKAU1Jr9gERibk4EdKpO0= 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-284-ETodXgd1OBKAK3jUQcuNEw-1; Wed, 29 Apr 2020 04:28:41 -0400 X-MC-Unique: ETodXgd1OBKAK3jUQcuNEw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81BFD45F; Wed, 29 Apr 2020 08:28:39 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-193.ams2.redhat.com [10.36.113.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06B6F5D9E5; Wed, 29 Apr 2020 08:28:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BFF5E1753B; Wed, 29 Apr 2020 10:28:37 +0200 (CEST) Date: Wed, 29 Apr 2020 10:28:37 +0200 From: Gerd Hoffmann To: Vasily Averin Cc: Caicai , Dave Airlie , David Airlie , virtualization@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, "linux-kernel@vger.kernel.org\"" , Zhangyueqian , "Denis V. Lunev" Subject: Re: [PATCH 1/1] drm/qxl: add mutex_lock/mutex_unlock to ensure the order in which resources are rele Message-ID: <20200429082837.uedcapxmennuc5a2@sirius.home.kraxel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > > The only way I see for this to happen is that the guest is preempted > > between qxl_push_{cursor,command}_ring_release() and > > qxl_release_fence_buffer_objects() calls. The host can complete the qxl > > command then, signal the guest, and the IRQ handler calls > > qxl_release_free_list() before qxl_release_fence_buffer_objects() runs. > > We think the same: qxl_release was freed by garbage collector before > original thread had called qxl_release_fence_buffer_objects(). Ok, nice, I think we can consider the issue being analyzed then ;) > > Looking through the code I think it should be safe to simply swap the > > qxl_release_fence_buffer_objects() + > > qxl_push_{cursor,command}_ring_release() calls to close that race > > window. Can you try that and see if it fixes the bug for you? > > I'm going to prepare and test such patch but I have one question here: > qxl_push_*_ring_release can be called with interruptible=true and fail > How to correctly handle this case? Is the hunk below correct from your POV? Oh, right, the error code path will be quite different, checking ... > --- a/drivers/gpu/drm/qxl/qxl_ioctl.c > +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c > @@ -261,12 +261,8 @@ static int qxl_process_single_command(struct qxl_device *qdev, > apply_surf_reloc(qdev, &reloc_info[i]); > } > > + qxl_release_fence_buffer_objects(release); > ret = qxl_push_command_ring_release(qdev, release, cmd->type, true); > - if (ret) > - qxl_release_backoff_reserve_list(release); <<<< ???? > - else > - qxl_release_fence_buffer_objects(release); > - > out_free_bos: > out_free_release: if (ret) qxl_release_free(qdev, release); [ code context added ] qxl_release_free() checks whenever a release is fenced and signals the fence in case it is so it doesn't wait for the signal forever. So, yes, I think qxl_release_free() should cleanup the release properly in any case and the patch chunk should be correct. take care, Gerd