[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <63fddbfb.60e7.19b975c40ea.Coremail.slark_xiao@163.com>
Date: Wed, 7 Jan 2026 15:29:24 +0800 (CST)
From: "Slark Xiao" <slark_xiao@....com>
To: "Sergey Ryazanov" <ryazanov.s.a@...il.com>
Cc: loic.poulain@....qualcomm.com, johannes@...solutions.net,
andrew+netdev@...n.ch, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com, mani@...nel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
"Daniele Palmas" <dnlplm@...il.com>
Subject: Re:Re: [net-next v4 7/8] net: wwan: prevent premature device
unregister when NMEA port is present
At 2026-01-07 09:06:05, "Sergey Ryazanov" <ryazanov.s.a@...il.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@....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.
Powered by blists - more mailing lists