* [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support
@ 2021-12-06 11:15 Anilkumar Kolli
2021-12-06 11:15 ` [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices Anilkumar Kolli
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Anilkumar Kolli @ 2021-12-06 11:15 UTC (permalink / raw)
To: ath11k; +Cc: linux-wireless, devicetree, robh, Anilkumar Kolli
Ath11k driver supports PCI devices such as QCN9074/QCA6390.
Ath11k firmware uses host DDR memory, DT entry is used to
reserve host DDR memory regions, send these memory base
addresses using DT entries.
Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
---
V4:
- Fix dt_binding_check warnings (Rob)
V2:
- Use reserved-memory (Rob)
.../bindings/net/wireless/qcom,ath11k.yaml | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml
index 85c2f699d602..cdf7b873b419 100644
--- a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml
+++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml
@@ -150,6 +150,12 @@ properties:
string to uniquely identify variant of the calibration data in the
board-2.bin for designs with colliding bus and device specific ids
+ memory-region:
+ maxItems: 1
+ description:
+ phandle to a node describing reserved memory (System RAM memory)
+ used by ath11k firmware (see bindings/reserved-memory/reserved-memory.txt)
+
required:
- compatible
- reg
@@ -279,3 +285,27 @@ examples:
"tcl2host-status-ring";
qcom,rproc = <&q6v5_wcss>;
};
+
+ - |
+
+ reserved-memory {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ qcn9074_0: qcn9074_0@51100000 {
+ no-map;
+ reg = <0x0 0x51100000 0x0 0x03500000>;
+ };
+ };
+
+ pci {
+ pcie0 {
+ #size-cells = <2>;
+ #address-cells = <3>;
+
+ wifi_0: wifi@0 {
+ reg = <0 0 0 0 0>;
+ memory-region = <&qcn9074_0>;
+ };
+ };
+ };
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices 2021-12-06 11:15 [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Anilkumar Kolli @ 2021-12-06 11:15 ` Anilkumar Kolli 2021-12-09 8:07 ` Kalle Valo 2021-12-07 20:10 ` [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Rob Herring 2021-12-16 15:34 ` Kalle Valo 2 siblings, 1 reply; 6+ messages in thread From: Anilkumar Kolli @ 2021-12-06 11:15 UTC (permalink / raw) To: ath11k; +Cc: linux-wireless, devicetree, robh, Anilkumar Kolli Host DDR memory (contiguous 45 MB in mode-0 or 15 MB in mode-2) is reserved through DT entries for firmware usage. Send the base address from DT entries. If DT entry is available, PCI device will work with fixed_mem_region else host allocates multiple segments. IPQ8074 on HK10 board supports multiple PCI devices. IPQ8074 + QCN9074 is tested with this patch. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1 Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org> --- V7: - Rebase on latest ath.git (Kalle) V6: - Use of_parse_phandle() (Sven) V5: - Use of_address_to_resource() (Sven) V4: - Update code review comments to handle return (Kalle) V3: - remove type cast and use of_property_read_u32_array() (Kalle) V2: - Use of_ API to read from dt node (Rob) drivers/net/wireless/ath/ath11k/core.h | 1 + drivers/net/wireless/ath/ath11k/mhi.c | 34 ++++++++++++++++- drivers/net/wireless/ath/ath11k/pci.c | 11 +++++- drivers/net/wireless/ath/ath11k/qmi.c | 67 +++++++++++++++++++++++++++++----- drivers/net/wireless/ath/ath11k/qmi.h | 1 + 5 files changed, 101 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 0103cfd0508d..e8157db337c7 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -201,6 +201,7 @@ enum ath11k_dev_flags { ATH11K_FLAG_HTC_SUSPEND_COMPLETE, ATH11K_FLAG_CE_IRQ_ENABLED, ATH11K_FLAG_EXT_IRQ_ENABLED, + ATH11K_FLAG_FIXED_MEM_RGN, }; enum ath11k_monitor_flags { diff --git a/drivers/net/wireless/ath/ath11k/mhi.c b/drivers/net/wireless/ath/ath11k/mhi.c index d0f94a785a59..5f2789c40125 100644 --- a/drivers/net/wireless/ath/ath11k/mhi.c +++ b/drivers/net/wireless/ath/ath11k/mhi.c @@ -3,6 +3,9 @@ #include <linux/msi.h> #include <linux/pci.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/ioport.h> #include "core.h" #include "debug.h" @@ -318,6 +321,26 @@ static void ath11k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl, writel(val, addr); } +static int ath11k_mhi_read_addr_from_dt(struct mhi_controller *mhi_ctrl) +{ + struct device_node *np; + struct resource res; + int ret; + + np = of_find_node_by_type(NULL, "memory"); + if (!np) + return -ENOENT; + + ret = of_address_to_resource(np, 0, &res); + if (ret) + return ret; + + mhi_ctrl->iova_start = res.start + 0x1000000; + mhi_ctrl->iova_stop = res.end; + + return 0; +} + int ath11k_mhi_register(struct ath11k_pci *ab_pci) { struct ath11k_base *ab = ab_pci->ab; @@ -349,8 +372,15 @@ int ath11k_mhi_register(struct ath11k_pci *ab_pci) if (!test_bit(ATH11K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags)) mhi_ctrl->irq_flags = IRQF_SHARED | IRQF_NOBALANCING; - mhi_ctrl->iova_start = 0; - mhi_ctrl->iova_stop = 0xffffffff; + if ((test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags))) { + ret = ath11k_mhi_read_addr_from_dt(mhi_ctrl); + if (ret < 0) + return ret; + } else { + mhi_ctrl->iova_start = 0; + mhi_ctrl->iova_stop = 0xFFFFFFFF; + } + mhi_ctrl->sbl_size = SZ_512K; mhi_ctrl->seg_len = SZ_512K; mhi_ctrl->fbc_download = true; diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c index 1898b1a33960..83ee14623468 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -6,6 +6,7 @@ #include <linux/module.h> #include <linux/msi.h> #include <linux/pci.h> +#include <linux/of.h> #include "pci.h" #include "core.h" @@ -1347,7 +1348,7 @@ static int ath11k_pci_probe(struct pci_dev *pdev, { struct ath11k_base *ab; struct ath11k_pci *ab_pci; - u32 soc_hw_version_major, soc_hw_version_minor; + u32 soc_hw_version_major, soc_hw_version_minor, addr; int ret; ab = ath11k_core_alloc(&pdev->dev, sizeof(*ab_pci), ATH11K_BUS_PCI, @@ -1367,6 +1368,14 @@ static int ath11k_pci_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, ab); spin_lock_init(&ab_pci->window_lock); + /* Set fixed_mem_region to true for platforms support reserved memory + * from DT. If memory is reserved from DT for FW, ath11k driver need not + * allocate memory. + */ + ret = of_property_read_u32(ab->dev->of_node, "memory-region", &addr); + if (!ret) + set_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags); + ret = ath11k_pci_claim(ab_pci, pdev); if (ret) { ath11k_err(ab, "failed to claim device: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index 25eb22cbeaeb..625d525a86b9 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -9,6 +9,8 @@ #include "core.h" #include "debug.h" #include <linux/of.h> +#include <linux/of_address.h> +#include <linux/ioport.h> #include <linux/firmware.h> #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02 @@ -1751,7 +1753,9 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) * failure to FW and FW will then request mulitple blocks of small * chunk size memory. */ - if (!ab->bus_params.fixed_mem_region && ab->qmi.target_mem_delayed) { + if (!(ab->bus_params.fixed_mem_region || + test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) && + ab->qmi.target_mem_delayed) { delayed = true; ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n", ab->qmi.mem_seg_count); @@ -1818,10 +1822,12 @@ static void ath11k_qmi_free_target_mem_chunk(struct ath11k_base *ab) { int i; - if (ab->bus_params.fixed_mem_region) - return; - for (i = 0; i < ab->qmi.mem_seg_count; i++) { + if ((ab->bus_params.fixed_mem_region || + test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) && + ab->qmi.target_mem[i].iaddr) + iounmap(ab->qmi.target_mem[i].iaddr); + if (!ab->qmi.target_mem[i].vaddr) continue; @@ -1869,10 +1875,44 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) { - int i, idx; + struct device *dev = ab->dev; + struct device_node *hremote_node = NULL; + struct resource res; + u32 host_ddr_sz; + int i, idx, ret; for (i = 0, idx = 0; i < ab->qmi.mem_seg_count; i++) { switch (ab->qmi.target_mem[i].type) { + case HOST_DDR_REGION_TYPE: + hremote_node = of_parse_phandle(dev->of_node, "memory-region", 0); + if (!hremote_node) { + ath11k_dbg(ab, ATH11K_DBG_QMI, + "qmi fail to get hremote_node\n"); + return ret; + } + + ret = of_address_to_resource(hremote_node, 0, &res); + if (ret) { + ath11k_dbg(ab, ATH11K_DBG_QMI, + "qmi fail to get reg from hremote\n"); + return ret; + } + + if (res.end - res.start + 1 < ab->qmi.target_mem[i].size) { + ath11k_dbg(ab, ATH11K_DBG_QMI, + "qmi fail to assign memory of sz\n"); + return -EINVAL; + } + + ab->qmi.target_mem[idx].paddr = res.start; + ab->qmi.target_mem[idx].iaddr = + ioremap(ab->qmi.target_mem[idx].paddr, + ab->qmi.target_mem[i].size); + ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; + host_ddr_sz = ab->qmi.target_mem[i].size; + ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; + idx++; + break; case BDF_MEM_REGION_TYPE: ab->qmi.target_mem[idx].paddr = ab->hw_params.bdf_addr; ab->qmi.target_mem[idx].vaddr = NULL; @@ -1887,10 +1927,16 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) } if (ath11k_cold_boot_cal && ab->hw_params.cold_boot_calib) { - ab->qmi.target_mem[idx].paddr = - ATH11K_QMI_CALDB_ADDRESS; - ab->qmi.target_mem[idx].vaddr = - (void *)ATH11K_QMI_CALDB_ADDRESS; + if (hremote_node) { + ab->qmi.target_mem[idx].paddr = + res.start + host_ddr_sz; + ab->qmi.target_mem[idx].iaddr = + ioremap(ab->qmi.target_mem[idx].paddr, + ab->qmi.target_mem[i].size); + } else { + ab->qmi.target_mem[idx].paddr = + ATH11K_QMI_CALDB_ADDRESS; + } } else { ab->qmi.target_mem[idx].paddr = 0; ab->qmi.target_mem[idx].vaddr = NULL; @@ -2621,7 +2667,8 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl, msg->mem_seg[i].type, msg->mem_seg[i].size); } - if (ab->bus_params.fixed_mem_region) { + if (ab->bus_params.fixed_mem_region || + test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) { ret = ath11k_qmi_assign_target_mem_chunk(ab); if (ret) { ath11k_warn(ab, "failed to assign qmi target memory: %d\n", diff --git a/drivers/net/wireless/ath/ath11k/qmi.h b/drivers/net/wireless/ath/ath11k/qmi.h index 3bb0f9ef7996..f8d45b7dc821 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.h +++ b/drivers/net/wireless/ath/ath11k/qmi.h @@ -95,6 +95,7 @@ struct target_mem_chunk { u32 type; dma_addr_t paddr; u32 *vaddr; + void __iomem *iaddr; }; struct target_info { -- 2.7.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices 2021-12-06 11:15 ` [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices Anilkumar Kolli @ 2021-12-09 8:07 ` Kalle Valo 0 siblings, 0 replies; 6+ messages in thread From: Kalle Valo @ 2021-12-09 8:07 UTC (permalink / raw) To: Anilkumar Kolli; +Cc: ath11k, linux-wireless, devicetree, robh Anilkumar Kolli <akolli@codeaurora.org> writes: > Host DDR memory (contiguous 45 MB in mode-0 or 15 MB in mode-2) > is reserved through DT entries for firmware usage. Send the base > address from DT entries. > If DT entry is available, PCI device will work with > fixed_mem_region else host allocates multiple segments. > > IPQ8074 on HK10 board supports multiple PCI devices. > IPQ8074 + QCN9074 is tested with this patch. > > Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1 > > Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org> [...] > @@ -349,8 +372,15 @@ int ath11k_mhi_register(struct ath11k_pci *ab_pci) > if (!test_bit(ATH11K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags)) > mhi_ctrl->irq_flags = IRQF_SHARED | IRQF_NOBALANCING; > > - mhi_ctrl->iova_start = 0; > - mhi_ctrl->iova_stop = 0xffffffff; > + if ((test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags))) { Unnecessary parenthesis, I fixed it in the pending branch. -- 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 v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support 2021-12-06 11:15 [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Anilkumar Kolli 2021-12-06 11:15 ` [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices Anilkumar Kolli @ 2021-12-07 20:10 ` Rob Herring 2021-12-09 8:04 ` Kalle Valo 2021-12-16 15:34 ` Kalle Valo 2 siblings, 1 reply; 6+ messages in thread From: Rob Herring @ 2021-12-07 20:10 UTC (permalink / raw) To: Anilkumar Kolli; +Cc: ath11k, linux-wireless, devicetree On Mon, 06 Dec 2021 16:45:18 +0530, Anilkumar Kolli wrote: > Ath11k driver supports PCI devices such as QCN9074/QCA6390. > Ath11k firmware uses host DDR memory, DT entry is used to > reserve host DDR memory regions, send these memory base > addresses using DT entries. > > Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org> > --- > V4: > - Fix dt_binding_check warnings (Rob) > V2: > - Use reserved-memory (Rob) > > .../bindings/net/wireless/qcom,ath11k.yaml | 30 ++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply. If a tag was not added on purpose, please state why and what changed. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support 2021-12-07 20:10 ` [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Rob Herring @ 2021-12-09 8:04 ` Kalle Valo 0 siblings, 0 replies; 6+ messages in thread From: Kalle Valo @ 2021-12-09 8:04 UTC (permalink / raw) To: Rob Herring; +Cc: Anilkumar Kolli, ath11k, linux-wireless, devicetree Rob Herring <robh@kernel.org> writes: > On Mon, 06 Dec 2021 16:45:18 +0530, Anilkumar Kolli wrote: >> Ath11k driver supports PCI devices such as QCN9074/QCA6390. >> Ath11k firmware uses host DDR memory, DT entry is used to >> reserve host DDR memory regions, send these memory base >> addresses using DT entries. >> >> Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org> >> --- >> V4: >> - Fix dt_binding_check warnings (Rob) >> V2: >> - Use reserved-memory (Rob) >> >> .../bindings/net/wireless/qcom,ath11k.yaml | 30 ++++++++++++++++++++++ >> 1 file changed, 30 insertions(+) >> > > > Please add Acked-by/Reviewed-by tags when posting new versions. However, > there's no need to repost patches *only* to add the tags. The upstream > maintainer will do that for acks received on the version they apply. > > If a tag was not added on purpose, please state why and what changed. Anil, please clarify. I can add the Rob's Reviewed-by if nothing was changed since v6. -- 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 v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support 2021-12-06 11:15 [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Anilkumar Kolli 2021-12-06 11:15 ` [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices Anilkumar Kolli 2021-12-07 20:10 ` [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Rob Herring @ 2021-12-16 15:34 ` Kalle Valo 2 siblings, 0 replies; 6+ messages in thread From: Kalle Valo @ 2021-12-16 15:34 UTC (permalink / raw) To: Anilkumar Kolli; +Cc: ath11k, linux-wireless, devicetree, robh, Anilkumar Kolli Anilkumar Kolli <akolli@codeaurora.org> wrote: > Ath11k driver supports PCI devices such as QCN9074/QCA6390. > Ath11k firmware uses host DDR memory, DT entry is used to > reserve host DDR memory regions, send these memory base > addresses using DT entries. > > Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org> > Reviewed-by: Rob Herring <robh@kernel.org> > Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> 2 patches applied to ath-next branch of ath.git, thanks. 77a0a30bb507 dt: bindings: add new DT entry for ath11k PCI device support 6ac04bdc5edb ath11k: Use reserved host DDR addresses from DT for PCI devices -- https://patchwork.kernel.org/project/linux-wireless/patch/1638789319-2950-1-git-send-email-akolli@codeaurora.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-12-16 15:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-12-06 11:15 [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Anilkumar Kolli 2021-12-06 11:15 ` [PATCH v7 2/2] ath11k: Use reserved host DDR addresses from DT for PCI devices Anilkumar Kolli 2021-12-09 8:07 ` Kalle Valo 2021-12-07 20:10 ` [PATCH v7 1/2] dt: bindings: add new DT entry for ath11k PCI device support Rob Herring 2021-12-09 8:04 ` Kalle Valo 2021-12-16 15:34 ` Kalle Valo
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).