From: Kalle Valo <kvalo@kernel.org>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: Bernie Huang <phhuang@realtek.com>,
"linux-wireless\@vger.kernel.org"
<linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 2/5] wifi: rtw89: add function to wait for completion of TX skbs
Date: Mon, 03 Apr 2023 13:32:54 +0300 [thread overview]
Message-ID: <875yadb6i1.fsf@kernel.org> (raw)
In-Reply-To: <360e6dd64e3645c68742fc4c603b3c2b@realtek.com> (Ping-Ke Shih's message of "Wed, 15 Mar 2023 12:09:26 +0000")
Ping-Ke Shih <pkshih@realtek.com> writes:
>> > +static void rtw89_core_free_tx_wait_work(struct work_struct *work)
>> > +{
>> > + struct rtw89_tx_wait_info *wait =
>> > + container_of(work, struct rtw89_tx_wait_info, work);
>> > + struct rtw89_dev *rtwdev = wait->rtwdev;
>> > + int done, ret;
>> > +
>> > + ret = read_poll_timeout(atomic_read, done, done, 1000, 100000, false,
>> > + &wait->wait_done);
>> > +
>> > + if (ret)
>> > + rtw89_err(rtwdev, "tx wait timed out, stop polling\n");
>> > + else
>> > + kfree(wait);
>> > +}
>>
>> I admit I didn't try to understand this patch in detail but this
>> function just looks odd to me. Why there's polling able to free
>> something?
>>
>
> Three works are involved in the "wait/completion".
>
> work 1. remain-on-channel work
> It trigger TX null data and wait (kmalloc 'wait' object, and wait for completion)
>
> work 2. TX completion by napi_poll
> It returns TX status (failed or succeed to TX), and complete the 'wait' object,
> and queue rtw89_core_free_tx_wait_work() to free 'wait' object.
>
> We queue this by work 2, because time of work 1 is predictable, but
> it is hard to estimate time of work 2. The read_poll_timeout() is for
> the work 1 predictable time.
>
> work 3. This work is to do garbage collection of 'wait' object
> It polls if work 1 is done before doing free 'wait' object.
>
>
> Things are complex because work 1 and 2 are done asynchronously, so one
> of them can't free 'wait' object, or it will causes use-after-free in other
> side.
>
> Use case 1: (work 1 could free 'wait' object)
> work 1 work 2 work 3
> wait
> completion
> wait ok
> free 'wait'
>
> Use case 2: (work 2 could free 'wait' object)
> work 1 work 2 work 3
> wait
> wait timeout
> completion
> free 'wait'
>
>
> I can add a comment as a hint why we can use a read_poll_timeout() to assist
> in freeing something.
I would expect that there's polling if you are waiting something from
hardware, or maybe when implementing a spin lock, but not when waiting
for another kernel thread. This just doesn't feel right but I don't have
time to propose a good alternative either, sorry.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
next prev parent reply other threads:[~2023-04-03 10:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 3:46 [PATCH 0/5] wifi: rtw89: preparation of multiple interface concurrency support Ping-Ke Shih
2023-03-10 3:46 ` [PATCH 1/5] wifi: rtw89: 8852c: add beacon filter and CQM support Ping-Ke Shih
2023-03-15 8:31 ` Kalle Valo
2023-03-15 8:57 ` Ping-Ke Shih
2023-03-15 11:45 ` Ping-Ke Shih
2023-03-16 12:24 ` Ping-Ke Shih
2023-04-03 10:21 ` rtw88/rtw89: command/event structure handling Kalle Valo
2023-04-03 13:23 ` Kalle Valo
2023-04-03 14:09 ` Ping-Ke Shih
2023-04-03 18:06 ` Kalle Valo
2023-03-10 3:46 ` [PATCH 2/5] wifi: rtw89: add function to wait for completion of TX skbs Ping-Ke Shih
2023-03-15 8:39 ` Kalle Valo
2023-03-15 12:09 ` Ping-Ke Shih
2023-04-03 10:32 ` Kalle Valo [this message]
2023-04-04 2:38 ` Ping-Ke Shih
2023-04-11 13:01 ` Ping-Ke Shih
2023-04-12 13:00 ` Kalle Valo
2023-03-10 3:46 ` [PATCH 3/5] wifi: rtw89: add ieee80211::remain_on_channel ops Ping-Ke Shih
2023-03-10 3:46 ` [PATCH 4/5] wifi: rtw89: add flag check for power state Ping-Ke Shih
2023-03-10 3:46 ` [PATCH 5/5] wifi: rtw89: fix authentication fail during scan Ping-Ke Shih
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=875yadb6i1.fsf@kernel.org \
--to=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=phhuang@realtek.com \
--cc=pkshih@realtek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.