lkml.org 
[lkml]   [2022]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 09/11] gunyah: rsc_mgr: Add auxiliary devices for console
    Date
    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
    \
     
     \ /
      Last update: 2022-02-24 00:39    [W:4.783 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site