Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1191561rdb; Sat, 18 Nov 2023 06:35:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/YrKfLuaq2ZR+8mZ06p1q9DGS0ZmLF94yTSq3m/lQ73MaH2b/TKmDADNtfWU9D3uajEzB X-Received: by 2002:a05:6870:ce8e:b0:1e9:ce72:35e0 with SMTP id xe14-20020a056870ce8e00b001e9ce7235e0mr2799803oab.0.1700318141537; Sat, 18 Nov 2023 06:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700318141; cv=none; d=google.com; s=arc-20160816; b=FRPnNnpBvDjeYvn64EWqWZPG3jNdlxiVjT7FL8wtiD5oiKbB7IbxOGybWgZ+Blntz2 PirQAhREQHRNTroweknJAKioReIIwDyt/cbN+++Z7Jm/VQOnJfTfydLfKKbkNONgvoSl mQVFa5KQq//M0Zri+ThwKMylz+rFPdlUpZMB+XV4heOkLkHLOMg3d+oF106JfGqn3TmR cER1y2sEuF6al5Iqyzv+lM+bGQlbz2LXZ2go/C6IwJ6ORjdNm/3hWvZcmULqdSZ0FK4e vQPt4MAueHlnMNdFmanshdf+7WiUIUaQpe+G18Ud+qzjuAcpG0G+33kHhMgtMMO7Gxql NVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WepOBgGYhP2iPHXfLSJdrtcP/KdijGX4DDw5TtExb38=; fh=Fyl4MhUCJ4e8ZZ3/mXDcga+oBOLRy7tO85qbzX3PS/Q=; b=akXaO2v+wqXP6QGZY5Mqpr/MyYqTB3W0GloJdCDKPKx253jCbSEsbFHtCtnJuCl4zd WsHGVs2/plQJvXhXTwaORG94W/gha/N/k+g0ikRebOPibqAEz1YoNFoEjekmLTZpk+TD cLvJTonhxPrRr2Tr/acEEOB1PIfJ5bQ2lgYkc0X15EX+87EWPDib0x4IE3PcLvVvk2jw 8ook4BlAa/ZaZmyMsnABlHMoMfK77sEZZ+uJorA+FmQixyYVdfOu+oRZVgAEhagpHt/V KzVRdCaYNWT+yXqFnc0pz+O+ohdKo3BG7lZULOpSIFr9shh/ZmsyFWlXtS9xGG8WvOnp 3GuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=ICT7ys2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bw12-20020a056a02048c00b005b2d044af30si4922383pgb.480.2023.11.18.06.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 06:35:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=ICT7ys2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C5AD28077484; Sat, 18 Nov 2023 06:35:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbjKROfW (ORCPT + 99 others); Sat, 18 Nov 2023 09:35:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjKROfV (ORCPT ); Sat, 18 Nov 2023 09:35:21 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A720196; Sat, 18 Nov 2023 06:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WepOBgGYhP2iPHXfLSJdrtcP/KdijGX4DDw5TtExb38=; b=ICT7ys2yuuz5dBBplm5lRh/5RH 8DQ/wBrdoRzImt37gHrrXGZbxFIq4nQUYdnoFZ7ub45vgsKXdsFQ3WpPYIwtzRGEaFUSWs9Jl8Cft zV68Vv2CJet2uScBr/EMtq2w1ZSkE0yvexguq2PIPGaq2XB0x9Tap/3aCxuXzAYeukSpt01ru2o4w 7MdD2AzqMSjlu0CLptTCpQ3QDLr6gxqWc9v8RdDACx1Rd5uF0R/esxAjX0DldxAaJylPxhg6B5Zrm sIoACMMyxvIad3j1tCTqoAiOBFKVS9XUS8iLiGQBCNMlSfF/nFqmtOvD+TiCYUoVZk0LZZVL0CFUB y0pbCdCQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:53404) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r4MPR-0003mC-32; Sat, 18 Nov 2023 14:34:58 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r4MPP-0001Cx-B2; Sat, 18 Nov 2023 14:34:55 +0000 Date: Sat, 18 Nov 2023 14:34:55 +0000 From: "Russell King (Oracle)" To: =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= Cc: Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Frank Wunderlich , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com Subject: Re: [PATCH net-next 01/15] net: dsa: mt7530: always trap frames to active CPU port on MT7530 Message-ID: References: <20231118123205.266819-1-arinc.unal@arinc9.com> <20231118123205.266819-2-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231118123205.266819-2-arinc.unal@arinc9.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 18 Nov 2023 06:35:38 -0800 (PST) On Sat, Nov 18, 2023 at 03:31:51PM +0300, Arınç ÜNAL wrote: > + /* Set the CPU port to trap frames to for MT7530. Trapped frames will be > + * forwarded to the numerically smallest CPU port which the DSA conduit > + * interface its affine to is up. > + */ > + if (priv->id != ID_MT7530 && priv->id != ID_MT7621) > + return; > + > + if (operational) > + priv->active_cpu_ports |= BIT(cpu_dp->index); > + else > + priv->active_cpu_ports &= ~BIT(cpu_dp->index); > + > + if (priv->active_cpu_ports) > + mt7530_rmw(priv, MT7530_MFC, CPU_EN | CPU_PORT_MASK, CPU_EN | > + CPU_PORT(__ffs(priv->active_cpu_ports))); I would be tempted to write this as: mask = BIT(cpu_dp->index); if (operational) priv->active_cpu_ports |= mask; else priv->active_cpu_ports &= ~mask; Now, what happens when active_cpu_ports is zero? Doesn't that mean there is no active CPU port? In which case, wouldn't disabling the CPU port direction be appropriate, such as: if (priv->active_cpu_ports) val = CPU_EN | CPU_PORT(__ffs(priv->active_cpu_ports)); else val = 0; mt7530_rmw(priv, MT7530_MFC, CPU_EN | CPU_PORT_MASK, val); ? > struct mt7530_priv { > struct device *dev; > @@ -786,6 +787,7 @@ struct mt7530_priv { > struct irq_domain *irq_domain; > u32 irq_enable; > int (*create_sgmii)(struct mt7530_priv *priv, bool dual_sgmii); > + unsigned long active_cpu_ports; So this will be 32 or 64 bit in size. Presumably you know how many CPU ports there can be, which looking at this code must be less than 8 as CPU_PORT_MASK is only 3 bits in size. So, maybe use a u8, and check that cpu_dp->index <= 7 ? I would also suggest moving irq_enable after create_sgmii, to avoid holes in the struct. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!