Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3696pxb; Mon, 2 Nov 2020 12:18:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVYm01r7cYt9oTzZDeo5ai4IoigHPHlIwYgIgFNEHIf857YXN3nVavLHIZeRZGeFqwVItQ X-Received: by 2002:a05:6402:287:: with SMTP id l7mr17981419edv.212.1604348288421; Mon, 02 Nov 2020 12:18:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604348288; cv=none; d=google.com; s=arc-20160816; b=zbbcRflg3s5PoYYQ0h/LGhXXcXj4mBEFEs/sr1IZ741S8czmpIELXH9UHWYDw8WDqp 0DIrlXYjwNuawJeNXhHXjxvywEjnYR2IGZL8vNIc+nr3uui22VENZoCxhgSb36ZtVZC+ lX2cKxkTKH0KjxaPs74IvOY3yPrcuO9QzT0PFJ7Z3ibOXGlpuUVzNbJ1Gvsrgzfa+TGA 01A9/e2GzxeBCnyNV23wijKUdceJMNqk5NZlDqhPyae7CMD245xciR2oW9Lsm92wvQ0p OLwSFxZsc5Z92dMJWsDBM90YgpIZ0wEBAcqKTwOhjkQyEVpOjEo9INDCb5Sfj6HUYQ57 Zp9g== 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 :message-id:date:subject:cc:to:from; bh=U9txsVA1iEPtyLZIhj1wbMuNGp7IQmJC932YSqjiwi4=; b=VL2pCWcMvPsBpnuYljJpCiicdoO43HxciRYWR0cLaRecp1dWStvEhJaFBuLBeZHQSW +dzHepZ5uTrcvUHBdrUPPQJKkCh04782s5gedQAfjgztm3rmiu4u+7Q4PfAniWzwBtpk 3o/XmOj+hiqUPJ0kGTMvazuq4W3+BwPRSa5fUu2YbZa2eaQ3PbI2+GEacA2fZmmBLGJz lB6Rv/W8P7kpdIgUf+STOjBsVSXggzXL4b4Lk2iq8Skl350I3h/a57s9RZANHz0lpPxW My1yIuYEchpn2aA5QFdKcHArfe+UeqMQRAXQvahZexnZFKK0V4M5adUQYRfNaWddNcjs 3qCw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si10122952ejd.426.2020.11.02.12.17.44; Mon, 02 Nov 2020 12:18:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgKBUOA (ORCPT + 99 others); Mon, 2 Nov 2020 15:14:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbgKBUMk (ORCPT ); Mon, 2 Nov 2020 15:12:40 -0500 X-Greylist: delayed 595 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 02 Nov 2020 12:12:40 PST Received: from relay07.th.seeweb.it (relay07.th.seeweb.it [IPv6:2001:4b7a:2000:18::168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E5AC0617A6 for ; Mon, 2 Nov 2020 12:12:40 -0800 (PST) Received: from Marijn-Arch-PC.localdomain (94-209-165-62.cable.dynamic.v4.ziggo.nl [94.209.165.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r2.th.seeweb.it (Postfix) with ESMTPSA id E34CA3E7B1; Mon, 2 Nov 2020 21:02:41 +0100 (CET) From: Marijn Suijten To: robdclark@gmail.com Cc: konrad.dybcio@somainline.org, martin.botka@somainline.org, phone-devel@vger.kernel.org, Marijn Suijten , AngeloGioacchino Del Regno , Sean Paul , David Airlie , Daniel Vetter , Jordan Crouse , Konrad Dybcio , AngeloGioacchino Del Regno , Eric Anholt , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/msm: a5xx: Make preemption reset case reentrant Date: Mon, 2 Nov 2020 21:02:25 +0100 Message-Id: <20201102200227.8876-1-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 d6804a802355..9a202a7da131 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.29.2