From patchwork Tue Aug 14 00:16:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 10564973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3F0813B4 for ; Tue, 14 Aug 2018 00:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 940B5291A4 for ; Tue, 14 Aug 2018 00:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8628A291D4; Tue, 14 Aug 2018 00:38:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7957291A4 for ; Tue, 14 Aug 2018 00:38:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C3AC189C83; Tue, 14 Aug 2018 00:38:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org X-Greylist: delayed 1363 seconds by postgrey-1.36 at gabe; Tue, 14 Aug 2018 00:38:53 UTC Received: from mail.lekensteyn.nl (mail.lekensteyn.nl [IPv6:2a02:2308::360:1:25]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE44589C83 for ; Tue, 14 Aug 2018 00:38:53 +0000 (UTC) Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fpN0K-0007p2-6L; Tue, 14 Aug 2018 02:16:08 +0200 From: Peter Wu To: intel-gfx@lists.freedesktop.org Date: Tue, 14 Aug 2018 02:16:07 +0200 Message-Id: <20180814001607.27026-1-peter@lekensteyn.nl> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH xf86-video-intel] SNA: fix PRIME output support since xserver 1.20 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Michel_D=C3=A4nzer?= MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Since xorg-server 1.20, an external monitor would remain blank when used in a PRIME output slave setup. Only a cursor was visible. The cause is "Make PixmapDirtyUpdateRec::src a DrawablePtr" in xserver, the "src" pointer might point to the root window (created by the server) instead of a pixmap (as created by xf86-video-intel). Use get_drawable_pixmap to handle both cases. When built with -fsanitize=address, the following test will trigger a heap-buffer-overflow error due to to_sna_from_pixmap receiving a window instead of a pixmap. Test on a hybrid graphics laptop (Intel + modesetting/nouveau): xrandr --setprovideroutputsource modesetting Intel xrandr --output DP-1-1 --mode 2560x1440 # should not crash glxgears # should display gears on both screens Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100086 Signed-off-by: Peter Wu --- Tested with xserver 1.20.1 with ASAN enabled. Survives multiple resolution changes, works with a Plasma desktop session, it seems stable. Something like this patch is required to make multi-monitor setups usable in a hybrid graphics setting with Xorg 1.20. --- src/sna/sna_accel.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 2f669bcf..80b116a3 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -17510,7 +17510,11 @@ static bool has_offload_slaves(struct sna *sna) PixmapDirtyUpdatePtr dirty; xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) { +#ifdef HAS_DIRTYTRACKING_DRAWABLE_SRC + assert(dirty->src == &sna->front->drawable); +#else assert(dirty->src == sna->front); +#endif if (RegionNotEmpty(DamageRegion(dirty->damage))) return true; } @@ -17671,7 +17675,11 @@ static void sna_accel_post_damage(struct sna *sna) if (RegionNil(damage)) continue; +#ifdef HAS_DIRTYTRACKING_DRAWABLE_SRC + src = get_drawable_pixmap(dirty->src); +#else src = dirty->src; +#endif dst = dirty->slave_dst->master_pixmap; region.extents.x1 = dirty->x; @@ -17922,9 +17930,15 @@ migrate_dirty_tracking(PixmapPtr old_front, PixmapPtr new_front) PixmapDirtyUpdatePtr dirty, safe; xorg_list_for_each_entry_safe(dirty, safe, &screen->pixmap_dirty_list, ent) { +#ifdef HAS_DIRTYTRACKING_DRAWABLE_SRC + assert(dirty->src == &old_front->drawable); + if (dirty->src != &old_front->drawable) + continue; +#else assert(dirty->src == old_front); if (dirty->src != old_front) continue; +#endif DamageUnregister(&dirty->src->drawable, dirty->damage); DamageDestroy(dirty->damage); @@ -17939,7 +17953,11 @@ migrate_dirty_tracking(PixmapPtr old_front, PixmapPtr new_front) } DamageRegister(&new_front->drawable, dirty->damage); +#ifdef HAS_DIRTYTRACKING_DRAWABLE_SRC + dirty->src = &new_front->drawable; +#else dirty->src = new_front; +#endif } #endif }