All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elliot Berman <quic_eberman@quicinc.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	<linux-kernel@vger.kernel.org>
Cc: Elliot Berman <quic_eberman@quicinc.com>,
	Trilok Soni <quic_tsoni@quicinc.com>,
	Murali Nalajala <quic_mnalajala@quicinc.com>,
	Srivatsa Vaddagiri <quic_svaddagiri@quicinc.com>,
	Carl van Schaik <quic_cvanscha@quicinc.com>,
	Andy Gross <agross@kernel.org>, <linux-arm-msm@vger.kernel.org>
Subject: [PATCH 09/11] gunyah: rsc_mgr: Add auxiliary devices for console
Date: Wed, 23 Feb 2022 15:37:27 -0800	[thread overview]
Message-ID: <20220223233729.1571114-10-quic_eberman@quicinc.com> (raw)
In-Reply-To: <20220223233729.1571114-1-quic_eberman@quicinc.com>

Gunyah resource manager exposes a concrete functionalities which
complicate a single resource manager driver. Use auxiliary bus
to help split high level functions for the resource manager and keep the
primary resource manager driver focused on the RPC with RM itself.
Delegate Resource Manager's console functionality to the auxiliary bus.

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 drivers/virt/gunyah/rsc_mgr.c | 58 +++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/drivers/virt/gunyah/rsc_mgr.c b/drivers/virt/gunyah/rsc_mgr.c
index c8c4e1617566..9ca63053dd38 100644
--- a/drivers/virt/gunyah/rsc_mgr.c
+++ b/drivers/virt/gunyah/rsc_mgr.c
@@ -91,6 +91,11 @@ struct gh_rm_notif_complete {
 	struct work_struct work;
 };
 
+struct gh_rsc_mgr_adev {
+	struct auxiliary_device adev;
+	struct list_head list;
+};
+
 struct gh_rsc_mgr {
 	struct task_struct *recv_task;
 	struct gh_msgq_platform_host msgq;
@@ -99,6 +104,13 @@ struct gh_rsc_mgr {
 	struct mutex call_idr_lock;
 
 	struct mutex send_lock;
+
+	struct list_head adevs;
+};
+
+/* List of auxiliary devices which resource manager creates */
+static const char *adev_names[] = {
+	"console",
 };
 
 static struct gh_rsc_mgr *__rsc_mgr;
@@ -499,10 +511,19 @@ int gh_rm_unregister_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(gh_rm_unregister_notifier);
 
+static void gh_rm_adev_release(struct device *dev)
+{
+	struct gh_rsc_mgr_adev *rm_adev = container_of(dev, struct gh_rsc_mgr_adev, adev.dev);
+
+	list_del(&rm_adev->list);
+	kfree(rm_adev);
+}
+
 static int gh_rm_drv_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct gh_rsc_mgr *rsc_mgr;
+	struct gh_rsc_mgr_adev *rm_adev;
 	struct list_head *l, *n;
 	int ret, i;
 
@@ -514,6 +535,7 @@ static int gh_rm_drv_probe(struct platform_device *pdev)
 	mutex_init(&rsc_mgr->call_idr_lock);
 	idr_init(&rsc_mgr->call_idr);
 	mutex_init(&rsc_mgr->send_lock);
+	INIT_LIST_HEAD(&rsc_mgr->adevs);
 
 	ret = gh_msgq_platform_host_attach(pdev, &rsc_mgr->msgq);
 	if (ret)
@@ -530,10 +552,38 @@ static int gh_rm_drv_probe(struct platform_device *pdev)
 		goto err_msgq;
 	}
 
+	for (i = 0; i < ARRAY_SIZE(adev_names); i++) {
+		rm_adev = kzalloc(sizeof(*rm_adev), GFP_KERNEL);
+
+		rm_adev->adev.dev.parent = dev;
+		rm_adev->adev.dev.release = gh_rm_adev_release;
+		rm_adev->adev.name = adev_names[i];
+		ret = auxiliary_device_init(&rm_adev->adev);
+		if (ret) {
+			kfree(rm_adev);
+			goto err_adevs;
+		}
+
+		list_add(&rm_adev->list, &rsc_mgr->adevs);
+
+		ret = auxiliary_device_add(&rm_adev->adev);
+		if (ret) {
+			auxiliary_device_uninit(&rm_adev->adev);
+			goto err_adevs;
+		}
+	}
+
 	__rsc_mgr = rsc_mgr;
 
 	return 0;
 
