From patchwork Mon Sep 19 06:41:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: poma X-Patchwork-Id: 9338627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1794A607D0 for ; Mon, 19 Sep 2016 06:42:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072D8291C0 for ; Mon, 19 Sep 2016 06:42:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFE15291C2; Mon, 19 Sep 2016 06:41:59 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 67BDB291C0 for ; Mon, 19 Sep 2016 06:41:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7E0489BAE; Mon, 19 Sep 2016 06:41:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B2D189BAE for ; Mon, 19 Sep 2016 06:41:47 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id 133so13209848wmq.2 for ; Sun, 18 Sep 2016 23:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=4bRjmr2i6UH/tQ5GpLHAhxpoVguWDf0YZUuvaBF+lzg=; b=JGbwzcGTLe6gPGP68oBWvOBwVxa+6Vabox1xR6WnuSRZkfP+08QkQ2epH2XEopFSNz faeoRz6uHxlSydRp8QYtSlVczujN1lYIu3cj6nEApaY8cpfnMwuWjZ7z9xSQgX5afZWH h8hu9+kqvg/1AVytveE24eknfqQyZfVeScEC54ZIWw8KRXy11YqWdsP0vtFjgaWe98t0 XVUWDXuuzNkTVJq8g70WET3pTLWHl/QJQARQEhusag8m2x6IgLrrTTqz/A3LAdC6tv87 TitdkUxgRZHXmnYNist7h017sgD/Ig522+RlymdcexpsX2/+Ll67ZO3UL7ik2e+pKi4T HMow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=4bRjmr2i6UH/tQ5GpLHAhxpoVguWDf0YZUuvaBF+lzg=; b=W7c4giy4uEYKNCa9LHf19ashH1p33QMdrB8SXz0aoeudDoc7WLukhBtkRfJHfHEfki rE790/BgbENfFSkz/HgsZlgqoM7w34Ah+F47gilQOEZbe3m0GbokJrFTGC6vuUMfUANt 0LUKkU7D4Z3IeUvzULdq9WXIVxMkyHJ38Vh+Men45qJgucqfHLRrEQ1/FXR7vP5I1B/C pnxZC9h87r+5tmbOOpvB/81kIRNbMzqLeEaNe9mBNl/1M/KtXpfhhP8XJtcynBB2mva8 DFtOXYbl8ZbvZfUc2mp4qASVSwAsxDvrwvFMZTsFpFtmyEw2pFK74UmmIPprRVC2y0vy 8V+Q== X-Gm-Message-State: AE9vXwNc5lKvR/WY5VDOpM2sb0ZzmVSXYcwNFd1iZDdifFL1NDKQhHATJos+0J3LxO/H3w== X-Received: by 10.28.57.69 with SMTP id g66mr7311546wma.49.1474267304923; Sun, 18 Sep 2016 23:41:44 -0700 (PDT) Received: from localhost (iskon5664.duo.carnet.hr. [31.147.118.32]) by smtp.gmail.com with ESMTPSA id bc5sm21338075wjb.37.2016.09.18.23.41.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Sep 2016 23:41:44 -0700 (PDT) From: poma Subject: Re: [PATCH] drm/udl: Fix for the X server screen update To: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= , DRI Development References: <750b2697-456e-bb82-b287-f594450f092e@tronnes.org> <4e8e06da-717f-a4ca-0e87-ce3f5113e9b2@gmail.com> Message-ID: <34ff0a5d-b1ea-b5f9-f49e-4a2d24e8be7f@gmail.com> Date: Mon, 19 Sep 2016 08:41:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Cc: Daniel Vetter , Gerd Hoffmann , Dave Airlie X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 18.09.2016 19:42, Noralf Trønnes wrote: > > Den 18.09.2016 15:48, skrev poma: >> Fix for DisplayLink GPU USB2.0 device X server screen update >> >> Within X server on top of DisplayLink GPU USB2.0 device, >> screen content is not refreshed i.e. updated, >> which is the most basic functionality of the screen. >> >> This partially (udl_handle_damage()) reverts commit: >> >> - e375882406d0cc24030746638592004755ed4ae0 >> "drm/udl: Use drm_fb_helper deferred_io support" >> >> Thanks Noralf for the tip. >> >> $ modinfo udl >> filename: /lib/modules/4.7.4-234.fc24.x86_64/updates/udl.ko >> license: GPL >> alias: usb:v17E9p*d*dc*dsc*dp*icFFisc00ip00in* >> depends: >> intree: Y >> vermagic: 4.7.4-234.fc24.x86_64 SMP mod_unload >> parm: fb_bpp:int >> parm: fb_defio:int >> >> $ dmesg | grep udl >> [ 41.888469] udl: module verification failed: signature and/or required key missing - tainting kernel >> [ 42.156988] udl 1-2:1.0: fb1: udldrmfb frame buffer device >> [ 42.158940] [drm] Initialized udl on minor 1 >> [ 42.159676] usbcore: registered new interface driver udl >> >> $ grep udl /var/log/Xorg.0.log >> [ 71.194] (**) | |-->Device "udl0" >> >> Tested-by: poma >> --- >> drivers/gpu/drm/udl/udl_drv.h | 2 ++ >> drivers/gpu/drm/udl/udl_fb.c | 39 +++++++++++++++++++++++++++++++++++++-- >> 2 files changed, 39 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h >> index 0b03d34..4a064ef 100644 >> --- a/drivers/gpu/drm/udl/udl_drv.h >> +++ b/drivers/gpu/drm/udl/udl_drv.h >> @@ -81,6 +81,8 @@ struct udl_framebuffer { >> struct drm_framebuffer base; >> struct udl_gem_object *obj; >> bool active_16; /* active on the 16-bit channel */ >> + int x1, y1, x2, y2; /* dirty rect */ >> + spinlock_t dirty_lock; >> }; >> >> #define to_udl_fb(x) container_of(x, struct udl_framebuffer, base) >> diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c >> index d5df555..b2b42d2 100644 >> --- a/drivers/gpu/drm/udl/udl_fb.c >> +++ b/drivers/gpu/drm/udl/udl_fb.c >> @@ -90,6 +90,9 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, >> struct urb *urb; >> int aligned_x; >> int bpp = (fb->base.bits_per_pixel / 8); >> + int x2, y2; >> + bool store_for_later = false; >> + unsigned long flags; >> >> if (!fb->active_16) >> return 0; >> @@ -115,6 +118,38 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, >> (y + height > fb->base.height)) >> return -EINVAL; >> >> + /* if we are in atomic just store the info >> + can't test inside spin lock */ >> + if (in_atomic()) >> + store_for_later = true; >> + >> + x2 = x + width - 1; >> + y2 = y + height - 1; >> + >> + spin_lock_irqsave(&fb->dirty_lock, flags); > > You can drop the spinlock and store_for_later since it always runs in > process context. > Which means that there's no need to store x1/x2/y1/y2 in fb. > >> + >> + if (fb->y1 < y) >> + y = fb->y1; >> + if (fb->y2 > y2) >> + y2 = fb->y2; >> + if (fb->x1 < x) >> + x = fb->x1; >> + if (fb->x2 > x2) >> + x2 = fb->x2; >> + >> + if (store_for_later) { >> + fb->x1 = x; >> + fb->x2 = x2; >> + fb->y1 = y; >> + fb->y2 = y2; >> + spin_unlock_irqrestore(&fb->dirty_lock, flags); >> + return 0; >> + } >> + >> + fb->x1 = fb->y1 = INT_MAX; >> + fb->x2 = fb->y2 = 0; >> + >> + spin_unlock_irqrestore(&fb->dirty_lock, flags); >> start_cycles = get_cycles(); >> >> urb = udl_get_urb(dev); >> @@ -122,14 +157,14 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, >> return 0; >> cmd = urb->transfer_buffer; >> >> - for (i = y; i < height ; i++) { >> + for (i = y; i <= y2 ; i++) { >> const int line_offset = fb->base.pitches[0] * i; >> const int byte_offset = line_offset + (x * bpp); >> const int dev_byte_offset = (fb->base.width * bpp * i) + (x * bpp); >> if (udl_render_hline(dev, bpp, &urb, >> (char *) fb->obj->vmapping, >> &cmd, byte_offset, dev_byte_offset, >> - width * bpp, > That's right, this is sufficient --- drivers/gpu/drm/udl/udl_fb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index d5df555..05ab114 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -90,6 +90,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, struct urb *urb; int aligned_x; int bpp = (fb->base.bits_per_pixel / 8); + int x2, y2; if (!fb->active_16) return 0; @@ -115,6 +116,9 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, (y + height > fb->base.height)) return -EINVAL; + x2 = x + width - 1; + y2 = y + height - 1; + start_cycles = get_cycles(); urb = udl_get_urb(dev); @@ -122,14 +126,14 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, return 0; cmd = urb->transfer_buffer; - for (i = y; i < height ; i++) { + for (i = y; i <= y2 ; i++) { const int line_offset = fb->base.pitches[0] * i; const int byte_offset = line_offset + (x * bpp); const int dev_byte_offset = (fb->base.width * bpp * i) + (x * bpp); if (udl_render_hline(dev, bpp, &urb, (char *) fb->obj->vmapping, &cmd, byte_offset, dev_byte_offset, - width * bpp, + (x2 - x + 1) * bpp, &bytes_identical, &bytes_sent)) goto error; }