public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Slark Xiao" <slark_xiao@163.com>
To: "Sergey Ryazanov" <ryazanov.s.a@gmail.com>
Cc: loic.poulain@oss.qualcomm.com, johannes@sipsolutions.net,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, mani@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Daniele Palmas" <dnlplm@gmail.com>
Subject: Re:Re: [net-next v4 7/8] net: wwan: prevent premature device unregister when NMEA port is present
Date: Wed, 7 Jan 2026 15:29:24 +0800 (CST)	[thread overview]
Message-ID: <63fddbfb.60e7.19b975c40ea.Coremail.slark_xiao@163.com> (raw)
In-Reply-To: <83c51a99-038d-4283-9a39-97129966a500@gmail.com>



At 2026-01-07 09:06:05, "Sergey Ryazanov" <ryazanov.s.a@gmail.com> wrote:
>Hi Slark, Loic,
>
>sorry for late joining the discussion, please find a design question below.
>
>On 1/5/26 12:20, Slark Xiao wrote:
>> From: Loic Poulain <loic.poulain@oss.qualcomm.com>
>> 
>> The WWAN core unregisters the device when it has no remaining WWAN ops
>> or child devices. For NMEA port types, the child is registered under
>> the GNSS class instead of WWAN, so the core incorrectly assumes there
>> are no children and unregisters the WWAN device too early. This leads
>> to a second unregister attempt after the NMEA device is removed.
>> 
>> To fix this issue, we register a virtual WWAN port device along the
>> GNSS device, this ensures the WWAN device remains registered until
>> all associated ports, including NMEA, are properly removed.
>
>wwan core assumes whole responsibility for managing a WWAN device. We 
>already use wwan_create_dev()/wwan_remove_dev() everywhere. But, we are 
>checking the reminding references in an implicit way using 
>device_for_each_child() and registered OPS existence. Thus, we need this 
>trick with a virtual child port.
>
>Does it make sense to switch to an explicit reference counting? We can 
>introduce such counter to the wwan_device structure, and 
>increment/decrement it on every wwan_create_dev()/wwan_remove_dev() 
>call. So, we will do device_unregister() upon reference number becoming 
>zero.
>
>If it sounds promising, I can send a RFC, let's say, tomorrow.

The RFC only for this patch or the existing design? Since there is problem
reported in https://patchwork.kernel.org/project/netdevbpf/patch/20260105102018.62731-3-slark_xiao@163.com/#26720828.

Currently design:
    minor = ida_alloc_range(&minors, 0, WWAN_MAX_MINORS - 1, GFP_KERNEL);
    if (minor < 0)
        return minor;

    port->dev.class = &wwan_class;
// when cdev is false, no devt was assigned. But wwan_port_destroy() use devt to free
    if (cdev)
        port->dev.devt = MKDEV(wwan_major, minor);

We need to have a update based on this patch if we want to use this one in this serial.
 

  reply	other threads:[~2026-01-07  7:30 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 10:20 [net-next v4 0/8] net: wwan: add NMEA port type support Slark Xiao
2026-01-05 10:20 ` [net-next v4 1/8] net: wwan: core: remove unused port_id field Slark Xiao
2026-01-05 10:20 ` [net-next v4 2/8] net: wwan: core: split port creation and registration Slark Xiao
2026-01-06 16:49   ` Sai Krishna Gajula
2026-01-07  7:21     ` Slark Xiao
2026-01-08  0:42       ` Sergey Ryazanov
2026-01-05 10:20 ` [net-next v4 3/8] net: wwan: core: split port unregister and stop Slark Xiao
2026-01-06 20:34   ` Loic Poulain
2026-01-05 10:20 ` [net-next v4 4/8] net: wwan: add NMEA port support Slark Xiao
2026-01-06 20:36   ` Loic Poulain
2026-01-05 10:20 ` [net-next v4 5/8] net: wwan: hwsim: refactor to support more port types Slark Xiao
2026-01-05 10:20 ` [net-next v4 6/8] net: wwan: hwsim: support NMEA port emulation Slark Xiao
2026-01-06 20:37   ` Loic Poulain
2026-01-05 10:20 ` [net-next v4 7/8] net: wwan: prevent premature device unregister when NMEA port is present Slark Xiao
2026-01-07  1:06   ` Sergey Ryazanov
2026-01-07  7:29     ` Slark Xiao [this message]
2026-01-07 10:24       ` Sergey Ryazanov
2026-01-08  2:05       ` [RFC PATCH 0/1] prevent premature device unregister via Sergey Ryazanov
2026-01-08  2:05         ` [RFC PATCH 1/1] net: wwan: core: explicit WWAN device reference counting Sergey Ryazanov
2026-01-08  8:59           ` Loic Poulain
2026-01-08 13:01             ` Sergey Ryazanov
2026-01-08 11:01         ` Re:[RFC PATCH 0/1] prevent premature device unregister via Slark Xiao
2026-01-08 13:12           ` Sergey Ryazanov
2026-01-05 10:20 ` [net-next v4 8/8] net: wwan: mhi_wwan_ctrl: Add NMEA channel support Slark Xiao
2026-01-06 20:38   ` Loic Poulain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=63fddbfb.60e7.19b975c40ea.Coremail.slark_xiao@163.com \
    --to=slark_xiao@163.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dnlplm@gmail.com \
    --cc=edumazet@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=mani@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryazanov.s.a@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox