Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp498759pxb; Thu, 9 Sep 2021 05:56:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoxB8v8V7rutMNlBdRV6bbG5ek1h9QMF2wXwaBSsPwXZmtf5bBEaZUYmHFUgkg1nTvkKTz X-Received: by 2002:a5d:9ac1:: with SMTP id x1mr2499295ion.191.1631192178733; Thu, 09 Sep 2021 05:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192178; cv=none; d=google.com; s=arc-20160816; b=oNL4bwkz3G8hP15Tx62IyY0PIeSIPM0Mz8vk5rbiEZaLCn+LV8cuMuXzGygPmlPQz0 n4ihUj352hhgZlywFKWehOEC0e8RiAbYxJYi1uQt8n0agXMybc9MrJPkocXEYzDhNN8h V6Ig00mIrfDWSUn7MN18FePkNKGhq8eavE9VfODAqQMRLA/O6oPuQQDuymUh7OzmUeuc zrcDUUMeBE1UZLwKYlS8OdQ7FZtwdOh3vmg63jwl1rZdEoIcy2UUVLRTEvm9JGVCuHg9 y/2C1g+oi2hKtXYSTZf8m2CyYEdz1KV1FgEy5utvL5SiKheham6zLShjbRM+voa4EyR5 Vrng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ccslqbdbDMRBI5TMJhPLL0kOsQFJUv4TDelcaobks6E=; b=eZvHRXuGOShyncA9ijpfeEAGPBu+mT8TL9/T/Lz72vzLbveO17ghhtLae9wagKKu2H YXgubpzkmSGcPdRlDSnVd5E3VLM4DrLlQQHTKjR2Qhx/kNJxAEzYeSgEUaJZzA5PMa0P w5iVN75WuZuxgxO3hVHaa2YufoPPUUtZ2GoUtsMnFEhW91Tc9somDmhGv53/RZ1XbgA2 xBQoOyCIXxcOgszvDcTH8r4ir8SNeC5TnZuHGFxZ+pY5+D1EOQUyDHXAvzNs1U6O45nc SjZpTJU8C+8CdSmdENQsKOBXmZ00MgJQr3pW/r1VAgG2yJ42Tm9jeD54K25g6O5H1kz2 2dNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=05fGKYQu; 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 b8si1731067ios.88.2021.09.09.05.56.04; Thu, 09 Sep 2021 05:56:18 -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=@lunn.ch header.s=20171124 header.b=05fGKYQu; 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 S1356791AbhIIMzx (ORCPT + 99 others); Thu, 9 Sep 2021 08:55:53 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:34430 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354448AbhIIMmO (ORCPT ); Thu, 9 Sep 2021 08:42:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=ccslqbdbDMRBI5TMJhPLL0kOsQFJUv4TDelcaobks6E=; b=05fGKYQu2zD3ugpGX5N14Irr/u 4b2Xrw30clYSR6GzAqprkul/PZvrYUFHAsgBsUlQYPoAkIntZMzoEReouEB/rC5W9RMm/fJXufvNK YRzOO15MAZywz9newS+wsM8iX2FIthUvRopVsx+PK+IdpiEK8tqC0PAbTvJ3aCpzGbJI=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mOJMM-005uJ8-Ct; Thu, 09 Sep 2021 14:40:54 +0200 Date: Thu, 9 Sep 2021 14:40:54 +0200 From: Andrew Lunn To: Lino Sanfilippo Cc: olteanv@gmail.com, p.rosenberger@kunbus.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] Fix for KSZ DSA switch shutdown Message-ID: References: <20210909095324.12978-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210909095324.12978-1-LinoSanfilippo@gmx.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 11:53:21AM +0200, Lino Sanfilippo wrote: > This patch series fixes a system hang I got each time i tried to shutdown > or reboot a system that uses a KSZ9897 as a DSA switch with a broadcom > GENET network device as the DSA master device. At the time the system hangs > the message "unregister_netdevice: waiting for eth0 to become free. Usage > count = 2." is dumped periodically to the console. > > After some investigation I found the reason to be unreleased references to > the master device which are still held by the slave devices at the time the > system is shut down (I have two slave devices in use). > > While these references are supposed to be released in ksz_switch_remove() > this function never gets the chance to be called due to the system hang at > the master device deregistration which happens before ksz_switch_remove() > is called. > > The fix is to make sure that the master device references are already > released when the device is unregistered. For this reason PATCH1 provides > a new function dsa_tree_shutdown() that can be called by DSA drivers to > untear the DSA switch at shutdown. PATCH2 uses this function in a new > helper function for KSZ switches to properly shutdown the KSZ switch. > PATCH 3 uses the new helper function in the KSZ9477 shutdown handler. I agree with Vladimir here. Shutdown works without issue on mv88e6xxx, i do it frequently. I'm sure other developers shutdown there devices at the end of the edit/compile/test cycle. If there was a generic problem, we would probably know about it. So it seems like there is something specific to your system which breaks the reference counting. We need to understand that first, then we can see how we fix it. > > Theses patches have been tested on a Raspberry PI 5.10 kernel with a > KSZ9897. The patches have been adjusted to apply against net-next and are > compile tested with next-next. Is the switch on a hat? Are you using DT overlays? Andrew