From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 792A8C2BB3F for ; Sat, 18 Nov 2023 14:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WepOBgGYhP2iPHXfLSJdrtcP/KdijGX4DDw5TtExb38=; b=1q2ErUUxZnZCqOkH9SwWVZjUnF HSnjtzo8hVGvDZ7lSAU2WIypUQD4fdzZ6yXVFisc/rAVFd7AF3dQiH2/GXlB7AtTjxxWN72frmyaf xcOqaFZcoruG+qMs9MirxlsDQzG+IjEwrbcpMVYaGU41c7S5V6FYgdsiDZzrwwEejmVrOUfZWpg3i Z8S8VSpCsadYXB859NN1xqGY4OMEW4l+r6143R6n6pFiUWnPvyOLZ8I5rgm1MVgchy9wt29HJM1tO 1Fpq1J5X/Ssy5wBn/V6Eq5hsfA5fmFGkzG0oFdQk6e2KXJ4Ir9yswzG+O3bv8QO/e+41k39kebyoG Mht9yjww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r4MRq-008eyu-0f; Sat, 18 Nov 2023 14:37:26 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r4MRl-008epb-0e; Sat, 18 Nov 2023 14:37:23 +0000 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==?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231118_063721_264620_4E107EA0 X-CRM114-Status: GOOD ( 14.61 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Landen Chao , Florian Fainelli , erkin.bozoglu@xeront.com, netdev@vger.kernel.org, Sean Wang , Daniel Golle , linux-kernel@vger.kernel.org, DENG Qingfang , Eric Dumazet , Paolo Abeni , linux-mediatek@lists.infradead.org, Bartel Eerdekens , Matthias Brugger , Jakub Kicinski , Vladimir Oltean , mithat.guner@xeront.com, "David S. Miller" , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org 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! From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43916C2BB3F for ; Sat, 18 Nov 2023 14:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To: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-Owner; bh=OxijP2BcBuG4HQiHicGtzm06uiEc710oaZ6QoSNhDOs=; b=WploVo5/6YJJfn xS6Cl89tslbtQBYEme/Qt+TNSsGzA64e39/UNlfLHt9gri3mSjExp6qKy0ByvEiG9rHynxW5hDHNJ khlOLMFs/MPzwn7r+6WBHiBKRM8ofW1do2BnURcjYEGp5B/JzY5bWnkSAaBvkpbFcyI29qLY0/yUW Jz8RlD8aA2kyVjyELK5VP3UEMoR56hto14fyJzzYoxV7l0oogU94bMcRY3K2mIVc7TVKfH/4i9J9c 7T0niIol/e+zYvE3H1gnE25mHMXexJsnw1uAcTEMZKfluF5lBhYLbutIPq1rVZ/hWuIZ5gUTBGyAT ateKVUp+K3Yto0k82s1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r4MRp-008eyo-2M; Sat, 18 Nov 2023 14:37:25 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r4MRl-008epb-0e; Sat, 18 Nov 2023 14:37:23 +0000 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-Disposition: inline In-Reply-To: <20231118123205.266819-2-arinc.unal@arinc9.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231118_063721_264620_4E107EA0 X-CRM114-Status: GOOD ( 14.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org T24gU2F0LCBOb3YgMTgsIDIwMjMgYXQgMDM6MzE6NTFQTSArMDMwMCwgQXLEsW7DpyDDnE5BTCB3 cm90ZToKPiArCS8qIFNldCB0aGUgQ1BVIHBvcnQgdG8gdHJhcCBmcmFtZXMgdG8gZm9yIE1UNzUz MC4gVHJhcHBlZCBmcmFtZXMgd2lsbCBiZQo+ICsJICogZm9yd2FyZGVkIHRvIHRoZSBudW1lcmlj YWxseSBzbWFsbGVzdCBDUFUgcG9ydCB3aGljaCB0aGUgRFNBIGNvbmR1aXQKPiArCSAqIGludGVy ZmFjZSBpdHMgYWZmaW5lIHRvIGlzIHVwLgo+ICsJICovCj4gKwlpZiAocHJpdi0+aWQgIT0gSURf TVQ3NTMwICYmIHByaXYtPmlkICE9IElEX01UNzYyMSkKPiArCQlyZXR1cm47Cj4gKwo+ICsJaWYg KG9wZXJhdGlvbmFsKQo+ICsJCXByaXYtPmFjdGl2ZV9jcHVfcG9ydHMgfD0gQklUKGNwdV9kcC0+ aW5kZXgpOwo+ICsJZWxzZQo+ICsJCXByaXYtPmFjdGl2ZV9jcHVfcG9ydHMgJj0gfkJJVChjcHVf ZHAtPmluZGV4KTsKPiArCj4gKwlpZiAocHJpdi0+YWN0aXZlX2NwdV9wb3J0cykKPiArCQltdDc1 MzBfcm13KHByaXYsIE1UNzUzMF9NRkMsIENQVV9FTiB8IENQVV9QT1JUX01BU0ssIENQVV9FTiB8 Cj4gKwkJCSAgIENQVV9QT1JUKF9fZmZzKHByaXYtPmFjdGl2ZV9jcHVfcG9ydHMpKSk7CgpJIHdv dWxkIGJlIHRlbXB0ZWQgdG8gd3JpdGUgdGhpcyBhczoKCgltYXNrID0gQklUKGNwdV9kcC0+aW5k ZXgpOwoKCWlmIChvcGVyYXRpb25hbCkKCQlwcml2LT5hY3RpdmVfY3B1X3BvcnRzIHw9IG1hc2s7 CgllbHNlCgkJcHJpdi0+YWN0aXZlX2NwdV9wb3J0cyAmPSB+bWFzazsKCk5vdywgd2hhdCBoYXBw ZW5zIHdoZW4gYWN0aXZlX2NwdV9wb3J0cyBpcyB6ZXJvPyBEb2Vzbid0IHRoYXQgbWVhbiB0aGVy ZQppcyBubyBhY3RpdmUgQ1BVIHBvcnQ/IEluIHdoaWNoIGNhc2UsIHdvdWxkbid0IGRpc2FibGlu ZyB0aGUgQ1BVIHBvcnQKZGlyZWN0aW9uIGJlIGFwcHJvcHJpYXRlLCBzdWNoIGFzOgoKCWlmIChw cml2LT5hY3RpdmVfY3B1X3BvcnRzKQoJCXZhbCA9IENQVV9FTiB8IENQVV9QT1JUKF9fZmZzKHBy aXYtPmFjdGl2ZV9jcHVfcG9ydHMpKTsKCWVsc2UKCQl2YWwgPSAwOwoKCW10NzUzMF9ybXcocHJp diwgTVQ3NTMwX01GQywgQ1BVX0VOIHwgQ1BVX1BPUlRfTUFTSywgdmFsKTsJCgo/Cgo+ICBzdHJ1 Y3QgbXQ3NTMwX3ByaXYgewo+ICAJc3RydWN0IGRldmljZQkJKmRldjsKPiBAQCAtNzg2LDYgKzc4 Nyw3IEBAIHN0cnVjdCBtdDc1MzBfcHJpdiB7Cj4gIAlzdHJ1Y3QgaXJxX2RvbWFpbiAqaXJxX2Rv bWFpbjsKPiAgCXUzMiBpcnFfZW5hYmxlOwo+ICAJaW50ICgqY3JlYXRlX3NnbWlpKShzdHJ1Y3Qg bXQ3NTMwX3ByaXYgKnByaXYsIGJvb2wgZHVhbF9zZ21paSk7Cj4gKwl1bnNpZ25lZCBsb25nIGFj dGl2ZV9jcHVfcG9ydHM7CgpTbyB0aGlzIHdpbGwgYmUgMzIgb3IgNjQgYml0IGluIHNpemUuIFBy ZXN1bWFibHkgeW91IGtub3cgaG93IG1hbnkgQ1BVCnBvcnRzIHRoZXJlIGNhbiBiZSwgd2hpY2gg bG9va2luZyBhdCB0aGlzIGNvZGUgbXVzdCBiZSBsZXNzIHRoYW4gOCBhcwpDUFVfUE9SVF9NQVNL IGlzIG9ubHkgMyBiaXRzIGluIHNpemUuIFNvLCBtYXliZSB1c2UgYSB1OCwgYW5kIGNoZWNrCnRo YXQgY3B1X2RwLT5pbmRleCA8PSA3ID8KCkkgd291bGQgYWxzbyBzdWdnZXN0IG1vdmluZyBpcnFf ZW5hYmxlIGFmdGVyIGNyZWF0ZV9zZ21paSwgdG8gYXZvaWQKaG9sZXMgaW4gdGhlIHN0cnVjdC4K Ci0tIApSTUsncyBQYXRjaCBzeXN0ZW06IGh0dHBzOi8vd3d3LmFybWxpbnV4Lm9yZy51ay9kZXZl bG9wZXIvcGF0Y2hlcy8KRlRUUCBpcyBoZXJlISA4ME1icHMgZG93biAxME1icHMgdXAuIERlY2Vu dCBjb25uZWN0aXZpdHkgYXQgbGFzdCEKCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fCmxpbnV4LWFybS1rZXJuZWwgbWFpbGluZyBsaXN0CmxpbnV4LWFybS1r ZXJuZWxAbGlzdHMuaW5mcmFkZWFkLm9yZwpodHRwOi8vbGlzdHMuaW5mcmFkZWFkLm9yZy9tYWls bWFuL2xpc3RpbmZvL2xpbnV4LWFybS1rZXJuZWwK From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 806A8C2BB3F for ; Sat, 18 Nov 2023 14:35:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbjKROfW (ORCPT ); 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!