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 B70DB389455 for ; Fri, 17 Jul 2026 20:48:53 +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=1784321335; cv=none; b=riIy9vmkUV7/DhYnWCTkAD/dplbm3YmVlWP0JqNJcfCwX/6uHjNq5eI3nqsG3pD3t+BZTeAe9Dx2vZd91HzjPa9QK1V2J6o+FFaHzovPYOTOOXHIdmGhZxn0AP4ZL53nkVU2BNMtggzWDJE4/HLd/9mYc5CZrQdHSU2C1M6dxJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784321335; c=relaxed/simple; bh=/3bqSJFB87g3YyDDP7AkU7aDRmxHIev5pH2eJsJSsIE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ibE+DFsLsfHC6rnUKwUSrtzVQLNXhorDOSQ/oZdRmIjnxbGUgmQqyIruu1SvP9B7nLM10K7C1VvQoCVgE8KiNzE/3nPwTvZGNJQQSo81ocMCPWcHeZ/OposmwSvv0e26L4W24CIcXJ32R1SAo/5eCMVtIAEPPDe2W3FfUzShPMY= 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=E22jaByj; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=SzS7ACmw; 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="E22jaByj"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="SzS7ACmw" 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 66HJtHAQ3901362 for ; Fri, 17 Jul 2026 20:48:53 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=CCt/FUCHkSx E63Ah7s7mIN0CuS0Ln8VYXya9PKCt1vg=; b=E22jaByjasWkOCk0HKNaWi8ncn8 1DRpNa25wDeziZu9H9KRtnJ1///s2FpxAXj3JfXjJDgxRYQWlJrKORdbU3LEGTwc qiGvO6YS2F3MjMYvaHhTqR1B0nZ2lCYwXSwnKt/EKOYhUQTE0aH7SYcfXq3lUoph qGqMlx64rXDCsulGTHwkcGpyxtIZjaBXHZscUHYCStGCexh22jwMqmY2/LhNtik0 +bQRSf53ffUzUAVEKfNtc4j+9sXIxtU14tK3GfhMNr2FrYXUWBAKM/AOSO9wNNzq VA3Z2tYkAXv6ySiQeO4h29WZckGhCn1Qe+oU0soOa/NnjVbtJqrtptYZeXg== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ffqvf90ag-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 17 Jul 2026 20:48:53 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2cee1ec30f2so67016675ad.3 for ; Fri, 17 Jul 2026 13:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784321332; x=1784926132; 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:content-type; bh=CCt/FUCHkSxE63Ah7s7mIN0CuS0Ln8VYXya9PKCt1vg=; b=SzS7ACmwjTqTywWrgDiTFQJhphdMc6sIMWW/k47EZDFe6V1UY6bGh0ppMVfScvtJ6O QzCcR3kN2ZBDg9ZCJUWUSYzpSDMxZLn4snIYavrNpi+/ikjcUNMG+9zz/VqeQTj09FoX fv8Iu/1BCMQh82SMDzSHStoMcp45KHYFJ5jSDNZonKyVWTbsgHLA2itfojxKlc/alMHu U/qYBdvgE+5ltiqbvygraPwFRnIluZO1hdO9Wl7eIQRlev1Hlo+7rqChY+ZWk4NOuEJG Hw3cJ9p8PoMVaoKJT49uUFMHowlOjryiL9Ovk7EQ107vKqe0fl7ytxQXXHJgwUFA6FiD MAiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784321332; x=1784926132; 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:content-type; bh=CCt/FUCHkSxE63Ah7s7mIN0CuS0Ln8VYXya9PKCt1vg=; b=PsAxo93qFiEakByODftPp7+jEX4IoBeuryF7TXJ6b4lfEf9IlJ1IuPN9WXb6celn+K fwpeLf+VQ1zIwVxUoaQxhx6A9MzihwcofXsL0gEK2VhtEGg/mxZcdv+EUvSH3w5Ii+zb QIhW6rq1OOJLi4B3YfDZxt5qI3ctpps6Qx6tQkw6OpFYWRHyCft4Cy7Q5wZNSkEMlz+u QOK4gPa+k9FpKC7yXTCJobr9HGfQwbVCrsoKiXPed+ISXAR0HivBzHxoMlV3k7MWW4aQ FB/rapD8IrFmvENGWXC/5gQLC8Yc84E2VOYDy7b0bpUERUBnfkFOERHexGM7pO/fkfzn hXTQ== X-Forwarded-Encrypted: i=1; AHgh+RokfmXPPY0S5uBLVYn5OH5uM9CDsuW3ZVnf7kkqXRosgMlkCy6/sZVm0OODnOwLtEbJOglSCbInPPTLpxo=@vger.kernel.org X-Gm-Message-State: AOJu0YwZuO1tOEO9BadUsvKKIWS1UN77ugJlUBMesooub5iHmGh5VuaM cd1yXc/e9GrcoxR1jvb8Wh/RW9qCsAEEPdauB9jFl4pkEAo6hQUMoTJ7W5qeRueZMEA1HNugDnn LNyb/vMa2RRKWNITitCM+WHTXeUGnJF+uZ5UoKzz69Rn33oI94qNw4fsSzVMDAvCETWk= X-Gm-Gg: AfdE7cl/J/ztXFv2sr7xDy51yV56hD0Cx9aqL7Er8O2IuDuVkg8c4VEMIFpaSGkUMWC czKcsDspacFayHQVvC19a2bEtWd8RItv1Ri/kPJaBBQIZFqc72RCipFVGY+bvhvCnJepZfcBGbA pJnuMFPHhFJ7JOqbKVVwzKkN52snhzELysdRpUedb92PsMgogjC/2qCpDU93JYs0uR/7ZZShy8c cnnDYJBafdisbfBUaCzztMUiZexYX7iSpi0SsU8jfhGW+NhokSZc7q925y54x4II3en+Z+XiDTh fEo2c0UKoIfVAMJWpZPykOQe0IUv+7bqni+JMcq1Mw9n9OHnTZPgtzuc2UpWi2wxH5XCQID79lM AvzUh1Y4vrp0fGXM2p5DNg8pG4lM6MYDMaSpUQuGqKp+egtU= X-Received: by 2002:a17:903:324e:b0:2ca:6514:9201 with SMTP id d9443c01a7336-2cf3486f1ffmr48129495ad.15.1784321332361; Fri, 17 Jul 2026 13:48:52 -0700 (PDT) X-Received: by 2002:a17:903:324e:b0:2ca:6514:9201 with SMTP id d9443c01a7336-2cf3486f1ffmr48129295ad.15.1784321331921; Fri, 17 Jul 2026 13:48:51 -0700 (PDT) Received: from localhost (c-73-37-105-206.hsd1.or.comcast.net. [73.37.105.206]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf34713fe1sm16812945ad.55.2026.07.17.13.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 13:48:51 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Konrad Dybcio , Akhil P Oommen , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 02/16] drm/msm: Rework queuelock Date: Fri, 17 Jul 2026 13:48:18 -0700 Message-ID: <20260717204841.26120-3-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260717204841.26120-1-robin.clark@oss.qualcomm.com> References: <20260717204841.26120-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-Proofpoint-GUID: _C4QL7_PUkvQE82WYwD5r8gCXmFvSsEs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDIxNCBTYWx0ZWRfX5lfxFq1q8NhP 3EvAu7ZpEBI1oMN6ZNk6pKAsfGL1T0m+niAn1X/ieeaP5Q9z1+HEPrWMheKTge3ANfDmLRgoKdb PTjCCXfI+ondwSCTp15jGXEBfwQ48KgRegHiR88P56q4cGKnlb6Y6QqO5UTsYGZJaOXAKmw13NG WnPMLxbJ0Bw4DK9CnoTnUyt+WuXKG3jS0+1E2KtnlSE04gLfH7TCVMs1hua0b0vjslyq4UDi3mw +X0bLR+c3Iu8dKIdbs4UfX/bQR2kg/jCyVs2qkXCutGyUHa6kotLJdU4rDdAa6xLIYUDMTrf31g v8VT5Kc8i3R+bQhuk/M07vtfizG6pFqDWDx6RHKaXONE7XPERdd5R6IFyqKS87q1g/joZ61ASGl kpKTxwjVzezQM1wtcxXntstHp7Cm2YG5aTV9UzWNHDbCGH5oOVFFJWyIMnUJ3kFTzk4NkJIDwbf p/5Y2eBb1ccc739XygA== X-Proofpoint-ORIG-GUID: _C4QL7_PUkvQE82WYwD5r8gCXmFvSsEs X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDIxNCBTYWx0ZWRfX0l5bXd+QEYh9 0pmyYVQ75l3I2F9ismjhXtwI5nDK9DP0qmMMIFRRE3CYBuyGRK8dJYI/BQkYwx5yQ0X19g4PLIC 3eEXQt+EjOP/M9ERbV40Mzsh4khvJSQ= X-Authority-Analysis: v=2.4 cv=OPMXGyaB c=1 sm=1 tr=0 ts=6a5a9535 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=19Wyn7e3V/0aNffMjNCMQw==:17 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=2F56w5eUDQPWH_qpgLoA:9 a=0bXxn9q0MV6snEgNplNhOjQmxlI=:19 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_06,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 bulkscore=0 suspectscore=0 adultscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170214 Rename to ctxlock, and use cleanup guards to manage releasing the lock. This will let us re-use it for other per-context read/write serial- ization, such as VM creation. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 4 ++-- drivers/gpu/drm/msm/msm_submitqueue.c | 14 +++----------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index ec88155e0ed7..384f32f4d0c2 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -251,7 +251,7 @@ static int context_init(struct drm_device *dev, struct drm_file *file) return -ENOMEM; INIT_LIST_HEAD(&ctx->submitqueues); - rwlock_init(&ctx->queuelock); + init_rwsem(&ctx->ctxlock); kref_init(&ctx->ref); msm_submitqueue_init(dev, ctx); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 6c83b8cbbb90..d27d54bdb7a7 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -392,8 +392,8 @@ msm_gpu_sysprof_no_ifpc(struct msm_gpu *gpu) * struct msm_context - per-drm_file context */ struct msm_context { - /** @queuelock: synchronizes access to submitqueues list */ - rwlock_t queuelock; + /** @ctxlock: synchronizes access to submitqueues list, etc */ + struct rw_semaphore ctxlock; /** @submitqueues: list of &msm_gpu_submitqueue created by userspace */ struct list_head submitqueues; /** diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c index 1a5a77b28016..8b5980d5a6a7 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -93,18 +93,15 @@ struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_context *ctx, if (!ctx) return NULL; - read_lock(&ctx->queuelock); + guard(rwsem_read)(&ctx->ctxlock); list_for_each_entry(entry, &ctx->submitqueues, node) { if (entry->id == id) { kref_get(&entry->ref); - read_unlock(&ctx->queuelock); - return entry; } } - read_unlock(&ctx->queuelock); return NULL; } @@ -237,7 +234,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_context *ctx, return ret; } - write_lock(&ctx->queuelock); + guard(rwsem_write)(&ctx->ctxlock); queue->ctx = msm_context_get(ctx); queue->id = ctx->queueid++; @@ -251,8 +248,6 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_context *ctx, list_add_tail(&queue->node, &ctx->submitqueues); - write_unlock(&ctx->queuelock); - return 0; } @@ -335,19 +330,16 @@ int msm_submitqueue_remove(struct msm_context *ctx, u32 id) if (!id) return -ENOENT; - write_lock(&ctx->queuelock); + guard(rwsem_write)(&ctx->ctxlock); list_for_each_entry(entry, &ctx->submitqueues, node) { if (entry->id == id) { list_del(&entry->node); - write_unlock(&ctx->queuelock); - msm_submitqueue_put(entry); return 0; } } - write_unlock(&ctx->queuelock); return -ENOENT; } -- 2.55.0