All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mt76: mt7921: allow chip reset during device restart
@ 2021-06-18 10:30 Lorenzo Bianconi
  2021-06-19 11:06 ` Kalle Valo
  0 siblings, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2021-06-18 10:30 UTC (permalink / raw)
  To: nbd; +Cc: lorenzo.bianconi, linux-wireless, sean.wang

Disable chip full reset just during device probing but allow
it during hw restart.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7921/init.c   | 8 +++++++-
 drivers/net/wireless/mediatek/mt76/mt7921/mac.c    | 8 +++++---
 drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h | 3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
index 9925c15ac9df..a9ce10b98827 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
@@ -236,7 +236,13 @@ int mt7921_register_device(struct mt7921_dev *dev)
 	if (ret)
 		return ret;
 
-	return mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable);
+	ret = mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable);
+	if (ret)
+		return ret;
+
+	dev->hw_init_done = true;
+
+	return 0;
 }
 
 void mt7921_unregister_device(struct mt7921_dev *dev)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
index dbcc8146e87a..e97d3a6b2724 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -1376,11 +1376,13 @@ void mt7921_reset(struct mt76_dev *mdev)
 {
 	struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
 
-	if (!test_bit(MT76_STATE_RUNNING, &dev->mphy.state))
+	if (!dev->hw_init_done)
 		return;
 
-	if (!dev->hw_full_reset)
-		queue_work(dev->mt76.wq, &dev->reset_work);
+	if (dev->hw_full_reset)
+		return;
+
+	queue_work(dev->mt76.wq, &dev->reset_work);
 }
 
 static void
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index 087067e7ea5b..a1962bfb4f67 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -160,7 +160,8 @@ struct mt7921_dev {
 	u16 chainmask;
 
 	struct work_struct reset_work;
-	bool hw_full_reset;
+	bool hw_full_reset:1;
+	bool hw_init_done:1;
 
 	struct list_head sta_poll_list;
 	spinlock_t sta_poll_lock;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mt76: mt7921: allow chip reset during device restart
  2021-06-18 10:30 [PATCH] mt76: mt7921: allow chip reset during device restart Lorenzo Bianconi
@ 2021-06-19 11:06 ` Kalle Valo
  2021-06-19 12:36   ` Lorenzo Bianconi
  0 siblings, 1 reply; 4+ messages in thread
From: Kalle Valo @ 2021-06-19 11:06 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: nbd, lorenzo.bianconi, linux-wireless, sean.wang

Lorenzo Bianconi <lorenzo@kernel.org> writes:

> Disable chip full reset just during device probing but allow
> it during hw restart.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

[...]

> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -160,7 +160,8 @@ struct mt7921_dev {
>  	u16 chainmask;
>  
>  	struct work_struct reset_work;
> -	bool hw_full_reset;
> +	bool hw_full_reset:1;
> +	bool hw_init_done:1;

Is there a specific reason why you use bitfields in a boolean? Looks
strange to me.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mt76: mt7921: allow chip reset during device restart
  2021-06-19 11:06 ` Kalle Valo
@ 2021-06-19 12:36   ` Lorenzo Bianconi
  2021-06-20  8:44     ` Kalle Valo
  0 siblings, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2021-06-19 12:36 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Lorenzo Bianconi, nbd, linux-wireless, sean.wang

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> 
> > Disable chip full reset just during device probing but allow
> > it during hw restart.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> [...]
> 
> > --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> > @@ -160,7 +160,8 @@ struct mt7921_dev {
> >  	u16 chainmask;
> >  
> >  	struct work_struct reset_work;
> > -	bool hw_full_reset;
> > +	bool hw_full_reset:1;
> > +	bool hw_init_done:1;
> 
> Is there a specific reason why you use bitfields in a boolean? Looks
> strange to me.

Hi Kalle,

nope, there is no specific reason, I have just reused the same approach used in
mt76_queue_entry for skip_buf{0,1}.

Regards,
Lorenzo

> 
> -- 
> https://patchwork.kernel.org/project/linux-wireless/list/
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mt76: mt7921: allow chip reset during device restart
  2021-06-19 12:36   ` Lorenzo Bianconi
@ 2021-06-20  8:44     ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2021-06-20  8:44 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Lorenzo Bianconi, nbd, linux-wireless, sean.wang

Lorenzo Bianconi <lorenzo.bianconi@redhat.com> writes:

>> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>> 
>> > Disable chip full reset just during device probing but allow
>> > it during hw restart.
>> >
>> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> 
>> [...]
>> 
>> > --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
>> > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
>> > @@ -160,7 +160,8 @@ struct mt7921_dev {
>> >  	u16 chainmask;
>> >  
>> >  	struct work_struct reset_work;
>> > -	bool hw_full_reset;
>> > +	bool hw_full_reset:1;
>> > +	bool hw_init_done:1;
>> 
>> Is there a specific reason why you use bitfields in a boolean? Looks
>> strange to me.
>
> Hi Kalle,
>
> nope, there is no specific reason, I have just reused the same approach used in
> mt76_queue_entry for skip_buf{0,1}.

Ah, I checked now and saw other uses of boolean bitfields elsewhere in
kernel as well, but this is the first time I saw about this. So I guess
this is then ok and saves few bytes. Learned something new again :)

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-20  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 10:30 [PATCH] mt76: mt7921: allow chip reset during device restart Lorenzo Bianconi
2021-06-19 11:06 ` Kalle Valo
2021-06-19 12:36   ` Lorenzo Bianconi
2021-06-20  8:44     ` Kalle Valo

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.