Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2026181imm; Tue, 10 Jul 2018 11:51:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfxvnLztnNZX9HyAKOwPpSjnszWS+28PIv6p1QfOzxfyUn5Ae85q+WrbaMovB0StZT6UeEP X-Received: by 2002:a63:bd01:: with SMTP id a1-v6mr17693987pgf.319.1531248686180; Tue, 10 Jul 2018 11:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248686; cv=none; d=google.com; s=arc-20160816; b=IFthlNGfY3DjCokfOOVJiQSJBqjZ8nez2ffizNmRP2M6FKMTo8R2rdpdeFc7dOKBVq BlaiexAN2iL07yq4Oni3JVeWp7naV61HmYvef/pSbMHkX/rlwm+yemW1k8/5BYjZz8kh ijnd3j8iu5oOs5xtls3WepMX9brelEGtMWj1TPA/ncax6c1axRqT6sYUJMGhw59fHtpg o5VW1ZSePbmfFXECyX25Q4CFWzQ9Wgg6t8MtbYThaSLVqAIsKYvE5eP1sNtA80NuiKyG guLi0xJobwYCFgRcXghxCoZgtaswWoa4ch1sx1rTaWSA5oJPJYSZ3g05Vj/SwQMt6vEi I0AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+wFUZ2QK+oiKgcHDRvAH98IPNfNca4CF3+qhx/lZw/g=; b=lNvgAQtcdG21dBlXv1vLCGC9EWBXwzn5d+8TU6nhYmFKI59BNkAawb7QhuI46VKVUi rNhZRZce81KkA7CqEEo14sgpOORoN5Fa838KSQGJ4LnOTfVYAV2SD1wNUDOozTwON4RX bvRO4TMAnh2ciRLDHWXJbHndWq1V99w+dxoZDtJ57r6++n1qIIG7BB0EU4M/ScF3HFIi h4imSdBtUNW9yh9zw88/nt1PHXDLGUD0Yc64c7inQu58yV3onMDrsJnImw2oWxa+LdU/ L43QbfR2/Pan7/jvIKO/lkDhCHEdubWRybMHxUEkiJV6A/FkP8m35OgIReFPu6n9g9W7 YOvw== 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 u5-v6si6602913pls.372.2018.07.10.11.51.11; Tue, 10 Jul 2018 11:51: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; 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 S2387971AbeGJSaN (ORCPT + 99 others); Tue, 10 Jul 2018 14:30:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45514 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732596AbeGJSaM (ORCPT ); Tue, 10 Jul 2018 14:30:12 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BAF9AEC2; Tue, 10 Jul 2018 18:30:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Dave Airlie Subject: [PATCH 4.9 25/52] drm/udl: fix display corruption of the last line Date: Tue, 10 Jul 2018 20:24:53 +0200 Message-Id: <20180710182451.870514784@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable 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 Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie Signed-off-by: Greg Kroah-Hartman --- 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 @@ -136,7 +136,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 @@ -152,11 +152,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); pixel_val16 = get_pixel_val16(pixel, bpp); while (pixel < cmd_pixel_end) { @@ -192,6 +192,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;