Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3028822imm; Tue, 4 Sep 2018 14:10:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYff+MdXW96CeHXkM++HR/Mz2k6yDF6iimjS0PV4gQr2TQIyn7xFMIHqM2jHn52/ibQFnfP X-Received: by 2002:a63:706:: with SMTP id 6-v6mr32519370pgh.137.1536095426643; Tue, 04 Sep 2018 14:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536095426; cv=none; d=google.com; s=arc-20160816; b=ekckrdsqB+6JkqdcjLtKnR3yBo0JYG5h3JhuYmyqx7/fxdCXYhRaNxZJ0vX8bolSR/ 45m1D//ZCOznPeiV7mIb6Lai1YV5YmZvDxOsUTNpQrul7UyxFNGPu1CPguk/OtsfXKZM Co8IFwcqQERHorBpZmp2ktvGkqIzZqE5vc0o2OKYb8r2Eq9ygn4lawCDAkAFuHyTPaEg OaAPepG5GWGLDaNzJzPe8Bvl6eouMR/L542jWvGudtJNiy3fMcrBJ+Bm4Ve4o4OINopm 7If9pXGRN0vhzuX5XkU+x0vmmAUW1tGXzrHMSrDf9QNeQ2dAIaFFxD6m9x+aQkrxwEP7 0ppg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=sGJ23fEclMpORbwCZVDGM19HmTiCRATIn0wraawGi0c=; b=p00JlJResVG9dTwldLjePaYP08BVE+XYwMipUWkMsj6ZDSYBHiBjn9hP4b0TRiaRb1 Ge9dX5lzHW0mshbHcFMM0VEHcoDAaxMk4nL+1t/U5Jd0mEiKq2SLNpBTJARVyVkXflM0 9Qs1+/a2E5h2m/ECIhJIClHlgp8LESb67Uo3Ya1EhN43ilcw/BF0cL7ZxAGwc3qa/nsw baSsCALlgJoQeUuNdPP5n1nehZIVJlzExwsDmXLvlralawmWZSnxpPuaD/DYhRfKt7fx 4qFsNQKYtqtoQqCqh3MWO+Nd0Eozcy+rem1P9Nrh0GprPqPikiCblmPnvGQPMB6DOLy0 FUIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lekensteyn.nl header.s=s2048-2015-q1 header.b=K8P0gp4W; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si22563621pgn.667.2018.09.04.14.10.10; Tue, 04 Sep 2018 14:10:26 -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=@lekensteyn.nl header.s=s2048-2015-q1 header.b=K8P0gp4W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727278AbeIEBfw (ORCPT + 99 others); Tue, 4 Sep 2018 21:35:52 -0400 Received: from lekensteyn.nl ([178.21.112.251]:44485 "EHLO lekensteyn.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727213AbeIEBfv (ORCPT ); Tue, 4 Sep 2018 21:35:51 -0400 X-Greylist: delayed 2474 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Sep 2018 21:35:51 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lekensteyn.nl; s=s2048-2015-q1; h=Message-Id:Date:Subject:Cc:To:From; bh=sGJ23fEclMpORbwCZVDGM19HmTiCRATIn0wraawGi0c=; b=K8P0gp4WKoGP3jdq+/xXN3MRmh1cJoWoPTXuZ70zACMdfQacWX6jeak0DitvGXBWm7x4m3UHcq6RCobJk1qoJibILrwPgOHt15IxTTMfQHYRnyh/BMyHnXd6vHP6jNuAIVvJrfa9ktN0odGxFtYkL3WAdUFX7jALLm4J5SnCwDH8MmbG6UQMHTGQ3x4GFvfjAlJdhGNmm/5TVgpKYzCeZQlsnoM1q7BZbM2XvAZ4pJWcgFQW1eWsrLlHFPWnGC6YVgBiNTPsf8RRgfdR4irymW5PLC4kw2Oh2egqiK6a+G8xTCXHbzwTPKFyld0zDtlMtapcuFwE8XCN8xDPodgZQQ==; Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fxHvN-0002Ox-Fh; Tue, 04 Sep 2018 22:27:45 +0200 From: Peter Wu To: Dave Airlie , Gerd Hoffmann Cc: Alan Jenkins , virtualization@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] qxl: fix null-pointer crash during suspend Date: Tue, 4 Sep 2018 22:27:47 +0200 Message-Id: <20180904202747.14968-1-peter@lekensteyn.nl> X-Mailer: git-send-email 2.18.0 X-Spam-Score: -0.0 (/) X-Spam-Status: No, hits=-0.0 required=5.0 tests=NO_RELAYS=-0.001 autolearn=no autolearn_force=no Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "crtc->helper_private" is not initialized by the QXL driver and thus the "crtc_funcs->disable" call would crash (resulting in suspend failure). Fix this by converting the suspend/resume functions to use the drm_mode_config_helper_* helpers. Tested system sleep with QEMU 3.0 using "echo mem > /sys/power/state". During suspend the following message is visible from QEMU: spice/server/display-channel.c:2425:display_channel_validate_surface: canvas address is 0x7fd05da68308 for 0 (and is NULL) spice/server/display-channel.c:2426:display_channel_validate_surface: failed on 0 This seems to be triggered by QXL_IO_NOTIFY_CMD after QXL_IO_DESTROY_PRIMARY_ASYNC, but aside from the warning things still seem to work (tested with both the GTK and -spice options). Signed-off-by: Peter Wu --- Hi, I found this issue while trying to suspend a VM that uses QXL. In order to see the stack trace over serial, boot with no_console_suspend. Searching for "qxl_drm_freeze" showed one recent report from Alan: https://lkml.kernel.org/r/891e334c-cf19-032c-b996-59ac166fcde1@gmail.com Kind regards, Peter --- drivers/gpu/drm/qxl/qxl_drv.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index 2445e75cf7ea..d00f45eed03c 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.c +++ b/drivers/gpu/drm/qxl/qxl_drv.c @@ -136,20 +136,11 @@ static int qxl_drm_freeze(struct drm_device *dev) { struct pci_dev *pdev = dev->pdev; struct qxl_device *qdev = dev->dev_private; - struct drm_crtc *crtc; - - drm_kms_helper_poll_disable(dev); - - console_lock(); - qxl_fbdev_set_suspend(qdev, 1); - console_unlock(); + int ret; - /* unpin the front buffers */ - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; - if (crtc->enabled) - (*crtc_funcs->disable)(crtc); - } + ret = drm_mode_config_helper_suspend(dev); + if (ret) + return ret; qxl_destroy_monitors_object(qdev); qxl_surf_evict(qdev); @@ -175,14 +166,7 @@ static int qxl_drm_resume(struct drm_device *dev, bool thaw) } qxl_create_monitors_object(qdev); - drm_helper_resume_force_mode(dev); - - console_lock(); - qxl_fbdev_set_suspend(qdev, 0); - console_unlock(); - - drm_kms_helper_poll_enable(dev); - return 0; + return drm_mode_config_helper_resume(dev); } static int qxl_pm_suspend(struct device *dev) -- 2.18.0