Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0310A37B41B for ; Thu, 20 Aug 2026 22:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787264890; cv=none; b=FCoTaUuU5d7yc+4dpo3tabvCevrSBvKBNTH1CofaC/k/JhgJt4jkKmXBMdjfvOYlFPx8uNEj4YT6V5DIQJM4Ep7Tec9M8Ys2nuNRDpiKm/Sz08PAh0f3GDK7GLN6bxX0N7HNuWu9yoW5llSYKTOJ5ropLgDTUTueJy+66aoMsIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787264890; c=relaxed/simple; bh=Y7HDENHyWjWDZPQP9p6YHCbgfAKYo/PkAfoDqDdCea4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bnegLsIp32lYf+MESRkgpTq4UsAMKWIM8fml1j0+ZH+O37/eTW4VAYDduK40MM8ZTyvh+l8Vmxpz9KTZKWCOkJ+COqgHmpPDnjaBmjP0rYzFhjZQQbYZstMlWLfJa7MjpwDD7tb8IycEtQi48JCm/N7DSaOxN8XgT6eZXYPJuSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Db1M7pal; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Db1M7pal" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 638E71F00A3A; Thu, 20 Aug 2026 22:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787264888; bh=HGB3oEx4SzAWIvKqbaP1bnHuYbOJQaTamlPoSHgR9RQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Db1M7palrQX53gyOUCev65/MSCnMP+b1WEUn1+izXmt8/avID62gBnqMRTp0Xf1Xu KYgOFMkOP9YTHrfyjbFZCZUulFPSAHeAVm1OoAc+7BT9sYTCkJjIMRXFvpQLbTF8Ec 4DdA3CjsS742Lg1FkFaGEXptOPIbtIvJmaijrPpiXqUQCofV8X9kHpDZ8ea0pLP7ZC W5iuv9H0VpJN0JH1sm+Rdl00F7ZBJGNx/nmcwUEPtPct8pBxgwxIzWNSpmuvNLztOi Uj7elxaREBZW1a4XGr5UWqSyrHl5hmXBHbiK8N/Db8pWV9WeRW/C2iFm7fuxR3safn SJKk/kxtBaO0Q== From: Sasha Levin To: stable@vger.kernel.org Cc: Srinivas Kandagatla , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.10.y 1/3] misc: fastrpc: separate fastrpc device from channel context Date: Thu, 20 Aug 2026 18:28:04 -0400 Message-ID: <20260820222806.2320324-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026081716-dandruff-marbled-a300@gregkh> References: <2026081716-dandruff-marbled-a300@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Srinivas Kandagatla [ Upstream commit 965602eabb57d086466ad749e81941e3dd66b595 ] Currently fastrpc misc device instance is within channel context struct with a kref. So we have 2 structs with refcount, both of them managing the same channel context structure. Separate fastrpc device from channel context and by adding a dedicated fastrpc_device structure, this should clean the structures a bit and also help when adding secure device node support. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220214161002.6831-2-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 6102ceb4eab8 ("misc: fastrpc: Remove buffer from list prior to unmap operation") Signed-off-by: Sasha Levin --- drivers/misc/fastrpc.c | 46 +++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index a42be2356672d..0fd9f4196db2b 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -78,7 +78,7 @@ #define USER_PD (1) #define SENSORS_PD (2) -#define miscdev_to_cctx(d) container_of(d, struct fastrpc_channel_ctx, miscdev) +#define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev) static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp", "sdsp", "cdsp"}; @@ -212,9 +212,14 @@ struct fastrpc_channel_ctx { spinlock_t lock; struct idr ctx_idr; struct list_head users; - struct miscdevice miscdev; struct kref refcount; u64 dma_mask; + struct fastrpc_device *fdevice; +}; + +struct fastrpc_device { + struct fastrpc_channel_ctx *cctx; + struct miscdevice miscdev; }; struct fastrpc_user { @@ -1248,10 +1253,14 @@ static int fastrpc_device_release(struct inode *inode, struct file *file) static int fastrpc_device_open(struct inode *inode, struct file *filp) { - struct fastrpc_channel_ctx *cctx = miscdev_to_cctx(filp->private_data); + struct fastrpc_channel_ctx *cctx; + struct fastrpc_device *fdevice; struct fastrpc_user *fl = NULL; unsigned long flags; + fdevice = miscdev_to_fdevice(filp->private_data); + cctx = fdevice->cctx; + fl = kzalloc(sizeof(*fl), GFP_KERNEL); if (!fl) return -ENOMEM; @@ -1649,6 +1658,27 @@ static struct platform_driver fastrpc_cb_driver = { }, }; +static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ctx *cctx, + const char *domain) +{ + struct fastrpc_device *fdev; + int err; + + fdev = devm_kzalloc(dev, sizeof(*fdev), GFP_KERNEL); + if (!fdev) + return -ENOMEM; + + fdev->cctx = cctx; + fdev->miscdev.minor = MISC_DYNAMIC_MINOR; + fdev->miscdev.fops = &fastrpc_fops; + fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s", domain); + err = misc_register(&fdev->miscdev); + if (!err) + cctx->fdevice = fdev; + + return err; +} + static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) { struct device *rdev = &rpdev->dev; @@ -1678,11 +1708,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) if (!data) return -ENOMEM; - data->miscdev.minor = MISC_DYNAMIC_MINOR; - data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s", - domains[domain_id]); - data->miscdev.fops = &fastrpc_fops; - err = misc_register(&data->miscdev); + err = fastrpc_device_register(rdev, data, domains[domain_id]); if (err) { kfree(data); return err; @@ -1727,7 +1753,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) fastrpc_notify_users(user); spin_unlock_irqrestore(&cctx->lock, flags); - misc_deregister(&cctx->miscdev); + if (cctx->fdevice) + misc_deregister(&cctx->fdevice->miscdev); + of_platform_depopulate(&rpdev->dev); fastrpc_channel_ctx_put(cctx); -- 2.53.0