From: Jakub Kicinski <kuba@kernel.org>
To: slark_xiao@163.com
Cc: Jakub Kicinski <kuba@kernel.org>,
quic_qianyu@quicinc.com, davem@davemloft.net,
loic.poulain@oss.qualcomm.com, johannes@sipsolutions.net,
netdev@vger.kernel.org, zaihan@unrealasia.net, johan@kernel.org,
andrew+netdev@lunn.ch, edumazet@google.com,
linux-kernel@vger.kernel.org, dnlplm@gmail.com,
manivannan.sadhasivam@linaro.org, pabeni@redhat.com,
mani@kernel.org, ryazanov.s.a@gmail.com
Subject: Re: [net-next,v7,7/8] net: wwan: hwsim: support NMEA port emulation
Date: Thu, 15 Jan 2026 18:44:41 -0800 [thread overview]
Message-ID: <20260116024441.347826-1-kuba@kernel.org> (raw)
In-Reply-To: <20260115114625.46991-8-slark_xiao@163.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: wwan: hwsim: support NMEA port emulation
This commit adds NMEA port emulation to the WWAN hardware simulator for
GNSS port testing. The emulator generates GGA and RMC sentences every
second via a timer callback.
> diff --git a/drivers/net/wwan/wwan_hwsim.c b/drivers/net/wwan/wwan_hwsim.c
> index 11d15dc39041..e4b1bbff9af2 100644
> --- a/drivers/net/wwan/wwan_hwsim.c
> +++ b/drivers/net/wwan/wwan_hwsim.c
[ ... ]
> +#if IS_ENABLED(CONFIG_GNSS)
> +#define NMEA_MAX_LEN 82 /* Max sentence length */
> +#define NMEA_TRAIL_LEN 5 /* '*' + Checksum + <CR><LF> */
> +#define NMEA_MAX_DATA_LEN (NMEA_MAX_LEN - NMEA_TRAIL_LEN)
> +
> +static __printf(2, 3)
> +void wwan_hwsim_nmea_skb_push_sentence(struct sk_buff *skb,
> + const char *fmt, ...)
> +{
> + unsigned char *s, *p;
> + va_list ap;
> + u8 cs = 0;
> + int len;
> +
> + s = skb_put(skb, NMEA_MAX_LEN + 1); /* +'\0' */
[ ... ]
> +static void wwan_hwsim_nmea_emul_timer(struct timer_list *t)
> +{
> + /* 43.74754722298909 N 11.25759835922875 E in DMM format */
> + static const unsigned int coord[4 * 2] = { 43, 44, 8528, 0,
> + 11, 15, 4559, 0 };
> + struct wwan_hwsim_port *port = timer_container_of(port, t, nmea_emul.timer);
> + struct sk_buff *skb;
> + struct tm tm;
> +
> + time64_to_tm(ktime_get_real_seconds(), 0, &tm);
> +
> + mod_timer(&port->nmea_emul.timer, jiffies + HZ); /* 1 second */
> +
> + skb = alloc_skb(NMEA_MAX_LEN * 2, GFP_KERNEL); /* GGA + RMC */
^^^^^^^^^^^^^^ ^^^^^^^^^^
Two questions about this allocation:
1. The buffer size appears to be insufficient. The allocation requests
NMEA_MAX_LEN * 2 = 164 bytes, but wwan_hwsim_nmea_skb_push_sentence()
is called twice and each call uses skb_put(skb, NMEA_MAX_LEN + 1) which
reserves 83 bytes per sentence. The total needed is 166 bytes, which
exceeds the 164 bytes allocated. Would this cause skb_over_panic() to
trigger on the second skb_put() call?
2. This function is a timer callback registered via timer_setup() in
wwan_hwsim_nmea_emul_start(). Timer callbacks run in softirq context
where sleeping is not permitted. GFP_KERNEL allocations can sleep when
memory pressure triggers reclaim. Should this be GFP_ATOMIC instead to
avoid "scheduling while atomic" warnings?
> + if (!skb)
> + return;
> +
> + wwan_hwsim_nmea_skb_push_sentence(skb,
> + "$GPGGA,%02u%02u%02u.000,%02u%02u.%04u,%c,%03u%02u.%04u,%c,1,7,1.03,176.2,M,55.2,M,,",
> + tm.tm_hour, tm.tm_min, tm.tm_sec,
> + coord[0], coord[1], coord[2],
> + coord[3] ? 'S' : 'N',
> + coord[4], coord[5], coord[6],
> + coord[7] ? 'W' : 'E');
> +
> + wwan_hwsim_nmea_skb_push_sentence(skb,
> + "$GPRMC,%02u%02u%02u.000,A,%02u%02u.%04u,%c,%03u%02u.%04u,%c,0.02,31.66,%02u%02u%02u,,,A",
> + tm.tm_hour, tm.tm_min, tm.tm_sec,
> + coord[0], coord[1], coord[2],
> + coord[3] ? 'S' : 'N',
> + coord[4], coord[5], coord[6],
> + coord[7] ? 'W' : 'E',
> + tm.tm_mday, tm.tm_mon + 1,
> + (unsigned int)tm.tm_year - 100);
> +
> + wwan_port_rx(port->wwan, skb);
> +}
[ ... ]
next prev parent reply other threads:[~2026-01-16 2:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:46 [net-next v7 0/8] net: wwan: add NMEA port type support Slark Xiao
2026-01-15 11:46 ` [net-next v7 1/8] net: wwan: core: remove unused port_id field Slark Xiao
2026-01-15 11:46 ` [net-next v7 2/8] net: wwan: core: explicit WWAN device reference counting Slark Xiao
2026-01-15 11:46 ` [net-next v7 3/8] net: wwan: core: split port creation and registration Slark Xiao
2026-01-16 2:44 ` [net-next,v7,3/8] " Jakub Kicinski
2026-01-16 3:24 ` Slark Xiao
2026-01-22 2:31 ` Slark Xiao
2026-01-22 12:01 ` Loic Poulain
2026-01-15 11:46 ` [net-next v7 4/8] net: wwan: core: split port unregister and stop Slark Xiao
2026-01-15 11:46 ` [net-next v7 5/8] net: wwan: add NMEA port support Slark Xiao
2026-01-20 12:30 ` Simon Horman
2026-01-21 2:08 ` Slark Xiao
2026-01-21 14:16 ` Loic Poulain
2026-01-21 16:53 ` Simon Horman
2026-01-15 11:46 ` [net-next v7 6/8] net: wwan: hwsim: refactor to support more port types Slark Xiao
2026-01-15 11:46 ` [net-next v7 7/8] net: wwan: hwsim: support NMEA port emulation Slark Xiao
2026-01-16 2:44 ` Jakub Kicinski [this message]
2026-01-22 3:06 ` Re:Re: [net-next,v7,7/8] " Slark Xiao
2026-01-15 11:46 ` [net-next v7 8/8] net: wwan: mhi_wwan_ctrl: Add NMEA channel support Slark Xiao
2026-01-15 20:19 ` Sergey Ryazanov
2026-01-16 2:43 ` [net-next v7 0/8] net: wwan: add NMEA port type support Jakub Kicinski
2026-01-16 3:18 ` Slark Xiao
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=20260116024441.347826-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dnlplm@gmail.com \
--cc=edumazet@google.com \
--cc=johan@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_qianyu@quicinc.com \
--cc=ryazanov.s.a@gmail.com \
--cc=slark_xiao@163.com \
--cc=zaihan@unrealasia.net \
/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