Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3097817ybi; Thu, 18 Jul 2019 20:59:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuxC7vCFy7/lCHlzqRmatXl3sSG3e+xgskPcVn8cYCBpedw0lampOJj2A3R5DC6B14e2WU X-Received: by 2002:a17:90a:db52:: with SMTP id u18mr55705044pjx.107.1563508793978; Thu, 18 Jul 2019 20:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508793; cv=none; d=google.com; s=arc-20160816; b=ue2Ag3SKt5w8mIiYO3Boz+kVmkmsUgZ2bQ9hA/tecvs08RQvtPPrteoLX5J6bNkKdN +yR4TxWp5raLrwCBBGFSdaT8Y1m2suxGy34CudJWEz2tDdeWyaDQh5jBQrL3cB+h4NaM EadHhAQqC+Fwwwr51uD0APrJD5SUhg3OUs1ECv1f9MEvP/gpVPIAbv1yhD+AHk6VBZd5 Y6CpI3yB6HzqzTtHBZ4apApmf9sHcSStYapzuYbYyh80wPQU5bwz8KpTwp4XFEfhQ+Yp 9zzkHMYDd7yu9qD1Qx6c/8lOJhAoi7JQdTqUGd5cAd5hqbvDybRRlI6OiWy70s4CkBcg 2/kg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0PqlsL59mw4p8xRwDOHq7eiZ9O9+NdPOt+z6V7LxXY4=; b=e1nhEDIDtbgOt6momdgd+8bv3a93mE7VDxtX0aabVWxCkgWm/4uEOY94Gh+8Z1pjQm rJJBhEgVv2F+a8nYDTXHsh7sJqnvgzE6nJZCbrIPma7waRQNddihvLmgTu9jjGaU7OK6 Jmv1KbzPBnMhZ3NVBKAr1yRqlrDBLE1KTXVwhW2dZeiql/NvS2V18QaBAjWNMC4Nu8V9 z+T65VCe3wqWp3UkEeiU/JSvPm6QrQBomln4wzO+OrGrUvRShBftPR0vmeShfRplxaT8 Rondp7JivVDahDiAuAJkF+PqkziPL+V44IClz4NQor/al+KmWi4GkM4iQS7cdus0tTV8 yoLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vRqbRgIf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si1786695pjp.101.2019.07.18.20.59.38; Thu, 18 Jul 2019 20:59:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vRqbRgIf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727486AbfGSD5p (ORCPT + 99 others); Thu, 18 Jul 2019 23:57:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:56936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727356AbfGSD5o (ORCPT ); Thu, 18 Jul 2019 23:57:44 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0914A21852; Fri, 19 Jul 2019 03:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508663; bh=fnhJtHhZ7psncufqizd+johqm8CCDOQCcGb61BQAxMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vRqbRgIf84hL8vDyIJkdhQECnhmt84w9FjXKgcYDw8dAZktKWlox09LVdr+FWX4zU fkZ3QnsUq5DfHCDTExcfkLlQmR8G+5Bfhuq18/TTm+Yv5GXKqHipuzYQTPUrGRJkpV dqURjNRGLLsRgZPSKFsXAlduSr3AKhWBr3/RzxMs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Kazlauskas , Sun peng Li , Bhawanpreet Lakha , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.2 021/171] drm/amd/display: Disable cursor when offscreen in negative direction Date: Thu, 18 Jul 2019 23:54:12 -0400 Message-Id: <20190719035643.14300-21-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Kazlauskas [ Upstream commit e371e19c10a264bd72c2ff1d21e2167b994710d1 ] [Why] When x or y is negative we set the x and y values to 0 and compensate with a positive cursor hotspot in DM since DC expects positive cursor values. When x or y is less than or equal to the maximum cursor width or height the cursor hotspot is clamped so the hotspot doesn't exceed the cursor size: if (x < 0) { xorigin = min(-x, amdgpu_crtc->max_cursor_width - 1); x = 0; } if (y < 0) { yorigin = min(-y, amdgpu_crtc->max_cursor_height - 1); y = 0; } This incorrectly forces the cursor to be at least 1 pixel on the screen in either direction when x or y is sufficiently negative. [How] Just disable the cursor when it goes far enough off the screen in one of these directions. This fixes kms_cursor_crc@cursor-256x256-offscreen. Signed-off-by: Nicholas Kazlauskas Reviewed-by: Sun peng Li Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index ab7c5c3004ee..fa268dd736f4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4952,12 +4952,12 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc, int x, y; int xorigin = 0, yorigin = 0; - if (!crtc || !plane->state->fb) { - position->enable = false; - position->x = 0; - position->y = 0; + position->enable = false; + position->x = 0; + position->y = 0; + + if (!crtc || !plane->state->fb) return 0; - } if ((plane->state->crtc_w > amdgpu_crtc->max_cursor_width) || (plane->state->crtc_h > amdgpu_crtc->max_cursor_height)) { @@ -4971,6 +4971,10 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc, x = plane->state->crtc_x; y = plane->state->crtc_y; + if (x <= -amdgpu_crtc->max_cursor_width || + y <= -amdgpu_crtc->max_cursor_height) + return 0; + if (crtc->primary->state) { /* avivo cursor are offset into the total surface */ x += crtc->primary->state->src_x >> 16; -- 2.20.1