From patchwork Wed Apr 19 09:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13216583 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 C1FF9C77B73 for ; Wed, 19 Apr 2023 09:55:43 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9mHsXLpYfpSJtnJvl0ALINAyNyEnvDetA+0nlcFeoXg=; b=K3TBRMDRdl/j67 tv+970DabFysQn8q7YN4/wvBNFsS3sJrYYEJKiFX6ZyWm1+MverGaX6ra7rmaOPOn5mxgmYEHZuNZ CCmUtswu/2o+96k5bZsHKHQyVXd/Kny9cxSi1o8eklKLWLY5RluZIPlXe8/RmvxOHSqBQTwVtr5fY c5YuxD0kD80ophdR6Y8lJxIfpX2DxAOuhwH7iREJ43H4U9JX/B5MrbkB31aNa7I9OaF7XpVmoh/Cg ytndB2FVel1jyBHbATBUTHsKz2rul+Bc9a9xrIwrUxlib5LCbLK5ZVH5kREOSg4PCy6Zj+oPYJPqc JsSnczWGEHc6gjmbqlUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp4Wa-004oqO-2Y; Wed, 19 Apr 2023 09:54:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp4WQ-004ome-01 for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 09:54:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E02A51474; Wed, 19 Apr 2023 02:55:23 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 787B33F6C4; Wed, 19 Apr 2023 02:54:39 -0700 (PDT) From: Sudeep Holla Date: Wed, 19 Apr 2023 10:54:17 +0100 Subject: [PATCH 3/3] firmware: arm_ffa: Fix FFA device names for logical partitions MIME-Version: 1.0 Message-Id: <20230419-ffa_fixes_6-4-v1-3-1881ee6699f1@arm.com> References: <20230419-ffa_fixes_6-4-v1-0-1881ee6699f1@arm.com> In-Reply-To: <20230419-ffa_fixes_6-4-v1-0-1881ee6699f1@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Lucian Paul-Trifu , Marc Bonnici , Jens Wiklander X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3167; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=q+ZsHcEj3a9mgTBm8wOZNEEwEuY+kpvdYtGnfZi1SBs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBkP7pcjnSaeiKuWhRlxVBKvP/EKbcpP4yUNfUV5 8yMnZC2SUOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZD+6XAAKCRAAQbq8MX7i mHcgD/9/phHv0/fdbyKWKmbQlkGaYu2lcfEClnZGxw2ZJaMKUnSJuMkzSK/nMZW0CFpQl5n7ynQ XWuqM3DM56j29k7bjlvwF9T6BBzSOB27sGBIswLhcS4gZfOAY2Os27/k9vgADCE/xcgn38t+VXR 7Pj/n99Po5VXJvFspwJzIBjaTDfY4R/uMv4YkE7wdE1wPHHe8XafC93GXXykVH2aPYsxDnejSSn /K47e8VUlBqFzXKm/gDLU0sYmMFi7TiC+C3qzfOvdQJx7tWgQ9YvrOtQI3PWTkCqaGKTIj9Yi1x NnWHa98bAwoDmWiB0fkODnkXGwYtmrUniVZgve9UFhw3dYHavhXWfNCP9CmG+apWwL6dDFQ3s/i ojlsK+/LoLeOSQEZSc6k+lETnwzc81OKQugiFFDKgoOTlfepcQMTUjn5vJc3MmGMiGiwMsy3Mg+ SGtzZXs4wYAUFRqM+YRv0sL3om+h34xTdauBQf1eh9nHy2b6jMjRs4tFLdoQLtZR5RMFVNDWy2B Lmtyuj+WiJN9WfrBGqTY4+dose1b1+Nj5qRwyBHKNeIipgcIivxNRQ+uOt/0fxeof16UpGUCqJ1 LHxJl2VM8oSTgr8P7sz3C2mIP4PSNoLpEkdfJcIwDqSQ3jfsO81uW+mDx0L+i+C0lh4h2Bzbfyl HpNUbAnpAmJxL2g== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_025442_136785_5191A186 X-CRM114-Status: GOOD ( 17.69 ) 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 Each physical partition can provide multiple services each with UUID. Each such service can be presented as logical partition with a unique combination of VM ID and UUID. The number of distinct UUID in a system will be less than or equal to the number of logical partitions. However, currently it fails to register more than one logical partition or service within a physical partition as the device name contains only VM ID while both VM ID and UUID are maintained in the partition information. The kernel complains with the below message: | sysfs: cannot create duplicate filename '/devices/arm-ffa-8001' | CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.3.0-rc7 #8 | Hardware name: FVP Base RevC (DT) | Call trace: | dump_backtrace+0xf8/0x118 | show_stack+0x18/0x24 | dump_stack_lvl+0x50/0x68 | dump_stack+0x18/0x24 | sysfs_create_dir_ns+0xe0/0x13c | kobject_add_internal+0x220/0x3d4 | kobject_add+0x94/0x100 | device_add+0x144/0x5d8 | device_register+0x20/0x30 | ffa_device_register+0x88/0xd8 | ffa_setup_partitions+0x108/0x1b8 | ffa_init+0x2ec/0x3a4 | do_one_initcall+0xcc/0x240 | do_initcall_level+0x8c/0xac | do_initcalls+0x54/0x94 | do_basic_setup+0x1c/0x28 | kernel_init_freeable+0x100/0x16c | kernel_init+0x20/0x1a0 | ret_from_fork+0x10/0x20 | kobject_add_internal failed for arm-ffa-8001 with -EEXIST, don't try to | register things with the same name in the same directory. | arm_ffa arm-ffa: unable to register device arm-ffa-8001 err=-17 | ARM FF-A: ffa_setup_partitions: failed to register partition ID 0x8001 By virtue of being random enough to avoid collisions when generated in a distributed system, there is no way to compress UUID keys to the number of bits required to identify each. We can eliminate '-' in the name but it is not worth eliminating 4 bytes and add unnecessary logic for doing that. Also v1.0 doesn't provide the UUID of the partitions which makes it hard to use the same for the device name. So to keep it simple, let us just append the index to the list of the partitions obtained in response to FFA_PARTITION_INFO_GET to "arm-ffa" to make up a unique device name. Fixes: e781858488b9 ("firmware: arm_ffa: Add initial FFA bus support for device enumeration") Reported-by: Lucian Paul-Trifu Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 4aced2e5b772..39b912bbd7db 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -678,7 +678,7 @@ static void ffa_setup_partitions(void) * provides UUID here for each partition as part of the * discovery API and the same is passed. */ - ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops); + ffa_dev = ffa_device_register(&uuid, idx, &ffa_drv_ops); if (!ffa_dev) { pr_err("%s: failed to register partition ID 0x%x\n", __func__, tpbuf->id);