Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3063924imu; Mon, 19 Nov 2018 10:05:20 -0800 (PST) X-Google-Smtp-Source: AJdET5cvwA9Qz6UvV7yGNFfwVXibwnoHzYXPW8LBiepis0TwRZ7hG7aVdzdTqNeda09AKUFFnk2h X-Received: by 2002:a63:77ce:: with SMTP id s197mr20865067pgc.89.1542650720369; Mon, 19 Nov 2018 10:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542650720; cv=none; d=google.com; s=arc-20160816; b=Xj2CeTLeqfWNpgcuc3l+JG+u2BhxMh+74gnXIYuzSRvF6+IP4SZfMZzvda6hcILlM1 D/x4nghqwJ0x7wr26OvnkH06Iztqf9B6RQDim7NkcAwKNjSm1LintmLUq5U73uJzKE/g O9LJgc7Bgdj2LugJVCvt9AmPC65pD2OBshLkTFAy85GcrZPpDwLtr6amTYBgmaKxhRcm 8z3Av4xy30aJhDt8GTxlFtwBWA8YYisggBWx3L1VUJoIdpmFcy3vPQSSIin8eheiJMT/ CP6dvClFXjtooGO5RLSr4BRdMS0TMb0CS/qSF1tKDimURF63LFbteH4wnzSqwZoTOK6Y 7REg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GBdtQL/mQzM3qYrTrXq2FLhGK64gxCYQjbJXFpzxLDw=; b=IpM/WFIVWFbW3Gk1/iiez0eQ5uPkdk49Azca1ZYzs/nNawumaqzeujav0Ug8wFDmpm hukYGI2mhPlwv2STxrYPy4fPAy2egZq65KeHU0e/XgbrE4AGXgycj0xT7ZTWjpJRzSr2 kvjni7ayUZn14Fs6Qq4ctmk70hQG1/LDJWbK7xKgbNdTfauAw2JaH6p+jWZkd1VaFOkH El7EPtzYp1Xv24udwzOdzY5JK/v4l0QAUt9Wiax/KRv2xL8tJKlmrKlqTxg3yqjp5b/A vTU1EJmz94Ts/u1JmQUpAAZB0sZx2wXkPmMKTAnBHuCWn9mSHjCjEZmAkGQvrBTYgX9T sYDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=csL5ZnFU; 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 l23si39292813pgh.533.2018.11.19.10.05.04; Mon, 19 Nov 2018 10:05:20 -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; dkim=pass header.i=@kernel.org header.s=default header.b=csL5ZnFU; 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 S1731259AbeKTC6J (ORCPT + 99 others); Mon, 19 Nov 2018 21:58:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:57044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729974AbeKTC6H (ORCPT ); Mon, 19 Nov 2018 21:58:07 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 23A452089F; Mon, 19 Nov 2018 16:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645239; bh=1HUFzHNltnDyyD8aRqV4SWxaEsFuDNaYf68Rz+Hf3S0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csL5ZnFUChAzVPLUT9QhfpmjGG4wGRVAQZhGIxgp9sn2KJn4OzXzLrxngfR7Llm2R N9swz8ukVyBheJX04bnZhIT+mKsFb/QcK6U7OR8jVlHWirIa7GXRgZfX9cmLNNAIUW XTxhKzhjF3E5i8tZ3VgfAztT1aiPfV1siCa5Xtuc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Bartlomiej Zolnierkiewicz Subject: [PATCH 4.19 089/205] mach64: fix image corruption due to reading accelerator registers Date: Mon, 19 Nov 2018 17:26:36 +0100 Message-Id: <20181119162631.957045785@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka commit c09bcc91bb94ed91f1391bffcbe294963d605732 upstream. Reading the registers without waiting for engine idle returns unpredictable values. These unpredictable values result in display corruption - if atyfb_imageblit reads the content of DP_PIX_WIDTH with the bit DP_HOST_TRIPLE_EN set (from previous invocation), the driver would never ever clear the bit, resulting in display corruption. We don't want to wait for idle because it would degrade performance, so this patch modifies the driver so that it never reads accelerator registers. HOST_CNTL doesn't have to be read, we can just write it with HOST_BYTE_ALIGN because no other part of the driver cares if HOST_BYTE_ALIGN is set. DP_PIX_WIDTH is written in the functions atyfb_copyarea and atyfb_fillrect with the default value and in atyfb_imageblit with the value set according to the source image data. Signed-off-by: Mikulas Patocka Reviewed-by: Ville Syrjälä Cc: stable@vger.kernel.org Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/aty/mach64_accel.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) --- a/drivers/video/fbdev/aty/mach64_accel.c +++ b/drivers/video/fbdev/aty/mach64_accel.c @@ -127,7 +127,7 @@ void aty_init_engine(struct atyfb_par *p /* set host attributes */ wait_for_fifo(13, par); - aty_st_le32(HOST_CNTL, 0, par); + aty_st_le32(HOST_CNTL, HOST_BYTE_ALIGN, par); /* set pattern attributes */ aty_st_le32(PAT_REG0, 0, par); @@ -233,7 +233,8 @@ void atyfb_copyarea(struct fb_info *info rotation = rotation24bpp(dx, direction); } - wait_for_fifo(4, par); + wait_for_fifo(5, par); + aty_st_le32(DP_PIX_WIDTH, par->crtc.dp_pix_width, par); aty_st_le32(DP_SRC, FRGD_SRC_BLIT, par); aty_st_le32(SRC_Y_X, (sx << 16) | sy, par); aty_st_le32(SRC_HEIGHT1_WIDTH1, (width << 16) | area->height, par); @@ -269,7 +270,8 @@ void atyfb_fillrect(struct fb_info *info rotation = rotation24bpp(dx, DST_X_LEFT_TO_RIGHT); } - wait_for_fifo(3, par); + wait_for_fifo(4, par); + aty_st_le32(DP_PIX_WIDTH, par->crtc.dp_pix_width, par); aty_st_le32(DP_FRGD_CLR, color, par); aty_st_le32(DP_SRC, BKGD_SRC_BKGD_CLR | FRGD_SRC_FRGD_CLR | MONO_SRC_ONE, @@ -284,7 +286,7 @@ void atyfb_imageblit(struct fb_info *inf { struct atyfb_par *par = (struct atyfb_par *) info->par; u32 src_bytes, dx = image->dx, dy = image->dy, width = image->width; - u32 pix_width_save, pix_width, host_cntl, rotation = 0, src, mix; + u32 pix_width, rotation = 0, src, mix; if (par->asleep) return; @@ -296,8 +298,7 @@ void atyfb_imageblit(struct fb_info *inf return; } - pix_width = pix_width_save = aty_ld_le32(DP_PIX_WIDTH, par); - host_cntl = aty_ld_le32(HOST_CNTL, par) | HOST_BYTE_ALIGN; + pix_width = par->crtc.dp_pix_width; switch (image->depth) { case 1: @@ -370,12 +371,11 @@ void atyfb_imageblit(struct fb_info *inf mix = FRGD_MIX_D_XOR_S | BKGD_MIX_D; } - wait_for_fifo(6, par); - aty_st_le32(DP_WRITE_MASK, 0xFFFFFFFF, par); + wait_for_fifo(5, par); aty_st_le32(DP_PIX_WIDTH, pix_width, par); aty_st_le32(DP_MIX, mix, par); aty_st_le32(DP_SRC, src, par); - aty_st_le32(HOST_CNTL, host_cntl, par); + aty_st_le32(HOST_CNTL, HOST_BYTE_ALIGN, par); aty_st_le32(DST_CNTL, DST_Y_TOP_TO_BOTTOM | DST_X_LEFT_TO_RIGHT | rotation, par); draw_rect(dx, dy, width, image->height, par); @@ -424,8 +424,4 @@ void atyfb_imageblit(struct fb_info *inf aty_st_le32(HOST_DATA0, get_unaligned_le32(pbitmap), par); } } - - /* restore pix_width */ - wait_for_fifo(1, par); - aty_st_le32(DP_PIX_WIDTH, pix_width_save, par); }