* [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource()
@ 2022-09-23 9:38 ruanjinjie
2022-09-23 16:50 ` Franky Lin
0 siblings, 1 reply; 6+ messages in thread
From: ruanjinjie @ 2022-09-23 9:38 UTC (permalink / raw)
To: aspriel, franky.lin, hante.meuleman, kvalo, davem, edumazet,
kuba, pabeni, marcan, linus.walleij, rmk+kernel, soontak.lee,
linux-wireless, SHA-cyfmac-dev-list, brcm80211-dev-list.pdl,
netdev, linux-kernel
Cc: ruanjinjie
Add missing pci_disable_device() if brcmf_pcie_get_resource() fails.
Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index f98641bb1528..25fa69793d86 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1725,7 +1725,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
if ((bar1_size == 0) || (bar1_addr == 0)) {
brcmf_err(bus, "BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
bar1_size, (unsigned long long)bar1_addr);
- return -EINVAL;
+ err = -EINVAL;
+ goto err_disable;
}
devinfo->regs = ioremap(bar0_addr, BRCMF_PCIE_REG_MAP_SIZE);
@@ -1734,7 +1735,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
if (!devinfo->regs || !devinfo->tcm) {
brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
devinfo->tcm);
- return -EINVAL;
+ err = -EINVAL;
+ goto err_disable;
}
brcmf_dbg(PCIE, "Phys addr : reg space = %p base addr %#016llx\n",
devinfo->regs, (unsigned long long)bar0_addr);
@@ -1743,6 +1745,9 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
(unsigned int)bar1_size);
return 0;
+err_disable:
+ pci_disable_device(pdev);
+ return err;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource()
2022-09-23 9:38 [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource() ruanjinjie
@ 2022-09-23 16:50 ` Franky Lin
2022-09-24 1:00 ` Ruan Jinjie
2022-09-24 2:54 ` Ruan Jinjie
0 siblings, 2 replies; 6+ messages in thread
From: Franky Lin @ 2022-09-23 16:50 UTC (permalink / raw)
To: ruanjinjie
Cc: aspriel, hante.meuleman, kvalo, davem, edumazet, kuba, pabeni,
marcan, linus.walleij, rmk+kernel, soontak.lee, linux-wireless,
SHA-cyfmac-dev-list, brcm80211-dev-list.pdl, netdev,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2145 bytes --]
On Fri, Sep 23, 2022 at 2:42 AM ruanjinjie <ruanjinjie@huawei.com> wrote:
>
> Add missing pci_disable_device() if brcmf_pcie_get_resource() fails.
Did you encounter any issue because of the absensent
pci_disable_device? A bit more context will be very helpful.
>
> Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> index f98641bb1528..25fa69793d86 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> @@ -1725,7 +1725,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
> if ((bar1_size == 0) || (bar1_addr == 0)) {
> brcmf_err(bus, "BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
> bar1_size, (unsigned long long)bar1_addr);
> - return -EINVAL;
> + err = -EINVAL;
> + goto err_disable;
> }
>
> devinfo->regs = ioremap(bar0_addr, BRCMF_PCIE_REG_MAP_SIZE);
> @@ -1734,7 +1735,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
> if (!devinfo->regs || !devinfo->tcm) {
> brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
> devinfo->tcm);
> - return -EINVAL;
> + err = -EINVAL;
> + goto err_disable;
> }
> brcmf_dbg(PCIE, "Phys addr : reg space = %p base addr %#016llx\n",
> devinfo->regs, (unsigned long long)bar0_addr);
> @@ -1743,6 +1745,9 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
> (unsigned int)bar1_size);
>
> return 0;
> +err_disable:
> + pci_disable_device(pdev);
Isn't brcmf_pcie_release_resource() a better choice which also unmap
the io if any was mapped?
Regards,
- Franky
> + return err;
> }
>
>
> --
> 2.25.1
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4203 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource()
2022-09-23 16:50 ` Franky Lin
@ 2022-09-24 1:00 ` Ruan Jinjie
2022-09-26 7:58 ` Kalle Valo
2022-09-24 2:54 ` Ruan Jinjie
1 sibling, 1 reply; 6+ messages in thread
From: Ruan Jinjie @ 2022-09-24 1:00 UTC (permalink / raw)
To: Franky Lin
Cc: aspriel, hante.meuleman, kvalo, davem, edumazet, kuba, pabeni,
marcan, linus.walleij, rmk+kernel, soontak.lee, linux-wireless,
SHA-cyfmac-dev-list, brcm80211-dev-list.pdl, netdev,
linux-kernel
On 2022/9/24 0:50, Franky Lin wrote:
> On Fri, Sep 23, 2022 at 2:42 AM ruanjinjie <ruanjinjie@huawei.com> wrote:
>>
>> Add missing pci_disable_device() if brcmf_pcie_get_resource() fails.
>
> Did you encounter any issue because of the absensent
> pci_disable_device? A bit more context will be very helpful.
>
We use static analysis via coccinelle to find the above issue. The
command we use is below:
spatch -I include -timeout 60 -very_quiet -sp_file
pci_disable_device_missing.cocci
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>>
>> Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
>> ---
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> index f98641bb1528..25fa69793d86 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> @@ -1725,7 +1725,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
>> if ((bar1_size == 0) || (bar1_addr == 0)) {
>> brcmf_err(bus, "BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
>> bar1_size, (unsigned long long)bar1_addr);
>> - return -EINVAL;
>> + err = -EINVAL;
>> + goto err_disable;
>> }
>>
>> devinfo->regs = ioremap(bar0_addr, BRCMF_PCIE_REG_MAP_SIZE);
>> @@ -1734,7 +1735,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
>> if (!devinfo->regs || !devinfo->tcm) {
>> brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
>> devinfo->tcm);
>> - return -EINVAL;
>> + err = -EINVAL;
>> + goto err_disable;
>> }
>> brcmf_dbg(PCIE, "Phys addr : reg space = %p base addr %#016llx\n",
>> devinfo->regs, (unsigned long long)bar0_addr);
>> @@ -1743,6 +1745,9 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
>> (unsigned int)bar1_size);
>>
>> return 0;
>> +err_disable:
>> + pci_disable_device(pdev);
>
> Isn't brcmf_pcie_release_resource() a better choice which also unmap
> the io if any was mapped?
>
> Regards,
> - Franky
>
>> + return err;
>> }
>>
>>
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource()
2022-09-23 16:50 ` Franky Lin
2022-09-24 1:00 ` Ruan Jinjie
@ 2022-09-24 2:54 ` Ruan Jinjie
1 sibling, 0 replies; 6+ messages in thread
From: Ruan Jinjie @ 2022-09-24 2:54 UTC (permalink / raw)
To: Franky Lin
Cc: aspriel, hante.meuleman, kvalo, davem, edumazet, kuba, pabeni,
marcan, linus.walleij, rmk+kernel, soontak.lee, linux-wireless,
SHA-cyfmac-dev-list, brcm80211-dev-list.pdl, netdev,
linux-kernel
On 2022/9/24 0:50, Franky Lin wrote:
> On Fri, Sep 23, 2022 at 2:42 AM ruanjinjie <ruanjinjie@huawei.com> wrote:
>>
>> Add missing pci_disable_device() if brcmf_pcie_get_resource() fails.
>
> Did you encounter any issue because of the absensent
> pci_disable_device? A bit more context will be very helpful.
>
>>
>> Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
>> ---
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> index f98641bb1528..25fa69793d86 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> @@ -1725,7 +1725,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
>> if ((bar1_size == 0) || (bar1_addr == 0)) {
>> brcmf_err(bus, "BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
>> bar1_size, (unsigned long long)bar1_addr);
>> - return -EINVAL;
>> + err = -EINVAL;
>> + goto err_disable;
>> }
>>
>> devinfo->regs = ioremap(bar0_addr, BRCMF_PCIE_REG_MAP_SIZE);
>> @@ -1734,7 +1735,8 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
>> if (!devinfo->regs || !devinfo->tcm) {
>> brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
>> devinfo->tcm);
>> - return -EINVAL;
>> + err = -EINVAL;
>> + goto err_disable;
>> }
>> brcmf_dbg(PCIE, "Phys addr : reg space = %p base addr %#016llx\n",
>> devinfo->regs, (unsigned long long)bar0_addr);
>> @@ -1743,6 +1745,9 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
>> (unsigned int)bar1_size);
>>
>> return 0;
>> +err_disable:
>> + pci_disable_device(pdev);
>
> Isn't brcmf_pcie_release_resource() a better choice which also unmap
> the io if any was mapped?
>
That is a better choice to call pci_disable_device() in
brcmf_pcie_release_resource()!
> Regards,
> - Franky
>
>> + return err;
>> }
>>
>>
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource()
2022-09-24 1:00 ` Ruan Jinjie
@ 2022-09-26 7:58 ` Kalle Valo
2022-09-26 8:06 ` Ruan Jinjie
0 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2022-09-26 7:58 UTC (permalink / raw)
To: Ruan Jinjie
Cc: Franky Lin, aspriel, hante.meuleman, davem, edumazet, kuba,
pabeni, marcan, linus.walleij, rmk+kernel, soontak.lee,
linux-wireless, SHA-cyfmac-dev-list, brcm80211-dev-list.pdl,
netdev, linux-kernel
Ruan Jinjie <ruanjinjie@huawei.com> writes:
> On 2022/9/24 0:50, Franky Lin wrote:
>> On Fri, Sep 23, 2022 at 2:42 AM ruanjinjie <ruanjinjie@huawei.com> wrote:
>>>
>>> Add missing pci_disable_device() if brcmf_pcie_get_resource() fails.
>>
>> Did you encounter any issue because of the absensent
>> pci_disable_device? A bit more context will be very helpful.
>>
>
> We use static analysis via coccinelle to find the above issue. The
> command we use is below:
>
> spatch -I include -timeout 60 -very_quiet -sp_file
> pci_disable_device_missing.cocci
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
Please include this information to the commit log, it helps to
understand the background of the fix.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource()
2022-09-26 7:58 ` Kalle Valo
@ 2022-09-26 8:06 ` Ruan Jinjie
0 siblings, 0 replies; 6+ messages in thread
From: Ruan Jinjie @ 2022-09-26 8:06 UTC (permalink / raw)
To: Kalle Valo
Cc: Franky Lin, aspriel, hante.meuleman, davem, edumazet, kuba,
pabeni, marcan, linus.walleij, rmk+kernel, soontak.lee,
linux-wireless, SHA-cyfmac-dev-list, brcm80211-dev-list.pdl,
netdev, linux-kernel
On 2022/9/26 15:58, Kalle Valo wrote:
> Ruan Jinjie <ruanjinjie@huawei.com> writes:
>
>> On 2022/9/24 0:50, Franky Lin wrote:
>>> On Fri, Sep 23, 2022 at 2:42 AM ruanjinjie <ruanjinjie@huawei.com> wrote:
>>>>
>>>> Add missing pci_disable_device() if brcmf_pcie_get_resource() fails.
>>>
>>> Did you encounter any issue because of the absensent
>>> pci_disable_device? A bit more context will be very helpful.
>>>
>>
>> We use static analysis via coccinelle to find the above issue. The
>> command we use is below:
>>
>> spatch -I include -timeout 60 -very_quiet -sp_file
>> pci_disable_device_missing.cocci
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>
> Please include this information to the commit log, it helps to
> understand the background of the fix.
Thank you for your suggestion! I'll include this information in the
future commit log.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-26 8:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 9:38 [PATCH -next] wifi: brcmfmac: pcie: add missing pci_disable_device() in brcmf_pcie_get_resource() ruanjinjie
2022-09-23 16:50 ` Franky Lin
2022-09-24 1:00 ` Ruan Jinjie
2022-09-26 7:58 ` Kalle Valo
2022-09-26 8:06 ` Ruan Jinjie
2022-09-24 2:54 ` Ruan Jinjie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).