Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp725048ybg; Tue, 28 Jul 2020 17:54:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZJAbDnaW1kphzZUbv0mNuTb+vr5jc2+4Nw9qp7VcrkldxDSGK8dPXIFvTO8J4bxdqQejR X-Received: by 2002:a17:906:1a54:: with SMTP id j20mr4560952ejf.102.1595984085485; Tue, 28 Jul 2020 17:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595984085; cv=none; d=google.com; s=arc-20160816; b=vsrA1RvZb6G6Jx2KHs5GNdg8cMBQxjNaohbh3p7in7AdJsUB9R/LuQN36DI9DfOwog UKoFfe5KrFVkHIchdzQVVleuBlzE1c9LzYgOiVIxU7UyIORWvMwW2PAF9Pxz1o46JELA tGDeQhpX+vdG59/AUo9dEnOMST7mbu+LpJE0YJy7RMwgwgDwUosWzXkLBSgQWBnND0We RYq4/5zdhwmNEPpi4bl6NiHBmf5qAlHMJqnzvW8LU/mUeMIGALXvSKVrUAAqFAgc8XwH LPg8E9hdNsrKERop7qQNqbRM592rJH6DEC9IG5p7toDbfzq7yqoes1WtLWKmTWqLB7gW JYWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=09VTNEHM4jI+84AUC899JQAVzf4WOs3318b4QtLm0Pw=; b=ZcfofsiLw1Cl6xv91jISJxGANqidwLQDGdl/pxs/oeZ7ucqWHd3P/9BVADfQUBvKG2 YrrChNfe/idt7uCEAkzjPwJzMBXS/2fLUN7bkJBr0hXo1TB6i3mRUyrjkwCs9cJUkSnC Mmhf3PxEpClEO8Y4f0cMfHxVonfHD2GtlOOEsGBSieiatvTb3dCKIW+fQRLRwptTeyxh xknzW9niyF1aF6KqqKSsoRRh86JieN/vuYQgGBii0MhBW5q+U7oln2oJd2kVmEtQX+uo O+ZLtbQvpHFXsJJ4jjnBd4KZQaFGuAHNu2nLgEDYfTHWBtSGV7oYWobdRPxfcPDcF5dw riXw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c21si89135ejm.385.2020.07.28.17.54.22; Tue, 28 Jul 2020 17:54:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731001AbgG2AwG (ORCPT + 99 others); Tue, 28 Jul 2020 20:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730869AbgG2AwE (ORCPT ); Tue, 28 Jul 2020 20:52:04 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BDEEC061794; Tue, 28 Jul 2020 17:52:04 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 78B0D128D74D3; Tue, 28 Jul 2020 17:35:18 -0700 (PDT) Date: Tue, 28 Jul 2020 17:52:02 -0700 (PDT) Message-Id: <20200728.175202.598794850221205861.davem@davemloft.net> To: Jisheng.Zhang@synaptics.com Cc: thomas.petazzoni@bootlin.com, kuba@kernel.org, linux@armlinux.org.uk, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-nex 2/2] net: mvneta: Don't speed down the PHY when changing mtu From: David Miller In-Reply-To: <20200727195314.704dfaed@xhacker.debian> References: <20200727195012.4bcd069d@xhacker.debian> <20200727195314.704dfaed@xhacker.debian> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 28 Jul 2020 17:35:18 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang Date: Mon, 27 Jul 2020 19:53:14 +0800 > @@ -3651,7 +3651,8 @@ static void mvneta_stop_dev(struct mvneta_port *pp) > > set_bit(__MVNETA_DOWN, &pp->state); > > - if (device_may_wakeup(&pp->dev->dev)) > + if (device_may_wakeup(&pp->dev->dev) && > + pp->pkt_size == MVNETA_RX_PKT_SIZE(pp->dev->mtu)) > phylink_speed_down(pp->phylink, false); > This is too much for me. You shouldn't have to shut down the entire device and take it back up again just to change the MTU. Unfortunately, this is a common pattern in many drivers and it is very dangerous to take this lazy path of just doing "stop/start" around the MTU change. It means you can't recover from partial failures properly, f.e. recovering from an inability to allocate queue resources for the new MTU. To solve this properly, you must restructure the MTU change such that is specifically stops the necessary and only the units of the chip necessary to change the MTU. It should next try to allocate the necessary resources to satisfy the MTU change, keeping the existing resources allocated in case of failure. Then, only is all resources are successfully allocated, it should commit the MTU change fully and without errors. Then none of these link flapping issues are even possible.