Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1541800lqt; Wed, 20 Mar 2024 07:09:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWpdkJbBXbfEVLmBu3GgmnDPT9t/hCkUyJdmUyO9NCmiRd7yvYS/WFWP8M3YBymaxLeeV6an3ea2y+N3WAPhWODgTqfG8zSUiXjPa9NfQ== X-Google-Smtp-Source: AGHT+IFGl7+TecKHWHGI2xULsaV7j8fOJzOXONMVueWa4FSDaz0IrAVSE/F0sfZMarNJaXbvOe14 X-Received: by 2002:a05:622a:5785:b0:430:c07d:632b with SMTP id eh5-20020a05622a578500b00430c07d632bmr14555503qtb.21.1710943757346; Wed, 20 Mar 2024 07:09:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710943757; cv=pass; d=google.com; s=arc-20160816; b=cK+63K9MT+CkpDC4DEyecP4ePb8zef1szTAq/scgcNeum9TxmXqJABMoK19rXK4CTU P+RHhHejQI1WFKwK/bRt2w5FQRY3lcbYdu463j0lSMMsfP+3jx9WyKJPc04luyN9Yj+S NYT/YmrJ6C/VNfvIPLeaWyJd2QgcNBx/QAwsewa6txc+7bsp+SFKoQeJuhDzendh3Y2i HOkdjAJiA7PmyUN0O1FnrSUmQZsi322m7ywC3bQfiU21hpr/PMs9321p5JV7GIKQcz8Y yQ1+27DpJuCdkIVtMQCq3EHD+3lvBfwoqi8zBET/NiNM3ga8+d8iq/f05EJ1y9efHM7o CXfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SIdJ3/H6efkxnibONQiSADbnnZKfOXj3hF+4ocmjhSc=; fh=ruL7ttBOuPXFzKjoZqklQzlPwBtYINSnMC/0lvydhUQ=; b=qiuRzm7WS/7CNny7bmPY/0+QtJskJM/wpWEumjrj8rqOxTBFZy/PeLUkLmsDlltBLx pZUDXlMGq2IZJcIoyu3QQbSGdHg0CtDf26eIVpPljYWCWyClgM77z2zwKl2yu9qgewJx /dBYovWCFiY2oInltlG73Bo2TBc5EiINbVI2OO4Z85KhB1ZiIPjIvn9tnZ/OG86/7Icd RE6ZMz7P4d6CN/s1icLgQsjctC/5+P1PBha25cx+gst+696Ggzrn285ie9967o9BLi3N vfup0FMLDAFRTX5b3iZTpo2qWrzJ/D7i6dCBQl8AGZ7X9yz4kNXgc0bFiTum5reXhVvE F5EQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@resnulli-us.20230601.gappssmtp.com header.s=20230601 header.b=qM5SVBSo; arc=pass (i=1 dkim=pass dkdomain=resnulli-us.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-108981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108981-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c12-20020ac87dcc000000b00431161c9045si766349qte.582.2024.03.20.07.09.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:09:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20230601.gappssmtp.com header.s=20230601 header.b=qM5SVBSo; arc=pass (i=1 dkim=pass dkdomain=resnulli-us.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-108981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108981-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F1B961C2296A for ; Wed, 20 Mar 2024 14:09:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F2A744370; Wed, 20 Mar 2024 14:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="qM5SVBSo" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEAEF3B2BE for ; Wed, 20 Mar 2024 14:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710943747; cv=none; b=YDRSUyhtR89t9ZaVLrYNPUh+6oN20N1TV6wmT6lwHK9Lvsc/nQq5mA/ZhCMhJJyez7vHwGz9r4cvizuOR9/HnsQAoTP7eLUd6t4yMgc9Sn7NpW0TNneX2TPDwt2LOmjiC5L3BnAUl5W+AxsTr8n7xCTe2YCx+4jK8etO0GxYPEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710943747; c=relaxed/simple; bh=H1XOmKD7bRcfqq1UFgWSVIBC/zw9QBBFa1xm/jed5/g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n+vMqOQsi0uozxMg6eqNGp6v37gBWbwLseMUHY7BmwV9Gs8kJL2tP6qbo7bj3YHzg0Txmg86/L/O9KFfEWbrS+AyCRcfU/wCYuX+1X2SAGlVZtlslU1KsYWWArG/OpnG1VGj3BQx81JSSoP4EYGQd+JWxMwVBUwf1qPVsc28dAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=qM5SVBSo; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a3ddc13bbb3so175483766b.0 for ; Wed, 20 Mar 2024 07:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1710943744; x=1711548544; darn=vger.kernel.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=SIdJ3/H6efkxnibONQiSADbnnZKfOXj3hF+4ocmjhSc=; b=qM5SVBSoKeNhdvQn/Y5ZfyBfAt7AxFmnl0fF+cYjriNoMYpfaAzVV0O2X5rq9n1C0X 4L+jkUWg/FgyOKTd7RCSCcCkrQfzfRapLvr1n+lCTvCOeBvjAAPXO083Q55t51m5mFKL cEaJUlY7E1ZBp6+2yrBjWSAzGQFj62+5NLR/QbmyFD4M7VzpRyK/rClnQO6TfiAoMzSk vDb9XCqcLY5iFC9JfInA9SuOJVhh6eXk+WsbSEQDgGzwjsAgnlxlB0mCT+tBpXlNbZmK ndgH2FPWPeCEmmNv1yLybCTtCd79TXNS//bH2xARGTYQCKwjvVmI0Jhw9rCbA6jcyzDe vIOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710943744; x=1711548544; 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=SIdJ3/H6efkxnibONQiSADbnnZKfOXj3hF+4ocmjhSc=; b=oz1tmx1cW90bezfF/AYXQWpPOGWG+XW1XLBiXa9RlEgqFJ0k3J6zeQYRnvtk2yO5Tv m/JASirlR0NbzbNptmQ3m+CYyH92eLncFdO5O5rEFupXJiZkB4E/eGmxUVJmmMNFbQlp J4hOTShI3/A+r+3t4udwKpGdx5CbbdS62ETltIF1Wn3oixy4U9qn+Gq7Wx3jQLCM6qAu DhjWO1EXWVj8CBjXdAerEfpWKPMebqAIvwVF1lZCZAHYaJ1CMGhAnAbY2/GhqCCT40pX EW9NyiOcVM63knKr6EonXIgKH42oI0sy7XdqgpfaIZJfekYK4qWnEZbgHlrMDZRipj/S jFfw== X-Forwarded-Encrypted: i=1; AJvYcCVPtQKZZCHanxJmo8bH7YEUFV2vtXBqHau7RPunLm28f5IjyzJOyWs6FRV6X+9MHPAV6UkZoNWF1c4h6n5DEt7V7BGaauYsgfku0ZUx X-Gm-Message-State: AOJu0YyagaLhoJONDYdU9XbGURHlWpThpitukevzojMoQB30S+/ZtUSx CCSwzhvm8d0H6ECKUG18x+s6QISooyMMcPjyN/D+sMhAhp9w/RThfm1Df+xmGpg= X-Received: by 2002:a17:906:b247:b0:a45:f9c5:3024 with SMTP id ce7-20020a170906b24700b00a45f9c53024mr5416028ejb.11.1710943743915; Wed, 20 Mar 2024 07:09:03 -0700 (PDT) Received: from localhost ([86.61.181.4]) by smtp.gmail.com with ESMTPSA id bp14-20020a17090726ce00b00a46bdc6278csm3699309ejc.71.2024.03.20.07.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:09:03 -0700 (PDT) Date: Wed, 20 Mar 2024 15:09:01 +0100 From: Jiri Pirko To: Josua Mayer Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: dsa: mv88e6xxx: add warning for truncated mdio bus id Message-ID: References: <20240320-mv88e6xxx-truncate-busid-v1-1-cface50b2efb@solid-run.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240320-mv88e6xxx-truncate-busid-v1-1-cface50b2efb@solid-run.com> Wed, Mar 20, 2024 at 02:48:55PM CET, josua@solid-run.com wrote: >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 which 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 whiich the dsa switch s/whiich/which/ >sits such as on CN9130 [1]. > >Test whether the return value of snprintf exceeds the maximum bus id >length and print a warning. > >[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 > >Signed-off-by: Josua Mayer This is not bug fix, assume you target net-next. Please: 1) Next time, indicate that in the patch subject like this: [patch net-next] xxx 2) net-next is currently closed, repost next week. >--- > drivers/net/dsa/mv88e6xxx/chip.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c >index 614cabb5c1b0..1c40f7631ab1 100644 >--- a/drivers/net/dsa/mv88e6xxx/chip.c >+++ b/drivers/net/dsa/mv88e6xxx/chip.c >@@ -3731,10 +3731,12 @@ 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); >+ if (snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np) >= MII_BUS_ID_SIZE) >+ dev_warn(chip->dev, "Truncated bus-id may collide.\n"); How about instead of warn&fail fallback to some different name in this case? > } else { > bus->name = "mv88e6xxx SMI"; >- snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); >+ if (snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++) >= MII_BUS_ID_SIZE) How exactly this may happen? >+ dev_warn(chip->dev, "Truncated bus-id may collide.\n"); > } > > bus->read = mv88e6xxx_mdio_read; > >--- >base-commit: e8f897f4afef0031fe618a8e94127a0934896aba >change-id: 20240320-mv88e6xxx-truncate-busid-34a1d2769bbf > >Sincerely, >-- >Josua Mayer > >