Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2352462pxb; Mon, 20 Sep 2021 19:49:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhhRuDQozf34qNsSL8bIsZrfIUw/lfNPk/oQid4WR04z6L+7AZVpqfdTIuimibBs0DHPok X-Received: by 2002:a17:906:e0d8:: with SMTP id gl24mr32263852ejb.413.1632192578242; Mon, 20 Sep 2021 19:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192578; cv=none; d=google.com; s=arc-20160816; b=XEKgEva8LqIiSKpUzxEp+P9WGhOLvl7g+YL9406HH4RhhdwHMdCqkgH72zz/K1Up8T CcyJjhwipBRGSYc2H4fFxWkJPD0H5k41QHOIesn0NT5AdjCy5H2vXf6y4xDrGP9OY+Su hCFNwV0/s08k95WzbwnQBrGxf4kJxP+k/fYKYawlNa0OphU+L4nnC6vspXPsHaDu5jJD BtuS83wcZl6325ufcuN7rmj1CalvO2bp0ttDwzeluXpHqjFjfIMrQp7Notw0TX68Wwwv DSO5DxVwHSToEEgKyGD1nL5dAQVZuFY7Y9yZr+8qQp50RUP4SMpUZsoez2nZwZr4INwu tBlw== 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=rq/gtgTkJQ/ppYZo0qynL7yh1Lds8Y7SzwXILW8TyuU=; b=fPmj5wTFMVfN1BFC3KvqJkBzwnOt3X95EuF7JhdxBeYsc0HIb39YRYKzRABDL1hn7I ZeTRtYIGh9eqVZblzyahVNlx6mUWwYNv7VPIxd6m0TZTXbTlkKFv268r7nsCF7Rcdb1I Zfkb9kpfBHbDocwibv/vy4+GqZ8KRn8oVx3EAYY6O+/W8sXB7bjw4rlc1ZUCLJb6xhrj eHiWKy+pwQ/P6d4IUGahH6bdBs6fyPHnwUgNRd+2JGXcsOqII9C/BZSBwTejFvqlCxL6 Y6XAZCaRlXZqcG/bgvKb2ru+IpX7WnRiVxAbakD1dCSmkGRABkYSfjBJi1+DsKG9CJg9 93KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0sLm7BXu; 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 d26si1142246edx.559.2021.09.20.19.49.15; Mon, 20 Sep 2021 19:49:38 -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=0sLm7BXu; 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 S1353222AbhITSiK (ORCPT + 99 others); Mon, 20 Sep 2021 14:38:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:52160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380248AbhITSdA (ORCPT ); Mon, 20 Sep 2021 14:33:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2617063301; Mon, 20 Sep 2021 17:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158896; bh=fhAlM7tXfgfz+PJ1/No1MPOY77yCuMAL+RYKZTGWvvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0sLm7BXuej23reSCBoZBldkk8Sdy1/8JlYzshnSd7UdRMarz32z/RLxYpsKQ3Gyuc p53Md/6VJ7mtk8aYqtAkj6fzhv1urQrOyvHzCugfu1K2oV7Waa0XbNlaOhyme3Gwbb PXIa1CPz21KvpDU/mA7hlhL/gAeUUP4Bp07SfK9g= 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.10 106/122] net: dsa: b53: Set correct number of ports in the DSA struct Date: Mon, 20 Sep 2021 18:44:38 +0200 Message-Id: <20210920163919.273487205@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163915.757887582@linuxfoundation.org> References: <20210920163915.757887582@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 a8e915dd826a..54558f47b633 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2559,6 +2559,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++) { @@ -2603,7 +2605,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