From nobody Mon Feb 9 17:35:08 2026 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 F15D82F25F0 for ; Tue, 30 Dec 2025 06:28:45 +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=1767076127; cv=none; b=b8BtZKRM62ihHcAfiS13p9oryYVuonNJzmAUhAPXDCKEfqXoyjHBNmRPB2a+OTgCSYXOt2sVZU1cMhKzyI3VHi++8ovVZC58rCa63wHC4kjsblR7Q0qNaBOLYpqCw3Ugb1ynf6kJDhH2IITGTt5PSsErxPxpIfhJNGpjj2Y4zRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767076127; c=relaxed/simple; bh=MHn+V6TRZoHpB/IKHPrGSV0ycKamLtaH9inFw5f2g5Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lIr7PHmCv6Z1o9dClFmxDR0tJ0+X4mzWaQnfspJpo7SsumBgF8ZHivlfted7elEiE65mYgA7ZyBpq8RCLnfTdDnlpuyKVIr67icR1TdU433CF7wDjdxAP50/w70Xu96iwwElM7wrimFPJaa3EPZHi46DVPi/IkhXFUe15jg3do8= 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=o10Q6H+t; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=W/xDKhuE; 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="o10Q6H+t"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="W/xDKhuE" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BU0kdsh2674102 for ; Tue, 30 Dec 2025 06:28:44 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=44twYS2j8pu ef9SPj0m2ACmUVD52vfoicRaqJwTY5UY=; b=o10Q6H+tj4bFnL3VN+7vryazyuG DuLLblP/BNHZaUg5h4ItaM8YksQLg+POH5mcaFtbahNvfW7dsEJJZkC+3X+ihsDH UDBHjJelunByqbUJY6rfnL9kdhcEnkOHFBeZJLTMf3rSfsL4NdoTIB4HYGcaZKy+ fL6LsFBxk++S9rf4b73kMAmlrbgsQIzBuZKqORU2dYWKGHctsQ+yYKcDevA6phfK XLCWwRj9/niTRTXq/LkK7okPUF+1bV+vYT6z9h5NBKDqjv9UWppC8hVT7AIhEhdW AtE/9miuioWRjLRZkGjPrXeuIOet1FO16iisfi8es5qXenByC9ozLlu/gRw== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bc4fcrmbd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 30 Dec 2025 06:28:44 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-b5edecdf94eso16459782a12.2 for ; Mon, 29 Dec 2025 22:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1767076124; x=1767680924; 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=44twYS2j8puef9SPj0m2ACmUVD52vfoicRaqJwTY5UY=; b=W/xDKhuEGPxVB8UCva6dz51BtdK7O8sp7nEwJPLBNweauJXWPJnOI9e2fx+JKfj7GH qQkOJwaU2GHQO3m0XoGtYe/Nakv8JHayyP8EyWiaLFJTRJsGMVo1ZV0pJNV9UYoHYN5A 97CBxImQPKZeHAGc53DXoFOpThv9NjcadqcHAYjb+FG4CqLWM0PnCin934X23kKDET8P 5AoiIpKpwCY3URaWs301xtYKyiXJXHyg6VFCcMl7f3hGjOoxL5PlogiONsrEbqIfszoj wA5qeLmDDOjdgekYlwyNWd4xJaAn/vVsxyMb8sGIFL8h2WdXPkQfm73aSv0jZLe/TVMz snOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767076124; x=1767680924; 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=44twYS2j8puef9SPj0m2ACmUVD52vfoicRaqJwTY5UY=; b=qqQasi9CnvII9GCqBpNBHwdyncGru0x3fVTq0hKV5ZQZZemnCzxmfY8RLkN6fYmmAI Q589rRZiqIoXWDuLywP693OXgddIavIRq9eCGHzbuyPwn8s0vZJec0i/cR6ztOGzyGSA HaZvz3h7WOG2rS1jb0Mtacus/umN9SUaFSNb4EHimKMP1s4RwUQfnQr69Vpwu8th1Mgz Zt5YmYUlqUyfuPoSIsTQuVwLV/yRuPRehtt1lCAcyhTSjiv4qd9M70CvuFJQVPPPw744 cUryizApyTZFBmq7xZuf7xeJw2LC7zxR03FDdwofi4lU24i2LHwmTUFRs1A06pZcCGLb d/HQ== X-Forwarded-Encrypted: i=1; AJvYcCWisachKieLnV/XnHb2FRrmhGrLQPrq9R7BtU1ga8ggSRbFGFCY9nizAAfvhFfbYJx6+SoF246melZ3PRA=@vger.kernel.org X-Gm-Message-State: AOJu0YzXS4Nbxg5LOpltEL0ndJglN3i9XvbnmmN+PknE9Cgs0jh7C/ED /W2kFDXg7h0qdLfztidPheqJvrXxQ+Zu4wRRQHmmyae2/vJXpHC+ttlSK13jPutpGiRQgITifEz oqHY66NzDg7PKcXaCDm8bLmmF6iQW70q4KwT4VPQgBxUbBj8LQOAQ7KaAw55KnU0cLd4= X-Gm-Gg: AY/fxX55iOToEOgq4fWj6zCZsNRZXxV8Te8WrZwCrRBzpsLc/brO0giOU7b6GJEvy0w ck1iRADTI1jHFvf0d15txTD0KEbSy1UnofwWvIPdAU947aQSE2WY3ebA4u2zVydnvY1T6zF7biR lL/kCOsuBl8tyfnV6onaZSNo/fggbV1NPEawXco5jRNXrDpr0shc2UqgJibMKNex8vUeYwZzmfv 049915rjafADsoRy5RvvuvAfOMXVzYdQtZPykwhFjYRJMhFVosIkO2sUk2Ceu4tdCuVXopX8qYd 4nwc0eTis12qO9h4dupLnm/mbnR3tEADLqlGCRYRMO8I18mJfTtCZfVRQ5l9H/3DC1lZL6N9l4E LeNXKNz+a8hnsQsmlgl5ORww1q/CjO50hQTMAULO8ug== X-Received: by 2002:a05:6a20:4325:b0:34f:afaa:125b with SMTP id adf61e73a8af0-376a94cb491mr31113752637.50.1767076123571; Mon, 29 Dec 2025 22:28:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGa7a36ash2kDsGeHNgvuyMuFBc2a3MlePVxdjQtL2BMh0tEoB3pf2il6edj9DeU0uuo4hGVg== X-Received: by 2002:a05:6a20:4325:b0:34f:afaa:125b with SMTP id adf61e73a8af0-376a94cb491mr31113731637.50.1767076123080; Mon, 29 Dec 2025 22:28:43 -0800 (PST) Received: from hu-ekangupt-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c1e7961b4d0sm26491536a12.5.2025.12.29.22.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Dec 2025 22:28:42 -0800 (PST) From: Ekansh Gupta To: srini@kernel.org, linux-arm-msm@vger.kernel.org Cc: gregkh@linuxfoundation.org, quic_bkumar@quicinc.com, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, dri-devel@lists.freedesktop.org, arnd@arndb.de, dmitry.baryshkov@oss.qualcomm.com, konrad.dybcio@oss.qualcomm.com Subject: [PATCH v5 2/4] misc: fastrpc: Replace hardcoded ctxid mask with GENMASK Date: Tue, 30 Dec 2025 11:58:29 +0530 Message-Id: <20251230062831.1195116-3-ekansh.gupta@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251230062831.1195116-1-ekansh.gupta@oss.qualcomm.com> References: <20251230062831.1195116-1-ekansh.gupta@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: quoted-printable X-Proofpoint-GUID: fY6RXO0IAfz8fxeZETUv3oHoyKbZIhVC X-Proofpoint-ORIG-GUID: fY6RXO0IAfz8fxeZETUv3oHoyKbZIhVC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjMwMDA1NyBTYWx0ZWRfX8E3+SBsmdYD6 zMolpVNVCRaTpRGmeL3oOMygWq6rXsLfUlN7dEN5D/RXG3K3t8zdjQOmg2eofaryMMic43m4fTO C3zCd49HMMmryXtm1jKca/2ZffrkutpV24RdQDJMKEc1fFrswreDu+R0XTXqr9sTvV/2ZAnlsKH pERn78lYiqxMW6ZlzO9JpHp4lYt/DV9B7DqxM10iRbFwJHVKZC8VvdBbHbP8kVM9gyf04o2aOvn y5uV1rCJ1yGjcPA4WJLtWPTG3+TSDhLlDMqPuuz3rK9iWIcixO1PqVY+irDD4bPllmrwRjEn2Ve JSsh/6nPsfq559rt5XK29buDJFSq2tbh/CU1cdNd+UfzFJm0cGlCDFAb9ruFHexXPyI37UZKSAH 9ubSytyDFUe9N+owhy+jooYoDNntbHO2tvViarz8VAZG8BU1J4iwWySrznC+ILcvKDP2hbSEYQR 39sTfW1y++MHdv5lGPQ== X-Authority-Analysis: v=2.4 cv=foHRpV4f c=1 sm=1 tr=0 ts=6953711c cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=mhgHPu3uRlbtNExDwEMA:9 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-29_07,2025-12-29_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 priorityscore=1501 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512300057 Content-Type: text/plain; charset="utf-8" Replace the hardcoded context ID mask (0xFF0) with GENMASK(11, 4) to improve readability and follow kernel bitfield conventions. Use FIELD_PREP and FIELD_GET instead of manual shifts for setting and extracting ctxid values. Signed-off-by: Ekansh Gupta Reviewed-by: Konrad Dybcio --- drivers/misc/fastrpc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 679cd8997a00..f7fb44a8e9c0 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 #define ADSP_DOMAIN_ID (0) #define MDSP_DOMAIN_ID (1) @@ -37,7 +38,7 @@ #define FASTRPC_CTX_MAX (256) #define FASTRPC_INIT_HANDLE 1 #define FASTRPC_DSP_UTILITIES_HANDLE 2 -#define FASTRPC_CTXID_MASK (0xFF0) +#define FASTRPC_CTXID_MASK GENMASK(11, 4) #define INIT_FILELEN_MAX (2 * 1024 * 1024) #define INIT_FILE_NAMELEN_MAX (128) #define FASTRPC_DEVICE_NAME "fastrpc" @@ -489,7 +490,7 @@ static void fastrpc_context_free(struct kref *ref) fastrpc_buf_free(ctx->buf); =20 spin_lock_irqsave(&cctx->lock, flags); - idr_remove(&cctx->ctx_idr, ctx->ctxid >> 4); + idr_remove(&cctx->ctx_idr, FIELD_GET(FASTRPC_CTXID_MASK, ctx->ctxid)); spin_unlock_irqrestore(&cctx->lock, flags); =20 kfree(ctx->maps); @@ -625,7 +626,7 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc( spin_unlock_irqrestore(&cctx->lock, flags); goto err_idr; } - ctx->ctxid =3D ret << 4; + ctx->ctxid =3D FIELD_PREP(FASTRPC_CTXID_MASK, ret); spin_unlock_irqrestore(&cctx->lock, flags); =20 kref_init(&ctx->refcount); @@ -2451,7 +2452,7 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device= *rpdev, void *data, if (len < sizeof(*rsp)) return -EINVAL; =20 - ctxid =3D ((rsp->ctx & FASTRPC_CTXID_MASK) >> 4); + ctxid =3D FIELD_GET(FASTRPC_CTXID_MASK, rsp->ctx); =20 spin_lock_irqsave(&cctx->lock, flags); ctx =3D idr_find(&cctx->ctx_idr, ctxid); --=20 2.34.1