Message ID | 1564575767-27557-3-git-send-email-yhchuang@realtek.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 713a30de45a2ec8619228280e4832b5d6a34e759 |
Delegated to: | Kalle Valo |
Headers | show |
Series | rtw88: add support for BT co-existence mechanism | expand |
I understand this is already queued up, but I still have a question: On Wed, Jul 31, 2019 at 5:23 AM <yhchuang@realtek.com> wrote: > C2H commands that cannot be handled in IRQ context should > be protected by rtwdev->mutex. Because they might have a > sequece of hardware operations that does not want to be > interfered. Can you elaborate on what interference you're looking at, exactly? I'm not a big fan of defensive addition of global locks, and this particular mutex isn't very targeted. It claims to be for mac80211 callbacks, but you use it in quite a few places (some of which clearly don't make sense), and many of them are not related to mac80211 callbacks AFAICT. To the contrary: this handler is called from the mac80211 work queue, which is ordered and therefore shouldn't be getting "interrupted" (e.g., conflicting commands). But then, you added the 'irqsafe' command, which gets run from the ISR...and doesn't hold this lock, obviously. It may well be that you're correct here, but I'd like to see a better explanation for stuff like this. And maybe an update to the rtw_dev::mutex comments. Brian
> I understand this is already queued up, but I still have a question: > > On Wed, Jul 31, 2019 at 5:23 AM <yhchuang@realtek.com> wrote: > > C2H commands that cannot be handled in IRQ context should > > be protected by rtwdev->mutex. Because they might have a > > sequece of hardware operations that does not want to be > > interfered. > > Can you elaborate on what interference you're looking at, exactly? I'm > not a big fan of defensive addition of global locks, and this > particular mutex isn't very targeted. It claims to be for mac80211 > callbacks, but you use it in quite a few places (some of which clearly > don't make sense), and many of them are not related to mac80211 > callbacks AFAICT. Basically it must protect rtwdev itself for mac80211 callbacks, but work queue also should be protected, as work queue could be interfered by mac80211 callbacks IIUC. And most of the time what I want to protect is the "hardware operations". I might implicitly binds those register read/write(s) with the rtwdev struct. I think the problem here is I should give a better comment to better describe the usage of the mutex. And I also want to keep it short. > > To the contrary: this handler is called from the mac80211 work queue, > which is ordered and therefore shouldn't be getting "interrupted" > (e.g., conflicting commands). But then, you added the 'irqsafe' > command, which gets run from the ISR...and doesn't hold this lock, > obviously. C2H work queue will not interrupt each other, but mac80211 callbacks could, as most of the functions are consist of a sequence of hardware register operations. And I don't want to use I/O under ISR context, so here to split the C2H commands. > > It may well be that you're correct here, but I'd like to see a better > explanation for stuff like this. And maybe an update to the > rtw_dev::mutex comments. > > Brian > Yan-Hsuan
On Thu, Aug 15, 2019 at 7:45 PM Tony Chuang <yhchuang@realtek.com> wrote: > I think the problem here is I should give a better comment to better > describe the usage of the mutex. And I also want to keep it short. I don't think we have limits on comments in source code -- better to document too much than not enough. Brian
diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index 3c4dcb7..3b06f71 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -36,6 +36,8 @@ void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb) c2h = (struct rtw_c2h_cmd *)(skb->data + pkt_offset); len = skb->len - pkt_offset - 2; + mutex_lock(&rtwdev->mutex); + switch (c2h->id) { case C2H_HALMAC: rtw_fw_c2h_cmd_handle_ext(rtwdev, skb); @@ -43,6 +45,8 @@ void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb) default: break; } + + mutex_unlock(&rtwdev->mutex); } void rtw_fw_c2h_cmd_rx_irqsafe(struct rtw_dev *rtwdev, u32 pkt_offset,