From patchwork Mon Jul 24 16:37:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9859797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 029B2601A1 for ; Mon, 24 Jul 2017 16:37:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7C1827F4B for ; Mon, 24 Jul 2017 16:37:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBE4128573; Mon, 24 Jul 2017 16:37:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA8D527F4B for ; Mon, 24 Jul 2017 16:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OzAF7L/hV49laVoIp8dCJ8U+YJcm4B8cOAd3iUxBNv8=; b=hh52AwP+zJxd+8 x3VjV1ni97nR0KXnVBx+qeLbOaDlqvCiq6evEUQ+HgrHmOfW8J1eShsm01z3CTDdlFwCIab/qSmmr KbjqiH4ycxlsSyh83IFwdabU5kl/lQUwrVaZEUSWYdXSF/aFZwkufLlTV6OtELGYVo2jmY9EO4N04 jIZuuyRJ2RXoofUdoMUPRdeowxGXRLbLH+872k6UrilFH9+e8XnfGYphr6DroWO4Py1OoNjNgZfbq toshBBF300Mpv4biE+5la39JyIl/BDcsPkQHK5u3D8FySLKUK2OJCf2EOZKcpROvGrWWdT9H7hCMD UrmGTeaBEK+dywzW9lfg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dZgMc-0008QI-Bm; Mon, 24 Jul 2017 16:37:46 +0000 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dZgMT-000824-8m for linux-mediatek@lists.infradead.org; Mon, 24 Jul 2017 16:37:43 +0000 Received: by mail-qk0-x241.google.com with SMTP id q66so10383050qki.1 for ; Mon, 24 Jul 2017 09:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=M6bytD+BRG4txWUMc/6qb6akZAjuNvsdmuW1tDGNfkc=; b=p3oOvQ/w1ndpYzOq07WARHphD9PXbg2KXtQ6kGJOfj0di3bY0calp4xy8CffdFa+94 n80ZZ45Ot8iJ6q2e2Yj/m0nzIJPQKdAsBQQRkyZMnBTHYoTw9e8vWKMFrgfb3zzEygm8 f4YYi8C+NNPPcJ//xydD0msFz8h2/bxyjOccXOyg7fS3JehCCNsKSPp6VkW6XX1rxtl0 W8+XoX4Xpu+icH6VVEyxhmCLlWW5tazB3Du7/fTgWwnVyD0eXZgiQJkoCTJTXWLEmq8v ynS8Oo8JWILd6hpnFOTFadOP7rjz63/t+/vRa39imHazHvf4LaMpkrLTQoG4v1jhidPt gMZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=M6bytD+BRG4txWUMc/6qb6akZAjuNvsdmuW1tDGNfkc=; b=tGWNhePu1pBAKklDgGejdI2g2G0IIqIHtZtNvFedUelUMWSeDgSHCi4NDZaDKoYgsJ R1Wa+x0wXXNrwioYVc3cM2GjRtNiMPhkmPVyesPr7HyXmYFVFJzQe9rLIElCFYaAcfPz hkDmSUgvqycxCsWyVXSf52t2/svUwJL7I8gRkZ0eYOQ1ruquyASdZ0XpwTXy+r/M4C1b P1/PvPRwZJEsm9BOnRtBCsDDL+9nK+uiEs2OVPpcCBGn1cH4vpNnsk0R9Wl+3ek5SrvB g0v5TOUkIlfnOeFcCAqP9pwMw3FJo04QUhHaYQxxjQtwbnKFj/yCsEDoVzfEPhfwg1LU InqA== X-Gm-Message-State: AIVw110hv2FttvJKYlukLZ7nIfJbHS7D5O2De/mCA7l/RiyXJcnPpH/C IRIrYQKJRa0Kz45Otq4= X-Received: by 10.55.180.198 with SMTP id d189mr19418379qkf.103.1500914235207; Mon, 24 Jul 2017 09:37:15 -0700 (PDT) Received: from [10.112.156.244] ([192.19.255.250]) by smtp.googlemail.com with ESMTPSA id n8sm8878995qtc.5.2017.07.24.09.37.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 09:37:14 -0700 (PDT) Subject: Re: [PATCH] net: dsa: fixup fail to get tag in mtk_get_tag_protocol To: sean.wang@mediatek.com, davem@davemloft.net, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com References: <77d2e1bb09314a27a08d02dec9ec62e217b2b9d6.1500908869.git.sean.wang@mediatek.com> From: Florian Fainelli Message-ID: <557d5c4b-118d-034f-5580-b57b06126965@gmail.com> Date: Mon, 24 Jul 2017 09:37:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <77d2e1bb09314a27a08d02dec9ec62e217b2b9d6.1500908869.git.sean.wang@mediatek.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170724_093739_020931_3DCC0BE5 X-CRM114-Status: GOOD ( 15.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 07/24/2017 08:14 AM, sean.wang@mediatek.com wrote: > From: Sean Wang > > dsa_is_cpu_port() checking ds->cpu_port_mask is not available in > ds->ops->get_tag_protocol > > Since commit 14be36c2c96c ("net: dsa: Initialize all CPU and enabled > ports masks in dsa_ds_parse()") So force returning DSA_TAG_PROTO_MTK > inside mtk_get_tag_protocol call after that. So a better fix could look like this then: > > Cc: Florian Fainelli > Signed-off-by: Sean Wang > --- > drivers/net/dsa/mt7530.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c > index 1e46418..c265e7e 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -892,15 +892,7 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port, > static enum dsa_tag_protocol > mtk_get_tag_protocol(struct dsa_switch *ds) > { > - struct mt7530_priv *priv = ds->priv; > - > - if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) { > - dev_warn(priv->dev, > - "port not matched with tagging CPU port\n"); > - return DSA_TAG_PROTO_NONE; > - } else { > - return DSA_TAG_PROTO_MTK; > - } > + return DSA_TAG_PROTO_MTK; > } > > static int > diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 56e46090526b..c442051d5a55 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -509,21 +509,22 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, dst->cpu_dp->netdev = ethernet_dev; } + /* Initialize cpu_port_mask now for drv->setup() + * to have access to a correct value, just like what + * net/dsa/dsa.c::dsa_switch_setup_one does. + */ + ds->cpu_port_mask |= BIT(index); + tag_protocol = ds->ops->get_tag_protocol(ds); dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); if (IS_ERR(dst->tag_ops)) { dev_warn(ds->dev, "No tagger for this switch\n"); + ds->cpu_port_mask &= ~BIT(index); return PTR_ERR(dst->tag_ops); } dst->rcv = dst->tag_ops->rcv; - /* Initialize cpu_port_mask now for drv->setup() - * to have access to a correct value, just like what - * net/dsa/dsa.c::dsa_switch_setup_one does. - */ - ds->cpu_port_mask |= BIT(index); - return 0; }