Skip to contentSkip to conversation

wifi: mt76: mt7921e: Set memory space enable in PCI_COMMAND if unset

PATCH RESEND Superseded Mario Limonciello 2 participants 6 messages Mar 29, 2023 – Apr 10, 2023

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 wifi: mt76: mt7921e: Set memory space enable in PCI_COMMAND if unset

When the BIOS has been configured for Fast Boot, systems with mt7921e have non-functional wifi. Turning on Fast boot caused both bus master enable and memory space enable bits in PCI_COMMAND not to get configured.

The mt7921 driver already sets bus master enable, but explicitly check and set memory access enable as well to fix this problem.

---
Original patch was submitted ~3 weeks ago with no comments.

---
 drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +6 -0
index cb72ded37256..aa1a427b16c2 100644
@@ -263,6 +263,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
 	struct mt76_dev *mdev;
 	u8 features;
 	int ret;
+	u16 cmd;
 
 	ret = pcim_enable_device(pdev);
 	if (ret)
@@ -272,6 +273,11 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
+	pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+	if (!(cmd & PCI_COMMAND_MEMORY)) {
+		cmd |= PCI_COMMAND_MEMORY;
+		pci_write_config_word(pdev, PCI_COMMAND, cmd);
+	}
 	pci_set_master(pdev);
 
 	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
Signature · 1 line
2.34.1
#1 lore raw

Hi,

Quoted 30 lines · Mario Limonciello

When the BIOS has been configured for Fast Boot, systems with mt7921e have non-functional wifi. Turning on Fast boot caused both bus master enable and memory space enable bits in PCI_COMMAND not to get configured.

The mt7921 driver already sets bus master enable, but explicitly check and set memory access enable as well to fix this problem.

---
Original patch was submitted ~3 weeks ago with no comments.

---
 drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -0
index cb72ded37256..aa1a427b16c2 100644
@@ -263,6 +263,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
        struct mt76_dev *mdev;
        u8 features;
        int ret;
+       u16 cmd;
 
        ret = pcim_enable_device(pdev);
        if (ret)

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 280

Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +5 -0
@@ -272,6 +273,11 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
        if (ret)
                return ret;
 
+       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+       if (!(cmd & PCI_COMMAND_MEMORY)) {
+               cmd |= PCI_COMMAND_MEMORY;
+               pci_write_config_word(pdev, PCI_COMMAND, cmd);
+       }

If PCI_COMMAND_MEMORY is required in any circumstance, then we don't need to add a conditional check and OR it with PCI_COMMAND_MEMORY. Also, I will try the patch on another Intel machine to see if it worked.

Sean

Quoted 6 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -1
        pci_set_master(pdev);
 
        ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
--

2.34.1

#2 lore raw
Quoted 37 lines · Sean Wang

Hi,

Quoted 33 lines · Mario Limonciello

When the BIOS has been configured for Fast Boot, systems with mt7921e have non-functional wifi. Turning on Fast boot caused both bus master enable and memory space enable bits in PCI_COMMAND not to get configured.

The mt7921 driver already sets bus master enable, but explicitly check and set memory access enable as well to fix this problem.

---
Original patch was submitted ~3 weeks ago with no comments.

---
  drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -0
index cb72ded37256..aa1a427b16c2 100644
@@ -263,6 +263,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
         struct mt76_dev *mdev;
         u8 features;
         int ret;
+       u16 cmd;
 
         ret = pcim_enable_device(pdev);
         if (ret)
@@ -272,6 +273,11 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
         if (ret)
                 return ret;
 
Quoted 8 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 280

Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +5 -0
+       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+       if (!(cmd & PCI_COMMAND_MEMORY)) {
+               cmd |= PCI_COMMAND_MEMORY;
+               pci_write_config_word(pdev, PCI_COMMAND, cmd);
+       }

If PCI_COMMAND_MEMORY is required in any circumstance, then we don't need to add a conditional check and OR it with PCI_COMMAND_MEMORY.

Generally it seemed advantageous to avoid an extra PCI write if it's not needed. For example that's how bus mastering works too (see __pci_set_master).

Quoted 1 line

Also, I will try the patch on another Intel machine to see if it worked.

Thanks.

Quoted 9 lines

Sean

Quoted 6 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -1
         pci_set_master(pdev);
 
         ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
--

2.34.1

#3 lore raw

[Public]

Quoted 52 lines · Sean Wang
Quoted 8 lines

Hi,

Quoted 4 lines · Mario Limonciello

When the BIOS has been configured for Fast Boot, systems with mt7921e have non-functional wifi. Turning on Fast boot caused both bus master enable and memory space enable bits in PCI_COMMAND not to get

configured.

Quoted 9 lines
Quoted 9 lines

The mt7921 driver already sets bus master enable, but explicitly check and set memory access enable as well to fix this problem.

---
Original patch was submitted ~3 weeks ago with no comments.

[email protected]/

Quoted 5 lines

Review

Quoted 5 lines
---
  drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 6 ++++++
  1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c

Quoted 9 lines
Quoted 9 lines

index cb72ded37256..aa1a427b16c2 100644

drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -0
@@ -263,6 +263,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
         struct mt76_dev *mdev;
         u8 features;
         int ret;
+       u16 cmd;
 
Quoted 3 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev

Quoted 3 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -0
         ret = pcim_enable_device(pdev);
         if (ret)
