Message ID | 20230304-topic-ddr_bwmon-v3-0-77a050c2fbda@linaro.org |
---|---|
Headers | show |
Series | Fix BWMONv4 for <SDM845 | expand |
On 15/03/2023 15:11, Konrad Dybcio wrote: > The BWMON hardware has two sets of registers: one for the monitor itself > and one called "global". It has what seems to be some kind of a head > switch and an interrupt control register. It's usually 0x200 in size. > > On fairly recent SoCs (with the starting point seemingly being moving > the OSM programming to the firmware) these two register sets are > contiguous and overlapping, like this (on sm8450): > > /* notice how base.start == global_base.start+0x100 */ > reg = <0x90b6400 0x300>, <0x90b6300 0x200>; > reg-names = "base", "global_base"; > > Which led to some confusion and the assumption that since the > "interesting" global registers begin right after global_base+0x100, > there's no need to map two separate regions and one can simply subtract > 0x100 from the offsets. > > This is however not the case for anything older than SDM845, as the > global region can appear in seemingly random spots on the register map. > > Handle the case where the global registers are mapped separately to allow > proper functioning of BWMONv4 on MSM8998 and older. Add specific > compatibles for 845, 8280xp, 7280 and 8550 (all of which use the single > reg space scheme) to keep backwards compatibility with old DTs. > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > --- > drivers/soc/qcom/icc-bwmon.c | 230 +++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 209 insertions(+), 21 deletions(-) > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof
On Wed, 15 Mar 2023 15:11:18 +0100, Konrad Dybcio wrote: > v2 -> v3: > - Rename: "DDR BWMON" -> "CPU BWMON" [2, 6/7] > - Set F_IRQ_STATUS = F_NUM_GLOBAL_FIELDS in enum bwmon_fields to save > one space in the enum > - Correct the struct icc_bwmon->global_regs array size > - Reorder the "Remove unused struct member" patch to come before the big > one > > [...] Applied, thanks! [4/7] arm64: dts: qcom: sc7280: Use the correct BWMON fallback compatible commit: bad26511c4cb5469545834886e8df1d2b4c117d8 [5/7] arm64: dts: qcom: sc8280xp: Use the correct BWMON fallback compatible commit: 5e1b11c00ffc0a2d105af5a92053fa10ca15fcd0 [6/7] arm64: dts: qcom: sdm845: Use the correct BWMON compatible commit: e95b60f1207dee16e0d3d66254ece655fd4e73c0 [7/7] arm64: dts: qcom: sm8550: Use the correct BWMON fallback compatible commit: feffd767971e25f43ba47bf2ab23a660f3a3758c Best regards,
v2 -> v3: - Rename: "DDR BWMON" -> "CPU BWMON" [2, 6/7] - Set F_IRQ_STATUS = F_NUM_GLOBAL_FIELDS in enum bwmon_fields to save one space in the enum - Correct the struct icc_bwmon->global_regs array size - Reorder the "Remove unused struct member" patch to come before the big one v2: https://lore.kernel.org/r/20230304-topic-ddr_bwmon-v2-0-04db989db059@linaro.org v1 -> v2: - Un-mess-up the example in bindings - Correctly limit reg/-names in bindings - Introduce "qcom,sdm845-cpu-bwmon" - Fix incorrect register assignment in msm8998_bwmon_reg_noread_ranges - Clean up the code around setting global registers on <=8998 - Don't add a separate enum for global registers - Don't use _GLOBAL vs _GLB - Add of match entries for targets that abused qcom,msm8998-bwmon before to keep old DTs working - Add comments near of match entries to make things clearer - Instead of if (...) { write to x } else { write to y } make the global register variable to keep the code more readable - Add dts patches to stop improperly using the 8998 compatible - (grumpily) drop Fixes from [2/7] - Pick up rb on [3/7] - Re-test on MSM8998 and SM6375 (OOT, uses 845-style BWMONv4) v1: https://lore.kernel.org/r/20230304-topic-ddr_bwmon-v1-0-e563837dc7d1@linaro.org BWMONv4 (the one used for DDR scaling on all SoCs from msm8998 to sm8550) features two register regions: "monitor" and "global" with the first one containing registers specific to the throughput monitor itself and the second one containing some sort of a head switch. The register layout on all BWMON versions an implementations up to that looked like this: |..........[GLOBAL].........[MONITOR]........| however with SDM845 somebody thought it would be a good idea to turn it into this: |................[GLOBAL]....................| |....................[MONITOR]...............| Sadly, the existing upstream driver was architected with SDM845 in mind, which means it doesn't support the global registers being somewhere else than near the beginning of the monitor space. This series tries to address that in the hopefully least painful way. Tested on msm8998 (the count unit seems to be wrong, should probably be 1MiB and not 64 KiB but the point is that this series makes it work at all, as without it the headswitch is never turned on) and SM6375 (with the "combined" layout introduced in SDM845). Equally sadly, everybody uses the qcom,msm8998-bwmon compatible (which frankly should have been just qcom,bwmon-v4) that never actually worked on MSM8998 , which prevents us from handling it in a simpler way.. While at it, an unused struct member is removed. One suboptimal feature of this patchset is that it introduces an "invalid resource" print from within devres. This could be solved with an introduction of devm_ioremap_resource_optional or by dropping devres functions in place of manual handling, which also doesn't sound great.. I'll leave it up to the reviewers to decide. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> --- Konrad Dybcio (7): dt-bindings: interconnect: qcom,msm8998-bwmon: Resolve MSM8998 support soc: qcom: icc-bwmon: Remove unused struct member soc: qcom: icc-bwmon: Handle global registers correctly arm64: dts: qcom: sc7280: Use the correct BWMON fallback compatible arm64: dts: qcom: sc8280xp: Use the correct BWMON fallback compatible arm64: dts: qcom: sdm845: Use the correct BWMON compatible arm64: dts: qcom: sm8550: Use the correct BWMON fallback compatible .../bindings/interconnect/qcom,msm8998-bwmon.yaml | 41 +++- arch/arm64/boot/dts/qcom/sc7280.dtsi | 2 +- arch/arm64/boot/dts/qcom/sc8280xp.dtsi | 2 +- arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +- arch/arm64/boot/dts/qcom/sm8550.dtsi | 2 +- drivers/soc/qcom/icc-bwmon.c | 231 +++++++++++++++++++-- 6 files changed, 247 insertions(+), 33 deletions(-) --- base-commit: 24469a0e5052ba01a35a15f104717a82b7a4798b change-id: 20230304-topic-ddr_bwmon-609022cd5e35 Best regards,