1 |
From 8d590e275cdf797c08acb58439f6911c403a853b Mon Sep 17 00:00:00 2001 |
2 |
From: Sasha Levin <sashal@kernel.org> |
3 |
Date: Thu, 18 Aug 2022 08:42:05 -0500 |
4 |
Subject: net: ipa: don't assume SMEM is page-aligned |
5 |
|
6 |
From: Alex Elder <elder@linaro.org> |
7 |
|
8 |
[ Upstream commit b8d4380365c515d8e0351f2f46d371738dd19be1 ] |
9 |
|
10 |
In ipa_smem_init(), a Qualcomm SMEM region is allocated (if needed) |
11 |
and then its virtual address is fetched using qcom_smem_get(). The |
12 |
physical address associated with that region is also fetched. |
13 |
|
14 |
The physical address is adjusted so that it is page-aligned, and an |
15 |
attempt is made to update the size of the region to compensate for |
16 |
any non-zero adjustment. |
17 |
|
18 |
But that adjustment isn't done properly. The physical address is |
19 |
aligned twice, and as a result the size is never actually adjusted. |
20 |
|
21 |
Fix this by *not* aligning the "addr" local variable, and instead |
22 |
making the "phys" local variable be the adjusted "addr" value. |
23 |
|
24 |
Fixes: a0036bb413d5b ("net: ipa: define SMEM memory region for IPA") |
25 |
Signed-off-by: Alex Elder <elder@linaro.org> |
26 |
Link: https://lore.kernel.org/r/20220818134206.567618-1-elder@linaro.org |
27 |
Signed-off-by: Jakub Kicinski <kuba@kernel.org> |
28 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
29 |
--- |
30 |
drivers/net/ipa/ipa_mem.c | 2 +- |
31 |
1 file changed, 1 insertion(+), 1 deletion(-) |
32 |
|
33 |
diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c |
34 |
index 1e9eae208e44f..53a1dbeaffa6d 100644 |
35 |
--- a/drivers/net/ipa/ipa_mem.c |
36 |
+++ b/drivers/net/ipa/ipa_mem.c |
37 |
@@ -568,7 +568,7 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size) |
38 |
} |
39 |
|
40 |
/* Align the address down and the size up to a page boundary */ |
41 |
- addr = qcom_smem_virt_to_phys(virt) & PAGE_MASK; |
42 |
+ addr = qcom_smem_virt_to_phys(virt); |
43 |
phys = addr & PAGE_MASK; |
44 |
size = PAGE_ALIGN(size + addr - phys); |
45 |
iova = phys; /* We just want a direct mapping */ |
46 |
-- |
47 |
2.35.1 |
48 |
|