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 90573C25B75 for ; Wed, 15 May 2024 13:16:11 +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=WaC1vKIpmVoypncoJn6DW8D2Fqam2vcUYcjWUiztz7g=; b=ma4khBKlHmQ4nj ROSO8tN2t1XCv/bFx9mZ0tHag5A46lw7i1L4zkO9rzhQB2cDMm2Sg0v+Nv3hxNmgYZwq2l5fe1jcx 9h9+hTd6yX1VXgOsOc0Cn3zGLKf9sNlhMAdErGwTziBVbwruhvjW9ExXegD1j99mJHyKfbz7WS+IQ 8ZJbcIvaUKiD8zt/tAixKkO/+i3nRIm3gFZ6tqd4rBnc+pZ+081M+mzjmingXGiPmZZpxFK3Gxnwv aKiKS+ozfTnmfK2Hfv97OGArKhtnCDJUroiTdZOIWyX4X7hOpqcFcN4+E4pVIsrGO4PkaBffxs3JX sD+aJ9MQd279k3xHB88w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7EU5-00000001cGy-3kEx; Wed, 15 May 2024 13:15: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 1s7EU2-00000001cEp-2Zgo for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 13:15:52 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41ff3a5af40so315475e9.1 for ; Wed, 15 May 2024 06:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715778948; x=1716383748; 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=p2CEBcQ3jh5VHSxkb8cxgZe75e77nuxGSMcQswJnSX8=; b=l9OsKDmcAFyhmSUT/pudhcXyx8iUg5GYL1lW4gMHnXv+0FWC+Rs0bVqKdpK35qadYe MB9pgwLLLkIUkWUvz8rPOZU0T58hFiCnEDh9K0WNOsPIXGR/J/4ylRKVSbGHniXcOWso Sg3C5Gz4eTQydmkoyu75GLmom+03kQHDTqHVFrYXKr6ywSMmOAQQOMe4JpkzM3M2dHsi 1MybSDBGXPnNh0NPYz80wMGLwaUtgzkdNMyScnCWrx+H/piE5qdnzmVnvvWa9V3dY/7t ciWJxgsusHWj2gppfgt38C75N+UZJR1ui7GCBgHaQxRFydFbIocg/FKf1shmtJQ4fBXV aMUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715778948; x=1716383748; 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=p2CEBcQ3jh5VHSxkb8cxgZe75e77nuxGSMcQswJnSX8=; b=SozA4smNGs1E/4YIx1utr1S0HpxL3bCKZOXZ4GEwXYFvcZhy/D0pVoz6fxZGSXinxP pBs/dBxMunhIDUnEhI53897ZdVZjbrMLAcUmV4lZqbfsOCrTVmudR4UbbwAmSbvQZmPh K4Loj9wxoIb3XnOlOPWHByfhdHVUJy3UyR8n+3YAu4wePFLeQUEX6sFpMAumYLxp/IC9 K2u8d38BEIb3DDXA8NOkyqVvbAEBp7QlNMZcXvnt9rhVGkcm1p3DRn9iZmFBiESxpnhM rgJsbXyVJlwsaM77m/E6HR/Ob4ctFURx9avAEtMOo6wGE0U2t0DDdYeEDBp1yFvVYLhw d0YQ== X-Gm-Message-State: AOJu0Yzr7AfxPIr6wLXMWSM3zSjpm2Jxd1qhjWIbi4wkpGZ/t5HVresa vuoL/97ZdXdPRKKU+PLMy1pEZqri4LuLNdja5H9KQv5NtvoO+2z8V0W0//iZZg== X-Google-Smtp-Source: AGHT+IGj5OwxfOJYFVoA/dq43qH/d+he+7JgZNANaciEEw1jdMdSJ9zQtt1/3FXZmwonExdTzBU37A== X-Received: by 2002:a05:600c:5024:b0:41b:4c6a:de7a with SMTP id 5b1f17b1804b1-4200f8bbe7bmr8532595e9.3.1715778948320; Wed, 15 May 2024 06:15: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 ffacd0b85a97d-3502baacff4sm16567511f8f.79.2024.05.15.06.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:15:47 -0700 (PDT) Date: Wed, 15 May 2024 13:15:46 +0000 From: Sebastian Ene To: Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi , Jens Wiklander Subject: Re: [PATCH v2 1/2] firmware: arm_ffa: Move the FF-A v1.0 NULL UUID workaround to bus notifier Message-ID: References: <20240515094028.1947976-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240515094028.1947976-1-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_061550_741572_B0371CD5 X-CRM114-Status: GOOD ( 43.59 ) 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 Wed, May 15, 2024 at 10:40:27AM +0100, Sudeep Holla wrote: > Currently FF-A bus ffa_device_match() handles the workaround for the > FF-A v1.0 devices which are not populated with UUID to match. The FF-A > bus layer calls into FF-A driver and populates the device UUID if it > matches with the driver attempting to match. > > But this forces to have both FF-A bus and core driver to be bundled into > a single module. However, keep it as a single module adds problems for > the FF-A driver registrations and their initcall levels. > > In preparation to split the FF-A bus and the core driver into distinct > modules, we need to move the workaround away from the FF-A bus layer. > We can add it into the FF-A core driver as a bus notifier. > > In order to do so, we need to always match any driver with the device if > the UUID is NULL and then during the driver binding phase, we can populate > the UUID if it matches with the driver UUID table using the bus notifiers. > We also need to add a check for NULL UUID before calling the device/driver > probe as devices with NULL UUID is possible since we match all for that > case. > > Signed-off-by: Sudeep Holla > --- > drivers/firmware/arm_ffa/bus.c | 11 +++++--- > drivers/firmware/arm_ffa/driver.c | 45 ++++++++++++++++++++++++------- > 2 files changed, 43 insertions(+), 13 deletions(-) > > v1->v2: > - Dropped unnecessary version check in ffa_device_match_uuid() > - Moved all the logic associated with ffa_bus_notifier() into this > patch which previously had incorrectly spilled into second patch > Thanks to Sebastian Ene for pointing it out. > Hello Sudeep, Thanks for the v2, this looks good to me. Acked-by: Sebastian Ene > diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c > index 2f557e90f2eb..4baaec7f0a09 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); > } > > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c > index 1609247cfafc..61d514776e5b 100644 > --- a/drivers/firmware/arm_ffa/driver.c > +++ b/drivers/firmware/arm_ffa/driver.c > @@ -1224,14 +1224,6 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid) > int count, idx; > struct ffa_partition_info *pbuf, *tpbuf; > > - /* > - * FF-A v1.1 provides UUID for each partition as part of the discovery > - * API, the discovered UUID must be populated in the device's UUID and > - * there is no need to copy the same from the driver table. > - */ > - if (drv_info->version > FFA_VERSION_1_0) > - return; > - > count = ffa_partition_probe(uuid, &pbuf); > if (count <= 0) > return; > @@ -1242,6 +1234,35 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid) > kfree(pbuf); > } > > +static int > +ffa_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) > +{ > + struct device *dev = data; > + struct ffa_device *fdev = to_ffa_dev(dev); > + > + if (action == BUS_NOTIFY_BIND_DRIVER) { > + struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver); > + const struct ffa_device_id *id_table= ffa_drv->id_table; > + > + /* > + * FF-A v1.1 provides UUID for each partition as part of the > + * discovery API, the discovered UUID must be populated in the > + * device's UUID and there is no need to workaround by copying > + * the same from the driver table. > + */ > + if (uuid_is_null(&fdev->uuid)) > + ffa_device_match_uuid(fdev, &id_table->uuid); > + > + return NOTIFY_OK; > + } > + > + return NOTIFY_DONE; > +} > + > +static struct notifier_block ffa_bus_nb = { > + .notifier_call = ffa_bus_notifier, > +}; > + > static int ffa_setup_partitions(void) > { > int count, idx, ret; > @@ -1250,6 +1271,12 @@ static int ffa_setup_partitions(void) > struct ffa_dev_part_info *info; > struct ffa_partition_info *pbuf, *tpbuf; > > + if (drv_info->version == FFA_VERSION_1_0) { > + ret = bus_register_notifier(&ffa_bus_type, &ffa_bus_nb); > + if (ret) > + pr_err("Failed to register FF-A bus notifiers\n"); > + } > + > count = ffa_partition_probe(&uuid_null, &pbuf); > if (count <= 0) { > pr_info("%s: No partitions found, error %d\n", __func__, count); > @@ -1261,7 +1288,7 @@ static int ffa_setup_partitions(void) > import_uuid(&uuid, (u8 *)tpbuf->uuid); > > /* Note that if the UUID will be uuid_null, that will require > - * ffa_device_match() to find the UUID of this partition id > + * ffa_bus_notifier() to find the UUID of this partition id > * with help of ffa_device_match_uuid(). FF-A v1.1 and above > * provides UUID here for each partition as part of the > * discovery API and the same is passed. > -- > 2.43.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel