From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FB49390CAC for ; Mon, 18 May 2026 19:08:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779131301; cv=none; b=Qi4ZVzqK4wyf/oV28dyb2WGJhZMLsmnY6nDzYU5GlJdgg0Agf2VGNTJZL3Ss80wKqn+4bqwncKpkM0/G/zAUsCnkx1tI1KGrq5Iq3Mb+V/Je+fEapgmkFff+WLZvXW+woyWRICa/dMSi1YdaQL6Jp4RD0Wk3p5vaNXIleiJQne0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779131301; c=relaxed/simple; bh=SUAMjZQYP9AOePOsiJrF8dJnyR56nPusuhXcE6GMh44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tENtP5u63h/vVyESp62pwe4nV4uH6VymUlEilK6TnwyjS2icFHCbif9HS7dQ5t5iB+Hj7iPlLEacSe4kAoNnXOG4bNHbtKNVnJh1iIazyeyWv2pHeNFCRGcY3Kw/Sa7DZ4TKQdTkforYQK1lOkTnx480b+6KXUaIgs5F/wfd8zI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=XTD9TNRx; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=gKTlhrRL; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="XTD9TNRx"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="gKTlhrRL" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64ICpBXH2438199 for ; Mon, 18 May 2026 19:08:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=t3fkEBTd8c7 M226NlRdLECqyLGtXW1CncR7GLKvMNdQ=; b=XTD9TNRxVBVOToW76jWGXBN1paC 9Tsq8HvWlIIGOKqoO9jRgXCZpgSVSLuIYjflJnE9J4Te6nWiH+lG8BS9QEY8sM3O z6n3w6o81DucGXn6H9SgpG7xrkvkMuwbNiDnYrVz2DsEpeY6iC13uK+nevgBDReS fjA/M14X7uolSgD82lhMpKrlHAL+9ZyFKhPm7e7GUNJcZ3cMutWjmwU+08MWFUc4 qsi4G4fHSOut7cGGdokOvFcmrJoQ7hkJQRAeQ9v6IzFkmHMmiflLicqaCm1NLooO qXRg+FaOL5mzVn421cMBn6FvVbT5bUO3PHYY5aNTUL94R3P/+olbvvpsNBA== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e834v1fpw-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 18 May 2026 19:08:19 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-367bb9caa54so2352948a91.2 for ; Mon, 18 May 2026 12:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779131299; x=1779736099; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t3fkEBTd8c7M226NlRdLECqyLGtXW1CncR7GLKvMNdQ=; b=gKTlhrRLe/iVLtR5W4GCSwOVdidqcL92Mk8ZGoWYMyjFuPrDmSMqc1D/bdqSBAnviV AeS5oDF+kXuTkQXn+MsD2l21Xlr+ArVRv4/ThL+itiDt5Djpj8KXoevn4YXiY1XO/cIC 0ICRs8bBjbOln503le+nHRAkulhgTBEBACNjvWuvyI0itpdt35tXyldynsRH9kNBgxiV BRjKhLtBLfE3L/AKJjbvsEgpX39sKyxrmEnfHUetzn/fSbXpYYXiXkf25iHW/ssQ5fVP NQvWg8f4ujiss2QzjgLnU1uKJj7pypd31y/C7b4JYMpmWTnYk2KqZE4p8Ln7+2e0xgzy AfPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779131299; x=1779736099; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=t3fkEBTd8c7M226NlRdLECqyLGtXW1CncR7GLKvMNdQ=; b=JEZF0bhTKkiJXUWY3nFaIjzfSRVAhj+K0Dr0hye/4SoVz2JaaGMTNF7xoX0MgM2q9T R7LKDID7PxIIcnaYXp6LmlzuNtBoW0PhUikgYtAfYBsJUG5gpDn/TlHyEz3jBiDg03ri Zj8oRepe3hjKYBMwP2sAwKZwLX86qJYH9QiZSlv7O3Z6e1EOD3Z66r/W8Tvh9Gv1DVii g3ehQmh3y2YuHLHOr6Jpv+XiEP2EfngbP12o7G9zIy7Fw3a778GsD5UIu8WupJ0U3VSL zkjAk/b/Q/aEJqgHIjbdIVXIWIUvX/DeJfCUvgVXRpEdPucr5AV/RHDYp/5jecBltxjk UnXw== X-Forwarded-Encrypted: i=1; AFNElJ+fueKD8UFeh6ECtI0+asMnFKRF6tN9FuON8AJZONHXah91oG5j8o9MzwRkZjvZMi3yCDiARz3cFWn2vF8=@vger.kernel.org X-Gm-Message-State: AOJu0YwClUy5OjaICkp2aFafmgZ5i97heBPV2GOoTGZVkkkfi+vKOXnY qzGzGcDqBSMK9eNYWQwexwV5M6R6pMG7KpJuAzB7JSp1Tkxp84gL4xQpjeZJZkdTMtfXLagsbwQ v4e/53ItUsrcD+ojJOq6okosrs3FbyCTtr5UN7XoEKBydsducTq1VP6q90vpjnkujQEg= X-Gm-Gg: Acq92OE822rXpY27SKB3zwsvKMmoOm1vmnIiPgVPr65MG6YJS6V0UKJW5fbyyx5uM+/ LHCtmsvpTvWcR+MEpu7tky1NGvCyPsCKHjkLNVkYDqEvPcWKrR9UskaGkh5fKiIt+GVDXIv10AL Kkz77FsorIPJysZslWajQIy97/0ElPDetlLyZatiF8wsdL8wft3f5aa0J10Y//zDr6/cd0RY9Ou rKbjYKGljtufYfujImMnVSN/GQv0GWlfbHxbFfM+3MAck4VV10xBj4ZVj/ZLIWnLCcYGemzLlkv WjKmAZQLYVdQiZ9M7IP/0yRREz7u1nhyTcdkunZQEUSLkxeXeZBsnyasaADfLTzTIcF2q8oTdNL IoWsJYa4OSpMOlLYOxVLUBcs8BtxmJvmp X-Received: by 2002:a05:6a21:6d9a:b0:398:aea8:a9c0 with SMTP id adf61e73a8af0-3b22eb9e9admr18155067637.19.1779131298621; Mon, 18 May 2026 12:08:18 -0700 (PDT) X-Received: by 2002:a05:6a21:6d9a:b0:398:aea8:a9c0 with SMTP id adf61e73a8af0-3b22eb9e9admr18155030637.19.1779131298119; Mon, 18 May 2026 12:08:18 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c82da93df0dsm7667139a12.19.2026.05.18.12.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 12:08:17 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Anna Maniscalco , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v7 08/16] drm/msm/a6xx: Add yield & flush helper Date: Mon, 18 May 2026 12:06:35 -0700 Message-ID: <20260518190735.16236-9-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518190735.16236-1-robin.clark@oss.qualcomm.com> References: <20260518190735.16236-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=F9ZnsKhN c=1 sm=1 tr=0 ts=6a0b63a3 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=7a4_7rcHm0II5uOVc2AA:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-ORIG-GUID: IwUrk71eWsqtUJaAEbx_HdbuN5Af2TMG X-Proofpoint-GUID: IwUrk71eWsqtUJaAEbx_HdbuN5Af2TMG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE4MDE4OCBTYWx0ZWRfX5yn/8RtMxghl l7vN6hj92ShzzKjNEMohe7RKt5wyTGnhvU1gf5mSu5F4HWJ8/b87hNZ1apPRt4/GXDizEYHH1cz WKz6zXBzvY9ddnVLBzixUSdR+Rnpfk0wUOcw654yoIT/haOB/H3YTcj327K3nQS66H8XH0Fm54p 9VOrRQJgxnOj6Fd/DkBTU+KOlblV3pbQfdgyvhSxpk1pKDFV1JctX6m/H6sA/TMyTqLZ7/5Gfn+ z/NkDMcMHCiZilOeLn9OT4ikxC3CTk7AfZRwLsYn2tad9Z4W0QbDvPDMWHeFVvnAPusJp1OMBQq ZkV2JJoa/Me1yd/foN3fSkpFHcfj5/vNNYZ1c4kOrKeYfNcGLb7zAQPNsje8uJEoWb/F7bF77uC qOdqpBN/3vOyy5UsdU4oz1D+c8A2AU9qgQDQmvgPf8ogwleAQF7AIIoiU7MnkpGkSc6lNL1Y8Jx Sf+Chql0foSGjTMpZDQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-18_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 suspectscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605180188 It's a common pattern, needing to insert a yield packet before flushing the rb. And we'll need this once again for configuring perfcntr SEL regs. So add a helper. Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov Reviewed-by: Anna Maniscalco --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 +++++++++++++-------------- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 10 +---- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 71f54ab5425d..415902f6e5d7 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -189,6 +189,30 @@ void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring) spin_unlock_irqrestore(&ring->preempt_lock, flags); } +void +a6xx_flush_yield(struct msm_gpu *gpu, struct msm_ringbuffer *ring) +{ + /* If preemption is enabled */ + if (gpu->nr_rings > 1) { + /* Yield the floor on command completion */ + OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); + + /* + * If dword[2:1] are non zero, they specify an address for + * the CP to write the value of dword[3] to on preemption + * complete. Write 0 to skip the write + */ + OUT_RING(ring, 0x00); + OUT_RING(ring, 0x00); + /* Data value - not used if the address above is 0 */ + OUT_RING(ring, 0x01); + /* generate interrupt on preemption completion */ + OUT_RING(ring, 0x00); + } + + a6xx_flush(gpu, ring); +} + static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, u64 iova) { @@ -597,28 +621,9 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) OUT_PKT7(ring, CP_SET_MARKER, 1); OUT_RING(ring, 0x100); /* IFPC enable */ - /* If preemption is enabled */ - if (gpu->nr_rings > 1) { - /* Yield the floor on command completion */ - OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); - - /* - * If dword[2:1] are non zero, they specify an address for - * the CP to write the value of dword[3] to on preemption - * complete. Write 0 to skip the write - */ - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - /* Data value - not used if the address above is 0 */ - OUT_RING(ring, 0x01); - /* generate interrupt on preemption completion */ - OUT_RING(ring, 0x00); - } - - trace_msm_gpu_submit_flush(submit, adreno_gpu->funcs->get_timestamp(gpu)); - a6xx_flush(gpu, ring); + a6xx_flush_yield(gpu, ring); /* Check to see if we need to start preemption */ if (adreno_is_a8xx(adreno_gpu)) @@ -958,15 +963,7 @@ static int a7xx_preempt_start(struct msm_gpu *gpu) a6xx_emit_set_pseudo_reg(ring, a6xx_gpu, NULL); - /* Yield the floor on command completion */ - OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - /* Generate interrupt on preemption completion */ - OUT_RING(ring, 0x00); - - a6xx_flush(gpu, ring); + a6xx_flush_yield(gpu, ring); return a6xx_idle(gpu, ring) ? 0 : -EINVAL; } diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h index eb431e5e00b1..99c3e55f5ca8 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -317,6 +317,7 @@ void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_ void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); int a6xx_fenced_write(struct a6xx_gpu *gpu, u32 offset, u64 value, u32 mask, bool is_64b); void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring); +void a6xx_flush_yield(struct msm_gpu *gpu, struct msm_ringbuffer *ring); int a6xx_zap_shader_init(struct msm_gpu *gpu); void a8xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bool gx_off); diff --git a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c index e022c9a162a4..124d315b2469 100644 --- a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c @@ -488,15 +488,7 @@ static int a8xx_preempt_start(struct msm_gpu *gpu) a6xx_emit_set_pseudo_reg(ring, a6xx_gpu, NULL); - /* Yield the floor on command completion */ - OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - /* Generate interrupt on preemption completion */ - OUT_RING(ring, 0x00); - - a6xx_flush(gpu, ring); + a6xx_flush_yield(gpu, ring); return a8xx_idle(gpu, ring) ? 0 : -EINVAL; } -- 2.54.0