From mboxrd@z Thu Jan 1 00:00:00 1970 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 25D81C25B75 for ; Tue, 14 May 2024 14:55:04 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+cNg82rAgz3IHLeknRPeRu722j9+9f+fuU5bmh3A6Wo=; b=eASDA5/KkTIaXx IX5dMoO9IJ22EXCceMGk3MJafx5oVu6HQa+yZJZavElMTcEVOX+O2sfyvGU//1rWl1CpOnJWCGOU7 SU52eSQTWO/letB2P0C7HUdqd6WH66Tl0beVIbQBcOGu+lbSo/rmdH/sH9AXGR08SuO7ypRWJIXjk uwldTRqdZxuunXICzb2ovTgbrNeyO9anaJL3p7GGniaNjc0s9S5phsSVSr6kXGD1BSv1m64NJnzRu TTl6gFanbTD8iGtWC1MQrT2va3/2WMRZ8qWNEApBEeoyeLOOhzzFymMGaJIGP13t+L3pmE00lnVsk UyozRyoALeRa5UP/1Z3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6tYL-0000000GFJd-3dHE; Tue, 14 May 2024 14:54:53 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6tYJ-0000000GFIy-1fZG for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2024 14:54:53 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-420107286ecso195535e9.0 for ; Tue, 14 May 2024 07:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715698488; x=1716303288; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=X+RtFqCfmaA7arP0KA4LywxQdRAvLaSK767pNWRx5TM=; b=QTVOLXkuJ5rqsHrlhg7LAyjXh43HQWHClPXwzM1f9A1znMRyWBXJbCKrMMbtP1pcX2 Pl3tTEiKB4w6ZvhfY/flAcKSGNDMOSIzjciIWrGA2bL2kqavX67wE6xooWTqpQ4FEXFG IGU2Piu+tMlrSWWpqJfKJz5IRTT48jrbf86aD/n8PVXN2wblBz8mQ0YhIU6JqktP3Vbf Z/8c1CeO3W/GCwnwpfUooHJ8D4XBtIdD1gVF/mlzGq3Sw+WsJpr/ptDmWScRLbYYezB7 Y9h7LO/5d73qIrSwHgkQq3kfxZePzaTqNKytGjNCRBXSpb8Sib0lKI0C5egjV358vBe4 brFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715698488; x=1716303288; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X+RtFqCfmaA7arP0KA4LywxQdRAvLaSK767pNWRx5TM=; b=rMIc8ly96DkC4OSPGf3fEgFFpnSn8nNR7GJAK4fOjj8ir3uN5k4T3iWvMZ+nYBeGQH Ujy1EsxG1piH+CjOFe3xrX2gbRhTspLAcU1sQWwlCz7W0TJUgg2lIeDG/F1ut0ulN7q9 xg0WK5lvEkVTpd4kZVbuFSAe8PkKKnwZWsai7BgikKXORsXHBuODgeWqd5sLfXTyelYw eZXHepgpoi+qyojcEO9Le+e9xL8ma4L7BV6dIHmJ5ywFGJhiXP68WSqClnNThbwWCDpn MVp4Hpr0rbStUyhQEv7GXrWplE1EC27yFB6Y3RnRMM2d+pgBMnxJVS1wkdnL1Efe/Vcr 8IVA== X-Gm-Message-State: AOJu0YzB8Js+afKkuvi4wRnNIDDsA31bQekAIPKIqZg1bt7eLSsZhtcx +lMeRtN7BlWtvl0ntrjrf0L+1YEHp47eg4NYxEyxWXfgBYKJ3LUqGr++g4vj4g== X-Google-Smtp-Source: AGHT+IHbf1PrwbWPs8LuXfMD9Ot65kZ3P03DrvVBR82zXAWMuy3OKVgRZ0eiVpTqit/md6d4YF/ubQ== X-Received: by 2002:a05:600c:4e55:b0:41f:9dd0:7168 with SMTP id 5b1f17b1804b1-4200ee13359mr6263735e9.2.1715698488370; Tue, 14 May 2024 07:54:48 -0700 (PDT) Received: from google.com (216.131.76.34.bc.googleusercontent.com. [34.76.131.216]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4201c3f8032sm49850655e9.28.2024.05.14.07.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 07:54:48 -0700 (PDT) Date: Tue, 14 May 2024 14:54:46 +0000 From: Sebastian Ene To: Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi , Jens Wiklander Subject: Re: [PATCH 2/2] firmware: arm_ffa: Split bus and driver into distinct modules Message-ID: References: <20240510183811.3802285-1-sudeep.holla@arm.com> <20240510183811.3802285-2-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240510183811.3802285-2-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240514_075451_467149_6A016894 X-CRM114-Status: GOOD ( 31.31 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, May 10, 2024 at 07:38:11PM +0100, Sudeep Holla wrote: > Make the FF-A bus on its own as a distinct module initialized at > subsys_initcall level when builtin. > > Keep the FF-A driver core stack, together with any configured transport, > in a different module initialized as module_init level. > > FF-A drivers initialization is now changed to module_init level. > > Signed-off-by: Sudeep Holla > --- > drivers/firmware/arm_ffa/Makefile | 6 ++++-- > drivers/firmware/arm_ffa/bus.c | 22 ++++++++++++++++------ > drivers/firmware/arm_ffa/common.h | 2 -- > drivers/firmware/arm_ffa/driver.c | 12 ++---------- > 4 files changed, 22 insertions(+), 20 deletions(-) > > Hi Sebastian, > > I reworked the patch I shared with you in private to include handling of > the FF-A v1.0 workaround I had removed as a quick hack when I shared the > patch. Please check if these couple of patches help you in the initcall > order issue you were facing. > > Regards, > Sudeep Hello Sudeep, Thank for sharing the patch. I gave it a spin with pKVM and OPTee under Qemu and it works well. Having the bus driver initialize separately is a good ideea. > > diff --git a/drivers/firmware/arm_ffa/Makefile b/drivers/firmware/arm_ffa/Makefile > index 9d9f37523200..168990a7e792 100644 > --- a/drivers/firmware/arm_ffa/Makefile > +++ b/drivers/firmware/arm_ffa/Makefile > @@ -2,5 +2,7 @@ > ffa-bus-y = bus.o > ffa-driver-y = driver.o > ffa-transport-$(CONFIG_ARM_FFA_SMCCC) += smccc.o > -ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y) $(ffa-transport-y) > -obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-module.o > +ffa-core-objs := $(ffa-bus-y) > +ffa-module-objs := $(ffa-driver-y) $(ffa-transport-y) > +obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-core.o > +obj-$(CONFIG_ARM_FFA_TRANSPORT) += ffa-module.o > diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c > index 2f557e90f2eb..0c83931485f6 100644 > --- a/drivers/firmware/arm_ffa/bus.c > +++ b/drivers/firmware/arm_ffa/bus.c > @@ -30,12 +30,11 @@ static int ffa_device_match(struct device *dev, struct device_driver *drv) > while (!uuid_is_null(&id_table->uuid)) { > /* > * FF-A v1.0 doesn't provide discovery of UUIDs, just the > - * partition IDs, so fetch the partitions IDs for this > - * id_table UUID and assign the UUID to the device if the > - * partition ID matches > + * partition IDs, so match it unconditionally here and handle > + * it via the installed bus notifier during driver binding. > */ > if (uuid_is_null(&ffa_dev->uuid)) > - ffa_device_match_uuid(ffa_dev, &id_table->uuid); > + return 1; > > if (uuid_equal(&ffa_dev->uuid, &id_table->uuid)) > return 1; > @@ -50,6 +49,10 @@ static int ffa_device_probe(struct device *dev) > struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver); > struct ffa_device *ffa_dev = to_ffa_dev(dev); > > + /* UUID can be still NULL with FF-A v1.0, so just skip probing them */ > + if (uuid_is_null(&ffa_dev->uuid)) > + return -ENODEV; > + > return ffa_drv->probe(ffa_dev); > } > > @@ -232,14 +235,21 @@ void ffa_device_unregister(struct ffa_device *ffa_dev) > } > EXPORT_SYMBOL_GPL(ffa_device_unregister); > > -int arm_ffa_bus_init(void) > +static int __init arm_ffa_bus_init(void) > { > return bus_register(&ffa_bus_type); > } > +subsys_initcall(arm_ffa_bus_init); > > -void arm_ffa_bus_exit(void) > +static void __exit arm_ffa_bus_exit(void) > { > ffa_devices_unregister(); > bus_unregister(&ffa_bus_type); > ida_destroy(&ffa_bus_id); > } > +module_exit(arm_ffa_bus_exit); > + > +MODULE_ALIAS("ffa-core"); > +MODULE_AUTHOR("Sudeep Holla "); > +MODULE_DESCRIPTION("ARM FF-A bus"); > +MODULE_LICENSE("GPL"); > diff --git a/drivers/firmware/arm_ffa/common.h b/drivers/firmware/arm_ffa/common.h > index d6eccf1fd3f6..9c6425a81d0d 100644 > --- a/drivers/firmware/arm_ffa/common.h > +++ b/drivers/firmware/arm_ffa/common.h > @@ -14,8 +14,6 @@ typedef struct arm_smccc_1_2_regs ffa_value_t; > > typedef void (ffa_fn)(ffa_value_t, ffa_value_t *); > > -int arm_ffa_bus_init(void); > -void arm_ffa_bus_exit(void); > bool ffa_device_is_valid(struct ffa_device *ffa_dev); > void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid); > > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c > index 159f2106a541..7cdd425c5fc4 100644 > --- a/drivers/firmware/arm_ffa/driver.c > +++ b/drivers/firmware/arm_ffa/driver.c > @@ -1603,14 +1603,9 @@ static int __init ffa_init(void) > if (ret) > return ret; > > - ret = arm_ffa_bus_init(); > - if (ret) > - return ret; > - > drv_info = kzalloc(sizeof(*drv_info), GFP_KERNEL); > if (!drv_info) { > - ret = -ENOMEM; > - goto ffa_bus_exit; > + return -ENOMEM; > } > > ret = ffa_version_check(&drv_info->version); > @@ -1671,11 +1666,9 @@ static int __init ffa_init(void) > free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE); > free_drv_info: > kfree(drv_info); > -ffa_bus_exit: > - arm_ffa_bus_exit(); > return ret; > } > -subsys_initcall(ffa_init); > +module_init(ffa_init); > > static void __exit ffa_exit(void) > { > @@ -1685,7 +1678,6 @@ static void __exit ffa_exit(void) > free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); > free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE); > kfree(drv_info); > - arm_ffa_bus_exit(); > } > module_exit(ffa_exit); > > -- > 2.43.2 > Ack, Sebastian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel