Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3318645imu; Sun, 11 Nov 2018 12:15:41 -0800 (PST) X-Google-Smtp-Source: AJdET5cMZRWi60tQDnnSwLgEbL0e0jtWqIpTJBhLNrtnhQxdiKeqgeQeqOQb8ITjgxVYHDnWehlD X-Received: by 2002:a63:89c2:: with SMTP id v185mr14039526pgd.97.1541967341925; Sun, 11 Nov 2018 12:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967341; cv=none; d=google.com; s=arc-20160816; b=rH+4s/IEl6FfshlWqdl2/zRyb6t8TgV6M0EpdBgnt6LJmMZ17S1KJipYI88vA9x+lK uNj1vbLTJk5ldv4ymknCTxdxw79ibWnjY9qklX2pDrfIteR++XUVTuPQfEKbBGiknCqd XdPWbL4m3+661W7xP4QyB/p1SaTHTewPISlxJ87dGu/W2a3KE4YPl9r+NACdJrBMYN1g lNxtIMrLIhbL/VS2tejBa3wdQIpw/6h2QIUdU3af6KcHNLtwBBHkrvf156vmBsPEj1Ah 5CG/J7zU8/AnuvmjBM9+3W6hlm5llpI3OD8l5Si6CCiy8y7aShlLdKdmZffrDS0gwqHm jb+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=tAbk1kLBjSVBPoPX3cNmcE2Pev88fvXHTrsex1RHaOE=; b=UUrN8AjxEwznmD22LM2oXR09qxXkRuPg4f+XKgSLUfK8boRAj+m5vs6XDTCUe3XZee Wa2LP53jpcwtDe2lQMIozai/7h+y4fU79AUQeucIh/1C2nSLiWX8hZYTSSD4LRNSvoZK YJ5wKhp+wahM+e25FoXc5MEWL3ukcDGoazlzmgxzYciH+QeziCMqmgZd/2eW6qyowFUl aN1eHsndQ+5RewRY/GW5mSLfzlCxvafyKWJYkg5Hi3D9bvstzWQYNv0LsTl5bviFXiDF 7tO90fa+rW3a7GFGhufWhNcokPQfdEgHe8dMfZ/jT9j1O/y4hDBmvMAQhVEk/z3J6MxB Xgqw== ARC-Authentication-Results: i=1; mx.google.com; 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 v1-v6si14833148plo.134.2018.11.11.12.15.26; Sun, 11 Nov 2018 12:15:41 -0800 (PST) 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; 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 S1731721AbeKLGES (ORCPT + 99 others); Mon, 12 Nov 2018 01:04:18 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52904 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726816AbeKLGER (ORCPT ); Mon, 12 Nov 2018 01:04:17 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvss-0000l8-6K; Sun, 11 Nov 2018 19:59:02 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsV-0001gC-Hn; Sun, 11 Nov 2018 19:58:39 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Mikulas Patocka" , "Dave Airlie" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 230/366] drm/udl: fix display corruption of the last line In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka commit 99ec9e77511dea55d81729fc80b6c63a61bfa8e0 upstream. The displaylink hardware has such a peculiarity that it doesn't render a command until next command is received. This produces occasional corruption, such as when setting 22x11 font on the console, only the first line of the cursor will be blinking if the cursor is located at some specific columns. When we end up with a repeating pixel, the driver has a bug that it leaves one uninitialized byte after the command (and this byte is enough to flush the command and render it - thus it fixes the screen corruption), however whe we end up with a non-repeating pixel, there is no byte appended and this results in temporary screen corruption. This patch fixes the screen corruption by always appending a byte 0xAF at the end of URB. It also removes the uninitialized byte. Signed-off-by: Mikulas Patocka Signed-off-by: Dave Airlie [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/gpu/drm/udl/udl_fb.c | 5 ++++- drivers/gpu/drm/udl/udl_transfer.c | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -234,7 +234,10 @@ int udl_handle_damage(struct udl_framebu if (cmd > (char *) urb->transfer_buffer) { /* Send partial buffer remaining before exiting */ - int len = cmd - (char *) urb->transfer_buffer; + int len; + if (cmd < (char *) urb->transfer_buffer + urb->transfer_buffer_length) + *cmd++ = 0xAF; + len = cmd - (char *) urb->transfer_buffer; ret = udl_submit_urb(dev, urb, len); bytes_sent += len; } else --- a/drivers/gpu/drm/udl/udl_transfer.c +++ b/drivers/gpu/drm/udl/udl_transfer.c @@ -149,11 +149,11 @@ static void udl_compress_hline16( raw_pixels_count_byte = cmd++; /* we'll know this later */ raw_pixel_start = pixel; - cmd_pixel_end = pixel + (min(MAX_CMD_PIXELS + 1, - min((int)(pixel_end - pixel) / bpp, - (int)(cmd_buffer_end - cmd) / 2))) * bpp; + cmd_pixel_end = pixel + min3(MAX_CMD_PIXELS + 1UL, + (unsigned long)(pixel_end - pixel) / bpp, + (unsigned long)(cmd_buffer_end - 1 - cmd) / 2) * bpp; - prefetch_range((void *) pixel, (cmd_pixel_end - pixel) * bpp); + prefetch_range((void *) pixel, cmd_pixel_end - pixel); while (pixel < cmd_pixel_end) { const u8 *const start = pixel; @@ -193,6 +193,9 @@ static void udl_compress_hline16( if (pixel > raw_pixel_start) { /* finalize last RAW span */ *raw_pixels_count_byte = ((pixel-raw_pixel_start) / bpp) & 0xFF; + } else { + /* undo unused byte */ + cmd--; } *cmd_pixels_count_byte = ((pixel - cmd_pixel_start) / bpp) & 0xFF;