Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp806343lqh; Sun, 5 May 2024 02:53:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURX40lL/dTxBGxbqjtwzvMtJeWmtfYD+mR0og15kF3ZvN0MVT0E6ZVRlNz8PNFzbsIWfvCf+9vGopdspWC1HvsyInQQ97YjkMRPa3mlw== X-Google-Smtp-Source: AGHT+IE9vW8BasJd0VIaGA51g/2elrnwuUP86liGkmsicsXnXgvBhn4hR3xRRcyZU/HAJPOgQpyJ X-Received: by 2002:a17:90a:ab92:b0:2ab:d82e:1afb with SMTP id n18-20020a17090aab9200b002abd82e1afbmr6910581pjq.16.1714902785998; Sun, 05 May 2024 02:53:05 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mh18-20020a17090b4ad200b002b2ce888193si9144655pjb.33.2024.05.05.02.53.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 02:53:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@solidrn.onmicrosoft.com header.s=selector1-solidrn-onmicrosoft-com header.b=Jy8kJ+R2; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-168936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=solid-run.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9C1CD281B4C for ; Sun, 5 May 2024 09:53:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3F87B665; Sun, 5 May 2024 09:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=solidrn.onmicrosoft.com header.i=@solidrn.onmicrosoft.com header.b="Jy8kJ+R2" Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2136.outbound.protection.outlook.com [40.107.247.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77E5F6FBE; Sun, 5 May 2024 09:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.136 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714902772; cv=fail; b=LPBD42l5PTzWbFC4QTNPJQx/jIVb7+YARfYnFvWGf74uB8/INh6soTpD5/NACFrZbNOtnNRjTn7oTpob1r1PbonSUu7RtICzPAAGjm7H6jHuNtPrx1IwVhLBiGrhr6XShtcvU0lSbnmlcEO2LnSY47ErbIWMGcjwA1YFbtruRio= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714902772; c=relaxed/simple; bh=dXfeRGDZ7cYp60tM9lZavUSCmaezb8UTb4S97ez1TVk=; h=From:Date:Subject:Content-Type:Message-Id:To:Cc:MIME-Version; b=R1Zr4E9E2FzHehAMBLbOdx/lnyimzr9av9xJnATI7Q9G2ozy6IPYQaJCVnlBjIzPZ+o7nlE17qQxxQRsFMRCh0WunsKiw5ZKGScdzvsad2/gP4ld3e8GT4k4QG2lu1smY5iAKOJkzz+YmqmXQMh4nyJ/1PdGo2B0VOyZOL9LLj4= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=solid-run.com; spf=pass smtp.mailfrom=solid-run.com; dkim=pass (1024-bit key) header.d=solidrn.onmicrosoft.com header.i=@solidrn.onmicrosoft.com header.b=Jy8kJ+R2; arc=fail smtp.client-ip=40.107.247.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=solid-run.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=solid-run.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mDGqs8Yu81hLe9YKWqmn6YnvW40IG09yjibR0G7YAkI9en8NFf80McNg+jJ4mm2VMZWeDEmfWvDKFYVuXxsr94JordM9Wy1CBPzxxlbg8yyub0zbhM+bOGCPfr6yjmiDLDcd8tSpd2SlQW8ux6j3IYWilbKk5XoaurSmdf8jxPaAtBrZWLML0pNvUSobhpXo2yPoEEiKrW+5/LvQTAjsYVocSX9SdpcgqiHNJsolrPWmLEezVlefhU5PHyuzBgnc1Kubui8xCWrx7kmPZgymKWCKxDbuctEceTg5v7jbOCCzojoZoYogM46jq+JCTV7fqsv64aivLPGOBOthdeqtZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0pOaZ/JQbzPRw8x370l57MX66OHOTKNKWpa/USo6moA=; b=LCVqiuMbdUcx6RdvLvdd9gk1jwkkH0bq37+FBDE5H02hCo3YxtaH2wveem2kaMU6hP10JtQ3kQ1rYSIamJIMDleX9sa++Bht2z5bLWyt3Hq3Igu7pkWsqYuOwQeHMKkTL856P+8a8TcpMLJ2RW9LpK8aC+B50ZcJVvxRuHJs5qee47ukLDUenrsSzWJRmJzbSM+AO7Y90IMmaGlMj0HflPoECPGRGj4L9KVynhg/hFoJGJwwls7Endrx56AdhZ3ipNtFOD1bWJAttj27Ex0qGT0NnVluMQXGwYWpSNBqx5BdqMNgfWMjDU0Oe+f9zLxJ/hhbPGtTTxhICOnBJrGrcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=solid-run.com; dmarc=pass action=none header.from=solid-run.com; dkim=pass header.d=solid-run.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solidrn.onmicrosoft.com; s=selector1-solidrn-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0pOaZ/JQbzPRw8x370l57MX66OHOTKNKWpa/USo6moA=; b=Jy8kJ+R2a7Tr5lRG/LbWS0w0yl0lSCsCaoRXhWOrKxGRgy31Fmwzzu2Z8isSdWnbo/GlOu00Qvr1NcKv9Oh2NBtU5YgRgqcv7chkuHBfBew9icj3qSfCAe5EbaT9WhYsDbUTNI+MylS0o4UDhYaiBDuJzuTHeN9GYDDCpjpUC1I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=solid-run.com; Received: from AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) by AM8PR04MB7331.eurprd04.prod.outlook.com (2603:10a6:20b:1c7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Sun, 5 May 2024 09:52:48 +0000 Received: from AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529]) by AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529%7]) with mapi id 15.20.7544.036; Sun, 5 May 2024 09:52:48 +0000 From: Josua Mayer Date: Sun, 05 May 2024 11:52:45 +0200 Subject: [PATCH net-next v3] net: dsa: mv88e6xxx: control mdio bus-id truncation for long paths Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240505-mv88e6xxx-truncate-busid-v3-1-e70d6ec2f3db@solid-run.com> X-B4-Tracking: v=1; b=H4sIAOxWN2YC/4XNSw7CIBAG4Ks0sxZDodLWlfcwLgodLIkFA5Rgm t5d0o0LE82s/nl8s0JAbzDAuVrBYzLBOFsCP1SgpsHekZixZGCUNZQzSubUdShyziT6xaohIpF LMCPhzVCPrBW9lBrK+dOjNnmnr2AxEos5wq1MJhOi86/9Z6r3+X8+1aQmSg8KT1Qy1PIS3KP0y 9ZRuXmHE/tgpX5grGCiFx3XoqW0+8K2bXsDAzyItRsBAAA= To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Josua Mayer , Mor Nagli X-Mailer: b4 0.12.4 X-ClientProxiedBy: FR4P281CA0087.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cd::11) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|AM8PR04MB7331:EE_ X-MS-Office365-Filtering-Correlation-Id: 76c133e7-5732-4f1d-4599-08dc6ce91eb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|1800799015|366007|376005|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?B?S01zS0R5RFlpR2xncStRZWRZdFhGdGYrU3J0dHVoeWczU0U5RmhpR01NaFVu?= =?utf-8?B?T0hubXlXbDd1OE9BR0k0bmJ4SXhkS3ZmbUQ4K3dZci83blhYTVJjR1pySmxN?= =?utf-8?B?WFVzNG80YU9FTVUxNXI0amY4K1BkNzFpSG1ETkxzczhDSEc1WDZoZzJWZDFK?= =?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U25RR1pnUnhqejFyQ2dY?= =?utf-8?B?MDFMejhqdEFaYS9XV2FJMW9HaHkrSnA5Z3JLRGVQaEZMS01MRlA0bEtrdDlm?= =?utf-8?B?cStjb3llVFptVXR5UDVHQ2F0WitMS3o4MkJjcDUrOWo1a1U1UXlsNW1NeVhl?= =?utf-8?B?NEZLRjI3aXVYSVEvUjhpNlExd01EenZsNWY1QzNQdkVESVJwaHdVMUtyR3Nv?= =?utf-8?B?dVpEYVdhNFBCOHJHRGdUMVFWTkJ1Y1VXWU1mTm5EbWVxUW1vWkxXcFQyYThF?= =?utf-8?B?d0FONE0rMkVDRnB1dldqSHJhb0k5SWtYR1BlUjJqTG84VDFmUWo5VlBuSWlM?= =?utf-8?B?eGc0VlhxR2dnQWFLallrTnJUbnBGWUU4OGFVUUNvUDJMVFU5MXkxUC8zNkJM?= =?utf-8?B?YmM0TnVRV1FzTjBSdnJtUkcyTVgzMnRTbkZQVEtya3F1dE9yMkRGRVJKNWVP?= =?utf-8?B?c1BTc1V1SGVxbXgvcC9ib3BWc044U0FUM3Yvc0NGdS83aGdiZkZwWTF2Z1hR?= =?utf-8?B?b1AwMnh1VEl1bXpvWm43WTlkTDl5WThpREwxTERrTkZlRUhDZ3phSkpMVVBS?= =?utf-8?B?R05SQmNjZnVSOFU2em4wTzFMNXdYekZZWHdyMW1kc3NTQW9GUy95NGtRdXNH?= =?utf-8?B?dzBHZXNFNytaMGxTYmhzeVBaR1Vmd29sK0UvNnRyVTN4L1hKYmFiaW5nPT0=?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB7586.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(1800799015)(366007)(376005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eHJGV2tVdlBpZGRUaU1xUn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f-8?B?NmpLYzVFeFkyTTZEUjZhaVpITkFGaGE2c3VKek82VFowSFRFSzg2OUxNd292?= =?utf-8?B?ZVNBS1dhOVBoR1hHK2JrSkJnVTN3b1U1YnRHbXpiZnB4dUk2NHVoRHVNZnVI?= =?utf-8?B?R0Q5VThEQlM5TDZhc0lLdWcrTkduNU1vTmFSY3hSU0Y4SW82SkxCM1Qrcm93?= =?utf-8?B?bDJJRjZZcTZzMjRhK2JUbHVCSFNjRWdCcnVlK1BXdVdYaUpQVFljb0t1NmZ6?= =?utf-8?B?VnpSRUlUQTBzSXR4MXE0TllsdEpEZFJoL1RHMm1mSk5aamdmdEFGdmJTQTZV?= =?utf-8?Q?BA1BXEl168R704sc2VKkkZJ3A?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76c133e7-5732-4f1d-4599-08dc6ce91eb3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2024 09:52:47.9357 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a4a8aaf3-fd27-4e27-add2-604707ce5b82 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LsHANZfP45pWRDC2KjSlPjci8RTuihxYfbqRkkmoKCnH/uejFCZgkXwJyuBcYPWOkSJ5VzlfUSayrp9sPk2oXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7331 mv88e6xxx supports multiple mdio buses as children, e.g. to model both internal and external phys. If the child buses mdio ids are truncated, they might collide with each other leading to an obscure error from kobject_add. The maximum length of bus id is currently defined as 61 (MII_BUS_ID_SIZE). Truncation can occur on platforms with long node names and multiple levels before the parent bus on which the dsa switch itself sits, e.g. CN9130 [1]. Compare the return value of snprintf against maximum bus-id length to detect truncation. In that case write an incrementing marker to the end to avoid name collisions. This changes the problematic bus-ids mdio and mdio-external from [1] to [2]. Truncation at the beginning was considered as a workaround, however that is still subject to name collisions in sysfs where only the first characters differ. [1] [ 8.324631] mv88e6085 f212a200.mdio-mii:04: switch 0x1760 detected: Marvell 88E6176, revision 1 [ 8.389516] mv88e6085 f212a200.mdio-mii:04: Truncated bus-id may collide. [ 8.592367] mv88e6085 f212a200.mdio-mii:04: Truncated bus-id may collide. [ 8.623593] sysfs: cannot create duplicate filename '/devices/platform/cp0/cp0:config-space@f2000000/f212a200.mdio/mdio_bus/f212a200.mdio-mii/f212a200.mdio-mii:04/mdio_bus/!cp0!config-space@f2000000!mdio@12a200!ethernet-switch@4!mdi' [ 8.785480] kobject: kobject_add_internal failed for !cp0!config-space@f2000000!mdio@12a200!ethernet-switch@4!mdi with -EEXIST, don't try to register things with the same name in the same directory. [ 8.936514] libphy: mii_bus /cp0/config-space@f2000000/mdio@12a200/ethernet-switch@4/mdi failed to register [ 8.946300] mdio_bus !cp0!config-space@f2000000!mdio@12a200!ethernet-switch@4!mdi: __mdiobus_register: -22 [ 8.956003] mv88e6085 f212a200.mdio-mii:04: Cannot register MDIO bus (-22) [ 8.965329] mv88e6085: probe of f212a200.mdio-mii:04 failed with error -22 [2] /devices/platform/cp0/cp0:config-space@f2000000/f212a200.mdio/mdio_bus/f212a200.mdio-mii/f212a200.mdio-mii:04/mdio_bus/!cp0!config-space@f2000000!mdio@12a200!ethernet-switch...!-0 /devices/platform/cp0/cp0:config-space@f2000000/f212a200.mdio/mdio_bus/f212a200.mdio-mii/f212a200.mdio-mii:04/mdio_bus/!cp0!config-space@f2000000!mdio@12a200!ethernet-switch...!-1 Signed-off-by: Josua Mayer --- Bcc: Mor Nagli --- Changes in v3: - Added better named variable "len" for snprintf return value to improve readability (Reported-by: Andrew Lunn ) - Added short explanation why there are two calls of snprintf in comment - Link to v2: https://lore.kernel.org/r/20240404-mv88e6xxx-truncate-busid-v2-1-69683f67008b@solid-run.com Changes in v2: - fixed typo in commit message (Reportby: Jiri Pirko ) - replaced warning message with controlled truncation - Link to v1: https://lore.kernel.org/r/20240320-mv88e6xxx-truncate-busid-v1-1-cface50b2efb@solid-run.com --- drivers/net/dsa/mv88e6xxx/chip.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 964c7b847fd3..9c996be00362 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3774,10 +3774,10 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, struct device_node *np, bool external) { - static int index; + static int index, trunc; struct mv88e6xxx_mdio_bus *mdio_bus; struct mii_bus *bus; - int err; + int err, len; if (external) { mv88e6xxx_reg_lock(chip); @@ -3803,10 +3803,28 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, if (np) { bus->name = np->full_name; - snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); + len = snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); } else { bus->name = "mv88e6xxx SMI"; - snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); + len = snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); + } + if (len < 0) { + return len; + } else if (len >= MII_BUS_ID_SIZE) { + /* If generated bus id is truncated, names in sysfs + * may collide. + * Generate a special numeric suffix. If it fits + * within MII_BUS_ID_SIZE, insert at the end to mark + * truncation and avoid name collisions. + */ + len = snprintf(NULL, 0, "...!-%d", trunc); + if (len < 0) + return err; + else if (len >= MII_BUS_ID_SIZE) + return -ENOBUFS; + + snprintf(bus->id + MII_BUS_ID_SIZE - err - 1, + MII_BUS_ID_SIZE - err, "...!-%d", trunc++); } bus->read = mv88e6xxx_mdio_read; --- base-commit: 173e7622ccb3f46834bd4176ed363f435e142942 change-id: 20240320-mv88e6xxx-truncate-busid-34a1d2769bbf Sincerely, -- Josua Mayer