Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9085393pxu; Mon, 28 Dec 2020 06:16:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLMkZ6TeqwOr/Q8L5cXlTzxNNOpWtt6lXRaryCq1i4GTjSu/ZIGxYc4rLe6ekZLJ7G0T5h X-Received: by 2002:a17:907:41e3:: with SMTP id nb3mr42490658ejb.378.1609165005157; Mon, 28 Dec 2020 06:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165005; cv=none; d=google.com; s=arc-20160816; b=hXL92ngFDDpnKuBSlv+DHGTpLnIJ5h5UmpqyswroDjmbhWSYzNTD4d2TotvsNqrL9b +zcZ7JnqA5phiN5WshCdIJO0E0BBAYOicH3wBNPLfYLkxKT86BhN/9eGVTmxwnA/gtL7 moMPLAcxR+oIqgPhFTU7DKR4WU/3RFcuk7/1fRDxK7uJFqRgQJf8IC8gCF5YApMbsTHS afgQ21NIjd88IsqIHLLxoKaVNZicuDH34t01H9aEEvIscE0oOslXPeM+57PnvqVoRYS/ SlNCImgHDPnNtiskfYKUJJ43W+pUlqD5d8Npz7xGdzvOpa+Awu0du8Gi6zcb/CdPUgm7 7TXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=19RJ9hCFKq74LAli9WJy0Sp8IDWcvz1R/EcvG22BFvY=; b=Yg19DciTq+Wexy1qOusx1Jh3WOP1fmXQ9l6GTB4IsfSuIefeWiyg7ApGqEqg3vGRXd OvFk2k4JWpdX7RBvOEkYYHQudzzEAAIJ4GXYVjHUYvgendnMP/BNvbXcDGtz6LiaPh+P /rAUOwgcxIYJoHPJ4L9WXLf5XBfeH76KvkaIwZu85roekxiYBGPg7LGRmDdPXzXmaziH zcvvWEYiYsCa4fSXcFTPBrzpVobSHx6dASzdyEET9NAFe4sH0jgj1ItAtnMPEhq0NdQ3 9F9WD1p/+zi6fUGECFPKfqqEE841PMUvBul2bVCJwErGNQKJCEXCMcRj9DNcuFhOAzQG 5lJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=os7bSPjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si18710696ejq.297.2020.12.28.06.16.21; Mon, 28 Dec 2020 06:16:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=os7bSPjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440396AbgL1OOW (ORCPT + 99 others); Mon, 28 Dec 2020 09:14:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:48962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440380AbgL1OOS (ORCPT ); Mon, 28 Dec 2020 09:14:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AEE2B207AB; Mon, 28 Dec 2020 14:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164843; bh=6i/clCzBH3uarIZ3RgFanfUSn3WBwtaGc4nPJE7PGtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=os7bSPjEhY4+bGiCBP+HEMlmZRoZnovn2J7SQsKl/NmeWrZk+t8nvCEFRuFNcE9ru 8nbnTKL78StzaZT74ETzq34zy2HcPonIVt91SmY65s1paiPMx7s3ytFnKN/Bjv1ECW k4gdwl6AXHpNpVwbJqLzTifxF8gKJgBCwrcm+a/M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marijn Suijten , AngeloGioacchino Del Regno , Jordan Crouse , Rob Clark , Sasha Levin Subject: [PATCH 5.10 319/717] drm/msm: a5xx: Make preemption reset case reentrant Date: Mon, 28 Dec 2020 13:45:17 +0100 Message-Id: <20201228125036.318013218@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marijn Suijten [ Upstream commit 7cc29fcdfcc8784e97c5151c848e193800ec79ac ] nr_rings is reset to 1, but when this function is called for a second (and third!) time nr_rings > 1 is false, thus the else case is entered to set up a buffer for the RPTR shadow and consequently written to RB_RPTR_ADDR, hanging platforms without WHERE_AM_I firmware support. Restructure the condition in such a way that shadow buffer setup only ever happens when has_whereami is true; otherwise preemption is only finalized when the number of ring buffers has not been reset to 1 yet. Fixes: 8907afb476ac ("drm/msm: Allow a5xx to mark the RPTR shadow as privileged") Signed-off-by: Marijn Suijten Tested-by: AngeloGioacchino Del Regno Reviewed-by: Jordan Crouse Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index 8aa08976aad17..69ed2c6094665 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -755,12 +755,8 @@ static int a5xx_hw_init(struct msm_gpu *gpu) gpu_write(gpu, REG_A5XX_CP_RB_CNTL, MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE); - /* Disable preemption if WHERE_AM_I isn't available */ - if (!a5xx_gpu->has_whereami && gpu->nr_rings > 1) { - a5xx_preempt_fini(gpu); - gpu->nr_rings = 1; - } else { - /* Create a privileged buffer for the RPTR shadow */ + /* Create a privileged buffer for the RPTR shadow */ + if (a5xx_gpu->has_whereami) { if (!a5xx_gpu->shadow_bo) { a5xx_gpu->shadow = msm_gem_kernel_new(gpu->dev, sizeof(u32) * gpu->nr_rings, @@ -774,6 +770,10 @@ static int a5xx_hw_init(struct msm_gpu *gpu) gpu_write64(gpu, REG_A5XX_CP_RB_RPTR_ADDR, REG_A5XX_CP_RB_RPTR_ADDR_HI, shadowptr(a5xx_gpu, gpu->rb[0])); + } else if (gpu->nr_rings > 1) { + /* Disable preemption if WHERE_AM_I isn't available */ + a5xx_preempt_fini(gpu); + gpu->nr_rings = 1; } a5xx_preempt_hw_init(gpu); -- 2.27.0