Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp305621ybi; Thu, 1 Aug 2019 19:29:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6cyFhf/pqX/v7PYCtR9gomovSxTg1imfoSBhaG84jTDJH+ylMoA4n9cWkUWkeB2sqDcM9 X-Received: by 2002:a17:90a:4f0e:: with SMTP id p14mr1877928pjh.40.1564712986724; Thu, 01 Aug 2019 19:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712986; cv=none; d=google.com; s=arc-20160816; b=t9GENId+mnrMmA3n3sR+KLWdG9t8S36w6jWpxjVAvwkDJr4y5lYiHQH6LwRe4UK5TV jdhO/BVtzPgKv+Q/hU9OlwJEF2AsxH9jSZmqdyLC3qCiiFs36FiPjzdbT+IFrHSnzbNS iltVQ92x4wF69tyiUXdi5LHAMCPi6Hzj//ZgNOGNxFWQ6nKu8b65tahdl+dy2Ss43unz vEmwfd7C9WZzRzG0x/C5EJr5OOUEsXbkYn34KP+12azdbSx2zpzHrtzgK9JUOXZErLkm 36JDAq6JwMq2z71rMcBjXvdNb98YWb8+OuRGnDEzHeB+H5pKptJrmFjH7KS2ZmTiuO1d PaJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PhuFM2pdRnW2kX108enkfIuXqe+2wuG+ARNOH5L+Sds=; b=YQSqoJwpKi/x1odqtnb04/g62IXlx7slcvMbGcPN3eOxB8L/IVpf19LQ7v6PlL+j5m EaZrzF2kf/XsD5Mi31CWS357KUGXRvVadYIR4RYf4SWb4j3nMSf+/Q/mGzY0okj7PkXW Q+9D2YFilIntKZM56tvMQDg4ere1LevPf3Fj3fubQsHgZTzxT3ISNXD5BNDBRkgRlxue /DvspUiflB029DQ/bgmdfZxf7McsaE+MN6oG4iNyxTOhQB9H61jEKfHt7X3Lun1qEbpi S4krVgz2Mi+BE/Iqqwipdm9wF8x7FMqSWrqNb5MHNyEe7oO9FezXSFc+xsVCeHBgRaxz T4qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=va1tKdss; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si36910621pfb.122.2019.08.01.19.29.32; Thu, 01 Aug 2019 19:29:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=va1tKdss; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403834AbfHAXqG (ORCPT + 99 others); Thu, 1 Aug 2019 19:46:06 -0400 Received: from mail-vk1-f193.google.com ([209.85.221.193]:43957 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390411AbfHAXqE (ORCPT ); Thu, 1 Aug 2019 19:46:04 -0400 Received: by mail-vk1-f193.google.com with SMTP id b200so14985502vkf.10; Thu, 01 Aug 2019 16:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PhuFM2pdRnW2kX108enkfIuXqe+2wuG+ARNOH5L+Sds=; b=va1tKdssM+gKOUvvNunrZBekJn5ccALnpSDxSI76pAmLOUxB0xAuqPlAx8pHMrFYRn AEXjxmVNbmQc86qbUbqlRbQAvSU2lupPHjr/iMKzTyU5QuE+zV5BV1zGRE5mXtWtXa9I AK84q1HiHlBCExd9gbz/p/lhTOH5qLzbMG4s6JUjR/8xndXPuxdZ0Z9XNDaxO8e6tYfF wYxF5ToKRSCB51NZjKea552bepCsYNBj8WlYGWuLzC3FeUjRogM5h5yz35xfnuGn8kzY 7kRLDObIkjHmVOykGk1qg8d7BHDHdflHFdRCydlJxiYIl9dyuvFs7/+rtRUjZ+P2sh5x aMWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PhuFM2pdRnW2kX108enkfIuXqe+2wuG+ARNOH5L+Sds=; b=rAlYUpGu00tMr2u+qt7X7B7T8wTCw7fvOhZVZ8uwZr/t62W9STBABpzf8A3XqEESOo UTCDGCA02ZLsxoFXh8kGUdgiAkBwGwYGgiGBXz4QMyJBEr9Z70k1X0T73ArDjWa5Thxz ZeUZtqIYWTVDrztO39CczYsQ++3g0yazblNaLYeb3gDjg2jtm401DKZUpbDAjUw+O+mb 5Aru1jxfnOOLm5YnA1ZQAIt/LLQCFz4xE1ZGumQspBFNmKsiqKwDNP2e4oRH8p1ctwft lsPuI0ggxzGHubDrWchjpbdKBhWjgFaOp3jVK9mH5MMSdwnK7ndpW7FN61UR6Hp8S0qe Juwg== X-Gm-Message-State: APjAAAWAGId0+d5WN8cVE2EWLtF0A6Y5eXJuczUAWqbcaorJOt1y9BcU kCzwbjab43UrRShE1Pn1/4FWvYBhGUPuygAJ9bc= X-Received: by 2002:a1f:4107:: with SMTP id o7mr52276511vka.34.1564703163073; Thu, 01 Aug 2019 16:46:03 -0700 (PDT) MIME-Version: 1.0 References: <20190801220216.15323-1-lyude@redhat.com> In-Reply-To: <20190801220216.15323-1-lyude@redhat.com> From: Ben Skeggs Date: Fri, 2 Aug 2019 09:45:52 +1000 Message-ID: Subject: Re: [Nouveau] [PATCH] drm/nouveau: Only release VCPI slots on mode changes To: Lyude Paul Cc: ML nouveau , David Airlie , ML dri-devel , stable@vger.kernel.org, linux-kernel@vger.kernel.org, Jerry Zuo , Ben Skeggs , Daniel Vetter , David Airlie , Harry Wentland , Juston Li , Laurent Pinchart 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 On Fri, 2 Aug 2019 at 08:02, Lyude Paul wrote: > > Looks like a regression got introduced into nv50_mstc_atomic_check() > that somehow didn't get found until now. If userspace changes > crtc_state->active to false but leaves the CRTC enabled, we end up > calling drm_dp_atomic_find_vcpi_slots() using the PBN calculated in > asyh->dp.pbn. However, if the display is inactive we end up calculating > a PBN of 0, which inadvertently causes us to have an allocation of 0. > From there, if userspace then disables the CRTC afterwards we end up > accidentally attempting to free the VCPI twice: > > WARNING: CPU: 0 PID: 1484 at drivers/gpu/drm/drm_dp_mst_topology.c:3336 > drm_dp_atomic_release_vcpi_slots+0x87/0xb0 [drm_kms_helper] > RIP: 0010:drm_dp_atomic_release_vcpi_slots+0x87/0xb0 [drm_kms_helper] > Call Trace: > drm_atomic_helper_check_modeset+0x3f3/0xa60 [drm_kms_helper] > ? drm_atomic_check_only+0x43/0x780 [drm] > drm_atomic_helper_check+0x15/0x90 [drm_kms_helper] > nv50_disp_atomic_check+0x83/0x1d0 [nouveau] > drm_atomic_check_only+0x54d/0x780 [drm] > ? drm_atomic_set_crtc_for_connector+0xec/0x100 [drm] > drm_atomic_commit+0x13/0x50 [drm] > drm_atomic_helper_set_config+0x81/0x90 [drm_kms_helper] > drm_mode_setcrtc+0x194/0x6a0 [drm] > ? vprintk_emit+0x16a/0x230 > ? drm_ioctl+0x163/0x390 [drm] > ? drm_mode_getcrtc+0x180/0x180 [drm] > drm_ioctl_kernel+0xaa/0xf0 [drm] > drm_ioctl+0x208/0x390 [drm] > ? drm_mode_getcrtc+0x180/0x180 [drm] > nouveau_drm_ioctl+0x63/0xb0 [nouveau] > do_vfs_ioctl+0x405/0x660 > ? recalc_sigpending+0x17/0x50 > ? _copy_from_user+0x37/0x60 > ksys_ioctl+0x5e/0x90 > ? exit_to_usermode_loop+0x92/0xe0 > __x64_sys_ioctl+0x16/0x20 > do_syscall_64+0x59/0x190 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > WARNING: CPU: 0 PID: 1484 at drivers/gpu/drm/drm_dp_mst_topology.c:3336 > drm_dp_atomic_release_vcpi_slots+0x87/0xb0 [drm_kms_helper] > ---[ end trace 4c395c0c51b1f88d ]--- > [drm:drm_dp_atomic_release_vcpi_slots [drm_kms_helper]] *ERROR* no VCPI for > [MST PORT:00000000e288eb7d] found in mst state 000000008e642070 > > So, fix this by doing what we probably should have done from the start: only > call drm_dp_atomic_find_vcpi_slots() when crtc_state->mode_changed is set, so > that VCPI allocations remain for as long as the CRTC is enabled. > > Signed-off-by: Lyude Paul > Fixes: 232c9eec417a ("drm/nouveau: Use atomic VCPI helpers for MST") > Cc: Lyude Paul > Cc: Ben Skeggs > Cc: Daniel Vetter > Cc: David Airlie > Cc: Jerry Zuo > Cc: Harry Wentland > Cc: Juston Li > Cc: Karol Herbst > Cc: Laurent Pinchart > Cc: Ilia Mirkin > Cc: # v5.1+ Acked-by: Ben Skeggs > --- > drivers/gpu/drm/nouveau/dispnv50/disp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c > index 8497768f1b41..126703816794 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c > @@ -780,7 +780,7 @@ nv50_msto_atomic_check(struct drm_encoder *encoder, > drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, > connector->display_info.bpc * 3); > > - if (drm_atomic_crtc_needs_modeset(crtc_state)) { > + if (crtc_state->mode_changed) { > slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr, > mstc->port, > asyh->dp.pbn); > -- > 2.21.0 > > _______________________________________________ > Nouveau mailing list > Nouveau@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/nouveau