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 2CCC83F23BD for ; Fri, 9 Oct 2026 06:02:55 +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=1791525776; cv=none; b=UkEKypnXpiWQKDZCetdH6n1NxskjQU6M6f1oFId3Ri189wl9LTCaTNmBci68RVVqFKmc5+ZTsXm8X+OmMHux1Kh+096nOvNa5pDWom6OmMdneBXe4GqghcnOL4UV5sMv5MhspWlb1sse5IvDjCKjLsqA+ZUCh//AcSEPTOl9/JA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791525776; c=relaxed/simple; bh=efqX0GVifKhOJlqEZ0k0bv+5jab29GzGjSyFqiVIdt0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=J6bAbJyllpbf/b4h537Qi5PJoVVvBcXXfo5lI3JeKuRjrzs4DP+WLmw+SS97NkAblJ9L85nz3MIsyr0fN0gt+JGRSKEo24nQbomsYGTvu2wkjaDSjQrsRnMAwRML+l7XhHqg7iLrSeupO2bCo9WJ7t3MG1ypFfKtgkTjylknFlg= 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=DLekEbqk; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=gtu4T5rV; 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="DLekEbqk"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="gtu4T5rV" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6993H8ZM3942582 for ; Fri, 9 Oct 2026 06:02:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 60YgA86+GQN4v5pv9VjFhYCGaZUcpH9rkoEgoxf9GQ0=; b=DLekEbqkJHfJZ10D IaeOnTjDOI8/ia+dW1xRDP8KnNjo0oJeAKBnPMbfqY33/OUahRS8Ks8OnZMsSYyC Z1Be77kFvxKuenI+Ah2o6ST20sjPfS1e3qBrA5ejAcjG3zvrvyWCuV5E2DLFknX0 IbEY4YqKf85vzB3UeESRfMO6fvhbjWBMMKEPWmRwoDSXcCmq7QgKxeFp7gqjB39t ZJr9hcdxBZ64P4XHEiaT4AEVlw1OofutSsmMvGEs7vGiGMTbKuSgaLGReCsR50Ok 2G1TRoSSYKS0xyHqDLY9cisvi2Y2ao/J6e0gkIOEDNGJk/h7F2X4QpoREpGnQgef tf8X4A== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4h6fxk265w-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 09 Oct 2026 06:02:54 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2e2d4a8623bso58462205ad.1 for ; Thu, 08 Oct 2026 23:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1791525773; x=1792130573; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=60YgA86+GQN4v5pv9VjFhYCGaZUcpH9rkoEgoxf9GQ0=; b=gtu4T5rVqTNvsCTIiHdMP9+hnlg/etuliGecu97X+1pnXvkUHy14npihPXcm72KI+p uNRYBjC/THeaW3oDnUgBcy0qy65D2Pe+RAjgW2/rCJuyYCSXMysgL8sHuNjV/YywoOTb 7NTgG0AGo7u+4jgHUfV/jL/XI8UvlbCJ4ieoSU8AmxofGM1Wlx7icZ5b0KjK1uwCsTaK wIxv/7fMLyhReicMPMJTKEbhWftuj30mdUOfLkQV0IokklJgkwFOhXs079Fn/nyzwiwc FbnV7CWyx/EsDyz/2sFFzCd8LxONdkudZjNne38bN29H+GxMHtCuKWDRyXd2Gje6f/Cl 20rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791525773; x=1792130573; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=60YgA86+GQN4v5pv9VjFhYCGaZUcpH9rkoEgoxf9GQ0=; b=IKvUhY3RH+PZ0KICQwnLO/92pzbBPFaT0uMzS5FqYMcVNW17cTxjzi5njl5lgUJ9wh 9anb+/yXh4hGk7LOVu40hSOurBIMTBWttxbZQ2fUp5TexkdJIrGbExm28larNgmbXcgL sWXK8JNXhEyFEmf9mymBOFObby+UE3XgOHmgpv6fr6krgky4I6rvNpvVg9ydCc6u6Bzp VinM2q44OhjdoXbw2V++mww/GuPaqqM9d7xiE63opmCMBHFyZMQOiEo5NexjIcK7xHFN XMsrAEObQji3k4GIoSyaovaCoVJRrCbmRCsGHFweJs0pqJcy5j1T3xD96nX1AGtmKgoG JGNg== X-Forwarded-Encrypted: i=1; AKwUvBwXkZTzAAlSBpcLS0+QSMWKkw1gjTAgCYBtpO/aU0X8OxYZci7MjEsHjvL5CTa0gtj+GpmEuL5X6pJW@vger.kernel.org X-Gm-Message-State: AFq9FYJYt1F8DaSp7EsANeIeHrWesSFrV2FoaWqMf6gj6tGp38ZNewtx j3hFv7a95dhhcvf+s+eGBMetJ5NnjWZYont1FBhalsJn5eDi2jeFzlZn6BQWKMZASLtbOabbLkt 68wcQ3SmcoxRhfonJcWvtH/5DqcZiHkSRiJX8mzjQhPSRGIIKvjD+GookUNH4Wrzn8ZqpXRVtXd w= X-Gm-Gg: AYBFou3UYtX/AtPunrGNPCgUvX+/bGFzj/SwpLxQmgRtpYXHi3Y8uy57rOgvng7sjGx dKHedOU7xIBXEEXfUjSdx1aJ0JSQAJoIl/hG4InA4nEVptY1gU7tGqhzsIIouMAE9c4Uoi2s3Yu uz9TJ/tbZAQWgb/RYh99Z0kNv0IfmOuSMYNZvxgCM8GaHJeeKW426FnsfxMCIsDhPjFKdBiGFDw 5ik8QRYDIVTGLF+DNIAX4rAknTABLvBSb9HmM/DVkwZOmY3/LFEbAsHnlx9wV4u1YdmiME87gCh csQxSvAkElH9q/X2gS6T1g87g+Bk2v5RVg1MhVGgnXOgWi7+cgU1wn/S01SC82oTBmmYEDdDaLd VAyWrhreQ+YbVmumFD5d1YsRS/996 X-Received: by 2002:a17:90b:2ccb:b0:3ab:1af3:a0d with SMTP id 98e67ed59e1d1-3ab3ac63ba3mr904205a91.33.1791525773274; Thu, 08 Oct 2026 23:02:53 -0700 (PDT) X-Received: by 2002:a17:90b:2ccb:b0:3ab:1af3:a0d with SMTP id 98e67ed59e1d1-3ab3ac63ba3mr904180a91.33.1791525772712; Thu, 08 Oct 2026 23:02:52 -0700 (PDT) Received: from [10.219.57.162] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ab38f2f866sm2466686a91.10.2026.10.08.23.02.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Oct 2026 23:02:52 -0700 (PDT) Message-ID: Date: Fri, 9 Oct 2026 11:32:46 +0530 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/3] misc: fastrpc: iterate CB nodes manually instead of of_platform_populate To: Vinayak Katoch , Srinivas Kandagatla , Amol Maheshwari , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Bharath Kumar , Chenna Kesava Raju , devicetree@vger.kernel.org References: <20260923-dup-sessions-v5-0-e953133a1827@oss.qualcomm.com> <20260923-dup-sessions-v5-1-e953133a1827@oss.qualcomm.com> Content-Language: en-US From: Ekansh Gupta In-Reply-To: <20260923-dup-sessions-v5-1-e953133a1827@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=fKesTpae c=1 sm=1 tr=0 ts=6ac8838e cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=SHHY10jX5hRKE-y4DCcA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-GUID: mCXD7T_WuT-NkQcCTzi0F-WHW5T1VYAx X-Proofpoint-Spam-Info: AW1haW4tMjYxMDA5MDAyMyBTYWx0ZWRfX1TbjYOWSHGU3 N3Zu4ya+JEmDNSwKCz6dFpnUNsJIO1wLtey8uD3ezCpYQ4DzxJsKuxuA5FyiTwFcFyMAa9UnXjn kbC0PjDNDD4ooMp0XlNP56bqSl4zU9s= X-Proofpoint-ORIG-GUID: mCXD7T_WuT-NkQcCTzi0F-WHW5T1VYAx X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDA5MDAyMyBTYWx0ZWRfX4n+Ko2big7mb Qp3kCZIe8Lr/XRjciafu017sCfo4511+XO7fNfZrAZWQQvNkG5eVxpX3wGFc14KeIkfGA6LNoj6 v+TvZWrnc/2VChalrYfffTcEGoGhdDRA9zRwOIEZctbYdKF7ToRzJBqrGebFqvB2q4u2j97MCM9 bfv5FrA1vrKE6nRjzdy2thl7256cl/EOi4kZV8AgQ4DmYSWATDqPsqBUxmkah/SpXnNALbfjN9S GJWAeWY11QCeU5cvRb6HovSA3lbBF29xCC/cB29eLAAHsC/1lCrwPYaYUj+2zDZFyqbAEwpDKyB h8y5l97ivaSE+XiRGku67Q5yVfkF0KMiSl8I8K7wZTGvi5RuOrKnx4jde+hL26zjkxwjFMx2F5m 1+iY0vul8vvqUGAJtIIO5EVY5DNi7mkpwcf5geAXufy8QKZtn8qrKplPIcrgLmS5GfM/BB1Vurp XWlpLFwPa5hzOjwH1ag== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-09_02,2026-10-08_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610020000 definitions=main-2610090023 On 23-09-2026 14:09, Vinayak Katoch wrote: > of_platform_populate() only guarantees that child devices are registered, > not that their probes have completed before it returns. This creates a > window where fastrpc_cb_init() may not have run for all context bank > nodes, leaving the channel context partially initialised. > > Introduce fastrpc_cb_devices_create() to iterate over child DT nodes > directly and call fastrpc_cb_init() synchronously for each > qcom,fastrpc-compute-cb node. This ensures all context banks are fully > initialised before fastrpc_rpmsg_probe() returns. > > Introduce fastrpc_cb_devices_destroy() as the symmetric counterpart. > Before destroying the CB platform devices, invalidate all sessions under > the channel lock so that any fastrpc_user still holding a reference to > the channel context cannot acquire a new session backed by a destroyed > device. > > Since fastrpc_cb_driver is no longer needed as an independent platform > driver, remove it along with its match table and remove callback. Use > module_rpmsg_driver() now that only a single driver registration remains. > > Signed-off-by: Vinayak Katoch > --- > drivers/misc/fastrpc.c | 104 ++++++++++++++++++++++++------------------------- > 1 file changed, 52 insertions(+), 52 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index af18ff1992ee..f20d3e5ecc81 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -2333,7 +2333,7 @@ static const struct file_operations fastrpc_fops = { > .compat_ioctl = fastrpc_device_ioctl, > }; > > -static int fastrpc_cb_probe(struct platform_device *pdev) > +static int fastrpc_cb_init(struct platform_device *pdev) > { > struct fastrpc_channel_ctx *cctx; > struct fastrpc_session_ctx *sess; > @@ -2355,7 +2355,7 @@ static int fastrpc_cb_probe(struct platform_device *pdev) > spin_lock_irqsave(&cctx->lock, flags); > if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) { > spin_unlock_irqrestore(&cctx->lock, flags); > - dev_err(&pdev->dev, "too many sessions\n"); > + dev_err(dev, "too many sessions\n"); > return -ENOSPC; > } > dma_bits = cctx->soc_data->dma_addr_bits_default; > @@ -2389,37 +2389,63 @@ static int fastrpc_cb_probe(struct platform_device *pdev) > return 0; > } > > -static void fastrpc_cb_remove(struct platform_device *pdev) > +static void fastrpc_cb_devices_destroy(struct rpmsg_device *rpdev) > { > - struct fastrpc_channel_ctx *cctx = dev_get_drvdata(pdev->dev.parent); > - struct fastrpc_session_ctx *sess = dev_get_drvdata(&pdev->dev); if this dev_get_drvdata() is not used, can you also remove dev_set_drvdata()?> + struct fastrpc_channel_ctx *cctx = dev_get_drvdata(&rpdev->dev); > + struct device *rdev = &rpdev->dev; > + struct platform_device *pdev; > + struct device_node *np; > unsigned long flags; > int i; > > spin_lock_irqsave(&cctx->lock, flags); > - for (i = 0; i < FASTRPC_MAX_SESSIONS; i++) { > - if (cctx->session[i].sid == sess->sid) { > - cctx->session[i].valid = false; > - cctx->sesscount--; > + for (i = 0; i < cctx->sesscount; i++) > + cctx->session[i].valid = false; > + spin_unlock_irqrestore(&cctx->lock, flags); > + > + for_each_available_child_of_node(rdev->of_node, np) { > + if (!of_device_is_compatible(np, "qcom,fastrpc-compute-cb")) { can there be any such case?> + of_node_put(np); > + continue; > } > + > + pdev = of_find_device_by_node(np); > + of_node_put(np); > + if (pdev) > + of_platform_device_destroy(&pdev->dev, NULL); > } can you check if this works here instead of above blob: device_for_each_child_reverse(rdev, NULL, of_platform_device_destroy);> - spin_unlock_irqrestore(&cctx->lock, flags); > } > > -static const struct of_device_id fastrpc_match_table[] = { > - { .compatible = "qcom,fastrpc-compute-cb" }, > - { } > -}; > +static int fastrpc_cb_devices_create(struct rpmsg_device *rpdev) > +{ > + struct device *rdev = &rpdev->dev; > + struct platform_device *pdev; > + struct device_node *np; > + int err; > > -static struct platform_driver fastrpc_cb_driver = { > - .probe = fastrpc_cb_probe, > - .remove = fastrpc_cb_remove, > - .driver = { > - .name = "qcom,fastrpc-cb", > - .of_match_table = fastrpc_match_table, > - .suppress_bind_attrs = true, > - }, > -}; > + for_each_available_child_of_node(rdev->of_node, np) { > + if (!of_device_is_compatible(np, "qcom,fastrpc-compute-cb")) { > + of_node_put(np); > + continue; > + } > + > + pdev = of_platform_device_create(np, NULL, rdev); > + if (!pdev) { > + of_node_put(np); > + fastrpc_cb_devices_destroy(rpdev); > + return -EINVAL; -ENODEV?> + } > + > + err = fastrpc_cb_init(pdev); > + if (err) { > + of_node_put(np); > + fastrpc_cb_devices_destroy(rpdev); > + return err; > + } > + } > + > + return 0; > +} > > static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ctx *cctx, > bool is_secured, const char *domain) > @@ -2639,7 +2665,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) > data->rpdev = rpdev; > dev_set_drvdata(&rpdev->dev, data); > > - err = of_platform_populate(rdev->of_node, NULL, NULL, rdev); > + err = fastrpc_cb_devices_create(rpdev); > if (err) > goto err_deregister_fdev; > > @@ -2711,7 +2737,7 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) > &cctx->remote_heap_addr, cctx->remote_heap_size, err); > } > > - of_platform_depopulate(&rpdev->dev); > + fastrpc_cb_devices_destroy(rpdev); > > fastrpc_channel_ctx_put(cctx); > } > @@ -2798,33 +2824,7 @@ static struct rpmsg_driver fastrpc_driver = { > }, > }; > > -static int fastrpc_init(void) > -{ > - int ret; > - > - ret = platform_driver_register(&fastrpc_cb_driver); > - if (ret < 0) { > - pr_err("fastrpc: failed to register cb driver\n"); > - return ret; > - } > - > - ret = register_rpmsg_driver(&fastrpc_driver); > - if (ret < 0) { > - pr_err("fastrpc: failed to register rpmsg driver\n"); > - platform_driver_unregister(&fastrpc_cb_driver); > - return ret; > - } > - > - return 0; > -} > -module_init(fastrpc_init); > - > -static void fastrpc_exit(void) > -{ > - platform_driver_unregister(&fastrpc_cb_driver); > - unregister_rpmsg_driver(&fastrpc_driver); > -} > -module_exit(fastrpc_exit); > +module_rpmsg_driver(fastrpc_driver); > > MODULE_DESCRIPTION("Qualcomm FastRPC"); > MODULE_LICENSE("GPL v2"); >