Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2354080pxb; Mon, 20 Sep 2021 19:53:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwEU4laTk6+pGmlBqwcJ9auEfiDBEaMB208bcB5lku88GtZ6bwOz6ZGAaXkOTLt186Nhwu X-Received: by 2002:a05:6e02:1c0d:: with SMTP id l13mr13104553ilh.7.1632192789751; Mon, 20 Sep 2021 19:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192789; cv=none; d=google.com; s=arc-20160816; b=r+u0P56YjCsbA6oIj+lDVgzAhQYIzjbHtC3HIom95GzlHxM/KnX6InoHBE2OoGfhi/ vg2FlWa+Lqj/f/xP3WJbK5UWBoqcvDWCOY12SRpQ6UXcIwE3/inqfDqvPFEz3JNsUSbt T372HWBfKP546zEid7CCtvAQOLqQOrHcfor0bRanP0FpLlx4emWGGsJxa0IS77YKtcuW dE3opKR8NxZeZ87wE9I9+Nk2CtcJMMcSGeNeoOEVjZO0NVEPN/vf6/lfvmxoW/+wZwoU Ax7XgDa+fhBld9wa3vI3W4VtWOdQ6Mm5JT/cpv54dO0XvEVdvgJFIIIiQ9thSJELL4bi 4gHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/z7AtFK6g5onAt5g6t2gfyD1gigEB0nFe3IfSc/U3zc=; b=BHV+VuAiS43ZG3EX8N/pUwEvCVKvrt9nStD/Uz0Q5h+llo2GdDK17BWE9zNXpR/38l lmqJluigYEfNDqPylN+5/NcJyc9pbhmHVBg92o01gbktiRlefWnFatrU1UKtO1+w1+5Y 44wtDDPFvuVG1ZPfAGbR3Mk/S0abcaxK5Ovi1d0VBcLFZijyMKRqoyy90QmqWArl17Ec BJaKqolttys7QLJ0lrBQxja/dW8sOYUZ6mMLSolW+7h1I7l8Q9172lC5SYNA+sm1CQYu py6POtvnt7MWohnaIJ2+CMFt17biyua5nSMR3ffjDQ/OdJQ7cijyIh3FkRCm40vel9X3 kdhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=isVtX6Ix; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si13422423ilr.112.2021.09.20.19.52.58; Mon, 20 Sep 2021 19:53:09 -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=@linuxfoundation.org header.s=korg header.b=isVtX6Ix; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387293AbhITS5D (ORCPT + 99 others); Mon, 20 Sep 2021 14:57:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:37126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385369AbhITSuZ (ORCPT ); Mon, 20 Sep 2021 14:50:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 804FA61B1C; Mon, 20 Sep 2021 17:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159268; bh=e5zN7kEmjEjUYhAYXZyvyA9I3ZY7VvOkjfyxZHpQbc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=isVtX6IxT3oaR0+JswVuaJc/pvsBb4DpD9mTmy8Cjx4emJ3I8cbYDn6xF4Qvz7QFA fuRIrd2TO+u9pCLpCDVqf+UJ/RJ21RTPw+B0VrLiHfbac65dNziAlafq8YIMLPBjgj DGHLHRPuWC76v7ekl2zibwJjQL0RQonuQmgbsnm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 153/168] net: dsa: b53: Set correct number of ports in the DSA struct Date: Mon, 20 Sep 2021 18:44:51 +0200 Message-Id: <20210920163926.698406949@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafał Miłecki [ Upstream commit d12e1c4649883e8ca5e8ff341e1948b3b6313259 ] Setting DSA_MAX_PORTS caused DSA to call b53 callbacks (e.g. b53_disable_port() during dsa_register_switch()) for invalid (non-existent) ports. That made b53 modify unrelated registers and is one of reasons for a broken BCM5301x support. This problem exists for years but DSA_MAX_PORTS usage has changed few times. It seems the most accurate to reference commit dropping dsa_switch_alloc() in the Fixes tag. Fixes: 7e99e3470172 ("net: dsa: remove dsa_switch_alloc helper") Signed-off-by: Rafał Miłecki Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/b53/b53_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index dcf9d7e5ae14..5646eb8afe38 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2615,6 +2615,8 @@ static int b53_switch_init(struct b53_device *dev) dev->enabled_ports |= BIT(dev->cpu_port); dev->num_ports = fls(dev->enabled_ports); + dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS); + /* Include non standard CPU port built-in PHYs to be probed */ if (is539x(dev) || is531x5(dev)) { for (i = 0; i < dev->num_ports; i++) { @@ -2659,7 +2661,6 @@ struct b53_device *b53_switch_alloc(struct device *base, return NULL; ds->dev = base; - ds->num_ports = DSA_MAX_PORTS; dev = devm_kzalloc(base, sizeof(*dev), GFP_KERNEL); if (!dev) -- 2.30.2