From patchwork Wed Nov 22 13:19:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 13464867 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 050171A597 for ; Wed, 22 Nov 2023 13:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j19ZbvAk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FB5FC433C7; Wed, 22 Nov 2023 13:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700659242; bh=7LwihJijMcBGsYICQ/FqBpaBHGRP+YQHQl9RI10ofT8=; h=From:To:Cc:Subject:Date:From; b=j19ZbvAkIKI2e/pIvAzDexOUQQBJltq13EahFGvqc3jIVBeXjpWLOFKsteLtkpnOz i82zQb7dKI88/TtWWqj+xRN5rwUh9l4opwcCGUm1IQ9wZLconhlf1Gyg2o8hAAWyVe Z2IDpIRA0CsvOM3ZX2AsKW9gqoNfM+6/6/xMIOCG9rIgjrI9rVmuaJWUU+lrlZa4xc IjMr9P2PDx2z4Nfq1nUjkFLNyDxjtp06VYJVAMmWwCIKayysctt3yEMMyEX3tKUOSg ku2LMsSOs0pABNURg+Kddbm4cDInStGB5+AU4+G79OzvUf5MKVLKUxHhrxzLihW2BJ MnMfnyAkP4rig== From: Greg Ungerer To: rmk+kernel@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, Greg Ungerer Subject: [PATCH 1/2] net: dsa: mv88e6xxx: fix marvell 6350 switch probing Date: Wed, 22 Nov 2023 23:19:44 +1000 Message-Id: <20231122131944.2180408-1-gerg@kernel.org> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org As of commit de5c9bf40c45 ("net: phylink: require supported_interfaces to be filled") Marvell 88e6350 switches fail to be probed: ... mv88e6085 d0072004.mdio-mii:11: switch 0x3710 detected: Marvell 88E6350, revision 2 mv88e6085 d0072004.mdio-mii:11: phylink: error: empty supported_interfaces error creating PHYLINK: -22 mv88e6085: probe of d0072004.mdio-mii:11 failed with error -22 ... The problem stems from the use of mv88e6185_phylink_get_caps() to get the device capabilities. Create a new dedicated phylink_get_caps for the 6350 to support its more different set of capabilities. Unfortunately the 6352 switch capabilities cannot be re-used due to their support of a SERDES lane. The Marvell 88e6351 switch is a slightly improved version of the 6350, but is mostly identical. It will also need the dedicated 6350 function, so update its phylink_get_caps as well. Fixes: de5c9bf40c45 ("net: phylink: require supported_interfaces to be filled") Signed-off-by: Greg Ungerer --- drivers/net/dsa/mv88e6xxx/chip.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 42b1acaca33a..e9adf9711c09 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -577,6 +577,18 @@ static void mv88e6250_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100; } +static void mv88e6350_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, + struct phylink_config *config) +{ + unsigned long *supported = config->supported_interfaces; + + /* Translate the default cmode */ + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); + + config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | + MAC_1000FD; +} + static int mv88e6352_get_port4_serdes_cmode(struct mv88e6xxx_chip *chip) { u16 reg, val; @@ -5069,7 +5081,7 @@ static const struct mv88e6xxx_ops mv88e6350_ops = { .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, .stu_getnext = mv88e6352_g1_stu_getnext, .stu_loadpurge = mv88e6352_g1_stu_loadpurge, - .phylink_get_caps = mv88e6185_phylink_get_caps, + .phylink_get_caps = mv88e6350_phylink_get_caps, }; static const struct mv88e6xxx_ops mv88e6351_ops = { @@ -5117,7 +5129,7 @@ static const struct mv88e6xxx_ops mv88e6351_ops = { .stu_loadpurge = mv88e6352_g1_stu_loadpurge, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops, - .phylink_get_caps = mv88e6185_phylink_get_caps, + .phylink_get_caps = mv88e6350_phylink_get_caps, }; static const struct mv88e6xxx_ops mv88e6352_ops = { From patchwork Wed Nov 22 13:21:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 13464868 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ABF204D12B for ; Wed, 22 Nov 2023 13:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="awyxEGm0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC640C433C8; Wed, 22 Nov 2023 13:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700659290; bh=p2IYNSEdkepQ863Rvue+YZ3H/BoxsnDcf0ABUSyrJzU=; h=From:To:Cc:Subject:Date:From; b=awyxEGm02x/i8JJmzbOhY0NgNl1aIiBqWXBhOwJfMJCDR5Llxfkg7ZPHspsoy0Qee rgpiLBa1weE0y1c3pfSIvRbzQCn/AUtt547wqMPC2NJnf9YkWfamxR8R+zXPl25Zud tYA5WdetbizLbysADEhEUByE+WHYCBMn2o2+7cFUr3NcBE61zvCqG3FZZ3QtM75G9G 0A6C/oxisgpBKh0lUE4wneZrYyfZmB6sBOtwoKs3mAwrK4l9084fdjyYZFqx6xvunI 37JZAP7B7HH3jTv01EEab6G3HMRo5Zq1S7h3pbf+madcF8XfiiVM75Ueh9gthlvXt9 IeZ1DOpD25RMw== From: Greg Ungerer To: rmk+kernel@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, Greg Ungerer , Russell King Subject: [PATCH 2/2] net: dsa: mv88e6xxx: fix marvell 6350 probe crash Date: Wed, 22 Nov 2023 23:21:16 +1000 Message-Id: <20231122132116.2180473-1-gerg@kernel.org> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org As of commit b92143d4420f ("net: dsa: mv88e6xxx: add infrastructure for phylink_pcs") probing of a Marvell 88e6350 switch causes a NULL pointer dereference like this example: ... mv88e6085 d0072004.mdio-mii:11: switch 0x3710 detected: Marvell 88E6350, revision 2 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000000 when read [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] ARM Modules linked in: CPU: 0 PID: 8 Comm: kworker/u2:0 Not tainted 6.7.0-rc2-dirty #26 Hardware name: Marvell Armada 370/XP (Device Tree) Workqueue: events_unbound deferred_probe_work_func PC is at mv88e6xxx_port_setup+0x1c/0x44 LR is at dsa_port_devlink_setup+0x74/0x154 pc : [] lr : [] psr: a0000013 sp : c184fce0 ip : c542b8f4 fp : 00000000 r10: 00000001 r9 : c542a540 r8 : c542bc00 r7 : c542b838 r6 : c5244580 r5 : 00000005 r4 : c5244580 r3 : 00000000 r2 : c542b840 r1 : 00000005 r0 : c1a02040 ... The Marvell 88e6350 switch has no SERDES interface and so has no corresponding pcs_ops defined for it. But during probing a call is made to mv88e6xxx_port_setup() which unconditionally expects pcs_ops to exist, though the presence of the pcs_ops->pcs_init function is optional. Modify the code to check for pcs_ops first, before checking for and calling pcs_ops->pcs_init. Fixes: b92143d4420f ("net: dsa: mv88e6xxx: add infrastructure for phylink_pcs") Suggested-by: Russell King (Oracle) Signed-off-by: Greg Ungerer --- drivers/net/dsa/mv88e6xxx/chip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index e9adf9711c09..38f76ee3035b 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3892,7 +3892,8 @@ static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port) struct mv88e6xxx_chip *chip = ds->priv; int err; - if (chip->info->ops->pcs_ops->pcs_init) { + if (chip->info->ops->pcs_ops && + chip->info->ops->pcs_ops->pcs_init) { err = chip->info->ops->pcs_ops->pcs_init(chip, port); if (err) return err;