+err_adevs:
+	list_for_each_safe(l, n, &rsc_mgr->adevs) {
+		rm_adev = container_of(l, struct gh_rsc_mgr_adev, list);
+		auxiliary_device_delete(&rm_adev->adev);
+		auxiliary_device_uninit(&rm_adev->adev);
+	}
+
 err_msgq:
 	gh_msgq_platform_host_unattach(&rsc_mgr->msgq);
 	return ret;
@@ -542,6 +592,14 @@ static int gh_rm_drv_probe(struct platform_device *pdev)
 static int gh_rm_drv_remove(struct platform_device *pdev)
 {
 	struct gh_rsc_mgr *rsc_mgr = platform_get_drvdata(pdev);
+	struct gh_rsc_mgr_adev *rm_adev;
+	struct list_head *l, *n;
+
+	list_for_each_safe(l, n, &rsc_mgr->adevs) {
+		rm_adev = container_of(l, struct gh_rsc_mgr_adev, list);
+		auxiliary_device_delete(&rm_adev->adev);
+		auxiliary_device_uninit(&rm_adev->adev);
+	}
 
 	gh_msgq_platform_host_unattach(&rsc_mgr->msgq);
 
-- 
2.25.1


  parent reply	other threads:[~2022-02-23 23:38 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 23:37 [PATCH 00/11] Gunyah Hypervisor drivers Elliot Berman
2022-02-23 23:37 ` [PATCH 01/11] docs: gunyah: Introduce Gunyah Hypervisor Elliot Berman
2022-02-23 23:37 ` [PATCH 02/11] dt-bindings: Add binding for gunyah hypervisor Elliot Berman
2022-02-25 20:01   ` Rob Herring
2022-03-02 23:53     ` Elliot Berman
2022-02-23 23:37 ` [PATCH 03/11] arm64: gunyah: Add Gunyah hypercalls ABI Elliot Berman
2022-02-23 23:37   ` Elliot Berman
2022-02-24 10:10   ` Mark Rutland
2022-02-24 10:10     ` Mark Rutland
2022-02-24 10:26     ` Marc Zyngier
2022-02-24 10:26       ` Marc Zyngier
2022-04-13 17:09       ` Elliot Berman
2022-04-13 17:09         ` Elliot Berman
2022-02-23 23:37 ` [PATCH 04/11] gunyah: Common types and error codes for Gunyah hypercalls Elliot Berman
2022-02-23 23:37 ` [PATCH 05/11] virt: gunyah: Add sysfs nodes Elliot Berman
2022-02-23 23:37 ` [PATCH 06/11] virt: gunyah: Add capabilities bus and devices Elliot Berman
2022-02-23 23:37 ` [PATCH 07/11] gunyah: msgq: Add Gunyah message queues Elliot Berman
2022-02-23 23:37 ` [PATCH 08/11] gunyah: rsc_mgr: Add resource manager RPC core Elliot Berman
2022-02-23 23:37 ` Elliot Berman [this message]
2022-02-23 23:37 ` [PATCH 10/11] gunyah: rsc_mgr: Add RPC for console services Elliot Berman
2022-02-23 23:37 ` [PATCH 11/11] gunyah: Add tty console driver for RM Console Serivces Elliot Berman
2022-07-14 21:29 ` [PATCH v2 00/11] Gunyah Hypervisor drivers Elliot Berman
2022-07-14 21:29   ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 01/11] docs: gunyah: Introduce Gunyah Hypervisor Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 02/11] dt-bindings: Add binding for gunyah hypervisor Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 03/11] arm64: gunyah: Add Gunyah hypercalls ABI Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 04/11] gunyah: Common types and error codes for Gunyah hypercalls Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 05/11] virt: gunyah: Add sysfs nodes Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 22:41     ` Randy Dunlap
2022-07-14 22:41       ` Randy Dunlap
2022-07-14 21:29   ` [PATCH v2 06/11] virt: gunyah: Add capabilities bus and devices Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 07/11] gunyah: msgq: Add Gunyah message queues Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 08/11] gunyah: rsc_mgr: Add resource manager RPC core Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 09/11] gunyah: rsc_mgr: Add auxiliary devices for console Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 10/11] gunyah: rsc_mgr: Add RPC for console services Elliot Berman
2022-07-14 21:29     ` Elliot Berman
2022-07-14 21:29   ` [PATCH v2 11/11] gunyah: Add tty console driver for RM Console Serivces Elliot Berman
2022-07-14 21:29     ` Elliot Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220223233729.1571114-10-quic_eberman@quicinc.com \
    --to=quic_eberman@quicinc.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_cvanscha@quicinc.com \
    --cc=quic_mnalajala@quicinc.com \
    --cc=quic_svaddagiri@quicinc.com \
    --cc=quic_tsoni@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.