From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 5AD113DB64D for ; Mon, 11 May 2026 13:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778504488; cv=none; b=pXdRJjA83Zcg6895c/trpe6JqYsNhtsAWW9v2f0WXHmJB+RfcakWVfSbrlO4qPHuoynW+bzLi7ZiBRXXRsuL6PXrr+nOoeWK6IwYBOvM34S4boKHbr21WpzAWd0U4fn7XRDfkenUsBU8SAuJ8VyBz4x3sdQ4L1c1GQOvI8/kTXY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778504488; c=relaxed/simple; bh=nf/AzQJzAwD5Wdqnd6VCCPR5ecVd2qygEvoiPvLJ7Vg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=arqLqYL0D+OarTwUQ5MXwCWKbr0b009ZJKjO5UVDSzUSibcTLSkrZrS6pmYfnYEconaC7cmLRjOjMxr2xRV5rUpIQG/4x8HySvfEVgTPw8kd8nHpWYNPMqFmkMCoJO6uMwIThBd6dF1CuK+rBL/UURGAqI2qpQxCvUkKI3mEmlA= 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=Jn1yekCp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Mk/tRsAB; arc=none smtp.client-ip=205.220.180.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="Jn1yekCp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Mk/tRsAB" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64B96bqJ652815 for ; Mon, 11 May 2026 13:01:25 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=ZFtTLmOQAzj qHoC3Fafdx5s7yem/Cv9ClA1WpeTUDMw=; b=Jn1yekCpstrqz+ayP+8M7z8c/BS Q3Z5rFpJR+3tTpCkhmtleSEu3T1D08jVw6+3IDHyhMC0YZDzj11boH04xu2P1sbN D1UmonVNJ9kH2Gc4SaVRrsb63TMF7n1c9iQNGVydZj+hEwMT4l7GCPYxZEmlM5Jr rRAH9qTdIU/IhUKYzvuzvsDHtz7JJZu3r6jT9qYWaGUnkyc4aPVsE24taIF9D/SY Y8JZwcR5AECRi745OjV+XviR4YMzADuAeaH3W3auczopHXZZ9GGqJw0raX6XEf11 /jzpUo2O2NQOhb1qeSh+zRfIAegJbgyuSaMLEcacAdJ/fU1Job7U5uNMnqQ== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e37xu9sne-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 11 May 2026 13:01:20 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-367fd7b8825so1732287a91.0 for ; Mon, 11 May 2026 06:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778504480; x=1779109280; 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=ZFtTLmOQAzjqHoC3Fafdx5s7yem/Cv9ClA1WpeTUDMw=; b=Mk/tRsABj0HuiJF/odMJvlaf3x1ucBMIe3m3gwjFnbKnVr5sKL2Y9UQlSVvuHpUsKS x8imm/0tlZkv79bfY1RTqWkIdcOiIw18UgSVUcnyJUx5Yd/eY+nEkN+Z8qvF+UfXVILz l0rZzgXReJIobauUYfSuuuXkUZI6ixUjnMS/DC/bLSYaawJqmvnARJXOW2cmgyTHfAu7 Ork4rheglf4OsDoFtuTfIlwMC5ByyshdMjqFH8krV8UuP2CcPJpiVicQ94ptJM7TPppH MO5QFVD8K2ab/159MI+GKccicB2Jeim372Y5P6ZMC/POilHDXCHrJDhoKb0PxBnXmZr/ aSag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778504480; x=1779109280; 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=ZFtTLmOQAzjqHoC3Fafdx5s7yem/Cv9ClA1WpeTUDMw=; b=DRqmcePnH6UnGMcS3q9OhnfrGOsfwWW39K2KnLKg5xaeFDjIMtu7KEGO5/E4OXo2su 15sxJqnkCPjGtQjbotsEmFOlCIdNOXY08jMxVdK0XQ4fgu8MTWgdxxd6rInLQO9scZmd e2iVBaUxqqZrY8t/xtz5wriHswDWTYHmrX8X68zZ/KKSF17IutkbD1g+Kcnov2mXuP+H Bkoy8LqXAS1DQOvFxtpArjibMYJwSE38uEB6r7wXmrVrbBJen8kcaAktACQVFN94+qFd p9qInnrvXtlsTbHTz8vkmU7HbRvyPRqRN/LZSu82y/7ajwPEELMioCHJdOCFVwr1o4dO mJiw== X-Forwarded-Encrypted: i=1; AFNElJ9xTa2bBh2rT9IYDU9skcihrhk3EVQN9xOn6/zjjKDNnD3Oia95OwQouQcuVSQq+SJsOxPgpEXgXlf5QLE=@vger.kernel.org X-Gm-Message-State: AOJu0YzmCIeznYbREwnY3mpn6rKFzYtiOszsgm8GDLF1BunTBa5ZGU5C /A9P4pZKvgMPBfmrx8J576JCwJaVcNTWD4rcZfWd3zqvnqhr0dxFq4PkdRF84+83+vO3aQ5bCQm N2zcJvdogGDgVgH5yWLyVEAc+K6J63JY/1O3GKxzK4vhPhotEcY3SpSXcnOgL/DbpLBc= X-Gm-Gg: Acq92OFQBNty+cA9fwy+nx/Ef/BFa4/kfYaXsI/7GtbIUZd3TDAP2dxu6Vu9Bhyy10y +ZhCWfsUPo3j8KE39pirLwpHNGRLWTY+2OS5NxuQQaeSnuq5S5c7PJTja+W8h+okspgNx0CoTkE UyNY25FKbFliBIVnyOgzApSMJeoOWLazch4qkZhfvQxam9rhH/4dk1zxhH4Y0Cy+Nnu7njY9K6b CPSkvU9nfBCkcctn6sLfeQDM9WbVV/0VebXvVXS+Ap8pedH/MXzhXsFIlT6aNYFjb7v73FyAto9 5QAfM4gCh3oQajpOw329kDDQWqfVo2U3anMoWIQmrMHNfBMuK+fGogJXmFzLXAoBlcOXbwwxoJe +z4eRRjv1TDvz98B1lr4VI+QDPIlyMyg3 X-Received: by 2002:a17:90b:3c0a:b0:367:b9ed:dec4 with SMTP id 98e67ed59e1d1-367d4a171c0mr10379146a91.27.1778504479561; Mon, 11 May 2026 06:01:19 -0700 (PDT) X-Received: by 2002:a17:90b:3c0a:b0:367:b9ed:dec4 with SMTP id 98e67ed59e1d1-367d4a171c0mr10379049a91.27.1778504478897; Mon, 11 May 2026 06:01:18 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-367d625ee39sm8246435a91.4.2026.05.11.06.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 06:01:18 -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 , 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 v5 08/16] drm/msm/a6xx: Add yield & flush helper Date: Mon, 11 May 2026 05:59:21 -0700 Message-ID: <20260511130017.96867-9-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511130017.96867-1-robin.clark@oss.qualcomm.com> References: <20260511130017.96867-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=EcL4hvmC c=1 sm=1 tr=0 ts=6a01d320 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=7a4_7rcHm0II5uOVc2AA:9 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTExMDE0NCBTYWx0ZWRfX0zAeb14lCi9U 44QC83mnyM5sLURPo6YUiyV+74oKDsGkRwjJG9Xp/WHEJ5uPPxbRAlzFhcA9AskMhZAee/FAb6x P50jAYlHYwMS787Z9yZ5HvWp2MoWBFLm2WyLrGMpY2M7r9EdNePHaQEUFd1jCZaIduy3KiZcdNu l06QnO+3qH4g+fc4eOq2/sCNTwEx3WGio/u7XNRMco/XMHpnU7kSZ8WPi/A5kCtqOVlTQrNHK44 wlpF440zt7Z4AreinAUWzmC/knzb4CeZ1LDyH0UmNcYT3oboPjm0ZpBI0rGt7lC8UZwXWSbjmf4 q5i8mSdrxV+p+D1pxNSn4Zczo/iI8/qEl5LucsWJ3xaZmn0APDbDLEsuEBkpuQBJ2pJvhP6QTKs bO5m3Ps20wNSDxFd9BGrlOOstCyf5g== X-Proofpoint-ORIG-GUID: AbY66tUHMMZ9fiGqpzZAMmr0NNZ1M8tM X-Proofpoint-GUID: AbY66tUHMMZ9fiGqpzZAMmr0NNZ1M8tM 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-11_03,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605110144 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 --- 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