Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2894110pxb; Tue, 24 Aug 2021 10:02:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX1MJAfd1OjJ0dbaIlb/3DxPtxey9PPQukmIHxw5OF1cwx23RIgN2+zUiUGzhz2+1cgX4h X-Received: by 2002:a92:c90a:: with SMTP id t10mr28693593ilp.188.1629824572633; Tue, 24 Aug 2021 10:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824572; cv=none; d=google.com; s=arc-20160816; b=afnSadcjb73BN5lPZ9Ss5AkoeRxTHP1UU6S0aoIHPZcJgtBZQbln+QMkUCFYrvbN+g YYHdqBtNCrvh+sm8nzRwYZ3AmN1D4rmRFjVa7yq+hCirPdfYxMnYPLhizpetxyUVREWv CJ0WGADhh1rl1Y4o9/rpRUxnvdJLYksEDQKW8L3NwhJCUeGubFAQ/cca/AyIbVRtoPtc V4XOUMLkaFj2ZZeHGZrHh8MfAlKPNSZ1PoOPnktsQNnOrok8yuAfZAFQ9aYVR46rBnB4 SVDGlb28ejbwWB1bsU8zeh6UpcdINB/iG+Kjo+VFobKq91xwRGwxch1kRBdjqzvyYanR aR6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9vzP14CtGDU0J/qTy0KaWge6XB1Gfk3SPz1l4HRzz7w=; b=h51OBXcgi+af104wKa6fSaIqS1NT20vyL6yd7z9QBZyC+ORkZAJ5g9d41Ptou5PcRY mxNxL/WeX2VUCEpbyBMtN0gYk7L1YUN03UCWBPYDMzfY6BmwYK9+SRsyWQ+ARLNydD9+ Tbge5Q0I7SMLaqK1IniO7HSyJYNoaiInJwZVop3NLJMXX50dmBYvJVp+v24AotlOULga XwUX/2lgGvbRTRFFpWj9Ni6nmcI4snEVRbHEZnTk1Q7vQ7g41iyAxODV8sCPmktWCqSj BitI7Dt4f+fo/5R3RVQSusEXChATHzkaolaIA5QFiaJ4UbKvjZSQbSpYcAwY9CYLYgx3 PmmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iy8A4hwh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si17741440ilq.58.2021.08.24.10.02.30; Tue, 24 Aug 2021 10:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iy8A4hwh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238631AbhHXRC3 (ORCPT + 99 others); Tue, 24 Aug 2021 13:02:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238897AbhHXQ7M (ORCPT ); Tue, 24 Aug 2021 12:59:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 259446142A; Tue, 24 Aug 2021 16:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824251; bh=bNXmRj4lhQHqq3AH5PhKAvWbdLxKyLKJmVnBVcs8F0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iy8A4hwh3RWqZ3Ha87A3Y9KqyRWbwedzyZf4hHQnD1bccrH0T+2XCtHwimFUzP7ie ZTur7FR1D3sQBh/wKwUv3FT03GhkZmNgJ3jMBWgl6QBMhYjPbXySmlqH7vnhSCqaSL X4ziUxUqCdQVGPj4ueeg2Vrvk2j2DGCrOcqQ753gBrNS1NaSSDU5YX4kOLQFrHxRl/ +wi788Ea8jremSBL9ar0gMtk+qmh6vIZEzGs+QQqHak2/rLR6v6dvXoR+34+1hSz+0 txfIhB1fg6KnuHAPYo/tjnhZRKF60dN8IKXYi/WBeKeMcaFoJDppqAbLWp54MzO2pi 7WJr2bQIfkvmw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vladimir Oltean , Ioana Ciornei , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.13 084/127] net: dpaa2-switch: disable the control interface on error path Date: Tue, 24 Aug 2021 12:55:24 -0400 Message-Id: <20210824165607.709387-85-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165607.709387-1-sashal@kernel.org> References: <20210824165607.709387-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.13.13-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.13.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.13.13-rc1 X-KernelTest-Deadline: 2021-08-26T16:55+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit cd0a719fbd702eb4b455a6ad986483750125588a ] Currently dpaa2_switch_takedown has a funny name and does not do the opposite of dpaa2_switch_init, which makes probing fail when we need to handle an -EPROBE_DEFER. A sketch of what dpaa2_switch_init does: dpsw_open dpaa2_switch_detect_features dpsw_reset for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { dpsw_if_disable dpsw_if_set_stp dpsw_vlan_remove_if_untagged dpsw_if_set_tci dpsw_vlan_remove_if } dpsw_vlan_remove alloc_ordered_workqueue dpsw_fdb_remove dpaa2_switch_ctrl_if_setup When dpaa2_switch_takedown is called from the error path of dpaa2_switch_probe(), the control interface, enabled by dpaa2_switch_ctrl_if_setup from dpaa2_switch_init, remains enabled, because dpaa2_switch_takedown does not call dpaa2_switch_ctrl_if_teardown. Since dpaa2_switch_probe might fail due to EPROBE_DEFER of a PHY, this means that a second probe of the driver will happen with the control interface directly enabled. This will trigger a second error: [ 93.273528] fsl_dpaa2_switch dpsw.0: dpsw_ctrl_if_set_pools() failed [ 93.281966] fsl_dpaa2_switch dpsw.0: fsl_mc_driver_probe failed: -13 [ 93.288323] fsl_dpaa2_switch: probe of dpsw.0 failed with error -13 Which if we investigate the /dev/dpaa2_mc_console log, we find out is caused by: [E, ctrl_if_set_pools:2211, DPMNG] ctrl_if must be disabled So make dpaa2_switch_takedown do the opposite of dpaa2_switch_init (in reasonable limits, no reason to change STP state, re-add VLANs etc), and rename it to something more conventional, like dpaa2_switch_teardown. Fixes: 613c0a5810b7 ("staging: dpaa2-switch: enable the control interface") Signed-off-by: Vladimir Oltean Reviewed-by: Ioana Ciornei Link: https://lore.kernel.org/r/20210819141755.1931423-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 87321b7239cf..58964d22cb17 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -3038,26 +3038,30 @@ static int dpaa2_switch_port_init(struct ethsw_port_priv *port_priv, u16 port) return err; } -static void dpaa2_switch_takedown(struct fsl_mc_device *sw_dev) +static void dpaa2_switch_ctrl_if_teardown(struct ethsw_core *ethsw) +{ + dpsw_ctrl_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); + dpaa2_switch_free_dpio(ethsw); + dpaa2_switch_destroy_rings(ethsw); + dpaa2_switch_drain_bp(ethsw); + dpaa2_switch_free_dpbp(ethsw); +} + +static void dpaa2_switch_teardown(struct fsl_mc_device *sw_dev) { struct device *dev = &sw_dev->dev; struct ethsw_core *ethsw = dev_get_drvdata(dev); int err; + dpaa2_switch_ctrl_if_teardown(ethsw); + + destroy_workqueue(ethsw->workqueue); + err = dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); if (err) dev_warn(dev, "dpsw_close err %d\n", err); } -static void dpaa2_switch_ctrl_if_teardown(struct ethsw_core *ethsw) -{ - dpsw_ctrl_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); - dpaa2_switch_free_dpio(ethsw); - dpaa2_switch_destroy_rings(ethsw); - dpaa2_switch_drain_bp(ethsw); - dpaa2_switch_free_dpbp(ethsw); -} - static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev) { struct ethsw_port_priv *port_priv; @@ -3068,8 +3072,6 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev) dev = &sw_dev->dev; ethsw = dev_get_drvdata(dev); - dpaa2_switch_ctrl_if_teardown(ethsw); - dpaa2_switch_teardown_irqs(sw_dev); dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); @@ -3084,9 +3086,7 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev) kfree(ethsw->acls); kfree(ethsw->ports); - dpaa2_switch_takedown(sw_dev); - - destroy_workqueue(ethsw->workqueue); + dpaa2_switch_teardown(sw_dev); fsl_mc_portal_free(ethsw->mc_io); @@ -3199,7 +3199,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev) GFP_KERNEL); if (!(ethsw->ports)) { err = -ENOMEM; - goto err_takedown; + goto err_teardown; } ethsw->fdbs = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->fdbs), @@ -3270,8 +3270,8 @@ err_free_fdbs: err_free_ports: kfree(ethsw->ports); -err_takedown: - dpaa2_switch_takedown(sw_dev); +err_teardown: + dpaa2_switch_teardown(sw_dev); err_free_cmdport: fsl_mc_portal_free(ethsw->mc_io); -- 2.30.2