* [PATCH 0/2] wifi: ath11k: fix ioremap() leak
@ 2024-04-30 13:30 Jeff Johnson
2024-04-30 13:30 ` [PATCH 1/2] wifi: ath11k: refactor CE remap & unmap Jeff Johnson
2024-04-30 13:30 ` [PATCH 2/2] wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path Jeff Johnson
0 siblings, 2 replies; 4+ messages in thread
From: Jeff Johnson @ 2024-04-30 13:30 UTC (permalink / raw
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Jeff Johnson
smatch flagged the following issue:
drivers/net/wireless/ath/ath11k/ahb.c:1218 ath11k_ahb_probe() warn: 'ab->mem_ce' from ioremap() not released on lines: 1218.
Fix it by refactoring the ioremap and iounmap code and then calling the
unmap in the ath11k_ahb_probe() error path.
---
Jeff Johnson (2):
wifi: ath11k: refactor CE remap & unmap
wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path
drivers/net/wireless/ath/ath11k/ahb.c | 57 +++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 19 deletions(-)
---
base-commit: bf99bc7423e18aa3475ef00a7a6fb773c31ce6df
change-id: 20240427-ce-unmap-3030e38ba1bb
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] wifi: ath11k: refactor CE remap & unmap
2024-04-30 13:30 [PATCH 0/2] wifi: ath11k: fix ioremap() leak Jeff Johnson
@ 2024-04-30 13:30 ` Jeff Johnson
2024-05-03 13:15 ` Kalle Valo
2024-04-30 13:30 ` [PATCH 2/2] wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path Jeff Johnson
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Johnson @ 2024-04-30 13:30 UTC (permalink / raw
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Jeff Johnson
Currently the logic that handles hw_params->ce_remap is inline code,
both for doing the remap and the unmap. An upcoming change needs to do
the unmap in a second place, so refactor the unmap logic into a
separate function. And although it is only called from one place,
refactor the remap logic as well to have functional symmetry.
No functional changes, compile tested only.
Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
---
drivers/net/wireless/ath/ath11k/ahb.c | 52 +++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c
index 60b4c2800a33..aa62ed710090 100644
--- a/drivers/net/wireless/ath/ath11k/ahb.c
+++ b/drivers/net/wireless/ath/ath11k/ahb.c
@@ -949,6 +949,36 @@ static int ath11k_ahb_setup_msa_resources(struct ath11k_base *ab)
return 0;
}
+static int ath11k_ahb_ce_remap(struct ath11k_base *ab)
+{
+ const struct ce_remap *ce_remap = ab->hw_params.ce_remap;
+ struct platform_device *pdev = ab->pdev;
+
+ if (!ce_remap) {
+ /* no separate CE register space */
+ ab->mem_ce = ab->mem;
+ return 0;
+ }
+
+ /* ce register space is moved out of wcss unlike ipq8074 or ipq6018
+ * and the space is not contiguous, hence remapping the CE registers
+ * to a new space for accessing them.
+ */
+ ab->mem_ce = ioremap(ce_remap->base, ce_remap->size);
+ if (!ab->mem_ce) {
+ dev_err(&pdev->dev, "ce ioremap error\n");
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static void ath11k_ahb_ce_unmap(struct ath11k_base *ab)
+{
+ if (ab->hw_params.ce_remap)
+ iounmap(ab->mem_ce);
+}
+
static int ath11k_ahb_fw_resources_init(struct ath11k_base *ab)
{
struct ath11k_ahb *ab_ahb = ath11k_ahb_priv(ab);
@@ -1141,21 +1171,9 @@ static int ath11k_ahb_probe(struct platform_device *pdev)
if (ret)
goto err_core_free;
- ab->mem_ce = ab->mem;
-
- if (ab->hw_params.ce_remap) {
- const struct ce_remap *ce_remap = ab->hw_params.ce_remap;
- /* ce register space is moved out of wcss unlike ipq8074 or ipq6018
- * and the space is not contiguous, hence remapping the CE registers
- * to a new space for accessing them.
- */
- ab->mem_ce = ioremap(ce_remap->base, ce_remap->size);
- if (!ab->mem_ce) {
- dev_err(&pdev->dev, "ce ioremap error\n");
- ret = -ENOMEM;
- goto err_core_free;
- }
- }
+ ret = ath11k_ahb_ce_remap(ab);
+ if (ret)
+ goto err_core_free;
ret = ath11k_ahb_fw_resources_init(ab);
if (ret)
@@ -1243,9 +1261,7 @@ static void ath11k_ahb_free_resources(struct ath11k_base *ab)
ath11k_ahb_release_smp2p_handle(ab);
ath11k_ahb_fw_resource_deinit(ab);
ath11k_ce_free_pipes(ab);
-
- if (ab->hw_params.ce_remap)
- iounmap(ab->mem_ce);
+ ath11k_ahb_ce_unmap(ab);
ath11k_core_free(ab);
platform_set_drvdata(pdev, NULL);
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path
2024-04-30 13:30 [PATCH 0/2] wifi: ath11k: fix ioremap() leak Jeff Johnson
2024-04-30 13:30 ` [PATCH 1/2] wifi: ath11k: refactor CE remap & unmap Jeff Johnson
@ 2024-04-30 13:30 ` Jeff Johnson
1 sibling, 0 replies; 4+ messages in thread
From: Jeff Johnson @ 2024-04-30 13:30 UTC (permalink / raw
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Jeff Johnson
Currently, in ath11k_ahb_probe(), if a failure occurs after
ath11k_ahb_ce_remap() is called, and if hw_params->ce_remap is
enabled, the CE register memory is not unmapped. So add a call to
ath11k_ahb_ce_unmap() in the error path.
This issue was identified by smatch/smatch_scripts/kchecker:
drivers/net/wireless/ath/ath11k/ahb.c:1218 ath11k_ahb_probe() warn: 'ab->mem_ce' from ioremap() not released on lines: 1218.
Since this is a rare error path with no simple way to test, and since
the change is trivial to review, compile tested only.
Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
---
drivers/net/wireless/ath/ath11k/ahb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c
index aa62ed710090..ef0ede16aac8 100644
--- a/drivers/net/wireless/ath/ath11k/ahb.c
+++ b/drivers/net/wireless/ath/ath11k/ahb.c
@@ -1177,7 +1177,7 @@ static int ath11k_ahb_probe(struct platform_device *pdev)
ret = ath11k_ahb_fw_resources_init(ab);
if (ret)
- goto err_core_free;
+ goto err_ce_unmap;
ret = ath11k_ahb_setup_smp2p_handle(ab);
if (ret)
@@ -1229,6 +1229,9 @@ static int ath11k_ahb_probe(struct platform_device *pdev)
err_fw_deinit:
ath11k_ahb_fw_resource_deinit(ab);
+err_ce_unmap:
+ ath11k_ahb_ce_unmap(ab);
+
err_core_free:
ath11k_core_free(ab);
platform_set_drvdata(pdev, NULL);
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] wifi: ath11k: refactor CE remap & unmap
2024-04-30 13:30 ` [PATCH 1/2] wifi: ath11k: refactor CE remap & unmap Jeff Johnson
@ 2024-05-03 13:15 ` Kalle Valo
0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2024-05-03 13:15 UTC (permalink / raw
To: Jeff Johnson
Cc: Jeff Johnson, linux-wireless, ath11k, linux-kernel, Jeff Johnson
Jeff Johnson <quic_jjohnson@quicinc.com> wrote:
> Currently the logic that handles hw_params->ce_remap is inline code,
> both for doing the remap and the unmap. An upcoming change needs to do
> the unmap in a second place, so refactor the unmap logic into a
> separate function. And although it is only called from one place,
> refactor the remap logic as well to have functional symmetry.
>
> No functional changes, compile tested only.
>
> Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
2 patches applied to ath-next branch of ath.git, thanks.
8b9ea752a9d6 wifi: ath11k: refactor CE remap & unmap
c57d00a4d3d8 wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path
--
https://patchwork.kernel.org/project/linux-wireless/patch/20240430-ce-unmap-v1-1-e468328f95d9@quicinc.com/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-03 13:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 13:30 [PATCH 0/2] wifi: ath11k: fix ioremap() leak Jeff Johnson
2024-04-30 13:30 ` [PATCH 1/2] wifi: ath11k: refactor CE remap & unmap Jeff Johnson
2024-05-03 13:15 ` Kalle Valo
2024-04-30 13:30 ` [PATCH 2/2] wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path Jeff Johnson
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 read-only IMAP folder(s) and NNTP newsgroup(s).