@@ -272,6 +273,11 @@ static int mt7921_pci_probe(struct pci_dev

*pdev,

Quoted 10 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 280

Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +5 -0
         if (ret)
                 return ret;
 
+       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+       if (!(cmd & PCI_COMMAND_MEMORY)) {
+               cmd |= PCI_COMMAND_MEMORY;
+               pci_write_config_word(pdev, PCI_COMMAND, cmd);
+       }

If PCI_COMMAND_MEMORY is required in any circumstance, then we

don't

Quoted 1 line

need to add a conditional check and OR it with PCI_COMMAND_MEMORY.

Quoted 8 lines

Generally it seemed advantageous to avoid an extra PCI write if it's not needed. For example that's how bus mastering works too (see __pci_set_master).

Quoted 1 line

Also, I will try the patch on another Intel machine to see if it worked.

Thanks.

Did you get a chance to try this on an Intel system?

Quoted 10 lines
Quoted 10 lines

Sean

Quoted 6 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -1
         pci_set_master(pdev);
 
         ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
--

2.34.1

Acked-by
#4 lore raw
Quoted 60 lines · Mario

[Public]

Quoted 57 lines · Sean Wang
Quoted 8 lines

Hi,

Quoted 4 lines · Mario Limonciello

When the BIOS has been configured for Fast Boot, systems with mt7921e have non-functional wifi. Turning on Fast boot caused both bus master enable and memory space enable bits in PCI_COMMAND not to get

configured.

Quoted 9 lines
Quoted 9 lines

The mt7921 driver already sets bus master enable, but explicitly check and set memory access enable as well to fix this problem.

---
Original patch was submitted ~3 weeks ago with no comments.

[email protected]/

Quoted 5 lines

Review

Quoted 5 lines
---
  drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 6 ++++++
  1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c

Quoted 9 lines
Quoted 9 lines

index cb72ded37256..aa1a427b16c2 100644

drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -0
@@ -263,6 +263,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
         struct mt76_dev *mdev;
         u8 features;
         int ret;
+       u16 cmd;
 
Quoted 3 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev

Quoted 3 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -0
         ret = pcim_enable_device(pdev);
         if (ret)
@@ -272,6 +273,11 @@ static int mt7921_pci_probe(struct pci_dev

*pdev,

Quoted 10 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 280

Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +5 -0
         if (ret)
                 return ret;
 
+       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+       if (!(cmd & PCI_COMMAND_MEMORY)) {
+               cmd |= PCI_COMMAND_MEMORY;
+               pci_write_config_word(pdev, PCI_COMMAND, cmd);
+       }

If PCI_COMMAND_MEMORY is required in any circumstance, then we

don't

Quoted 1 line

need to add a conditional check and OR it with PCI_COMMAND_MEMORY.

Generally it seemed advantageous to avoid an extra PCI write if it's not needed. For example that's how bus mastering works too (see __pci_set_master).

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Also, I will try the patch on another Intel machine to see if it worked.

Thanks.

Did you get a chance to try this on an Intel system?

Hi,

Sorry for the late response. We have tested the related Intel platform and it worked fine. You can add the tag from me like

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Sean

Quoted 6 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -1
         pci_set_master(pdev);
 
         ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
--

2.34.1

#5 lore raw
Quoted 57 lines · Sean Wang
Quoted 55 lines · Mario

[Public]

Quoted 53 lines · Sean Wang
Quoted 7 lines

Hi,

Quoted 3 lines · Mario Limonciello

When the BIOS has been configured for Fast Boot, systems with mt7921e have non-functional wifi. Turning on Fast boot caused both bus master enable and memory space enable bits in PCI_COMMAND not to get

configured.

Quoted 8 lines
Quoted 8 lines

The mt7921 driver already sets bus master enable, but explicitly check and set memory access enable as well to fix this problem.

---
Original patch was submitted ~3 weeks ago with no comments.

[email protected]/

Quoted 5 lines

Review

Quoted 5 lines
---
   drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 6 ++++++
   1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c

Quoted 9 lines
Quoted 9 lines

index cb72ded37256..aa1a427b16c2 100644

drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -0
@@ -263,6 +263,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
          struct mt76_dev *mdev;
          u8 features;
          int ret;
+       u16 cmd;
 
Quoted 3 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev

Quoted 3 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0 -0
          ret = pcim_enable_device(pdev);
          if (ret)
@@ -272,6 +273,11 @@ static int mt7921_pci_probe(struct pci_dev

*pdev,

Quoted 9 lines

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 280

Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +5 -0
          if (ret)
                  return ret;
 
+       pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+       if (!(cmd & PCI_COMMAND_MEMORY)) {
+               cmd |= PCI_COMMAND_MEMORY;
+               pci_write_config_word(pdev, PCI_COMMAND, cmd);
+       }

If PCI_COMMAND_MEMORY is required in any circumstance, then we

don't

Quoted 1 line

need to add a conditional check and OR it with PCI_COMMAND_MEMORY.

Generally it seemed advantageous to avoid an extra PCI write if it's not needed. For example that's how bus mastering works too (see __pci_set_master).

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

Also, I will try the patch on another Intel machine to see if it worked.

Thanks.

Did you get a chance to try this on an Intel system?

Hi,

Sorry for the late response. We have tested the related Intel platform and it worked fine. You can add the tag from me like

Thanks!

Felix, Lorenzo, or Ryder can you guys please pick this up?

Thanks,