Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2963388iob; Fri, 6 May 2022 14:33:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPdtc+cWAOYxsGrjoauXcdm6FwjSoyLWlQ1LEiuTFaUyIAwJLDfyGTiaM3kn5wVCJBxu9E X-Received: by 2002:a17:907:a0ca:b0:6f8:5bef:b9c with SMTP id hw10-20020a170907a0ca00b006f85bef0b9cmr208943ejc.630.1651872783324; Fri, 06 May 2022 14:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651872783; cv=none; d=google.com; s=arc-20160816; b=Fn5mmODe9e7p4rThV1PjZXL3vI2q1K+/uALZ+HUXsFnAUSOXCFEhvC1k8OpzFVfG2+ ZH9NNMqcCymiBPf/k1Gkf8rL+pbjXshlwvt6OSYjjbSnVIv/qOmICOwlzbdCa9bHHzIA 41CGkAWsbMXVh26wMW3dhWC8jObiEYn6nUP6c5DgiFGnJ4cI+eO3RJR7lOTeXQ4fLo3P Np8T0bQynsEqFT7E5U27n9EcQSJbeArlZd1LPTZRwQk7feRuvSxPaQQyMg/JqR58KrOn pJC5xi09FO779QE1yZJh71ZX88nJ0l8U1afVOSG1o4UU2ZCCwMw2Imr3ykkAO8bHBsjU fa+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=rQdApoYa6nUTANKsVJL2yCvAWducoOnmFhGo9oVvBLo=; b=uenQJnuqCBIFiFbwfpwEBKYr2ICNpS2o+jSN8K5zGJrArnLSXdHYKjZvXCvy5vN9Ky zTQwuSxuhZPrr9stzCcIT3vEpVqzGiLXyGOsAm0LIX39/FZW14KAICjBmUoIPT6HIifo vpwdnoDtrCE5UP2o7hHAtfszRx2/serMG79h0GUc+aJkxMSDbhMXjSUGb3EW58C6AG9H 2wqpr+xVQn2bNgYRENZnS1BdppA1pcoD/Lt1oiMTs50D6deEe5CivhOwC2gbaIHwvtZu FHKQXOHKIaTz0c9bNNuPxOZv2NxBdAxSiZCElqPxSj4f25M8k0yb+2DY97m0fuWTE661 FtiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h5sn2L+u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a1709064cd300b006e894cad8c7si5707064ejt.980.2022.05.06.14.32.38; Fri, 06 May 2022 14:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h5sn2L+u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238796AbiEEUBO (ORCPT + 99 others); Thu, 5 May 2022 16:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241858AbiEEUBM (ORCPT ); Thu, 5 May 2022 16:01:12 -0400 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.133.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B81B25EBC2 for ; Thu, 5 May 2022 12:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651780650; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rQdApoYa6nUTANKsVJL2yCvAWducoOnmFhGo9oVvBLo=; b=h5sn2L+uS+ybPxJYdEiyVldvi9Hcpp1dDaRPZ8I2qLyzhrA+KfNG21kB+RQFU3LEaSYI1r 0DEQe19tUYeWWl95bu9pn/Q+7Yu53U9H28l8FPHJFDTHMjUKfVKabaDhUAH5LfhNFy/+Yf +JoqwM7JwPZ4E5yNyRbc0vzAjhyYnSY= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-qgiC8VKVOPeMG6LwkFhn-g-1; Thu, 05 May 2022 15:57:29 -0400 X-MC-Unique: qgiC8VKVOPeMG6LwkFhn-g-1 Received: by mail-qv1-f69.google.com with SMTP id ke27-20020a056214301b00b0045a82079370so4024790qvb.20 for ; Thu, 05 May 2022 12:57:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:organization:user-agent:mime-version :content-transfer-encoding; bh=rQdApoYa6nUTANKsVJL2yCvAWducoOnmFhGo9oVvBLo=; b=evUMMgAzfarHVaKg8HE8A9nCMdurizlSgaQekDnDlSzslq7D1O4H3pZNquh7ARgy5N zH+c5aHA5e2SNUdbSWyMqegSES1A9/w2F5bqsVmg5O11xe7QDz9CNIOGda2t92hYHvT5 wdZuPghwkA24OGevAkAltKCxxcxZBUMKtxhZD8o6VXz1HHeZ17aDkz4l3rQa3dKyw+qI Cxp0cRKowFvCH+gEke6mBLHaoYgHTkhvHKQ5K1kGpfhnffcC6oEpTY1GE7lPDIPfsU78 SwizDi+r5V2WWlKeWUChTi3+3A5OcBcjSMdLccXXi8YFuGYFJw6lSeUj1r0pv5YukyOr KWaw== X-Gm-Message-State: AOAM5336Rn96AL+a5s9lNXoYv4zzbLrpO00BnuSVuK9w/LYx3ILPj7oN CncL8m2+XS2ab2+0rivrxKmxnxPIeEPhCm/1nrIIK61cGX/j4HJkc1daKAhW1hIWOEDhtFoFw6Y gGPyPXZK+9JZc1Yx9Qj7eI+lr X-Received: by 2002:a37:9381:0:b0:69f:62c6:56a7 with SMTP id v123-20020a379381000000b0069f62c656a7mr21018125qkd.643.1651780649335; Thu, 05 May 2022 12:57:29 -0700 (PDT) X-Received: by 2002:a37:9381:0:b0:69f:62c6:56a7 with SMTP id v123-20020a379381000000b0069f62c656a7mr21018112qkd.643.1651780649132; Thu, 05 May 2022 12:57:29 -0700 (PDT) Received: from [192.168.8.138] (static-71-184-137-158.bstnma.ftas.verizon.net. [71.184.137.158]) by smtp.gmail.com with ESMTPSA id l15-20020ac848cf000000b002f39b99f6c3sm1288303qtr.93.2022.05.05.12.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 12:57:28 -0700 (PDT) Message-ID: <7574d491866ffa7c1a4607885b76140ba4206477.camel@redhat.com> Subject: Re: [PATCH] drm/nouveau: reorder nouveau_drm_device_fini From: Lyude Paul To: Mark Menzynski , linux-kernel@vger.kernel.org Cc: Ben Skeggs , Karol Herbst , David Airlie , Daniel Vetter , Sumit Semwal , Christian =?ISO-8859-1?Q?K=F6nig?= , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Date: Thu, 05 May 2022 15:57:27 -0400 In-Reply-To: <20220504171851.17188-1-mmenzyns@redhat.com> References: <20220504171851.17188-1-mmenzyns@redhat.com> Organization: Red Hat Inc. Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hmm, I think we might just need to move the drm_kms_helper_poll_enable() call to the end here instead of all of nouveau_display_init(). I realized this because in nouveau_display_init() it seems that we actually rely on nouveau_display_init() to setup hotplug interrupts - which we do actually need this early on in the driver probe process. That being said though, drm_kms_helper_poll_enable() shouldn't be required for MST short HPD IRQs from working so moving that instead should work. On Wed, 2022-05-04 at 19:18 +0200, Mark Menzynski wrote: > Resources needed for output poll workers are destroyed in > nouveau_fbcon_fini() before output poll workers are cleared in > nouveau_display_fini(). This means there is a time between fbcon_fini > and display_fini, where if output poll happens, it crashes. > > BUG: KASAN: use-after-free in > __drm_fb_helper_initial_config_and_unlock.cold+0x1f3/0x291 > [drm_kms_helper] > > Cc: Ben Skeggs > Cc: Karol Herbst > Cc: Lyude Paul > Cc: David Airlie > Cc: Daniel Vetter > Cc: Sumit Semwal > Cc: "Christian König" > Cc: dri-devel@lists.freedesktop.org > Cc: nouveau@lists.freedesktop.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-media@vger.kernel.org > Cc: linaro-mm-sig@lists.linaro.org > Signed-off-by: Mark Menzynski > --- >  drivers/gpu/drm/nouveau/nouveau_drm.c | 17 ++++++++--------- >  1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c > b/drivers/gpu/drm/nouveau/nouveau_drm.c > index 561309d447e0..773efdd20d2f 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_drm.c > +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c > @@ -588,12 +588,6 @@ nouveau_drm_device_init(struct drm_device *dev) >         if (ret) >                 goto fail_dispctor; >   > -       if (dev->mode_config.num_crtc) { > -               ret = nouveau_display_init(dev, false, false); > -               if (ret) > -                       goto fail_dispinit; > -       } > - >         nouveau_debugfs_init(drm); >         nouveau_hwmon_init(dev); >         nouveau_svm_init(drm); > @@ -601,6 +595,12 @@ nouveau_drm_device_init(struct drm_device *dev) >         nouveau_fbcon_init(dev); >         nouveau_led_init(dev); >   > +       if (dev->mode_config.num_crtc) { > +               ret = nouveau_display_init(dev, false, false); > +               if (ret) > +                       goto fail_dispinit; > +       } > + >         if (nouveau_pmops_runtime()) { >                 pm_runtime_use_autosuspend(dev->dev); >                 pm_runtime_set_autosuspend_delay(dev->dev, 5000); > @@ -641,15 +641,14 @@ nouveau_drm_device_fini(struct drm_device *dev) >                 pm_runtime_forbid(dev->dev); >         } >   > +       if (dev->mode_config.num_crtc) > +               nouveau_display_fini(dev, false, false); >         nouveau_led_fini(dev); >         nouveau_fbcon_fini(dev); >         nouveau_dmem_fini(drm); >         nouveau_svm_fini(drm); >         nouveau_hwmon_fini(dev); >         nouveau_debugfs_fini(drm); > - > -       if (dev->mode_config.num_crtc) > -               nouveau_display_fini(dev, false, false); >         nouveau_display_destroy(dev); >   >         nouveau_accel_fini(drm); -- Cheers, Lyude Paul (she/her) Software Engineer at Red Hat