From patchwork Thu Jul 14 21:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 12918495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C8F3C43334 for ; Thu, 14 Jul 2022 21:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oK42YdDjGiPqrqrF6gTURbRAdD7EV3wk9diyHJGJnWg=; b=kJna06LlnBlX6w sW8TOdcDQFEiu7uc7jq6ExYvkCG72iQ+cYk8P10bb5c83tVeN+aLjhOlG2tPwoPOwg34RdHEsithv hkJ6OsK5IuaHeS0NU+OZEwV9daqq03zJLyHjctnIcEVZJTxaWzUlmG0WhyuLX4EEcLDeD3RqhtKrA yrINTfG9pBei+QLCg/OVazR5YlXkHmgHeYz4SuMxjJar8Q3f+3Xd0QM4nkuwu2Sk/QoWFIN+qSB7h v020gEuJzWpBhtAnAcy6XCMyjAX99N/FXA8RdXD5qJ7uVwPcUhwLOygBPirYpmJwjR7ejEjNT3HvM mU/yYFEO5f/l53JkhmYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oC6Qr-001ed8-LC; Thu, 14 Jul 2022 21:31:37 +0000 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oC6Pd-001e5E-B8 for linux-arm-kernel@lists.infradead.org; Thu, 14 Jul 2022 21:30:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657834221; x=1689370221; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yzAyPrU/qCIlo6Cf2CdARPBaTkg8+aYwmjRonAsM36o=; b=ul6ymNskjAz633a3v06qgs4DtC3huAAgqiHluobwqZShh58nqyDgjd1A NV5cJLIgz694md7/889wd0cBpXiliCAGdATxycaQHPuknvFrk1XO0QoDW qNyLP6vmunl51I/4j/GXJ8XkHdoXbMWL5UUwtr4UaMvDSZJgeMHLgALqf I=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 14 Jul 2022 14:30:09 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 14:30:09 -0700 Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 14 Jul 2022 14:30:08 -0700 From: Elliot Berman To: Bjorn Andersson , CC: Elliot Berman , Trilok Soni , Murali Nalajala , Srivatsa Vaddagiri , Carl van Schaik , Andy Gross , , Lorenzo Pieralisi , Sudeep Holla , "Marc Zyngier" , Rob Herring , "Krzysztof Kozlowski" , Jonathan Corbet , Will Deacon , Catalin Marinas , , Subject: [PATCH v2 09/11] gunyah: rsc_mgr: Add auxiliary devices for console Date: Thu, 14 Jul 2022 14:29:38 -0700 Message-ID: <20220714212940.2988436-10-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220714212940.2988436-1-quic_eberman@quicinc.com> References: <20220223233729.1571114-1-quic_eberman@quicinc.com> <20220714212940.2988436-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01b.na.qualcomm.com (10.46.141.250) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220714_143021_458457_88135F77 X-CRM114-Status: GOOD ( 16.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- drivers/virt/gunyah/rsc_mgr.c | 61 ++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/virt/gunyah/rsc_mgr.c b/drivers/virt/gunyah/rsc_mgr.c index b8268ee02fab..44b22cef7d44 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 gunyah_device *msgq_tx, *msgq_rx; @@ -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 * const adev_names[] = { + "console", }; static struct gh_rsc_mgr *__rsc_mgr; @@ -516,6 +528,14 @@ 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 struct gunyah_device *gh_msgq_platform_probe_direction(struct platform_device *pdev, u8 gh_type, int idx) { @@ -550,7 +570,9 @@ static struct gunyah_device *gh_msgq_platform_probe_direction(struct platform_de static int gh_rm_drv_probe(struct platform_device *pdev) { struct gh_rsc_mgr *rsc_mgr; - int ret; + struct gh_rsc_mgr_adev *rm_adev; + struct list_head *l, *n; + int ret, i; rsc_mgr = devm_kzalloc(&pdev->dev, sizeof(*rsc_mgr), GFP_KERNEL); if (!rsc_mgr) @@ -560,6 +582,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); rsc_mgr->msgq_tx = gh_msgq_platform_probe_direction(pdev, GUNYAH_DEVICE_TYPE_MSGQ_TX, 0); if (IS_ERR(rsc_mgr->msgq_tx)) @@ -576,10 +599,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 = &pdev->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: gunyah_device_remove(rsc_mgr->msgq_rx); err_msgq_tx: @@ -590,6 +641,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); + } gunyah_device_remove(rsc_mgr->msgq_tx); gunyah_device_remove(rsc_mgr->msgq_rx);