From a2176b00dcbb09b072d3e7843cd3b7de8eed6545 Mon Sep 17 00:00:00 2001 From: Simon1511 Date: Sun, 23 Jun 2024 13:19:56 +0200 Subject: [PATCH] sm7125: merge A525FXXU6EWL3 sources Change-Id: I5c3f62afd4d8e770e66f84b49af51f28e7fbe959 --- .../admin-guide/kernel-parameters.txt | 9 +- .../bindings/thermal/qti-ddr-cdev.txt | 65 - arch/arm64/Kconfig.projects | 8 +- arch/arm64/boot/dts/samsung/Makefile | 7 + ...atoll-sec-gta4xlvewifi-kor-overlay-r00.dts | 48 +- .../atoll-sec-gta4xlve-battery-common.dtsi | 4 +- .../gta4xlve/atoll-sec-gta4xlve-common.dtsi | 6 + .../configs/vendor/lineage-a52q_defconfig | 8 +- .../configs/vendor/lineage-a72q_defconfig | 8 +- arch/arm64/mm/init.c | 44 - arch/x86/boot/compressed/Makefile | 2 +- drivers/battery/common/sec_battery_ttf.c | 2 +- drivers/battery_v2/sec_battery_ttf.c | 2 +- drivers/block/zram/zcomp.c | 7 +- drivers/block/zram/zcomp.h | 1 + drivers/block/zram/zram_drv.c | 1067 +++++--- drivers/block/zram/zram_drv.h | 34 +- drivers/char/adsprpc.c | 37 +- drivers/clk/qcom/gcc-atoll.c | 1 + drivers/gpu/drm/msm/dsi-staging/dsi_panel.c | 1 + drivers/gpu/msm/adreno.h | 5 +- drivers/gpu/msm/adreno_a6xx_preempt.c | 19 +- drivers/gpu/msm/kgsl.c | 48 +- drivers/gpu/msm/kgsl.h | 6 + drivers/gpu/msm/kgsl_iommu.c | 14 +- drivers/gpu/msm/kgsl_pool.c | 10 + .../media/platform/msm/ais/ais_isp/Makefile | 13 - .../platform/msm/ais/ais_isp/ais_ife_dev.c | 711 ------ .../platform/msm/ais/ais_isp/ais_ife_dev.h | 47 - .../platform/msm/ais/ais_isp/csid_hw/Makefile | 9 - .../msm/ais/ais_isp/csid_hw/ais_ife_csid170.h | 316 --- .../msm/ais/ais_isp/csid_hw/ais_ife_csid175.h | 357 --- .../ais/ais_isp/csid_hw/ais_ife_csid175_200.h | 373 --- .../msm/ais/ais_isp/csid_hw/ais_ife_csid17x.c | 82 - .../ais/ais_isp/csid_hw/ais_ife_csid_core.c | 2150 ----------------- .../ais/ais_isp/csid_hw/ais_ife_csid_core.h | 591 ----- .../ais/ais_isp/csid_hw/ais_ife_csid_dev.c | 157 -- .../ais_isp/csid_hw/ais_ife_csid_lite17x.c | 61 - .../ais_isp/csid_hw/ais_ife_csid_lite17x.h | 322 --- .../ais/ais_isp/csid_hw/ais_ife_csid_soc.c | 239 -- .../ais/ais_isp/csid_hw/ais_ife_csid_soc.h | 126 - .../ais_isp/include/ais_ife_csid_hw_intf.h | 115 - .../msm/ais/ais_isp/include/ais_isp_hw.h | 528 ---- .../msm/ais/ais_isp/include/ais_vfe_hw_intf.h | 106 - .../platform/msm/ais/ais_isp/utils/Makefile | 9 - .../msm/ais/ais_isp/utils/ais_isp_trace.c | 38 - .../msm/ais/ais_isp/utils/ais_isp_trace.h | 259 -- .../platform/msm/ais/ais_isp/vfe_hw/Makefile | 16 - .../msm/ais/ais_isp/vfe_hw/ais_vfe_core.c | 1698 ------------- .../msm/ais/ais_isp/vfe_hw/ais_vfe_core.h | 181 -- .../msm/ais/ais_isp/vfe_hw/ais_vfe_dev.c | 223 -- .../msm/ais/ais_isp/vfe_hw/ais_vfe_dev.h | 42 - .../msm/ais/ais_isp/vfe_hw/ais_vfe_soc.c | 357 --- .../msm/ais/ais_isp/vfe_hw/ais_vfe_soc.h | 124 - .../msm/ais/ais_isp/vfe_hw/vfe17x/Makefile | 14 - .../ais/ais_isp/vfe_hw/vfe17x/ais_vfe170.h | 1046 -------- .../ais/ais_isp/vfe_hw/vfe17x/ais_vfe175.h | 1223 ---------- .../ais_isp/vfe_hw/vfe17x/ais_vfe175_130.h | 1327 ---------- .../ais/ais_isp/vfe_hw/vfe17x/ais_vfe17x.c | 71 - .../ais_isp/vfe_hw/vfe17x/ais_vfe_lite17x.h | 335 --- .../vfe_hw/vfe_bus/ais_vfe_bus_rd_ver1.h | 107 - .../ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver1.h | 100 - .../ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver2.h | 251 -- .../vfe_hw/vfe_bus/include/ais_vfe_bus.h | 25 - .../vfe_hw/vfe_top/ais_vfe_camif_lite_ver2.h | 46 - .../vfe_hw/vfe_top/ais_vfe_camif_ver2.h | 82 - .../ais_isp/vfe_hw/vfe_top/ais_vfe_fe_ver1.h | 80 - .../ais/ais_isp/vfe_hw/vfe_top/ais_vfe_rdi.h | 36 - .../ais_isp/vfe_hw/vfe_top/ais_vfe_top_ver2.h | 99 - .../vfe_hw/vfe_top/include/ais_vfe_top.h | 44 - drivers/media/platform/msm/npu/npu_mgr.c | 15 + drivers/media/platform/msm/npu/npu_mgr.h | 1 + drivers/media/platform/msm/npu_v2/npu_mgr.c | 15 + drivers/media/platform/msm/npu_v2/npu_mgr.h | 1 + drivers/misc/qseecom.c | 4 +- drivers/mmc/core/bus.c | 4 +- drivers/mmc/core/sdio_cis.c | 2 +- drivers/mmc/host/sdhci-msm.h | 2 +- drivers/mmc/host/sdhci.c | 3 +- drivers/muic/sm/sm5714/sm5714-muic.c | 53 +- drivers/net/wan/Kconfig | 2 +- drivers/net/wireless/cnss2/main.h | 5 +- .../dp/inc/cdp_txrx_cmn_struct.h | 4 + .../dp/inc/cdp_txrx_mob_def.h | 3 + .../qca-wifi-host-cmn/dp/wifi3.0/dp_main.c | 6 + .../qca-wifi-host-cmn/dp/wifi3.0/dp_rx.c | 13 +- .../qca-wifi-host-cmn/dp/wifi3.0/dp_stats.c | 5 + .../qca-wifi-host-cmn/dp/wifi3.0/dp_types.h | 2 + .../src/target_if_direct_buf_rx_main.c | 10 + .../qca-wifi-host-cmn/wlan_cfg/cfg_dp.h | 43 +- .../qca-wifi-host-cmn/wlan_cfg/wlan_cfg.c | 10 +- .../qca-wifi-host-cmn/wlan_cfg/wlan_cfg.h | 5 + .../wmi/src/wmi_unified_tlv.c | 17 + .../policy_mgr/inc/wlan_policy_mgr_api.h | 1 + .../src/wlan_policy_mgr_get_set_utils.c | 1 + .../src/wlan_policy_mgr_init_deinit.c | 1 + .../qcacld-3.0/configs/default_defconfig | 3 +- .../wcn39xx/qcacld-3.0/core/cds/src/cds_api.c | 25 +- .../qcacld-3.0/core/dp/ol/inc/ol_cfg.h | 3 + .../wcn39xx/qcacld-3.0/core/dp/txrx/ol_cfg.c | 3 + .../wcn39xx/qcacld-3.0/core/dp/txrx/ol_txrx.c | 7 + .../qcacld-3.0/core/hdd/inc/wlan_hdd_main.h | 24 +- .../qcacld-3.0/core/hdd/inc/wlan_hdd_tx_rx.h | 1 + .../qcacld-3.0/core/hdd/src/wlan_hdd_main.c | 154 +- .../qcacld-3.0/core/hdd/src/wlan_hdd_nan.c | 6 +- .../core/hdd/src/wlan_hdd_nan_datapath.c | 6 +- .../qcacld-3.0/core/hdd/src/wlan_hdd_tx_rx.c | 106 +- .../qcacld-3.0/core/mac/inc/qwlan_version.h | 4 +- .../core/mac/src/pe/lim/lim_utils.c | 24 +- .../qcacld-3.0/core/wma/src/wma_scan_roam.c | 24 +- .../qcacld-3.0/core/wma/src/wma_utils.c | 15 +- .../qcacld-3.0/os_if/nan/inc/os_if_nan.h | 5 +- .../qcacld-3.0/os_if/nan/src/os_if_nan.c | 13 +- drivers/pinctrl/qcom/pinctrl-msm.c | 20 +- drivers/scsi/ufs/ufshcd.c | 2 +- drivers/sensors/isg6320.c | 15 +- drivers/sensors/sx9360.c | 5 +- drivers/thermal/qcom/qti_bus_scaling_cdev.c | 227 -- drivers/usb/gadget/configfs.c | 4 +- drivers/usb/gadget/function/f_accessory.c | 20 + drivers/usb/gadget/function/f_ss_mon_gadget.c | 8 +- drivers/usb/typec/sm/sm5714/sm5714_typec.c | 116 +- fs/dlog_hook.c | 7 +- fs/exec.c | 18 + fs/ext4/extents.c | 3 + fs/f2fs/compress.c | 4 - fs/f2fs/f2fs.h | 88 +- fs/f2fs/file.c | 3 +- fs/f2fs/gc.c | 3 +- fs/proc/task_mmu.c | 118 +- fs/sdfat/cache.c | 42 +- fs/sdfat/core.c | 22 +- fs/sdfat/core_exfat.c | 3 + fs/sdfat/core_fat.c | 44 +- fs/sdfat/misc.c | 54 +- fs/sdfat/mpage.c | 7 +- fs/sdfat/sdfat.c | 285 ++- fs/sdfat/version.h | 4 +- include/linux/cgroup-defs.h | 1 + include/linux/cgroup.h | 7 + include/linux/muic/sm/sm5714/sm5714-muic.h | 1 + include/linux/olog.pb.h | 14 +- include/linux/rmap.h | 7 +- include/linux/usb.h | 3 +- .../linux/usb/typec/sm/sm5714/sm5714_typec.h | 3 +- include/linux/vm_event_item.h | 6 - kernel/cgroup/cgroup.c | 48 +- kernel/sched/psi.c | 30 +- mm/rmap.c | 31 +- mm/vmstat.c | 6 - net/bluetooth/hci_sock.c | 171 +- net/core/neighbour.c | 16 + net/ipv4/tcp_output.c | 4 + net/ipv6/addrconf.c | 8 +- net/ipv6/ndisc.c | 17 + net/qrtr/fifo.c | 8 + net/sched/cls_fw.c | 10 +- sound/core/control_compat.c | 4 + .../audio/4.0/asoc/msm-audio-effects-q6-v2.c | 8 + .../audio/4.0/asoc/msm-pcm-host-voice-v2.c | 18 + techpack/audio/4.0/asoc/msm-pcm-q6-noirq.c | 4 + techpack/audio/4.0/asoc/msm-pcm-q6-v2.c | 7 + techpack/audio/4.0/asoc/msm-pcm-routing-v2.c | 16 +- techpack/audio/4.0/asoc/msm-pcm-voip-v2.c | 28 + techpack/audio/4.0/dsp/msm_audio_ion.c | 33 +- techpack/audio/4.0/dsp/q6adm.c | 3 +- techpack/audio/4.0/dsp/q6afe.c | 34 + techpack/audio/4.0/dsp/q6asm.c | 22 +- techpack/audio/4.0/dsp/q6core.c | 2 +- techpack/audio/4.0/dsp/q6lsm.c | 9 +- techpack/audio/4.0/dsp/q6voice.c | 7 + techpack/audio/4.0/include/dsp/q6asm-v2.h | 3 + techpack/audio/asoc/msm-audio-effects-q6-v2.c | 9 + techpack/audio/asoc/msm-pcm-host-voice-v2.c | 25 + techpack/audio/asoc/msm-pcm-q6-noirq.c | 4 + techpack/audio/asoc/msm-pcm-q6-v2.c | 7 + techpack/audio/asoc/msm-pcm-voip-v2.c | 28 + techpack/audio/dsp/msm_audio_ion.c | 24 +- techpack/audio/dsp/q6adm.c | 3 +- techpack/audio/dsp/q6afe.c | 41 +- techpack/audio/dsp/q6asm.c | 22 +- techpack/audio/dsp/q6core.c | 2 +- techpack/audio/dsp/q6lsm.c | 9 +- techpack/audio/dsp/q6voice.c | 7 + techpack/audio/include/dsp/q6asm-v2.h | 3 + 185 files changed, 2687 insertions(+), 15458 deletions(-) delete mode 100755 Documentation/devicetree/bindings/thermal/qti-ddr-cdev.txt rename drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.h => arch/arm64/boot/dts/samsung/atoll-sec-gta4xlvewifi-kor-overlay-r00.dts (55%) delete mode 100755 drivers/media/platform/msm/ais/ais_isp/Makefile delete mode 100755 drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/Makefile delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid170.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175_200.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid17x.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/include/ais_ife_csid_hw_intf.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/include/ais_isp_hw.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/include/ais_vfe_hw_intf.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/utils/Makefile delete mode 100755 drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/Makefile delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/Makefile delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe170.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175_130.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe17x.c delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe_lite17x.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_rd_ver1.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver1.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver2.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/include/ais_vfe_bus.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_lite_ver2.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_ver2.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_fe_ver1.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_rdi.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_top_ver2.h delete mode 100755 drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/include/ais_vfe_top.h delete mode 100755 drivers/thermal/qcom/qti_bus_scaling_cdev.c diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 26a29f7723fe..79de22b080e2 100755 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -477,16 +477,21 @@ ccw_timeout_log [S390] See Documentation/s390/CommonIO for details. - cgroup_disable= [KNL] Disable a particular controller - Format: {name of the controller(s) to disable} + cgroup_disable= [KNL] Disable a particular controller or optional feature + Format: {name of the controller(s) or feature(s) to disable} The effects of cgroup_disable=foo are: - foo isn't auto-mounted if you mount all cgroups in a single hierarchy - foo isn't visible as an individually mountable subsystem + - if foo is an optional feature then the feature is + disabled and corresponding cgroup files are not + created {Currently only "memory" controller deal with this and cut the overhead, others just disable the usage. So only cgroup_disable=memory is actually worthy} + Specifying "pressure" disables per-cgroup pressure + stall information accounting feature cgroup_no_v1= [KNL] Disable one, multiple, all cgroup controllers in v1 Format: { controller[,controller...] | "all" } diff --git a/Documentation/devicetree/bindings/thermal/qti-ddr-cdev.txt b/Documentation/devicetree/bindings/thermal/qti-ddr-cdev.txt deleted file mode 100755 index 14228543615e..000000000000 --- a/Documentation/devicetree/bindings/thermal/qti-ddr-cdev.txt +++ /dev/null @@ -1,65 +0,0 @@ -QTI DDR cooling device. - -The DDR cooling device will be used to place a DDR frequency vote. This -cooling device will be used in those cases where all the subsystem's are -thermally throttled and DDR has to be operated with a minimum performance -level. This cooling device vote can ensure the same. - -Properties: -- compatible: - Usage: required - Value type: - Definition: should be "qcom,ddr-cooling-device". - -Bus Scaling Data: -- qcom,msm-bus,name: - Usage: required - Value type: - Definition: String describing DDR cooling device client. It is defined - at Documentation/devicetree/bindings/arm/msm/msm_bus.txt. -- qcom,msm-bus,num-cases: - Usage: required - Value type: - Definition: This is the number of Bus Scaling use cases - defined in the vectors property. This must be set to more than - one for DDR cooling device based on different levels of DDR - frequency cooling support required. The use-case0 always should - be a vote to take off DDR cdev votes from the system. It is - defined at Documentation/devicetree/bindings/arm/msm/msm_bus.txt. -- qcom,msm-bus,active-only: - Usage: optional - Value type: - Definition: A boolean flag indicating if it is active only - bandwidth vote. It is defined at - Documentation/devicetree/bindings/arm/msm/msm_bus.txt. -- qcom,msm-bus,num-paths: - Usage: required - Value type: - Definition: This represents total number of master-slave pairs for - different usecases. It is defined at - Documentation/devicetree/bindings/arm/msm/msm_bus.txt. -- qcom,msm-bus,vectors-KBps: - Usage: required - Value type: - Definition: A series of 4 cell properties, with a format of - (src, dst, ab, ib). It is defined at - Documentation/devicetree/bindings/arm/msm/msm_bus.txt. - -Cooling Device Property: -- #cooling-cells: - Usage: required - Value type: - Definition: Must be 2. Needed for of_thermal as cooling device - identifier. Please refer to - for more - details. -Example: - qcom,ddr-cdev { - compatible = "qcom,ddr-cooling-device"; - qcom,msm-bus,name = "ddr-cdev"; - qcom,msm-bus,num-cases = <2>; - qcom,msm-bus,num-paths = <1>; - qcom,msm-bus,vectors-KBps = <1 512 0 0>, - <1 512 0 366000>; - #cooling-cells = <2>; - }; diff --git a/arch/arm64/Kconfig.projects b/arch/arm64/Kconfig.projects index d9b59e852274..079daa405c63 100755 --- a/arch/arm64/Kconfig.projects +++ b/arch/arm64/Kconfig.projects @@ -19,7 +19,6 @@ config SEC_GTA4XLVE_PROJECT help Support for Samsung GTA4XLVE Project - config SEC_A52Q_EUR_OPEN depends on SEC_A52Q_PROJECT default n @@ -82,4 +81,11 @@ config SEC_GTA4XLVEWIFI_CHN_OPEN bool "Samsung GTA4XLVEWIFI CHN OPEN" help Support for Samsung GTA4XLVEWIFI CHN OPEN device. + +config SEC_GTA4XLVEWIFI_KOR_OPEN + depends on SEC_GTA4XLVE_PROJECT + default n + bool "Samsung GTA4XLVEWIFI KOR OPEN" + help + Support for Samsung GTA4XLVEWIFI KOR OPEN device. diff --git a/arch/arm64/boot/dts/samsung/Makefile b/arch/arm64/boot/dts/samsung/Makefile index ad5bb759128d..23ccb6affff1 100755 --- a/arch/arm64/boot/dts/samsung/Makefile +++ b/arch/arm64/boot/dts/samsung/Makefile @@ -50,6 +50,10 @@ SEC_GTA4XLVE_CHN_DTBO := \ # GTA4XLVEWIFI CHN SEC_GTA4XLVEWIFI_CHN_DTBO := \ atoll-sec-gta4xlvewifi-chn-overlay-r00.dtbo + +# GTA4XLVEWIFI KOR +SEC_GTA4XLVEWIFI_KOR_DTBO := \ + atoll-sec-gta4xlvewifi-kor-overlay-r00.dtbo endif define __sec_dtbo_build dtbo-$(2) += $(1) @@ -90,6 +94,9 @@ $(eval $(call sec_dtbo_build, \ $(eval $(call sec_dtbo_build, \ $(SEC_GTA4XLVEWIFI_CHN_DTBO),$(CONFIG_SEC_GTA4XLVEWIFI_CHN_OPEN),$(SEC_ATOLL_BASE_DTB))) + +$(eval $(call sec_dtbo_build, \ + $(SEC_GTA4XLVEWIFI_KOR_DTBO),$(CONFIG_SEC_GTA4XLVEWIFI_KOR_OPEN),$(SEC_ATOLL_BASE_DTB))) endif endif diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.h b/arch/arm64/boot/dts/samsung/atoll-sec-gta4xlvewifi-kor-overlay-r00.dts similarity index 55% rename from drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.h rename to arch/arm64/boot/dts/samsung/atoll-sec-gta4xlvewifi-kor-overlay-r00.dts index 94e6c06a4287..442446cbbc3e 100755 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.h +++ b/arch/arm64/boot/dts/samsung/atoll-sec-gta4xlvewifi-kor-overlay-r00.dts @@ -1,23 +1,25 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_DEV_H_ -#define _AIS_IFE_CSID_DEV_H_ - -#include "ais_isp_hw.h" - -irqreturn_t ais_ife_csid_irq(int irq_num, void *data); - -int ais_ife_csid_probe(struct platform_device *pdev); -int ais_ife_csid_remove(struct platform_device *pdev); - -#endif /*_AIS_IFE_CSID_DEV_H_ */ +/* Copyright (c) 2020, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/dts-v1/; +/plugin/; + +#include "atoll-sec-common.dtsi" +#include "gta4xlve/atoll-sec-gta4xlvewifi-r00.dtsi" + + +/ { + model = "Samsung GTA4XLVEWIFI KOR PROJECT BRINGUP (board-id,00)"; + compatible = "qcom,atoll-ab-idp", "qcom,atoll-ab", "qcom,idp"; + qcom,board-id = <34 0>; + dtbo-version = <0>; +}; diff --git a/arch/arm64/boot/dts/samsung/drivers/atoll-sec-gta4xlve-battery-common.dtsi b/arch/arm64/boot/dts/samsung/drivers/atoll-sec-gta4xlve-battery-common.dtsi index d2833a3a9b03..7b7295933dd2 100755 --- a/arch/arm64/boot/dts/samsung/drivers/atoll-sec-gta4xlve-battery-common.dtsi +++ b/arch/arm64/boot/dts/samsung/drivers/atoll-sec-gta4xlve-battery-common.dtsi @@ -321,8 +321,8 @@ * 39 CABLE_MAX, */ cable-info { - default_input_current = <1800>; - default_charging_current = <2100>; + default_input_current = <1500>; + default_charging_current = <1800>; full_check_current_1st = <680>; full_check_current_2nd = <350>; diff --git a/arch/arm64/boot/dts/samsung/gta4xlve/atoll-sec-gta4xlve-common.dtsi b/arch/arm64/boot/dts/samsung/gta4xlve/atoll-sec-gta4xlve-common.dtsi index a296bf0fc58a..c63d18e81cc4 100755 --- a/arch/arm64/boot/dts/samsung/gta4xlve/atoll-sec-gta4xlve-common.dtsi +++ b/arch/arm64/boot/dts/samsung/gta4xlve/atoll-sec-gta4xlve-common.dtsi @@ -31,3 +31,9 @@ &sdhc_1 { status = "disabled"; }; + +&sdhc_2 { + qcom,clk-rates = <400000 20000000 25000000 + 50000000 100000000 179555556>; + qcom,devfreq,freq-table = <50000000 179555556>; +}; diff --git a/arch/arm64/configs/vendor/lineage-a52q_defconfig b/arch/arm64/configs/vendor/lineage-a52q_defconfig index d47a2a3f0911..352beec99b62 100755 --- a/arch/arm64/configs/vendor/lineage-a52q_defconfig +++ b/arch/arm64/configs/vendor/lineage-a52q_defconfig @@ -179,6 +179,7 @@ CONFIG_DEFAULT_USE_ENERGY_AWARE=y # CONFIG_RELAY is not set CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" +# CONFIG_INITRAMFS_FORCE is not set CONFIG_RD_GZIP=y CONFIG_RD_BZIP2=y CONFIG_RD_LZMA=y @@ -679,7 +680,10 @@ CONFIG_RANDOMIZE_MODULE_REGION_FULL=y # # Boot options # -CONFIG_CMDLINE="" +CONFIG_CMDLINE="cgroup_disable=pressure" +# CONFIG_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_CMDLINE_EXTEND=y +# CONFIG_CMDLINE_FORCE is not set # CONFIG_EFI is not set # CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE is not set CONFIG_BUILD_ARM64_KERNEL_COMPRESSION_GZIP=y @@ -1198,7 +1202,7 @@ CONFIG_NET_EMATCH_U32=y CONFIG_NET_EMATCH_META=y CONFIG_NET_EMATCH_TEXT=y CONFIG_NET_CLS_ACT=y -# CONFIG_NET_ACT_POLICE is not set +CONFIG_NET_ACT_POLICE=y CONFIG_NET_ACT_GACT=y # CONFIG_GACT_PROB is not set CONFIG_NET_ACT_MIRRED=y diff --git a/arch/arm64/configs/vendor/lineage-a72q_defconfig b/arch/arm64/configs/vendor/lineage-a72q_defconfig index 93d3ed47f909..c24410020e9d 100644 --- a/arch/arm64/configs/vendor/lineage-a72q_defconfig +++ b/arch/arm64/configs/vendor/lineage-a72q_defconfig @@ -179,6 +179,7 @@ CONFIG_DEFAULT_USE_ENERGY_AWARE=y # CONFIG_RELAY is not set CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" +# CONFIG_INITRAMFS_FORCE is not set CONFIG_RD_GZIP=y CONFIG_RD_BZIP2=y CONFIG_RD_LZMA=y @@ -676,7 +677,10 @@ CONFIG_RANDOMIZE_MODULE_REGION_FULL=y # # Boot options # -CONFIG_CMDLINE="" +CONFIG_CMDLINE="cgroup_disable=pressure" +# CONFIG_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_CMDLINE_EXTEND=y +# CONFIG_CMDLINE_FORCE is not set # CONFIG_EFI is not set # CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE is not set CONFIG_BUILD_ARM64_KERNEL_COMPRESSION_GZIP=y @@ -1195,7 +1199,7 @@ CONFIG_NET_EMATCH_U32=y CONFIG_NET_EMATCH_META=y CONFIG_NET_EMATCH_TEXT=y CONFIG_NET_CLS_ACT=y -# CONFIG_NET_ACT_POLICE is not set +CONFIG_NET_ACT_POLICE=y CONFIG_NET_ACT_GACT=y # CONFIG_GACT_PROB is not set CONFIG_NET_ACT_MIRRED=y diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 71ec29a57fb6..03f3e1597199 100755 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -721,50 +721,6 @@ void __init mem_init(void) mem_init_print_info(NULL); -#ifdef CONFIG_PRINT_VMEMLAYOUT -#define MLK(b, t) b, t, ((t) - (b)) >> 10 -#define MLM(b, t) b, t, ((t) - (b)) >> 20 -#define MLG(b, t) b, t, ((t) - (b)) >> 30 -#define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K) - - pr_notice("Virtual kernel memory layout:\n"); -#ifdef CONFIG_KASAN - pr_notice(" kasan : 0x%16lx - 0x%16lx (%6ld GB)\n", - MLG(KASAN_SHADOW_START, KASAN_SHADOW_END)); -#endif - pr_notice(" modules : 0x%16lx - 0x%16lx (%6ld MB)\n", - MLM(MODULES_VADDR, MODULES_END)); - pr_notice(" vmalloc : 0x%16lx - 0x%16lx (%6ld GB)\n", - MLG(VMALLOC_START, VMALLOC_END)); - pr_notice(" .text : 0x%p" " - 0x%p" " (%6ld KB)\n", - MLK_ROUNDUP(_text, _etext)); - pr_notice(" .rodata : 0x%p" " - 0x%p" " (%6ld KB)\n", - MLK_ROUNDUP(__start_rodata, __init_begin)); - pr_notice(" .init : 0x%p" " - 0x%p" " (%6ld KB)\n", - MLK_ROUNDUP(__init_begin, __init_end)); - pr_notice(" .data : 0x%p" " - 0x%p" " (%6ld KB)\n", - MLK_ROUNDUP(_sdata, _edata)); - pr_notice(" .bss : 0x%p" " - 0x%p" " (%6ld KB)\n", - MLK_ROUNDUP(__bss_start, __bss_stop)); - pr_notice(" fixed : 0x%16lx - 0x%16lx (%6ld KB)\n", - MLK(FIXADDR_START, FIXADDR_TOP)); - pr_notice(" PCI I/O : 0x%16lx - 0x%16lx (%6ld MB)\n", - MLM(PCI_IO_START, PCI_IO_END)); -#ifdef CONFIG_SPARSEMEM_VMEMMAP - pr_notice(" vmemmap : 0x%16lx - 0x%16lx (%6ld GB maximum)\n", - MLG(VMEMMAP_START, VMEMMAP_START + VMEMMAP_SIZE)); - pr_notice(" 0x%16lx - 0x%16lx (%6ld MB actual)\n", - MLM((unsigned long)phys_to_page(memblock_start_of_DRAM()), - (unsigned long)virt_to_page(high_memory))); -#endif - pr_notice(" memory : 0x%16lx - 0x%16lx (%6ld MB)\n", - MLM(__phys_to_virt(memblock_start_of_DRAM()), - (unsigned long)high_memory)); - -#undef MLK -#undef MLM -#undef MLK_ROUNDUP -#endif /* * Check boundaries twice: Some fundamental inconsistencies can be * detected at build time already. diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 24b9faffcd3c..3a250ca2406c 100755 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -97,7 +97,7 @@ vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o quiet_cmd_check_data_rel = DATAREL $@ define cmd_check_data_rel for obj in $(filter %.o,$^); do \ - $(READELF) -S $$obj | grep -qF .rel.local && { \ + ${CROSS_COMPILE}readelf -S $$obj | grep -qF .rel.local && { \ echo "error: $$obj has data relocations!" >&2; \ exit 1; \ } || true; \ diff --git a/drivers/battery/common/sec_battery_ttf.c b/drivers/battery/common/sec_battery_ttf.c index 4ea50eb4b70c..06e6458a23e6 100755 --- a/drivers/battery/common/sec_battery_ttf.c +++ b/drivers/battery/common/sec_battery_ttf.c @@ -138,7 +138,7 @@ void sec_bat_calc_time_to_full(struct sec_battery_info * battery) charge = battery->ttf_d->ttf_wireless_charge_current; #if defined(CONFIG_PDIC_NOTIFIER) } else if (is_pd_apdo_wire_type(battery->cable_type) || - (is_pd_fpdo_wire_type(battery->cable_type) && battery->hv_pdo)) { + (is_pd_fpdo_wire_type(battery->cable_type) && battery->pdic_info.sink_status.available_pdo_num > 1)) { if (battery->pd_max_charge_power > HV_CHARGER_STATUS_STANDARD4) { charge = battery->ttf_d->ttf_dc45_charge_current; } else if (battery->pd_max_charge_power > HV_CHARGER_STATUS_STANDARD3) { diff --git a/drivers/battery_v2/sec_battery_ttf.c b/drivers/battery_v2/sec_battery_ttf.c index 2c7892d40187..d6e44d6e2c72 100755 --- a/drivers/battery_v2/sec_battery_ttf.c +++ b/drivers/battery_v2/sec_battery_ttf.c @@ -334,7 +334,7 @@ int ttf_display(struct sec_battery_info *battery) if (((battery->status == POWER_SUPPLY_STATUS_CHARGING) || (battery->status == POWER_SUPPLY_STATUS_FULL && battery->capacity != 100)) && - !battery->swelling_mode) + !battery->swelling_mode && !(battery->current_event & SEC_BAT_CURRENT_EVENT_LOW_TEMP_SWELLING_2ND)) return battery->ttf_d->timetofull; else return 0; diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index e9b08f356b5b..c50a479c4f3c 100755 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -44,6 +44,10 @@ static void zcomp_strm_free(struct zcomp_strm *zstrm) if (!IS_ERR_OR_NULL(zstrm->tfm)) crypto_free_comp(zstrm->tfm); free_pages((unsigned long)zstrm->buffer, 1); + if (zstrm->tmpbuf) { + free_pages((unsigned long)zstrm->tmpbuf, 1); + zstrm->tmpbuf = NULL; + } kfree(zstrm); } @@ -63,7 +67,8 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp) * case when compressed size is larger than the original one */ zstrm->buffer = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); - if (IS_ERR_OR_NULL(zstrm->tfm) || !zstrm->buffer) { + zstrm->tmpbuf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); + if (IS_ERR_OR_NULL(zstrm->tfm) || !zstrm->buffer || !zstrm->tmpbuf) { zcomp_strm_free(zstrm); zstrm = NULL; } diff --git a/drivers/block/zram/zcomp.h b/drivers/block/zram/zcomp.h index 41c1002a7d7d..dbcbbc005433 100755 --- a/drivers/block/zram/zcomp.h +++ b/drivers/block/zram/zcomp.h @@ -14,6 +14,7 @@ struct zcomp_strm { /* compression/decompression buffer */ void *buffer; struct crypto_comp *tfm; + void *tmpbuf; }; /* dynamic per-device compression frontend */ diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index d0a6904b2597..979e0f919bdc 100755 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -35,14 +35,8 @@ #include #include #include -#include -#include #include #include -#include -#include -#include -#include #include #include @@ -67,6 +61,9 @@ static const char *default_compressor = "zstd"; static const char *default_compressor = "lzo-rle"; #endif +static bool is_lzorle; +static unsigned char lzo_marker[4] = {0x11, 0x00, 0x00}; + /* Module params (documentation at end) */ static unsigned int num_devices = 1; /* @@ -354,35 +351,12 @@ static ssize_t idle_store(struct device *dev, #ifdef CONFIG_ZRAM_WRITEBACK #ifdef CONFIG_ZRAM_LRU_WRITEBACK -static int zram_wbd(void *p); +#define LRU_LIMIT_RATIO 3 +#define ZWBS_ALIGN_MASK (~(NR_ZWBS - 1)) +static int zram_wbd(void *); static struct zram *g_zram; -static struct notifier_block zram_app_launch_nb; static bool is_app_launch; -#define F2FS_IOCTL_MAGIC 0xf5 -#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32) -#define F2FS_SET_PIN_FILE 1 -static int zram_pin_backing_file(struct zram *zram) -{ - struct loop_device *lo = zram->bdev->bd_disk->private_data; - struct file *file = lo->lo_backing_file; - unsigned int cmd = F2FS_IOC_SET_PIN_FILE; - int __user *buf; - int set = F2FS_SET_PIN_FILE; - int ret; - - buf = compat_alloc_user_space(sizeof(*buf)); - if (!buf) { - pr_info("%s failed to compat_alloc_user_space\n", __func__); - return -ENOMEM; - } - copy_to_user(buf, &set, sizeof(int)); - ret = file->f_op->unlocked_ioctl(file, cmd, (unsigned long)buf); - pr_info("%s ioctl to pin file returned %d\n", __func__, ret); - - return ret; -} - static void fallocate_block(struct zram *zram, unsigned long blk_idx) { struct block_device *bdev = zram->bdev; @@ -428,10 +402,6 @@ static int init_lru_writeback(struct zram *zram) ret = -ENOMEM; goto out; } - if (zram_pin_backing_file(zram)) { - ret = -EINVAL; - goto out; - } bitmap_sz = BITS_TO_LONGS(zram->nr_pages) * sizeof(long) / NR_ZWBS; /* backing dev should be large enough for chunk writeback */ @@ -442,6 +412,11 @@ static int init_lru_writeback(struct zram *zram) ret = -ENOMEM; goto out; } + zram->read_req_bitmap = kvzalloc(bitmap_sz, GFP_KERNEL); + if (!zram->read_req_bitmap) { + ret = -ENOMEM; + goto out; + } zram->wbd = kthread_run(zram_wbd, zram, "%s_wbd", zram->disk->disk_name); if (IS_ERR(zram->wbd)) { @@ -449,12 +424,16 @@ static int init_lru_writeback(struct zram *zram) goto out; } - g_zram = zram; zram->wb_limit_enable = true; sched_setscheduler(zram->wbd, SCHED_IDLE, ¶m); + zram->nr_lru_pages = (zram->nr_pages * LRU_LIMIT_RATIO / 10) & ZWBS_ALIGN_MASK; return ret; out: + if (zram->read_req_bitmap) { + kvfree(zram->read_req_bitmap); + zram->read_req_bitmap = NULL; + } if (zram->chunk_bitmap) { kvfree(zram->chunk_bitmap); zram->chunk_bitmap = NULL; @@ -471,7 +450,6 @@ out: static void stop_lru_writeback(struct zram *zram) { if (!IS_ERR_OR_NULL(zram->wbd)) { - g_zram = NULL; kthread_stop(zram->wbd); zram->wbd = NULL; } @@ -483,6 +461,10 @@ static void deinit_lru_writeback(struct zram *zram) u8 *wb_table_tmp = zram->wb_table; stop_lru_writeback(zram); + if (zram->read_req_bitmap) { + kvfree(zram->read_req_bitmap); + zram->read_req_bitmap = NULL; + } if (zram->chunk_bitmap) { kvfree(zram->chunk_bitmap); zram->chunk_bitmap = NULL; @@ -755,13 +737,21 @@ static unsigned long blk_to_chunk_idx(unsigned long idx) return idx / NR_ZWBS; } -static unsigned long alloc_chunk_bdev(struct zram *zram) +static unsigned long alloc_chunk_bdev(struct zram *zram, bool ppr) { - unsigned long chunk_idx = 1; - unsigned long max_idx = zram->nr_pages / NR_ZWBS; + unsigned long chunk_idx; + unsigned long max_idx; unsigned long blk_idx; unsigned long flags; int i; + + if (ppr) { + chunk_idx = blk_to_chunk_idx(zram->nr_lru_pages) + 1; + max_idx = blk_to_chunk_idx(zram->nr_pages); + } else { + chunk_idx = 1; + max_idx = blk_to_chunk_idx(zram->nr_lru_pages); + } retry: /* skip 0 bit to confuse zram.handle = 0 */ chunk_idx = find_next_zero_bit(zram->chunk_bitmap, max_idx, chunk_idx); @@ -778,7 +768,8 @@ retry: BUG_ON(test_and_set_bit(blk_idx + i, zram->bitmap)); spin_unlock_irqrestore(&zram->bitmap_lock, flags); atomic64_add(NR_ZWBS, &zram->stats.bd_count); - count_vm_events(SQZR_COUNT, NR_ZWBS); + if (ppr) + atomic64_add(NR_ZWBS, &zram->stats.bd_ppr_count); return blk_idx; } @@ -788,8 +779,8 @@ static unsigned long alloc_block_bdev(struct zram *zram) unsigned long flags; retry: /* skip 0 bit to confuse zram.handle = 0 */ - blk_idx = find_next_zero_bit(zram->bitmap, zram->nr_pages, blk_idx); - if (blk_idx == zram->nr_pages) + blk_idx = find_next_zero_bit(zram->bitmap, zram->nr_lru_pages, blk_idx); + if (blk_idx == zram->nr_lru_pages) return 0; spin_lock_irqsave(&zram->bitmap_lock, flags); @@ -800,24 +791,9 @@ retry: set_bit(blk_to_chunk_idx(blk_idx), zram->chunk_bitmap); spin_unlock_irqrestore(&zram->bitmap_lock, flags); atomic64_inc(&zram->stats.bd_count); - count_vm_events(SQZR_COUNT, 1); return blk_idx; } -static unsigned long try_alloc_block_bdev(struct zram *zram, int *nr_pages) -{ - unsigned long blk_idx; - - /* found free chunk, return blk_idx */ - if (*nr_pages == NR_ZWBS) { - blk_idx = alloc_chunk_bdev(zram); - if (blk_idx) - return blk_idx; - } - *nr_pages = 1; - return alloc_block_bdev(zram); -} - static void free_chunk_bdev(struct zram *zram, unsigned long chunk_idx) { unsigned long blk_idx; @@ -846,7 +822,6 @@ static void free_block_bdev(struct zram *zram, unsigned long blk_idx, bool ppr) goto out; zram->wb_table[blk_idx]--; atomic64_dec(&zram->stats.bd_objcnt); - count_vm_events(SQZR_OBJCNT, -1); if (ppr) atomic64_dec(&zram->stats.bd_ppr_objcnt); if (zram->wb_table[blk_idx] > 0) { @@ -858,7 +833,38 @@ out: was_set = test_and_clear_bit(blk_idx, zram->bitmap); WARN_ON_ONCE(!was_set); atomic64_dec(&zram->stats.bd_count); - count_vm_events(SQZR_COUNT, -1); + if (ppr) + atomic64_dec(&zram->stats.bd_ppr_count); + free_chunk_bdev(zram, blk_to_chunk_idx(blk_idx)); +} + +static void zram_inc_wb_table(struct zram *zram, unsigned long blk_idx) +{ + unsigned long flags; + + spin_lock_irqsave(&zram->wb_table_lock, flags); + if (zram->wb_table) + zram->wb_table[blk_idx]++; + spin_unlock_irqrestore(&zram->wb_table_lock, flags); +} + +static void zram_dec_wb_table(struct zram *zram, unsigned long blk_idx, bool ppr) +{ + unsigned long flags; + + spin_lock_irqsave(&zram->wb_table_lock, flags); + if (!zram->wb_table) { + spin_unlock_irqrestore(&zram->wb_table_lock, flags); + return; + } + zram->wb_table[blk_idx]--; + if (zram->wb_table[blk_idx] > 0) { + spin_unlock_irqrestore(&zram->wb_table_lock, flags); + return; + } + spin_unlock_irqrestore(&zram->wb_table_lock, flags); + clear_bit(blk_idx, zram->bitmap); + atomic64_dec(&zram->stats.bd_count); if (ppr) atomic64_dec(&zram->stats.bd_ppr_count); free_chunk_bdev(zram, blk_to_chunk_idx(blk_idx)); @@ -907,7 +913,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec, { struct bio *bio; - bio = bio_alloc(GFP_ATOMIC, 1); + bio = bio_alloc(GFP_NOIO, 1); if (!bio) return -ENOMEM; @@ -943,7 +949,7 @@ static bool is_bdev_avail(struct zram *zram) u64 min_free_blocks; int ret; - if (!zram->bdev->bd_disk) + if (!zram->bdev || !zram->bdev->bd_disk) return false; lo = zram->bdev->bd_disk->private_data; @@ -983,6 +989,9 @@ static inline bool zram_throttle_writeback_size(struct zram *zram) static bool zram_wb_available(struct zram *zram) { + if (!is_bdev_avail(zram)) + return false; + if (!zram->wb_table) return false; spin_lock(&zram->wb_limit_lock); @@ -999,6 +1008,8 @@ static bool zram_wb_available(struct zram *zram) static u32 entry_to_index(struct zram *zram, struct zram_table_entry *entry) { + if ((unsigned long)entry < (unsigned long)zram->table) + return zram->disksize >> PAGE_SHIFT; return (u32)(((unsigned long)entry - (unsigned long)zram->table) / sizeof(struct zram_table_entry)); } @@ -1027,23 +1038,36 @@ static int zram_try_mark_page(struct zram *zram, u32 index) return 0; } -void free_zwbs(struct zwbs **zwbs) +static void free_writeback_buffer(struct zram_writeback_buffer *buf) { + struct zwbs **zwbs; int i; + if (!buf) + return; + + zwbs = buf->zwbs; for (i = 0; i < NR_ZWBS; i++) { if (!zwbs[i]) - return; + break; if (zwbs[i]->page) __free_page(zwbs[i]->page); kfree(zwbs[i]); } + kfree(buf); } -int alloc_zwbs(struct zwbs **zwbs) +static struct zram_writeback_buffer *alloc_writeback_buffer(void) { + struct zram_writeback_buffer *buf; + struct zwbs **zwbs; int i; + buf = kzalloc(sizeof(struct zram_writeback_buffer), GFP_KERNEL); + if (!buf) + return NULL; + + zwbs = buf->zwbs; for (i = 0; i < NR_ZWBS; i++) { zwbs[i] = kzalloc(sizeof(struct zwbs), GFP_KERNEL); if (!zwbs[i]) @@ -1052,10 +1076,11 @@ int alloc_zwbs(struct zwbs **zwbs) if (!zwbs[i]->page) goto out; } - return 0; + return buf; + out: - free_zwbs(zwbs); - return -ENOMEM; + free_writeback_buffer(buf); + return NULL; } bool zram_is_app_launch(void) @@ -1063,7 +1088,7 @@ bool zram_is_app_launch(void) return is_app_launch; } -#define ZRAM_WBD_INTERVAL 10 * HZ +#define ZRAM_WBD_INTERVAL ((10)*(HZ)) static bool zram_should_writeback(struct zram *zram, unsigned long pages, bool trigger) { @@ -1118,8 +1143,7 @@ static void try_wakeup_zram_wbd(struct zram *zram) if (zram->backing_dev && !zram->wbd_running && zram_wb_available(zram) && - zram_should_writeback(zram, 0, true) && - is_bdev_avail(zram)) { + zram_should_writeback(zram, 0, true)) { bd_count = atomic64_read(&zram->stats.bd_count); /* wakeup zram_wbd with enough free blocks */ if (zram->nr_pages - bd_count < NR_ZWBS) @@ -1161,15 +1185,99 @@ static void mark_end_of_page(struct zwbs *zwbs) } } +struct hex_dump_pages { + struct page **pages; + int nr_pages; + unsigned int idx; +}; + +static void print_hex_dump_pages(struct page **src_page, int nr_pages, + int cur_idx) +{ + void *src; + + if (cur_idx < 0 || cur_idx > NR_ZWBS - 1) + return; + + if (nr_pages == NR_ZWBS && cur_idx != 0) { + pr_err("Previous page\n"); + src = kmap_atomic(src_page[cur_idx - 1]); + print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, + src, PAGE_SIZE, 1); + kunmap_atomic(src); + } + + pr_err("This page\n"); + src = kmap_atomic(src_page[cur_idx]); + print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, src, + PAGE_SIZE, 1); + kunmap_atomic(src); + + if (nr_pages == NR_ZWBS && cur_idx != NR_ZWBS - 1) { + pr_err("Next page\n"); + src = kmap_atomic(src_page[cur_idx + 1]); + print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, + src, PAGE_SIZE, 1); + kunmap_atomic(src); + } +} + +static void check_marker(void *addr, int size, struct hex_dump_pages *hdp) +{ + if (!is_lzorle) + return; + + if (size == PAGE_SIZE) + return; + + if (!memcmp(addr + size - 3, lzo_marker, 3)) + return; + + pr_err("%ps marker error, addr=0x%px len=%u\n", _RET_IP_, addr, size); + if (hdp) + print_hex_dump_pages(hdp->pages, hdp->nr_pages, hdp->idx); + else + print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, addr, + size, 1); + BUG(); +} + +static void handle_decomp_fail(char *comp, int err, u32 index, void *src, + unsigned int size, struct hex_dump_pages *hdp) +{ + bool is_marker_err = false; + + pr_err("%ps %s Decompression failed! err=%d %s=%u src=0x%px len=%u\n", + _RET_IP_, comp, err, hdp ? "offset" : "index", index, + src, size); + if (is_lzorle && size != PAGE_SIZE) { + if (memcmp(src + size - 3, lzo_marker, 3)) { + pr_err("%s marker error\n", __func__); + is_marker_err = true; + } + } + + if (hdp) + print_hex_dump_pages(hdp->pages, hdp->nr_pages, hdp->idx); + else + print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, src, + size, 1); + + if (is_marker_err) + BUG(); + else + panic("zram decomp failed"); +} + static int zram_writeback_fill_page(struct zram *zram, u32 index, - struct zwbs *zwbs) + struct zwbs **zwbs, int idx, bool ppr) { struct zram_wb_header *zhdr; - struct page *page = zwbs->page; - int offset = zwbs->off; + struct page *page = zwbs[idx]->page; + int offset = zwbs[idx]->off; unsigned long handle; void *src, *dst; - int ret, size; + int size, sizes[2]; int header_sz = 0; zram_slot_lock(zram, index); @@ -1182,10 +1290,12 @@ static int zram_writeback_fill_page(struct zram *zram, u32 index, return 0; } size = zram_get_obj_size(zram, index); - if (size != PAGE_SIZE) + if (ppr || size != PAGE_SIZE) header_sz = sizeof(struct zram_wb_header); - if (offset + header_sz + size > PAGE_SIZE) { + if (((!ppr || idx == NR_ZWBS - 1) && + offset + header_sz + size > PAGE_SIZE) || + offset + header_sz > PAGE_SIZE) { zram_slot_unlock(zram, index); return -ENOSPC; } @@ -1206,36 +1316,61 @@ static int zram_writeback_fill_page(struct zram *zram, u32 index, } src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO); dst = kmap_atomic(page); - if (size != PAGE_SIZE) { + if (header_sz) { zhdr = (struct zram_wb_header *)(dst + offset); zhdr->index = index; zhdr->size = size; dst = (u8 *)(zhdr + 1); } - memcpy(dst, src, size); - ret = size; + if (offset + header_sz + size > PAGE_SIZE) { + sizes[0] = PAGE_SIZE - (offset + header_sz); + sizes[1] = size - sizes[0]; + memcpy(dst, src, sizes[0]); + kunmap_atomic(dst); + dst = kmap_atomic(zwbs[idx + 1]->page); + memcpy(dst, src + sizes[0], sizes[1]); + zwbs[idx + 1]->off = sizes[1]; + } else { + memcpy(dst, src, size); + } kunmap_atomic(dst); + check_marker(src, size, NULL); zs_unmap_object(zram->mem_pool, handle); zram_slot_unlock(zram, index); - return ret; + return size; } -static void zram_writeback_clear_flag(struct zram *zram, struct zwbs *zwbs) +static void zram_writeback_clear_flag(struct zram *zram, u32 index) { - struct zram_wb_entry *entry = zwbs->entry; - unsigned int count = zwbs->cnt; - unsigned long index; - int i; + unsigned long flags; - for (i = 0; i < count; i++) { - index = entry[i].index; - zram_slot_lock(zram, index); + zram_slot_lock(zram, index); + if (zram_allocated(zram, index)) { zram_clear_flag(zram, index, ZRAM_UNDER_WB); zram_clear_flag(zram, index, ZRAM_IDLE); zram_clear_flag(zram, index, ZRAM_UNDER_PPR); - zram_slot_unlock(zram, index); + + /* putback halted entry to zram lru list */ + spin_lock_irqsave(&zram->list_lock, flags); + if (!list_empty(&zram->table[index].lru_list)) + list_move_tail(&zram->table[index].lru_list, &zram->list); + else + list_add_tail(&zram->table[index].lru_list, &zram->list); + spin_unlock_irqrestore(&zram->list_lock, flags); + zram_set_flag(zram, index, ZRAM_LRU); + atomic64_inc(&zram->stats.lru_pages); } + zram_slot_unlock(zram, index); +} + +static void zram_writeback_clear_flags(struct zram *zram, struct zwbs **zwbs) +{ + int i, j; + + for (i = 0; i < NR_ZWBS; i++) + for (j = 0; j < zwbs[i]->cnt; j++) + zram_writeback_clear_flag(zram, zwbs[i]->entry[j].index); } static void zram_update_max_stats(struct zram *zram) @@ -1248,7 +1383,7 @@ static void zram_update_max_stats(struct zram *zram) bd_size = atomic64_read(&zram->stats.bd_size); bd_ppr_count = atomic64_read(&zram->stats.bd_ppr_count); - bd_ppr_size = atomic64_read(&zram->stats.bd_ppr_size); + bd_ppr_size = atomic64_read(&zram->stats.bd_ppr_size); atomic64_set(&zram->stats.bd_max_count, bd_count); atomic64_set(&zram->stats.bd_max_size, bd_size); atomic64_set(&zram->stats.bd_ppr_max_count, bd_ppr_count); @@ -1274,6 +1409,10 @@ static void zram_writeback_done(struct zram *zram, int i; unsigned long flags; + if (!count) { + free_block_bdev(zram, blk_idx, ppr); + return; + } spin_lock_irqsave(&zram->wb_table_lock, flags); if (!zram->wb_table) { spin_unlock_irqrestore(&zram->wb_table_lock, flags); @@ -1283,7 +1422,6 @@ static void zram_writeback_done(struct zram *zram, spin_unlock_irqrestore(&zram->wb_table_lock, flags); atomic64_add(count, &zram->stats.bd_objwrites); atomic64_add(count, &zram->stats.bd_objcnt); - count_vm_events(SQZR_OBJCNT, count); if (ppr) atomic64_add(count, &zram->stats.bd_ppr_objcnt); @@ -1329,143 +1467,163 @@ static void zram_writeback_done(struct zram *zram, } } -static void zram_writeback_end_io(struct bio *bio) +static void zram_writeback_done_work(struct work_struct *work) { - if (g_zram && !g_zram->io_complete) { - g_zram->io_complete = true; - wake_up(&g_zram->wbd_wait); + struct zram_wb_work *zw = container_of(work, struct zram_wb_work, work); + struct zram *zram = zw->zram; + struct zram_writeback_buffer *buf = zw->buf; + struct bio *bio = zw->bio; + unsigned long blk_idx = zw->handle; + int nr_pages = zw->nr_pages; + int i; + bool ppr = zw->ppr; + + if (bio->bi_status) + zram_writeback_clear_flags(zram, buf->zwbs); + + for (i = 0; i < nr_pages; i++) + zram_writeback_done(zram, buf->zwbs[i], blk_idx + i, ppr); + + zram_update_max_stats(zram); + atomic64_add(nr_pages, &zram->stats.bd_writes); + if (ppr) + atomic64_add(nr_pages, &zram->stats.bd_ppr_writes); + spin_lock(&zram->wb_limit_lock); + if (zram->wb_limit_enable) { + if (zram->bd_wb_limit > nr_pages) + zram->bd_wb_limit -= nr_pages; + else + zram->bd_wb_limit = 0; } + spin_unlock(&zram->wb_limit_lock); + + bio_put(bio); + free_writeback_buffer(buf); + kfree(zw); } -static int zram_writeback_page(struct zram *zram, struct zwbs **zwbs, - int nr_to_write, bool sync, bool ppr) +static void zram_writeback_page_end_io(struct bio *bio) { - struct bio bio; - struct bio_vec *bio_vec; + struct page *page = bio->bi_io_vec[0].bv_page; + struct zram_wb_work *zw = (struct zram_wb_work *)page_private(page); + int errno = blk_status_to_errno(bio->bi_status); + + if (errno) + pr_info("%s errno %d\n", __func__, errno); + + INIT_WORK(&zw->work, zram_writeback_done_work); + schedule_work(&zw->work); +} + +static int zram_writeback_page(struct zram *zram, struct zram_writeback_buffer *buf, bool ppr) +{ + struct zram_wb_work *zw; + struct zwbs **zwbs = buf->zwbs; + struct bio *bio; unsigned long blk_idx; - int ret = 0; - int i, idx = 0; - int nr_pages = nr_to_write; -retry: - blk_idx = try_alloc_block_bdev(zram, &nr_pages); - if (!blk_idx) { - ret = -ENOSPC; + int i; + + blk_idx = alloc_chunk_bdev(zram, ppr); + if (!blk_idx) goto out; - } + /* fallocate 2MB block if not allocated yet */ fallocate_block(zram, blk_idx); - if (ppr) - atomic64_add(nr_pages, &zram->stats.bd_ppr_count); - bio_vec = kmalloc_array(nr_pages, sizeof(struct bio_vec), GFP_KERNEL); - if (!bio_vec) { - ret = -ENOSPC; + zw = kzalloc(sizeof(struct zram_wb_work), GFP_KERNEL); + if (!zw) goto out; - } - bio_init(&bio, bio_vec, nr_pages); - bio_set_dev(&bio, zram->bdev); - bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9); - bio.bi_opf = REQ_OP_WRITE; - for (i = 0; i < nr_pages; i++) - bio_add_page(&bio, zwbs[idx + i]->page, PAGE_SIZE, 0); - if (sync) { - ret = submit_bio_wait(&bio); - } else { - bio.bi_end_io = zram_writeback_end_io; - zram->io_complete = false; - submit_bio(&bio); - wait_event(zram->wbd_wait, zram->io_complete); - ret = blk_status_to_errno(bio.bi_status); + bio = bio_alloc(GFP_KERNEL, NR_ZWBS); + if (!bio) { + kfree(zw); + goto out; } - kfree(bio_vec); -out: - if (!ret) { - for (i = 0; i < nr_pages; i++) - zram_writeback_done(zram, zwbs[idx + i], blk_idx + i, ppr); + bio->bi_opf = REQ_OP_WRITE; + bio->bi_end_io = zram_writeback_page_end_io; + bio->bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9); + bio_set_dev(bio, zram->bdev); + for (i = 0; i < NR_ZWBS; i++) + bio_add_page(bio, zwbs[i]->page, PAGE_SIZE, 0); - zram_update_max_stats(zram); - atomic64_add(nr_pages, &zram->stats.bd_writes); - count_vm_events(SQZR_WRITE, nr_pages); - if (ppr) - atomic64_add(nr_pages, &zram->stats.bd_ppr_writes); - spin_lock(&zram->wb_limit_lock); - if (zram->wb_limit_enable) { - if (zram->bd_wb_limit > nr_pages) - zram->bd_wb_limit -= nr_pages; - else - zram->bd_wb_limit = 0; - } - spin_unlock(&zram->wb_limit_lock); + zw->nr_pages = NR_ZWBS; + zw->zram = zram; + zw->handle = blk_idx; + zw->buf = buf; + zw->bio = bio; + zw->ppr = ppr; + set_page_private(zwbs[0]->page, (unsigned long)zw); - idx += nr_pages; - if (idx < nr_to_write) - goto retry; - } else { - if (blk_idx) - for (i = 0; i < nr_pages; i++) - free_block_bdev(zram, blk_idx + i, ppr); - /* free all remaining entries when error */ - for (i = idx; i < nr_to_write; i++) - zram_writeback_clear_flag(zram, zwbs[i]); - } - return ret; + submit_bio(bio); + + return 0; +out: + if (blk_idx) + for (i = 0; i < NR_ZWBS; i++) + free_block_bdev(zram, blk_idx + i, ppr); + zram_writeback_clear_flags(zram, zwbs); + free_writeback_buffer(buf); + + return -ENOMEM; } -static int zram_comp_writeback_index(struct zram *zram, u32 index, - struct zwbs **zwbs, int *idx, bool sync, bool ppr) +static int zram_writeback_index(struct zram *zram, u32 index, + struct zram_writeback_buffer **buf, bool ppr) { - int size, ret = 0; - int i = *idx, j; + struct zram_writeback_buffer *tmpbuf = *buf; + struct zwbs **zwbs; + int size, i, ret = 0; + retry: - size = zram_writeback_fill_page(zram, index, zwbs[i]); + /* allocate new buffer for writeback */ + if (tmpbuf == NULL) { + tmpbuf = alloc_writeback_buffer(); + if (tmpbuf == NULL) + return -ENOMEM; + } + zwbs = tmpbuf->zwbs; + i = tmpbuf->idx; + + size = zram_writeback_fill_page(zram, index, zwbs, i, ppr); if (size > 0) { struct zram_wb_entry *entry = zwbs[i]->entry; + entry[zwbs[i]->cnt].index = index; entry[zwbs[i]->cnt].offset = zwbs[i]->off; entry[zwbs[i]->cnt].size = size; - zwbs[i]->off += size; - if (size < PAGE_SIZE) - zwbs[i]->off += sizeof(struct zram_wb_header); + zwbs[i]->off += (size + sizeof(struct zram_wb_header)); zwbs[i]->cnt++; } /* writeback if page is full/entry is full */ if (size == -ENOSPC || zwbs[i]->cnt == ZRAM_WB_THRESHOLD) { mark_end_of_page(zwbs[i]); - i = (i + 1) % NR_ZWBS; - if (i > 0) - goto retry; - ret = zram_writeback_page(zram, zwbs, NR_ZWBS, sync, ppr); - for (j = 0; j < NR_ZWBS; j++) { - zwbs[j]->cnt = 0; - zwbs[j]->off = 0; + if (++tmpbuf->idx == NR_ZWBS) { + ret = zram_writeback_page(zram, tmpbuf, ppr); + tmpbuf = NULL; } - if (ret == 0 && size == -ENOSPC) + if (ret == 0) goto retry; } - *idx = i; + *buf = tmpbuf; return ret; } static void zram_comp_writeback(struct zram *zram) { - struct zwbs *zwbs[NR_ZWBS]; + struct zram_writeback_buffer *buf = NULL; unsigned long nr_pages = zram->disksize >> PAGE_SHIFT; unsigned long index; - int idx = 0; - - if (alloc_zwbs(zwbs)) { - pr_info("%s alloc_zwbs failed", __func__); - return; - } for (index = 0; index < nr_pages; index++) { if (!zram_wb_available(zram)) break; - if (zram_comp_writeback_index(zram, index, zwbs, &idx, true, false)) + if (zram_writeback_index(zram, index, &buf, false)) break; } - free_zwbs(zwbs); + if (buf) { + mark_end_of_page(buf->zwbs[buf->idx]); + zram_writeback_page(zram, buf, false); + } pr_info("%s done", __func__); } @@ -1473,20 +1631,15 @@ static int zram_wbd(void *p) { struct zram *zram = (struct zram *)p; struct zram_table_entry *zram_entry, *n; - struct zwbs *zwbs[NR_ZWBS]; + struct zram_writeback_buffer *buf = NULL; u32 index; - int idx = 0; int ret; set_freezable(); - if (alloc_zwbs(zwbs)) { - pr_info("%s alloc_zwbs failed", __func__); - return 0; - } - while (!kthread_should_stop()) { unsigned long nr_pages = 0; + wait_event_freezable(zram->wbd_wait, zram->wbd_running || kthread_should_stop()); list_for_each_entry_safe(zram_entry, n, &zram->list, lru_list) { @@ -1497,8 +1650,7 @@ static int zram_wbd(void *p) index = entry_to_index(zram, zram_entry); ret = zram_try_mark_page(zram, index); if (!ret) { - if (zram_comp_writeback_index(zram, index, - zwbs, &idx, false, false)) + if (zram_writeback_index(zram, index, &buf, false)) break; } else if (ret == ABORT) { n = list_first_entry(&zram->list, @@ -1510,51 +1662,20 @@ static int zram_wbd(void *p) zram->wbd_running = false; pr_info("%s done", __func__); } - free_zwbs(zwbs); + free_writeback_buffer(buf); return 0; } -int is_writeback_entry(swp_entry_t entry) -{ - struct zram *zram; - struct swap_info_struct *sis = swap_info[swp_type(entry)]; - unsigned long index = swp_offset(entry); - int ret = 0; - - if (!(sis->flags & SWP_BLKDEV)) - return 0; - - zram = sis->bdev->bd_disk->private_data; - zram_slot_lock(zram, index); - if (zram_allocated(zram, index) && - zram_test_flag(zram, index, ZRAM_WB)) - ret = 1; - zram_slot_unlock(zram, index); - - return ret; -} - -void swap_add_to_list(struct list_head *list, swp_entry_t entry) +void zram_add_to_writeback_list(struct list_head *list, unsigned long index) { - struct zram *zram; - struct swap_info_struct *sis = swap_info[swp_type(entry)]; - unsigned long index = swp_offset(entry); + struct zram *zram = g_zram; unsigned long flags; - if (!(sis->flags & SWP_BLKDEV)) - return; - - zram = sis->bdev->bd_disk->private_data; - if (zram != g_zram) - return; - - if (!is_bdev_avail(zram)) - return; - if (!zram_wb_available(zram)) return; - + if (index >= (zram->disksize >> PAGE_SHIFT)) + return; if (!zram_slot_trylock(zram, index)) return; @@ -1567,44 +1688,33 @@ void swap_add_to_list(struct list_head *list, swp_entry_t entry) zram_set_flag(zram, index, ZRAM_IDLE); zram_set_flag(zram, index, ZRAM_UNDER_PPR); spin_lock_irqsave(&zram->list_lock, flags); - if (!list_empty(&zram->table[index].lru_list)) + if (!list_empty(&zram->table[index].lru_list)) { list_move(&zram->table[index].lru_list, list); + if (zram_test_flag(zram, index, ZRAM_LRU)) { + zram_clear_flag(zram, index, ZRAM_LRU); + atomic64_dec(&zram->stats.lru_pages); + } + } spin_unlock_irqrestore(&zram->list_lock, flags); } zram_slot_unlock(zram, index); } -void swap_writeback_list(struct zwbs **zwbs, struct list_head *list) +int zram_writeback_list(struct list_head *list) { struct zram *zram = g_zram; - struct zram_table_entry *zram_entry; + struct zram_table_entry *entry; u32 index; - static int idx = 0; unsigned long flags; - bool skip = false; - - if (list == NULL) { - if (idx > 0 || zwbs[idx]->cnt > 0) { - mark_end_of_page(zwbs[idx]); - if (zwbs[idx]->cnt > 0) - idx++; - zram_writeback_page(zram, zwbs, idx, true, true); - } - idx = 0; - return; - } while (!list_empty(list)) { - zram_entry = list_first_entry(list, - typeof(struct zram_table_entry), lru_list); - index = entry_to_index(zram, zram_entry); - if (!skip) { - if (!zram_wb_available(zram)) - skip = true; - else if (zram_comp_writeback_index(zram, index, - zwbs, &idx, true, true)) - skip = true; - } + entry = list_first_entry(list, typeof(*entry), lru_list); + index = entry_to_index(zram, entry); + if (index >= (zram->disksize >> PAGE_SHIFT)) + return -EINVAL; + if (is_app_launch || !zram_wb_available(zram) || + zram_writeback_index(zram, index, &zram->buf, true)) + return -EINVAL; zram_slot_lock(zram, index); zram_clear_flag(zram, index, ZRAM_UNDER_PPR); spin_lock_irqsave(&zram->list_lock, flags); @@ -1613,6 +1723,98 @@ void swap_writeback_list(struct zwbs **zwbs, struct list_head *list) spin_unlock_irqrestore(&zram->list_lock, flags); zram_slot_unlock(zram, index); } + return 0; +} + +void flush_writeback_buffer(struct list_head *list) +{ + struct zram *zram = g_zram; + struct zram_table_entry *entry; + u32 index; + + if (list_empty(list) && zram->buf) { + mark_end_of_page(zram->buf->zwbs[zram->buf->idx]); + zram_writeback_page(zram, zram->buf, true); + zram->buf = NULL; + return; + } + + /* putback all remaining zram entries */ + while (!list_empty(list)) { + entry = list_first_entry(list, typeof(*entry), lru_list); + index = entry_to_index(zram, entry); + if (index >= (zram->disksize >> PAGE_SHIFT)) + break; + zram_writeback_clear_flag(zram, index); + } + + if (zram->buf) { + zram_writeback_clear_flags(zram, zram->buf->zwbs); + free_writeback_buffer(zram->buf); + zram->buf = NULL; + } +} + +int zram_get_entry_type(unsigned long index) +{ + struct zram *zram = g_zram; + int ret = 0; + + if (index >= (zram->disksize >> PAGE_SHIFT)) + return ret; + + zram_slot_lock(zram, index); + if (zram_allocated(zram, index)) { + if (zram_test_flag(zram, index, ZRAM_WB)) + ret = zram_get_element(zram, index) & (PAGE_SIZE - 1) ? + ZRAM_WB_TYPE : ZRAM_WB_HUGE_TYPE; + else if (zram_test_flag(zram, index, ZRAM_SAME)) + ret = ZRAM_SAME_TYPE; + else if (zram_test_flag(zram, index, ZRAM_HUGE)) + ret = ZRAM_HUGE_TYPE; + } + zram_slot_unlock(zram, index); + + return ret; +} + +static int read_comp_from_bdev(struct zram *zram, struct bio_vec *bvec, + unsigned long handle, struct bio *parent, bool ppr); + +int zram_prefetch_entry(unsigned long index) +{ + struct zram *zram = g_zram; + unsigned long handle; + unsigned long chunk_idx; + unsigned long blk_idx; + + if (index >= (zram->disksize >> PAGE_SHIFT)) + return -1; + + if (!zram_slot_trylock(zram, index)) + return -1; + + if (!zram_allocated(zram, index) || + !zram_test_flag(zram, index, ZRAM_WB) || + !zram_test_flag(zram, index, ZRAM_PPR) || + zram_test_flag(zram, index, ZRAM_READ_BDEV)) { + zram_slot_unlock(zram, index); + return -1; + } + handle = zram_get_element(zram, index); + blk_idx = handle >> (PAGE_SHIFT * 2); + chunk_idx = blk_to_chunk_idx(blk_idx); + if (test_and_set_bit(chunk_idx, zram->read_req_bitmap)) { + zram_slot_unlock(zram, index); + return -1; + } + zram_inc_wb_table(zram, blk_idx); + zram_slot_unlock(zram, index); + if (read_comp_from_bdev(zram, NULL, handle, NULL, true) < 0) + zram_dec_wb_table(zram, blk_idx, true); + atomic64_inc(&zram->stats.bd_ppr_reads); + + return 0; } #endif @@ -1668,7 +1870,7 @@ static ssize_t writeback_store(struct device *dev, #ifdef CONFIG_ZRAM_LRU_WRITEBACK if (mode == IDLE_WRITEBACK) { - if (is_bdev_avail(zram)) + if (zram_wb_available(zram)) zram_comp_writeback(zram); ret = len; __free_page(page); @@ -1750,9 +1952,6 @@ static ssize_t writeback_store(struct device *dev, } atomic64_inc(&zram->stats.bd_writes); -#ifdef CONFIG_ZRAM_LRU_WRITEBACK - count_vm_event(SQZR_WRITE); -#endif /* * We released zram_slot_lock so need to check if the slot was * changed. If there is freeing for the slot, we can catch it @@ -1773,12 +1972,15 @@ static ssize_t writeback_store(struct device *dev, zram_free_page(zram, index); zram_clear_flag(zram, index, ZRAM_UNDER_WB); zram_set_flag(zram, index, ZRAM_WB); +#ifdef CONFIG_ZRAM_LRU_WRITEBACK zram_set_element(zram, index, blk_idx << (PAGE_SHIFT * 2)); +#else + zram_set_element(zram, index, blk_idx); +#endif blk_idx = 0; atomic64_inc(&zram->stats.pages_stored); - atomic64_inc(&zram->stats.bd_objcnt); #ifdef CONFIG_ZRAM_LRU_WRITEBACK - count_vm_event(SQZR_OBJCNT); + atomic64_inc(&zram->stats.bd_objcnt); #endif spin_lock(&zram->wb_limit_lock); if (zram->wb_limit_enable && zram->bd_wb_limit > 0) @@ -1789,7 +1991,11 @@ next: } if (blk_idx) +#ifdef CONFIG_ZRAM_LRU_WRITEBACK free_block_bdev(zram, blk_idx, false); +#else + free_block_bdev(zram, blk_idx); +#endif ret = len; __free_page(page); release_init_lock: @@ -1852,9 +2058,6 @@ static int read_from_bdev(struct zram *zram, struct bio_vec *bvec, unsigned long entry, struct bio *parent, bool sync) { atomic64_inc(&zram->stats.bd_reads); -#ifdef CONFIG_ZRAM_LRU_WRITEBACK - count_vm_event(SQZR_READ); -#endif if (sync) return read_from_bdev_sync(zram, bvec, entry, parent); else @@ -1862,26 +2065,81 @@ static int read_from_bdev(struct zram *zram, struct bio_vec *bvec, } #ifdef CONFIG_ZRAM_LRU_WRITEBACK -static void zram_handle_remain(struct zram *zram, struct page *page, - unsigned int blk_idx) +static void free_zw_pages(struct zram_wb_work *zw) +{ + int i; + + for (i = 0; i < zw->nr_pages; i++) { + if (!zw->src_page[i]) + return; + __free_page(zw->src_page[i]); + } +} + +static int alloc_zw_pages(struct zram_wb_work *zw) +{ + int i; + + for (i = 0; i < zw->nr_pages; i++) { + zw->src_page[i] = alloc_page(GFP_NOIO|__GFP_HIGHMEM); + if (!zw->src_page[i]) { + pr_info("%s failed to alloc page", __func__); + free_zw_pages(zw); + return -ENOMEM; + } + } + return 0; +} + +static void copy_to_buf(void *dst, struct page **pages, + unsigned int idx, unsigned int offset, + unsigned int size) +{ + int sizes[2]; + u8 *src; + + sizes[0] = min_t(int, size, PAGE_SIZE - offset); + sizes[1] = size - sizes[0]; + + if (sizes[0]) { + src = kmap_atomic(pages[idx]); + memcpy(dst, src + offset, sizes[0]); + kunmap_atomic(src); + } + if (sizes[1]) { + src = kmap_atomic(pages[idx + 1]); + memcpy(dst + sizes[0], src, sizes[1]); + kunmap_atomic(src); + } +} + +static void zram_handle_remain(struct zram *zram, struct page **pages, + unsigned int blk_idx, int nr_pages) { struct zram_wb_header *zhdr; unsigned long alloced_pages; unsigned long handle; + unsigned long flags; + unsigned int idx = 0; unsigned int offset = 0; unsigned int size; + int header_sz = sizeof(struct zram_wb_header); u32 index; - u8 *mem, *src, *dst; + u8 *mem, *dst; + struct hex_dump_pages hdp; - mem = kmap_atomic(page); - while (offset + sizeof(struct zram_wb_header) < PAGE_SIZE) { + while (idx < nr_pages) { + mem = kmap_atomic(pages[idx]); zhdr = (struct zram_wb_header *)(mem + offset); index = zhdr->index; size = zhdr->size; + kunmap_atomic(mem); - /* invalid index */ - if (index >= (zram->disksize >> PAGE_SHIFT)) - break; + /* invalid index or size, this means last object or corrupted page */ + if (index >= (zram->disksize >> PAGE_SHIFT) || size > PAGE_SIZE) { + index = -EINVAL; + goto next; + } if (!zram_slot_trylock(zram, index)) goto next; @@ -1893,9 +2151,10 @@ static void zram_handle_remain(struct zram *zram, struct page *page, goto next; } handle = zram_get_element(zram, index); - if ((handle >> (PAGE_SHIFT * 2)) != blk_idx || - ((handle >> PAGE_SHIFT) & (PAGE_SIZE -1)) != offset || - (handle & (PAGE_SIZE - 1)) != size) { + if ((handle >> (PAGE_SHIFT * 2)) != blk_idx + idx || + ((handle >> PAGE_SHIFT) & (PAGE_SIZE - 1)) != offset || + (size == PAGE_SIZE && (handle & (PAGE_SIZE - 1)) != 0) || + (size != PAGE_SIZE && (handle & (PAGE_SIZE - 1)) != size)) { zram_slot_unlock(zram, index); goto next; } @@ -1914,23 +2173,40 @@ static void zram_handle_remain(struct zram *zram, struct page *page, update_used_max(zram, alloced_pages); dst = zs_map_object(zram->mem_pool, handle, ZS_MM_WO); - src = (u8 *)(zhdr + 1); - memcpy(dst, src, size); + copy_to_buf(dst, pages, idx, offset + header_sz, size); + hdp.pages = pages; + hdp.nr_pages = nr_pages; + hdp.idx = idx; + check_marker(dst, size, &hdp); zs_unmap_object(zram->mem_pool, handle); atomic64_add(size, &zram->stats.compr_data_size); zram_free_page(zram, index); zram_set_element(zram, index, handle); zram_set_obj_size(zram, index, size); + spin_lock_irqsave(&zram->list_lock, flags); + list_add_tail(&zram->table[index].lru_list, &zram->list); + spin_unlock_irqrestore(&zram->list_lock, flags); + zram_set_flag(zram, index, ZRAM_LRU); + atomic64_inc(&zram->stats.lru_pages); zram_slot_unlock(zram, index); atomic64_inc(&zram->stats.pages_stored); next: - offset += (size + sizeof(struct zram_wb_header)); + offset += (size + header_sz); + if (offset + header_sz > PAGE_SIZE || index == -EINVAL) { + idx++; + if (offset < PAGE_SIZE || index == -EINVAL) + offset = 0; + else + offset %= PAGE_SIZE; + + /* check next offset again */ + if (offset + header_sz > PAGE_SIZE) { + idx++; + offset = 0; + } + } } - kunmap_atomic(mem); - free_block_bdev(zram, blk_idx, false); - atomic64_inc(&zram->stats.bd_objcnt); - count_vm_event(SQZR_OBJCNT); } static void zram_handle_comp_page(struct work_struct *work) @@ -1939,114 +2215,170 @@ static void zram_handle_comp_page(struct work_struct *work) struct zram_wb_header *zhdr; struct zram *zram = zw->zram; struct zcomp_strm *zstrm; - struct page *src_page = zw->src_page; + struct page **src_page = zw->src_page; struct page *dst_page = zw->dst_page; struct bio *bio = zw->bio; - unsigned long handle; unsigned int blk_idx = zw->handle >> (PAGE_SHIFT * 2); unsigned int offset = (zw->handle >> PAGE_SHIFT) & (PAGE_SIZE - 1); unsigned int size = zw->handle & (PAGE_SIZE - 1); - u8 *src, *dst; - int ret; - unsigned long flags; + unsigned int page_idx = 0; + int header_sz = sizeof(struct zram_wb_header); + int ret = 0; + u32 index; + u8 *src, *dst, *src_decomp; + bool spanned; + + if (zw->ppr) { + page_idx = blk_idx & ~ZWBS_ALIGN_MASK; + blk_idx &= ZWBS_ALIGN_MASK; + } - src = kmap_atomic(src_page); + src = kmap_atomic(src_page[page_idx]); zhdr = (struct zram_wb_header *)(src + offset); - handle = zhdr->index; - BUG_ON(zhdr->size != size); + index = zhdr->index; + if (size == 0) + size = PAGE_SIZE; + if (zhdr->size != size) { + pr_err("%s %s zhdr error, size should be %u but was %u src=0x%px offset=%u\n", + __func__, zram->compressor, size, zhdr->size, src, + offset); + print_hex_dump_pages(src_page, zw->nr_pages, page_idx); + BUG(); + } + + if (!dst_page) { + kunmap_atomic(src); + goto out; + } dst = kmap_atomic(dst_page); zstrm = zcomp_stream_get(zram->comp); - ret = zcomp_decompress(zstrm, - src + offset + sizeof(struct zram_wb_header), size, dst); + spanned = (offset + header_sz + size > PAGE_SIZE) ? true : false; + if (spanned) { + kunmap_atomic(src); + if (size == PAGE_SIZE) { + copy_to_buf(dst, src_page, page_idx, offset + header_sz, size); + goto out_huge; + } + src = zstrm->tmpbuf; + copy_to_buf(src, src_page, page_idx, offset + header_sz, size); + src_decomp = src; + } else { + src_decomp = src + offset + header_sz; + } + ret = zcomp_decompress(zstrm, src_decomp, size, dst); +out_huge: zcomp_stream_put(zram->comp); if (ret) { - pr_err("%s Decompression failed! err=%d offset=%u size=%u addr=%p\n", - __func__, ret, offset, size, src); - print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, - src, PAGE_SIZE, 1); - BUG_ON(ret); + struct hex_dump_pages hdp; + + hdp.pages = src_page; + hdp.nr_pages = zw->nr_pages; + hdp.idx = page_idx; + handle_decomp_fail(zram->compressor, ret, offset + header_sz, + src_decomp, size, &hdp); } kunmap_atomic(dst); - kunmap_atomic(src); - - zram_slot_lock(zram, handle); - zram_clear_flag(zram, handle, ZRAM_READ_BDEV); - zram_slot_unlock(zram, handle); + if (!spanned) + kunmap_atomic(src); - /* increment refcount to prevent freeing block */ - spin_lock_irqsave(&zram->wb_table_lock, flags); - if (zram->wb_table) - zram->wb_table[blk_idx]++; - spin_unlock_irqrestore(&zram->wb_table_lock, flags); + zram_slot_lock(zram, index); + zram_clear_flag(zram, index, ZRAM_READ_BDEV); + zram_slot_unlock(zram, index); - page_endio(dst_page, op_is_write(bio_op(bio)), - blk_status_to_errno(bio->bi_status)); + if (zw->bio_chain) + bio_endio(zw->bio_chain); + else + page_endio(dst_page, false, 0); +out: bio_put(bio); - zram_handle_remain(zram, src_page, blk_idx); + zram_handle_remain(zram, src_page, blk_idx, zw->nr_pages); + + if (!dst_page) + clear_bit(blk_to_chunk_idx(blk_idx), zram->read_req_bitmap); + + zram_dec_wb_table(zram, blk_idx + page_idx, zw->ppr); + free_zw_pages(zw); kfree(zw); - __free_page(src_page); } static void zram_comp_page_end_io(struct bio *bio) { struct page *page = bio->bi_io_vec[0].bv_page; struct zram_wb_work *zw = (struct zram_wb_work *)page_private(page); + int errno = blk_status_to_errno(bio->bi_status); + if (errno) + pr_err("%s submit_bio errno %d\n", __func__, errno); INIT_WORK(&zw->work, zram_handle_comp_page); schedule_work(&zw->work); } static int read_comp_from_bdev(struct zram *zram, struct bio_vec *bvec, - unsigned long handle, struct bio *parent) + unsigned long handle, struct bio *parent, bool ppr) { struct zram_wb_work *zw; struct bio *bio; - struct page *page; - unsigned long blk_idx = handle >> (PAGE_SHIFT * 2); + unsigned long blk_idx; + int i, nr_pages; + + if (ppr) { + blk_idx = handle >> (PAGE_SHIFT * 2) & ZWBS_ALIGN_MASK; + nr_pages = NR_ZWBS; + } else { + blk_idx = handle >> (PAGE_SHIFT * 2); + nr_pages = 1; + } atomic64_inc(&zram->stats.bd_reads); - count_vm_event(SQZR_READ); - bio = bio_alloc(GFP_ATOMIC, 1); + bio = bio_alloc(GFP_NOIO, nr_pages); if (!bio) return -ENOMEM; - page = alloc_page(GFP_NOIO|__GFP_HIGHMEM); - if (!page) { - pr_info("%s failed to alloc page", __func__); + zw = kzalloc(sizeof(struct zram_wb_work), GFP_NOIO); + if (!zw) { bio_put(bio); return -ENOMEM; } - zw = kzalloc(sizeof(struct zram_wb_work), GFP_ATOMIC); - if (!zw) { - __free_page(page); + zw->nr_pages = nr_pages; + if (alloc_zw_pages(zw)) { + kfree(zw); bio_put(bio); return -ENOMEM; } - zw->src_page = page; - zw->dst_page = bvec->bv_page; + zw->dst_page = bvec ? bvec->bv_page : NULL; zw->zram = zram; zw->bio = bio; zw->handle = handle; - set_page_private(page, (unsigned long)zw); + zw->ppr = ppr; + set_page_private(zw->src_page[0], (unsigned long)zw); bio->bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9); bio_set_dev(bio, zram->bdev); - if (!bio_add_page(bio, page, PAGE_SIZE, 0)) { - kfree(zw); - __free_page(page); - bio_put(bio); - return -EIO; + for (i = 0; i < nr_pages; i++) { + if (!bio_add_page(bio, zw->src_page[i], PAGE_SIZE, 0)) { + free_zw_pages(zw); + kfree(zw); + bio_put(bio); + return -EIO; + } } - if (!parent) { - bio->bi_opf = REQ_OP_READ; - bio->bi_end_io = zram_comp_page_end_io; - } else { - bio->bi_opf = parent->bi_opf; - bio_chain(bio, parent); + bio->bi_opf = REQ_OP_READ; + bio->bi_end_io = zram_comp_page_end_io; + + if (parent) { + zw->bio_chain = bio_alloc(GFP_NOIO, 1); + if (!zw->bio_chain) { + free_zw_pages(zw); + kfree(zw); + bio_put(bio); + return -ENOMEM; + } + zw->bio_chain->bi_opf = parent->bi_opf; + bio_chain(zw->bio_chain, parent); } submit_bio(bio); @@ -2388,8 +2720,9 @@ static ssize_t bd_stat_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct zram *zram = dev_to_zram(dev); + zram_reset_stats(zram); - return len; + return len; } #endif #endif @@ -2415,7 +2748,11 @@ static ssize_t debug_stat_show(struct device *dev, static DEVICE_ATTR_RO(io_stat); static DEVICE_ATTR_RO(mm_stat); #ifdef CONFIG_ZRAM_WRITEBACK +#ifdef CONFIG_ZRAM_LRU_WRITEBACK static DEVICE_ATTR_RW(bd_stat); +#else +static DEVICE_ATTR_RO(bd_stat); +#endif #endif static DEVICE_ATTR_RO(debug_stat); @@ -2526,6 +2863,7 @@ static void zram_free_page(struct zram *zram, size_t index) { struct zram_entry *entry; #ifdef CONFIG_ZRAM_LRU_WRITEBACK + unsigned long handle; unsigned long flags; #endif @@ -2542,9 +2880,9 @@ static void zram_free_page(struct zram *zram, size_t index) if (zram_test_flag(zram, index, ZRAM_WB)) { #ifdef CONFIG_ZRAM_LRU_WRITEBACK - unsigned long handle; int size; bool ppr = zram_test_flag(zram, index, ZRAM_PPR); + handle = zram_get_element(zram, index); size = handle & (PAGE_SIZE - 1); if (size == 0) @@ -2561,8 +2899,8 @@ static void zram_free_page(struct zram *zram, size_t index) zram_clear_flag(zram, index, ZRAM_WB); free_block_bdev(zram, handle >> (PAGE_SHIFT * 2), ppr); #else - zram_clear_flag(zram, index, ZRAM_WB); - free_block_bdev(zram, zram_get_element(zram, index) >> (PAGE_SHIFT * 2)); + zram_clear_flag(zram, index, ZRAM_WB); + free_block_bdev(zram, zram_get_element(zram, index)); #endif goto out; } @@ -2615,6 +2953,9 @@ static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index, void *src, *dst; #ifdef CONFIG_ZRAM_LRU_WRITEBACK unsigned long flags; + unsigned long blk_idx; + unsigned long handle; + bool ppr; #endif zram_slot_lock(zram, index); @@ -2626,23 +2967,32 @@ static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index, bvec.bv_offset = 0; #ifdef CONFIG_ZRAM_LRU_WRITEBACK atomic64_inc(&zram->stats.bd_objreads); - if (zram_test_flag(zram, index, ZRAM_PPR)) + ppr = zram_test_flag(zram, index, ZRAM_PPR); + if (ppr) atomic64_inc(&zram->stats.bd_ppr_reads); if (!zram_test_flag(zram, index, ZRAM_EXPIRE)) { zram_set_flag(zram, index, ZRAM_EXPIRE); atomic64_inc(&zram->stats.bd_expire); } - if ((zram_get_element(zram, index) & (PAGE_SIZE - 1)) != 0) { + handle = zram_get_element(zram, index); + blk_idx = handle >> (PAGE_SHIFT * 2); + if (((handle & (PAGE_SIZE - 1)) != 0) || ppr) { zram_set_flag(zram, index, ZRAM_READ_BDEV); + zram_inc_wb_table(zram, blk_idx); zram_slot_unlock(zram, index); - return read_comp_from_bdev(zram, &bvec, - zram_get_element(zram, index), bio); + ret = read_comp_from_bdev(zram, &bvec, handle, bio, ppr); + if (ret < 0) + zram_dec_wb_table(zram, blk_idx, ppr); + return ret; } -#endif + zram_slot_unlock(zram, index); + return read_from_bdev(zram, &bvec, blk_idx, bio, partial_io); +#else zram_slot_unlock(zram, index); return read_from_bdev(zram, &bvec, - zram_get_element(zram, index) >> (PAGE_SHIFT * 2), + zram_get_element(zram, index), bio, partial_io); +#endif } entry = zram_get_entry(zram, index); @@ -2675,12 +3025,11 @@ static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index, kunmap_atomic(dst); zcomp_stream_put(zram->comp); } + /* Should NEVER happen. BUG() if it does. */ - if (unlikely(ret)) { - pr_err("Decompression failed! err=%d, page=%u, len=%u, addr=%p\n", ret, index, size, src); - print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, src, size, 1); - BUG(); - } + if (unlikely(ret)) + handle_decomp_fail(zram->compressor, ret, index, src, size, + NULL); zs_unmap_object(zram->mem_pool, zram_entry_handle(zram, entry)); #ifdef CONFIG_ZRAM_LRU_WRITEBACK @@ -2854,7 +3203,7 @@ out: if (flags) { zram_set_flag(zram, index, flags); zram_set_element(zram, index, element); - } else { + } else { zram_set_entry(zram, index, entry); zram_set_obj_size(zram, index, comp_len); #ifdef CONFIG_ZRAM_LRU_WRITEBACK @@ -2873,7 +3222,8 @@ out: /* Update stats */ atomic64_inc(&zram->stats.pages_stored); #ifdef CONFIG_ZRAM_LRU_WRITEBACK - try_wakeup_zram_wbd(zram); + if (!flags) + try_wakeup_zram_wbd(zram); #endif return ret; } @@ -3195,6 +3545,9 @@ static ssize_t disksize_store(struct device *dev, goto out_free_meta; } + if (!strncmp(zram->compressor, "lzo-rle", 7)) + is_lzorle = true; + zram->comp = comp; zram->disksize = disksize; set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); @@ -3431,6 +3784,10 @@ static int zram_add(void) strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); zram_debugfs_register(zram); +#ifdef CONFIG_ZRAM_LRU_WRITEBACK + if (!g_zram) + g_zram = zram; +#endif pr_info("Added device: %s\n", zram->disk->disk_name); return device_id; @@ -3463,6 +3820,8 @@ static int zram_remove(struct zram *zram) #ifdef CONFIG_ZRAM_LRU_WRITEBACK stop_lru_writeback(zram); + if (g_zram == zram) + g_zram = NULL; #endif zram_debugfs_unregister(zram); /* Make sure all the pending I/O are finished */ diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index 4c69d24630a1..f533a342d9d4 100755 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -133,7 +133,7 @@ struct zram_stats { #ifdef CONFIG_ZRAM_LRU_WRITEBACK #define ZRAM_WB_THRESHOLD 32 -#define NR_ZWBS 16 +#define NR_ZWBS 64 #define NR_FALLOC_PAGES 512 #define FALLOC_ALIGN_MASK (~(NR_FALLOC_PAGES - 1)) struct zram_wb_header { @@ -143,11 +143,15 @@ struct zram_wb_header { struct zram_wb_work { struct work_struct work; - struct page *src_page; + struct page *src_page[NR_ZWBS]; struct page *dst_page; struct bio *bio; + struct bio *bio_chain; + struct zram_writeback_buffer *buf; struct zram *zram; unsigned long handle; + int nr_pages; + bool ppr; }; struct zram_wb_entry { @@ -163,12 +167,24 @@ struct zwbs { u32 off; }; -void free_zwbs(struct zwbs **); -int alloc_zwbs(struct zwbs **); +struct zram_writeback_buffer { + struct zwbs *zwbs[NR_ZWBS]; + int idx; +}; + +enum zram_entry_type { + ZRAM_WB_TYPE = 1, + ZRAM_WB_HUGE_TYPE, + ZRAM_SAME_TYPE, + ZRAM_HUGE_TYPE, +}; + bool zram_is_app_launch(void); -int is_writeback_entry(swp_entry_t); -void swap_add_to_list(struct list_head *, swp_entry_t); -void swap_writeback_list(struct zwbs **, struct list_head *); +void zram_add_to_writeback_list(struct list_head *list, unsigned long index); +int zram_writeback_list(struct list_head *list); +void flush_writeback_buffer(struct list_head *list); +int zram_get_entry_type(unsigned long index); +int zram_prefetch_entry(unsigned long index); #endif struct zram_hash { @@ -220,14 +236,16 @@ struct zram { wait_queue_head_t wbd_wait; u8 *wb_table; unsigned long *chunk_bitmap; + unsigned long nr_lru_pages; bool wbd_running; - bool io_complete; struct list_head list; spinlock_t list_lock; spinlock_t wb_table_lock; spinlock_t bitmap_lock; unsigned long *blk_bitmap; struct mutex blk_bitmap_lock; + unsigned long *read_req_bitmap; + struct zram_writeback_buffer *buf; #endif }; diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index 1baa32c4cfcb..c6932ada0256 100755 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -339,6 +339,8 @@ struct fastrpc_mmap { int uncached; int secure; uintptr_t attr; + bool is_filemap; /* flag to indicate map used in process init */ + unsigned int ctx_refs; /* Indicates reference count for context map */ }; enum fastrpc_perfkeys { @@ -701,7 +703,9 @@ static int fastrpc_mmap_remove(struct fastrpc_file *fl, uintptr_t va, hlist_for_each_entry_safe(map, n, &me->maps, hn) { if (map->raddr == va && map->raddr + map->len == va + len && - map->refs == 1) { + map->refs == 1 && + /* Remove map if not used in process initialization*/ + !map->is_filemap) { match = map; hlist_del_init(&map->hn); break; @@ -714,8 +718,11 @@ static int fastrpc_mmap_remove(struct fastrpc_file *fl, uintptr_t va, } hlist_for_each_entry_safe(map, n, &fl->maps, hn) { if (map->raddr == va && + !map->ctx_refs && map->raddr + map->len == va + len && - map->refs == 1) { + map->refs == 1 && + /* Remove map if not used in process initialization*/ + !map->is_filemap) { match = map; hlist_del_init(&map->hn); break; @@ -753,14 +760,14 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags) map->flags == ADSP_MMAP_REMOTE_HEAP_ADDR) { spin_lock(&me->hlock); map->refs--; - if (!map->refs) + if (!map->refs && !map->ctx_refs) hlist_del_init(&map->hn); spin_unlock(&me->hlock); if (map->refs > 0) return; } else { map->refs--; - if (!map->refs) + if (!map->refs && !map->ctx_refs) hlist_del_init(&map->hn); if (map->refs > 0 && !flags) return; @@ -849,6 +856,8 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, map->fl = fl; map->fd = fd; map->attr = attr; + map->is_filemap = false; + map->ctx_refs = 0; if (mflags == ADSP_MMAP_HEAP_ADDR || mflags == ADSP_MMAP_REMOTE_HEAP_ADDR) { map->apps = me; @@ -1316,8 +1325,11 @@ static void context_free(struct smq_invoke_ctx *ctx) hlist_del_init(&ctx->hn); spin_unlock(&ctx->fl->hlock); mutex_lock(&ctx->fl->map_mutex); - for (i = 0; i < nbufs; ++i) + for (i = 0; i < nbufs; ++i) { + if (ctx->maps[i] && ctx->maps[i]->ctx_refs) + ctx->maps[i]->ctx_refs--; fastrpc_mmap_free(ctx->maps[i], 0); + } mutex_unlock(&ctx->fl->map_mutex); fastrpc_buf_free(ctx->buf, 1); fastrpc_buf_free(ctx->lbuf, 1); @@ -1501,6 +1513,8 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx) err = fastrpc_mmap_create(ctx->fl, ctx->fds[i], ctx->attrs[i], buf, len, mflags, &ctx->maps[i]); + if (ctx->maps[i]) + ctx->maps[i]->ctx_refs++; mutex_unlock(&ctx->fl->map_mutex); if (err) goto bail; @@ -1518,6 +1532,8 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx) err = fastrpc_mmap_create(ctx->fl, ctx->fds[i], FASTRPC_ATTR_NOVA, 0, 0, dmaflags, &ctx->maps[i]); + if (!err && ctx->maps[i]) + ctx->maps[i]->ctx_refs++; if (err) { mutex_unlock(&ctx->fl->map_mutex); goto bail; @@ -1752,6 +1768,8 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx, goto bail; } else { mutex_lock(&ctx->fl->map_mutex); + if (ctx->maps[i]->ctx_refs) + ctx->maps[i]->ctx_refs--; fastrpc_mmap_free(ctx->maps[i], 0); mutex_unlock(&ctx->fl->map_mutex); ctx->maps[i] = NULL; @@ -1763,8 +1781,11 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx, if (!fdlist[i]) break; if (!fastrpc_mmap_find(ctx->fl, (int)fdlist[i], 0, 0, - 0, 0, &mmap)) + 0, 0, &mmap)) { + if (mmap && mmap->ctx_refs) + mmap->ctx_refs--; fastrpc_mmap_free(mmap, 0); + } } } mutex_unlock(&ctx->fl->map_mutex); @@ -2195,6 +2216,8 @@ static int fastrpc_init_process(struct fastrpc_file *fl, mutex_lock(&fl->map_mutex); VERIFY(err, !fastrpc_mmap_create(fl, init->filefd, 0, init->file, init->filelen, mflags, &file)); + if (file) + file->is_filemap = true; mutex_unlock(&fl->map_mutex); if (err) goto bail; @@ -2308,6 +2331,8 @@ static int fastrpc_init_process(struct fastrpc_file *fl, VERIFY(err, !fastrpc_mmap_create(fl, -1, 0, init->mem, init->memlen, ADSP_MMAP_REMOTE_HEAP_ADDR, &mem)); + if (mem) + mem->is_filemap = true; mutex_unlock(&fl->map_mutex); if (err) goto bail; diff --git a/drivers/clk/qcom/gcc-atoll.c b/drivers/clk/qcom/gcc-atoll.c index acaf43aeaaef..9aa2d5634421 100755 --- a/drivers/clk/qcom/gcc-atoll.c +++ b/drivers/clk/qcom/gcc-atoll.c @@ -727,6 +727,7 @@ static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = { F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0), F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0), F(100000000, P_GPLL0_OUT_EVEN, 3, 0, 0), + F(179555556, P_GPLL7_OUT_MAIN, 4.5, 0, 0), F(202000000, P_GPLL7_OUT_MAIN, 4, 0, 0), { } }; diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c index 9f19f72fb33f..3bdec3888e10 100755 --- a/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c +++ b/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c @@ -1132,6 +1132,7 @@ int dsi_panel_set_backlight(struct dsi_panel *panel, u32 bl_lvl) if (panel->host_config.ext_bridge_num) return 0; + pr_debug("backlight type:%d lvl:%d\n", bl->type, bl_lvl); switch (bl->type) { case DSI_BACKLIGHT_WLED: rc = backlight_device_set_brightness(bl->raw_bd, bl_lvl); diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index a3016d77c091..4a02fc48caf7 100755 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -1,5 +1,5 @@ /* Copyright (c) 2008-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -35,9 +35,6 @@ #define DEVICE_3D_NAME "kgsl-3d" #define DEVICE_3D0_NAME "kgsl-3d0" -/* Index to preemption scratch buffer to store KMD postamble */ -#define KMD_POSTAMBLE_IDX 100 - /* ADRENO_DEVICE - Given a kgsl_device return the adreno device struct */ #define ADRENO_DEVICE(device) \ container_of(device, struct adreno_device, dev) diff --git a/drivers/gpu/msm/adreno_a6xx_preempt.c b/drivers/gpu/msm/adreno_a6xx_preempt.c index 4fb89e2d7384..12c4c20849aa 100755 --- a/drivers/gpu/msm/adreno_a6xx_preempt.c +++ b/drivers/gpu/msm/adreno_a6xx_preempt.c @@ -1,5 +1,5 @@ /* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -738,8 +738,8 @@ unsigned int a6xx_preemption_pre_ibsubmit( * preemption */ if (!adreno_dev->perfcounter) { - u64 kmd_postamble_addr = - PREEMPT_SCRATCH_ADDR(adreno_dev, KMD_POSTAMBLE_IDX); + u64 kmd_postamble_addr = SCRATCH_POSTAMBLE_ADDR + (KGSL_DEVICE(adreno_dev)); *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3); *cmds++ = lower_32_bits(kmd_postamble_addr); @@ -983,14 +983,15 @@ int a6xx_preemption_init(struct adreno_device *adreno_dev) } /* - * First 8 dwords of the preemption scratch buffer is used to store the - * address for CP to save/restore VPC data. Reserve 11 dwords in the - * preemption scratch buffer from index KMD_POSTAMBLE_IDX for KMD - * postamble pm4 packets + * First 28 dwords of the device scratch buffer are used to store + * shadow rb data. Reserve 11 dwords in the device scratch buffer + * from SCRATCH_POSTAMBLE_OFFSET for KMD postamble pm4 packets. + * This should be in *device->scratch* so that userspace cannot + * access it. */ if (!adreno_dev->perfcounter) { - u32 *postamble = preempt->scratch.hostptr + - (KMD_POSTAMBLE_IDX * sizeof(u64)); + u32 *postamble = device->scratch.hostptr + + SCRATCH_POSTAMBLE_OFFSET; u32 count = 0; postamble[count++] = cp_type7_packet(CP_REG_RMW, 3); diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index 2bbc88966670..a410f48e1bf9 100755 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -1,4 +1,5 @@ /* Copyright (c) 2008-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -2544,6 +2545,14 @@ static int memdesc_sg_virt(struct kgsl_memdesc *memdesc, unsigned long useraddr) ret = sg_alloc_table_from_pages(memdesc->sgt, pages, npages, 0, memdesc->size, GFP_KERNEL); + if (ret) + goto out; + + ret = kgsl_cache_range_op(memdesc, 0, memdesc->size, + KGSL_CACHE_OP_FLUSH); + + if (ret) + sg_free_table(memdesc->sgt); out: if (ret) { for (i = 0; i < npages; i++) @@ -2593,6 +2602,15 @@ static int kgsl_setup_anon_useraddr(struct kgsl_pagetable *pagetable, } #ifdef CONFIG_DMA_SHARED_BUFFER +static int match_file(const void *p, struct file *file, unsigned int fd) +{ + /* + * We must return fd + 1 because iterate_fd stops searching on + * non-zero return, but 0 is a valid fd. + */ + return (p == file) ? (fd + 1) : 0; +} + static void _setup_cache_mode(struct kgsl_mem_entry *entry, struct vm_area_struct *vma) { @@ -2630,6 +2648,8 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device, vma = find_vma(current->mm, hostptr); if (vma && vma->vm_file) { + int fd; + ret = check_vma_flags(vma, entry->memdesc.flags); if (ret) { up_read(¤t->mm->mmap_sem); @@ -2645,13 +2665,27 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device, return -EFAULT; } - /* - * Take a refcount because dma_buf_put() decrements the - * refcount - */ - get_file(vma->vm_file); - - dmabuf = vma->vm_file->private_data; + /* Look for the fd that matches this vma file */ + fd = iterate_fd(current->files, 0, match_file, vma->vm_file); + if (fd) { + dmabuf = dma_buf_get(fd - 1); + if (IS_ERR(dmabuf)) { + up_read(¤t->mm->mmap_sem); + return PTR_ERR(dmabuf); + } + /* + * It is possible that the fd obtained from iterate_fd + * was closed before passing the fd to dma_buf_get(). + * Hence dmabuf returned by dma_buf_get() could be + * different from vma->vm_file->private_data. Return + * failure if this happens. + */ + if (dmabuf != vma->vm_file->private_data) { + dma_buf_put(dmabuf); + up_read(¤t->mm->mmap_sem); + return -EBADF; + } + } } if (IS_ERR_OR_NULL(dmabuf)) { diff --git a/drivers/gpu/msm/kgsl.h b/drivers/gpu/msm/kgsl.h index 2b12c33ae655..25fbb3e2e726 100755 --- a/drivers/gpu/msm/kgsl.h +++ b/drivers/gpu/msm/kgsl.h @@ -1,4 +1,5 @@ /* Copyright (c) 2008-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -83,6 +84,11 @@ #define SCRATCH_RPTR_GPU_ADDR(dev, id) \ ((dev)->scratch.gpuaddr + SCRATCH_RPTR_OFFSET(id)) +/* OFFSET to KMD postamble packets in scratch buffer */ +#define SCRATCH_POSTAMBLE_OFFSET (100 * sizeof(u64)) +#define SCRATCH_POSTAMBLE_ADDR(dev) \ + ((dev)->scratch.gpuaddr + SCRATCH_POSTAMBLE_OFFSET) + /* Timestamp window used to detect rollovers (half of integer range) */ #define KGSL_TIMESTAMP_WINDOW 0x80000000 diff --git a/drivers/gpu/msm/kgsl_iommu.c b/drivers/gpu/msm/kgsl_iommu.c index eee9df0ea2d6..162c14cceed0 100755 --- a/drivers/gpu/msm/kgsl_iommu.c +++ b/drivers/gpu/msm/kgsl_iommu.c @@ -1,5 +1,5 @@ /* Copyright (c) 2011-2020,2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. @@ -2538,14 +2538,18 @@ static uint64_t kgsl_iommu_find_svm_region(struct kgsl_pagetable *pagetable, static bool iommu_addr_in_svm_ranges(struct kgsl_iommu_pt *pt, u64 gpuaddr, u64 size) { + u64 end = gpuaddr + size; + + /* Make sure size is not zero and we don't wrap around */ + if (end <= gpuaddr) + return false; + if ((gpuaddr >= pt->compat_va_start && gpuaddr < pt->compat_va_end) && - ((gpuaddr + size) > pt->compat_va_start && - (gpuaddr + size) <= pt->compat_va_end)) + (end > pt->compat_va_start && end <= pt->compat_va_end)) return true; if ((gpuaddr >= pt->svm_start && gpuaddr < pt->svm_end) && - ((gpuaddr + size) > pt->svm_start && - (gpuaddr + size) <= pt->svm_end)) + (end > pt->svm_start && end <= pt->svm_end)) return true; return false; diff --git a/drivers/gpu/msm/kgsl_pool.c b/drivers/gpu/msm/kgsl_pool.c index 14e5470accb4..a226f3290129 100755 --- a/drivers/gpu/msm/kgsl_pool.c +++ b/drivers/gpu/msm/kgsl_pool.c @@ -1,4 +1,5 @@ /* Copyright (c) 2016-2017, 2019-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -83,6 +84,15 @@ _kgsl_pool_zero_page(struct page *p, unsigned int pool_order) static void _kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p) { + /* + * Sanity check to make sure we don't re-pool a page that + * somebody else has a reference to. + */ + if (WARN_ON_ONCE(unlikely(page_count(p) > 1))) { + __free_pages(p, pool->pool_order); + return; + } + _kgsl_pool_zero_page(p, pool->pool_order); spin_lock(&pool->list_lock); diff --git a/drivers/media/platform/msm/ais/ais_isp/Makefile b/drivers/media/platform/msm/ais/ais_isp/Makefile deleted file mode 100755 index 277eb8275180..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_core -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/include -ccflags-y += -Idrivers/media/platform/msm/ais/cam_req_mgr -ccflags-y += -Idrivers/media/platform/msm/ais/cam_smmu/ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_sync -ccflags-y += -Idrivers/media/platform/msm/ais/cam_utils -ccflags-y += -Idrivers/media/platform/msm/ais/cam_cdm/ - -obj-$(CONFIG_MSM_AIS) += csid_hw/ -obj-$(CONFIG_MSM_AIS) += vfe_hw/ -obj-$(CONFIG_MSM_AIS) += utils/ - -obj-$(CONFIG_MSM_AIS) += ais_ife_dev.o diff --git a/drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.c b/drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.c deleted file mode 100755 index 89e378afcebe..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.c +++ /dev/null @@ -1,711 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "ais_ife_dev.h" -#include "ais_vfe_hw_intf.h" -#include "ais_ife_csid_hw_intf.h" -#include "cam_node.h" -#include "cam_debug_util.h" -#include "cam_smmu_api.h" - -#define AIS_IFE_SUBDEVICE_EVENT_MAX 30 - -static int ais_ife_driver_cmd(struct ais_ife_dev *p_ife_dev, void *arg); -static int ais_ife_init_subdev_params(struct ais_ife_dev *p_ife_dev); - -static int ais_ife_subdev_subscribe_event(struct v4l2_subdev *sd, - struct v4l2_fh *fh, - struct v4l2_event_subscription *sub) -{ - return v4l2_event_subscribe(fh, sub, AIS_IFE_SUBDEVICE_EVENT_MAX, NULL); -} - -static int ais_ife_subdev_unsubscribe_event(struct v4l2_subdev *sd, - struct v4l2_fh *fh, - struct v4l2_event_subscription *sub) -{ - return v4l2_event_unsubscribe(fh, sub); -} - -static long ais_ife_subdev_ioctl(struct v4l2_subdev *sd, - unsigned int cmd, void *arg) -{ - int rc = 0; - - struct ais_ife_dev *p_ife_dev = v4l2_get_subdevdata(sd); - - - switch (cmd) { - case VIDIOC_CAM_CONTROL: - rc = ais_ife_driver_cmd(p_ife_dev, arg); - break; - default: - CAM_ERR(CAM_ISP, "Invalid ioctl cmd: %d", cmd); - rc = -EINVAL; - break; - } - return rc; -} - -#ifdef CONFIG_COMPAT -static long ais_ife_subdev_ioctl_compat(struct v4l2_subdev *sd, - unsigned int cmd, unsigned long arg) -{ - struct cam_control cmd_data; - int32_t rc = 0; - - if (copy_from_user(&cmd_data, (void __user *)arg, - sizeof(cmd_data))) { - CAM_ERR(CAM_SENSOR, "Failed to copy from user_ptr=%pK size=%zu", - (void __user *)arg, sizeof(cmd_data)); - return -EFAULT; - } - - switch (cmd) { - case VIDIOC_CAM_CONTROL: - rc = ais_ife_subdev_ioctl(sd, cmd, &cmd_data); - if (rc < 0) - CAM_ERR(CAM_SENSOR, "cam_sensor_subdev_ioctl failed"); - break; - default: - CAM_ERR(CAM_SENSOR, "Invalid compat ioctl cmd_type: %d", cmd); - rc = -EINVAL; - } - - if (!rc) { - if (copy_to_user((void __user *)arg, &cmd_data, - sizeof(cmd_data))) { - CAM_ERR(CAM_SENSOR, - "Failed to copy to user_ptr=%pK size=%zu", - (void __user *)arg, sizeof(cmd_data)); - rc = -EFAULT; - } - } - - return rc; -} -#endif - -static void ais_ife_dev_get_hw_caps(struct ais_ife_dev *p_ife_dev, - struct cam_isp_query_cap_cmd *query_isp) -{ - int i; - - query_isp->device_iommu.non_secure = p_ife_dev->iommu_hdl; - query_isp->device_iommu.secure = p_ife_dev->iommu_hdl_secure; - query_isp->reserved = p_ife_dev->hw_idx; - query_isp->num_dev = 1; - for (i = 0; i < query_isp->num_dev; i++) { - query_isp->dev_caps[i].hw_type = CAM_ISP_HW_IFE; - query_isp->dev_caps[i].hw_version.major = 1; - query_isp->dev_caps[i].hw_version.minor = 7; - query_isp->dev_caps[i].hw_version.incr = 0; - query_isp->dev_caps[i].hw_version.reserved = 0; - } -} - -static int ais_ife_cmd_reserve(struct ais_ife_dev *p_ife_dev, - struct ais_ife_rdi_init_args *rdi_init, - uint32_t cmd_size) -{ - int rc; - struct cam_hw_intf *csid_drv; - struct cam_hw_intf *vfe_drv; - struct ais_ife_rdi_deinit_args rdi_deinit; - - csid_drv = p_ife_dev->p_csid_drv; - vfe_drv = p_ife_dev->p_vfe_drv; - rdi_deinit.path = rdi_init->path; - - rc = csid_drv->hw_ops.init( - csid_drv->hw_priv, rdi_init, cmd_size); - if (rc) - goto fail_csid_init; - - rc = vfe_drv->hw_ops.init( - vfe_drv->hw_priv, rdi_init, cmd_size); - if (rc) - goto fail_vfe_init; - - rc = csid_drv->hw_ops.reserve( - csid_drv->hw_priv, rdi_init, cmd_size); - if (rc) - goto fail_csid_reserve; - - rc = vfe_drv->hw_ops.reserve( - vfe_drv->hw_priv, rdi_init, cmd_size); - if (rc) - goto fail_vfe_reserve; - - return rc; - -fail_vfe_reserve: - csid_drv->hw_ops.release( - csid_drv->hw_priv, &rdi_deinit, sizeof(rdi_deinit)); -fail_csid_reserve: - vfe_drv->hw_ops.deinit( - vfe_drv->hw_priv, &rdi_deinit, sizeof(rdi_deinit)); -fail_vfe_init: - csid_drv->hw_ops.deinit( - csid_drv->hw_priv, &rdi_deinit, sizeof(rdi_deinit)); -fail_csid_init: - return rc; -} - -static int ais_ife_cmd_release(struct ais_ife_dev *p_ife_dev, - struct ais_ife_rdi_deinit_args *rdi_deinit, - uint32_t cmd_size) -{ - int rc; - int tmp; - struct cam_hw_intf *csid_drv; - struct cam_hw_intf *vfe_drv; - - csid_drv = p_ife_dev->p_csid_drv; - vfe_drv = p_ife_dev->p_vfe_drv; - - rc = csid_drv->hw_ops.release( - csid_drv->hw_priv, rdi_deinit, cmd_size); - - tmp = vfe_drv->hw_ops.release( - vfe_drv->hw_priv, rdi_deinit, cmd_size); - if (!rc) - rc = tmp; - - tmp = csid_drv->hw_ops.deinit( - csid_drv->hw_priv, rdi_deinit, cmd_size); - if (!rc) - rc = tmp; - - tmp = vfe_drv->hw_ops.deinit( - vfe_drv->hw_priv, rdi_deinit, cmd_size); - if (!rc) - rc = tmp; - - return rc; -} - -static int ais_ife_driver_cmd(struct ais_ife_dev *p_ife_dev, void *arg) -{ - int rc = 0; - struct cam_control *cmd = (struct cam_control *)arg; - struct cam_hw_intf *csid_drv; - struct cam_hw_intf *vfe_drv; - - if (!p_ife_dev || !arg) { - CAM_ERR(CAM_SENSOR, "s_ctrl is NULL"); - rc = -EINVAL; - goto EXIT; - } - - if (cmd->handle_type != AIS_ISP_CMD_TYPE) { - CAM_ERR(CAM_SENSOR, "Invalid handle type 0x%x", - cmd->handle_type); - rc = -EINVAL; - goto EXIT; - } - - csid_drv = p_ife_dev->p_csid_drv; - vfe_drv = p_ife_dev->p_vfe_drv; - - CAM_DBG(CAM_ISP, "CMD %d", cmd->op_code); - - mutex_lock(&p_ife_dev->mutex); - switch (cmd->op_code) { - case AIS_IFE_QUERY_CAPS: { - struct cam_isp_query_cap_cmd query_isp; - - if (cmd->size != sizeof(query_isp)) { - rc = -EINVAL; - } else if (copy_from_user(&query_isp, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - ais_ife_dev_get_hw_caps(p_ife_dev, &query_isp); - - if (copy_to_user(u64_to_user_ptr(cmd->handle), - &query_isp, - cmd->size)) - rc = -EFAULT; - } - } - break; - case AIS_IFE_POWER_UP: { - } - break; - case AIS_IFE_POWER_DOWN: { - } - break; - case AIS_IFE_RESET: { - int tmp; - - rc = p_ife_dev->p_csid_drv->hw_ops.reset( - p_ife_dev->p_csid_drv->hw_priv, NULL, 0); - tmp = p_ife_dev->p_vfe_drv->hw_ops.reset( - p_ife_dev->p_vfe_drv->hw_priv, NULL, 0); - if (!rc) - rc = tmp; - } - break; - case AIS_IFE_RESERVE: { - struct ais_ife_rdi_init_args rdi_init; - - if (cmd->size != sizeof(rdi_init)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&rdi_init, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - rc = ais_ife_cmd_reserve(p_ife_dev, - &rdi_init, cmd->size); - } - } - break; - case AIS_IFE_RELEASE: { - struct ais_ife_rdi_deinit_args rdi_deinit; - - if (cmd->size != sizeof(rdi_deinit)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&rdi_deinit, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - rc = ais_ife_cmd_release(p_ife_dev, - &rdi_deinit, cmd->size); - } - } - break; - case AIS_IFE_START: { - struct ais_ife_rdi_start_args rdi_start; - - if (cmd->size != sizeof(rdi_start)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&rdi_start, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - rc = vfe_drv->hw_ops.start(vfe_drv->hw_priv, - &rdi_start, cmd->size); - if (!rc) { - rc = csid_drv->hw_ops.start( - csid_drv->hw_priv, &rdi_start, - cmd->size); - if (rc) { - struct ais_ife_rdi_stop_args rdi_stop; - - rdi_stop.path = rdi_start.path; - vfe_drv->hw_ops.stop(vfe_drv->hw_priv, - &rdi_stop, sizeof(rdi_stop)); - } - } - } - } - break; - case AIS_IFE_STOP: { - struct ais_ife_rdi_stop_args rdi_stop; - - if (cmd->size != sizeof(rdi_stop)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&rdi_stop, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - int tmp; - - rc = csid_drv->hw_ops.stop( - csid_drv->hw_priv, &rdi_stop, cmd->size); - tmp = vfe_drv->hw_ops.stop( - vfe_drv->hw_priv, &rdi_stop, cmd->size); - if (!rc) - rc = tmp; - } - } - break; - case AIS_IFE_PAUSE: { - struct ais_ife_rdi_stop_args rdi_stop; - - if (cmd->size != sizeof(rdi_stop)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&rdi_stop, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - rc = vfe_drv->hw_ops.stop( - vfe_drv->hw_priv, &rdi_stop, cmd->size); - } - } - break; - case AIS_IFE_RESUME: { - struct ais_ife_rdi_start_args rdi_start; - - if (cmd->size != sizeof(rdi_start)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&rdi_start, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - rc = vfe_drv->hw_ops.start( - vfe_drv->hw_priv, &rdi_start, cmd->size); - } - } - break; - case AIS_IFE_BUFFER_ENQ: { - struct ais_ife_enqueue_buffer_args enq_buf; - - if (cmd->size != sizeof(enq_buf)) { - CAM_ERR(CAM_ISP, "Invalid cmd size"); - rc = -EINVAL; - } else if (copy_from_user(&enq_buf, - u64_to_user_ptr(cmd->handle), - cmd->size)) { - rc = -EFAULT; - } else { - rc = vfe_drv->hw_ops.process_cmd(vfe_drv->hw_priv, - AIS_VFE_CMD_ENQ_BUFFER, &enq_buf, - cmd->size); - } - } - break; - default: - rc = -EINVAL; - break; - } - - mutex_unlock(&p_ife_dev->mutex); -EXIT: - return rc; -} - -static int ais_ife_subdev_open(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh) -{ - struct ais_ife_dev *p_ife_dev = v4l2_get_subdevdata(sd); - - mutex_lock(&p_ife_dev->mutex); - p_ife_dev->open_cnt++; - mutex_unlock(&p_ife_dev->mutex); - - return 0; -} - -static int ais_ife_subdev_close(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh) -{ - int rc = 0; - struct ais_ife_dev *p_ife_dev = v4l2_get_subdevdata(sd); - - CAM_INFO(CAM_ISP, "IFE%d close", p_ife_dev->hw_idx); - - mutex_lock(&p_ife_dev->mutex); - if (p_ife_dev->open_cnt <= 0) { - CAM_ERR(CAM_ISP, "IFE device is already closed"); - rc = -EINVAL; - goto end; - } - - p_ife_dev->open_cnt--; - - /*reset to shutdown vfe and csid*/ - if (p_ife_dev->open_cnt == 0) { - CAM_DBG(CAM_ISP, "IFE%d shutdown", p_ife_dev->hw_idx); - p_ife_dev->p_csid_drv->hw_ops.reset( - p_ife_dev->p_csid_drv->hw_priv, NULL, 0); - p_ife_dev->p_vfe_drv->hw_ops.reset( - p_ife_dev->p_vfe_drv->hw_priv, NULL, 0); - CAM_INFO(CAM_ISP, "IFE%d shutdown complete", p_ife_dev->hw_idx); - } - -end: - mutex_unlock(&p_ife_dev->mutex); - return rc; -} - -static int ais_ife_dev_cb(void *priv, struct ais_ife_event_data *evt_data) -{ - struct ais_ife_dev *p_ife_dev; - struct v4l2_event event = {}; - - p_ife_dev = (struct ais_ife_dev *)priv; - - if (!evt_data) { - CAM_ERR(CAM_ISP, "IFE%d callback with NULL event", - p_ife_dev->hw_idx); - return -EINVAL; - } - - CAM_DBG(CAM_ISP, "IFE%d CALLBACK %d", - p_ife_dev->hw_idx, evt_data->type); - - - if (sizeof(*evt_data) > sizeof(event.u.data)) { - CAM_ERR(CAM_ISP, "IFE Callback struct too large (%d)!", - sizeof(*evt_data)); - return -EINVAL; - } - - /* Queue the event */ - memcpy(event.u.data, (void *)evt_data, sizeof(*evt_data)); - event.id = V4L_EVENT_ID_AIS_IFE; - event.type = V4L_EVENT_TYPE_AIS_IFE; - v4l2_event_queue(p_ife_dev->cam_sd.sd.devnode, &event); - - return 0; -} - -static void ais_ife_dev_iommu_fault_handler( - struct iommu_domain *domain, struct device *dev, unsigned long iova, - int flags, void *token, uint32_t buf_info) -{ - struct ais_ife_dev *p_ife_dev = NULL; - - if (!token) { - CAM_ERR(CAM_ISP, "invalid token in page handler cb"); - return; - } - - p_ife_dev = (struct ais_ife_dev *)token; - - CAM_ERR(CAM_ISP, "IFE%d Pagefault at iova 0x%x %s", - p_ife_dev->hw_idx, iova, domain->name); -} - -static int ais_ife_dev_remove(struct platform_device *pdev) -{ - int rc = 0; - struct ais_ife_dev *p_ife_dev; - - p_ife_dev = platform_get_drvdata(pdev); - if (!p_ife_dev) { - CAM_ERR(CAM_ISP, "IFE device is NULL"); - return 0; - } - - /* clean up resources */ - cam_unregister_subdev(&(p_ife_dev->cam_sd)); - platform_set_drvdata(pdev, NULL); - v4l2_set_subdevdata(&(p_ife_dev->cam_sd.sd), NULL); - devm_kfree(&pdev->dev, p_ife_dev); - - return rc; -} - -static int ais_ife_dev_probe(struct platform_device *pdev) -{ - int rc = -1; - struct ais_ife_dev *p_ife_dev = NULL; - struct ais_isp_hw_init_args hw_init = {}; - - /* Create IFE control structure */ - p_ife_dev = devm_kzalloc(&pdev->dev, - sizeof(struct ais_ife_dev), GFP_KERNEL); - if (!p_ife_dev) - return -ENOMEM; - - rc = of_property_read_u32(pdev->dev.of_node, - "cell-index", &p_ife_dev->hw_idx); - if (rc) { - CAM_ERR(CAM_ISP, "IFE failed to read cell-index"); - return rc; - } - - /* Initialze the v4l2 subdevice and register with cam_node */ - rc = ais_ife_init_subdev_params(p_ife_dev); - if (rc) { - CAM_ERR(CAM_ISP, "IFE%d init subdev failed!", - p_ife_dev->hw_idx); - goto err; - } - - mutex_init(&p_ife_dev->mutex); - - /* - * for now, we only support one iommu handle. later - * we will need to setup more iommu handle for other - * use cases. - * Also, we have to release them once we have the - * deinit support - */ - cam_smmu_get_handle("ife", &p_ife_dev->iommu_hdl); - if (rc) { - CAM_ERR(CAM_ISP, "Can not get iommu handle"); - rc = -EINVAL; - goto unregister; - } - - rc = cam_smmu_ops(p_ife_dev->iommu_hdl, CAM_SMMU_ATTACH); - if (rc && rc != -EALREADY) { - CAM_ERR(CAM_ISP, "Attach iommu handle failed %d", rc); - goto attach_fail; - } - - rc = cam_smmu_get_handle("ife-cp", - &p_ife_dev->iommu_hdl_secure); - if (rc) { - CAM_ERR(CAM_ISP, "Failed to get secure iommu handle %d", rc); - goto secure_fail; - } - - rc = cam_smmu_ops(p_ife_dev->iommu_hdl_secure, CAM_SMMU_ATTACH); - if (rc && rc != -EALREADY) { - CAM_ERR(CAM_ISP, "Attach secure iommu handle failed %d", rc); - goto secure_fail; - } - - CAM_DBG(CAM_ISP, "iommu_handles: non-secure[0x%x], secure[0x%x]", - p_ife_dev->iommu_hdl, - p_ife_dev->iommu_hdl_secure); - - cam_smmu_set_client_page_fault_handler(p_ife_dev->iommu_hdl, - ais_ife_dev_iommu_fault_handler, p_ife_dev); - - cam_smmu_set_client_page_fault_handler(p_ife_dev->iommu_hdl_secure, - ais_ife_dev_iommu_fault_handler, p_ife_dev); - - hw_init.hw_idx = p_ife_dev->hw_idx; - hw_init.iommu_hdl = p_ife_dev->iommu_hdl; - hw_init.iommu_hdl_secure = p_ife_dev->iommu_hdl_secure; - hw_init.event_cb = &ais_ife_dev_cb; - hw_init.event_cb_priv = p_ife_dev; - - rc = ais_ife_csid_hw_init(&p_ife_dev->p_csid_drv, &hw_init); - if (rc) { - CAM_ERR(CAM_ISP, "IFE%d no CSID dev", p_ife_dev->hw_idx, rc); - goto secure_attach_fail; - } - - rc = ais_vfe_hw_init(&p_ife_dev->p_vfe_drv, &hw_init, - p_ife_dev->p_csid_drv); - if (rc) { - CAM_ERR(CAM_ISP, "IFE%d no VFE dev", p_ife_dev->hw_idx, rc); - goto secure_attach_fail; - } - - CAM_INFO(CAM_ISP, "IFE%d probe complete", p_ife_dev->hw_idx); - - platform_set_drvdata(pdev, p_ife_dev); - - return 0; - -secure_attach_fail: - cam_smmu_ops(p_ife_dev->iommu_hdl_secure, - CAM_SMMU_DETACH); -secure_fail: - cam_smmu_ops(p_ife_dev->iommu_hdl, - CAM_SMMU_DETACH); -attach_fail: - cam_smmu_destroy_handle(p_ife_dev->iommu_hdl); - p_ife_dev->iommu_hdl = -1; -unregister: - cam_unregister_subdev(&(p_ife_dev->cam_sd)); -err: - return rc; -} - -static struct v4l2_subdev_core_ops ais_ife_subdev_core_ops = { - .ioctl = ais_ife_subdev_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl32 = ais_ife_subdev_ioctl_compat, -#endif - .subscribe_event = ais_ife_subdev_subscribe_event, - .unsubscribe_event = ais_ife_subdev_unsubscribe_event, -}; - -static struct v4l2_subdev_ops ais_ife_subdev_ops = { - .core = &ais_ife_subdev_core_ops, -}; - -static const struct v4l2_subdev_internal_ops ais_ife_internal_ops = { - .open = ais_ife_subdev_open, - .close = ais_ife_subdev_close, -}; - -static int ais_ife_init_subdev_params(struct ais_ife_dev *p_ife_dev) -{ - int rc = 0; - - p_ife_dev->cam_sd.internal_ops = - &ais_ife_internal_ops; - p_ife_dev->cam_sd.ops = - &ais_ife_subdev_ops; - strlcpy(p_ife_dev->device_name, AIS_IFE_DEV_NAME, - sizeof(p_ife_dev->device_name)); - p_ife_dev->cam_sd.name = - p_ife_dev->device_name; - p_ife_dev->cam_sd.sd_flags = - (V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS); - p_ife_dev->cam_sd.ent_function = - AIS_IFE_DEVICE_TYPE; - p_ife_dev->cam_sd.token = p_ife_dev; - - rc = cam_register_subdev(&(p_ife_dev->cam_sd)); - if (rc) - CAM_ERR(CAM_ISP, "Fail with cam_register_subdev rc: %d", rc); - - return rc; -} - -static const struct of_device_id ais_ife_dt_match[] = { - { - .compatible = "qcom,ais-ife" - }, - {} -}; - -static struct platform_driver ife_driver = { - .probe = ais_ife_dev_probe, - .remove = ais_ife_dev_remove, - .driver = { - .name = "ais_ife", - .owner = THIS_MODULE, - .of_match_table = ais_ife_dt_match, - .suppress_bind_attrs = true, - }, -}; - -static int __init ais_ife_dev_init_module(void) -{ - return platform_driver_register(&ife_driver); -} - -static void __exit ais_ife_dev_exit_module(void) -{ - platform_driver_unregister(&ife_driver); -} - -module_init(ais_ife_dev_init_module); -module_exit(ais_ife_dev_exit_module); -MODULE_DESCRIPTION("AIS IFE driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.h b/drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.h deleted file mode 100755 index 4273c4c1f7ab..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/ais_ife_dev.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_DEV_H_ -#define _AIS_IFE_DEV_H_ - -#include "cam_subdev.h" -#include "cam_hw_intf.h" - -#define AIS_IFE_DEV_NAME_MAX_LENGTH 20 - -/** - * struct ais_ife_dev - Camera IFE V4l2 device node - * - * @sd: IFE subdevice node - * @ctx: IFE base context storage - * @ctx_isp: IFE private context storage - * @mutex: IFE dev mutex - * @open_cnt: Open device count - */ -struct ais_ife_dev { - /*subdev info*/ - char device_name[AIS_IFE_DEV_NAME_MAX_LENGTH]; - struct cam_subdev cam_sd; - - uint32_t hw_idx; - - struct cam_hw_intf *p_vfe_drv; - struct cam_hw_intf *p_csid_drv; - - int iommu_hdl; - int iommu_hdl_secure; - - struct mutex mutex; - int32_t open_cnt; -}; - -#endif /* _AIS_IFE_DEV_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/Makefile b/drivers/media/platform/msm/ais/ais_isp/csid_hw/Makefile deleted file mode 100755 index a4e76eacaa9e..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_utils -ccflags-y += -Idrivers/media/platform/msm/ais/cam_core -ccflags-y += -Idrivers/media/platform/msm/ais/cam_cpas/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/include -ccflags-y += -Idrivers/media/platform/msm/ais/cam_smmu/ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_req_mgr/ - -obj-$(CONFIG_MSM_AIS) += ais_ife_csid_dev.o ais_ife_csid_soc.o ais_ife_csid_core.o -obj-$(CONFIG_MSM_AIS) += ais_ife_csid17x.o ais_ife_csid_lite17x.o diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid170.h b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid170.h deleted file mode 100755 index 91ce5a3ba6fb..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid170.h +++ /dev/null @@ -1,316 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_170_H_ -#define _AIS_IFE_CSID_170_H_ - -#include "ais_ife_csid_core.h" - -static struct ais_ife_csid_pxl_reg_offset ais_ife_csid_170_ipp_reg_offset = { - .csid_pxl_irq_status_addr = 0x30, - .csid_pxl_irq_mask_addr = 0x34, - .csid_pxl_irq_clear_addr = 0x38, - .csid_pxl_irq_set_addr = 0x3c, - - .csid_pxl_cfg0_addr = 0x200, - .csid_pxl_cfg1_addr = 0x204, - .csid_pxl_ctrl_addr = 0x208, - .csid_pxl_frm_drop_pattern_addr = 0x20c, - .csid_pxl_frm_drop_period_addr = 0x210, - .csid_pxl_irq_subsample_pattern_addr = 0x214, - .csid_pxl_irq_subsample_period_addr = 0x218, - .csid_pxl_hcrop_addr = 0x21c, - .csid_pxl_vcrop_addr = 0x220, - .csid_pxl_pix_drop_pattern_addr = 0x224, - .csid_pxl_pix_drop_period_addr = 0x228, - .csid_pxl_line_drop_pattern_addr = 0x22c, - .csid_pxl_line_drop_period_addr = 0x230, - .csid_pxl_rst_strobes_addr = 0x240, - .csid_pxl_status_addr = 0x254, - .csid_pxl_misr_val_addr = 0x258, - .csid_pxl_format_measure_cfg0_addr = 0x270, - .csid_pxl_format_measure_cfg1_addr = 0x274, - .csid_pxl_format_measure0_addr = 0x278, - .csid_pxl_format_measure1_addr = 0x27c, - .csid_pxl_format_measure2_addr = 0x280, - .csid_pxl_timestamp_curr0_sof_addr = 0x290, - .csid_pxl_timestamp_curr1_sof_addr = 0x294, - .csid_pxl_timestamp_perv0_sof_addr = 0x298, - .csid_pxl_timestamp_perv1_sof_addr = 0x29c, - .csid_pxl_timestamp_curr0_eof_addr = 0x2a0, - .csid_pxl_timestamp_curr1_eof_addr = 0x2a4, - .csid_pxl_timestamp_perv0_eof_addr = 0x2a8, - .csid_pxl_timestamp_perv1_eof_addr = 0x2ac, - /* configurations */ - .pix_store_en_shift_val = 7, - .early_eof_en_shift_val = 29, -}; - -static struct ais_ife_csid_rdi_reg_offset ais_ife_csid_170_rdi_0_reg_offset = { - .csid_rdi_irq_status_addr = 0x40, - .csid_rdi_irq_mask_addr = 0x44, - .csid_rdi_irq_clear_addr = 0x48, - .csid_rdi_irq_set_addr = 0x4c, - .csid_rdi_cfg0_addr = 0x300, - .csid_rdi_cfg1_addr = 0x304, - .csid_rdi_ctrl_addr = 0x308, - .csid_rdi_frm_drop_pattern_addr = 0x30c, - .csid_rdi_frm_drop_period_addr = 0x310, - .csid_rdi_irq_subsample_pattern_addr = 0x314, - .csid_rdi_irq_subsample_period_addr = 0x318, - .csid_rdi_rpp_hcrop_addr = 0x31c, - .csid_rdi_rpp_vcrop_addr = 0x320, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x324, - .csid_rdi_rpp_pix_drop_period_addr = 0x328, - .csid_rdi_rpp_line_drop_pattern_addr = 0x32c, - .csid_rdi_rpp_line_drop_period_addr = 0x330, - .csid_rdi_rst_strobes_addr = 0x340, - .csid_rdi_status_addr = 0x350, - .csid_rdi_misr_val0_addr = 0x354, - .csid_rdi_misr_val1_addr = 0x358, - .csid_rdi_misr_val2_addr = 0x35c, - .csid_rdi_misr_val3_addr = 0x360, - .csid_rdi_format_measure_cfg0_addr = 0x370, - .csid_rdi_format_measure_cfg1_addr = 0x374, - .csid_rdi_format_measure0_addr = 0x378, - .csid_rdi_format_measure1_addr = 0x37c, - .csid_rdi_format_measure2_addr = 0x380, - .csid_rdi_timestamp_curr0_sof_addr = 0x390, - .csid_rdi_timestamp_curr1_sof_addr = 0x394, - .csid_rdi_timestamp_prev0_sof_addr = 0x398, - .csid_rdi_timestamp_prev1_sof_addr = 0x39c, - .csid_rdi_timestamp_curr0_eof_addr = 0x3a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x3a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x3a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x3ac, - .csid_rdi_byte_cntr_ping_addr = 0x3e0, - .csid_rdi_byte_cntr_pong_addr = 0x3e4, -}; - -static struct ais_ife_csid_rdi_reg_offset ais_ife_csid_170_rdi_1_reg_offset = { - .csid_rdi_irq_status_addr = 0x50, - .csid_rdi_irq_mask_addr = 0x54, - .csid_rdi_irq_clear_addr = 0x58, - .csid_rdi_irq_set_addr = 0x5c, - .csid_rdi_cfg0_addr = 0x400, - .csid_rdi_cfg1_addr = 0x404, - .csid_rdi_ctrl_addr = 0x408, - .csid_rdi_frm_drop_pattern_addr = 0x40c, - .csid_rdi_frm_drop_period_addr = 0x410, - .csid_rdi_irq_subsample_pattern_addr = 0x414, - .csid_rdi_irq_subsample_period_addr = 0x418, - .csid_rdi_rpp_hcrop_addr = 0x41c, - .csid_rdi_rpp_vcrop_addr = 0x420, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x424, - .csid_rdi_rpp_pix_drop_period_addr = 0x428, - .csid_rdi_rpp_line_drop_pattern_addr = 0x42c, - .csid_rdi_rpp_line_drop_period_addr = 0x430, - .csid_rdi_rst_strobes_addr = 0x440, - .csid_rdi_status_addr = 0x450, - .csid_rdi_misr_val0_addr = 0x454, - .csid_rdi_misr_val1_addr = 0x458, - .csid_rdi_misr_val2_addr = 0x45c, - .csid_rdi_misr_val3_addr = 0x460, - .csid_rdi_format_measure_cfg0_addr = 0x470, - .csid_rdi_format_measure_cfg1_addr = 0x474, - .csid_rdi_format_measure0_addr = 0x478, - .csid_rdi_format_measure1_addr = 0x47c, - .csid_rdi_format_measure2_addr = 0x480, - .csid_rdi_timestamp_curr0_sof_addr = 0x490, - .csid_rdi_timestamp_curr1_sof_addr = 0x494, - .csid_rdi_timestamp_prev0_sof_addr = 0x498, - .csid_rdi_timestamp_prev1_sof_addr = 0x49c, - .csid_rdi_timestamp_curr0_eof_addr = 0x4a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x4a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x4a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x4ac, - .csid_rdi_byte_cntr_ping_addr = 0x4e0, - .csid_rdi_byte_cntr_pong_addr = 0x4e4, -}; - -static struct ais_ife_csid_rdi_reg_offset ais_ife_csid_170_rdi_2_reg_offset = { - .csid_rdi_irq_status_addr = 0x60, - .csid_rdi_irq_mask_addr = 0x64, - .csid_rdi_irq_clear_addr = 0x68, - .csid_rdi_irq_set_addr = 0x6c, - .csid_rdi_cfg0_addr = 0x500, - .csid_rdi_cfg1_addr = 0x504, - .csid_rdi_ctrl_addr = 0x508, - .csid_rdi_frm_drop_pattern_addr = 0x50c, - .csid_rdi_frm_drop_period_addr = 0x510, - .csid_rdi_irq_subsample_pattern_addr = 0x514, - .csid_rdi_irq_subsample_period_addr = 0x518, - .csid_rdi_rpp_hcrop_addr = 0x51c, - .csid_rdi_rpp_vcrop_addr = 0x520, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x524, - .csid_rdi_rpp_pix_drop_period_addr = 0x528, - .csid_rdi_rpp_line_drop_pattern_addr = 0x52c, - .csid_rdi_rpp_line_drop_period_addr = 0x530, - .csid_rdi_yuv_chroma_conversion_addr = 0x534, - .csid_rdi_rst_strobes_addr = 0x540, - .csid_rdi_status_addr = 0x550, - .csid_rdi_misr_val0_addr = 0x554, - .csid_rdi_misr_val1_addr = 0x558, - .csid_rdi_misr_val2_addr = 0x55c, - .csid_rdi_misr_val3_addr = 0x560, - .csid_rdi_format_measure_cfg0_addr = 0x570, - .csid_rdi_format_measure_cfg1_addr = 0x574, - .csid_rdi_format_measure0_addr = 0x578, - .csid_rdi_format_measure1_addr = 0x57c, - .csid_rdi_format_measure2_addr = 0x580, - .csid_rdi_timestamp_curr0_sof_addr = 0x590, - .csid_rdi_timestamp_curr1_sof_addr = 0x594, - .csid_rdi_timestamp_prev0_sof_addr = 0x598, - .csid_rdi_timestamp_prev1_sof_addr = 0x59c, - .csid_rdi_timestamp_curr0_eof_addr = 0x5a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x5a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x5a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x5ac, - .csid_rdi_byte_cntr_ping_addr = 0x5e0, - .csid_rdi_byte_cntr_pong_addr = 0x5e4, -}; - -static struct ais_ife_csid_csi2_rx_reg_offset - ais_ife_csid_170_csi2_reg_offset = { - .csid_csi2_rx_irq_status_addr = 0x20, - .csid_csi2_rx_irq_mask_addr = 0x24, - .csid_csi2_rx_irq_clear_addr = 0x28, - .csid_csi2_rx_irq_set_addr = 0x2c, - - /*CSI2 rx control */ - .csid_csi2_rx_cfg0_addr = 0x100, - .csid_csi2_rx_cfg1_addr = 0x104, - .csid_csi2_rx_capture_ctrl_addr = 0x108, - .csid_csi2_rx_rst_strobes_addr = 0x110, - .csid_csi2_rx_de_scramble_cfg0_addr = 0x114, - .csid_csi2_rx_de_scramble_cfg1_addr = 0x118, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_0_addr = 0x120, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_1_addr = 0x124, - .csid_csi2_rx_captured_short_pkt_0_addr = 0x128, - .csid_csi2_rx_captured_short_pkt_1_addr = 0x12c, - .csid_csi2_rx_captured_long_pkt_0_addr = 0x130, - .csid_csi2_rx_captured_long_pkt_1_addr = 0x134, - .csid_csi2_rx_captured_long_pkt_ftr_addr = 0x138, - .csid_csi2_rx_captured_cphy_pkt_hdr_addr = 0x13c, - .csid_csi2_rx_lane0_misr_addr = 0x150, - .csid_csi2_rx_lane1_misr_addr = 0x154, - .csid_csi2_rx_lane2_misr_addr = 0x158, - .csid_csi2_rx_lane3_misr_addr = 0x15c, - .csid_csi2_rx_total_pkts_rcvd_addr = 0x160, - .csid_csi2_rx_stats_ecc_addr = 0x164, - .csid_csi2_rx_total_crc_err_addr = 0x168, - - .csi2_rst_srb_all = 0x3FFF, - .csi2_rst_done_shift_val = 27, - .csi2_irq_mask_all = 0xFFFFFFF, - .csi2_misr_enable_shift_val = 6, - .csi2_vc_mode_shift_val = 2, - .csi2_capture_long_pkt_en_shift = 0, - .csi2_capture_short_pkt_en_shift = 1, - .csi2_capture_cphy_pkt_en_shift = 2, - .csi2_capture_long_pkt_dt_shift = 4, - .csi2_capture_long_pkt_vc_shift = 10, - .csi2_capture_short_pkt_vc_shift = 15, - .csi2_capture_cphy_pkt_dt_shift = 20, - .csi2_capture_cphy_pkt_vc_shift = 26, - .csi2_rx_phy_num_mask = 0x3, -}; - -static struct ais_ife_csid_csi2_tpg_reg_offset - ais_ife_csid_170_tpg_reg_offset = { - /*CSID TPG control */ - .csid_tpg_ctrl_addr = 0x600, - .csid_tpg_vc_cfg0_addr = 0x604, - .csid_tpg_vc_cfg1_addr = 0x608, - .csid_tpg_lfsr_seed_addr = 0x60c, - .csid_tpg_dt_n_cfg_0_addr = 0x610, - .csid_tpg_dt_n_cfg_1_addr = 0x614, - .csid_tpg_dt_n_cfg_2_addr = 0x618, - .csid_tpg_color_bars_cfg_addr = 0x640, - .csid_tpg_color_box_cfg_addr = 0x644, - .csid_tpg_common_gen_cfg_addr = 0x648, - .csid_tpg_cgen_n_cfg_addr = 0x650, - .csid_tpg_cgen_n_x0_addr = 0x654, - .csid_tpg_cgen_n_x1_addr = 0x658, - .csid_tpg_cgen_n_x2_addr = 0x65c, - .csid_tpg_cgen_n_xy_addr = 0x660, - .csid_tpg_cgen_n_y1_addr = 0x664, - .csid_tpg_cgen_n_y2_addr = 0x668, - - /* configurations */ - .tpg_dtn_cfg_offset = 0xc, - .tpg_cgen_cfg_offset = 0x20, - .tpg_cpas_ife_reg_offset = 0x28, -}; - -static struct ais_ife_csid_common_reg_offset - ais_ife_csid_170_cmn_reg_offset = { - .csid_hw_version_addr = 0x0, - .csid_cfg0_addr = 0x4, - .csid_ctrl_addr = 0x8, - .csid_reset_addr = 0xc, - .csid_rst_strobes_addr = 0x10, - - .csid_test_bus_ctrl_addr = 0x14, - .csid_top_irq_status_addr = 0x70, - .csid_top_irq_mask_addr = 0x74, - .csid_top_irq_clear_addr = 0x78, - .csid_top_irq_set_addr = 0x7c, - .csid_irq_cmd_addr = 0x80, - - /*configurations */ - .major_version = 1, - .minor_version = 7, - .version_incr = 0, - .num_rdis = 3, - .num_pix = 1, - .num_ppp = 0, - .csid_reg_rst_stb = 1, - .csid_rst_stb = 0x1e, - .csid_rst_stb_sw_all = 0x1f, - .path_rst_stb_all = 0x7f, - .path_rst_done_shift_val = 1, - .path_en_shift_val = 31, - .dt_id_shift_val = 27, - .vc_shift_val = 22, - .dt_shift_val = 16, - .fmt_shift_val = 12, - .plain_fmt_shit_val = 10, - .crop_v_en_shift_val = 6, - .crop_h_en_shift_val = 5, - .crop_shift = 16, - .ipp_irq_mask_all = 0x7FFF, - .rdi_irq_mask_all = 0x7FFF, - .ppp_irq_mask_all = 0x0, - .measure_en_hbi_vbi_cnt_mask = 0xC, - .format_measure_en_val = 1, - .format_measure_height_mask_val = 0xFFFF, - .format_measure_height_shift_val = 0x10, - .format_measure_width_mask_val = 0xFFFF, - .format_measure_width_shift_val = 0x0, -}; - -static struct ais_ife_csid_reg_offset ais_ife_csid_170_reg_offset = { - .cmn_reg = &ais_ife_csid_170_cmn_reg_offset, - .csi2_reg = &ais_ife_csid_170_csi2_reg_offset, - .ipp_reg = &ais_ife_csid_170_ipp_reg_offset, - .ppp_reg = NULL, - .rdi_reg = { - &ais_ife_csid_170_rdi_0_reg_offset, - &ais_ife_csid_170_rdi_1_reg_offset, - &ais_ife_csid_170_rdi_2_reg_offset, - NULL, - }, - .tpg_reg = &ais_ife_csid_170_tpg_reg_offset, -}; - -#endif /*_AIS_IFE_CSID_170_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175.h b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175.h deleted file mode 100755 index 777c784ef26a..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175.h +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_175_H_ -#define _AIS_IFE_CSID_175_H_ - -#include "ais_ife_csid_core.h" - -static struct ais_ife_csid_pxl_reg_offset ais_ife_csid_175_ipp_reg_offset = { - .csid_pxl_irq_status_addr = 0x30, - .csid_pxl_irq_mask_addr = 0x34, - .csid_pxl_irq_clear_addr = 0x38, - .csid_pxl_irq_set_addr = 0x3c, - - .csid_pxl_cfg0_addr = 0x200, - .csid_pxl_cfg1_addr = 0x204, - .csid_pxl_ctrl_addr = 0x208, - .csid_pxl_frm_drop_pattern_addr = 0x20c, - .csid_pxl_frm_drop_period_addr = 0x210, - .csid_pxl_irq_subsample_pattern_addr = 0x214, - .csid_pxl_irq_subsample_period_addr = 0x218, - .csid_pxl_hcrop_addr = 0x21c, - .csid_pxl_vcrop_addr = 0x220, - .csid_pxl_pix_drop_pattern_addr = 0x224, - .csid_pxl_pix_drop_period_addr = 0x228, - .csid_pxl_line_drop_pattern_addr = 0x22c, - .csid_pxl_line_drop_period_addr = 0x230, - .csid_pxl_rst_strobes_addr = 0x240, - .csid_pxl_status_addr = 0x254, - .csid_pxl_misr_val_addr = 0x258, - .csid_pxl_format_measure_cfg0_addr = 0x270, - .csid_pxl_format_measure_cfg1_addr = 0x274, - .csid_pxl_format_measure0_addr = 0x278, - .csid_pxl_format_measure1_addr = 0x27c, - .csid_pxl_format_measure2_addr = 0x280, - .csid_pxl_timestamp_curr0_sof_addr = 0x290, - .csid_pxl_timestamp_curr1_sof_addr = 0x294, - .csid_pxl_timestamp_perv0_sof_addr = 0x298, - .csid_pxl_timestamp_perv1_sof_addr = 0x29c, - .csid_pxl_timestamp_curr0_eof_addr = 0x2a0, - .csid_pxl_timestamp_curr1_eof_addr = 0x2a4, - .csid_pxl_timestamp_perv0_eof_addr = 0x2a8, - .csid_pxl_timestamp_perv1_eof_addr = 0x2ac, - /* configurations */ - .pix_store_en_shift_val = 7, - .early_eof_en_shift_val = 29, -}; - -static struct ais_ife_csid_pxl_reg_offset ais_ife_csid_175_ppp_reg_offset = { - .csid_pxl_irq_status_addr = 0xa0, - .csid_pxl_irq_mask_addr = 0xa4, - .csid_pxl_irq_clear_addr = 0xa8, - .csid_pxl_irq_set_addr = 0xac, - - .csid_pxl_cfg0_addr = 0x700, - .csid_pxl_cfg1_addr = 0x704, - .csid_pxl_ctrl_addr = 0x708, - .csid_pxl_frm_drop_pattern_addr = 0x70c, - .csid_pxl_frm_drop_period_addr = 0x710, - .csid_pxl_irq_subsample_pattern_addr = 0x714, - .csid_pxl_irq_subsample_period_addr = 0x718, - .csid_pxl_hcrop_addr = 0x71c, - .csid_pxl_vcrop_addr = 0x720, - .csid_pxl_pix_drop_pattern_addr = 0x724, - .csid_pxl_pix_drop_period_addr = 0x728, - .csid_pxl_line_drop_pattern_addr = 0x72c, - .csid_pxl_line_drop_period_addr = 0x730, - .csid_pxl_rst_strobes_addr = 0x740, - .csid_pxl_status_addr = 0x754, - .csid_pxl_misr_val_addr = 0x758, - .csid_pxl_format_measure_cfg0_addr = 0x770, - .csid_pxl_format_measure_cfg1_addr = 0x774, - .csid_pxl_format_measure0_addr = 0x778, - .csid_pxl_format_measure1_addr = 0x77c, - .csid_pxl_format_measure2_addr = 0x780, - .csid_pxl_timestamp_curr0_sof_addr = 0x790, - .csid_pxl_timestamp_curr1_sof_addr = 0x794, - .csid_pxl_timestamp_perv0_sof_addr = 0x798, - .csid_pxl_timestamp_perv1_sof_addr = 0x79c, - .csid_pxl_timestamp_curr0_eof_addr = 0x7a0, - .csid_pxl_timestamp_curr1_eof_addr = 0x7a4, - .csid_pxl_timestamp_perv0_eof_addr = 0x7a8, - .csid_pxl_timestamp_perv1_eof_addr = 0x7ac, - /* configurations */ - .pix_store_en_shift_val = 7, - .early_eof_en_shift_val = 29, -}; - - -static struct ais_ife_csid_rdi_reg_offset ais_ife_csid_175_rdi_0_reg_offset = { - .csid_rdi_irq_status_addr = 0x40, - .csid_rdi_irq_mask_addr = 0x44, - .csid_rdi_irq_clear_addr = 0x48, - .csid_rdi_irq_set_addr = 0x4c, - .csid_rdi_cfg0_addr = 0x300, - .csid_rdi_cfg1_addr = 0x304, - .csid_rdi_ctrl_addr = 0x308, - .csid_rdi_frm_drop_pattern_addr = 0x30c, - .csid_rdi_frm_drop_period_addr = 0x310, - .csid_rdi_irq_subsample_pattern_addr = 0x314, - .csid_rdi_irq_subsample_period_addr = 0x318, - .csid_rdi_rpp_hcrop_addr = 0x31c, - .csid_rdi_rpp_vcrop_addr = 0x320, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x324, - .csid_rdi_rpp_pix_drop_period_addr = 0x328, - .csid_rdi_rpp_line_drop_pattern_addr = 0x32c, - .csid_rdi_rpp_line_drop_period_addr = 0x330, - .csid_rdi_rst_strobes_addr = 0x340, - .csid_rdi_status_addr = 0x350, - .csid_rdi_misr_val0_addr = 0x354, - .csid_rdi_misr_val1_addr = 0x358, - .csid_rdi_misr_val2_addr = 0x35c, - .csid_rdi_misr_val3_addr = 0x360, - .csid_rdi_format_measure_cfg0_addr = 0x370, - .csid_rdi_format_measure_cfg1_addr = 0x374, - .csid_rdi_format_measure0_addr = 0x378, - .csid_rdi_format_measure1_addr = 0x37c, - .csid_rdi_format_measure2_addr = 0x380, - .csid_rdi_timestamp_curr0_sof_addr = 0x390, - .csid_rdi_timestamp_curr1_sof_addr = 0x394, - .csid_rdi_timestamp_prev0_sof_addr = 0x398, - .csid_rdi_timestamp_prev1_sof_addr = 0x39c, - .csid_rdi_timestamp_curr0_eof_addr = 0x3a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x3a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x3a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x3ac, - .csid_rdi_byte_cntr_ping_addr = 0x3e0, - .csid_rdi_byte_cntr_pong_addr = 0x3e4, -}; - -static struct ais_ife_csid_rdi_reg_offset ais_ife_csid_175_rdi_1_reg_offset = { - .csid_rdi_irq_status_addr = 0x50, - .csid_rdi_irq_mask_addr = 0x54, - .csid_rdi_irq_clear_addr = 0x58, - .csid_rdi_irq_set_addr = 0x5c, - .csid_rdi_cfg0_addr = 0x400, - .csid_rdi_cfg1_addr = 0x404, - .csid_rdi_ctrl_addr = 0x408, - .csid_rdi_frm_drop_pattern_addr = 0x40c, - .csid_rdi_frm_drop_period_addr = 0x410, - .csid_rdi_irq_subsample_pattern_addr = 0x414, - .csid_rdi_irq_subsample_period_addr = 0x418, - .csid_rdi_rpp_hcrop_addr = 0x41c, - .csid_rdi_rpp_vcrop_addr = 0x420, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x424, - .csid_rdi_rpp_pix_drop_period_addr = 0x428, - .csid_rdi_rpp_line_drop_pattern_addr = 0x42c, - .csid_rdi_rpp_line_drop_period_addr = 0x430, - .csid_rdi_rst_strobes_addr = 0x440, - .csid_rdi_status_addr = 0x450, - .csid_rdi_misr_val0_addr = 0x454, - .csid_rdi_misr_val1_addr = 0x458, - .csid_rdi_misr_val2_addr = 0x45c, - .csid_rdi_misr_val3_addr = 0x460, - .csid_rdi_format_measure_cfg0_addr = 0x470, - .csid_rdi_format_measure_cfg1_addr = 0x474, - .csid_rdi_format_measure0_addr = 0x478, - .csid_rdi_format_measure1_addr = 0x47c, - .csid_rdi_format_measure2_addr = 0x480, - .csid_rdi_timestamp_curr0_sof_addr = 0x490, - .csid_rdi_timestamp_curr1_sof_addr = 0x494, - .csid_rdi_timestamp_prev0_sof_addr = 0x498, - .csid_rdi_timestamp_prev1_sof_addr = 0x49c, - .csid_rdi_timestamp_curr0_eof_addr = 0x4a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x4a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x4a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x4ac, - .csid_rdi_byte_cntr_ping_addr = 0x4e0, - .csid_rdi_byte_cntr_pong_addr = 0x4e4, -}; - -static struct ais_ife_csid_rdi_reg_offset ais_ife_csid_175_rdi_2_reg_offset = { - .csid_rdi_irq_status_addr = 0x60, - .csid_rdi_irq_mask_addr = 0x64, - .csid_rdi_irq_clear_addr = 0x68, - .csid_rdi_irq_set_addr = 0x6c, - .csid_rdi_cfg0_addr = 0x500, - .csid_rdi_cfg1_addr = 0x504, - .csid_rdi_ctrl_addr = 0x508, - .csid_rdi_frm_drop_pattern_addr = 0x50c, - .csid_rdi_frm_drop_period_addr = 0x510, - .csid_rdi_irq_subsample_pattern_addr = 0x514, - .csid_rdi_irq_subsample_period_addr = 0x518, - .csid_rdi_rpp_hcrop_addr = 0x51c, - .csid_rdi_rpp_vcrop_addr = 0x520, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x524, - .csid_rdi_rpp_pix_drop_period_addr = 0x528, - .csid_rdi_rpp_line_drop_pattern_addr = 0x52c, - .csid_rdi_rpp_line_drop_period_addr = 0x530, - .csid_rdi_yuv_chroma_conversion_addr = 0x534, - .csid_rdi_rst_strobes_addr = 0x540, - .csid_rdi_status_addr = 0x550, - .csid_rdi_misr_val0_addr = 0x554, - .csid_rdi_misr_val1_addr = 0x558, - .csid_rdi_misr_val2_addr = 0x55c, - .csid_rdi_misr_val3_addr = 0x560, - .csid_rdi_format_measure_cfg0_addr = 0x570, - .csid_rdi_format_measure_cfg1_addr = 0x574, - .csid_rdi_format_measure0_addr = 0x578, - .csid_rdi_format_measure1_addr = 0x57c, - .csid_rdi_format_measure2_addr = 0x580, - .csid_rdi_timestamp_curr0_sof_addr = 0x590, - .csid_rdi_timestamp_curr1_sof_addr = 0x594, - .csid_rdi_timestamp_prev0_sof_addr = 0x598, - .csid_rdi_timestamp_prev1_sof_addr = 0x59c, - .csid_rdi_timestamp_curr0_eof_addr = 0x5a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x5a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x5a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x5ac, - .csid_rdi_byte_cntr_ping_addr = 0x5e0, - .csid_rdi_byte_cntr_pong_addr = 0x5e4, -}; - -static struct ais_ife_csid_csi2_rx_reg_offset - ais_ife_csid_175_csi2_reg_offset = { - .csid_csi2_rx_irq_status_addr = 0x20, - .csid_csi2_rx_irq_mask_addr = 0x24, - .csid_csi2_rx_irq_clear_addr = 0x28, - .csid_csi2_rx_irq_set_addr = 0x2c, - - /*CSI2 rx control */ - .csid_csi2_rx_cfg0_addr = 0x100, - .csid_csi2_rx_cfg1_addr = 0x104, - .csid_csi2_rx_capture_ctrl_addr = 0x108, - .csid_csi2_rx_rst_strobes_addr = 0x110, - .csid_csi2_rx_de_scramble_cfg0_addr = 0x114, - .csid_csi2_rx_de_scramble_cfg1_addr = 0x118, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_0_addr = 0x120, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_1_addr = 0x124, - .csid_csi2_rx_captured_short_pkt_0_addr = 0x128, - .csid_csi2_rx_captured_short_pkt_1_addr = 0x12c, - .csid_csi2_rx_captured_long_pkt_0_addr = 0x130, - .csid_csi2_rx_captured_long_pkt_1_addr = 0x134, - .csid_csi2_rx_captured_long_pkt_ftr_addr = 0x138, - .csid_csi2_rx_captured_cphy_pkt_hdr_addr = 0x13c, - .csid_csi2_rx_lane0_misr_addr = 0x150, - .csid_csi2_rx_lane1_misr_addr = 0x154, - .csid_csi2_rx_lane2_misr_addr = 0x158, - .csid_csi2_rx_lane3_misr_addr = 0x15c, - .csid_csi2_rx_total_pkts_rcvd_addr = 0x160, - .csid_csi2_rx_stats_ecc_addr = 0x164, - .csid_csi2_rx_total_crc_err_addr = 0x168, - - .csi2_rst_srb_all = 0x3FFF, - .csi2_rst_done_shift_val = 27, - .csi2_irq_mask_all = 0xFFFFFFF, - .csi2_misr_enable_shift_val = 6, - .csi2_vc_mode_shift_val = 2, - .csi2_capture_long_pkt_en_shift = 0, - .csi2_capture_short_pkt_en_shift = 1, - .csi2_capture_cphy_pkt_en_shift = 2, - .csi2_capture_long_pkt_dt_shift = 4, - .csi2_capture_long_pkt_vc_shift = 10, - .csi2_capture_short_pkt_vc_shift = 15, - .csi2_capture_cphy_pkt_dt_shift = 20, - .csi2_capture_cphy_pkt_vc_shift = 26, - .csi2_rx_phy_num_mask = 0x3, -}; - -static struct ais_ife_csid_csi2_tpg_reg_offset - ais_ife_csid_175_tpg_reg_offset = { - /*CSID TPG control */ - .csid_tpg_ctrl_addr = 0x600, - .csid_tpg_vc_cfg0_addr = 0x604, - .csid_tpg_vc_cfg1_addr = 0x608, - .csid_tpg_lfsr_seed_addr = 0x60c, - .csid_tpg_dt_n_cfg_0_addr = 0x610, - .csid_tpg_dt_n_cfg_1_addr = 0x614, - .csid_tpg_dt_n_cfg_2_addr = 0x618, - .csid_tpg_color_bars_cfg_addr = 0x640, - .csid_tpg_color_box_cfg_addr = 0x644, - .csid_tpg_common_gen_cfg_addr = 0x648, - .csid_tpg_cgen_n_cfg_addr = 0x650, - .csid_tpg_cgen_n_x0_addr = 0x654, - .csid_tpg_cgen_n_x1_addr = 0x658, - .csid_tpg_cgen_n_x2_addr = 0x65c, - .csid_tpg_cgen_n_xy_addr = 0x660, - .csid_tpg_cgen_n_y1_addr = 0x664, - .csid_tpg_cgen_n_y2_addr = 0x668, - - /* configurations */ - .tpg_dtn_cfg_offset = 0xc, - .tpg_cgen_cfg_offset = 0x20, - .tpg_cpas_ife_reg_offset = 0x28, -}; - -static struct ais_ife_csid_common_reg_offset - ais_ife_csid_175_cmn_reg_offset = { - .csid_hw_version_addr = 0x0, - .csid_cfg0_addr = 0x4, - .csid_ctrl_addr = 0x8, - .csid_reset_addr = 0xc, - .csid_rst_strobes_addr = 0x10, - - .csid_test_bus_ctrl_addr = 0x14, - .csid_top_irq_status_addr = 0x70, - .csid_top_irq_mask_addr = 0x74, - .csid_top_irq_clear_addr = 0x78, - .csid_top_irq_set_addr = 0x7c, - .csid_irq_cmd_addr = 0x80, - - /*configurations */ - .major_version = 1, - .minor_version = 7, - .version_incr = 0, - .num_rdis = 3, - .num_pix = 1, - .num_ppp = 1, - .csid_reg_rst_stb = 1, - .csid_rst_stb = 0x1e, - .csid_rst_stb_sw_all = 0x1f, - .path_rst_stb_all = 0x7f, - .path_rst_done_shift_val = 1, - .path_en_shift_val = 31, - .dt_id_shift_val = 27, - .vc_shift_val = 22, - .dt_shift_val = 16, - .fmt_shift_val = 12, - .plain_fmt_shit_val = 10, - .crop_v_en_shift_val = 6, - .crop_h_en_shift_val = 5, - .crop_shift = 16, - .ipp_irq_mask_all = 0x7FFF, - .rdi_irq_mask_all = 0x7FFF, - .ppp_irq_mask_all = 0xFFFF, - .measure_en_hbi_vbi_cnt_mask = 0xC, - .format_measure_en_val = 1, - .format_measure_height_mask_val = 0xFFFF, - .format_measure_height_shift_val = 0x10, - .format_measure_width_mask_val = 0xFFFF, - .format_measure_width_shift_val = 0x0, -}; - -static struct ais_ife_csid_reg_offset ais_ife_csid_175_reg_offset = { - .cmn_reg = &ais_ife_csid_175_cmn_reg_offset, - .csi2_reg = &ais_ife_csid_175_csi2_reg_offset, - .ipp_reg = &ais_ife_csid_175_ipp_reg_offset, - .ppp_reg = &ais_ife_csid_175_ppp_reg_offset, - .rdi_reg = { - &ais_ife_csid_175_rdi_0_reg_offset, - &ais_ife_csid_175_rdi_1_reg_offset, - &ais_ife_csid_175_rdi_2_reg_offset, - NULL, - }, - .tpg_reg = &ais_ife_csid_175_tpg_reg_offset, -}; - -#endif /*_AIS_IFE_CSID_175_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175_200.h b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175_200.h deleted file mode 100755 index a8eb8243c1cd..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid175_200.h +++ /dev/null @@ -1,373 +0,0 @@ -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_175_200_H_ -#define _AIS_IFE_CSID_175_200_H_ - -#include "ais_ife_csid_core.h" - -static struct ais_ife_csid_pxl_reg_offset - ais_ife_csid_175_200_ipp_reg_offset = { - .csid_pxl_irq_status_addr = 0x30, - .csid_pxl_irq_mask_addr = 0x34, - .csid_pxl_irq_clear_addr = 0x38, - .csid_pxl_irq_set_addr = 0x3c, - - .csid_pxl_cfg0_addr = 0x200, - .csid_pxl_cfg1_addr = 0x204, - .csid_pxl_ctrl_addr = 0x208, - .csid_pxl_frm_drop_pattern_addr = 0x20c, - .csid_pxl_frm_drop_period_addr = 0x210, - .csid_pxl_irq_subsample_pattern_addr = 0x214, - .csid_pxl_irq_subsample_period_addr = 0x218, - .csid_pxl_hcrop_addr = 0x21c, - .csid_pxl_vcrop_addr = 0x220, - .csid_pxl_pix_drop_pattern_addr = 0x224, - .csid_pxl_pix_drop_period_addr = 0x228, - .csid_pxl_line_drop_pattern_addr = 0x22c, - .csid_pxl_line_drop_period_addr = 0x230, - .csid_pxl_rst_strobes_addr = 0x240, - .csid_pxl_status_addr = 0x254, - .csid_pxl_misr_val_addr = 0x258, - .csid_pxl_format_measure_cfg0_addr = 0x270, - .csid_pxl_format_measure_cfg1_addr = 0x274, - .csid_pxl_format_measure0_addr = 0x278, - .csid_pxl_format_measure1_addr = 0x27c, - .csid_pxl_format_measure2_addr = 0x280, - .csid_pxl_timestamp_curr0_sof_addr = 0x290, - .csid_pxl_timestamp_curr1_sof_addr = 0x294, - .csid_pxl_timestamp_perv0_sof_addr = 0x298, - .csid_pxl_timestamp_perv1_sof_addr = 0x29c, - .csid_pxl_timestamp_curr0_eof_addr = 0x2a0, - .csid_pxl_timestamp_curr1_eof_addr = 0x2a4, - .csid_pxl_timestamp_perv0_eof_addr = 0x2a8, - .csid_pxl_timestamp_perv1_eof_addr = 0x2ac, - /* configurations */ - .pix_store_en_shift_val = 7, - .early_eof_en_shift_val = 29, - .ccif_violation_en = 1, -}; - -static struct ais_ife_csid_pxl_reg_offset - ais_ife_csid_175_200_ppp_reg_offset = { - .csid_pxl_irq_status_addr = 0xa0, - .csid_pxl_irq_mask_addr = 0xa4, - .csid_pxl_irq_clear_addr = 0xa8, - .csid_pxl_irq_set_addr = 0xac, - - .csid_pxl_cfg0_addr = 0x700, - .csid_pxl_cfg1_addr = 0x704, - .csid_pxl_ctrl_addr = 0x708, - .csid_pxl_frm_drop_pattern_addr = 0x70c, - .csid_pxl_frm_drop_period_addr = 0x710, - .csid_pxl_irq_subsample_pattern_addr = 0x714, - .csid_pxl_irq_subsample_period_addr = 0x718, - .csid_pxl_hcrop_addr = 0x71c, - .csid_pxl_vcrop_addr = 0x720, - .csid_pxl_pix_drop_pattern_addr = 0x724, - .csid_pxl_pix_drop_period_addr = 0x728, - .csid_pxl_line_drop_pattern_addr = 0x72c, - .csid_pxl_line_drop_period_addr = 0x730, - .csid_pxl_rst_strobes_addr = 0x740, - .csid_pxl_status_addr = 0x754, - .csid_pxl_misr_val_addr = 0x758, - .csid_pxl_format_measure_cfg0_addr = 0x770, - .csid_pxl_format_measure_cfg1_addr = 0x774, - .csid_pxl_format_measure0_addr = 0x778, - .csid_pxl_format_measure1_addr = 0x77c, - .csid_pxl_format_measure2_addr = 0x780, - .csid_pxl_timestamp_curr0_sof_addr = 0x790, - .csid_pxl_timestamp_curr1_sof_addr = 0x794, - .csid_pxl_timestamp_perv0_sof_addr = 0x798, - .csid_pxl_timestamp_perv1_sof_addr = 0x79c, - .csid_pxl_timestamp_curr0_eof_addr = 0x7a0, - .csid_pxl_timestamp_curr1_eof_addr = 0x7a4, - .csid_pxl_timestamp_perv0_eof_addr = 0x7a8, - .csid_pxl_timestamp_perv1_eof_addr = 0x7ac, - /* configurations */ - .pix_store_en_shift_val = 7, - .early_eof_en_shift_val = 29, - .ccif_violation_en = 1, -}; - - -static struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_175_200_rdi_0_reg_offset = { - .csid_rdi_irq_status_addr = 0x40, - .csid_rdi_irq_mask_addr = 0x44, - .csid_rdi_irq_clear_addr = 0x48, - .csid_rdi_irq_set_addr = 0x4c, - .csid_rdi_cfg0_addr = 0x300, - .csid_rdi_cfg1_addr = 0x304, - .csid_rdi_ctrl_addr = 0x308, - .csid_rdi_frm_drop_pattern_addr = 0x30c, - .csid_rdi_frm_drop_period_addr = 0x310, - .csid_rdi_irq_subsample_pattern_addr = 0x314, - .csid_rdi_irq_subsample_period_addr = 0x318, - .csid_rdi_rpp_hcrop_addr = 0x31c, - .csid_rdi_rpp_vcrop_addr = 0x320, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x324, - .csid_rdi_rpp_pix_drop_period_addr = 0x328, - .csid_rdi_rpp_line_drop_pattern_addr = 0x32c, - .csid_rdi_rpp_line_drop_period_addr = 0x330, - .csid_rdi_rst_strobes_addr = 0x340, - .csid_rdi_status_addr = 0x350, - .csid_rdi_misr_val0_addr = 0x354, - .csid_rdi_misr_val1_addr = 0x358, - .csid_rdi_misr_val2_addr = 0x35c, - .csid_rdi_misr_val3_addr = 0x360, - .csid_rdi_format_measure_cfg0_addr = 0x370, - .csid_rdi_format_measure_cfg1_addr = 0x374, - .csid_rdi_format_measure0_addr = 0x378, - .csid_rdi_format_measure1_addr = 0x37c, - .csid_rdi_format_measure2_addr = 0x380, - .csid_rdi_timestamp_curr0_sof_addr = 0x390, - .csid_rdi_timestamp_curr1_sof_addr = 0x394, - .csid_rdi_timestamp_prev0_sof_addr = 0x398, - .csid_rdi_timestamp_prev1_sof_addr = 0x39c, - .csid_rdi_timestamp_curr0_eof_addr = 0x3a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x3a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x3a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x3ac, - .csid_rdi_byte_cntr_ping_addr = 0x3e0, - .csid_rdi_byte_cntr_pong_addr = 0x3e4, - .ccif_violation_en = 1, -}; - -static struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_175_200_rdi_1_reg_offset = { - .csid_rdi_irq_status_addr = 0x50, - .csid_rdi_irq_mask_addr = 0x54, - .csid_rdi_irq_clear_addr = 0x58, - .csid_rdi_irq_set_addr = 0x5c, - .csid_rdi_cfg0_addr = 0x400, - .csid_rdi_cfg1_addr = 0x404, - .csid_rdi_ctrl_addr = 0x408, - .csid_rdi_frm_drop_pattern_addr = 0x40c, - .csid_rdi_frm_drop_period_addr = 0x410, - .csid_rdi_irq_subsample_pattern_addr = 0x414, - .csid_rdi_irq_subsample_period_addr = 0x418, - .csid_rdi_rpp_hcrop_addr = 0x41c, - .csid_rdi_rpp_vcrop_addr = 0x420, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x424, - .csid_rdi_rpp_pix_drop_period_addr = 0x428, - .csid_rdi_rpp_line_drop_pattern_addr = 0x42c, - .csid_rdi_rpp_line_drop_period_addr = 0x430, - .csid_rdi_rst_strobes_addr = 0x440, - .csid_rdi_status_addr = 0x450, - .csid_rdi_misr_val0_addr = 0x454, - .csid_rdi_misr_val1_addr = 0x458, - .csid_rdi_misr_val2_addr = 0x45c, - .csid_rdi_misr_val3_addr = 0x460, - .csid_rdi_format_measure_cfg0_addr = 0x470, - .csid_rdi_format_measure_cfg1_addr = 0x474, - .csid_rdi_format_measure0_addr = 0x478, - .csid_rdi_format_measure1_addr = 0x47c, - .csid_rdi_format_measure2_addr = 0x480, - .csid_rdi_timestamp_curr0_sof_addr = 0x490, - .csid_rdi_timestamp_curr1_sof_addr = 0x494, - .csid_rdi_timestamp_prev0_sof_addr = 0x498, - .csid_rdi_timestamp_prev1_sof_addr = 0x49c, - .csid_rdi_timestamp_curr0_eof_addr = 0x4a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x4a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x4a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x4ac, - .csid_rdi_byte_cntr_ping_addr = 0x4e0, - .csid_rdi_byte_cntr_pong_addr = 0x4e4, - .ccif_violation_en = 1, -}; - -static struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_175_200_rdi_2_reg_offset = { - .csid_rdi_irq_status_addr = 0x60, - .csid_rdi_irq_mask_addr = 0x64, - .csid_rdi_irq_clear_addr = 0x68, - .csid_rdi_irq_set_addr = 0x6c, - .csid_rdi_cfg0_addr = 0x500, - .csid_rdi_cfg1_addr = 0x504, - .csid_rdi_ctrl_addr = 0x508, - .csid_rdi_frm_drop_pattern_addr = 0x50c, - .csid_rdi_frm_drop_period_addr = 0x510, - .csid_rdi_irq_subsample_pattern_addr = 0x514, - .csid_rdi_irq_subsample_period_addr = 0x518, - .csid_rdi_rpp_hcrop_addr = 0x51c, - .csid_rdi_rpp_vcrop_addr = 0x520, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x524, - .csid_rdi_rpp_pix_drop_period_addr = 0x528, - .csid_rdi_rpp_line_drop_pattern_addr = 0x52c, - .csid_rdi_rpp_line_drop_period_addr = 0x530, - .csid_rdi_yuv_chroma_conversion_addr = 0x534, - .csid_rdi_rst_strobes_addr = 0x540, - .csid_rdi_status_addr = 0x550, - .csid_rdi_misr_val0_addr = 0x554, - .csid_rdi_misr_val1_addr = 0x558, - .csid_rdi_misr_val2_addr = 0x55c, - .csid_rdi_misr_val3_addr = 0x560, - .csid_rdi_format_measure_cfg0_addr = 0x570, - .csid_rdi_format_measure_cfg1_addr = 0x574, - .csid_rdi_format_measure0_addr = 0x578, - .csid_rdi_format_measure1_addr = 0x57c, - .csid_rdi_format_measure2_addr = 0x580, - .csid_rdi_timestamp_curr0_sof_addr = 0x590, - .csid_rdi_timestamp_curr1_sof_addr = 0x594, - .csid_rdi_timestamp_prev0_sof_addr = 0x598, - .csid_rdi_timestamp_prev1_sof_addr = 0x59c, - .csid_rdi_timestamp_curr0_eof_addr = 0x5a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x5a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x5a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x5ac, - .csid_rdi_byte_cntr_ping_addr = 0x5e0, - .csid_rdi_byte_cntr_pong_addr = 0x5e4, - .ccif_violation_en = 1, -}; - -static struct ais_ife_csid_csi2_rx_reg_offset - ais_ife_csid_175_200_csi2_reg_offset = { - .csid_csi2_rx_irq_status_addr = 0x20, - .csid_csi2_rx_irq_mask_addr = 0x24, - .csid_csi2_rx_irq_clear_addr = 0x28, - .csid_csi2_rx_irq_set_addr = 0x2c, - - /*CSI2 rx control */ - .csid_csi2_rx_cfg0_addr = 0x100, - .csid_csi2_rx_cfg1_addr = 0x104, - .csid_csi2_rx_capture_ctrl_addr = 0x108, - .csid_csi2_rx_rst_strobes_addr = 0x110, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_0_addr = 0x120, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_1_addr = 0x124, - .csid_csi2_rx_captured_short_pkt_0_addr = 0x128, - .csid_csi2_rx_captured_short_pkt_1_addr = 0x12c, - .csid_csi2_rx_captured_long_pkt_0_addr = 0x130, - .csid_csi2_rx_captured_long_pkt_1_addr = 0x134, - .csid_csi2_rx_captured_long_pkt_ftr_addr = 0x138, - .csid_csi2_rx_captured_cphy_pkt_hdr_addr = 0x13c, - .csid_csi2_rx_lane0_misr_addr = 0x150, - .csid_csi2_rx_lane1_misr_addr = 0x154, - .csid_csi2_rx_lane2_misr_addr = 0x158, - .csid_csi2_rx_lane3_misr_addr = 0x15c, - .csid_csi2_rx_total_pkts_rcvd_addr = 0x160, - .csid_csi2_rx_stats_ecc_addr = 0x164, - .csid_csi2_rx_total_crc_err_addr = 0x168, - .csid_csi2_rx_de_scramble_type3_cfg0_addr = 0x170, - .csid_csi2_rx_de_scramble_type3_cfg1_addr = 0x174, - .csid_csi2_rx_de_scramble_type2_cfg0_addr = 0x178, - .csid_csi2_rx_de_scramble_type2_cfg1_addr = 0x17c, - .csid_csi2_rx_de_scramble_type1_cfg0_addr = 0x180, - .csid_csi2_rx_de_scramble_type1_cfg1_addr = 0x184, - .csid_csi2_rx_de_scramble_type0_cfg0_addr = 0x188, - .csid_csi2_rx_de_scramble_type0_cfg1_addr = 0x18c, - - .csi2_rst_srb_all = 0x3FFF, - .csi2_rst_done_shift_val = 27, - .csi2_irq_mask_all = 0xFFFFFFF, - .csi2_misr_enable_shift_val = 6, - .csi2_vc_mode_shift_val = 2, - .csi2_capture_long_pkt_en_shift = 0, - .csi2_capture_short_pkt_en_shift = 1, - .csi2_capture_cphy_pkt_en_shift = 2, - .csi2_capture_long_pkt_dt_shift = 4, - .csi2_capture_long_pkt_vc_shift = 10, - .csi2_capture_short_pkt_vc_shift = 15, - .csi2_capture_cphy_pkt_dt_shift = 20, - .csi2_capture_cphy_pkt_vc_shift = 26, - .csi2_rx_phy_num_mask = 0x7, -}; - -static struct ais_ife_csid_csi2_tpg_reg_offset - ais_ife_csid_175_200_tpg_reg_offset = { - /*CSID TPG control */ - .csid_tpg_ctrl_addr = 0x600, - .csid_tpg_vc_cfg0_addr = 0x604, - .csid_tpg_vc_cfg1_addr = 0x608, - .csid_tpg_lfsr_seed_addr = 0x60c, - .csid_tpg_dt_n_cfg_0_addr = 0x610, - .csid_tpg_dt_n_cfg_1_addr = 0x614, - .csid_tpg_dt_n_cfg_2_addr = 0x618, - .csid_tpg_color_bars_cfg_addr = 0x640, - .csid_tpg_color_box_cfg_addr = 0x644, - .csid_tpg_common_gen_cfg_addr = 0x648, - .csid_tpg_cgen_n_cfg_addr = 0x650, - .csid_tpg_cgen_n_x0_addr = 0x654, - .csid_tpg_cgen_n_x1_addr = 0x658, - .csid_tpg_cgen_n_x2_addr = 0x65c, - .csid_tpg_cgen_n_xy_addr = 0x660, - .csid_tpg_cgen_n_y1_addr = 0x664, - .csid_tpg_cgen_n_y2_addr = 0x668, - - /* configurations */ - .tpg_dtn_cfg_offset = 0xc, - .tpg_cgen_cfg_offset = 0x20, - .tpg_cpas_ife_reg_offset = 0x28, -}; - -static struct ais_ife_csid_common_reg_offset - ais_ife_csid_175_200_cmn_reg_offset = { - .csid_hw_version_addr = 0x0, - .csid_cfg0_addr = 0x4, - .csid_ctrl_addr = 0x8, - .csid_reset_addr = 0xc, - .csid_rst_strobes_addr = 0x10, - - .csid_test_bus_ctrl_addr = 0x14, - .csid_top_irq_status_addr = 0x70, - .csid_top_irq_mask_addr = 0x74, - .csid_top_irq_clear_addr = 0x78, - .csid_top_irq_set_addr = 0x7c, - .csid_irq_cmd_addr = 0x80, - - /*configurations */ - .major_version = 1, - .minor_version = 7, - .version_incr = 5, - .num_rdis = 3, - .num_pix = 1, - .num_ppp = 1, - .csid_reg_rst_stb = 1, - .csid_rst_stb = 0x1e, - .csid_rst_stb_sw_all = 0x1f, - .path_rst_stb_all = 0x7f, - .path_rst_done_shift_val = 1, - .path_en_shift_val = 31, - .dt_id_shift_val = 27, - .vc_shift_val = 22, - .dt_shift_val = 16, - .fmt_shift_val = 12, - .plain_fmt_shit_val = 10, - .crop_v_en_shift_val = 6, - .crop_h_en_shift_val = 5, - .crop_shift = 16, - .ipp_irq_mask_all = 0xFFFF, - .rdi_irq_mask_all = 0xFFFF, - .ppp_irq_mask_all = 0xFFFF, - .measure_en_hbi_vbi_cnt_mask = 0xC, - .format_measure_en_val = 1, - .format_measure_height_mask_val = 0xFFFF, - .format_measure_height_shift_val = 0x10, - .format_measure_width_mask_val = 0xFFFF, - .format_measure_width_shift_val = 0x0, -}; - -static struct ais_ife_csid_reg_offset ais_ife_csid_175_200_reg_offset = { - .cmn_reg = &ais_ife_csid_175_200_cmn_reg_offset, - .csi2_reg = &ais_ife_csid_175_200_csi2_reg_offset, - .ipp_reg = &ais_ife_csid_175_200_ipp_reg_offset, - .ppp_reg = &ais_ife_csid_175_200_ppp_reg_offset, - .rdi_reg = { - &ais_ife_csid_175_200_rdi_0_reg_offset, - &ais_ife_csid_175_200_rdi_1_reg_offset, - &ais_ife_csid_175_200_rdi_2_reg_offset, - NULL, - }, - .tpg_reg = &ais_ife_csid_175_200_tpg_reg_offset, -}; - -#endif /*_AIS_IFE_CSID_175_200_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid17x.c b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid17x.c deleted file mode 100755 index e5005bef0b7b..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid17x.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - -#include -#include "ais_ife_csid_core.h" -#include "ais_ife_csid170.h" -#include "ais_ife_csid175.h" -#include "ais_ife_csid175_200.h" -#include "ais_ife_csid_dev.h" - -#define AIS_CSID_DRV_NAME "ais-csid_17x" -#define AIS_CSID_VERSION_V170 0x10070000 -#define AIS_CSID_VERSION_V175 0x10070050 - -static struct ais_ife_csid_hw_info ais_ife_csid170_hw_info = { - .csid_reg = &ais_ife_csid_170_reg_offset, - .hw_dts_version = AIS_CSID_VERSION_V170, -}; - -static struct ais_ife_csid_hw_info ais_ife_csid175_hw_info = { - .csid_reg = &ais_ife_csid_175_reg_offset, - .hw_dts_version = AIS_CSID_VERSION_V175, -}; - -static struct ais_ife_csid_hw_info ais_ife_csid175_200_hw_info = { - .csid_reg = &ais_ife_csid_175_200_reg_offset, - .hw_dts_version = AIS_CSID_VERSION_V175, -}; - -static const struct of_device_id ais_ife_csid17x_dt_match[] = { - { - .compatible = "qcom,ais-csid170", - .data = &ais_ife_csid170_hw_info, - }, - { - .compatible = "qcom,ais-csid175", - .data = &ais_ife_csid175_hw_info, - }, - { - .compatible = "qcom,ais-csid175_200", - .data = &ais_ife_csid175_200_hw_info, - }, - {} -}; - -MODULE_DEVICE_TABLE(of, ais_ife_csid17x_dt_match); - -static struct platform_driver ais_ife_csid17x_driver = { - .probe = ais_ife_csid_probe, - .remove = ais_ife_csid_remove, - .driver = { - .name = AIS_CSID_DRV_NAME, - .owner = THIS_MODULE, - .of_match_table = ais_ife_csid17x_dt_match, - .suppress_bind_attrs = true, - }, -}; - -static int __init ais_ife_csid17x_init_module(void) -{ - return platform_driver_register(&ais_ife_csid17x_driver); -} - -static void __exit ais_ife_csid17x_exit_module(void) -{ - platform_driver_unregister(&ais_ife_csid17x_driver); -} - -module_init(ais_ife_csid17x_init_module); -module_exit(ais_ife_csid17x_exit_module); -MODULE_DESCRIPTION("AIS IFE_CSID17X driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.c b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.c deleted file mode 100755 index 77b0e1905d49..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.c +++ /dev/null @@ -1,2150 +0,0 @@ -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include - -#include "cam_req_mgr_workq.h" -#include "ais_ife_csid_core.h" -#include "ais_isp_hw.h" -#include "cam_soc_util.h" -#include "cam_io_util.h" -#include "cam_debug_util.h" -#include "cam_cpas_api.h" - -/* Timeout value in msec */ -#define IFE_CSID_TIMEOUT 1000 - -/* TPG VC/DT values */ -#define AIS_IFE_CSID_TPG_VC_VAL 0xA -#define AIS_IFE_CSID_TPG_DT_VAL 0x2B - -/* Timeout values in usec */ -#define AIS_IFE_CSID_TIMEOUT_SLEEP_US 1000 -#define AIS_IFE_CSID_TIMEOUT_ALL_US 100000 - -/* - * Constant Factors needed to change QTimer ticks to nanoseconds - * QTimer Freq = 19.2 MHz - * Time(us) = ticks/19.2 - * Time(ns) = ticks/19.2 * 1000 - */ -#define AIS_IFE_CSID_QTIMER_MUL_FACTOR 10000 -#define AIS_IFE_CSID_QTIMER_DIV_FACTOR 192 - -/* Max number of sof irq's triggered in case of SOF freeze */ -#define AIS_CSID_IRQ_SOF_DEBUG_CNT_MAX 12 - -/* Max CSI Rx irq error count threshold value */ -#define AIS_IFE_CSID_MAX_IRQ_ERROR_COUNT 5 - -static int ais_ife_csid_global_reset(struct ais_ife_csid_hw *csid_hw) -{ - struct cam_hw_soc_info *soc_info; - const struct ais_ife_csid_reg_offset *csid_reg; - int rc = 0; - uint32_t val = 0, i; - uint32_t status; - - soc_info = &csid_hw->hw_info->soc_info; - csid_reg = csid_hw->csid_info->csid_reg; - - if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) { - CAM_ERR(CAM_ISP, "CSID:%d Invalid HW State:%d", - csid_hw->hw_intf->hw_idx, - csid_hw->hw_info->hw_state); - return -EINVAL; - } - - CAM_DBG(CAM_ISP, "CSID:%d Csid reset", - csid_hw->hw_intf->hw_idx); - - /* Mask all interrupts */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr); - - if (csid_reg->cmn_reg->num_pix) - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_mask_addr); - - if (csid_reg->cmn_reg->num_ppp) - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->ppp_reg->csid_pxl_irq_mask_addr); - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_mask_addr); - - /* clear all interrupts */ - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_clear_addr); - - cam_io_w_mb(csid_reg->csi2_reg->csi2_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_clear_addr); - - if (csid_reg->cmn_reg->num_pix) - cam_io_w_mb(csid_reg->cmn_reg->ipp_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_clear_addr); - - if (csid_reg->cmn_reg->num_ppp) - cam_io_w_mb(csid_reg->cmn_reg->ppp_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->ppp_reg->csid_pxl_irq_clear_addr); - - for (i = 0 ; i < csid_reg->cmn_reg->num_rdis; i++) - cam_io_w_mb(csid_reg->cmn_reg->rdi_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_clear_addr); - - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_irq_cmd_addr); - - cam_io_w_mb(0x80, soc_info->reg_map[0].mem_base + - csid_hw->csid_info->csid_reg->csi2_reg->csid_csi2_rx_cfg1_addr); - - /* enable the IPP and RDI format measure */ - if (csid_reg->cmn_reg->num_pix) - cam_io_w_mb(0x1, soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_cfg0_addr); - - if (csid_reg->cmn_reg->num_ppp) - cam_io_w_mb(0x1, soc_info->reg_map[0].mem_base + - csid_reg->ppp_reg->csid_pxl_cfg0_addr); - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) - cam_io_w_mb(0x2, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_cfg0_addr); - - /* perform the top CSID HW registers reset */ - cam_io_w_mb(csid_reg->cmn_reg->csid_rst_stb, - soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_rst_strobes_addr); - - rc = readl_poll_timeout(soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_status_addr, - status, (status & 0x1) == 0x1, - AIS_IFE_CSID_TIMEOUT_SLEEP_US, AIS_IFE_CSID_TIMEOUT_ALL_US); - if (rc < 0) { - CAM_ERR(CAM_ISP, "CSID:%d csid_reset fail rc = %d", - csid_hw->hw_intf->hw_idx, rc); - rc = -ETIMEDOUT; - } - - /* perform the SW registers reset */ - cam_io_w_mb(csid_reg->cmn_reg->csid_reg_rst_stb, - soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_rst_strobes_addr); - - rc = readl_poll_timeout(soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_status_addr, - status, (status & 0x1) == 0x1, - AIS_IFE_CSID_TIMEOUT_SLEEP_US, AIS_IFE_CSID_TIMEOUT_ALL_US); - if (rc < 0) { - CAM_ERR(CAM_ISP, "CSID:%d csid_reset fail rc = %d", - csid_hw->hw_intf->hw_idx, rc); - rc = -ETIMEDOUT; - } - - usleep_range(3000, 3010); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr); - if (val != 0) - CAM_ERR(CAM_ISP, "CSID:%d IRQ value after reset rc = %d", - csid_hw->hw_intf->hw_idx, val); - csid_hw->error_irq_count = 0; - - for (i = 0 ; i < AIS_IFE_CSID_RDI_MAX; i++) { - csid_hw->rdi_cfg[i].state = AIS_ISP_RESOURCE_STATE_AVAILABLE; - csid_hw->rdi_cfg[i].sof_cnt = 0; - csid_hw->rdi_cfg[i].prev_sof_hw_ts = 0; - csid_hw->rdi_cfg[i].prev_sof_boot_ts = 0; - csid_hw->rdi_cfg[i].measure_cfg.measure_enabled = 0; - } - - return rc; -} - -static int ais_ife_csid_path_reset(struct ais_ife_csid_hw *csid_hw, - enum ais_ife_output_path_id reset_path) -{ - int rc = 0; - struct cam_hw_soc_info *soc_info; - const struct ais_ife_csid_reg_offset *csid_reg; - uint32_t reset_strb_addr, reset_strb_val, val, id; - struct completion *complete; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) { - CAM_ERR(CAM_ISP, "CSID:%d Invalid hw state :%d", - csid_hw->hw_intf->hw_idx, - csid_hw->hw_info->hw_state); - return -EINVAL; - } - - if (reset_path >= AIS_IFE_CSID_RDI_MAX) { - CAM_DBG(CAM_ISP, "CSID:%d Invalid res id%d", - csid_hw->hw_intf->hw_idx, reset_path); - rc = -EINVAL; - goto end; - } - - CAM_DBG(CAM_ISP, "CSID:%d resource:%d", - csid_hw->hw_intf->hw_idx, reset_path); - - id = reset_path; - if (!csid_reg->rdi_reg[id]) { - CAM_ERR(CAM_ISP, "CSID:%d RDI res not supported :%d", - csid_hw->hw_intf->hw_idx, - reset_path); - return -EINVAL; - } - - reset_strb_addr = csid_reg->rdi_reg[id]->csid_rdi_rst_strobes_addr; - complete = &csid_hw->csid_rdi_complete[id]; - - /* Enable path reset done interrupt */ - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_irq_mask_addr); - val |= CSID_PATH_INFO_RST_DONE; - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_irq_mask_addr); - - reinit_completion(complete); - reset_strb_val = csid_reg->cmn_reg->path_rst_stb_all; - - /* Reset the corresponding ife csid path */ - cam_io_w_mb(reset_strb_val, soc_info->reg_map[0].mem_base + - reset_strb_addr); - - rc = wait_for_completion_timeout(complete, - msecs_to_jiffies(IFE_CSID_TIMEOUT)); - if (rc) { - rc = 0; - } else { - CAM_ERR(CAM_ISP, "CSID:%d RDI%d reset fail", - csid_hw->hw_intf->hw_idx, reset_path, rc); - rc = -ETIMEDOUT; - } - -end: - return rc; - -} - - -static int ais_ife_csid_enable_hw(struct ais_ife_csid_hw *csid_hw) -{ - int rc = 0; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - uint32_t i, val, clk_lvl; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - /* overflow check before increment */ - if (csid_hw->hw_info->open_count == UINT_MAX) { - CAM_ERR(CAM_ISP, "CSID:%d Open count reached max", - csid_hw->hw_intf->hw_idx); - return -EINVAL; - } - - /* Increment ref Count */ - csid_hw->hw_info->open_count++; - if (csid_hw->hw_info->open_count > 1) { - CAM_DBG(CAM_ISP, "CSID hw has already been enabled"); - return rc; - } - - CAM_DBG(CAM_ISP, "CSID:%d init CSID HW", - csid_hw->hw_intf->hw_idx); - - clk_lvl = cam_soc_util_get_vote_level(soc_info, csid_hw->clk_rate); - CAM_DBG(CAM_ISP, "CSID clock lvl %u", clk_lvl); - - rc = ais_ife_csid_enable_soc_resources(soc_info, CAM_TURBO_VOTE); - if (rc) { - CAM_ERR(CAM_ISP, "CSID:%d Enable SOC failed", - csid_hw->hw_intf->hw_idx); - goto err; - } - - csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_UP; - - /* Reset CSID top */ - rc = ais_ife_csid_global_reset(csid_hw); - if (rc) - goto disable_soc; - - /* clear all interrupts */ - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_clear_addr); - - cam_io_w_mb(csid_reg->csi2_reg->csi2_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_clear_addr); - - if (csid_reg->cmn_reg->num_pix) - cam_io_w_mb(csid_reg->cmn_reg->ipp_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_clear_addr); - - if (csid_reg->cmn_reg->num_ppp) - cam_io_w_mb(csid_reg->cmn_reg->ppp_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->ppp_reg->csid_pxl_irq_clear_addr); - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) - cam_io_w_mb(csid_reg->cmn_reg->rdi_irq_mask_all, - soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_clear_addr); - - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_irq_cmd_addr); - - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_hw_version_addr); - CAM_DBG(CAM_ISP, "CSID:%d CSID HW version: 0x%x", - csid_hw->hw_intf->hw_idx, val); - - return 0; - -disable_soc: - ais_ife_csid_disable_soc_resources(soc_info); - csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN; -err: - csid_hw->hw_info->open_count--; - return rc; -} - -static int ais_ife_csid_disable_hw(struct ais_ife_csid_hw *csid_hw) -{ - int rc = -EINVAL; - uint32_t i; - struct cam_hw_soc_info *soc_info; - const struct ais_ife_csid_reg_offset *csid_reg; - unsigned long flags; - - /* Check for refcount */ - if (!csid_hw->hw_info->open_count) { - CAM_WARN(CAM_ISP, "Unbalanced disable_hw"); - return rc; - } - - /* Decrement ref Count */ - csid_hw->hw_info->open_count--; - - if (csid_hw->hw_info->open_count) { - rc = 0; - return rc; - } - - soc_info = &csid_hw->hw_info->soc_info; - csid_reg = csid_hw->csid_info->csid_reg; - - CAM_DBG(CAM_ISP, "Calling Global Reset"); - ais_ife_csid_global_reset(csid_hw); - CAM_DBG(CAM_ISP, "Global Reset Done"); - - CAM_DBG(CAM_ISP, "CSID:%d De-init CSID HW", - csid_hw->hw_intf->hw_idx); - - /*disable the top IRQ interrupt */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_mask_addr); - - rc = ais_ife_csid_disable_soc_resources(soc_info); - if (rc) - CAM_ERR(CAM_ISP, "CSID:%d Disable CSID SOC failed", - csid_hw->hw_intf->hw_idx); - - spin_lock_irqsave(&csid_hw->lock_state, flags); - csid_hw->device_enabled = 0; - spin_unlock_irqrestore(&csid_hw->lock_state, flags); - for (i = 0; i < AIS_IFE_CSID_RDI_MAX; i++) { - csid_hw->rdi_cfg[i].state = AIS_ISP_RESOURCE_STATE_AVAILABLE; - csid_hw->rdi_cfg[i].sof_cnt = 0; - csid_hw->rdi_cfg[i].prev_sof_boot_ts = 0; - csid_hw->rdi_cfg[i].prev_sof_hw_ts = 0; - csid_hw->rdi_cfg[i].measure_cfg.measure_enabled = 0; - } - - csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN; - csid_hw->error_irq_count = 0; - csid_hw->fatal_err_detected = false; - - - return rc; -} - - -static int ais_ife_csid_enable_csi2( - struct ais_ife_csid_hw *csid_hw, - struct ais_ife_csid_csi_info *csi_info) -{ - int rc = 0; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - uint32_t val = 0; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - CAM_DBG(CAM_ISP, "CSID:%d count:%d config csi2 rx", - csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt); - - /* overflow check before increment */ - if (csid_hw->csi2_cfg_cnt == UINT_MAX) { - CAM_ERR(CAM_ISP, "CSID:%d Open count reached max", - csid_hw->hw_intf->hw_idx); - return -EINVAL; - } - - csid_hw->csi2_cfg_cnt++; - if (csid_hw->csi2_cfg_cnt > 1) - return rc; - - csid_hw->csi2_rx_cfg.phy_sel = csi_info->csiphy_id; - csid_hw->csi2_rx_cfg.lane_num = csi_info->num_lanes; - csid_hw->csi2_rx_cfg.lane_cfg = csi_info->lane_assign; - csid_hw->csi2_rx_cfg.lane_type = csi_info->is_3Phase; - - /* rx cfg0 */ - val = ((csid_hw->csi2_rx_cfg.lane_num - 1) & 0x3) | - ((csid_hw->csi2_rx_cfg.lane_cfg & 0xFFFF) << 4) | - ((csid_hw->csi2_rx_cfg.lane_type & 0x1) << 24); - val |= (csid_hw->csi2_rx_cfg.phy_sel & - csid_reg->csi2_reg->csi2_rx_phy_num_mask) << 20; - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_cfg0_addr); - - /* rx cfg1*/ - val = (1 << csid_reg->csi2_reg->csi2_misr_enable_shift_val); - /* if VC value is more than 3 than set full width of VC */ - if (csi_info->vc > 3) - val |= (1 << csid_reg->csi2_reg->csi2_vc_mode_shift_val); - - /* enable packet ecc correction */ - val |= 1; - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_cfg1_addr); - - /*Enable the CSI2 rx inerrupts */ - val = CSID_CSI2_RX_INFO_RST_DONE | - CSID_CSI2_RX_ERROR_TG_FIFO_OVERFLOW | - CSID_CSI2_RX_ERROR_LANE0_FIFO_OVERFLOW | - CSID_CSI2_RX_ERROR_LANE1_FIFO_OVERFLOW | - CSID_CSI2_RX_ERROR_LANE2_FIFO_OVERFLOW | - CSID_CSI2_RX_ERROR_LANE3_FIFO_OVERFLOW | - CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION | - CSID_CSI2_RX_ERROR_CPHY_SOT_RECEPTION | - CSID_CSI2_RX_ERROR_CRC | - CSID_CSI2_RX_ERROR_ECC | - CSID_CSI2_RX_ERROR_MMAPPED_VC_DT | - CSID_CSI2_RX_ERROR_STREAM_UNDERFLOW | - CSID_CSI2_RX_ERROR_UNBOUNDED_FRAME | - CSID_CSI2_RX_ERROR_CPHY_PH_CRC; - - /* Enable the interrupt based on csid debug info set */ - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOT_IRQ) - val |= CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED | - CSID_CSI2_RX_INFO_PHY_DL1_SOT_CAPTURED | - CSID_CSI2_RX_INFO_PHY_DL2_SOT_CAPTURED | - CSID_CSI2_RX_INFO_PHY_DL3_SOT_CAPTURED; - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOT_IRQ) - val |= CSID_CSI2_RX_INFO_PHY_DL0_EOT_CAPTURED | - CSID_CSI2_RX_INFO_PHY_DL1_EOT_CAPTURED | - CSID_CSI2_RX_INFO_PHY_DL2_EOT_CAPTURED | - CSID_CSI2_RX_INFO_PHY_DL3_EOT_CAPTURED; - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE) - val |= CSID_CSI2_RX_INFO_SHORT_PKT_CAPTURED; - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE) - val |= CSID_CSI2_RX_INFO_LONG_PKT_CAPTURED; - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE) - val |= CSID_CSI2_RX_INFO_CPHY_PKT_HDR_CAPTURED; - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr); - - return 0; -} - -static int ais_ife_csid_disable_csi2(struct ais_ife_csid_hw *csid_hw) -{ - int rc = 0; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - CAM_DBG(CAM_ISP, "CSID:%d cnt : %d Disable csi2 rx", - csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt); - - if (csid_hw->csi2_cfg_cnt) - csid_hw->csi2_cfg_cnt--; - - if (csid_hw->csi2_cfg_cnt) - return 0; - - /* Disable the CSI2 rx inerrupts */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr); - - /* Reset the Rx CFG registers */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_cfg0_addr); - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_cfg1_addr); - - return rc; -} - -static void ais_ife_csid_halt_csi2( - struct ais_ife_csid_hw *csid_hw) -{ - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - /* Disable the CSI2 rx inerrupts */ - cam_io_w(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr); - - /* Reset the Rx CFG registers */ - cam_io_w(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_cfg0_addr); - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_cfg1_addr); -} - -static int ais_ife_csid_config_rdi_path( - struct ais_ife_csid_hw *csid_hw, - struct ais_ife_rdi_init_args *res) -{ - int rc = 0; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - struct ais_ife_csid_path_cfg *path_cfg; - uint32_t val = 0, cfg0 = 0, id = 0, i = 0; - uint32_t format_measure_addr; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - id = res->path; - if (id >= csid_reg->cmn_reg->num_rdis || !csid_reg->rdi_reg[id]) { - CAM_ERR(CAM_ISP, "CSID:%d RDI:%d is not supported on HW", - csid_hw->hw_intf->hw_idx, id); - return -EINVAL; - } - - path_cfg = &csid_hw->rdi_cfg[id]; - path_cfg->vc = res->csi_cfg.vc; - path_cfg->dt = res->csi_cfg.dt; - path_cfg->cid = id; - path_cfg->in_format = res->in_cfg.format; - path_cfg->out_format = res->out_cfg.format; - path_cfg->crop_enable = res->in_cfg.crop_enable; - path_cfg->start_pixel = res->in_cfg.crop_left; - path_cfg->end_pixel = res->in_cfg.crop_right; - path_cfg->start_line = res->in_cfg.crop_top; - path_cfg->end_line = res->in_cfg.crop_bottom; - path_cfg->decode_fmt = res->in_cfg.decode_format; - path_cfg->plain_fmt = res->in_cfg.pack_type; - path_cfg->init_frame_drop = res->in_cfg.init_frame_drop; - - if (path_cfg->decode_fmt == 0xF) - path_cfg->pix_enable = false; - else - path_cfg->pix_enable = true; - - /* select the post irq sub sample strobe for time stamp capture */ - cam_io_w_mb(CSID_TIMESTAMP_STB_POST_IRQ, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_cfg1_addr); - - if (path_cfg->crop_enable) { - val = (((path_cfg->end_pixel & 0xFFFF) << - csid_reg->cmn_reg->crop_shift) | - (path_cfg->start_pixel & 0xFFFF)); - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_rpp_hcrop_addr); - CAM_DBG(CAM_ISP, "CSID:%d Horizontal crop config val: 0x%x", - csid_hw->hw_intf->hw_idx, val); - - val = (((path_cfg->end_line & 0xFFFF) << - csid_reg->cmn_reg->crop_shift) | - (path_cfg->start_line & 0xFFFF)); - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_rpp_vcrop_addr); - CAM_DBG(CAM_ISP, "CSID:%d Vertical Crop config val: 0x%x", - csid_hw->hw_intf->hw_idx, val); - } - - /* configure pixel format measure */ - if (csid_hw->rdi_cfg[id].measure_cfg.measure_enabled) { - val = ((csid_hw->rdi_cfg[id].measure_cfg.height & - csid_reg->cmn_reg->format_measure_height_mask_val) << - csid_reg->cmn_reg->format_measure_height_shift_val); - - if (path_cfg->decode_fmt == 0xF) - val |= (((csid_hw->rdi_cfg[id].measure_cfg.width * - path_cfg->in_bpp) / 8) & - csid_reg->cmn_reg->format_measure_width_mask_val); - else - val |= (csid_hw->rdi_cfg[id].measure_cfg.width & - csid_reg->cmn_reg->format_measure_width_mask_val); - - CAM_DBG(CAM_ISP, "CSID:%d format measure cfg1 value : 0x%x", - csid_hw->hw_intf->hw_idx, val); - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_format_measure_cfg1_addr); - - /* enable pixel and line counter */ - cam_io_w_mb(3, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_format_measure_cfg0_addr); - } - - /* set frame drop pattern to 0 and period to 1 */ - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_frm_drop_period_addr); - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_frm_drop_pattern_addr); - /* set IRQ sum sabmple */ - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_irq_subsample_period_addr); - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_irq_subsample_pattern_addr); - - /* set pixel drop pattern to 0 and period to 1 */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_rpp_pix_drop_pattern_addr); - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_rpp_pix_drop_period_addr); - /* set line drop pattern to 0 and period to 1 */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_rpp_line_drop_pattern_addr); - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_rpp_line_drop_period_addr); - - /* Configure the halt mode */ - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_ctrl_addr); - - /* Program the IPP CFG0 for full IFE in case of RPP path enabled */ - if (!csid_hw->ipp_fix_cfg && - csid_reg->cmn_reg->num_rdis == 3 && - path_cfg->pix_enable) { - for (i = 0; i < AIS_IFE_CSID_RDI_MAX; i++) { - struct ais_ife_csid_path_cfg *tmp = - &csid_hw->rdi_cfg[i]; - - /* - * doesn't compare with itself and - * not INIT/STREAMING rdi - */ - if (id == i || - tmp->state < AIS_ISP_RESOURCE_STATE_INIT_HW) - continue; - - /*checking for multiple streams of same VC*/ - if (tmp->vc == path_cfg->vc && - tmp->decode_fmt == path_cfg->decode_fmt) { - val = path_cfg->decode_fmt << - csid_reg->cmn_reg->fmt_shift_val; - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_cfg0_addr); - - csid_hw->ipp_fix_cfg = true; - break; - } - } - } - - /* RDI path config and enable*/ - cfg0 = (path_cfg->vc << csid_reg->cmn_reg->vc_shift_val) | - (path_cfg->dt << csid_reg->cmn_reg->dt_shift_val) | - (path_cfg->cid << csid_reg->cmn_reg->dt_id_shift_val) | - (path_cfg->decode_fmt << csid_reg->cmn_reg->fmt_shift_val) | - (path_cfg->plain_fmt << csid_reg->cmn_reg->plain_fmt_shit_val) | - (path_cfg->crop_enable << - csid_reg->cmn_reg->crop_h_en_shift_val) | - (path_cfg->crop_enable << - csid_reg->cmn_reg->crop_v_en_shift_val) | - (1 << csid_reg->cmn_reg->path_en_shift_val) | - (1 << 2) | 3; - - cam_io_w_mb(cfg0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr); - - format_measure_addr = - csid_reg->rdi_reg[id]->csid_rdi_format_measure_cfg0_addr; - - /* Enable the HBI/VBI counter */ - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO) { - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - format_measure_addr); - val |= csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask; - cam_io_w_mb(val, - soc_info->reg_map[0].mem_base + format_measure_addr); - } - - /* configure the rx packet capture based on csid debug set */ - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE) - val = ((1 << - csid_reg->csi2_reg->csi2_capture_short_pkt_en_shift) | - (path_cfg->vc << - csid_reg->csi2_reg->csi2_capture_short_pkt_vc_shift)); - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE) - val |= ((1 << - csid_reg->csi2_reg->csi2_capture_long_pkt_en_shift) | - (path_cfg->dt << - csid_reg->csi2_reg->csi2_capture_long_pkt_dt_shift) | - (path_cfg->vc << - csid_reg->csi2_reg->csi2_capture_long_pkt_vc_shift)); - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE) - val |= ((1 << - csid_reg->csi2_reg->csi2_capture_cphy_pkt_en_shift) | - (path_cfg->dt << - csid_reg->csi2_reg->csi2_capture_cphy_pkt_dt_shift) | - (path_cfg->vc << - csid_reg->csi2_reg->csi2_capture_cphy_pkt_vc_shift)); - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_capture_ctrl_addr); - - path_cfg->state = AIS_ISP_RESOURCE_STATE_INIT_HW; - - CAM_DBG(CAM_ISP, "CSID:%d RDI%d configured vc:%d dt:%d", id, - csid_hw->hw_intf->hw_idx, path_cfg->vc, path_cfg->dt); - - return rc; -} - -static int ais_ife_csid_deinit_rdi_path( - struct ais_ife_csid_hw *csid_hw, - enum ais_ife_output_path_id id) -{ - int rc = 0, i = 0; - uint32_t val, format_measure_addr; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - struct ais_ife_csid_path_cfg *path_cfg; - - path_cfg = &csid_hw->rdi_cfg[id]; - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - format_measure_addr = - csid_reg->rdi_reg[id]->csid_rdi_format_measure_cfg0_addr; - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_HBI_VBI_INFO) { - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr); - val &= ~csid_reg->cmn_reg->format_measure_en_val; - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_cfg0_addr); - - /* Disable the HBI/VBI counter */ - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - format_measure_addr); - val &= ~csid_reg->cmn_reg->measure_en_hbi_vbi_cnt_mask; - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - format_measure_addr); - } - - /* Reset ipp_fix_cfg if needed. Check for multiple streams of same DT*/ - if (csid_hw->ipp_fix_cfg == true) { - int check_cnt = 0; - - for (i = 0; i < AIS_IFE_CSID_RDI_MAX; i++) { - struct ais_ife_csid_path_cfg *tmp = - &csid_hw->rdi_cfg[i]; - - if (i == id || - tmp->state == AIS_ISP_RESOURCE_STATE_AVAILABLE) - continue; - - if (tmp->vc == path_cfg->vc && - tmp->decode_fmt == path_cfg->decode_fmt) - check_cnt++; - } - - if (check_cnt <= 1) - csid_hw->ipp_fix_cfg = false; - } - - path_cfg->state = AIS_ISP_RESOURCE_STATE_AVAILABLE; - - return rc; -} - -static int ais_ife_csid_enable_rdi_path( - struct ais_ife_csid_hw *csid_hw, - struct ais_ife_rdi_start_args *start_cmd) -{ - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - struct ais_ife_csid_path_cfg *path_data; - uint32_t id, val; - - id = start_cmd->path; - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - path_data = &csid_hw->rdi_cfg[id]; - path_data->sof_cnt = 0; - - /* Enable the required RDI interrupts */ - val = CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW; - - if (csid_reg->rdi_reg[id]->ccif_violation_en) - val |= CSID_PATH_ERROR_CCIF_VIOLATION; - - if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOF_IRQ) || - (path_data->init_frame_drop)) - val |= CSID_PATH_INFO_INPUT_SOF; - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOF_IRQ) - val |= CSID_PATH_INFO_INPUT_EOF; - - if (csid_hw->rdi_cfg[id].measure_cfg.measure_enabled) - val |= (CSID_PATH_ERROR_PIX_COUNT | - CSID_PATH_ERROR_LINE_COUNT); - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_irq_mask_addr); - - /*resume at frame boundary */ - if (!path_data->init_frame_drop) { - CAM_DBG(CAM_ISP, "Start RDI:%d path", id); - cam_io_w_mb(AIS_CSID_RESUME_AT_FRAME_BOUNDARY, - soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_ctrl_addr); - } - - path_data->state = AIS_ISP_RESOURCE_STATE_STREAMING; - - return 0; -} - - -static int ais_ife_csid_disable_rdi_path( - struct ais_ife_csid_hw *csid_hw, - struct ais_ife_rdi_stop_args *stop_args, - enum ais_ife_csid_halt_cmd stop_cmd) -{ - int rc = 0; - uint32_t id, val = 0; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - struct ais_ife_csid_path_cfg *path_data; - - id = stop_args->path; - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - path_data = &csid_hw->rdi_cfg[id]; - - if (path_data->state != AIS_ISP_RESOURCE_STATE_STREAMING) { - CAM_ERR_RATE_LIMIT(CAM_ISP, - "CSID:%d RDI:%d already in stopped state:%d", - csid_hw->hw_intf->hw_idx, - id, path_data->state); - return -EINVAL; - } - - if (stop_cmd != AIS_CSID_HALT_AT_FRAME_BOUNDARY && - stop_cmd != AIS_CSID_HALT_IMMEDIATELY) { - CAM_ERR(CAM_ISP, "CSID:%d un supported stop command:%d", - csid_hw->hw_intf->hw_idx, stop_cmd); - return -EINVAL; - } - - CAM_DBG(CAM_ISP, "CSID:%d RDI:%d", - csid_hw->hw_intf->hw_idx, id); - - cam_io_w_mb(0, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_irq_mask_addr); - - /* Halt the RDI path */ - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_ctrl_addr); - val &= ~0x3; - val |= stop_cmd; - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[id]->csid_rdi_ctrl_addr); - - path_data->state = AIS_ISP_RESOURCE_STATE_INIT_HW; - - return rc; -} - -static int ais_ife_csid_poll_stop_status( - struct ais_ife_csid_hw *csid_hw, - uint32_t res_mask) -{ - int rc = 0; - uint32_t csid_status_addr = 0, val = 0, res_id = 0; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - for (; res_id < AIS_IFE_CSID_RDI_MAX; res_id++, res_mask >>= 1) { - if ((res_mask & 0x1) == 0) - continue; - val = 0; - - csid_status_addr = - csid_reg->rdi_reg[res_id]->csid_rdi_status_addr; - - CAM_DBG(CAM_ISP, "start polling CSID:%d res_id:%d", - csid_hw->hw_intf->hw_idx, res_id); - - rc = readl_poll_timeout(soc_info->reg_map[0].mem_base + - csid_status_addr, val, (val & 0x1) == 0x1, - AIS_IFE_CSID_TIMEOUT_SLEEP_US, - AIS_IFE_CSID_TIMEOUT_ALL_US); - if (rc < 0) { - CAM_ERR(CAM_ISP, "CSID:%d res:%d halt failed rc %d", - csid_hw->hw_intf->hw_idx, res_id, rc); - rc = -ETIMEDOUT; - break; - } - CAM_DBG(CAM_ISP, "End polling CSID:%d res_id:%d", - csid_hw->hw_intf->hw_idx, res_id); - } - - return rc; -} - - -static int ais_ife_csid_get_time_stamp( - struct ais_ife_csid_hw *csid_hw, - void *cmd_args) -{ - struct ais_ife_rdi_get_timestamp_args *p_timestamp; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - const struct ais_ife_csid_rdi_reg_offset *rdi_reg; - uint32_t time_32_lsb, time_32_msb, id; - uint64_t time_64; - - p_timestamp = (struct ais_ife_rdi_get_timestamp_args *)cmd_args; - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - id = p_timestamp->path; - - if (id >= AIS_IFE_CSID_RDI_MAX || !csid_reg->rdi_reg[id]) { - CAM_DBG(CAM_ISP, "CSID:%d Invalid RDI%d", - csid_hw->hw_intf->hw_idx, id); - return -EINVAL; - } - - if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) { - CAM_ERR(CAM_ISP, "CSID:%d Invalid dev state :%d", - csid_hw->hw_intf->hw_idx, - csid_hw->hw_info->hw_state); - return -EINVAL; - } - - rdi_reg = csid_reg->rdi_reg[id]; - time_32_lsb = cam_io_r_mb(soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_timestamp_curr0_sof_addr); - time_32_msb = cam_io_r_mb(soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_timestamp_curr1_sof_addr); - time_64 = ((uint64_t)time_32_msb << 32) | (uint64_t)time_32_lsb; - p_timestamp->ts->cur_sof_ts = mul_u64_u32_div(time_64, - AIS_IFE_CSID_QTIMER_MUL_FACTOR, - AIS_IFE_CSID_QTIMER_DIV_FACTOR); - - time_32_lsb = cam_io_r_mb(soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_timestamp_prev0_sof_addr); - time_32_msb = cam_io_r_mb(soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_timestamp_prev1_sof_addr); - time_64 = ((uint64_t)time_32_msb << 32) | (uint64_t)time_32_lsb; - p_timestamp->ts->prev_sof_ts = mul_u64_u32_div(time_64, - AIS_IFE_CSID_QTIMER_MUL_FACTOR, - AIS_IFE_CSID_QTIMER_DIV_FACTOR); - - csid_hw->rdi_cfg[id].prev_sof_hw_ts = p_timestamp->ts->cur_sof_ts; - - return 0; -} - -static int ais_ife_csid_set_csid_debug(struct ais_ife_csid_hw *csid_hw, - void *cmd_args) -{ - uint32_t *csid_debug; - - csid_debug = (uint32_t *) cmd_args; - csid_hw->csid_debug = *csid_debug; - CAM_DBG(CAM_ISP, "CSID:%d set csid debug value:%d", - csid_hw->hw_intf->hw_idx, csid_hw->csid_debug); - - return 0; -} - -static int ais_ife_csid_get_hw_caps(void *hw_priv, - void *get_hw_cap_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw_caps *hw_caps; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - const struct ais_ife_csid_reg_offset *csid_reg; - - if (!hw_priv || !get_hw_cap_args) { - CAM_ERR(CAM_ISP, "CSID: Invalid args"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - csid_reg = csid_hw->csid_info->csid_reg; - hw_caps = (struct ais_ife_csid_hw_caps *) get_hw_cap_args; - - hw_caps->num_rdis = csid_reg->cmn_reg->num_rdis; - hw_caps->num_pix = csid_reg->cmn_reg->num_pix; - hw_caps->num_ppp = csid_reg->cmn_reg->num_ppp; - hw_caps->major_version = csid_reg->cmn_reg->major_version; - hw_caps->minor_version = csid_reg->cmn_reg->minor_version; - hw_caps->version_incr = csid_reg->cmn_reg->version_incr; - - CAM_DBG(CAM_ISP, - "CSID:%d No rdis:%d, no pix:%d, major:%d minor:%d ver :%d", - csid_hw->hw_intf->hw_idx, hw_caps->num_rdis, - hw_caps->num_pix, hw_caps->major_version, - hw_caps->minor_version, hw_caps->version_incr); - - return rc; -} - -static int ais_ife_csid_force_reset(void *hw_priv, - void *reset_args, uint32_t arg_size) -{ - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - int rc = 0; - - if (!hw_priv) { - CAM_ERR(CAM_ISP, "CSID:Invalid args"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - - mutex_lock(&csid_hw->hw_info->hw_mutex); - - /* Disable CSID HW if necessary */ - if (csid_hw_info->open_count) { - csid_hw_info->open_count = 1; - - CAM_DBG(CAM_ISP, "Disabling CSID Hw"); - rc = ais_ife_csid_disable_hw(csid_hw); - } - - mutex_unlock(&csid_hw->hw_info->hw_mutex); - - CAM_INFO(CAM_ISP, "Exit (%d)", rc); - - return rc; -} - -static int ais_ife_csid_reset_retain_sw_reg( - struct ais_ife_csid_hw *csid_hw) -{ - int rc = 0; - uint32_t status; - const struct ais_ife_csid_reg_offset *csid_reg = - csid_hw->csid_info->csid_reg; - struct cam_hw_soc_info *soc_info; - - soc_info = &csid_hw->hw_info->soc_info; - /* clear the top interrupt first */ - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_clear_addr); - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_irq_cmd_addr); - - usleep_range(3000, 3010); - - cam_io_w_mb(csid_reg->cmn_reg->csid_rst_stb, - soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_rst_strobes_addr); - rc = readl_poll_timeout(soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_status_addr, - status, (status & 0x1) == 0x1, - AIS_IFE_CSID_TIMEOUT_SLEEP_US, AIS_IFE_CSID_TIMEOUT_ALL_US); - if (rc < 0) { - CAM_ERR(CAM_ISP, "CSID:%d csid_reset fail rc = %d", - csid_hw->hw_intf->hw_idx, rc); - rc = -ETIMEDOUT; - } else { - CAM_DBG(CAM_ISP, "CSID:%d hw reset completed %d", - csid_hw->hw_intf->hw_idx, rc); - rc = 0; - } - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_clear_addr); - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_irq_cmd_addr); - - return rc; -} - - -static int ais_ife_csid_reserve(void *hw_priv, - void *reserve_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - struct ais_ife_rdi_init_args *rdi_cfg; - const struct ais_ife_csid_reg_offset *csid_reg; - unsigned long flags; - - if (!hw_priv || !reserve_args || - (arg_size != sizeof(struct ais_ife_rdi_init_args))) { - CAM_ERR(CAM_ISP, "CSID: Invalid args"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - rdi_cfg = (struct ais_ife_rdi_init_args *)reserve_args; - csid_reg = csid_hw->csid_info->csid_reg; - - mutex_lock(&csid_hw->hw_info->hw_mutex); - if (rdi_cfg->path >= AIS_IFE_CSID_RDI_MAX) { - CAM_ERR(CAM_ISP, "CSID:%d Invalid RDI%d", - csid_hw->hw_intf->hw_idx, rdi_cfg->path); - rc = -EINVAL; - goto end; - } - - if (csid_hw->rdi_cfg[rdi_cfg->path].state != - AIS_ISP_RESOURCE_STATE_AVAILABLE) { - CAM_ERR(CAM_ISP, - "CSID:%d RDI%d Invalid state %d", - csid_hw->hw_intf->hw_idx, - rdi_cfg->path, csid_hw->rdi_cfg[rdi_cfg->path].state); - rc = -EINVAL; - goto end; - } - - CAM_DBG(CAM_ISP, "CSID:%d res path :%d", - csid_hw->hw_intf->hw_idx, rdi_cfg->path); - - rc = ais_ife_csid_enable_csi2(csid_hw, &rdi_cfg->csi_cfg); - if (rc) - goto end; - - if (csid_hw->device_enabled == 0) { - rc = ais_ife_csid_reset_retain_sw_reg(csid_hw); - if (rc < 0) { - CAM_ERR(CAM_ISP, "CSID: Failed in SW reset"); - goto disable_csi2; - } else { - CAM_DBG(CAM_ISP, "CSID: SW reset Successful"); - spin_lock_irqsave(&csid_hw->lock_state, flags); - csid_hw->device_enabled = 1; - spin_unlock_irqrestore(&csid_hw->lock_state, flags); - } - } - - rc = ais_ife_csid_config_rdi_path(csid_hw, rdi_cfg); - if (rc) - goto disable_csi2; - -disable_csi2: - if (rc) - ais_ife_csid_disable_csi2(csid_hw); -end: - mutex_unlock(&csid_hw->hw_info->hw_mutex); - - return rc; -} - -static int ais_ife_csid_release(void *hw_priv, - void *release_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - struct ais_ife_rdi_deinit_args *rdi_deinit; - - if (!hw_priv || !release_args || - (arg_size != sizeof(struct ais_ife_rdi_deinit_args))) { - CAM_ERR(CAM_ISP, "CSID:Invalid arguments"); - return -EINVAL; - } - - CAM_DBG(CAM_ISP, "Enter"); - rdi_deinit = (struct ais_ife_rdi_deinit_args *)release_args; - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - - mutex_lock(&csid_hw->hw_info->hw_mutex); - if (rdi_deinit->path >= AIS_IFE_CSID_RDI_MAX) { - CAM_ERR(CAM_ISP, "CSID:%d Invalid path:%d", - csid_hw->hw_intf->hw_idx, rdi_deinit->path); - rc = -EINVAL; - goto end; - } - - if (csid_hw->rdi_cfg[rdi_deinit->path].state < - AIS_ISP_RESOURCE_STATE_INIT_HW) { - CAM_ERR(CAM_ISP, - "CSID:%d path:%d Invalid state %d", - csid_hw->hw_intf->hw_idx, - rdi_deinit->path, - csid_hw->rdi_cfg[rdi_deinit->path].state); - rc = -EINVAL; - goto end; - } - - CAM_DBG(CAM_ISP, "De-Init RDI Path: %d", rdi_deinit->path); - rc = ais_ife_csid_deinit_rdi_path(csid_hw, rdi_deinit->path); - - CAM_DBG(CAM_ISP, "De-Init ife_csid"); - rc |= ais_ife_csid_disable_csi2(csid_hw); - - CAM_DBG(CAM_ISP, "Exit"); - -end: - mutex_unlock(&csid_hw->hw_info->hw_mutex); - - return rc; -} - -static int ais_ife_csid_init_hw(void *hw_priv, - void *init_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - - if (!hw_priv || !init_args || - (arg_size != sizeof(struct ais_ife_rdi_init_args))) { - CAM_ERR(CAM_ISP, "CSID: Invalid args"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - - mutex_lock(&csid_hw->hw_info->hw_mutex); - - /* Initialize the csid hardware */ - rc = ais_ife_csid_enable_hw(csid_hw); - - mutex_unlock(&csid_hw->hw_info->hw_mutex); - - CAM_DBG(CAM_ISP, "Exit (%d)", rc); - - return rc; -} - -static int ais_ife_csid_deinit_hw(void *hw_priv, - void *deinit_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - struct ais_ife_rdi_deinit_args *deinit; - - if (!hw_priv || !deinit_args || - (arg_size != sizeof(struct ais_ife_rdi_deinit_args))) { - CAM_ERR(CAM_ISP, "CSID:Invalid arguments"); - return -EINVAL; - } - - CAM_DBG(CAM_ISP, "Enter"); - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - deinit = (struct ais_ife_rdi_deinit_args *)deinit_args; - - mutex_lock(&csid_hw->hw_info->hw_mutex); - - ais_ife_csid_path_reset(csid_hw, deinit->path); - - /* Disable CSID HW */ - CAM_DBG(CAM_ISP, "Disabling CSID Hw"); - rc = ais_ife_csid_disable_hw(csid_hw); - - mutex_unlock(&csid_hw->hw_info->hw_mutex); - - CAM_DBG(CAM_ISP, "Exit"); - - return rc; -} - -static int ais_ife_csid_start(void *hw_priv, void *start_args, - uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - const struct ais_ife_csid_reg_offset *csid_reg; - struct ais_ife_rdi_start_args *start_cmd; - - if (!hw_priv || !start_args || - (arg_size != sizeof(struct ais_ife_rdi_start_args))) { - CAM_ERR(CAM_ISP, "CSID: Invalid args"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - csid_reg = csid_hw->csid_info->csid_reg; - start_cmd = (struct ais_ife_rdi_start_args *)start_args; - - if (start_cmd->path >= csid_reg->cmn_reg->num_rdis || - !csid_reg->rdi_reg[start_cmd->path]) { - CAM_ERR(CAM_ISP, "CSID:%d RDI:%d is not supported on HW", - csid_hw->hw_intf->hw_idx, start_cmd->path); - rc = -EINVAL; - goto end; - } - - /* Reset sof irq debug fields */ - csid_hw->sof_irq_triggered = false; - csid_hw->irq_debug_cnt = 0; - - CAM_DBG(CAM_ISP, "CSID:%d res_id:%d", - csid_hw->hw_intf->hw_idx, start_cmd->path); - - rc = ais_ife_csid_enable_rdi_path(csid_hw, start_cmd); -end: - return rc; -} - -static int ais_ife_csid_stop(void *hw_priv, - void *stop_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - const struct ais_ife_csid_reg_offset *csid_reg; - struct ais_ife_rdi_stop_args *stop_cmd; - uint32_t res_mask = 0; - - if (!hw_priv || !stop_args || - (arg_size != sizeof(struct ais_ife_rdi_stop_args))) { - CAM_ERR(CAM_ISP, "CSID: Invalid args"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - csid_reg = csid_hw->csid_info->csid_reg; - stop_cmd = (struct ais_ife_rdi_stop_args *) stop_args; - - if (stop_cmd->path >= csid_reg->cmn_reg->num_rdis || - !csid_reg->rdi_reg[stop_cmd->path]) { - CAM_ERR(CAM_ISP, "CSID:%d RDI:%d is not supported on HW", - csid_hw->hw_intf->hw_idx, stop_cmd->path); - rc = -EINVAL; - goto end; - } - - CAM_DBG(CAM_ISP, "CSID:%d RDI %d", - csid_hw->hw_intf->hw_idx, - stop_cmd->path); - - /* Stop the resource first */ - rc = ais_ife_csid_disable_rdi_path(csid_hw, stop_cmd, - AIS_CSID_HALT_IMMEDIATELY); - - if (res_mask) - rc = ais_ife_csid_poll_stop_status(csid_hw, res_mask); - -end: - CAM_DBG(CAM_ISP, "Exit (%d)", rc); - - return rc; - -} - -static int ais_ife_csid_read(void *hw_priv, - void *read_args, uint32_t arg_size) -{ - CAM_ERR(CAM_ISP, "CSID: un supported"); - - return -EINVAL; -} - -static int ais_ife_csid_write(void *hw_priv, - void *write_args, uint32_t arg_size) -{ - CAM_ERR(CAM_ISP, "CSID: un supported"); - return -EINVAL; -} - -static int ais_ife_csid_sof_irq_debug( - struct ais_ife_csid_hw *csid_hw, void *cmd_args) -{ - int i = 0; - uint32_t val = 0; - bool sof_irq_enable = false; - const struct ais_ife_csid_reg_offset *csid_reg; - struct cam_hw_soc_info *soc_info; - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - - if (*((uint32_t *)cmd_args) == 1) - sof_irq_enable = true; - - if (csid_hw->hw_info->hw_state == - CAM_HW_STATE_POWER_DOWN) { - CAM_WARN(CAM_ISP, - "CSID powered down unable to %s sof irq", - (sof_irq_enable == true) ? "enable" : "disable"); - return 0; - } - - if (csid_reg->ipp_reg) { - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_mask_addr); - - if (val) { - if (sof_irq_enable) - val |= CSID_PATH_INFO_INPUT_SOF; - else - val &= ~CSID_PATH_INFO_INPUT_SOF; - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_mask_addr); - val = 0; - } - } - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) { - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_mask_addr); - if (val) { - if (sof_irq_enable) - val |= CSID_PATH_INFO_INPUT_SOF; - else - val &= ~CSID_PATH_INFO_INPUT_SOF; - - cam_io_w_mb(val, soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_mask_addr); - val = 0; - } - } - - if (sof_irq_enable) { - csid_hw->csid_debug |= CSID_DEBUG_ENABLE_SOF_IRQ; - csid_hw->sof_irq_triggered = true; - } else { - csid_hw->csid_debug &= ~CSID_DEBUG_ENABLE_SOF_IRQ; - csid_hw->sof_irq_triggered = false; - } - - CAM_INFO(CAM_ISP, "SOF freeze: CSID SOF irq %s", - (sof_irq_enable == true) ? "enabled" : "disabled"); - - return 0; -} - -static int ais_ife_csid_set_csid_clock( - struct ais_ife_csid_hw *csid_hw, void *cmd_args) -{ - struct ais_ife_csid_clock_update_args *clk_update = NULL; - - if (!csid_hw) - return -EINVAL; - - clk_update = - (struct ais_ife_csid_clock_update_args *)cmd_args; - - csid_hw->clk_rate = clk_update->clk_rate; - CAM_INFO(CAM_ISP, "CSID clock rate %llu", csid_hw->clk_rate); - - return 0; -} - -static int ais_ife_csid_dump_hw( - struct ais_ife_csid_hw *csid_hw, void *cmd_args) -{ - struct cam_hw_soc_info *soc_info; - struct ais_isp_hw_dump_args *dump_args = - (struct ais_isp_hw_dump_args *)cmd_args; - int i; - uint32_t *addr, *start; - uint32_t num_reg; - struct ais_isp_hw_dump_header *hdr; - uint8_t *dst; - - if (!dump_args->cpu_addr || !dump_args->buf_len) { - CAM_ERR(CAM_ISP, - "lnvalid len %zu ", dump_args->buf_len); - return -EINVAL; - } - soc_info = &csid_hw->hw_info->soc_info; - /*100 bytes we store the meta info of the dump data*/ - if ((dump_args->buf_len - dump_args->offset) < - soc_info->reg_map[0].size + 100) { - CAM_ERR(CAM_ISP, "Dump buffer exhaust"); - return 0; - } - dst = (char *)dump_args->cpu_addr + dump_args->offset; - hdr = (struct ais_isp_hw_dump_header *)dst; - snprintf(hdr->tag, AIS_ISP_HW_DUMP_TAG_MAX_LEN, - "CSID_REG:"); - addr = (uint32_t *)(dst + sizeof(struct ais_isp_hw_dump_header)); - - start = addr; - num_reg = soc_info->reg_map[0].size/4; - hdr->word_size = sizeof(uint32_t); - *addr = soc_info->index; - addr++; - for (i = 0; i < num_reg; i++) { - addr[0] = soc_info->mem_block[0]->start + (i*4); - addr[1] = cam_io_r(soc_info->reg_map[0].mem_base - + (i*4)); - addr += 2; - } - hdr->size = hdr->word_size * (addr - start); - dump_args->offset += hdr->size + - sizeof(struct ais_isp_hw_dump_header); - CAM_DBG(CAM_ISP, "offset %d", dump_args->offset); - return 0; -} - -static int ais_ife_csid_process_cmd(void *hw_priv, - uint32_t cmd_type, void *cmd_args, uint32_t arg_size) -{ - int rc = 0; - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_info *csid_hw_info; - - if (!hw_priv || !cmd_args) { - CAM_ERR(CAM_ISP, "CSID: Invalid arguments"); - return -EINVAL; - } - - csid_hw_info = (struct cam_hw_info *)hw_priv; - csid_hw = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - - switch (cmd_type) { - case AIS_IFE_CSID_CMD_GET_TIME_STAMP: - rc = ais_ife_csid_get_time_stamp(csid_hw, cmd_args); - break; - case AIS_IFE_CSID_SET_CSID_DEBUG: - rc = ais_ife_csid_set_csid_debug(csid_hw, cmd_args); - break; - case AIS_IFE_CSID_SOF_IRQ_DEBUG: - rc = ais_ife_csid_sof_irq_debug(csid_hw, cmd_args); - break; - case AIS_ISP_HW_CMD_CSID_CLOCK_UPDATE: - rc = ais_ife_csid_set_csid_clock(csid_hw, cmd_args); - break; - case AIS_ISP_HW_CMD_DUMP_HW: - rc = ais_ife_csid_dump_hw(csid_hw, cmd_args); - break; - default: - CAM_ERR(CAM_ISP, "CSID:%d unsupported cmd:%d", - csid_hw->hw_intf->hw_idx, cmd_type); - rc = -EINVAL; - break; - } - - return rc; -} - -static int ais_csid_event_dispatch_process(void *priv, void *data) -{ - struct ais_ife_event_data evt_payload; - struct ais_ife_csid_hw *csid_hw; - struct ais_csid_hw_work_data *work_data; - int rc = 0; - - csid_hw = (struct ais_ife_csid_hw *)priv; - if (!csid_hw) { - CAM_ERR(CAM_ISP, "Invalid parameters"); - return -EINVAL; - } - if (!csid_hw->event_cb) { - CAM_ERR(CAM_ISP, "CSID%d Error Cb not registered", - csid_hw->hw_intf->hw_idx); - return -EINVAL; - } - work_data = (struct ais_csid_hw_work_data *)data; - - CAM_ERR_RATE_LIMIT(CAM_ISP, "CSID%d [%d %d] TOP:0x%x RX:0x%x", - csid_hw->hw_intf->hw_idx, - work_data->evt_type, - csid_hw->csi2_rx_cfg.phy_sel, - work_data->irq_status[CSID_IRQ_STATUS_TOP], - work_data->irq_status[CSID_IRQ_STATUS_RX]); - - CAM_ERR_RATE_LIMIT(CAM_ISP, " RDIs 0x%x 0x%x 0x%x 0x%x", - work_data->irq_status[CSID_IRQ_STATUS_RDI0], - work_data->irq_status[CSID_IRQ_STATUS_RDI1], - work_data->irq_status[CSID_IRQ_STATUS_RDI2], - work_data->irq_status[CSID_IRQ_STATUS_RDI3]); - - evt_payload.idx = csid_hw->hw_intf->hw_idx; - evt_payload.boot_ts = work_data->timestamp; - evt_payload.path = 0xF; - - switch (work_data->evt_type) { - case AIS_IFE_MSG_CSID_ERROR: - if (csid_hw->fatal_err_detected) - break; - csid_hw->fatal_err_detected = true; - - evt_payload.type = AIS_IFE_MSG_CSID_ERROR; - - rc = csid_hw->event_cb(csid_hw->event_cb_priv, &evt_payload); - break; - - case AIS_IFE_MSG_CSID_WARNING: - break; - default: - CAM_DBG(CAM_ISP, "CSID[%d] invalid error type %d", - csid_hw->hw_intf->hw_idx, - work_data->evt_type); - break; - } - return rc; -} - -static int ais_csid_dispatch_irq(struct ais_ife_csid_hw *csid_hw, - int evt_type, uint32_t *irq_status, uint64_t timestamp) -{ - struct crm_workq_task *task; - struct ais_csid_hw_work_data *work_data; - int rc = 0; - int i; - - CAM_DBG(CAM_ISP, "CSID[%d] error %d", - csid_hw->hw_intf->hw_idx, evt_type); - - task = cam_req_mgr_workq_get_task(csid_hw->work); - if (!task) { - CAM_ERR(CAM_ISP, "Can not get task for worker"); - return -ENOMEM; - } - work_data = (struct ais_csid_hw_work_data *)task->payload; - work_data->evt_type = evt_type; - work_data->timestamp = timestamp; - for (i = 0; i < CSID_IRQ_STATUS_MAX; i++) - work_data->irq_status[i] = irq_status[i]; - - task->process_cb = ais_csid_event_dispatch_process; - rc = cam_req_mgr_workq_enqueue_task(task, csid_hw, - CRM_TASK_PRIORITY_0); - - return rc; -} - -static irqreturn_t ais_ife_csid_irq(int irq_num, void *data) -{ - struct ais_ife_csid_hw *csid_hw; - struct cam_hw_soc_info *soc_info; - const struct ais_ife_csid_reg_offset *csid_reg; - const struct ais_ife_csid_csi2_rx_reg_offset *csi2_reg; - struct ais_ife_csid_path_cfg *path_data; - const struct ais_ife_csid_rdi_reg_offset *rdi_reg; - uint32_t i; - uint32_t val, val2; - uint32_t warn_cnt = 0; - bool fatal_err_detected = false; - uint32_t sof_irq_debug_en = 0; - unsigned long flags; - uint32_t irq_status[CSID_IRQ_STATUS_MAX] = {}; - struct timespec ts; - - if (!data) { - CAM_ERR(CAM_ISP, "CSID: Invalid arguments"); - return IRQ_HANDLED; - } - - get_monotonic_boottime64(&ts); - - csid_hw = (struct ais_ife_csid_hw *)data; - CAM_DBG(CAM_ISP, "CSID %d IRQ Handling", csid_hw->hw_intf->hw_idx); - - csid_reg = csid_hw->csid_info->csid_reg; - soc_info = &csid_hw->hw_info->soc_info; - csi2_reg = csid_reg->csi2_reg; - - /* read */ - irq_status[CSID_IRQ_STATUS_TOP] = - cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_top_irq_status_addr); - - irq_status[CSID_IRQ_STATUS_RX] = - cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_status_addr); - - if (csid_reg->cmn_reg->num_pix) - irq_status[CSID_IRQ_STATUS_IPP] = - cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_status_addr); - - if (csid_reg->cmn_reg->num_ppp) - irq_status[CSID_IRQ_STATUS_PPP] = - cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->ppp_reg->csid_pxl_irq_status_addr); - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) - irq_status[CSID_IRQ_STATUS_RDI0 + i] = - cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_status_addr); - - /* clear */ - cam_io_w_mb(irq_status[CSID_IRQ_STATUS_RX], - soc_info->reg_map[0].mem_base + - csid_reg->csi2_reg->csid_csi2_rx_irq_clear_addr); - if (csid_reg->cmn_reg->num_pix) - cam_io_w_mb(irq_status[CSID_IRQ_STATUS_IPP], - soc_info->reg_map[0].mem_base + - csid_reg->ipp_reg->csid_pxl_irq_clear_addr); - - if (csid_reg->cmn_reg->num_ppp) - cam_io_w_mb(irq_status[CSID_IRQ_STATUS_PPP], - soc_info->reg_map[0].mem_base + - csid_reg->ppp_reg->csid_pxl_irq_clear_addr); - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) { - cam_io_w_mb(irq_status[CSID_IRQ_STATUS_RDI0 + i], - soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_irq_clear_addr); - } - cam_io_w_mb(1, soc_info->reg_map[0].mem_base + - csid_reg->cmn_reg->csid_irq_cmd_addr); - - if (irq_status[CSID_IRQ_STATUS_RX] & - BIT(csid_reg->csi2_reg->csi2_rst_done_shift_val)) { - CAM_DBG(CAM_ISP, "csi rx reset complete"); - complete(&csid_hw->csid_csi2_complete); - } - - spin_lock_irqsave(&csid_hw->lock_state, flags); - if (csid_hw->device_enabled == 1) { - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_LANE0_FIFO_OVERFLOW) { - fatal_err_detected = true; - goto handle_fatal_error; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_LANE1_FIFO_OVERFLOW) { - fatal_err_detected = true; - goto handle_fatal_error; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_LANE2_FIFO_OVERFLOW) { - fatal_err_detected = true; - goto handle_fatal_error; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_LANE3_FIFO_OVERFLOW) { - fatal_err_detected = true; - goto handle_fatal_error; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_TG_FIFO_OVERFLOW) { - fatal_err_detected = true; - goto handle_fatal_error; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION) { - warn_cnt++; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_CPHY_SOT_RECEPTION) { - warn_cnt++; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_STREAM_UNDERFLOW) { - warn_cnt++; - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_ERROR_UNBOUNDED_FRAME) { - warn_cnt++; - } - } - - csid_hw->error_irq_count += warn_cnt; - - if (csid_hw->error_irq_count > - AIS_IFE_CSID_MAX_IRQ_ERROR_COUNT) { - fatal_err_detected = true; - csid_hw->error_irq_count = 0; - } else if (warn_cnt) { - uint64_t timestamp; - - timestamp = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); - ais_csid_dispatch_irq(csid_hw, - AIS_IFE_MSG_CSID_WARNING, - irq_status, timestamp); - } - -handle_fatal_error: - spin_unlock_irqrestore(&csid_hw->lock_state, flags); - if (fatal_err_detected) { - uint64_t timestamp; - - timestamp = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); - CAM_INFO(CAM_ISP, - "CSID: %d cnt: %d Halt csi2 rx irq_status_rx:0x%x", - csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt, - irq_status[CSID_IRQ_STATUS_RX]); - ais_ife_csid_halt_csi2(csid_hw); - ais_csid_dispatch_irq(csid_hw, - AIS_IFE_MSG_CSID_ERROR, - irq_status, timestamp); - } - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOT_IRQ) { - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL0_EOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL0_EOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL1_EOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL1_EOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL2_EOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL2_EOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL3_EOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL3_EOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - } - - if (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOT_IRQ) { - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL0_SOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL1_SOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL1_SOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL2_SOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL2_SOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - if (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_PHY_DL3_SOT_CAPTURED) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d PHY_DL3_SOT_CAPTURED", - csid_hw->hw_intf->hw_idx); - } - } - - if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE) && - (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_LONG_PKT_CAPTURED)) { - CAM_INFO_RATE_LIMIT(CAM_ISP, "CSID:%d LONG_PKT_CAPTURED", - csid_hw->hw_intf->hw_idx); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csi2_reg->csid_csi2_rx_captured_long_pkt_0_addr); - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d long packet VC :%d DT:%d WC:%d", - csid_hw->hw_intf->hw_idx, - (val >> 22), ((val >> 16) & 0x3F), (val & 0xFFFF)); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csi2_reg->csid_csi2_rx_captured_long_pkt_1_addr); - CAM_INFO_RATE_LIMIT(CAM_ISP, "CSID:%d long packet ECC :%d", - csid_hw->hw_intf->hw_idx, val); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csi2_reg->csid_csi2_rx_captured_long_pkt_ftr_addr); - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d long pkt cal CRC:%d expected CRC:%d", - csid_hw->hw_intf->hw_idx, (val >> 16), (val & 0xFFFF)); - } - if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE) && - (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_SHORT_PKT_CAPTURED)) { - CAM_INFO_RATE_LIMIT(CAM_ISP, "CSID:%d SHORT_PKT_CAPTURED", - csid_hw->hw_intf->hw_idx); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csi2_reg->csid_csi2_rx_captured_short_pkt_0_addr); - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d short pkt VC :%d DT:%d LC:%d", - csid_hw->hw_intf->hw_idx, - (val >> 22), ((val >> 16) & 0x1F), (val & 0xFFFF)); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csi2_reg->csid_csi2_rx_captured_short_pkt_1_addr); - CAM_INFO_RATE_LIMIT(CAM_ISP, "CSID:%d short packet ECC :%d", - csid_hw->hw_intf->hw_idx, val); - } - - if ((csid_hw->csid_debug & CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE) && - (irq_status[CSID_IRQ_STATUS_RX] & - CSID_CSI2_RX_INFO_CPHY_PKT_HDR_CAPTURED)) { - CAM_INFO_RATE_LIMIT(CAM_ISP, "CSID:%d CPHY_PKT_HDR_CAPTURED", - csid_hw->hw_intf->hw_idx); - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csi2_reg->csid_csi2_rx_captured_cphy_pkt_hdr_addr); - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID:%d cphy packet VC :%d DT:%d WC:%d", - csid_hw->hw_intf->hw_idx, - (val >> 22), ((val >> 16) & 0x1F), (val & 0xFFFF)); - } - - for (i = 0; i < csid_reg->cmn_reg->num_rdis; i++) { - path_data = (struct ais_ife_csid_path_cfg *) - &csid_hw->rdi_cfg[i]; - rdi_reg = csid_reg->rdi_reg[i]; - if (irq_status[CSID_IRQ_STATUS_RDI0 + i] & - BIT(csid_reg->cmn_reg->path_rst_done_shift_val)) { - complete(&csid_hw->csid_rdi_complete[i]); - } - - if ((irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_INFO_INPUT_SOF) && - (csid_hw->csid_debug & CSID_DEBUG_ENABLE_SOF_IRQ)) { - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID RDI:%d SOF received", i); - if (csid_hw->sof_irq_triggered) - csid_hw->irq_debug_cnt++; - } - - if ((irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_INFO_INPUT_SOF) && - (path_data->init_frame_drop) && - (path_data->state == - AIS_ISP_RESOURCE_STATE_STREAMING)) { - path_data->sof_cnt++; - CAM_DBG(CAM_ISP, - "CSID:%d RDI:%d SOF cnt:%d init_frame_drop:%d", - csid_hw->hw_intf->hw_idx, i, - path_data->sof_cnt, - path_data->init_frame_drop); - if (path_data->sof_cnt == - path_data->init_frame_drop) { - cam_io_w_mb(AIS_CSID_RESUME_AT_FRAME_BOUNDARY, - soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_ctrl_addr); - - path_data->init_frame_drop = 0; - - if (!(csid_hw->csid_debug & - CSID_DEBUG_ENABLE_SOF_IRQ)) { - val = cam_io_r_mb( - soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_irq_mask_addr); - val &= ~(CSID_PATH_INFO_INPUT_SOF); - cam_io_w_mb(val, - soc_info->reg_map[0].mem_base + - rdi_reg->csid_rdi_irq_mask_addr); - } - } - } - - if ((irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_INFO_INPUT_EOF) && - (csid_hw->csid_debug & CSID_DEBUG_ENABLE_EOF_IRQ)) - CAM_INFO_RATE_LIMIT(CAM_ISP, - "CSID RDI:%d EOF received", i); - - if ((irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_ERROR_CCIF_VIOLATION) || - (irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_ERROR_FIFO_OVERFLOW)) { - CAM_ERR_RATE_LIMIT(CAM_ISP, - "CSID:%d irq_status_rdi[%d]:0x%x", - csid_hw->hw_intf->hw_idx, i, - irq_status[CSID_IRQ_STATUS_RDI0 + i]); - } - if (irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_ERROR_FIFO_OVERFLOW) { - /* Stop RDI path immediately */ - cam_io_w_mb(AIS_CSID_HALT_IMMEDIATELY, - soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_ctrl_addr); - } - - if ((irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_ERROR_PIX_COUNT) || - (irq_status[CSID_IRQ_STATUS_RDI0 + i] & - CSID_PATH_ERROR_LINE_COUNT)) { - val = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_format_measure0_addr); - val2 = cam_io_r_mb(soc_info->reg_map[0].mem_base + - csid_reg->rdi_reg[i]->csid_rdi_format_measure_cfg1_addr - ); - CAM_ERR(CAM_ISP, - "CSID:%d irq_status_rdi[%d]:0x%x", - csid_hw->hw_intf->hw_idx, i, - irq_status[CSID_IRQ_STATUS_RDI0 + i]); - CAM_ERR(CAM_ISP, - "Expected sz 0x%x*0x%x actual sz 0x%x*0x%x", - ((val2 >> - csid_reg->cmn_reg->format_measure_height_shift_val) & - csid_reg->cmn_reg->format_measure_height_mask_val), - val2 & - csid_reg->cmn_reg->format_measure_width_mask_val, - ((val >> - csid_reg->cmn_reg->format_measure_height_shift_val) & - csid_reg->cmn_reg->format_measure_height_mask_val), - val & - csid_reg->cmn_reg->format_measure_width_mask_val); - } - } - - if (csid_hw->irq_debug_cnt >= AIS_CSID_IRQ_SOF_DEBUG_CNT_MAX) { - ais_ife_csid_sof_irq_debug(csid_hw, &sof_irq_debug_en); - csid_hw->irq_debug_cnt = 0; - } - - CAM_DBG(CAM_ISP, "IRQ Handling exit"); - return IRQ_HANDLED; -} - -int ais_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf, - uint32_t csid_idx) -{ - int rc = -EINVAL; - uint32_t i; - struct cam_hw_info *csid_hw_info; - struct ais_ife_csid_hw *ife_csid_hw = NULL; - char worker_name[128]; - - if (csid_idx >= AIS_IFE_CSID_HW_RES_MAX) { - CAM_ERR(CAM_ISP, "Invalid csid index:%d", csid_idx); - return rc; - } - - csid_hw_info = (struct cam_hw_info *) csid_hw_intf->hw_priv; - ife_csid_hw = (struct ais_ife_csid_hw *) csid_hw_info->core_info; - - ife_csid_hw->hw_intf = csid_hw_intf; - ife_csid_hw->hw_info = csid_hw_info; - - CAM_DBG(CAM_ISP, "type %d index %d", - ife_csid_hw->hw_intf->hw_type, csid_idx); - - ife_csid_hw->device_enabled = 0; - ife_csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN; - mutex_init(&ife_csid_hw->hw_info->hw_mutex); - spin_lock_init(&ife_csid_hw->hw_info->hw_lock); - spin_lock_init(&ife_csid_hw->lock_state); - init_completion(&ife_csid_hw->hw_info->hw_complete); - - init_completion(&ife_csid_hw->csid_top_complete); - init_completion(&ife_csid_hw->csid_csi2_complete); - init_completion(&ife_csid_hw->csid_ipp_complete); - init_completion(&ife_csid_hw->csid_ppp_complete); - for (i = 0; i < AIS_IFE_CSID_RDI_MAX; i++) - init_completion(&ife_csid_hw->csid_rdi_complete[i]); - - rc = ais_ife_csid_init_soc_resources(&ife_csid_hw->hw_info->soc_info, - ais_ife_csid_irq, ife_csid_hw); - if (rc < 0) { - CAM_ERR(CAM_ISP, "CSID:%d Failed to init_soc", csid_idx); - goto err; - } - - ife_csid_hw->hw_intf->hw_ops.get_hw_caps = ais_ife_csid_get_hw_caps; - ife_csid_hw->hw_intf->hw_ops.init = ais_ife_csid_init_hw; - ife_csid_hw->hw_intf->hw_ops.deinit = ais_ife_csid_deinit_hw; - ife_csid_hw->hw_intf->hw_ops.reset = ais_ife_csid_force_reset; - ife_csid_hw->hw_intf->hw_ops.reserve = ais_ife_csid_reserve; - ife_csid_hw->hw_intf->hw_ops.release = ais_ife_csid_release; - ife_csid_hw->hw_intf->hw_ops.start = ais_ife_csid_start; - ife_csid_hw->hw_intf->hw_ops.stop = ais_ife_csid_stop; - ife_csid_hw->hw_intf->hw_ops.read = ais_ife_csid_read; - ife_csid_hw->hw_intf->hw_ops.write = ais_ife_csid_write; - ife_csid_hw->hw_intf->hw_ops.process_cmd = ais_ife_csid_process_cmd; - - /* Initialize the RDI resource */ - for (i = 0; i < ife_csid_hw->csid_info->csid_reg->cmn_reg->num_rdis; - i++) { - ife_csid_hw->rdi_cfg[i].state = - AIS_ISP_RESOURCE_STATE_AVAILABLE; - } - - ife_csid_hw->csid_debug = 0; - ife_csid_hw->error_irq_count = 0; - - scnprintf(worker_name, sizeof(worker_name), - "csid%u_worker", ife_csid_hw->hw_intf->hw_idx); - CAM_DBG(CAM_ISP, "Create CSID worker %s", worker_name); - rc = cam_req_mgr_workq_create(worker_name, - AIS_CSID_WORKQ_NUM_TASK, - &ife_csid_hw->work, CRM_WORKQ_USAGE_IRQ, 0); - if (rc) { - CAM_ERR(CAM_ISP, "Unable to create a workq, rc=%d", rc); - goto err_deinit_soc; - } - - for (i = 0; i < AIS_CSID_WORKQ_NUM_TASK; i++) - ife_csid_hw->work->task.pool[i].payload = - &ife_csid_hw->work_data[i]; - - return 0; - -err_deinit_soc: - ais_ife_csid_deinit_soc_resources(&ife_csid_hw->hw_info->soc_info); -err: - return rc; -} - - -int ais_ife_csid_hw_deinit(struct ais_ife_csid_hw *ife_csid_hw) -{ - int rc = 0; - - if (ife_csid_hw) { - ais_ife_csid_deinit_soc_resources( - &ife_csid_hw->hw_info->soc_info); - cam_req_mgr_workq_destroy(&ife_csid_hw->work); - } else { - CAM_ERR(CAM_ISP, "Invalid param"); - rc = -EINVAL; - } - - return rc; -} diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.h b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.h deleted file mode 100755 index 58cb9f6f1d74..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_core.h +++ /dev/null @@ -1,591 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_HW_H_ -#define _AIS_IFE_CSID_HW_H_ - -#include "cam_hw.h" -#include "ais_ife_csid_hw_intf.h" -#include "ais_ife_csid_soc.h" - -#define AIS_IFE_CSID_HW_RES_MAX 8 -#define AIS_IFE_CSID_CID_RES_MAX 4 -#define AIS_IFE_CSID_RDI_MAX 4 -#define AIS_CSID_WORKQ_NUM_TASK 10 - -#define CSID_CSI2_RX_INFO_PHY_DL0_EOT_CAPTURED BIT(0) -#define CSID_CSI2_RX_INFO_PHY_DL1_EOT_CAPTURED BIT(1) -#define CSID_CSI2_RX_INFO_PHY_DL2_EOT_CAPTURED BIT(2) -#define CSID_CSI2_RX_INFO_PHY_DL3_EOT_CAPTURED BIT(3) -#define CSID_CSI2_RX_INFO_PHY_DL0_SOT_CAPTURED BIT(4) -#define CSID_CSI2_RX_INFO_PHY_DL1_SOT_CAPTURED BIT(5) -#define CSID_CSI2_RX_INFO_PHY_DL2_SOT_CAPTURED BIT(6) -#define CSID_CSI2_RX_INFO_PHY_DL3_SOT_CAPTURED BIT(7) -#define CSID_CSI2_RX_INFO_LONG_PKT_CAPTURED BIT(8) -#define CSID_CSI2_RX_INFO_SHORT_PKT_CAPTURED BIT(9) -#define CSID_CSI2_RX_INFO_CPHY_PKT_HDR_CAPTURED BIT(10) -#define CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION BIT(11) -#define CSID_CSI2_RX_ERROR_CPHY_SOT_RECEPTION BIT(12) -#define CSID_CSI2_RX_ERROR_CPHY_PH_CRC BIT(13) -#define CSID_CSI2_RX_WARNING_ECC BIT(14) -#define CSID_CSI2_RX_ERROR_LANE0_FIFO_OVERFLOW BIT(15) -#define CSID_CSI2_RX_ERROR_LANE1_FIFO_OVERFLOW BIT(16) -#define CSID_CSI2_RX_ERROR_LANE2_FIFO_OVERFLOW BIT(17) -#define CSID_CSI2_RX_ERROR_LANE3_FIFO_OVERFLOW BIT(18) -#define CSID_CSI2_RX_ERROR_CRC BIT(19) -#define CSID_CSI2_RX_ERROR_ECC BIT(20) -#define CSID_CSI2_RX_ERROR_MMAPPED_VC_DT BIT(21) -#define CSID_CSI2_RX_ERROR_UNMAPPED_VC_DT BIT(22) -#define CSID_CSI2_RX_ERROR_STREAM_UNDERFLOW BIT(23) -#define CSID_CSI2_RX_ERROR_UNBOUNDED_FRAME BIT(24) -#define CSID_CSI2_RX_INFO_TG_DONE BIT(25) -#define CSID_CSI2_RX_ERROR_TG_FIFO_OVERFLOW BIT(26) -#define CSID_CSI2_RX_INFO_RST_DONE BIT(27) - -#define CSID_PATH_INFO_RST_DONE BIT(1) -#define CSID_PATH_ERROR_FIFO_OVERFLOW BIT(2) -#define CSID_PATH_INFO_SUBSAMPLED_EOF BIT(3) -#define CSID_PATH_INFO_SUBSAMPLED_SOF BIT(4) -#define CSID_PATH_INFO_FRAME_DROP_EOF BIT(5) -#define CSID_PATH_INFO_FRAME_DROP_EOL BIT(6) -#define CSID_PATH_INFO_FRAME_DROP_SOL BIT(7) -#define CSID_PATH_INFO_FRAME_DROP_SOF BIT(8) -#define CSID_PATH_INFO_INPUT_EOF BIT(9) -#define CSID_PATH_INFO_INPUT_EOL BIT(10) -#define CSID_PATH_INFO_INPUT_SOL BIT(11) -#define CSID_PATH_INFO_INPUT_SOF BIT(12) -#define CSID_PATH_ERROR_PIX_COUNT BIT(13) -#define CSID_PATH_ERROR_LINE_COUNT BIT(14) -#define CSID_PATH_ERROR_CCIF_VIOLATION BIT(15) - -/* - * Debug values enable the corresponding interrupts and debug logs provide - * necessary information - */ -#define CSID_DEBUG_ENABLE_SOF_IRQ BIT(0) -#define CSID_DEBUG_ENABLE_EOF_IRQ BIT(1) -#define CSID_DEBUG_ENABLE_SOT_IRQ BIT(2) -#define CSID_DEBUG_ENABLE_EOT_IRQ BIT(3) -#define CSID_DEBUG_ENABLE_SHORT_PKT_CAPTURE BIT(4) -#define CSID_DEBUG_ENABLE_LONG_PKT_CAPTURE BIT(5) -#define CSID_DEBUG_ENABLE_CPHY_PKT_CAPTURE BIT(6) -#define CSID_DEBUG_ENABLE_HBI_VBI_INFO BIT(7) -#define CSID_DEBUG_DISABLE_EARLY_EOF BIT(8) - -/* enum ais_csid_path_halt_mode select the path halt mode control */ -enum ais_csid_path_halt_mode { - CSID_HALT_MODE_INTERNAL, - CSID_HALT_MODE_GLOBAL, - CSID_HALT_MODE_MASTER, - CSID_HALT_MODE_SLAVE, -}; - -/** - *enum ais_csid_path_timestamp_stb_sel - select the sof/eof strobes used to - * capture the timestamp - */ -enum ais_csid_path_timestamp_stb_sel { - CSID_TIMESTAMP_STB_PRE_HALT, - CSID_TIMESTAMP_STB_POST_HALT, - CSID_TIMESTAMP_STB_POST_IRQ, - CSID_TIMESTAMP_STB_MAX, -}; - -/** - *enum ais_csid_irq_status - csid irq status to keep track - * various status registers - */ -enum ais_csid_irq_status { - CSID_IRQ_STATUS_TOP, - CSID_IRQ_STATUS_RX, - CSID_IRQ_STATUS_IPP, - CSID_IRQ_STATUS_PPP, - CSID_IRQ_STATUS_RDI0, - CSID_IRQ_STATUS_RDI1, - CSID_IRQ_STATUS_RDI2, - CSID_IRQ_STATUS_RDI3, - CSID_IRQ_STATUS_MAX, -}; - -struct ais_ife_csid_pxl_reg_offset { - /* Pxl path register offsets*/ - uint32_t csid_pxl_irq_status_addr; - uint32_t csid_pxl_irq_mask_addr; - uint32_t csid_pxl_irq_clear_addr; - uint32_t csid_pxl_irq_set_addr; - - uint32_t csid_pxl_cfg0_addr; - uint32_t csid_pxl_cfg1_addr; - uint32_t csid_pxl_ctrl_addr; - uint32_t csid_pxl_frm_drop_pattern_addr; - uint32_t csid_pxl_frm_drop_period_addr; - uint32_t csid_pxl_irq_subsample_pattern_addr; - uint32_t csid_pxl_irq_subsample_period_addr; - uint32_t csid_pxl_hcrop_addr; - uint32_t csid_pxl_vcrop_addr; - uint32_t csid_pxl_pix_drop_pattern_addr; - uint32_t csid_pxl_pix_drop_period_addr; - uint32_t csid_pxl_line_drop_pattern_addr; - uint32_t csid_pxl_line_drop_period_addr; - uint32_t csid_pxl_rst_strobes_addr; - uint32_t csid_pxl_status_addr; - uint32_t csid_pxl_misr_val_addr; - uint32_t csid_pxl_format_measure_cfg0_addr; - uint32_t csid_pxl_format_measure_cfg1_addr; - uint32_t csid_pxl_format_measure0_addr; - uint32_t csid_pxl_format_measure1_addr; - uint32_t csid_pxl_format_measure2_addr; - uint32_t csid_pxl_timestamp_curr0_sof_addr; - uint32_t csid_pxl_timestamp_curr1_sof_addr; - uint32_t csid_pxl_timestamp_perv0_sof_addr; - uint32_t csid_pxl_timestamp_perv1_sof_addr; - uint32_t csid_pxl_timestamp_curr0_eof_addr; - uint32_t csid_pxl_timestamp_curr1_eof_addr; - uint32_t csid_pxl_timestamp_perv0_eof_addr; - uint32_t csid_pxl_timestamp_perv1_eof_addr; - - /* configuration */ - uint32_t pix_store_en_shift_val; - uint32_t early_eof_en_shift_val; - uint32_t quad_cfa_bin_en_shift_val; - uint32_t ccif_violation_en; -}; - -struct ais_ife_csid_rdi_reg_offset { - uint32_t csid_rdi_irq_status_addr; - uint32_t csid_rdi_irq_mask_addr; - uint32_t csid_rdi_irq_clear_addr; - uint32_t csid_rdi_irq_set_addr; - - /*RDI N register address */ - uint32_t csid_rdi_cfg0_addr; - uint32_t csid_rdi_cfg1_addr; - uint32_t csid_rdi_ctrl_addr; - uint32_t csid_rdi_frm_drop_pattern_addr; - uint32_t csid_rdi_frm_drop_period_addr; - uint32_t csid_rdi_irq_subsample_pattern_addr; - uint32_t csid_rdi_irq_subsample_period_addr; - uint32_t csid_rdi_rpp_hcrop_addr; - uint32_t csid_rdi_rpp_vcrop_addr; - uint32_t csid_rdi_rpp_pix_drop_pattern_addr; - uint32_t csid_rdi_rpp_pix_drop_period_addr; - uint32_t csid_rdi_rpp_line_drop_pattern_addr; - uint32_t csid_rdi_rpp_line_drop_period_addr; - uint32_t csid_rdi_yuv_chroma_conversion_addr; - uint32_t csid_rdi_rst_strobes_addr; - uint32_t csid_rdi_status_addr; - uint32_t csid_rdi_misr_val0_addr; - uint32_t csid_rdi_misr_val1_addr; - uint32_t csid_rdi_misr_val2_addr; - uint32_t csid_rdi_misr_val3_addr; - uint32_t csid_rdi_format_measure_cfg0_addr; - uint32_t csid_rdi_format_measure_cfg1_addr; - uint32_t csid_rdi_format_measure0_addr; - uint32_t csid_rdi_format_measure1_addr; - uint32_t csid_rdi_format_measure2_addr; - uint32_t csid_rdi_timestamp_curr0_sof_addr; - uint32_t csid_rdi_timestamp_curr1_sof_addr; - uint32_t csid_rdi_timestamp_prev0_sof_addr; - uint32_t csid_rdi_timestamp_prev1_sof_addr; - uint32_t csid_rdi_timestamp_curr0_eof_addr; - uint32_t csid_rdi_timestamp_curr1_eof_addr; - uint32_t csid_rdi_timestamp_prev0_eof_addr; - uint32_t csid_rdi_timestamp_prev1_eof_addr; - uint32_t csid_rdi_byte_cntr_ping_addr; - uint32_t csid_rdi_byte_cntr_pong_addr; - - /* configuration */ - uint32_t packing_format; - uint32_t ccif_violation_en; -}; - -struct ais_ife_csid_csi2_rx_reg_offset { - uint32_t csid_csi2_rx_irq_status_addr; - uint32_t csid_csi2_rx_irq_mask_addr; - uint32_t csid_csi2_rx_irq_clear_addr; - uint32_t csid_csi2_rx_irq_set_addr; - uint32_t csid_csi2_rx_cfg0_addr; - uint32_t csid_csi2_rx_cfg1_addr; - uint32_t csid_csi2_rx_capture_ctrl_addr; - uint32_t csid_csi2_rx_rst_strobes_addr; - uint32_t csid_csi2_rx_de_scramble_cfg0_addr; - uint32_t csid_csi2_rx_de_scramble_cfg1_addr; - uint32_t csid_csi2_rx_cap_unmap_long_pkt_hdr_0_addr; - uint32_t csid_csi2_rx_cap_unmap_long_pkt_hdr_1_addr; - uint32_t csid_csi2_rx_captured_short_pkt_0_addr; - uint32_t csid_csi2_rx_captured_short_pkt_1_addr; - uint32_t csid_csi2_rx_captured_long_pkt_0_addr; - uint32_t csid_csi2_rx_captured_long_pkt_1_addr; - uint32_t csid_csi2_rx_captured_long_pkt_ftr_addr; - uint32_t csid_csi2_rx_captured_cphy_pkt_hdr_addr; - uint32_t csid_csi2_rx_lane0_misr_addr; - uint32_t csid_csi2_rx_lane1_misr_addr; - uint32_t csid_csi2_rx_lane2_misr_addr; - uint32_t csid_csi2_rx_lane3_misr_addr; - uint32_t csid_csi2_rx_total_pkts_rcvd_addr; - uint32_t csid_csi2_rx_stats_ecc_addr; - uint32_t csid_csi2_rx_total_crc_err_addr; - uint32_t csid_csi2_rx_de_scramble_type3_cfg0_addr; - uint32_t csid_csi2_rx_de_scramble_type3_cfg1_addr; - uint32_t csid_csi2_rx_de_scramble_type2_cfg0_addr; - uint32_t csid_csi2_rx_de_scramble_type2_cfg1_addr; - uint32_t csid_csi2_rx_de_scramble_type1_cfg0_addr; - uint32_t csid_csi2_rx_de_scramble_type1_cfg1_addr; - uint32_t csid_csi2_rx_de_scramble_type0_cfg0_addr; - uint32_t csid_csi2_rx_de_scramble_type0_cfg1_addr; - - /*configurations */ - uint32_t csi2_rst_srb_all; - uint32_t csi2_rst_done_shift_val; - uint32_t csi2_irq_mask_all; - uint32_t csi2_misr_enable_shift_val; - uint32_t csi2_vc_mode_shift_val; - uint32_t csi2_capture_long_pkt_en_shift; - uint32_t csi2_capture_short_pkt_en_shift; - uint32_t csi2_capture_cphy_pkt_en_shift; - uint32_t csi2_capture_long_pkt_dt_shift; - uint32_t csi2_capture_long_pkt_vc_shift; - uint32_t csi2_capture_short_pkt_vc_shift; - uint32_t csi2_capture_cphy_pkt_dt_shift; - uint32_t csi2_capture_cphy_pkt_vc_shift; - uint32_t csi2_rx_phy_num_mask; -}; - -struct ais_ife_csid_csi2_tpg_reg_offset { - uint32_t csid_tpg_ctrl_addr; - uint32_t csid_tpg_vc_cfg0_addr; - uint32_t csid_tpg_vc_cfg1_addr; - uint32_t csid_tpg_lfsr_seed_addr; - uint32_t csid_tpg_dt_n_cfg_0_addr; - uint32_t csid_tpg_dt_n_cfg_1_addr; - uint32_t csid_tpg_dt_n_cfg_2_addr; - uint32_t csid_tpg_color_bars_cfg_addr; - uint32_t csid_tpg_color_box_cfg_addr; - uint32_t csid_tpg_common_gen_cfg_addr; - uint32_t csid_tpg_cgen_n_cfg_addr; - uint32_t csid_tpg_cgen_n_x0_addr; - uint32_t csid_tpg_cgen_n_x1_addr; - uint32_t csid_tpg_cgen_n_x2_addr; - uint32_t csid_tpg_cgen_n_xy_addr; - uint32_t csid_tpg_cgen_n_y1_addr; - uint32_t csid_tpg_cgen_n_y2_addr; - - /*configurations */ - uint32_t tpg_dtn_cfg_offset; - uint32_t tpg_cgen_cfg_offset; - uint32_t tpg_cpas_ife_reg_offset; - -}; -struct ais_ife_csid_common_reg_offset { - /* MIPI CSID registers */ - uint32_t csid_hw_version_addr; - uint32_t csid_cfg0_addr; - uint32_t csid_ctrl_addr; - uint32_t csid_reset_addr; - uint32_t csid_rst_strobes_addr; - - uint32_t csid_test_bus_ctrl_addr; - uint32_t csid_top_irq_status_addr; - uint32_t csid_top_irq_mask_addr; - uint32_t csid_top_irq_clear_addr; - uint32_t csid_top_irq_set_addr; - uint32_t csid_irq_cmd_addr; - - /*configurations */ - uint32_t major_version; - uint32_t minor_version; - uint32_t version_incr; - uint32_t num_rdis; - uint32_t num_pix; - uint32_t num_ppp; - uint32_t csid_reg_rst_stb; - uint32_t csid_rst_stb; - uint32_t csid_rst_stb_sw_all; - uint32_t path_rst_stb_all; - uint32_t path_rst_done_shift_val; - uint32_t path_en_shift_val; - uint32_t dt_id_shift_val; - uint32_t vc_shift_val; - uint32_t dt_shift_val; - uint32_t fmt_shift_val; - uint32_t plain_fmt_shit_val; - uint32_t crop_v_en_shift_val; - uint32_t crop_h_en_shift_val; - uint32_t crop_shift; - uint32_t ipp_irq_mask_all; - uint32_t rdi_irq_mask_all; - uint32_t ppp_irq_mask_all; - uint32_t measure_en_hbi_vbi_cnt_mask; - uint32_t format_measure_en_val; - uint32_t format_measure_width_shift_val; - uint32_t format_measure_width_mask_val; - uint32_t format_measure_height_shift_val; - uint32_t format_measure_height_mask_val; -}; - -/** - * struct ais_ife_csid_reg_offset- CSID instance register info - * - * @cmn_reg: csid common registers info - * @ipp_reg: ipp register offset information - * @ppp_reg: ppp register offset information - * @rdi_reg: rdi register offser information - * - */ -struct ais_ife_csid_reg_offset { - const struct ais_ife_csid_common_reg_offset *cmn_reg; - const struct ais_ife_csid_csi2_rx_reg_offset *csi2_reg; - const struct ais_ife_csid_pxl_reg_offset *ipp_reg; - const struct ais_ife_csid_pxl_reg_offset *ppp_reg; - const struct ais_ife_csid_rdi_reg_offset *rdi_reg[AIS_IFE_CSID_RDI_MAX]; - const struct ais_ife_csid_csi2_tpg_reg_offset *tpg_reg; -}; - - -/** - * struct ais_ife_csid_hw_info- CSID HW info - * - * @csid_reg: csid register offsets - * @hw_dts_version: HW DTS version - * @csid_max_clk: maximim csid clock - * - */ -struct ais_ife_csid_hw_info { - const struct ais_ife_csid_reg_offset *csid_reg; - uint32_t hw_dts_version; - uint32_t csid_max_clk; - -}; - - - -/** - * struct ais_ife_csid_csi2_rx_cfg- csid csi2 rx configuration data - * @phy_sel: input resource type for sensor only - * @lane_type: lane type: c-phy or d-phy - * @lane_num : active lane number - * @lane_cfg: lane configurations: 4 bits per lane - * - */ -struct ais_ife_csid_csi2_rx_cfg { - uint32_t phy_sel; - uint32_t lane_type; - uint32_t lane_num; - uint32_t lane_cfg; -}; - -/** - * struct ais_ife_csid_tpg_cfg- csid tpg configuration data - * @width: width - * @height: height - * @test_pattern : pattern - * @in_format: decode format - * @usage_type: whether dual isp is required - * - */ -struct ais_ife_csid_tpg_cfg { - uint32_t width; - uint32_t height; - uint32_t test_pattern; - uint32_t in_format; - uint32_t usage_type; -}; - -/** - * struct ais_ife_csid_cid_data- cid configuration private data - * - * @vc: Virtual channel - * @dt: Data type - * @cnt: Cid resource reference count. - * @tpg_set: Tpg used for this cid resource - * - */ -struct ais_ife_csid_cid_data { - uint32_t vc; - uint32_t dt; - uint32_t cnt; - uint32_t tpg_set; -}; - -/** - * struct ais_csid_hw_work_data- work data for csid - * Later other fields can be added to this data - * @evt_type : Event type from CSID - * @irq_status : IRQ Status register - * - */ -struct ais_csid_hw_work_data { - uint64_t timestamp; - uint32_t evt_type; - uint32_t irq_status[CSID_IRQ_STATUS_MAX]; -}; - -/** - * struct ais_ife_csid_path_cfg- csid path configuration details. It is stored - * as private data for IPP/ RDI paths - * @vc : Virtual channel number - * @dt : Data type number - * @cid cid number, it is same as DT_ID number in HW - * @in_format: input decode format - * @out_format: output format - * @crop_enable: crop is enable or disabled, if enabled - * then remaining parameters are valid. - * @start_pixel: start pixel - * @end_pixel: end_pixel - * @width: width - * @start_line: start line - * @end_line: end_line - * @height: heigth - * @sync_mode: Applicable for IPP/RDI path reservation - * Reserving the path for master IPP or slave IPP - * master (set value 1), Slave ( set value 2) - * for RDI, set mode to none - * @master_idx: For Slave reservation, Give master IFE instance Index. - * Slave will synchronize with master Start and stop operations - * @clk_rate Clock rate - * @usage_type Usage type ie dual or single ife usecase - * @init_frame_drop init frame drop value. In dual ife case rdi need to drop one - * more frame than pix. - * - */ -struct ais_ife_csid_path_cfg { - enum ais_isp_resource_state state; - uint32_t vc; - uint32_t dt; - uint32_t cid; - uint32_t in_format; - uint32_t out_format; - - bool pix_enable; - uint32_t decode_fmt; - uint32_t plain_fmt; - uint32_t in_bpp; - - bool crop_enable; - uint32_t start_pixel; - uint32_t end_pixel; - uint32_t width; - uint32_t start_line; - uint32_t end_line; - uint32_t height; - - struct cam_isp_sensor_dimension measure_cfg; - - uint32_t master_idx; - uint64_t clk_rate; - uint32_t usage_type; - - uint32_t init_frame_drop; - - uint32_t sof_cnt; - uint32_t prev_sof_hw_ts; - uint32_t prev_sof_boot_ts; -}; - -/** - * struct ais_ife_csid_hw- csid hw device resources data - * - * @hw_intf: contain the csid hw interface information - * @hw_info: csid hw device information - * @csid_info: csid hw specific information - * @res_type: CSID in resource type - * @csi2_rx_cfg: Csi2 rx decoder configuration for csid - * @tpg_cfg: TPG configuration - * @csi2_rx_reserve_cnt: CSI2 reservations count value - * @csi2_cfg_cnt: csi2 configuration count - * @tpg_start_cnt: tpg start count - * @ipp_res: image pixel path resource - * @ppp_res: phase pxl path resource - * @rdi_res: raw dump image path resources - * @cid_res: cid resources state - * @csid_top_reset_complete: csid top reset completion - * @csid_csi2_reset_complete: csi2 reset completion - * @csid_ipp_reset_complete: ipp reset completion - * @csid_ppp_complete: ppp reset completion - * @csid_rdin_reset_complete: rdi n completion - * @csid_debug: csid debug information to enable the SOT, EOT, - * SOF, EOF, measure etc in the csid hw - * @clk_rate Clock rate - * @ipp_path ipp path configuration - * @ppp_path ppp path configuration - * @rdi_path RDI path configuration - * @hbi Horizontal blanking - * @vbi Vertical blanking - * @sof_irq_triggered: Flag is set on receiving event to enable sof irq - * incase of SOF freeze. - * @irq_debug_cnt: Counter to track sof irq's when above flag is set. - * @error_irq_count Error IRQ count, if continuous error irq comes - * need to stop the CSID and mask interrupts. - * @device_enabled Device enabled will set once CSID powered on and - * initial configuration are done. - * @lock_state csid spin lock - * @dual_usage usage type, dual ife or single ife - * @init_frame_drop Initial frame drop number - * @res_sof_cnt path resource sof count value. it used for initial - * frame drop - * @prev_boot_timestamp first bootime stamp at the start - * @prev_qtimer_ts stores csid timestamp - * @ppi_hw_intf interface to ppi hardware - * @ppi_enabled flag to specify if the hardware has ppi bridge - * or not - * @fatal_err_detected flag to indicate fatal errror is reported - * @ctx Hw manager context - * @work Work queue to handle CSID IRQ work - * @work_data Work data to be passed to work queue - * @event_cb Callback to hw manager if CSID event reported - * - */ -struct ais_ife_csid_hw { - struct cam_hw_intf *hw_intf; - struct cam_hw_info *hw_info; - struct ais_ife_csid_hw_info *csid_info; - - enum ais_isp_resource_state state; - struct ais_ife_csid_path_cfg rdi_cfg[AIS_IFE_CSID_RDI_MAX]; - bool ipp_fix_cfg; - - uint32_t res_type; - struct ais_ife_csid_csi2_rx_cfg csi2_rx_cfg; - struct ais_ife_csid_tpg_cfg tpg_cfg; - uint32_t csi2_reserve_cnt; - uint32_t csi2_cfg_cnt; - uint32_t tpg_start_cnt; - struct completion csid_top_complete; - struct completion csid_csi2_complete; - struct completion csid_ipp_complete; - struct completion csid_ppp_complete; - struct completion csid_rdi_complete[AIS_IFE_CSID_RDI_MAX]; - uint64_t csid_debug; - uint64_t clk_rate; - - bool sof_irq_triggered; - uint32_t irq_debug_cnt; - uint32_t error_irq_count; - bool fatal_err_detected; - uint32_t device_enabled; - spinlock_t lock_state; - uint32_t dual_usage; - uint32_t init_frame_drop; - - void *ctx; - struct cam_req_mgr_core_workq *work; - struct ais_csid_hw_work_data work_data[AIS_CSID_WORKQ_NUM_TASK]; - ais_ife_event_cb_func event_cb; - void *event_cb_priv; -}; - -int ais_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf, - uint32_t csid_idx); - -int ais_ife_csid_hw_deinit(struct ais_ife_csid_hw *ife_csid_hw); - -#endif /* _AIS_IFE_CSID_HW_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.c b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.c deleted file mode 100755 index 564a73aa46f8..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_dev.c +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include "ais_ife_csid_core.h" -#include "ais_ife_csid_dev.h" -#include "ais_ife_csid_hw_intf.h" -#include "cam_debug_util.h" - -static struct cam_hw_intf *ais_ife_csid_hw_list[AIS_IFE_CSID_HW_RES_MAX] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; - -static char csid_dev_name[8]; - -int ais_ife_csid_probe(struct platform_device *pdev) -{ - - struct cam_hw_intf *csid_hw_intf; - struct cam_hw_info *csid_hw_info; - struct ais_ife_csid_hw *csid_dev = NULL; - const struct of_device_id *match_dev = NULL; - struct ais_ife_csid_hw_info *csid_hw_data = NULL; - uint32_t csid_dev_idx; - int rc = 0; - - CAM_INFO(CAM_ISP, "probe called"); - - csid_hw_intf = kzalloc(sizeof(*csid_hw_intf), GFP_KERNEL); - if (!csid_hw_intf) { - rc = -ENOMEM; - goto err; - } - - csid_hw_info = kzalloc(sizeof(struct cam_hw_info), GFP_KERNEL); - if (!csid_hw_info) { - rc = -ENOMEM; - goto free_hw_intf; - } - - csid_dev = kzalloc(sizeof(struct ais_ife_csid_hw), GFP_KERNEL); - if (!csid_dev) { - rc = -ENOMEM; - goto free_hw_info; - } - - /* get ife csid hw index */ - of_property_read_u32(pdev->dev.of_node, "cell-index", &csid_dev_idx); - /* get ife csid hw information */ - match_dev = of_match_device(pdev->dev.driver->of_match_table, - &pdev->dev); - if (!match_dev) { - CAM_ERR(CAM_ISP, "No matching table for the IFE CSID HW!"); - rc = -EINVAL; - goto free_dev; - } - - CAM_INFO(CAM_ISP, "CSID%d probe called", csid_dev_idx); - - memset(csid_dev_name, 0, sizeof(csid_dev_name)); - snprintf(csid_dev_name, sizeof(csid_dev_name), - "csid%1u", csid_dev_idx); - - csid_hw_intf->hw_idx = csid_dev_idx; - csid_hw_intf->hw_type = AIS_ISP_HW_TYPE_IFE_CSID; - csid_hw_intf->hw_priv = csid_hw_info; - - csid_hw_info->core_info = csid_dev; - csid_hw_info->soc_info.pdev = pdev; - csid_hw_info->soc_info.dev = &pdev->dev; - csid_hw_info->soc_info.dev_name = csid_dev_name; - csid_hw_info->soc_info.index = csid_dev_idx; - - csid_hw_data = (struct ais_ife_csid_hw_info *)match_dev->data; - /* need to setup the pdev before call the ife hw probe init */ - csid_dev->csid_info = csid_hw_data; - - rc = ais_ife_csid_hw_probe_init(csid_hw_intf, csid_dev_idx); - if (rc) - goto free_dev; - - platform_set_drvdata(pdev, csid_dev); - CAM_INFO(CAM_ISP, "CSID:%d probe successful", - csid_hw_intf->hw_idx); - - - if (csid_hw_intf->hw_idx < AIS_IFE_CSID_HW_RES_MAX) - ais_ife_csid_hw_list[csid_hw_intf->hw_idx] = csid_hw_intf; - else - goto free_dev; - - return 0; - -free_dev: - kfree(csid_dev); -free_hw_info: - kfree(csid_hw_info); -free_hw_intf: - kfree(csid_hw_intf); -err: - return rc; -} - -int ais_ife_csid_remove(struct platform_device *pdev) -{ - struct ais_ife_csid_hw *csid_dev = NULL; - struct cam_hw_intf *csid_hw_intf; - struct cam_hw_info *csid_hw_info; - - csid_dev = (struct ais_ife_csid_hw *)platform_get_drvdata(pdev); - csid_hw_intf = csid_dev->hw_intf; - csid_hw_info = csid_dev->hw_info; - - CAM_DBG(CAM_ISP, "CSID:%d remove", - csid_dev->hw_intf->hw_idx); - - ais_ife_csid_hw_deinit(csid_dev); - - /*release the csid device memory */ - kfree(csid_dev); - kfree(csid_hw_info); - kfree(csid_hw_intf); - return 0; -} - -int ais_ife_csid_hw_init(struct cam_hw_intf **ife_csid_hw, - struct ais_isp_hw_init_args *init) -{ - int rc = 0; - - if (ais_ife_csid_hw_list[init->hw_idx]) { - struct cam_hw_info *csid_hw_info = NULL; - struct ais_ife_csid_hw *core_info = NULL; - - csid_hw_info = ais_ife_csid_hw_list[init->hw_idx]->hw_priv; - core_info = (struct ais_ife_csid_hw *)csid_hw_info->core_info; - - core_info->event_cb = init->event_cb; - core_info->event_cb_priv = init->event_cb_priv; - *ife_csid_hw = ais_ife_csid_hw_list[init->hw_idx]; - } else { - *ife_csid_hw = NULL; - rc = -1; - } - - return rc; -} diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.c b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.c deleted file mode 100755 index 90530829b394..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include "ais_ife_csid_lite17x.h" -#include "ais_ife_csid_core.h" -#include "ais_ife_csid_dev.h" - -#define CAM_CSID_LITE_DRV_NAME "ais-csid_lite" - -static struct ais_ife_csid_hw_info ais_ife_csid_lite_hw_info = { - .csid_reg = &ais_ife_csid_lite_17x_reg_offset, -}; - -static const struct of_device_id ais_ife_csid_lite_dt_match[] = { - { - .compatible = "qcom,ais-csid-lite170", - .data = &ais_ife_csid_lite_hw_info, - }, - { - .compatible = "qcom,ais-csid-lite175", - .data = &ais_ife_csid_lite_hw_info, - }, - {} -}; -MODULE_DEVICE_TABLE(of, ais_ife_csid_lite_dt_match); - -static struct platform_driver ais_ife_csid_lite_driver = { - .probe = ais_ife_csid_probe, - .remove = ais_ife_csid_remove, - .driver = { - .name = CAM_CSID_LITE_DRV_NAME, - .owner = THIS_MODULE, - .of_match_table = ais_ife_csid_lite_dt_match, - .suppress_bind_attrs = true, - }, -}; - -static int __init ais_ife_csid_lite_init_module(void) -{ - return platform_driver_register(&ais_ife_csid_lite_driver); -} - -static void __exit ais_ife_csid_lite_exit_module(void) -{ - platform_driver_unregister(&ais_ife_csid_lite_driver); -} - -module_init(ais_ife_csid_lite_init_module); -module_exit(ais_ife_csid_lite_exit_module); -MODULE_DESCRIPTION("CAM IFE_CSID_LITE driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.h b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.h deleted file mode 100755 index 376718f31566..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_lite17x.h +++ /dev/null @@ -1,322 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_LITE17X_H_ -#define _AIS_IFE_CSID_LITE17X_H_ -#include "ais_ife_csid_core.h" - -static const struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_lite_17x_rdi_0_reg_offset = { - - .csid_rdi_irq_status_addr = 0x30, - .csid_rdi_irq_mask_addr = 0x34, - .csid_rdi_irq_clear_addr = 0x38, - .csid_rdi_irq_set_addr = 0x3c, - .csid_rdi_cfg0_addr = 0x200, - .csid_rdi_cfg1_addr = 0x204, - .csid_rdi_ctrl_addr = 0x208, - .csid_rdi_frm_drop_pattern_addr = 0x20c, - .csid_rdi_frm_drop_period_addr = 0x210, - .csid_rdi_irq_subsample_pattern_addr = 0x214, - .csid_rdi_irq_subsample_period_addr = 0x218, - .csid_rdi_rpp_hcrop_addr = 0x21c, - .csid_rdi_rpp_vcrop_addr = 0x220, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x224, - .csid_rdi_rpp_pix_drop_period_addr = 0x228, - .csid_rdi_rpp_line_drop_pattern_addr = 0x22c, - .csid_rdi_rpp_line_drop_period_addr = 0x230, - .csid_rdi_rst_strobes_addr = 0x240, - .csid_rdi_status_addr = 0x250, - .csid_rdi_misr_val0_addr = 0x254, - .csid_rdi_misr_val1_addr = 0x258, - .csid_rdi_misr_val2_addr = 0x25c, - .csid_rdi_misr_val3_addr = 0x260, - .csid_rdi_format_measure_cfg0_addr = 0x270, - .csid_rdi_format_measure_cfg1_addr = 0x274, - .csid_rdi_format_measure0_addr = 0x278, - .csid_rdi_format_measure1_addr = 0x27c, - .csid_rdi_format_measure2_addr = 0x280, - .csid_rdi_timestamp_curr0_sof_addr = 0x290, - .csid_rdi_timestamp_curr1_sof_addr = 0x294, - .csid_rdi_timestamp_prev0_sof_addr = 0x298, - .csid_rdi_timestamp_prev1_sof_addr = 0x29c, - .csid_rdi_timestamp_curr0_eof_addr = 0x2a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x2a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x2a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x2ac, - .csid_rdi_byte_cntr_ping_addr = 0x2e0, - .csid_rdi_byte_cntr_pong_addr = 0x2e4, -}; - -static const struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_lite_17x_rdi_1_reg_offset = { - - .csid_rdi_irq_status_addr = 0x40, - .csid_rdi_irq_mask_addr = 0x44, - .csid_rdi_irq_clear_addr = 0x48, - .csid_rdi_irq_set_addr = 0x4c, - .csid_rdi_cfg0_addr = 0x300, - .csid_rdi_cfg1_addr = 0x304, - .csid_rdi_ctrl_addr = 0x308, - .csid_rdi_frm_drop_pattern_addr = 0x30c, - .csid_rdi_frm_drop_period_addr = 0x310, - .csid_rdi_irq_subsample_pattern_addr = 0x314, - .csid_rdi_irq_subsample_period_addr = 0x318, - .csid_rdi_rpp_hcrop_addr = 0x31c, - .csid_rdi_rpp_vcrop_addr = 0x320, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x324, - .csid_rdi_rpp_pix_drop_period_addr = 0x328, - .csid_rdi_rpp_line_drop_pattern_addr = 0x32c, - .csid_rdi_rpp_line_drop_period_addr = 0x330, - .csid_rdi_rst_strobes_addr = 0x340, - .csid_rdi_status_addr = 0x350, - .csid_rdi_misr_val0_addr = 0x354, - .csid_rdi_misr_val1_addr = 0x358, - .csid_rdi_misr_val2_addr = 0x35c, - .csid_rdi_misr_val3_addr = 0x360, - .csid_rdi_format_measure_cfg0_addr = 0x370, - .csid_rdi_format_measure_cfg1_addr = 0x374, - .csid_rdi_format_measure0_addr = 0x378, - .csid_rdi_format_measure1_addr = 0x37c, - .csid_rdi_format_measure2_addr = 0x380, - .csid_rdi_timestamp_curr0_sof_addr = 0x390, - .csid_rdi_timestamp_curr1_sof_addr = 0x394, - .csid_rdi_timestamp_prev0_sof_addr = 0x398, - .csid_rdi_timestamp_prev1_sof_addr = 0x39c, - .csid_rdi_timestamp_curr0_eof_addr = 0x3a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x3a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x3a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x3ac, - .csid_rdi_byte_cntr_ping_addr = 0x3e0, - .csid_rdi_byte_cntr_pong_addr = 0x3e4, -}; - -static const struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_lite_17x_rdi_2_reg_offset = { - - .csid_rdi_irq_status_addr = 0x50, - .csid_rdi_irq_mask_addr = 0x54, - .csid_rdi_irq_clear_addr = 0x58, - .csid_rdi_irq_set_addr = 0x5c, - .csid_rdi_cfg0_addr = 0x400, - .csid_rdi_cfg1_addr = 0x404, - .csid_rdi_ctrl_addr = 0x408, - .csid_rdi_frm_drop_pattern_addr = 0x40c, - .csid_rdi_frm_drop_period_addr = 0x410, - .csid_rdi_irq_subsample_pattern_addr = 0x414, - .csid_rdi_irq_subsample_period_addr = 0x418, - .csid_rdi_rpp_hcrop_addr = 0x41c, - .csid_rdi_rpp_vcrop_addr = 0x420, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x424, - .csid_rdi_rpp_pix_drop_period_addr = 0x428, - .csid_rdi_rpp_line_drop_pattern_addr = 0x42c, - .csid_rdi_rpp_line_drop_period_addr = 0x430, - .csid_rdi_yuv_chroma_conversion_addr = 0x434, - .csid_rdi_rst_strobes_addr = 0x440, - .csid_rdi_status_addr = 0x450, - .csid_rdi_misr_val0_addr = 0x454, - .csid_rdi_misr_val1_addr = 0x458, - .csid_rdi_misr_val2_addr = 0x45c, - .csid_rdi_misr_val3_addr = 0x460, - .csid_rdi_format_measure_cfg0_addr = 0x470, - .csid_rdi_format_measure_cfg1_addr = 0x474, - .csid_rdi_format_measure0_addr = 0x478, - .csid_rdi_format_measure1_addr = 0x47c, - .csid_rdi_format_measure2_addr = 0x480, - .csid_rdi_timestamp_curr0_sof_addr = 0x490, - .csid_rdi_timestamp_curr1_sof_addr = 0x494, - .csid_rdi_timestamp_prev0_sof_addr = 0x498, - .csid_rdi_timestamp_prev1_sof_addr = 0x49c, - .csid_rdi_timestamp_curr0_eof_addr = 0x4a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x4a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x4a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x4ac, - .csid_rdi_byte_cntr_ping_addr = 0x4e0, - .csid_rdi_byte_cntr_pong_addr = 0x4e4, -}; - -static const struct ais_ife_csid_rdi_reg_offset - ais_ife_csid_lite_17x_rdi_3_reg_offset = { - - .csid_rdi_irq_status_addr = 0x60, - .csid_rdi_irq_mask_addr = 0x64, - .csid_rdi_irq_clear_addr = 0x68, - .csid_rdi_irq_set_addr = 0x6c, - .csid_rdi_cfg0_addr = 0x500, - .csid_rdi_cfg1_addr = 0x504, - .csid_rdi_ctrl_addr = 0x508, - .csid_rdi_frm_drop_pattern_addr = 0x50c, - .csid_rdi_frm_drop_period_addr = 0x510, - .csid_rdi_irq_subsample_pattern_addr = 0x514, - .csid_rdi_irq_subsample_period_addr = 0x518, - .csid_rdi_rpp_hcrop_addr = 0x51c, - .csid_rdi_rpp_vcrop_addr = 0x520, - .csid_rdi_rpp_pix_drop_pattern_addr = 0x524, - .csid_rdi_rpp_pix_drop_period_addr = 0x528, - .csid_rdi_rpp_line_drop_pattern_addr = 0x52c, - .csid_rdi_rpp_line_drop_period_addr = 0x530, - .csid_rdi_yuv_chroma_conversion_addr = 0x534, - .csid_rdi_rst_strobes_addr = 0x540, - .csid_rdi_status_addr = 0x550, - .csid_rdi_misr_val0_addr = 0x554, - .csid_rdi_misr_val1_addr = 0x558, - .csid_rdi_misr_val2_addr = 0x55c, - .csid_rdi_misr_val3_addr = 0x560, - .csid_rdi_format_measure_cfg0_addr = 0x570, - .csid_rdi_format_measure_cfg1_addr = 0x574, - .csid_rdi_format_measure0_addr = 0x578, - .csid_rdi_format_measure1_addr = 0x57c, - .csid_rdi_format_measure2_addr = 0x580, - .csid_rdi_timestamp_curr0_sof_addr = 0x590, - .csid_rdi_timestamp_curr1_sof_addr = 0x594, - .csid_rdi_timestamp_prev0_sof_addr = 0x598, - .csid_rdi_timestamp_prev1_sof_addr = 0x59c, - .csid_rdi_timestamp_curr0_eof_addr = 0x5a0, - .csid_rdi_timestamp_curr1_eof_addr = 0x5a4, - .csid_rdi_timestamp_prev0_eof_addr = 0x5a8, - .csid_rdi_timestamp_prev1_eof_addr = 0x5ac, - .csid_rdi_byte_cntr_ping_addr = 0x5e0, - .csid_rdi_byte_cntr_pong_addr = 0x5e4, -}; - -static const struct ais_ife_csid_csi2_rx_reg_offset - ais_ife_csid_lite_17x_csi2_reg_offset = { - - .csid_csi2_rx_irq_status_addr = 0x20, - .csid_csi2_rx_irq_mask_addr = 0x24, - .csid_csi2_rx_irq_clear_addr = 0x28, - .csid_csi2_rx_irq_set_addr = 0x2c, - - /*CSI2 rx control */ - .csid_csi2_rx_cfg0_addr = 0x100, - .csid_csi2_rx_cfg1_addr = 0x104, - .csid_csi2_rx_capture_ctrl_addr = 0x108, - .csid_csi2_rx_rst_strobes_addr = 0x110, - .csid_csi2_rx_de_scramble_cfg0_addr = 0x114, - .csid_csi2_rx_de_scramble_cfg1_addr = 0x118, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_0_addr = 0x120, - .csid_csi2_rx_cap_unmap_long_pkt_hdr_1_addr = 0x124, - .csid_csi2_rx_captured_short_pkt_0_addr = 0x128, - .csid_csi2_rx_captured_short_pkt_1_addr = 0x12c, - .csid_csi2_rx_captured_long_pkt_0_addr = 0x130, - .csid_csi2_rx_captured_long_pkt_1_addr = 0x134, - .csid_csi2_rx_captured_long_pkt_ftr_addr = 0x138, - .csid_csi2_rx_captured_cphy_pkt_hdr_addr = 0x13c, - .csid_csi2_rx_lane0_misr_addr = 0x150, - .csid_csi2_rx_lane1_misr_addr = 0x154, - .csid_csi2_rx_lane2_misr_addr = 0x158, - .csid_csi2_rx_lane3_misr_addr = 0x15c, - .csid_csi2_rx_total_pkts_rcvd_addr = 0x160, - .csid_csi2_rx_stats_ecc_addr = 0x164, - .csid_csi2_rx_total_crc_err_addr = 0x168, - - .csi2_rst_srb_all = 0x3FFF, - .csi2_rst_done_shift_val = 27, - .csi2_irq_mask_all = 0xFFFFFFF, - .csi2_misr_enable_shift_val = 6, - .csi2_vc_mode_shift_val = 2, - .csi2_capture_long_pkt_en_shift = 0, - .csi2_capture_short_pkt_en_shift = 1, - .csi2_capture_cphy_pkt_en_shift = 2, - .csi2_capture_long_pkt_dt_shift = 4, - .csi2_capture_long_pkt_vc_shift = 10, - .csi2_capture_short_pkt_vc_shift = 15, - .csi2_capture_cphy_pkt_dt_shift = 20, - .csi2_capture_cphy_pkt_vc_shift = 26, - .csi2_rx_phy_num_mask = 0x3, -}; - - -static const struct ais_ife_csid_csi2_tpg_reg_offset - ais_ife_csid_lite_17x_tpg_reg_offset = { - - /*CSID TPG control */ - .csid_tpg_ctrl_addr = 0x600, - .csid_tpg_vc_cfg0_addr = 0x604, - .csid_tpg_vc_cfg1_addr = 0x608, - .csid_tpg_lfsr_seed_addr = 0x60c, - .csid_tpg_dt_n_cfg_0_addr = 0x610, - .csid_tpg_dt_n_cfg_1_addr = 0x614, - .csid_tpg_dt_n_cfg_2_addr = 0x618, - .csid_tpg_color_bars_cfg_addr = 0x640, - .csid_tpg_color_box_cfg_addr = 0x644, - .csid_tpg_common_gen_cfg_addr = 0x648, - .csid_tpg_cgen_n_cfg_addr = 0x650, - .csid_tpg_cgen_n_x0_addr = 0x654, - .csid_tpg_cgen_n_x1_addr = 0x658, - .csid_tpg_cgen_n_x2_addr = 0x65c, - .csid_tpg_cgen_n_xy_addr = 0x660, - .csid_tpg_cgen_n_y1_addr = 0x664, - .csid_tpg_cgen_n_y2_addr = 0x668, - - /*configurations */ - .tpg_dtn_cfg_offset = 0xc, - .tpg_cgen_cfg_offset = 0x20, - .tpg_cpas_ife_reg_offset = 0x28, -}; - - -static const struct ais_ife_csid_common_reg_offset - cam_csid_lite_17x_cmn_reg_offset = { - - .csid_hw_version_addr = 0x0, - .csid_cfg0_addr = 0x4, - .csid_ctrl_addr = 0x8, - .csid_reset_addr = 0xc, - .csid_rst_strobes_addr = 0x10, - - .csid_test_bus_ctrl_addr = 0x14, - .csid_top_irq_status_addr = 0x70, - .csid_top_irq_mask_addr = 0x74, - .csid_top_irq_clear_addr = 0x78, - .csid_top_irq_set_addr = 0x7c, - .csid_irq_cmd_addr = 0x80, - - /*configurations */ - .major_version = 1, - .minor_version = 7, - .version_incr = 0, - .num_rdis = 4, - .num_pix = 0, - .csid_reg_rst_stb = 1, - .csid_rst_stb = 0x1e, - .csid_rst_stb_sw_all = 0x1f, - .path_rst_stb_all = 0x7f, - .path_rst_done_shift_val = 1, - .path_en_shift_val = 31, - .dt_id_shift_val = 27, - .vc_shift_val = 22, - .dt_shift_val = 16, - .fmt_shift_val = 12, - .plain_fmt_shit_val = 10, - .crop_v_en_shift_val = 6, - .crop_h_en_shift_val = 5, - .crop_shift = 16, - .ipp_irq_mask_all = 0x7FFF, - .rdi_irq_mask_all = 0x7FFF, - .ppp_irq_mask_all = 0xFFFF, -}; - -static const struct ais_ife_csid_reg_offset ais_ife_csid_lite_17x_reg_offset = { - .cmn_reg = &cam_csid_lite_17x_cmn_reg_offset, - .csi2_reg = &ais_ife_csid_lite_17x_csi2_reg_offset, - .ipp_reg = NULL, - .rdi_reg = { - &ais_ife_csid_lite_17x_rdi_0_reg_offset, - &ais_ife_csid_lite_17x_rdi_1_reg_offset, - &ais_ife_csid_lite_17x_rdi_2_reg_offset, - &ais_ife_csid_lite_17x_rdi_3_reg_offset, - }, - .tpg_reg = &ais_ife_csid_lite_17x_tpg_reg_offset, -}; - -#endif /*_AIS_IFE_CSID_LITE17X_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.c b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.c deleted file mode 100755 index 71b0ac283808..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.c +++ /dev/null @@ -1,239 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include "ais_ife_csid_soc.h" -#include "cam_cpas_api.h" -#include "cam_debug_util.h" - -static int ais_ife_csid_get_dt_properties(struct cam_hw_soc_info *soc_info) -{ - struct device_node *of_node = NULL; - struct csid_device_soc_info *csid_soc_info = NULL; - int rc = 0; - - of_node = soc_info->pdev->dev.of_node; - csid_soc_info = (struct csid_device_soc_info *)soc_info->soc_private; - - rc = cam_soc_util_get_dt_properties(soc_info); - if (rc) - return rc; - - return rc; -} - -static int ais_ife_csid_request_platform_resource( - struct cam_hw_soc_info *soc_info, - irq_handler_t csid_irq_handler, - void *irq_data) -{ - int rc = 0; - - rc = cam_soc_util_request_platform_resource(soc_info, csid_irq_handler, - irq_data); - if (rc) - return rc; - - return rc; -} - -int ais_ife_csid_init_soc_resources(struct cam_hw_soc_info *soc_info, - irq_handler_t csid_irq_handler, void *irq_data) -{ - int rc = 0; - struct cam_cpas_register_params cpas_register_param; - struct ais_csid_soc_private *soc_private; - - soc_private = kzalloc(sizeof(struct ais_csid_soc_private), GFP_KERNEL); - if (!soc_private) - return -ENOMEM; - - soc_info->soc_private = soc_private; - - rc = ais_ife_csid_get_dt_properties(soc_info); - if (rc < 0) - return rc; - - /* Need to see if we want post process the clock list */ - - rc = ais_ife_csid_request_platform_resource(soc_info, csid_irq_handler, - irq_data); - if (rc < 0) { - CAM_ERR(CAM_ISP, - "Error Request platform resources failed rc=%d", rc); - goto free_soc_private; - } - - memset(&cpas_register_param, 0, sizeof(cpas_register_param)); - strlcpy(cpas_register_param.identifier, "csid", - CAM_HW_IDENTIFIER_LENGTH); - cpas_register_param.cell_index = soc_info->index; - cpas_register_param.dev = soc_info->dev; - rc = cam_cpas_register_client(&cpas_register_param); - if (rc) { - CAM_ERR(CAM_ISP, "CPAS registration failed rc=%d", rc); - goto release_soc; - } else { - soc_private->cpas_handle = cpas_register_param.client_handle; - } - - return rc; - -release_soc: - cam_soc_util_release_platform_resource(soc_info); -free_soc_private: - kfree(soc_private); - - return rc; -} - -int ais_ife_csid_deinit_soc_resources( - struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - struct ais_csid_soc_private *soc_private; - - soc_private = soc_info->soc_private; - if (!soc_private) { - CAM_ERR(CAM_ISP, "Error soc_private NULL"); - return -ENODEV; - } - - rc = cam_cpas_unregister_client(soc_private->cpas_handle); - if (rc) - CAM_ERR(CAM_ISP, "CPAS unregistration failed rc=%d", rc); - - rc = cam_soc_util_release_platform_resource(soc_info); - - return rc; -} - -int ais_ife_csid_enable_soc_resources( - struct cam_hw_soc_info *soc_info, enum cam_vote_level clk_level) -{ - int rc = 0; - struct ais_csid_soc_private *soc_private; - struct cam_ahb_vote ahb_vote; - struct cam_axi_vote axi_vote; - - soc_private = soc_info->soc_private; - - rc = cam_soc_util_enable_platform_resource(soc_info, true, - clk_level, true); - if (rc) { - CAM_ERR(CAM_ISP, "enable platform failed"); - goto end; - } - - ahb_vote.type = CAM_VOTE_ABSOLUTE; - ahb_vote.vote.level = CAM_SVS_VOTE; - axi_vote.compressed_bw = CAM_CPAS_DEFAULT_AXI_BW; - axi_vote.compressed_bw_ab = CAM_CPAS_DEFAULT_AXI_BW; - axi_vote.uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW; - - CAM_DBG(CAM_ISP, "csid vote compressed_bw:%lld uncompressed_bw:%lld", - axi_vote.compressed_bw, axi_vote.uncompressed_bw); - - rc = cam_cpas_start(soc_private->cpas_handle, &ahb_vote, &axi_vote); - if (rc) { - CAM_ERR(CAM_ISP, "Error CPAS start failed"); - rc = -EFAULT; - goto disable_platform_resource; - } - goto end; - -disable_platform_resource: - if (cam_soc_util_disable_platform_resource(soc_info, true, true)) - CAM_ERR(CAM_ISP, "Disable platform resource failed"); - -end: - return rc; -} - -int ais_ife_csid_disable_soc_resources(struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - struct ais_csid_soc_private *soc_private; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error Invalid params"); - return -EINVAL; - } - soc_private = soc_info->soc_private; - - rc = cam_soc_util_disable_platform_resource(soc_info, true, true); - if (rc) - CAM_ERR(CAM_ISP, "Disable platform failed"); - - rc = cam_cpas_stop(soc_private->cpas_handle); - if (rc) { - CAM_ERR(CAM_ISP, "Error CPAS stop failed rc=%d", rc); - return rc; - } - - return rc; -} - -int ais_ife_csid_enable_ife_force_clock_on(struct cam_hw_soc_info *soc_info, - uint32_t cpas_ife_base_offset) -{ - int rc = 0; - struct ais_csid_soc_private *soc_private; - uint32_t cpass_ife_force_clk_offset; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error Invalid params"); - return -EINVAL; - } - - soc_private = soc_info->soc_private; - cpass_ife_force_clk_offset = - cpas_ife_base_offset + (0x4 * soc_info->index); - rc = cam_cpas_reg_write(soc_private->cpas_handle, CAM_CPAS_REG_CPASTOP, - cpass_ife_force_clk_offset, 1, 1); - - if (rc) - CAM_ERR(CAM_ISP, "CPASS set IFE:%d Force clock On failed", - soc_info->index); - else - CAM_DBG(CAM_ISP, "CPASS set IFE:%d Force clock On", - soc_info->index); - - return rc; -} - -int ais_ife_csid_disable_ife_force_clock_on(struct cam_hw_soc_info *soc_info, - uint32_t cpas_ife_base_offset) -{ - int rc = 0; - struct ais_csid_soc_private *soc_private; - uint32_t cpass_ife_force_clk_offset; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error Invalid params"); - return -EINVAL; - } - - soc_private = soc_info->soc_private; - cpass_ife_force_clk_offset = - cpas_ife_base_offset + (0x4 * soc_info->index); - rc = cam_cpas_reg_write(soc_private->cpas_handle, CAM_CPAS_REG_CPASTOP, - cpass_ife_force_clk_offset, 1, 0); - - if (rc) - CAM_ERR(CAM_ISP, "CPASS set IFE:%d Force clock Off failed", - soc_info->index); - else - CAM_DBG(CAM_ISP, "CPASS set IFE:%d Force clock off", - soc_info->index); - - return rc; -} diff --git a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.h b/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.h deleted file mode 100755 index 1a06fa41f5e9..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/csid_hw/ais_ife_csid_soc.h +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright (c) 2017-2018, 2020 The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_IFE_CSID_SOC_H_ -#define _AIS_IFE_CSID_SOC_H_ - -#include "ais_isp_hw.h" - -/* - * struct ais_csid_soc_private: - * - * @Brief: Private SOC data specific to CSID HW Driver - * - * @cpas_handle: Handle returned on registering with CPAS driver. - * This handle is used for all further interface - * with CPAS. - */ -struct ais_csid_soc_private { - uint32_t cpas_handle; -}; - -/** - * struct csid_device_soc_info - CSID SOC info object - * - * @csi_vdd_voltage: csi vdd voltage value - * - */ -struct csid_device_soc_info { - int csi_vdd_voltage; -}; - -/** - * ais_ife_csid_init_soc_resources() - * - * @brief: csid initialization function for the soc info - * - * @soc_info: soc info structure pointer - * @csid_irq_handler: irq handler function to be registered - * @irq_data: irq data for the callback function - * - */ -int ais_ife_csid_init_soc_resources(struct cam_hw_soc_info *soc_info, - irq_handler_t csid_irq_handler, void *irq_data); - - -/** - * ais_ife_csid_deinit_soc_resources() - * - * @brief: csid de initialization function for the soc info - * - * @soc_info: soc info structure pointer - * - */ -int ais_ife_csid_deinit_soc_resources(struct cam_hw_soc_info *soc_info); - -/** - * ais_ife_csid_enable_soc_resources() - * - * @brief: csid soc resource enable function - * - * @soc_info: soc info structure pointer - * @clk_lvl: vote level to start with - * - */ -int ais_ife_csid_enable_soc_resources(struct cam_hw_soc_info *soc_info, - uint32_t clk_lvl); - -/** - * ais_ife_csid_disable_soc_resources() - * - * @brief: csid soc resource disable function - * - * @soc_info: soc info structure pointer - * - */ -int ais_ife_csid_disable_soc_resources(struct cam_hw_soc_info *soc_info); - -/** - * ais_ife_csid_enable_ife_force_clock() - * - * @brief: if csid testgen used for dual isp case, before - * starting csid test gen, enable ife force clock on - * through cpas - * - * @soc_info: soc info structure pointer - * @cpas_ife_base_offset: cpas ife force clock base reg offset value - * - */ -int ais_ife_csid_enable_ife_force_clock_on(struct cam_hw_soc_info *soc_info, - uint32_t cpas_ife_base_offset); - -/** - * ais_ife_csid_disable_ife_force_clock_on() - * - * @brief: disable the IFE force clock on after dual ISP - * CSID test gen stop - * - * @soc_info: soc info structure pointer - * @cpas_ife_base_offset: cpas ife force clock base reg offset value - * - */ -int ais_ife_csid_disable_ife_force_clock_on(struct cam_hw_soc_info *soc_info, - uint32_t cpas_ife_base_offset); - -/** - * ais_ife_csid_get_vote_level() - * - * @brief: get the vote level from clock rate - * - * @soc_info: soc info structure pointer - * @clock_rate clock rate - * - */ -uint32_t ais_ife_csid_get_vote_level(struct cam_hw_soc_info *soc_info, - uint64_t clock_rate); - -#endif diff --git a/drivers/media/platform/msm/ais/ais_isp/include/ais_ife_csid_hw_intf.h b/drivers/media/platform/msm/ais/ais_isp/include/ais_ife_csid_hw_intf.h deleted file mode 100755 index 78d25db59a25..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/include/ais_ife_csid_hw_intf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_CSID_HW_INTF_H_ -#define _AIS_CSID_HW_INTF_H_ - -#include "ais_isp_hw.h" -#include "cam_hw_intf.h" - -/* MAX IFE CSID instance */ -#define AIS_IFE_CSID_HW_NUM_MAX 8 - -/** - * enum ais_ife_cid_res_id - Specify the csid cid - */ -enum ais_ife_cid_res_id { - AIS_IFE_CSID_CID_0, - AIS_IFE_CSID_CID_1, - AIS_IFE_CSID_CID_2, - AIS_IFE_CSID_CID_3, - AIS_IFE_CSID_CID_MAX, -}; - -/** - * struct ais_ife_csid_hw_caps- get the CSID hw capability - * @num_rdis: number of rdis supported by CSID HW device - * @num_pix: number of pxl paths supported by CSID HW device - * @num_ppp: number of ppp paths supported by CSID HW device - * @major_version : major version - * @minor_version: minor version - * @version_incr: version increment - * - */ -struct ais_ife_csid_hw_caps { - uint32_t num_rdis; - uint32_t num_pix; - uint32_t num_ppp; - uint32_t major_version; - uint32_t minor_version; - uint32_t version_incr; -}; - -/** - * enum ais_ife_csid_halt_cmd - Specify the halt command type - */ -enum ais_ife_csid_halt_cmd { - AIS_CSID_HALT_AT_FRAME_BOUNDARY, - AIS_CSID_RESUME_AT_FRAME_BOUNDARY, - AIS_CSID_HALT_IMMEDIATELY, - AIS_CSID_HALT_MAX, -}; - -/** - * enum ais_ife_csid_reset_type - Specify the reset type - */ -enum ais_ife_csid_reset_type { - AIS_IFE_CSID_RESET_GLOBAL, - AIS_IFE_CSID_RESET_PATH, - AIS_IFE_CSID_RESET_MAX, -}; - -/** - * struct ais_ife_csid_reset_cfg- csid reset configuration - * @ reset_type : Global reset or path reset - * @res_node : resource need to be reset - * - */ -struct ais_csid_reset_cfg_args { - enum ais_ife_csid_reset_type reset_type; - enum ais_ife_output_path_id path; -}; - - -/** - * enum ais_ife_csid_cmd_type - Specify the csid command - */ -enum ais_ife_csid_cmd_type { - AIS_IFE_CSID_CMD_GET_TIME_STAMP, - AIS_IFE_CSID_SET_CSID_DEBUG, - AIS_IFE_CSID_SOF_IRQ_DEBUG, - AIS_IFE_CSID_SET_INIT_FRAME_DROP, - AIS_IFE_CSID_SET_SENSOR_DIMENSION_CFG, - AIS_IFE_CSID_CMD_MAX, -}; - -/** - * ais_ife_csid_hw_init() - * - * @brief: Initialize function for the CSID hardware - * - * @ife_csid_hw: CSID hardware instance returned - * @hw_idex: CSID hardware instance id - */ -int ais_ife_csid_hw_init(struct cam_hw_intf **ife_csid_hw, - struct ais_isp_hw_init_args *init); - -/* - * struct ais_ife_csid_clock_update_args: - * - * @clk_rate: Clock rate requested - */ -struct ais_ife_csid_clock_update_args { - uint64_t clk_rate; -}; - -#endif /* _AIS_CSID_HW_INTF_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/include/ais_isp_hw.h b/drivers/media/platform/msm/ais/ais_isp/include/ais_isp_hw.h deleted file mode 100755 index a6ac796674ec..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/include/ais_isp_hw.h +++ /dev/null @@ -1,528 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_ISP_HW_H_ -#define _AIS_ISP_HW_H_ - -#include -#include -#include "cam_hw.h" -#include "cam_hw_intf.h" -#include "cam_soc_util.h" - -/* cam_control handle_type for IFE device */ -#define AIS_ISP_CMD_TYPE 0xA151FE00 - -/* Maximum length of tag while dumping */ -#define AIS_ISP_HW_DUMP_TAG_MAX_LEN 32 - -/* - * struct ais_irq_register_set: - * @Brief: Structure containing offsets of IRQ related - * registers belonging to a Set - * - * @mask_reg_offset: Offset of IRQ MASK register - * @clear_reg_offset: Offset of IRQ CLEAR register - * @status_reg_offset: Offset of IRQ STATUS register - */ -struct ais_irq_register_set { - uint32_t mask_reg_offset; - uint32_t clear_reg_offset; - uint32_t status_reg_offset; -}; - -/* - * struct ais_irq_controller_reg_info: - * @Brief: Structure describing the IRQ registers - * - * @num_registers: Number of sets(mask/clear/status) of IRQ registers - * @irq_reg_set: Array of Register Set Offsets. - * Length of array = num_registers - * @global_clear_offset: Offset of Global IRQ Clear register. This register - * contains the BIT that needs to be set for the CLEAR - * to take effect - * @global_clear_bitmask: Bitmask needed to be used in Global Clear register - * for Clear IRQ cmd to take effect - */ -struct ais_irq_controller_reg_info { - uint32_t num_registers; - struct ais_irq_register_set *irq_reg_set; - uint32_t global_clear_offset; - uint32_t global_clear_bitmask; -}; - -/* - * struct ais_isp_timestamp: - * - * @mono_time: Monotonic boot time - * @vt_time: AV Timer time - * @ticks: Qtimer ticks - * @time_usecs: time in micro seconds - */ -struct ais_isp_timestamp { - struct timeval mono_time; - struct timeval vt_time; - uint64_t ticks; - uint64_t time_usecs; -}; - -/* - * ais_isp_hw_get_timestamp() - * - * @Brief: Get timestamp values - * - * @time_stamp: Structure that holds different time values - * - * @Return: Void - */ -void ais_isp_hw_get_timestamp(struct ais_isp_timestamp *time_stamp); - -enum ais_isp_hw_type { - AIS_ISP_HW_TYPE_CSID = 0, - AIS_ISP_HW_TYPE_ISPIF = 1, - AIS_ISP_HW_TYPE_VFE = 2, - AIS_ISP_HW_TYPE_IFE_CSID = 3, - AIS_ISP_HW_TYPE_MAX = 4, -}; - -enum ais_isp_resource_state { - AIS_ISP_RESOURCE_STATE_UNAVAILABLE = 0, - AIS_ISP_RESOURCE_STATE_AVAILABLE = 1, - AIS_ISP_RESOURCE_STATE_RESERVED = 2, - AIS_ISP_RESOURCE_STATE_INIT_HW = 3, - AIS_ISP_RESOURCE_STATE_STREAMING = 4, - AIS_ISP_RESOURCE_STATE_ERROR = 5 -}; - -enum ais_isp_hw_cmd_type { - AIS_ISP_HW_CMD_GET_CHANGE_BASE, - AIS_ISP_HW_CMD_GET_BUF_UPDATE, - AIS_ISP_HW_CMD_GET_BUF_UPDATE_RM, - AIS_ISP_HW_CMD_GET_REG_UPDATE, - AIS_ISP_HW_CMD_GET_HFR_UPDATE, - AIS_ISP_HW_CMD_GET_HFR_UPDATE_RM, - AIS_ISP_HW_CMD_GET_SECURE_MODE, - AIS_ISP_HW_CMD_STRIPE_UPDATE, - AIS_ISP_HW_CMD_CLOCK_UPDATE, - AIS_ISP_HW_CMD_BW_UPDATE, - AIS_ISP_HW_CMD_BW_CONTROL, - AIS_ISP_HW_CMD_STOP_BUS_ERR_IRQ, - AIS_ISP_HW_CMD_GET_REG_DUMP, - AIS_ISP_HW_CMD_UBWC_UPDATE, - AIS_ISP_HW_CMD_SOF_IRQ_DEBUG, - AIS_ISP_HW_CMD_SET_CAMIF_DEBUG, - AIS_ISP_HW_CMD_CSID_CLOCK_UPDATE, - AIS_ISP_HW_CMD_FE_UPDATE_IN_RD, - AIS_ISP_HW_CMD_FE_UPDATE_BUS_RD, - AIS_ISP_HW_CMD_GET_IRQ_REGISTER_DUMP, - AIS_ISP_HW_CMD_FPS_CONFIG, - AIS_ISP_HW_CMD_DUMP_HW, - AIS_ISP_HW_CMD_SET_STATS_DMI_DUMP, - AIS_ISP_HW_CMD_GET_RDI_IRQ_MASK, - AIS_ISP_HW_CMD_MAX, -}; - - -/* - * struct ais_isp_hw_cmd_buf_update: - * - * @Brief: Contain the new created command buffer information - * - * @cmd_buf_addr: Command buffer to store the change base command - * @size: Size of the buffer in bytes - * @used_bytes: Consumed bytes in the command buffer - * - */ -struct ais_isp_hw_cmd_buf_update { - uint32_t *cmd_buf_addr; - uint32_t size; - uint32_t used_bytes; -}; - -/* - * struct ais_isp_hw_get_wm_update: - * - * @Brief: Get cmd buffer for WM updates. - * - * @ image_buf: image buffer address array - * @ num_buf: Number of buffers in the image_buf array - * @ io_cfg: IO buffer config information sent from UMD - * - */ -struct ais_isp_hw_get_wm_update { - uint64_t *image_buf; - uint32_t num_buf; - struct cam_buf_io_cfg *io_cfg; -}; - -/* - * struct ais_isp_hw_rup_data: - * - * @Brief: RUP for required resources. - * - * @is_fe_enable if fetch engine enabled - * @res_bitmap resource bitmap for set resources - * - */ -struct ais_isp_hw_rup_data { - bool is_fe_enable; - unsigned long res_bitmap; -}; - -/* - * struct ais_isp_hw_get_cmd_update: - * - * @Brief: Get cmd buffer update for different CMD types - * - * @res: Resource node - * @cmd_type: Command type for which to get update - * @cmd: Command buffer information - * - */ -struct ais_isp_hw_get_cmd_update { - enum ais_isp_hw_cmd_type cmd_type; - union { - void *data; - }; -}; - -/* - * struct ais_isp_hw_dump_args: - * - * @Brief: isp hw dump args - * - * @ req_id: request id - * @ cpu_addr: cpu address - * @ buf_len: buf len - * @ offset: offset of buffer - * @ ctxt_to_hw_map: ctx to hw map - */ -struct ais_isp_hw_dump_args { - uint64_t req_id; - uintptr_t cpu_addr; - size_t buf_len; - uint32_t offset; - void *ctxt_to_hw_map; -}; - -/** - * struct ais_isp_hw_dump_header - ISP context dump header - * - * @Brief: isp hw dump header - * - * @tag: Tag name for the header - * @word_size: Size of word - * @size: Size of data - * - */ -struct ais_isp_hw_dump_header { - char tag[AIS_ISP_HW_DUMP_TAG_MAX_LEN]; - uint64_t size; - uint32_t word_size; -}; - - -/** - * enum ais_ife_output_path_id - * - * @brief output path IDs - */ -enum ais_ife_output_path_id { - AIS_IFE_PATH_RDI_0, - AIS_IFE_PATH_RDI_1, - AIS_IFE_PATH_RDI_2, - AIS_IFE_PATH_RDI_3, - AIS_IFE_PATH_MAX, -}; - -/** - * struct ais_ife_rdi_in_cfg - * - * @brief Input Configuration - * - * @format : format - * @width : width - * @height : height - * @crop_enable : is crop enabled - * @crop_top : crop top line - * @crop_bottom : crop bottom line - * @crop_left : crop left pixel - * @crop_right : crop right pixel - * @reserved - */ -struct ais_ife_rdi_in_cfg { - uint32_t format; - uint32_t decode_format; - uint32_t pack_type; - uint32_t width; - uint32_t height; - uint32_t crop_enable; - uint32_t crop_top; - uint32_t crop_bottom; - uint32_t crop_left; - uint32_t crop_right; - uint32_t init_frame_drop; - uint32_t reserved; -}; - -/** - * struct ais_ife_rdi_out_cfg - * - * @brief Output Configuration - * - * @format : format - * @secure_mode : Data Type - * @mode : line based or frame based - * @width : width - * @height : height - * @stride : stride - * @frame_increment : frame increment - * @frame_drop_pattern : framedrop pattern - * @frame_drop_period : framedrop period - * @reserved - */ -struct ais_ife_rdi_out_cfg { - uint32_t format; - uint32_t secure_mode; - uint32_t mode; - uint32_t width; - uint32_t height; - uint32_t stride; - uint32_t frame_increment; - uint32_t frame_drop_pattern; - uint32_t frame_drop_period; - uint32_t reserved; -}; - -/** - * struct ais_ife_csid_csi_info - * - * @brief CSI Configuration - * - * @csiphy_id : CSIPHY id - * @vc : Virtual Channel - * @dt : Data Type - * @num_lanes : Number of lanes - * @lane_assign : Lane mapping - * @is_3Phase : DPHY or CPHY - */ -struct ais_ife_csid_csi_info { - uint32_t csiphy_id; - uint32_t vc; - uint32_t dt; - uint32_t num_lanes; - uint32_t lane_assign; - uint32_t is_3Phase; -}; - -/** - * struct ais_ife_rdi_init_args - * - * @brief Iniit RDI path - * - * @path : output path - * @csi_cfg : CSI configuration - * @in_cfg : Input configuration - * @out_cfg : Output configuration - */ -struct ais_ife_rdi_init_args { - enum ais_ife_output_path_id path; - struct ais_ife_csid_csi_info csi_cfg; - struct ais_ife_rdi_in_cfg in_cfg; - struct ais_ife_rdi_out_cfg out_cfg; -}; - -/** - * struct ais_ife_rdi_deinit_args - * - * @brief Deinit RDI path - * - * @path : output path - */ -struct ais_ife_rdi_deinit_args { - enum ais_ife_output_path_id path; -}; - -/** - * struct ais_ife_rdi_stop_args - * - * @brief Start RDI path - * - * @path : output path - */ -struct ais_ife_rdi_start_args { - enum ais_ife_output_path_id path; -}; - -/** - * struct ais_ife_rdi_stop_args - * - * @brief Stop RDI path - * - * @path : output path - */ -struct ais_ife_rdi_stop_args { - enum ais_ife_output_path_id path; -}; - -/** - * struct ais_ife_enqueue_buffer_args - * - * @brief buffer definition for enqueue - * - * @mem_handle : allocated mem_handle - * @idx : buffer index used as identifier - * @offset : offset into buffer for hw to write to - */ -struct ais_ife_buffer_enqueue { - int32_t mem_handle; - uint32_t idx; - uint32_t offset; -}; - -/** - * struct ais_ife_enqueue_buffer_args - * - * @brief Enqueue buffer command argument - * - * @path : output path to enqueue to - * @buffer : image buffer - * @buffer_header : frame header buffer - */ -struct ais_ife_enqueue_buffer_args { - enum ais_ife_output_path_id path; - struct ais_ife_buffer_enqueue buffer; - struct ais_ife_buffer_enqueue buffer_header; -}; - -/** - * struct ais_ife_rdi_timestamps - * - * @brief : timestamps for RDI path - * - * @cur_sof_ts : current SOF time stamp - * @prev_sof_ts : previous SOF time stamp - */ -struct ais_ife_rdi_timestamps { - uint64_t cur_sof_ts; - uint64_t prev_sof_ts; -}; - -/** - * struct ais_ife_rdi_get_timestamp_args - * - * @brief : time stamp capture arguments - * - * @path : output path to get the time stamp - * @ts : timestamps - */ -struct ais_ife_rdi_get_timestamp_args { - enum ais_ife_output_path_id path; - struct ais_ife_rdi_timestamps *ts; -}; - -/** - * struct ais_ife_sof_msg - * - * @brief SOF event message - * - * @hw_ts : HW timestamp - * @frame_id : frame count - */ -struct ais_ife_sof_msg { - uint64_t hw_ts; - uint32_t frame_id; -}; - -/** - * struct ais_ife_error_msg - * - * @brief Error event message - * - * @reserved : payload information - */ -struct ais_ife_error_msg { - uint32_t reserved; -}; - -/** - * struct ais_ife_frame_msg - * - * @brief Frame done event message - * - * @hw_ts : SOF HW timestamp - * @ts : SOF timestamp - * @frame_id : frame count - * @buf_idx : buffer index - */ -struct ais_ife_frame_msg { - uint64_t hw_ts; - uint64_t ts; - uint32_t frame_id; - uint32_t buf_idx; -}; - -/** - * enum ais_ife_msg_type - * - * @brief event message type - */ -enum ais_ife_msg_type { - AIS_IFE_MSG_SOF, - AIS_IFE_MSG_FRAME_DONE, - AIS_IFE_MSG_OUTPUT_WARNING, - AIS_IFE_MSG_OUTPUT_ERROR, - AIS_IFE_MSG_CSID_WARNING, - AIS_IFE_MSG_CSID_ERROR -}; - -/** - * struct ais_ife_frame_msg - * - * @brief Frame done event message - * - * @type : message type - * @idx : IFE idx - * @path : input/output path - * @reserved: reserved for alignment - * @reserved1: reserved for alignment - * @boot_ts : event timestamp - * @u : event message - */ -struct ais_ife_event_data { - uint8_t type; - uint8_t idx; - uint8_t path; - uint8_t reserved; - uint32_t reserved1; - uint64_t boot_ts; - union { - struct ais_ife_sof_msg sof_msg; - struct ais_ife_error_msg err_msg; - struct ais_ife_frame_msg frame_msg; - } u; -}; - -/* hardware event callback function type */ -typedef int (*ais_ife_event_cb_func)(void *priv, - struct ais_ife_event_data *evt_data); - - -struct ais_isp_hw_init_args { - uint32_t hw_idx; - int iommu_hdl; - int iommu_hdl_secure; - ais_ife_event_cb_func event_cb; - void *event_cb_priv; -}; - -#endif /* _AIS_ISP_HW_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/include/ais_vfe_hw_intf.h b/drivers/media/platform/msm/ais/ais_isp/include/ais_vfe_hw_intf.h deleted file mode 100755 index 888add3086b1..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/include/ais_vfe_hw_intf.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_HW_INTF_H_ -#define _AIS_VFE_HW_INTF_H_ - -#include "ais_isp_hw.h" - -#define AIS_VFE_HW_NUM_MAX 8 - -#define VFE_CORE_BASE_IDX 0 -/* - * VBIF and BUS do not exist on same HW. - * Hence both can be 1 below. - */ -#define VFE_VBIF_BASE_IDX 1 -#define VFE_BUS_BASE_IDX 1 - -enum ais_vfe_hw_cmd_type { - AIS_VFE_CMD_ENQ_BUFFER = 0 -}; - -enum ais_vfe_hw_irq_status { - AIS_VFE_IRQ_STATUS_ERR_COMP = -3, - AIS_VFE_IRQ_STATUS_COMP_OWRT = -2, - AIS_VFE_IRQ_STATUS_ERR = -1, - AIS_VFE_IRQ_STATUS_SUCCESS = 0, - AIS_VFE_IRQ_STATUS_OVERFLOW = 1, - AIS_VFE_IRQ_STATUS_P2I_ERROR = 2, - AIS_VFE_IRQ_STATUS_VIOLATION = 3, - AIS_VFE_IRQ_STATUS_MAX, -}; - -enum ais_vfe_hw_irq_regs { - CAM_IFE_IRQ_CAMIF_REG_STATUS0 = 0, - CAM_IFE_IRQ_CAMIF_REG_STATUS1 = 1, - CAM_IFE_IRQ_VIOLATION_STATUS = 2, - CAM_IFE_IRQ_REGISTERS_MAX, -}; - -enum ais_vfe_bus_irq_regs { - CAM_IFE_IRQ_BUS_REG_STATUS0 = 0, - CAM_IFE_IRQ_BUS_REG_STATUS1 = 1, - CAM_IFE_IRQ_BUS_REG_STATUS2 = 2, - CAM_IFE_IRQ_BUS_REG_COMP_ERR = 3, - CAM_IFE_IRQ_BUS_REG_COMP_OWRT = 4, - CAM_IFE_IRQ_BUS_DUAL_COMP_ERR = 5, - CAM_IFE_IRQ_BUS_DUAL_COMP_OWRT = 6, - CAM_IFE_BUS_IRQ_REGISTERS_MAX, -}; - -enum ais_vfe_reset_type { - AIS_VFE_HW_RESET_HW_AND_REG, - AIS_VFE_HW_RESET_HW, - AIS_VFE_HW_RESET_MAX, -}; - -/** - * struct ais_vfe_hw_evt_payload- handle vfe error - * @hw_idx : Hw index of vfe - * @evt_type : Event type from VFE - */ -struct ais_vfe_hw_evt_payload { - uint32_t hw_idx; - uint32_t evt_type; -}; - -/* - * struct ais_vfe_hw_get_hw_cap: - * - * @max_width: Max width supported by HW - * @max_height: Max height supported by HW - * @max_pixel_num: Max Pixel channels available - * @max_rdi_num: Max Raw channels available - */ -struct ais_vfe_hw_get_hw_cap { - uint32_t max_width; - uint32_t max_height; - uint32_t max_pixel_num; - uint32_t max_rdi_num; -}; - -/* - * ais_vfe_hw_init() - * - * @Brief: Initialize VFE HW device - * - * @vfe_hw: vfe_hw interface to fill in and return on - * successful initialization - * @hw_idx: Index of VFE HW - */ -int ais_vfe_hw_init(struct cam_hw_intf **vfe_hw, - struct ais_isp_hw_init_args *init, - struct cam_hw_intf *csid_hw); - - -#endif /* _AIS_VFE_HW_INTF_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/utils/Makefile b/drivers/media/platform/msm/ais/ais_isp/utils/Makefile deleted file mode 100755 index bada56e9bf98..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/utils/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_core -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/include -ccflags-y += -Idrivers/media/platform/msm/ais/cam_req_mgr -ccflags-y += -Idrivers/media/platform/msm/ais/cam_smmu/ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_sync -ccflags-y += -Idrivers/media/platform/msm/ais/cam_utils -ccflags-y += -Idrivers/media/platform/msm/ais/cam_cdm/ - -obj-$(CONFIG_MSM_AIS) += ais_isp_trace.o diff --git a/drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.c b/drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.c deleted file mode 100755 index 59590995762f..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -/* Instantiate tracepoints */ -#define CREATE_TRACE_POINTS - -#include -#include - -#include "ais_isp_trace.h" - -static uint debug_trace; -module_param(debug_trace, uint, 0644); - -void ais_trace_print(char c, int value, const char *fmt, ...) -{ - if (debug_trace) { - char str_buffer[256]; - va_list args; - - va_start(args, fmt); - vsnprintf(str_buffer, 256, fmt, args); - - trace_ais_tracing_mark_write(c, current, str_buffer, value); - va_end(args); - } -} - diff --git a/drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.h b/drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.h deleted file mode 100755 index 00f2116124b3..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/utils/ais_isp_trace.h +++ /dev/null @@ -1,259 +0,0 @@ -/* Copyright (c) 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#if !defined(_AIS_ISP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) -#define _AIS_ISP_TRACE_H - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM camera -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE ais_isp_trace - -#include -#include -#include "ais_isp_hw.h" - -TRACE_EVENT(ais_isp_vfe_irq_activated, - TP_PROTO(uint8_t id, uint32_t status0, uint32_t status1), - TP_ARGS(id, status0, status1), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint32_t, status0) - __field(uint32_t, status1) - ), - TP_fast_assign( - __entry->id = id; - __entry->status0 = status0; - __entry->status1 = status1; - ), - TP_printk( - "vfe%d: irq 0x%08x 0x%08x", - __entry->id, - __entry->status0, __entry->status1 - ) -); - -TRACE_EVENT(ais_isp_irq_process, - TP_PROTO(uint8_t id, uint8_t evt, uint8_t state), - TP_ARGS(id, evt, state), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, evt) - __field(uint8_t, state) - ), - TP_fast_assign( - __entry->id = id; - __entry->evt = evt; - __entry->state = state; - ), - TP_printk( - "vfe%d: irq event %d (%d)", - __entry->id, __entry->evt, __entry->state - ) -); - -TRACE_EVENT(ais_isp_vfe_state, - TP_PROTO(uint8_t id, uint8_t path, uint8_t state), - TP_ARGS(id, path, state), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint8_t, state) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->state = state; - ), - TP_printk( - "vfe%d:%d: state %d", - __entry->id, __entry->path, __entry->state - ) -); - -TRACE_EVENT(ais_isp_vfe_sof, - TP_PROTO(uint8_t id, uint8_t path, struct ais_ife_rdi_timestamps *ts, - uint32_t fifo, uint32_t miss), - TP_ARGS(id, path, ts, fifo, miss), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint32_t, fifo) - __field(uint32_t, miss) - __field(uint64_t, ts_cur) - __field(uint64_t, ts_prev) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->fifo = fifo; - __entry->miss = miss; - __entry->ts_cur = ts->cur_sof_ts; - __entry->ts_prev = ts->prev_sof_ts; - ), - TP_printk( - "vfe%d:%d: sof %llu %llu fifo %u miss %u", - __entry->id, __entry->path, __entry->ts_cur, __entry->ts_prev, - __entry->fifo, __entry->miss - ) -); - -TRACE_EVENT(ais_isp_vfe_q_sof, - TP_PROTO(uint8_t id, uint8_t path, uint32_t frame, uint64_t ts), - TP_ARGS(id, path, frame, ts), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint32_t, frame) - __field(uint64_t, ts) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->frame = frame; - __entry->ts = ts; - ), - TP_printk( - "vfe%d:%d: sof %d %llu", - __entry->id, __entry->path, __entry->frame, __entry->ts - ) -); - -TRACE_EVENT(ais_isp_vfe_buf_done, - TP_PROTO(uint8_t id, uint8_t path, uint8_t idx, uint32_t frame, - uint8_t fifo, uint8_t match), - TP_ARGS(id, path, idx, frame, fifo, match), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint8_t, idx) - __field(uint32_t, frame) - __field(uint8_t, fifo) - __field(uint8_t, match) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->idx = idx; - __entry->frame = frame; - __entry->fifo = fifo; - __entry->match = match; - ), - TP_printk( - "vfe%d:%d: buf_done %d (%d fifo %d match %d)", - __entry->id, __entry->path, __entry->idx, __entry->frame, - __entry->fifo, __entry->match - ) -); - -TRACE_EVENT(ais_isp_vfe_enq_buf_hw, - TP_PROTO(uint8_t id, uint8_t path, uint8_t idx, - uint8_t fifo, uint8_t full), - TP_ARGS(id, path, idx, fifo, full), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint8_t, idx) - __field(uint8_t, fifo) - __field(uint8_t, full) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->idx = idx; - __entry->fifo = fifo; - __entry->full = full; - ), - TP_printk( - "vfe%d:%d: enq buf hw %d fifo %d full %d", - __entry->id, __entry->path, __entry->idx, - __entry->fifo, __entry->full - ) -); - -TRACE_EVENT(ais_isp_vfe_enq_req, - TP_PROTO(uint8_t id, uint8_t path, uint8_t idx), - TP_ARGS(id, path, idx), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint8_t, idx) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->idx = idx; - ), - TP_printk( - "vfe%d:%d: enq req %d", - __entry->id, __entry->path, __entry->idx - ) -); - -TRACE_EVENT(ais_isp_vfe_error, - TP_PROTO(uint8_t id, uint8_t path, uint8_t err, uint8_t payload), - TP_ARGS(id, path, err, payload), - TP_STRUCT__entry( - __field(uint8_t, id) - __field(uint8_t, path) - __field(uint8_t, err) - __field(uint8_t, payload) - ), - TP_fast_assign( - __entry->id = id; - __entry->path = path; - __entry->err = err; - __entry->payload = payload; - ), - TP_printk( - "vfe%d:%d: error %d %d", - __entry->id, __entry->path, __entry->err, __entry->payload - ) -); - -TRACE_EVENT(ais_tracing_mark_write, - TP_PROTO(char trace_type, const struct task_struct *task, - const char *name, int value), - TP_ARGS(trace_type, task, name, value), - TP_STRUCT__entry( - __field(char, trace_type) - __field(int, pid) - __string(trace_name, name) - __field(int, value) - ), - TP_fast_assign( - __entry->trace_type = trace_type; - __entry->pid = task ? task->tgid : 0; - __assign_str(trace_name, name); - __entry->value = value; - ), - TP_printk("%c|%d|%s|%d", __entry->trace_type, - __entry->pid, __get_str(trace_name), __entry->value) -); - -void ais_trace_print(char c, int value, const char *fmt, ...); - -#define AIS_ATRACE_BEGIN(fmt, args...) ais_trace_print('B', 0, fmt, ##args) - -#define AIS_ATRACE_END(fmt, args...) ais_trace_print('E', 0, fmt, ##args) - -#define AIS_ATRACE_INT(value, fmt, args...) \ - ais_trace_print('C', value, fmt, ##args) - - -#endif /* _AIS_ISP_TRACE_H */ - -/* This part must be outside protection */ -#include diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/Makefile b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/Makefile deleted file mode 100755 index 81e5b8b88dcd..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_utils -ccflags-y += -Idrivers/media/platform/msm/ais/cam_core -ccflags-y += -Idrivers/media/platform/msm/ais/cam_cpas/include -ccflags-y += -Idrivers/media/platform/msm/ais/cam_smmu/ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_req_mgr/ -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/utils -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top - -obj-$(CONFIG_MSM_AIS) += ais_vfe_soc.o ais_vfe_dev.o ais_vfe_core.o -obj-$(CONFIG_MSM_AIS) += vfe17x/ \ No newline at end of file diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.c b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.c deleted file mode 100755 index 60249b88868e..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.c +++ /dev/null @@ -1,1698 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include "cam_mem_mgr_api.h" -#include "cam_req_mgr_workq.h" -#include "ais_vfe_soc.h" -#include "ais_vfe_core.h" -#include "cam_debug_util.h" -#include "ais_isp_trace.h" - -/*VFE TOP DEFINITIONS*/ -#define AIS_VFE_HW_RESET_HW_AND_REG_VAL 0x00003F9F -#define AIS_VFE_HW_RESET_HW_VAL 0x00003F87 - -#define AIS_VFE_IRQ_CMD 0x58 -#define AIS_VFE_IRQ_MASK0 0x5C -#define AIS_VFE_IRQ_MASK1 0x60 -#define AIS_VFE_IRQ_CLEAR0 0x64 -#define AIS_VFE_IRQ_CLEAR1 0x68 -#define AIS_VFE_IRQ_STATUS0 0x6C -#define AIS_VFE_IRQ_STATUS1 0x70 - -#define AIS_VFE_STATUS0_RDI_SOF_IRQ_SHFT 27 -#define AIS_VFE_STATUS0_RDI_SOF_IRQ_MSK 0xF -#define AIS_VFE_STATUS0_RDI_REGUP_IRQ_SHFT 5 -#define AIS_VFE_STATUS0_RDI_REGUP_IRQ_MSK 0xF -#define AIS_VFE_STATUS1_RDI_OVERFLOW_IRQ_SHFT 2 -#define AIS_VFE_STATUS1_RDI_OVERFLOW_IRQ_MSK 0xF - -#define AIS_VFE_MASK0_RDI 0x780001E0 -#define AIS_VFE_MASK1_RDI 0x000000BC - -#define AIS_VFE_STATUS0_BUS_WR_IRQ (1 << 9) -#define AIS_VFE_STATUS0_RDI_SOF_IRQ (0xF << AIS_VFE_STATUS0_RDI_SOF_IRQ_SHFT) -#define AIS_VFE_STATUS0_RDI_OVERFLOW_IRQ \ - (0xF << AIS_VFE_STATUS1_RDI_OVERFLOW_IRQ_SHFT) -#define AIS_VFE_STATUS0_RESET_ACK_IRQ (1 << 31) - -#define AIS_VFE_REGUP_RDI_SHIFT 1 -#define AIS_VFE_REGUP_RDI_ALL 0x1E - -/*Allow max of 4 HW FIFO Q + 2 delayed buffers before error*/ -#define MAX_NUM_BUF_SW_FIFOQ_ERR 6 - -/*VFE BUS DEFINITIONS*/ -#define AIS_VFE_BUS_SET_DEBUG_REG 0x82 - -#define AIS_VFE_RDI_BUS_DEFAULT_WIDTH 0xFF01 -#define AIS_VFE_RDI_BUS_DEFAULT_STRIDE 0xFF01 - -#define AIS_VFE_BUS_INTRA_CLIENT_MASK 0x3 -#define AIS_VFE_BUS_ADDR_SYNC_INTRA_CLIENT_SHIFT 8 -#define AIS_VFE_BUS_VER2_MAX_CLIENTS 24 -#define AIS_VFE_BUS_ADDR_NO_SYNC_DEFAULT_VAL \ - ((1 << AIS_VFE_BUS_VER2_MAX_CLIENTS) - 1) - - -static void ais_clear_rdi_path(struct ais_vfe_rdi_output *rdi_path) -{ - int i; - - rdi_path->frame_cnt = 0; - - rdi_path->num_buffer_hw_q = 0; - INIT_LIST_HEAD(&rdi_path->buffer_q); - INIT_LIST_HEAD(&rdi_path->buffer_hw_q); - INIT_LIST_HEAD(&rdi_path->free_buffer_list); - for (i = 0; i < AIS_VFE_MAX_BUF; i++) { - INIT_LIST_HEAD(&rdi_path->buffers[i].list); - list_add_tail(&rdi_path->buffers[i].list, - &rdi_path->free_buffer_list); - } - - memset(&rdi_path->last_sof_info, 0, sizeof(rdi_path->last_sof_info)); - - rdi_path->num_sof_info_q = 0; - INIT_LIST_HEAD(&rdi_path->sof_info_q); - INIT_LIST_HEAD(&rdi_path->free_sof_info_list); - for (i = 0; i < AIS_VFE_MAX_SOF_INFO; i++) { - INIT_LIST_HEAD(&rdi_path->sof_info[i].list); - list_add_tail(&rdi_path->sof_info[i].list, - &rdi_path->free_sof_info_list); - } -} - -static int ais_vfe_bus_hw_init(struct ais_vfe_hw_core_info *core_info) -{ - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - - /*set IRQ mask for BUS WR*/ - core_info->irq_mask0 |= AIS_VFE_STATUS0_BUS_WR_IRQ; - cam_io_w_mb(core_info->irq_mask0, - core_info->mem_base + AIS_VFE_IRQ_MASK0); - - cam_io_w_mb(0x7801, - core_info->mem_base + bus_hw_irq_regs[0].mask_reg_offset); - cam_io_w_mb(0x0, - core_info->mem_base + bus_hw_irq_regs[1].mask_reg_offset); - cam_io_w_mb(0x0, - core_info->mem_base + bus_hw_irq_regs[2].mask_reg_offset); - - /*Set Debug Registers*/ - cam_io_w_mb(AIS_VFE_BUS_SET_DEBUG_REG, core_info->mem_base + - bus_hw_info->common_reg.debug_status_cfg); - - /* BUS_WR_INPUT_IF_ADDR_SYNC_FRAME_HEADER */ - cam_io_w_mb(0x0, core_info->mem_base + - bus_hw_info->common_reg.addr_sync_frame_hdr); - - /* no clock gating at bus input */ - cam_io_w_mb(0xFFFFF, core_info->mem_base + 0x0000200C); - - /* BUS_WR_TEST_BUS_CTRL */ - cam_io_w_mb(0x0, core_info->mem_base + 0x0000211C); - - /* if addr_no_sync has default value then config the addr no sync reg */ - cam_io_w_mb(AIS_VFE_BUS_ADDR_NO_SYNC_DEFAULT_VAL, - core_info->mem_base + - bus_hw_info->common_reg.addr_sync_no_sync); - - return 0; -} - -static int ais_vfe_bus_hw_deinit(struct ais_vfe_hw_core_info *core_info) -{ - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - - /*set IRQ mask for BUS WR*/ - core_info->irq_mask0 &= ~AIS_VFE_STATUS0_BUS_WR_IRQ; - - cam_io_w_mb(0x7800, - core_info->mem_base + bus_hw_irq_regs[0].mask_reg_offset); - cam_io_w_mb(0x0, - core_info->mem_base + bus_hw_irq_regs[1].mask_reg_offset); - cam_io_w_mb(0x0, - core_info->mem_base + bus_hw_irq_regs[2].mask_reg_offset); - - return 0; -} - -int ais_vfe_get_hw_caps(void *hw_priv, void *get_hw_cap_args, uint32_t arg_size) -{ - struct cam_hw_info *vfe_dev = hw_priv; - struct ais_vfe_hw_core_info *core_info = NULL; - int rc = 0; - - CAM_DBG(CAM_ISP, "Enter"); - if (!hw_priv) { - CAM_ERR(CAM_ISP, "Invalid arguments"); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_dev->core_info; - - CAM_WARN(CAM_ISP, "VFE%d get_hw_caps not implemented", - core_info->vfe_idx); - - rc = -EPERM; - - CAM_DBG(CAM_ISP, "Exit"); - return rc; -} - -static int ais_vfe_reset(void *hw_priv, - void *reset_core_args, uint32_t arg_size) -{ - struct cam_hw_info *vfe_hw = hw_priv; - struct cam_hw_soc_info *soc_info = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - struct ais_vfe_top_ver2_hw_info *top_hw_info = NULL; - uint32_t *reset_reg_args = reset_core_args; - uint32_t reset_reg_val; - int rc = 0; - int i; - - CAM_DBG(CAM_ISP, "Enter"); - - if (!hw_priv) { - CAM_ERR(CAM_ISP, "Invalid input arguments"); - return -EINVAL; - } - - switch (*reset_reg_args) { - case AIS_VFE_HW_RESET_HW_AND_REG: - reset_reg_val = AIS_VFE_HW_RESET_HW_AND_REG_VAL; - break; - default: - reset_reg_val = AIS_VFE_HW_RESET_HW_VAL; - break; - } - - soc_info = &vfe_hw->soc_info; - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - top_hw_info = core_info->vfe_hw_info->top_hw_info; - - cam_io_w_mb(AIS_VFE_STATUS0_RESET_ACK_IRQ, - core_info->mem_base + AIS_VFE_IRQ_MASK0); - cam_io_w_mb(0x0, core_info->mem_base + AIS_VFE_IRQ_MASK1); - - reinit_completion(&vfe_hw->hw_complete); - - CAM_DBG(CAM_ISP, "calling RESET on vfe %d", soc_info->index); - - /* Reset HW */ - cam_io_w_mb(reset_reg_val, - core_info->mem_base + - top_hw_info->common_reg->global_reset_cmd); - - CAM_DBG(CAM_ISP, "waiting for vfe reset complete"); - - /* Wait for Completion or Timeout of 500ms */ - rc = wait_for_completion_timeout(&vfe_hw->hw_complete, - msecs_to_jiffies(500)); - if (rc) { - rc = 0; - } else { - CAM_ERR(CAM_ISP, "Error! Reset Timeout"); - rc = EFAULT; - } - - CAM_DBG(CAM_ISP, "reset complete done (%d)", rc); - - core_info->irq_mask0 = 0x0; - cam_io_w_mb(0x0, core_info->mem_base + AIS_VFE_IRQ_MASK0); - - for (i = 0; i < AIS_IFE_PATH_MAX; i++) - ais_clear_rdi_path(&core_info->rdi_out[i]); - - CAM_DBG(CAM_ISP, "Exit"); - return rc; -} - -int ais_vfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size) -{ - struct cam_hw_info *vfe_hw = hw_priv; - struct cam_hw_soc_info *soc_info = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - int rc = 0; - uint32_t reset_core_args = AIS_VFE_HW_RESET_HW_AND_REG; - - CAM_DBG(CAM_ISP, "Enter"); - if (!hw_priv) { - CAM_ERR(CAM_ISP, "Invalid arguments"); - return -EINVAL; - } - - mutex_lock(&vfe_hw->hw_mutex); - vfe_hw->open_count++; - if (vfe_hw->open_count > 1) { - mutex_unlock(&vfe_hw->hw_mutex); - CAM_DBG(CAM_ISP, "VFE has already been initialized cnt %d", - vfe_hw->open_count); - return 0; - } - mutex_unlock(&vfe_hw->hw_mutex); - - soc_info = &vfe_hw->soc_info; - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - - /* Turn ON Regulators, Clocks and other SOC resources */ - rc = ais_vfe_enable_soc_resources(soc_info); - if (rc) { - CAM_ERR(CAM_ISP, "Enable SOC failed"); - rc = -EFAULT; - goto decrement_open_cnt; - } - - CAM_DBG(CAM_ISP, "Enable soc done"); - - /* Do HW Reset */ - rc = ais_vfe_reset(hw_priv, &reset_core_args, sizeof(uint32_t)); - if (rc) { - CAM_ERR(CAM_ISP, "Reset Failed rc=%d", rc); - goto disable_soc; - } - - rc = ais_vfe_bus_hw_init(core_info); - if (rc) { - CAM_ERR(CAM_ISP, "Reset Failed rc=%d", rc); - goto disable_soc; - } - - vfe_hw->hw_state = CAM_HW_STATE_POWER_UP; - return rc; - -disable_soc: - ais_vfe_disable_soc_resources(soc_info); -decrement_open_cnt: - mutex_lock(&vfe_hw->hw_mutex); - vfe_hw->open_count--; - mutex_unlock(&vfe_hw->hw_mutex); - return rc; -} - -int ais_vfe_deinit_hw(void *hw_priv, void *deinit_hw_args, uint32_t arg_size) -{ - struct cam_hw_info *vfe_hw = hw_priv; - struct cam_hw_soc_info *soc_info = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - int rc = 0; - uint32_t reset_core_args = - AIS_VFE_HW_RESET_HW_AND_REG; - - CAM_DBG(CAM_ISP, "Enter"); - if (!hw_priv) { - CAM_ERR(CAM_ISP, "Invalid arguments"); - return -EINVAL; - } - - mutex_lock(&vfe_hw->hw_mutex); - if (!vfe_hw->open_count) { - mutex_unlock(&vfe_hw->hw_mutex); - CAM_ERR(CAM_ISP, "Error! Unbalanced deinit"); - return -EFAULT; - } - vfe_hw->open_count--; - if (vfe_hw->open_count) { - mutex_unlock(&vfe_hw->hw_mutex); - CAM_DBG(CAM_ISP, "open_cnt non-zero =%d", vfe_hw->open_count); - return 0; - } - mutex_unlock(&vfe_hw->hw_mutex); - - soc_info = &vfe_hw->soc_info; - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - - rc = ais_vfe_bus_hw_deinit(core_info); - if (rc) - CAM_ERR(CAM_ISP, "Bus HW deinit Failed rc=%d", rc); - - rc = ais_vfe_reset(hw_priv, &reset_core_args, sizeof(uint32_t)); - - /* Turn OFF Regulators, Clocks and other SOC resources */ - CAM_DBG(CAM_ISP, "Disable SOC resource"); - rc = ais_vfe_disable_soc_resources(soc_info); - if (rc) - CAM_ERR(CAM_ISP, "Disable SOC failed"); - - vfe_hw->hw_state = CAM_HW_STATE_POWER_DOWN; - - CAM_DBG(CAM_ISP, "Exit"); - return rc; -} - -int ais_vfe_force_reset(void *hw_priv, void *reset_core_args, uint32_t arg_size) -{ - struct cam_hw_info *vfe_hw = hw_priv; - bool require_deinit = false; - int rc = 0; - - mutex_lock(&vfe_hw->hw_mutex); - if (vfe_hw->open_count) { - vfe_hw->open_count = 1; - require_deinit = true; - - } - mutex_unlock(&vfe_hw->hw_mutex); - - if (require_deinit) { - CAM_INFO(CAM_ISP, "vfe deinit HW"); - rc = ais_vfe_deinit_hw(vfe_hw, NULL, 0); - } - - CAM_DBG(CAM_ISP, "Exit (%d)", rc); - - return rc; -} - -void ais_isp_hw_get_timestamp(struct ais_isp_timestamp *time_stamp) -{ - struct timespec ts; - - get_monotonic_boottime(&ts); - time_stamp->mono_time.tv_sec = ts.tv_sec; - time_stamp->mono_time.tv_usec = ts.tv_nsec/1000; - time_stamp->time_usecs = ts.tv_sec * 1000000 + - time_stamp->mono_time.tv_usec; -} - - -int ais_vfe_reserve(void *hw_priv, void *reserve_args, uint32_t arg_size) -{ - struct ais_vfe_hw_core_info *core_info = NULL; - struct cam_hw_info *vfe_hw = hw_priv; - struct ais_vfe_rdi_output *rdi_path = NULL; - struct ais_ife_rdi_init_args *rdi_cfg; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - int rc = 0; - - if (!hw_priv || !reserve_args || (arg_size != - sizeof(struct ais_ife_rdi_init_args))) { - CAM_ERR(CAM_ISP, "Invalid input arguments"); - return -EINVAL; - } - - rdi_cfg = (struct ais_ife_rdi_init_args *)reserve_args; - if (rdi_cfg->path >= AIS_IFE_PATH_MAX) { - CAM_ERR(CAM_ISP, "Invalid output path %d", rdi_cfg->path); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - rdi_path = &core_info->rdi_out[rdi_cfg->path]; - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - client_regs = &bus_hw_info->bus_client_reg[rdi_cfg->path]; - - CAM_DBG(CAM_ISP, "Config RDI%d", rdi_cfg->path); - - mutex_lock(&vfe_hw->hw_mutex); - - if (rdi_path->state >= AIS_ISP_RESOURCE_STATE_INIT_HW) { - CAM_ERR(CAM_ISP, "RDI%d invalid state %d", rdi_cfg->path, - rdi_path->state); - rc = -EINVAL; - goto EXIT; - } - - rdi_path->secure_mode = rdi_cfg->out_cfg.secure_mode; - - cam_io_w(0xf, core_info->mem_base + client_regs->burst_limit); - /*disable pack as it is done in CSID*/ - cam_io_w(0x0, core_info->mem_base + client_regs->packer_cfg); - - /*frame based mode*/ - if (rdi_cfg->out_cfg.mode == 1) { - cam_io_w_mb(AIS_VFE_RDI_BUS_DEFAULT_WIDTH, - core_info->mem_base + client_regs->buffer_width_cfg); - cam_io_w(0x0, - core_info->mem_base + client_regs->buffer_height_cfg); - cam_io_w_mb(AIS_VFE_RDI_BUS_DEFAULT_STRIDE, - core_info->mem_base + client_regs->stride); - cam_io_w_mb(0x0, - core_info->mem_base + client_regs->frame_inc); - rdi_path->en_cfg = 0x3; - - } else { - cam_io_w_mb(rdi_cfg->out_cfg.width, - core_info->mem_base + client_regs->buffer_width_cfg); - cam_io_w(rdi_cfg->out_cfg.height, - core_info->mem_base + client_regs->buffer_height_cfg); - cam_io_w_mb(rdi_cfg->out_cfg.stride, - core_info->mem_base + client_regs->stride); - cam_io_w_mb(rdi_cfg->out_cfg.frame_increment, - core_info->mem_base + client_regs->frame_inc); - rdi_path->en_cfg = 0x1; - } - - cam_io_w_mb(rdi_cfg->out_cfg.frame_drop_period, - core_info->mem_base + client_regs->framedrop_period); - cam_io_w_mb(rdi_cfg->out_cfg.frame_drop_pattern, - core_info->mem_base + client_regs->framedrop_pattern); - - rdi_path->state = AIS_ISP_RESOURCE_STATE_INIT_HW; - -EXIT: - mutex_unlock(&vfe_hw->hw_mutex); - - return rc; -} - - -int ais_vfe_release(void *hw_priv, void *release_args, uint32_t arg_size) -{ - struct ais_vfe_hw_core_info *core_info = NULL; - struct cam_hw_info *vfe_hw = hw_priv; - struct ais_vfe_rdi_output *rdi_path = NULL; - struct ais_ife_rdi_deinit_args *deinit_cmd; - - int rc = 0; - - if (!hw_priv || !release_args || - (arg_size != sizeof(struct ais_ife_rdi_deinit_args))) { - CAM_ERR(CAM_ISP, "Invalid input arguments"); - return -EINVAL; - } - - deinit_cmd = (struct ais_ife_rdi_deinit_args *)release_args; - - if (deinit_cmd->path >= AIS_IFE_PATH_MAX) { - CAM_ERR(CAM_ISP, "Invalid output path %d", deinit_cmd->path); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - rdi_path = &core_info->rdi_out[deinit_cmd->path]; - - mutex_lock(&vfe_hw->hw_mutex); - - if (rdi_path->state < AIS_ISP_RESOURCE_STATE_INIT_HW) { - CAM_ERR(CAM_ISP, "RDI%d invalid state %d", deinit_cmd->path, - rdi_path->state); - rc = -EINVAL; - goto EXIT; - } - - rdi_path->state = AIS_ISP_RESOURCE_STATE_AVAILABLE; - -EXIT: - mutex_unlock(&vfe_hw->hw_mutex); - - return rc; -} - - -int ais_vfe_start(void *hw_priv, void *start_args, uint32_t arg_size) -{ - struct ais_vfe_hw_core_info *core_info = NULL; - struct cam_hw_info *vfe_hw = hw_priv; - struct ais_ife_rdi_start_args *start_cmd; - struct ais_vfe_rdi_output *rdi_path; - struct ais_vfe_top_ver2_hw_info *top_hw_info = NULL; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - int rc = 0; - - if (!hw_priv || !start_args || - (arg_size != sizeof(struct ais_ife_rdi_start_args))) { - CAM_ERR(CAM_ISP, "Invalid input arguments"); - return -EINVAL; - } - - start_cmd = (struct ais_ife_rdi_start_args *)start_args; - if (start_cmd->path >= AIS_IFE_PATH_MAX) { - CAM_ERR(CAM_ISP, "Invalid output path %d", start_cmd->path); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - rdi_path = &core_info->rdi_out[start_cmd->path]; - top_hw_info = core_info->vfe_hw_info->top_hw_info; - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - client_regs = &bus_hw_info->bus_client_reg[start_cmd->path]; - - mutex_lock(&vfe_hw->hw_mutex); - - if (rdi_path->state != AIS_ISP_RESOURCE_STATE_INIT_HW) { - CAM_ERR(CAM_ISP, "RDI%d invalid state %d", start_cmd->path, - rdi_path->state); - rc = -EINVAL; - goto EXIT; - } - - /*Enable bus WR mask*/ - core_info->bus_wr_mask1 |= (1 << start_cmd->path); - cam_io_w_mb(core_info->bus_wr_mask1, - core_info->mem_base + bus_hw_irq_regs[1].mask_reg_offset); - - /*Update VFE mask*/ - core_info->irq_mask0 |= AIS_VFE_MASK0_RDI; - core_info->irq_mask1 |= AIS_VFE_MASK1_RDI; - cam_io_w_mb(core_info->irq_mask0, - core_info->mem_base + AIS_VFE_IRQ_MASK0); - cam_io_w_mb(core_info->irq_mask1, - core_info->mem_base + AIS_VFE_IRQ_MASK1); - - /* Enable WM and reg-update*/ - cam_io_w_mb(rdi_path->en_cfg, core_info->mem_base + client_regs->cfg); - cam_io_w_mb(AIS_VFE_REGUP_RDI_ALL, core_info->mem_base + - top_hw_info->common_reg->reg_update_cmd); - - rdi_path->state = AIS_ISP_RESOURCE_STATE_STREAMING; - -EXIT: - mutex_unlock(&vfe_hw->hw_mutex); - - return rc; -} - -int ais_vfe_stop(void *hw_priv, void *stop_args, uint32_t arg_size) -{ - struct ais_vfe_hw_core_info *core_info = NULL; - struct cam_hw_info *vfe_hw = hw_priv; - struct ais_ife_rdi_stop_args *stop_cmd; - struct ais_vfe_rdi_output *rdi_path; - struct ais_vfe_top_ver2_hw_info *top_hw_info = NULL; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - int rc = 0; - - if (!hw_priv || !stop_args || - (arg_size != sizeof(struct ais_ife_rdi_stop_args))) { - CAM_ERR(CAM_ISP, "Invalid input arguments"); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - stop_cmd = (struct ais_ife_rdi_stop_args *)stop_args; - - if (stop_cmd->path >= AIS_IFE_PATH_MAX) { - CAM_ERR(CAM_ISP, "Invalid output path %d", stop_cmd->path); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - rdi_path = &core_info->rdi_out[stop_cmd->path]; - top_hw_info = core_info->vfe_hw_info->top_hw_info; - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - client_regs = &bus_hw_info->bus_client_reg[stop_cmd->path]; - - mutex_lock(&vfe_hw->hw_mutex); - - if (rdi_path->state != AIS_ISP_RESOURCE_STATE_STREAMING && - rdi_path->state != AIS_ISP_RESOURCE_STATE_ERROR) { - CAM_ERR(CAM_ISP, "RDI%d invalid state %d", stop_cmd->path, - rdi_path->state); - rc = -EINVAL; - goto EXIT; - } - - rdi_path->state = AIS_ISP_RESOURCE_STATE_INIT_HW; - - core_info->bus_wr_mask1 &= ~(1 << stop_cmd->path); - cam_io_w_mb(core_info->bus_wr_mask1, - core_info->mem_base + bus_hw_irq_regs[1].mask_reg_offset); - - /* Disable WM and reg-update */ - cam_io_w_mb(0x0, core_info->mem_base + client_regs->cfg); - cam_io_w_mb(AIS_VFE_REGUP_RDI_ALL, core_info->mem_base + - top_hw_info->common_reg->reg_update_cmd); - - /* issue bus wr reset and wait for reset ack */ - reinit_completion(&vfe_hw->hw_complete); - - cam_io_w_mb((1 << stop_cmd->path), core_info->mem_base + - bus_hw_info->common_reg.sw_reset); - - /* Wait for completion or timeout of 50ms */ - rc = wait_for_completion_timeout(&vfe_hw->hw_complete, - msecs_to_jiffies(50)); - if (rc) - rc = 0; - else - CAM_WARN(CAM_ISP, "Reset Bus WR timeout"); - - ais_clear_rdi_path(rdi_path); - -EXIT: - mutex_unlock(&vfe_hw->hw_mutex); - - return rc; -} - -int ais_vfe_read(void *hw_priv, void *read_args, uint32_t arg_size) -{ - return -EPERM; -} - -int ais_vfe_write(void *hw_priv, void *write_args, uint32_t arg_size) -{ - return -EPERM; -} - -static void ais_vfe_q_bufs_to_hw(struct ais_vfe_hw_core_info *core_info, - enum ais_ife_output_path_id path) -{ - struct ais_vfe_rdi_output *rdi_path = NULL; - struct ais_vfe_buffer_t *vfe_buf = NULL; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - uint32_t fifo_status = 0; - bool is_full = false; - struct ais_ife_rdi_get_timestamp_args get_ts; - - rdi_path = &core_info->rdi_out[path]; - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - client_regs = &bus_hw_info->bus_client_reg[path]; - - fifo_status = cam_io_r_mb(core_info->mem_base + - bus_hw_info->common_reg.addr_fifo_status); - - is_full = fifo_status & (1 << path); - - while (!is_full) { - if (list_empty(&rdi_path->buffer_q)) - break; - - vfe_buf = list_first_entry(&rdi_path->buffer_q, - struct ais_vfe_buffer_t, list); - list_del_init(&vfe_buf->list); - - get_ts.path = path; - get_ts.ts = &vfe_buf->ts_hw; - core_info->csid_hw->hw_ops.process_cmd( - core_info->csid_hw->hw_priv, - AIS_IFE_CSID_CMD_GET_TIME_STAMP, - &get_ts, - sizeof(get_ts)); - - - CAM_DBG(CAM_ISP, "IFE%d|RDI%d: Q %d(0x%x) FIFO:%d ts %llu", - core_info->vfe_idx, path, - vfe_buf->bufIdx, vfe_buf->iova_addr, - rdi_path->num_buffer_hw_q, vfe_buf->ts_hw.cur_sof_ts); - - cam_io_w_mb(vfe_buf->iova_addr, - core_info->mem_base + client_regs->image_addr); - - list_add_tail(&vfe_buf->list, &rdi_path->buffer_hw_q); - ++rdi_path->num_buffer_hw_q; - - - fifo_status = cam_io_r_mb(core_info->mem_base + - bus_hw_info->common_reg.addr_fifo_status); - is_full = fifo_status & (1 << path); - - trace_ais_isp_vfe_enq_buf_hw(core_info->vfe_idx, path, - vfe_buf->bufIdx, rdi_path->num_buffer_hw_q, is_full); - } - - if (rdi_path->num_buffer_hw_q > MAX_NUM_BUF_SW_FIFOQ_ERR) - CAM_WARN(CAM_ISP, "Excessive number of buffers in SW FIFO (%d)", - rdi_path->num_buffer_hw_q); -} - - -static int ais_vfe_cmd_enq_buf(struct ais_vfe_hw_core_info *core_info, - struct ais_ife_enqueue_buffer_args *enq_buf) -{ - int rc; - struct ais_vfe_buffer_t *vfe_buf = NULL; - struct ais_vfe_rdi_output *rdi_path = NULL; - int32_t mmu_hdl; - size_t src_buf_size; - - if (enq_buf->path >= AIS_IFE_PATH_MAX) { - CAM_ERR(CAM_ISP, "Invalid output path %d", enq_buf->path); - rc = -EINVAL; - goto EXIT; - } - - rdi_path = &core_info->rdi_out[enq_buf->path]; - if (rdi_path->state < AIS_ISP_RESOURCE_STATE_RESERVED) { - CAM_ERR(CAM_ISP, "RDI%d invalid state %d", enq_buf->path, - rdi_path->state); - rc = -EINVAL; - goto EXIT; - } - - spin_lock(&rdi_path->buffer_lock); - if (!list_empty(&rdi_path->free_buffer_list)) { - vfe_buf = list_first_entry(&rdi_path->free_buffer_list, - struct ais_vfe_buffer_t, list); - list_del_init(&vfe_buf->list); - } - spin_unlock(&rdi_path->buffer_lock); - - if (!vfe_buf) { - CAM_ERR(CAM_ISP, "RDI%d No more free buffers!", enq_buf->path); - return -ENOMEM; - } - - vfe_buf->bufIdx = enq_buf->buffer.idx; - vfe_buf->mem_handle = enq_buf->buffer.mem_handle; - - mmu_hdl = core_info->iommu_hdl; - - if (cam_mem_is_secure_buf(vfe_buf->mem_handle) || rdi_path->secure_mode) - mmu_hdl = core_info->iommu_hdl_secure; - - rc = cam_mem_get_io_buf(vfe_buf->mem_handle, - mmu_hdl, &vfe_buf->iova_addr, &src_buf_size); - if (rc < 0) { - CAM_ERR(CAM_ISP, - "get src buf address fail mem_handle 0x%x", - vfe_buf->mem_handle); - } - if (vfe_buf->iova_addr >> 32) { - CAM_ERR(CAM_ISP, "Invalid mapped address"); - rc = -EINVAL; - } - - if (enq_buf->buffer.offset >= src_buf_size) { - CAM_ERR(CAM_ISP, "Invalid buffer offset"); - rc = -EINVAL; - } - - //if any error, return buffer list object to being free - if (rc) { - spin_lock(&rdi_path->buffer_lock); - list_add_tail(&vfe_buf->list, &rdi_path->free_buffer_list); - spin_unlock(&rdi_path->buffer_lock); - } else { - //add offset - vfe_buf->iova_addr += enq_buf->buffer.offset; - - spin_lock(&rdi_path->buffer_lock); - - trace_ais_isp_vfe_enq_req(core_info->vfe_idx, enq_buf->path, - enq_buf->buffer.idx); - - list_add_tail(&vfe_buf->list, &rdi_path->buffer_q); - - if (rdi_path->state < AIS_ISP_RESOURCE_STATE_STREAMING) - ais_vfe_q_bufs_to_hw(core_info, enq_buf->path); - - spin_unlock(&rdi_path->buffer_lock); - } - -EXIT: - return rc; -} - -int ais_vfe_process_cmd(void *hw_priv, uint32_t cmd_type, - void *cmd_args, uint32_t arg_size) -{ - struct cam_hw_info *vfe_hw = hw_priv; - struct cam_hw_soc_info *soc_info = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - struct ais_vfe_hw_info *hw_info = NULL; - int rc = 0; - - if (!hw_priv) { - CAM_ERR(CAM_ISP, "Invalid arguments"); - return -EINVAL; - } - - soc_info = &vfe_hw->soc_info; - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - hw_info = core_info->vfe_hw_info; - - mutex_lock(&vfe_hw->hw_mutex); - - switch (cmd_type) { - case AIS_VFE_CMD_ENQ_BUFFER: { - struct ais_ife_enqueue_buffer_args *enq_buf = - (struct ais_ife_enqueue_buffer_args *)cmd_args; - if (arg_size != sizeof(*enq_buf)) - rc = -EINVAL; - else - rc = ais_vfe_cmd_enq_buf(core_info, enq_buf); - break; - } - default: - CAM_ERR(CAM_ISP, "Invalid cmd type:%d", cmd_type); - rc = -EINVAL; - break; - } - - mutex_unlock(&vfe_hw->hw_mutex); - - return rc; -} - -static uint8_t ais_vfe_get_num_missed_sof( - uint64_t cur_sof, - uint64_t prev_sof, - uint64_t last_sof, - uint64_t ts_delta) -{ - uint8_t miss_sof = 0; - - if (prev_sof == last_sof) { - miss_sof = 0; - } else if (prev_sof < last_sof) { - //rollover case - miss_sof = (int)(((U64_MAX - last_sof) + prev_sof + 1 + - ts_delta/2) / ts_delta); - } else { - miss_sof = (int)((prev_sof - last_sof + ts_delta/2) / ts_delta); - } - - return miss_sof; -} - -static int ais_vfe_q_sof(struct ais_vfe_hw_core_info *core_info, - enum ais_ife_output_path_id path, - struct ais_sof_info_t *p_sof) -{ - struct ais_vfe_rdi_output *p_rdi = &core_info->rdi_out[path]; - struct ais_sof_info_t *p_sof_info = NULL; - int rc = 0; - - if (!list_empty(&p_rdi->free_sof_info_list)) { - p_sof_info = list_first_entry(&p_rdi->free_sof_info_list, - struct ais_sof_info_t, list); - list_del_init(&p_sof_info->list); - p_sof_info->frame_cnt = p_sof->frame_cnt; - p_sof_info->sof_ts = p_sof->sof_ts; - p_sof_info->cur_sof_hw_ts = p_sof->cur_sof_hw_ts; - p_sof_info->prev_sof_hw_ts = p_sof->prev_sof_hw_ts; - list_add_tail(&p_sof_info->list, &p_rdi->sof_info_q); - p_rdi->num_sof_info_q++; - - trace_ais_isp_vfe_q_sof(core_info->vfe_idx, path, - p_sof->frame_cnt, p_sof->cur_sof_hw_ts); - - CAM_DBG(CAM_ISP, "I%d|R%d|F%llu: sof %llu", - core_info->vfe_idx, path, p_sof->frame_cnt, - p_sof_info->cur_sof_hw_ts); - } else { - rc = -1; - - CAM_ERR(CAM_ISP, - "I%d|R%d|F%llu: free timestamp empty (%d) sof %llu", - core_info->vfe_idx, path, p_sof->frame_cnt, - p_rdi->num_buffer_hw_q, p_sof->cur_sof_hw_ts); - } - - return rc; -} - - -static void ais_vfe_handle_sof_rdi(struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_work_data *work_data, - enum ais_ife_output_path_id path) -{ - struct ais_vfe_rdi_output *p_rdi = &core_info->rdi_out[path]; - uint64_t cur_sof_hw_ts = work_data->ts_hw[path].cur_sof_ts; - uint64_t prev_sof_hw_ts = work_data->ts_hw[path].prev_sof_ts; - - p_rdi->frame_cnt++; - - if (p_rdi->num_buffer_hw_q) { - struct ais_sof_info_t sof = {}; - uint64_t ts_delta; - uint8_t miss_sof = 0; - - if (cur_sof_hw_ts < prev_sof_hw_ts) - ts_delta = cur_sof_hw_ts + - (U64_MAX - prev_sof_hw_ts); - else - ts_delta = cur_sof_hw_ts - prev_sof_hw_ts; - - - //check any missing SOFs - if (p_rdi->frame_cnt > 1) { - if (ts_delta == 0) { - CAM_ERR(CAM_ISP, "IFE%d RDI%d ts_delta is 0", - core_info->vfe_idx, path); - } else { - miss_sof = ais_vfe_get_num_missed_sof( - cur_sof_hw_ts, - prev_sof_hw_ts, - p_rdi->last_sof_info.cur_sof_hw_ts, - ts_delta); - - CAM_DBG(CAM_ISP, - "I%d R%d miss_sof %u prev %llu last %llu cur %llu", - core_info->vfe_idx, path, - miss_sof, prev_sof_hw_ts, - p_rdi->last_sof_info.cur_sof_hw_ts, - cur_sof_hw_ts); - } - } - - trace_ais_isp_vfe_sof(core_info->vfe_idx, path, - &work_data->ts_hw[path], - p_rdi->num_buffer_hw_q, miss_sof); - - if (p_rdi->frame_cnt == 1 && prev_sof_hw_ts != 0) { - //enq missed first frame - sof.sof_ts = work_data->ts; - sof.cur_sof_hw_ts = prev_sof_hw_ts; - sof.frame_cnt = p_rdi->frame_cnt++; - - ais_vfe_q_sof(core_info, path, &sof); - } else if (miss_sof > 0) { - if (miss_sof > 1) { - int i = 0; - int miss_idx = miss_sof - 1; - - for (i = 0; i < (miss_sof - 1); i++) { - - sof.sof_ts = work_data->ts; - sof.cur_sof_hw_ts = prev_sof_hw_ts - - (ts_delta * miss_idx); - sof.frame_cnt = p_rdi->frame_cnt++; - - ais_vfe_q_sof(core_info, path, &sof); - - miss_idx--; - } - } - - //enq prev - sof.sof_ts = work_data->ts; - sof.cur_sof_hw_ts = prev_sof_hw_ts; - sof.frame_cnt = p_rdi->frame_cnt++; - - ais_vfe_q_sof(core_info, path, &sof); - } - - //enq curr - sof.sof_ts = work_data->ts; - sof.cur_sof_hw_ts = cur_sof_hw_ts; - sof.frame_cnt = p_rdi->frame_cnt; - - ais_vfe_q_sof(core_info, path, &sof); - - } else { - trace_ais_isp_vfe_sof(core_info->vfe_idx, path, - &work_data->ts_hw[path], - p_rdi->num_buffer_hw_q, 0); - - CAM_DBG(CAM_ISP, "I%d R%d Flush SOF (%d) HW Q empty", - core_info->vfe_idx, path, - p_rdi->num_sof_info_q); - - if (p_rdi->num_sof_info_q) { - struct ais_sof_info_t *p_sof_info; - - while (!list_empty(&p_rdi->sof_info_q)) { - p_sof_info = list_first_entry( - &p_rdi->sof_info_q, - struct ais_sof_info_t, list); - list_del_init(&p_sof_info->list); - list_add_tail(&p_sof_info->list, - &p_rdi->free_sof_info_list); - } - p_rdi->num_sof_info_q = 0; - } - - trace_ais_isp_vfe_error(core_info->vfe_idx, - path, 1, 0); - - //send warning - core_info->event.type = AIS_IFE_MSG_OUTPUT_WARNING; - core_info->event.path = path; - core_info->event.u.err_msg.reserved = 0; - - core_info->event_cb(core_info->event_cb_priv, - &core_info->event); - - } - - p_rdi->last_sof_info.cur_sof_hw_ts = cur_sof_hw_ts; - - //send sof only for current frame - core_info->event.type = AIS_IFE_MSG_SOF; - core_info->event.path = path; - core_info->event.u.sof_msg.frame_id = p_rdi->frame_cnt; - core_info->event.u.sof_msg.hw_ts = cur_sof_hw_ts; - - core_info->event_cb(core_info->event_cb_priv, - &core_info->event); - -} - -static int ais_vfe_handle_sof( - struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_work_data *work_data) -{ - struct ais_vfe_rdi_output *p_rdi; - int path = 0; - int rc = 0; - - CAM_DBG(CAM_ISP, "IFE%d SOF RDIs 0x%x", core_info->vfe_idx, - work_data->path); - - for (path = 0; path < AIS_IFE_PATH_MAX; path++) { - - if (!(work_data->path & (1 << path))) - continue; - - p_rdi = &core_info->rdi_out[path]; - if (p_rdi->state != AIS_ISP_RESOURCE_STATE_STREAMING) - continue; - - AIS_ATRACE_BEGIN("SOF_%u_%u_%lu", - core_info->vfe_idx, path, p_rdi->frame_cnt); - ais_vfe_handle_sof_rdi(core_info, work_data, path); - AIS_ATRACE_END("SOF_%u_%u_%lu", - core_info->vfe_idx, path, p_rdi->frame_cnt); - - //enq buffers - spin_lock_bh(&p_rdi->buffer_lock); - ais_vfe_q_bufs_to_hw(core_info, path); - spin_unlock_bh(&p_rdi->buffer_lock); - } - - return rc; -} - -static int ais_vfe_handle_error( - struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_work_data *work_data) -{ - struct ais_vfe_top_ver2_hw_info *top_hw_info = NULL; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - struct ais_vfe_rdi_output *p_rdi; - int path = 0; - int rc = 0; - - CAM_ERR(CAM_ISP, "IFE%d ERROR on RDIs 0x%x", core_info->vfe_idx, - work_data->path); - - trace_ais_isp_vfe_error(core_info->vfe_idx, - work_data->path, 0, 0); - - top_hw_info = core_info->vfe_hw_info->top_hw_info; - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - - for (path = 0; path < AIS_IFE_PATH_MAX; path++) { - - if (!(work_data->path & (1 << path))) - continue; - - p_rdi = &core_info->rdi_out[path]; - - if (p_rdi->state != AIS_ISP_RESOURCE_STATE_STREAMING) - continue; - - CAM_ERR(CAM_ISP, "IFE%d Turn off RDI %d", - core_info->vfe_idx, path); - - p_rdi->state = AIS_ISP_RESOURCE_STATE_ERROR; - - client_regs = &bus_hw_info->bus_client_reg[path]; - - core_info->bus_wr_mask1 &= ~(1 << path); - cam_io_w_mb(core_info->bus_wr_mask1, - core_info->mem_base + - bus_hw_irq_regs[1].mask_reg_offset); - - /* Disable WM and reg-update */ - cam_io_w_mb(0x0, core_info->mem_base + client_regs->cfg); - cam_io_w_mb(AIS_VFE_REGUP_RDI_ALL, core_info->mem_base + - top_hw_info->common_reg->reg_update_cmd); - - cam_io_w_mb((1 << path), core_info->mem_base + - bus_hw_info->common_reg.sw_reset); - - - core_info->event.type = AIS_IFE_MSG_OUTPUT_ERROR; - core_info->event.path = path; - - core_info->event_cb(core_info->event_cb_priv, - &core_info->event); - } - - return rc; -} - -static void ais_vfe_bus_handle_client_frame_done( - struct ais_vfe_hw_core_info *core_info, - enum ais_ife_output_path_id path, - uint32_t last_addr) -{ - struct ais_vfe_rdi_output *rdi_path = NULL; - struct ais_vfe_buffer_t *vfe_buf = NULL; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - uint64_t frame_cnt = 0; - uint64_t sof_ts; - uint64_t cur_sof_hw_ts; - bool last_addr_match = false; - - - CAM_DBG(CAM_ISP, "I%d|R%d last_addr 0x%x", - core_info->vfe_idx, path, last_addr); - - if (last_addr == 0) { - CAM_ERR(CAM_ISP, "I%d|R%d null last_addr", - core_info->vfe_idx, path); - return; - } - - rdi_path = &core_info->rdi_out[path]; - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - - core_info->event.type = AIS_IFE_MSG_FRAME_DONE; - core_info->event.path = path; - - while (rdi_path->num_buffer_hw_q && !last_addr_match) { - struct ais_sof_info_t *p_sof_info = NULL; - bool is_sof_match = false; - - if (list_empty(&rdi_path->buffer_hw_q)) { - CAM_DBG(CAM_ISP, "I%d|R%d: FD while HW Q empty", - core_info->vfe_idx, path); - break; - } - - vfe_buf = list_first_entry(&rdi_path->buffer_hw_q, - struct ais_vfe_buffer_t, list); - list_del_init(&vfe_buf->list); - --rdi_path->num_buffer_hw_q; - - if (last_addr == vfe_buf->iova_addr) - last_addr_match = true; - else - CAM_WARN(CAM_ISP, "IFE%d buf %d did not match addr", - core_info->vfe_idx, vfe_buf->bufIdx); - - CAM_DBG(CAM_ISP, "I%d|R%d BUF DQ %d (0x%x) FIFO:%d|0x%x", - core_info->vfe_idx, path, - vfe_buf->bufIdx, vfe_buf->iova_addr, - rdi_path->num_buffer_hw_q, last_addr); - - if (!list_empty(&rdi_path->sof_info_q)) { - while (!is_sof_match && - !list_empty(&rdi_path->sof_info_q)) { - p_sof_info = - list_first_entry(&rdi_path->sof_info_q, - struct ais_sof_info_t, list); - list_del_init(&p_sof_info->list); - rdi_path->num_sof_info_q--; - if (p_sof_info->cur_sof_hw_ts > - vfe_buf->ts_hw.cur_sof_ts) { - is_sof_match = true; - break; - } - list_add_tail(&p_sof_info->list, - &rdi_path->free_sof_info_list); - } - - if (!is_sof_match) { - p_sof_info = NULL; - CAM_ERR(CAM_ISP, - "I%d|R%d: can't find the match sof", - core_info->vfe_idx, path); - } - - } else - CAM_ERR(CAM_ISP, "I%d|R%d: SOF info Q is empty", - core_info->vfe_idx, path); - - if (p_sof_info) { - frame_cnt = p_sof_info->frame_cnt; - sof_ts = p_sof_info->sof_ts; - cur_sof_hw_ts = p_sof_info->cur_sof_hw_ts; - list_add_tail(&p_sof_info->list, - &rdi_path->free_sof_info_list); - } else { - frame_cnt = sof_ts = cur_sof_hw_ts = 0; - } - - CAM_DBG(CAM_ISP, "I%d|R%d|F%llu: si [%llu, %llu, %llu]", - core_info->vfe_idx, path, frame_cnt, sof_ts, - cur_sof_hw_ts); - - - trace_ais_isp_vfe_buf_done(core_info->vfe_idx, path, - vfe_buf->bufIdx, - frame_cnt, - rdi_path->num_buffer_hw_q, - last_addr_match); - - core_info->event.u.frame_msg.frame_id = frame_cnt; - core_info->event.u.frame_msg.buf_idx = vfe_buf->bufIdx; - core_info->event.u.frame_msg.ts = sof_ts; - core_info->event.u.frame_msg.hw_ts = cur_sof_hw_ts; - - core_info->event_cb(core_info->event_cb_priv, - &core_info->event); - - - list_add_tail(&vfe_buf->list, &rdi_path->free_buffer_list); - } - - if (!last_addr_match) { - CAM_ERR(CAM_ISP, "IFE%d BUF| RDI%d NO MATCH addr 0x%x", - core_info->vfe_idx, path, last_addr); - - trace_ais_isp_vfe_error(core_info->vfe_idx, path, 1, 1); - - //send warning - core_info->event.type = AIS_IFE_MSG_OUTPUT_WARNING; - core_info->event.path = path; - core_info->event.u.err_msg.reserved = 1; - - core_info->event_cb(core_info->event_cb_priv, - &core_info->event); - } - - /* Flush SOF info Q if HW Buffer Q is empty */ - if (rdi_path->num_buffer_hw_q == 0) { - struct ais_sof_info_t *p_sof_info = NULL; - - CAM_DBG(CAM_ISP, "I%d|R%d|F%llu: Flush SOF (%d) HW Q empty", - core_info->vfe_idx, path, frame_cnt, - rdi_path->num_sof_info_q); - - while (!list_empty(&rdi_path->sof_info_q)) { - p_sof_info = list_first_entry(&rdi_path->sof_info_q, - struct ais_sof_info_t, list); - list_del_init(&p_sof_info->list); - list_add_tail(&p_sof_info->list, - &rdi_path->free_sof_info_list); - } - - rdi_path->num_sof_info_q = 0; - - trace_ais_isp_vfe_error(core_info->vfe_idx, path, 1, 0); - - //send warning - core_info->event.type = AIS_IFE_MSG_OUTPUT_WARNING; - core_info->event.path = path; - core_info->event.u.err_msg.reserved = 0; - - core_info->event_cb(core_info->event_cb_priv, - &core_info->event); - } - - spin_lock_bh(&rdi_path->buffer_lock); - - ais_vfe_q_bufs_to_hw(core_info, path); - - spin_unlock_bh(&rdi_path->buffer_lock); -} - -static int ais_vfe_bus_handle_frame_done( - struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_work_data *work_data) -{ - struct ais_vfe_rdi_output *p_rdi = &core_info->rdi_out[0]; - uint32_t client_mask = work_data->bus_wr_status[1]; - uint32_t client; - int rc = 0; - - CAM_DBG(CAM_ISP, "VFE%d Frame Done clients 0x%x", - core_info->vfe_idx, client_mask); - - for (client = 0 ; client < AIS_IFE_PATH_MAX; client++) { - p_rdi = &core_info->rdi_out[client]; - - if (p_rdi->state != AIS_ISP_RESOURCE_STATE_STREAMING) - continue; - - if (client_mask & (0x1 << client)) { - //process frame done - AIS_ATRACE_BEGIN("FD_%u_%u_%lu", - core_info->vfe_idx, client, p_rdi->frame_cnt); - ais_vfe_bus_handle_client_frame_done(core_info, - client, work_data->last_addr[client]); - AIS_ATRACE_END("FD_%u_%u_%lu", - core_info->vfe_idx, client, p_rdi->frame_cnt); - } - } - - return rc; -} - -static void ais_vfe_irq_fill_bus_wr_status( - struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_work_data *work_data) -{ - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - uint32_t client = 0; - - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - client_regs = &bus_hw_info->bus_client_reg[client]; - - work_data->bus_wr_status[0] = cam_io_r_mb(core_info->mem_base + - bus_hw_irq_regs[0].status_reg_offset); - work_data->bus_wr_status[1] = cam_io_r_mb(core_info->mem_base + - bus_hw_irq_regs[1].status_reg_offset); - work_data->bus_wr_status[2] = cam_io_r_mb(core_info->mem_base + - bus_hw_irq_regs[2].status_reg_offset); - - if (work_data->bus_wr_status[1]) { - struct ais_vfe_rdi_output *p_rdi; - - for (client = 0 ; client < AIS_IFE_PATH_MAX; client++) { - if (work_data->bus_wr_status[1] & (0x1 << client)) { - p_rdi = &core_info->rdi_out[client]; - client_regs = - &bus_hw_info->bus_client_reg[client]; - work_data->last_addr[client] = cam_io_r( - core_info->mem_base + - client_regs->status0); - } - } - } - - cam_io_w(work_data->bus_wr_status[0], core_info->mem_base + - bus_hw_irq_regs[0].clear_reg_offset); - cam_io_w(work_data->bus_wr_status[1], core_info->mem_base + - bus_hw_irq_regs[1].clear_reg_offset); - cam_io_w(work_data->bus_wr_status[2], core_info->mem_base + - bus_hw_irq_regs[2].clear_reg_offset); - cam_io_w_mb(0x1, core_info->mem_base + - bus_hw_info->common_reg.irq_reg_info.global_clear_offset); -} - -static int ais_vfe_handle_bus_wr_irq(struct cam_hw_info *vfe_hw, - struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_work_data *work_data) -{ - int rc = 0; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info = NULL; - struct ais_irq_register_set *bus_hw_irq_regs = NULL; - struct ais_vfe_bus_ver2_reg_offset_bus_client *client_regs = NULL; - uint32_t client = 0; - - bus_hw_info = core_info->vfe_hw_info->bus_hw_info; - bus_hw_irq_regs = bus_hw_info->common_reg.irq_reg_info.irq_reg_set; - client_regs = &bus_hw_info->bus_client_reg[client]; - - - CAM_DBG(CAM_ISP, "VFE%d BUS status 0x%x 0x%x 0x%x", core_info->vfe_idx, - work_data->bus_wr_status[0], - work_data->bus_wr_status[1], - work_data->bus_wr_status[2]); - - if (work_data->bus_wr_status[1]) { - AIS_ATRACE_BEGIN("FD_%d", core_info->vfe_idx); - ais_vfe_bus_handle_frame_done(core_info, work_data); - AIS_ATRACE_END("FD_%d", core_info->vfe_idx); - } - - if (work_data->bus_wr_status[0] & 0x7800) { - CAM_ERR(CAM_ISP, "VFE%d: WR BUS error occurred status = 0x%x", - core_info->vfe_idx, work_data->bus_wr_status[0]); - work_data->path = (work_data->bus_wr_status[0] >> 11) & 0xF; - rc = ais_vfe_handle_error(core_info, work_data); - } - - if (work_data->bus_wr_status[0] & 0x1) { - CAM_DBG(CAM_ISP, "VFE%d: WR BUS reset completed", - core_info->vfe_idx); - complete(&vfe_hw->hw_complete); - } - - return rc; -} - -static int ais_vfe_process_irq_bh(void *priv, void *data) -{ - struct ais_vfe_hw_work_data *work_data; - struct cam_hw_info *vfe_hw; - struct ais_vfe_hw_core_info *core_info; - int rc = 0; - - vfe_hw = (struct cam_hw_info *)priv; - if (!vfe_hw) { - CAM_ERR(CAM_ISP, "Invalid parameters"); - return -EINVAL; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - if (!core_info->event_cb) { - CAM_ERR(CAM_ISP, "hw_idx %d Error Cb not registered", - core_info->vfe_idx); - return -EINVAL; - } - - work_data = (struct ais_vfe_hw_work_data *)data; - - trace_ais_isp_irq_process(core_info->vfe_idx, work_data->evt_type, 1); - CAM_DBG(CAM_ISP, "VFE[%d] event %d", - core_info->vfe_idx, work_data->evt_type); - - core_info->event.idx = core_info->vfe_idx; - core_info->event.boot_ts = work_data->ts; - - switch (work_data->evt_type) { - case AIS_VFE_HW_IRQ_EVENT_SOF: - AIS_ATRACE_BEGIN("SOF_%d", core_info->vfe_idx); - rc = ais_vfe_handle_sof(core_info, work_data); - AIS_ATRACE_END("SOF_%d", core_info->vfe_idx); - break; - case AIS_VFE_HW_IRQ_EVENT_BUS_WR: - rc = ais_vfe_handle_bus_wr_irq(vfe_hw, core_info, work_data); - break; - case AIS_VFE_HW_IRQ_EVENT_ERROR: - rc = ais_vfe_handle_error(core_info, work_data); - break; - default: - CAM_ERR(CAM_ISP, "VFE[%d] invalid event type %d", - core_info->vfe_idx, work_data->evt_type); - break; - } - - trace_ais_isp_irq_process(core_info->vfe_idx, work_data->evt_type, 2); - - return rc; -} - -static int ais_vfe_dispatch_irq(struct cam_hw_info *vfe_hw, - struct ais_vfe_hw_work_data *p_work) -{ - struct ais_vfe_hw_core_info *core_info; - struct ais_vfe_hw_work_data *work_data; - struct crm_workq_task *task; - int rc = 0; - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - - CAM_DBG(CAM_ISP, "VFE[%d] event %d", - core_info->vfe_idx, p_work->evt_type); - - task = cam_req_mgr_workq_get_task(core_info->workq); - if (!task) { - CAM_ERR(CAM_ISP, "Can not get task for worker"); - return -ENOMEM; - } - work_data = (struct ais_vfe_hw_work_data *)task->payload; - *work_data = *p_work; - - trace_ais_isp_irq_process(core_info->vfe_idx, p_work->evt_type, 0); - - task->process_cb = ais_vfe_process_irq_bh; - rc = cam_req_mgr_workq_enqueue_task(task, vfe_hw, - CRM_TASK_PRIORITY_0); - - return rc; -} - -irqreturn_t ais_vfe_irq(int irq_num, void *data) -{ - struct cam_hw_info *vfe_hw; - struct ais_vfe_hw_core_info *core_info; - uint32_t ife_status[2] = {}; - - if (!data) - return IRQ_NONE; - - vfe_hw = (struct cam_hw_info *)data; - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - - /* Read and Clear all IFE status regs */ - ife_status[0] = cam_io_r_mb(core_info->mem_base + AIS_VFE_IRQ_STATUS0); - ife_status[1] = cam_io_r_mb(core_info->mem_base + AIS_VFE_IRQ_STATUS1); - - cam_io_w_mb(ife_status[0], core_info->mem_base + AIS_VFE_IRQ_CLEAR0); - cam_io_w_mb(ife_status[1], core_info->mem_base + AIS_VFE_IRQ_CLEAR1); - cam_io_w_mb(0x1, core_info->mem_base + AIS_VFE_IRQ_CMD); - - trace_ais_isp_vfe_irq_activated(core_info->vfe_idx, - ife_status[0], ife_status[1]); - CAM_DBG(CAM_ISP, "VFE%d irq status 0x%x 0x%x", core_info->vfe_idx, - ife_status[0], ife_status[1]); - - //process any reset inetrrupt - if (ife_status[0] & AIS_VFE_STATUS0_RESET_ACK_IRQ) { - /* - * Clear All IRQs to avoid spurious IRQs immediately - * after Reset Done. - */ - cam_io_w(0xFFFFFFFF, core_info->mem_base + AIS_VFE_IRQ_CLEAR0); - cam_io_w(0xFFFFFFFF, core_info->mem_base + AIS_VFE_IRQ_CLEAR1); - cam_io_w(0x1, core_info->mem_base + AIS_VFE_IRQ_CMD); - CAM_DBG(CAM_ISP, "VFE%d Calling Complete for RESET CMD", - core_info->vfe_idx); - complete(&vfe_hw->hw_complete); - } else { - struct ais_ife_rdi_get_timestamp_args get_ts; - struct ais_vfe_hw_work_data work_data; - struct timespec64 ts; - - get_monotonic_boottime64(&ts); - work_data.ts = - (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); - - if (ife_status[0] & AIS_VFE_STATUS0_RDI_SOF_IRQ) { - //RDI SOF - int i; - - work_data.path = (ife_status[0] >> - AIS_VFE_STATUS0_RDI_SOF_IRQ_SHFT) & - AIS_VFE_STATUS0_RDI_SOF_IRQ_MSK; - CAM_DBG(CAM_ISP, "IFE%d SOF 0x%x", - core_info->vfe_idx, work_data.path); - - //fill HW timestamp for each RDI path - for (i = 0; i < AIS_IFE_PATH_MAX; i++) { - if (!(work_data.path & (1 << i))) - continue; - - get_ts.path = i; - get_ts.ts = &work_data.ts_hw[i]; - core_info->csid_hw->hw_ops.process_cmd( - core_info->csid_hw->hw_priv, - AIS_IFE_CSID_CMD_GET_TIME_STAMP, - &get_ts, - sizeof(get_ts)); - } - - work_data.evt_type = AIS_VFE_HW_IRQ_EVENT_SOF; - ais_vfe_dispatch_irq(vfe_hw, &work_data); - } - if (ife_status[0] & AIS_VFE_STATUS0_BUS_WR_IRQ) { - //BUS_WR IRQ - CAM_DBG(CAM_ISP, "IFE%d BUS_WR", core_info->vfe_idx); - work_data.evt_type = AIS_VFE_HW_IRQ_EVENT_BUS_WR; - ais_vfe_irq_fill_bus_wr_status(core_info, &work_data); - - ais_vfe_dispatch_irq(vfe_hw, &work_data); - } - if (ife_status[1]) { - if (ife_status[1] & AIS_VFE_STATUS0_RDI_OVERFLOW_IRQ) { - work_data.path = (ife_status[1] >> - AIS_VFE_STATUS1_RDI_OVERFLOW_IRQ_SHFT) & - AIS_VFE_STATUS1_RDI_OVERFLOW_IRQ_MSK; - - CAM_ERR_RATE_LIMIT(CAM_ISP, - "IFE%d Overflow 0x%x", - core_info->vfe_idx, - work_data.path); - work_data.evt_type = AIS_VFE_HW_IRQ_EVENT_ERROR; - ais_vfe_dispatch_irq(vfe_hw, &work_data); - } - } - } - - return IRQ_HANDLED; -} - -int ais_vfe_core_init(struct ais_vfe_hw_core_info *core_info, - struct cam_hw_soc_info *soc_info, - struct cam_hw_intf *hw_intf, - struct ais_vfe_hw_info *vfe_hw_info) -{ - int rc = 0; - int i; - char worker_name[128]; - - CAM_DBG(CAM_ISP, "Enter"); - - core_info->vfe_idx = soc_info->index; - core_info->mem_base = - CAM_SOC_GET_REG_MAP_START(soc_info, VFE_CORE_BASE_IDX); - - spin_lock_init(&core_info->spin_lock); - - for (i = 0; i < AIS_IFE_PATH_MAX; i++) { - struct ais_vfe_rdi_output *p_rdi = &core_info->rdi_out[i]; - - spin_lock_init(&p_rdi->buffer_lock); - ais_clear_rdi_path(p_rdi); - p_rdi->state = AIS_ISP_RESOURCE_STATE_AVAILABLE; - } - - - scnprintf(worker_name, sizeof(worker_name), - "vfe%u_worker", core_info->vfe_idx); - CAM_DBG(CAM_ISP, "Create VFE worker %s", worker_name); - rc = cam_req_mgr_workq_create(worker_name, - AIS_VFE_WORKQ_NUM_TASK, - &core_info->workq, CRM_WORKQ_USAGE_IRQ, 0); - if (rc) { - CAM_ERR(CAM_ISP, "Unable to create a workq, rc=%d", rc); - goto EXIT; - } - - for (i = 0; i < AIS_VFE_WORKQ_NUM_TASK; i++) - core_info->workq->task.pool[i].payload = - &core_info->work_data[i]; - -EXIT: - return rc; -} - -int ais_vfe_core_deinit(struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_info *vfe_hw_info) -{ - int rc = -EINVAL; - int i; - unsigned long flags; - - spin_lock_irqsave(&core_info->spin_lock, flags); - - cam_req_mgr_workq_destroy(&core_info->workq); - - for (i = 0; i < AIS_IFE_PATH_MAX; i++) { - struct ais_vfe_rdi_output *p_rdi = &core_info->rdi_out[i]; - - ais_clear_rdi_path(p_rdi); - p_rdi->state = AIS_ISP_RESOURCE_STATE_AVAILABLE; - } - - spin_unlock_irqrestore(&core_info->spin_lock, flags); - - return rc; -} diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.h deleted file mode 100755 index 747f422a113d..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_core.h +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_CORE_H_ -#define _AIS_VFE_CORE_H_ - -#include -#include "cam_hw_intf.h" -#include "ais_vfe_hw_intf.h" -#include "ais_ife_csid_hw_intf.h" -#include "ais_vfe_bus_ver2.h" -#include "ais_vfe_top_ver2.h" - -#define AIS_VFE_WORKQ_NUM_TASK 20 -#define AIS_VFE_MAX_BUF 20 -#define AIS_VFE_MAX_SOF_INFO 8 - -enum ais_vfe_hw_irq_event { - AIS_VFE_HW_IRQ_EVENT_SOF, - AIS_VFE_HW_IRQ_EVENT_BUS_WR, - AIS_VFE_HW_IRQ_EVENT_ERROR, -}; - -/** - * struct ais_csid_hw_work_data- work data for csid - * Later other fields can be added to this data - * @evt_type : Event type from CSID - * @irq_status : IRQ Status register - * - */ -struct ais_vfe_hw_work_data { - enum ais_vfe_hw_irq_event evt_type; - uint32_t path; - uint64_t ts; - uint32_t bus_wr_status[3]; - uint32_t last_addr[AIS_IFE_PATH_MAX]; - struct ais_ife_rdi_timestamps ts_hw[AIS_IFE_PATH_MAX]; -}; - -struct ais_vfe_hw_info { - struct ais_irq_controller_reg_info *irq_reg_info; - - uint32_t bus_version; - struct ais_vfe_bus_ver2_hw_info *bus_hw_info; - - uint32_t bus_rd_version; - void *bus_rd_hw_info; - - uint32_t top_version; - struct ais_vfe_top_ver2_hw_info *top_hw_info; - - uint32_t camif_version; - void *camif_reg; - - uint32_t camif_lite_version; - void *camif_lite_reg; - - uint32_t testgen_version; - void *testgen_reg; - - uint32_t num_qos_settings; - struct cam_isp_reg_val_pair *qos_settings; - - uint32_t num_ds_settings; - struct cam_isp_reg_val_pair *ds_settings; - - uint32_t num_vbif_settings; - struct cam_isp_reg_val_pair *vbif_settings; -}; - -struct ais_vfe_buffer_t { - struct list_head list; - int32_t mem_handle; - uint64_t iova_addr; - uint32_t bufIdx; - struct ais_ife_rdi_timestamps ts_hw; -}; - -struct ais_sof_info_t { - struct list_head list; - uint64_t frame_cnt; - uint64_t sof_ts; - uint64_t cur_sof_hw_ts; - uint64_t prev_sof_hw_ts; -}; - -struct ais_vfe_rdi_output { - enum ais_isp_resource_state state; - - uint32_t en_cfg; - uint32_t secure_mode; - - spinlock_t buffer_lock; - struct ais_vfe_buffer_t buffers[AIS_VFE_MAX_BUF]; - struct list_head buffer_q; - uint8_t num_buffer_hw_q; - struct list_head buffer_hw_q; - struct list_head free_buffer_list; - - uint64_t frame_cnt; - - uint8_t num_sof_info_q; - struct ais_sof_info_t sof_info[AIS_VFE_MAX_SOF_INFO]; - struct list_head sof_info_q; - struct list_head free_sof_info_list; - struct ais_sof_info_t last_sof_info; -}; - -struct ais_vfe_hw_core_info { - struct ais_vfe_hw_info *vfe_hw_info; - uint32_t vfe_idx; - - void __iomem *mem_base; - int iommu_hdl; - int iommu_hdl_secure; - - uint32_t max_rdis; - struct ais_vfe_rdi_output rdi_out[AIS_IFE_PATH_MAX]; - - uint32_t cpas_handle; - int irq_handle; - int irq_err_handle; - - uint32_t irq_mask0; - uint32_t irq_mask1; - uint32_t bus_wr_mask1; - - spinlock_t spin_lock; - - struct cam_req_mgr_core_workq *workq; - struct ais_vfe_hw_work_data work_data[AIS_VFE_WORKQ_NUM_TASK]; - - struct cam_hw_intf *csid_hw; - struct ais_ife_event_data event; - void *event_cb_priv; - ais_ife_event_cb_func event_cb; -}; - -int ais_vfe_get_hw_caps(void *device_priv, - void *get_hw_cap_args, uint32_t arg_size); -int ais_vfe_init_hw(void *device_priv, - void *init_hw_args, uint32_t arg_size); -int ais_vfe_deinit_hw(void *hw_priv, - void *deinit_hw_args, uint32_t arg_size); -int ais_vfe_force_reset(void *device_priv, - void *reset_core_args, uint32_t arg_size); -int ais_vfe_reserve(void *device_priv, - void *reserve_args, uint32_t arg_size); -int ais_vfe_release(void *device_priv, - void *reserve_args, uint32_t arg_size); -int ais_vfe_start(void *device_priv, - void *start_args, uint32_t arg_size); -int ais_vfe_stop(void *device_priv, - void *stop_args, uint32_t arg_size); -int ais_vfe_read(void *device_priv, - void *read_args, uint32_t arg_size); -int ais_vfe_write(void *device_priv, - void *write_args, uint32_t arg_size); -int ais_vfe_process_cmd(void *device_priv, uint32_t cmd_type, - void *cmd_args, uint32_t arg_size); - -irqreturn_t ais_vfe_irq(int irq_num, void *data); - -int ais_vfe_core_init(struct ais_vfe_hw_core_info *core_info, - struct cam_hw_soc_info *soc_info, - struct cam_hw_intf *hw_intf, - struct ais_vfe_hw_info *vfe_hw_info); - -int ais_vfe_core_deinit(struct ais_vfe_hw_core_info *core_info, - struct ais_vfe_hw_info *vfe_hw_info); - -#endif /* _AIS_VFE_CORE_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.c b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.c deleted file mode 100755 index 9eb6315b15f5..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.c +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - -#include -#include -#include -#include "ais_vfe_dev.h" -#include "ais_vfe_core.h" -#include "ais_vfe_soc.h" -#include "cam_debug_util.h" - -static struct cam_hw_intf *ais_vfe_hw_list[AIS_VFE_HW_NUM_MAX] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; - -static char vfe_dev_name[8]; - -int ais_vfe_probe(struct platform_device *pdev) -{ - struct cam_hw_info *vfe_hw = NULL; - struct cam_hw_intf *vfe_hw_intf = NULL; - const struct of_device_id *match_dev = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - struct ais_vfe_hw_info *hw_info = NULL; - int rc = 0; - - CAM_INFO(CAM_ISP, "Probe called"); - - vfe_hw_intf = kzalloc(sizeof(struct cam_hw_intf), GFP_KERNEL); - if (!vfe_hw_intf) { - rc = -ENOMEM; - goto end; - } - - of_property_read_u32(pdev->dev.of_node, - "cell-index", &vfe_hw_intf->hw_idx); - - vfe_hw = kzalloc(sizeof(struct cam_hw_info), GFP_KERNEL); - if (!vfe_hw) { - rc = -ENOMEM; - goto free_vfe_hw_intf; - } - - memset(vfe_dev_name, 0, sizeof(vfe_dev_name)); - snprintf(vfe_dev_name, sizeof(vfe_dev_name), - "vfe%1u", vfe_hw_intf->hw_idx); - - vfe_hw->soc_info.pdev = pdev; - vfe_hw->soc_info.dev = &pdev->dev; - vfe_hw->soc_info.dev_name = vfe_dev_name; - vfe_hw_intf->hw_priv = vfe_hw; - vfe_hw_intf->hw_ops.get_hw_caps = ais_vfe_get_hw_caps; - vfe_hw_intf->hw_ops.init = ais_vfe_init_hw; - vfe_hw_intf->hw_ops.deinit = ais_vfe_deinit_hw; - vfe_hw_intf->hw_ops.reset = ais_vfe_force_reset; - vfe_hw_intf->hw_ops.reserve = ais_vfe_reserve; - vfe_hw_intf->hw_ops.release = ais_vfe_release; - vfe_hw_intf->hw_ops.start = ais_vfe_start; - vfe_hw_intf->hw_ops.stop = ais_vfe_stop; - vfe_hw_intf->hw_ops.read = ais_vfe_read; - vfe_hw_intf->hw_ops.write = ais_vfe_write; - vfe_hw_intf->hw_ops.process_cmd = ais_vfe_process_cmd; - vfe_hw_intf->hw_type = AIS_ISP_HW_TYPE_VFE; - - CAM_INFO(CAM_ISP, "Probe called for VFE%d", vfe_hw_intf->hw_idx); - - platform_set_drvdata(pdev, vfe_hw_intf); - - vfe_hw->core_info = kzalloc(sizeof(struct ais_vfe_hw_core_info), - GFP_KERNEL); - if (!vfe_hw->core_info) { - CAM_DBG(CAM_ISP, "Failed to alloc for core"); - rc = -ENOMEM; - goto free_vfe_hw; - } - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - - match_dev = of_match_device(pdev->dev.driver->of_match_table, - &pdev->dev); - if (!match_dev) { - CAM_ERR(CAM_ISP, "Of_match Failed"); - rc = -EINVAL; - goto free_core_info; - } - hw_info = (struct ais_vfe_hw_info *)match_dev->data; - core_info->vfe_hw_info = hw_info; - - rc = ais_vfe_init_soc_resources(&vfe_hw->soc_info, ais_vfe_irq, - vfe_hw); - if (rc < 0) { - CAM_ERR(CAM_ISP, "Failed to init soc rc=%d", rc); - goto free_core_info; - } - - rc = ais_vfe_core_init(core_info, &vfe_hw->soc_info, - vfe_hw_intf, hw_info); - if (rc < 0) { - CAM_ERR(CAM_ISP, "Failed to init core rc=%d", rc); - goto deinit_soc; - } - - vfe_hw->hw_state = CAM_HW_STATE_POWER_DOWN; - mutex_init(&vfe_hw->hw_mutex); - spin_lock_init(&vfe_hw->hw_lock); - init_completion(&vfe_hw->hw_complete); - - if (vfe_hw_intf->hw_idx < AIS_VFE_HW_NUM_MAX) - ais_vfe_hw_list[vfe_hw_intf->hw_idx] = vfe_hw_intf; - - /*@TODO: why do we need this if not checking for errors*/ - ais_vfe_init_hw(vfe_hw, NULL, 0); - ais_vfe_deinit_hw(vfe_hw, NULL, 0); - - CAM_DBG(CAM_ISP, "VFE%d probe successful", vfe_hw_intf->hw_idx); - - return rc; - -deinit_soc: - if (ais_vfe_deinit_soc_resources(&vfe_hw->soc_info)) - CAM_ERR(CAM_ISP, "Failed to deinit soc"); -free_core_info: - kfree(vfe_hw->core_info); -free_vfe_hw: - kfree(vfe_hw); -free_vfe_hw_intf: - kfree(vfe_hw_intf); -end: - return rc; -} - -int ais_vfe_remove(struct platform_device *pdev) -{ - struct cam_hw_info *vfe_hw = NULL; - struct cam_hw_intf *vfe_hw_intf = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - int rc = 0; - - vfe_hw_intf = platform_get_drvdata(pdev); - if (!vfe_hw_intf) { - CAM_ERR(CAM_ISP, "Error! No data in pdev"); - return -EINVAL; - } - - CAM_DBG(CAM_ISP, "type %d index %d", - vfe_hw_intf->hw_type, vfe_hw_intf->hw_idx); - - if (vfe_hw_intf->hw_idx < AIS_VFE_HW_NUM_MAX) - ais_vfe_hw_list[vfe_hw_intf->hw_idx] = NULL; - - vfe_hw = vfe_hw_intf->hw_priv; - if (!vfe_hw) { - CAM_ERR(CAM_ISP, "Error! HW data is NULL"); - rc = -ENODEV; - goto free_vfe_hw_intf; - } - - core_info = (struct ais_vfe_hw_core_info *)vfe_hw->core_info; - if (!core_info) { - CAM_ERR(CAM_ISP, "Error! core data NULL"); - rc = -EINVAL; - goto deinit_soc; - } - - rc = ais_vfe_core_deinit(core_info, core_info->vfe_hw_info); - if (rc < 0) - CAM_ERR(CAM_ISP, "Failed to deinit core rc=%d", rc); - - kfree(vfe_hw->core_info); - -deinit_soc: - rc = ais_vfe_deinit_soc_resources(&vfe_hw->soc_info); - if (rc < 0) - CAM_ERR(CAM_ISP, "Failed to deinit soc rc=%d", rc); - - mutex_destroy(&vfe_hw->hw_mutex); - kfree(vfe_hw); - - CAM_DBG(CAM_ISP, "VFE%d remove successful", vfe_hw_intf->hw_idx); - -free_vfe_hw_intf: - kfree(vfe_hw_intf); - - return rc; -} - -int ais_vfe_hw_init(struct cam_hw_intf **vfe_hw, - struct ais_isp_hw_init_args *init, - struct cam_hw_intf *csid_hw) -{ - int rc = 0; - - if (ais_vfe_hw_list[init->hw_idx]) { - struct cam_hw_info *vfe_hw_info = NULL; - struct ais_vfe_hw_core_info *core_info = NULL; - - vfe_hw_info = ais_vfe_hw_list[init->hw_idx]->hw_priv; - core_info = - (struct ais_vfe_hw_core_info *)vfe_hw_info->core_info; - - core_info->csid_hw = csid_hw; - - core_info->event_cb = init->event_cb; - core_info->event_cb_priv = init->event_cb_priv; - core_info->iommu_hdl = init->iommu_hdl; - core_info->iommu_hdl_secure = init->iommu_hdl_secure; - - *vfe_hw = ais_vfe_hw_list[init->hw_idx]; - rc = 0; - } else { - *vfe_hw = NULL; - rc = -ENODEV; - } - return rc; -} diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.h deleted file mode 100755 index 99b85a7dea9d..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_dev.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_DEV_H_ -#define _AIS_VFE_DEV_H_ - -#include - -/* - * ais_vfe_probe() - * - * @brief: Driver probe function called on Boot - * - * @pdev: Platform Device pointer - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_probe(struct platform_device *pdev); - -/* - * ais_vfe_remove() - * - * @brief: Driver remove function - * - * @pdev: Platform Device pointer - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_remove(struct platform_device *pdev); - -#endif /* _AIS_VFE_DEV_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.c b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.c deleted file mode 100755 index 3d93340c0f86..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.c +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include "cam_cpas_api.h" -#include "ais_vfe_soc.h" -#include "cam_debug_util.h" - -static bool ais_vfe_cpas_cb(uint32_t client_handle, void *userdata, - struct cam_cpas_irq_data *irq_data) -{ - bool error_handled = false; - - if (!irq_data) - return error_handled; - - switch (irq_data->irq_type) { - case CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR: - case CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR: - case CAM_CAMNOC_IRQ_IFE0_UBWC_ENCODE_ERROR: - case CAM_CAMNOC_IRQ_IFE1_WRITE_UBWC_ENCODE_ERROR: - CAM_ERR_RATE_LIMIT(CAM_ISP, - "IFE UBWC Encode error type=%d status=%x", - irq_data->irq_type, - irq_data->u.enc_err.encerr_status.value); - error_handled = true; - break; - default: - break; - } - - return error_handled; -} - -static int ais_vfe_get_dt_properties(struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - - rc = cam_soc_util_get_dt_properties(soc_info); - if (rc) { - CAM_ERR(CAM_ISP, "Error! get DT properties failed rc=%d", rc); - return rc; - } - - return rc; -} - -static int ais_vfe_request_platform_resource( - struct cam_hw_soc_info *soc_info, - irq_handler_t vfe_irq_handler, void *irq_data) -{ - int rc = 0; - - rc = cam_soc_util_request_platform_resource(soc_info, vfe_irq_handler, - irq_data); - if (rc) - CAM_ERR(CAM_ISP, - "Error! Request platform resource failed rc=%d", rc); - - return rc; -} - -static int ais_vfe_release_platform_resource(struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - - rc = cam_soc_util_release_platform_resource(soc_info); - if (rc) - CAM_ERR(CAM_ISP, - "Error! Release platform resource failed rc=%d", rc); - - return rc; -} - -int ais_vfe_init_soc_resources(struct cam_hw_soc_info *soc_info, - irq_handler_t vfe_irq_handler, void *irq_data) -{ - int rc = 0; - struct ais_vfe_soc_private *soc_private; - struct cam_cpas_register_params cpas_register_param; - - soc_private = kzalloc(sizeof(struct ais_vfe_soc_private), - GFP_KERNEL); - if (!soc_private) { - CAM_DBG(CAM_ISP, "Error! soc_private Alloc Failed"); - return -ENOMEM; - } - soc_info->soc_private = soc_private; - - rc = ais_vfe_get_dt_properties(soc_info); - if (rc < 0) { - CAM_ERR(CAM_ISP, "Error! Get DT properties failed rc=%d", rc); - goto free_soc_private; - } - - rc = cam_soc_util_get_option_clk_by_name(soc_info, - AIS_VFE_DSP_CLK_NAME, &soc_private->dsp_clk, - &soc_private->dsp_clk_index, &soc_private->dsp_clk_rate); - if (rc) - /* failure expected as dsp clk is not used for now */ - CAM_INFO(CAM_ISP, "Option clk get failed with rc %d", rc); - - rc = ais_vfe_request_platform_resource(soc_info, vfe_irq_handler, - irq_data); - if (rc < 0) { - CAM_ERR(CAM_ISP, - "Error! Request platform resources failed rc=%d", rc); - goto free_soc_private; - } - - memset(&cpas_register_param, 0, sizeof(cpas_register_param)); - - cpas_register_param.cell_index = soc_info->index; - cpas_register_param.dev = soc_info->dev; - cpas_register_param.cam_cpas_client_cb = ais_vfe_cpas_cb; - cpas_register_param.userdata = soc_info; - - rc = cam_cpas_get_cpas_hw_version(&soc_private->cpas_version); - if (rc) { - CAM_ERR(CAM_ISP, "Error! Invalid cpas version rc=%d", rc); - goto free_soc_private; - } - - switch (soc_private->cpas_version) { - case CAM_CPAS_TITAN_175_V120: - strlcpy(cpas_register_param.identifier, "iferdi", - CAM_HW_IDENTIFIER_LENGTH); - rc = cam_cpas_register_client(&cpas_register_param); - if (rc) { - CAM_ERR(CAM_ISP, "rdi CPAS registration failed rc=%d", - rc); - goto release_soc; - } else { - soc_private->cpas_handle[0] = - cpas_register_param.client_handle; - } - - strlcpy(cpas_register_param.identifier, "ifenrdi", - CAM_HW_IDENTIFIER_LENGTH); - rc = cam_cpas_register_client(&cpas_register_param); - if (rc) { - CAM_ERR(CAM_ISP, "nrdi CPAS registration failed rc=%d", - rc); - goto release_soc; - } else { - soc_private->cpas_handle[1] = - cpas_register_param.client_handle; - } - break; - default: - strlcpy(cpas_register_param.identifier, "ife", - CAM_HW_IDENTIFIER_LENGTH); - rc = cam_cpas_register_client(&cpas_register_param); - if (rc) { - CAM_ERR(CAM_ISP, "CPAS registration failed rc=%d", rc); - goto release_soc; - } else { - soc_private->cpas_handle[0] = - cpas_register_param.client_handle; - } - } - return rc; - -release_soc: - cam_soc_util_release_platform_resource(soc_info); -free_soc_private: - kfree(soc_private); - - return rc; -} - -int ais_vfe_deinit_soc_resources(struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - struct ais_vfe_soc_private *soc_private; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error! soc_info NULL"); - return -ENODEV; - } - - soc_private = soc_info->soc_private; - if (!soc_private) { - CAM_ERR(CAM_ISP, "Error! soc_private NULL"); - return -ENODEV; - } - rc = cam_cpas_unregister_client(soc_private->cpas_handle[0]); - if (rc) - CAM_ERR(CAM_ISP, "CPAS0 unregistration failed rc=%d", rc); - - if (!rc && soc_private->cpas_version == CAM_CPAS_TITAN_175_V120) { - rc = cam_cpas_unregister_client(soc_private->cpas_handle[1]); - if (rc) - CAM_ERR(CAM_ISP, "CPAS1 unregistration failed rc=%d", - rc); - } - - rc = ais_vfe_release_platform_resource(soc_info); - if (rc < 0) - CAM_ERR(CAM_ISP, - "Error! Release platform resources failed rc=%d", rc); - - rc = cam_soc_util_clk_put(&soc_private->dsp_clk); - if (rc < 0) - CAM_ERR(CAM_ISP, - "Error Put dsp clk failed rc=%d", rc); - - kfree(soc_private); - - return rc; -} - -int ais_vfe_enable_soc_resources(struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - struct ais_vfe_soc_private *soc_private; - struct cam_ahb_vote ahb_vote; - struct cam_axi_vote axi_vote; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error! Invalid params"); - rc = -EINVAL; - goto end; - } - soc_private = soc_info->soc_private; - - rc = cam_soc_util_enable_platform_resource(soc_info, true, - CAM_TURBO_VOTE, true); - if (rc) { - CAM_ERR(CAM_ISP, "Error! enable platform failed rc=%d", rc); - goto end; - } - - ahb_vote.type = CAM_VOTE_ABSOLUTE; - ahb_vote.vote.level = CAM_SVS_VOTE; - - axi_vote.compressed_bw = 10640000000L; - axi_vote.compressed_bw_ab = 10640000000L; - axi_vote.uncompressed_bw = 10640000000L; - - rc = cam_cpas_start(soc_private->cpas_handle[0], &ahb_vote, &axi_vote); - if (rc) { - CAM_ERR(CAM_ISP, "Error! CPAS0 start failed rc=%d", rc); - rc = -EFAULT; - goto disable_platform_resource; - } - - if (!rc && soc_private->cpas_version == CAM_CPAS_TITAN_175_V120) - rc = cam_cpas_start(soc_private->cpas_handle[1], &ahb_vote, - &axi_vote); - if (rc) { - CAM_ERR(CAM_ISP, "Error! CPAS1 start failed rc=%d", rc); - rc = -EFAULT; - goto disable_platform_resource; - } - - goto end; - -disable_platform_resource: - if (cam_soc_util_disable_platform_resource(soc_info, true, true)) - CAM_ERR(CAM_ISP, "Disable platform resource failed"); - -end: - return rc; -} - -int ais_vfe_soc_enable_clk(struct cam_hw_soc_info *soc_info, - const char *clk_name) -{ - int rc = 0; - struct ais_vfe_soc_private *soc_private; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error Invalid params"); - rc = -EINVAL; - return rc; - } - soc_private = soc_info->soc_private; - - if (strcmp(clk_name, AIS_VFE_DSP_CLK_NAME) == 0) { - rc = cam_soc_util_clk_enable(soc_private->dsp_clk, - AIS_VFE_DSP_CLK_NAME, soc_private->dsp_clk_rate); - if (rc) - CAM_ERR(CAM_ISP, - "Error enable dsp clk failed rc=%d", rc); - } - - return rc; -} - -int ais_vfe_soc_disable_clk(struct cam_hw_soc_info *soc_info, - const char *clk_name) -{ - int rc = 0; - struct ais_vfe_soc_private *soc_private; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error Invalid params"); - rc = -EINVAL; - return rc; - } - soc_private = soc_info->soc_private; - - if (strcmp(clk_name, AIS_VFE_DSP_CLK_NAME) == 0) { - rc = cam_soc_util_clk_disable(soc_private->dsp_clk, - AIS_VFE_DSP_CLK_NAME); - if (rc) - CAM_ERR(CAM_ISP, - "Error enable dsp clk failed rc=%d", rc); - } - - return rc; -} - - -int ais_vfe_disable_soc_resources(struct cam_hw_soc_info *soc_info) -{ - int rc = 0; - struct ais_vfe_soc_private *soc_private; - - if (!soc_info) { - CAM_ERR(CAM_ISP, "Error! Invalid params"); - rc = -EINVAL; - return rc; - } - soc_private = soc_info->soc_private; - - rc = cam_soc_util_disable_platform_resource(soc_info, true, true); - if (rc) { - CAM_ERR(CAM_ISP, "Disable platform failed rc=%d", rc); - return rc; - } - - rc = cam_cpas_stop(soc_private->cpas_handle[0]); - if (rc) { - CAM_ERR(CAM_ISP, "Error! CPAS stop failed rc=%d", rc); - return rc; - } - - if (!rc && soc_private->cpas_version == CAM_CPAS_TITAN_175_V120) - rc = cam_cpas_stop(soc_private->cpas_handle[1]); - if (rc) { - CAM_ERR(CAM_ISP, "Error! CPAS stop failed rc=%d", rc); - return rc; - } - - return rc; -} diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.h deleted file mode 100755 index 407acf9ef6c6..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/ais_vfe_soc.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_SOC_H_ -#define _AIS_VFE_SOC_H_ - -#include "cam_soc_util.h" -#include "ais_isp_hw.h" - -#define AIS_VFE_DSP_CLK_NAME "ife_dsp_clk" - -enum cam_cpas_handle_id { - CAM_CPAS_HANDLE_CAMIF, - CAM_CPAS_HANDLE_RAW, - CAM_CPAS_HANDLE_MAX, -}; - -/* - * struct ais_vfe_soc_private: - * - * @Brief: Private SOC data specific to VFE HW Driver - * - * @cpas_handle: Handle returned on registering with CPAS driver. - * This handle is used for all further interface - * with CPAS. - * @cpas_version: Has cpas version read from Hardware - */ -struct ais_vfe_soc_private { - uint32_t cpas_handle[CAM_CPAS_HANDLE_MAX]; - uint32_t cpas_version; - struct clk *dsp_clk; - int32_t dsp_clk_index; - int32_t dsp_clk_rate; -}; - -/* - * ais_vfe_init_soc_resources() - * - * @Brief: Initialize SOC resources including private data - * - * @soc_info: Device soc information - * @handler: Irq handler function pointer - * @irq_data: Irq handler function Callback data - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_init_soc_resources(struct cam_hw_soc_info *soc_info, - irq_handler_t vfe_irq_handler, void *irq_data); - -/* - * ais_vfe_deinit_soc_resources() - * - * @Brief: Deinitialize SOC resources including private data - * - * @soc_info: Device soc information - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_deinit_soc_resources(struct cam_hw_soc_info *soc_info); - -/* - * ais_vfe_enable_soc_resources() - * - * @brief: Enable regulator, irq resources, start CPAS - * - * @soc_info: Device soc information - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_enable_soc_resources(struct cam_hw_soc_info *soc_info); - -/* - * ais_vfe_disable_soc_resources() - * - * @brief: Disable regulator, irq resources, stop CPAS - * - * @soc_info: Device soc information - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_disable_soc_resources(struct cam_hw_soc_info *soc_info); - -/* - * ais_vfe_soc_enable_clk() - * - * @brief: Enable clock with given name - * - * @soc_info: Device soc information - * @clk_name: Name of clock to enable - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_soc_enable_clk(struct cam_hw_soc_info *soc_info, - const char *clk_name); - -/* - * ais_vfe_soc_disable_dsp_clk() - * - * @brief: Disable clock with given name - * - * @soc_info: Device soc information - * @clk_name: Name of clock to enable - * - * @Return: 0: Success - * Non-zero: Failure - */ -int ais_vfe_soc_disable_clk(struct cam_hw_soc_info *soc_info, - const char *clk_name); - -#endif /* _AIS_VFE_SOC_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/Makefile b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/Makefile deleted file mode 100755 index a0d0984f70be..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -ccflags-y += -Idrivers/media/platform/msm/ais/cam_utils -ccflags-y += -Idrivers/media/platform/msm/ais/cam_core -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/include -ccflags-y += -Idrivers/media/platform/msm/ais/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -Idrivers/media/platform/msm/ais/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/include -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus -ccflags-y += -Idrivers/media/platform/msm/ais/ais_isp/vfe_hw - -obj-$(CONFIG_MSM_AIS) += ais_vfe17x.o diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe170.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe170.h deleted file mode 100755 index bf947f734c5e..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe170.h +++ /dev/null @@ -1,1046 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE170_H_ -#define _AIS_VFE170_H_ - -#include "ais_vfe_camif_ver2.h" -#include "ais_vfe_bus_ver2.h" -#include "ais_vfe_top_ver2.h" -#include "ais_vfe_core.h" - -static struct ais_irq_register_set vfe170_top_irq_reg_set[2] = { - { - .mask_reg_offset = 0x0000005C, - .clear_reg_offset = 0x00000064, - .status_reg_offset = 0x0000006C, - }, - { - .mask_reg_offset = 0x00000060, - .clear_reg_offset = 0x00000068, - .status_reg_offset = 0x00000070, - }, -}; - -static struct ais_irq_controller_reg_info vfe170_top_irq_reg_info = { - .num_registers = 2, - .irq_reg_set = vfe170_top_irq_reg_set, - .global_clear_offset = 0x00000058, - .global_clear_bitmask = 0x00000001, -}; - -static struct ais_vfe_camif_ver2_reg vfe170_camif_reg = { - .camif_cmd = 0x00000478, - .camif_config = 0x0000047C, - .line_skip_pattern = 0x00000488, - .pixel_skip_pattern = 0x0000048C, - .skip_period = 0x00000490, - .irq_subsample_pattern = 0x0000049C, - .epoch_irq = 0x000004A0, - .raw_crop_width_cfg = 0x00000CE4, - .raw_crop_height_cfg = 0x00000CE8, - .reg_update_cmd = 0x000004AC, - .vfe_diag_config = 0x00000C48, - .vfe_diag_sensor_status = 0x00000C4C, -}; - -static struct ais_vfe_camif_reg_data vfe_170_camif_reg_data = { - .raw_crop_first_pixel_shift = 16, - .raw_crop_first_pixel_mask = 0xFFFF, - .raw_crop_last_pixel_shift = 0x0, - .raw_crop_last_pixel_mask = 0x3FFF, - .raw_crop_first_line_shift = 16, - .raw_crop_first_line_mask = 0xFFFF, - .raw_crop_last_line_shift = 0, - .raw_crop_last_line_mask = 0x3FFF, - .input_mux_sel_shift = 5, - .input_mux_sel_mask = 0x3, - .extern_reg_update_shift = 4, - .extern_reg_update_mask = 1, - .pixel_pattern_shift = 0, - .pixel_pattern_mask = 0x7, - .dsp_mode_shift = 23, - .dsp_mode_mask = 0x1, - .dsp_en_shift = 3, - .dsp_en_mask = 0x1, - .reg_update_cmd_data = 0x1, - .epoch_line_cfg = 0x00140014, - .sof_irq_mask = 0x00000001, - .epoch0_irq_mask = 0x00000004, - .reg_update_irq_mask = 0x00000010, - .eof_irq_mask = 0x00000002, - .error_irq_mask0 = 0x0003FC00, - .error_irq_mask1 = 0x0FFF7E80, - .enable_diagnostic_hw = 0x1, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe_170_lens_reg = { - .reset = 0x0000001C, - .cgc_ovd = 0x0000002C, - .enable = 0x00000040, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe_170_stats_reg = { - .reset = 0x00000020, - .cgc_ovd = 0x00000030, - .enable = 0x00000044, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe_170_color_reg = { - .reset = 0x00000024, - .cgc_ovd = 0x00000034, - .enable = 0x00000048, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe_170_zoom_reg = { - .reset = 0x00000028, - .cgc_ovd = 0x00000038, - .enable = 0x0000004C, -}; - -static struct ais_vfe_bus_ver2_stats_cfg_info vfe170_stats_info = { - .dmi_offset_info = { - .auto_increment = 0x00000100, - .cfg_offset = 0x00000C24, - .addr_offset = 0x00000C28, - .data_hi_offset = 0x00000C2C, - .data_lo_offset = 0x00000C30, - }, - .stats_cfg_offset = { - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI0 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI1 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI2 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI3 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FULL */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS4 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS16 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FD */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_PDAF */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - .cfg_offset = 0x00000AB8, - .num_cfg = 0x00000ABC, - .cfg_size = 0x00000AC0, - .is_lut = 0, - .lut = { - .size = 0, - .bank_0 = 0, - .bank_1 = 0, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST */ - { - .res_index = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - .cfg_offset = 0x00000AD4, - .num_cfg = 0x00000AD8, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x36, - .bank_1 = 0x37, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - .cfg_offset = 0x00000AE4, - .num_cfg = 0x00000000, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x40, - .bank_1 = 0x41, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - .cfg_offset = 0x00000BC8, - .num_cfg = 0x00000BCC, - .cfg_size = 0x00000BD0, - .is_lut = 0, - .lut = { - .size = 0, - .bank_0 = 0, - .bank_1 = 0, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - .cfg_offset = 0x00000BE4, - .num_cfg = 0x00000BE8, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x3A, - .bank_1 = 0, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - .cfg_offset = 0x00000BEC, - .num_cfg = 0x00000BF0, - .cfg_size = 0x00000BF4, - .is_lut = 0, - .lut = { - .size = 0, - .bank_0 = 0, - .bank_1 = 0, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - .cfg_offset = 0x00000BF8, - .num_cfg = 0x00000BFC, - .cfg_size = 0x00000C00, - .is_lut = 0, - .lut = { - .size = 0, - .bank_0 = 0, - .bank_1 = 0, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - .cfg_offset = 0x00000C04, - .num_cfg = 0x00000C08, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x3B, - .bank_1 = 0x3C, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FULL_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS4_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS16_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_2PD */ - { - }, - }, -}; - - -static struct ais_vfe_top_ver2_reg_offset_common vfe170_top_common_reg = { - .hw_version = 0x00000000, - .hw_capability = 0x00000004, - .lens_feature = 0x00000008, - .stats_feature = 0x0000000C, - .color_feature = 0x00000010, - .zoom_feature = 0x00000014, - .global_reset_cmd = 0x00000018, - .module_ctrl = { - &vfe_170_lens_reg, - &vfe_170_stats_reg, - &vfe_170_color_reg, - &vfe_170_zoom_reg, - }, - .bus_cgc_ovd = 0x0000003C, - .core_cfg = 0x00000050, - .three_D_cfg = 0x00000054, - .violation_status = 0x0000007C, - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_ver2_reg vfe170_rdi_reg = { - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_reg_data vfe_170_rdi_0_data = { - .reg_update_cmd_data = 0x2, - .sof_irq_mask = 0x8000000, - .reg_update_irq_mask = 0x20, -}; - -static struct ais_vfe_rdi_reg_data vfe_170_rdi_1_data = { - .reg_update_cmd_data = 0x4, - .sof_irq_mask = 0x10000000, - .reg_update_irq_mask = 0x40, -}; - -static struct ais_vfe_rdi_reg_data vfe_170_rdi_2_data = { - .reg_update_cmd_data = 0x8, - .sof_irq_mask = 0x20000000, - .reg_update_irq_mask = 0x80, -}; - -static struct ais_vfe_top_ver2_hw_info vfe170_top_hw_info = { - .common_reg = &vfe170_top_common_reg, - .camif_hw_info = { - .common_reg = &vfe170_top_common_reg, - .camif_reg = &vfe170_camif_reg, - .reg_data = &vfe_170_camif_reg_data, - }, - .camif_lite_hw_info = { - .common_reg = NULL, - .camif_lite_reg = NULL, - .reg_data = NULL, - }, - .rdi_hw_info = { - .common_reg = &vfe170_top_common_reg, - .rdi_reg = &vfe170_rdi_reg, - .reg_data = { - &vfe_170_rdi_0_data, - &vfe_170_rdi_1_data, - &vfe_170_rdi_2_data, - NULL, - }, - }, - .dump_data = { - .num_reg_dump_entries = 2, - .num_lut_dump_entries = 1, - .dmi_cfg = 0xc24, - .dmi_addr = 0xc28, - .dmi_data_path_hi = 0xc2C, - .dmi_data_path_lo = 0xc30, - .reg_entry = { - { - .reg_dump_start = 0x0, - .reg_dump_end = 0x1160, - }, - { - .reg_dump_start = 0x2000, - .reg_dump_end = 0x3978, - }, - }, - .lut_entry = { - { - .lut_word_size = 64, - .lut_bank_sel = 0x40, - .lut_addr_size = 180, - }, - }, - }, - .mux_type = { - AIS_VFE_CAMIF_VER_2_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - }, -}; - -static struct ais_irq_register_set vfe170_bus_irq_reg[3] = { - { - .mask_reg_offset = 0x00002044, - .clear_reg_offset = 0x00002050, - .status_reg_offset = 0x0000205C, - }, - { - .mask_reg_offset = 0x00002048, - .clear_reg_offset = 0x00002054, - .status_reg_offset = 0x00002060, - }, - { - .mask_reg_offset = 0x0000204C, - .clear_reg_offset = 0x00002058, - .status_reg_offset = 0x00002064, - }, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_client ubwc_regs_client_3 = { - .tile_cfg = 0x0000252C, - .h_init = 0x00002530, - .v_init = 0x00002534, - .meta_addr = 0x00002538, - .meta_offset = 0x0000253C, - .meta_stride = 0x00002540, - .mode_cfg_0 = 0x00002544, - .bw_limit = 0x000025A0, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_client ubwc_regs_client_4 = { - .tile_cfg = 0x0000262C, - .h_init = 0x00002630, - .v_init = 0x00002634, - .meta_addr = 0x00002638, - .meta_offset = 0x0000263C, - .meta_stride = 0x00002640, - .mode_cfg_0 = 0x00002644, - .bw_limit = 0x000026A0, -}; - -static struct ais_vfe_bus_ver2_hw_info vfe170_bus_hw_info = { - .common_reg = { - .hw_version = 0x00002000, - .hw_capability = 0x00002004, - .sw_reset = 0x00002008, - .cgc_ovd = 0x0000200C, - .pwr_iso_cfg = 0x000020CC, - .dual_master_comp_cfg = 0x00002028, - .irq_reg_info = { - .num_registers = 3, - .irq_reg_set = vfe170_bus_irq_reg, - .global_clear_offset = 0x00002068, - .global_clear_bitmask = 0x00000001, - }, - .comp_error_status = 0x0000206C, - .comp_ovrwr_status = 0x00002070, - .dual_comp_error_status = 0x00002074, - .dual_comp_ovrwr_status = 0x00002078, - .addr_sync_cfg = 0x0000207C, - .addr_sync_frame_hdr = 0x00002080, - .addr_sync_no_sync = 0x00002084, - .addr_fifo_status = 0x000020A8, - .debug_status_cfg = 0x0000226C, - .debug_status_0 = 0x00002270, - }, - .num_client = 20, - .is_lite = 0, - .bus_client_reg = { - /* BUS Client 0 */ - { - .status0 = 0x00002200, - .status1 = 0x00002204, - .cfg = 0x00002208, - .header_addr = 0x0000220C, - .header_cfg = 0x00002210, - .image_addr = 0x00002214, - .image_addr_offset = 0x00002218, - .buffer_width_cfg = 0x0000221C, - .buffer_height_cfg = 0x00002220, - .packer_cfg = 0x00002224, - .stride = 0x00002228, - .irq_subsample_period = 0x00002248, - .irq_subsample_pattern = 0x0000224C, - .framedrop_period = 0x00002250, - .framedrop_pattern = 0x00002254, - .frame_inc = 0x00002258, - .burst_limit = 0x0000225C, - .ubwc_regs = NULL, - }, - /* BUS Client 1 */ - { - .status0 = 0x00002300, - .status1 = 0x00002304, - .cfg = 0x00002308, - .header_addr = 0x0000230C, - .header_cfg = 0x00002310, - .image_addr = 0x00002314, - .image_addr_offset = 0x00002318, - .buffer_width_cfg = 0x0000231C, - .buffer_height_cfg = 0x00002320, - .packer_cfg = 0x00002324, - .stride = 0x00002328, - .irq_subsample_period = 0x00002348, - .irq_subsample_pattern = 0x0000234C, - .framedrop_period = 0x00002350, - .framedrop_pattern = 0x00002354, - .frame_inc = 0x00002358, - .burst_limit = 0x0000235C, - .ubwc_regs = NULL, - }, - /* BUS Client 2 */ - { - .status0 = 0x00002400, - .status1 = 0x00002404, - .cfg = 0x00002408, - .header_addr = 0x0000240C, - .header_cfg = 0x00002410, - .image_addr = 0x00002414, - .image_addr_offset = 0x00002418, - .buffer_width_cfg = 0x0000241C, - .buffer_height_cfg = 0x00002420, - .packer_cfg = 0x00002424, - .stride = 0x00002428, - .irq_subsample_period = 0x00002448, - .irq_subsample_pattern = 0x0000244C, - .framedrop_period = 0x00002450, - .framedrop_pattern = 0x00002454, - .frame_inc = 0x00002458, - .burst_limit = 0x0000245C, - .ubwc_regs = NULL, - }, - /* BUS Client 3 */ - { - .status0 = 0x00002500, - .status1 = 0x00002504, - .cfg = 0x00002508, - .header_addr = 0x0000250C, - .header_cfg = 0x00002510, - .image_addr = 0x00002514, - .image_addr_offset = 0x00002518, - .buffer_width_cfg = 0x0000251C, - .buffer_height_cfg = 0x00002520, - .packer_cfg = 0x00002524, - .stride = 0x00002528, - .irq_subsample_period = 0x00002548, - .irq_subsample_pattern = 0x0000254C, - .framedrop_period = 0x00002550, - .framedrop_pattern = 0x00002554, - .frame_inc = 0x00002558, - .burst_limit = 0x0000255C, - .ubwc_regs = &ubwc_regs_client_3, - }, - /* BUS Client 4 */ - { - .status0 = 0x00002600, - .status1 = 0x00002604, - .cfg = 0x00002608, - .header_addr = 0x0000260C, - .header_cfg = 0x00002610, - .image_addr = 0x00002614, - .image_addr_offset = 0x00002618, - .buffer_width_cfg = 0x0000261C, - .buffer_height_cfg = 0x00002620, - .packer_cfg = 0x00002624, - .stride = 0x00002628, - .irq_subsample_period = 0x00002648, - .irq_subsample_pattern = 0x0000264C, - .framedrop_period = 0x00002650, - .framedrop_pattern = 0x00002654, - .frame_inc = 0x00002658, - .burst_limit = 0x0000265C, - .ubwc_regs = &ubwc_regs_client_4, - }, - /* BUS Client 5 */ - { - .status0 = 0x00002700, - .status1 = 0x00002704, - .cfg = 0x00002708, - .header_addr = 0x0000270C, - .header_cfg = 0x00002710, - .image_addr = 0x00002714, - .image_addr_offset = 0x00002718, - .buffer_width_cfg = 0x0000271C, - .buffer_height_cfg = 0x00002720, - .packer_cfg = 0x00002724, - .stride = 0x00002728, - .irq_subsample_period = 0x00002748, - .irq_subsample_pattern = 0x0000274C, - .framedrop_period = 0x00002750, - .framedrop_pattern = 0x00002754, - .frame_inc = 0x00002758, - .burst_limit = 0x0000275C, - .ubwc_regs = NULL, - }, - /* BUS Client 6 */ - { - .status0 = 0x00002800, - .status1 = 0x00002804, - .cfg = 0x00002808, - .header_addr = 0x0000280C, - .header_cfg = 0x00002810, - .image_addr = 0x00002814, - .image_addr_offset = 0x00002818, - .buffer_width_cfg = 0x0000281C, - .buffer_height_cfg = 0x00002820, - .packer_cfg = 0x00002824, - .stride = 0x00002828, - .irq_subsample_period = 0x00002848, - .irq_subsample_pattern = 0x0000284C, - .framedrop_period = 0x00002850, - .framedrop_pattern = 0x00002854, - .frame_inc = 0x00002858, - .burst_limit = 0x0000285C, - .ubwc_regs = NULL, - }, - /* BUS Client 7 */ - { - .status0 = 0x00002900, - .status1 = 0x00002904, - .cfg = 0x00002908, - .header_addr = 0x0000290C, - .header_cfg = 0x00002910, - .image_addr = 0x00002914, - .image_addr_offset = 0x00002918, - .buffer_width_cfg = 0x0000291C, - .buffer_height_cfg = 0x00002920, - .packer_cfg = 0x00002924, - .stride = 0x00002928, - .irq_subsample_period = 0x00002948, - .irq_subsample_pattern = 0x0000294C, - .framedrop_period = 0x00002950, - .framedrop_pattern = 0x00002954, - .frame_inc = 0x00002958, - .burst_limit = 0x0000295C, - .ubwc_regs = NULL, - }, - /* BUS Client 8 */ - { - .status0 = 0x00002A00, - .status1 = 0x00002A04, - .cfg = 0x00002A08, - .header_addr = 0x00002A0C, - .header_cfg = 0x00002A10, - .image_addr = 0x00002A14, - .image_addr_offset = 0x00002A18, - .buffer_width_cfg = 0x00002A1C, - .buffer_height_cfg = 0x00002A20, - .packer_cfg = 0x00002A24, - .stride = 0x00002A28, - .irq_subsample_period = 0x00002A48, - .irq_subsample_pattern = 0x00002A4C, - .framedrop_period = 0x00002A50, - .framedrop_pattern = 0x00002A54, - .frame_inc = 0x00002A58, - .burst_limit = 0x00002A5C, - .ubwc_regs = NULL, - }, - /* BUS Client 9 */ - { - .status0 = 0x00002B00, - .status1 = 0x00002B04, - .cfg = 0x00002B08, - .header_addr = 0x00002B0C, - .header_cfg = 0x00002B10, - .image_addr = 0x00002B14, - .image_addr_offset = 0x00002B18, - .buffer_width_cfg = 0x00002B1C, - .buffer_height_cfg = 0x00002B20, - .packer_cfg = 0x00002B24, - .stride = 0x00002B28, - .irq_subsample_period = 0x00002B48, - .irq_subsample_pattern = 0x00002B4C, - .framedrop_period = 0x00002B50, - .framedrop_pattern = 0x00002B54, - .frame_inc = 0x00002B58, - .burst_limit = 0x00002B5C, - .ubwc_regs = NULL, - }, - /* BUS Client 10 */ - { - .status0 = 0x00002C00, - .status1 = 0x00002C04, - .cfg = 0x00002C08, - .header_addr = 0x00002C0C, - .header_cfg = 0x00002C10, - .image_addr = 0x00002C14, - .image_addr_offset = 0x00002C18, - .buffer_width_cfg = 0x00002C1C, - .buffer_height_cfg = 0x00002C20, - .packer_cfg = 0x00002C24, - .stride = 0x00002C28, - .irq_subsample_period = 0x00002C48, - .irq_subsample_pattern = 0x00002C4C, - .framedrop_period = 0x00002C50, - .framedrop_pattern = 0x00002C54, - .frame_inc = 0x00002C58, - .burst_limit = 0x00002C5C, - .ubwc_regs = NULL, - }, - /* BUS Client 11 */ - { - .status0 = 0x00002D00, - .status1 = 0x00002D04, - .cfg = 0x00002D08, - .header_addr = 0x00002D0C, - .header_cfg = 0x00002D10, - .image_addr = 0x00002D14, - .image_addr_offset = 0x00002D18, - .buffer_width_cfg = 0x00002D1C, - .buffer_height_cfg = 0x00002D20, - .packer_cfg = 0x00002D24, - .stride = 0x00002D28, - .irq_subsample_period = 0x00002D48, - .irq_subsample_pattern = 0x00002D4C, - .framedrop_period = 0x00002D50, - .framedrop_pattern = 0x00002D54, - .frame_inc = 0x00002D58, - .burst_limit = 0x00002D5C, - .ubwc_regs = NULL, - }, - /* BUS Client 12 */ - { - .status0 = 0x00002E00, - .status1 = 0x00002E04, - .cfg = 0x00002E08, - .header_addr = 0x00002E0C, - .header_cfg = 0x00002E10, - .image_addr = 0x00002E14, - .image_addr_offset = 0x00002E18, - .buffer_width_cfg = 0x00002E1C, - .buffer_height_cfg = 0x00002E20, - .packer_cfg = 0x00002E24, - .stride = 0x00002E28, - .irq_subsample_period = 0x00002E48, - .irq_subsample_pattern = 0x00002E4C, - .framedrop_period = 0x00002E50, - .framedrop_pattern = 0x00002E54, - .frame_inc = 0x00002E58, - .burst_limit = 0x00002E5C, - .ubwc_regs = NULL, - }, - /* BUS Client 13 */ - { - .status0 = 0x00002F00, - .status1 = 0x00002F04, - .cfg = 0x00002F08, - .header_addr = 0x00002F0C, - .header_cfg = 0x00002F10, - .image_addr = 0x00002F14, - .image_addr_offset = 0x00002F18, - .buffer_width_cfg = 0x00002F1C, - .buffer_height_cfg = 0x00002F20, - .packer_cfg = 0x00002F24, - .stride = 0x00002F28, - .irq_subsample_period = 0x00002F48, - .irq_subsample_pattern = 0x00002F4C, - .framedrop_period = 0x00002F50, - .framedrop_pattern = 0x00002F54, - .frame_inc = 0x00002F58, - .burst_limit = 0x00002F5C, - .ubwc_regs = NULL, - }, - /* BUS Client 14 */ - { - .status0 = 0x00003000, - .status1 = 0x00003004, - .cfg = 0x00003008, - .header_addr = 0x0000300C, - .header_cfg = 0x00003010, - .image_addr = 0x00003014, - .image_addr_offset = 0x00003018, - .buffer_width_cfg = 0x0000301C, - .buffer_height_cfg = 0x00003020, - .packer_cfg = 0x00003024, - .stride = 0x00003028, - .irq_subsample_period = 0x00003048, - .irq_subsample_pattern = 0x0000304C, - .framedrop_period = 0x00003050, - .framedrop_pattern = 0x00003054, - .frame_inc = 0x00003058, - .burst_limit = 0x0000305C, - .ubwc_regs = NULL, - }, - /* BUS Client 15 */ - { - .status0 = 0x00003100, - .status1 = 0x00003104, - .cfg = 0x00003108, - .header_addr = 0x0000310C, - .header_cfg = 0x00003110, - .image_addr = 0x00003114, - .image_addr_offset = 0x00003118, - .buffer_width_cfg = 0x0000311C, - .buffer_height_cfg = 0x00003120, - .packer_cfg = 0x00003124, - .stride = 0x00003128, - .irq_subsample_period = 0x00003148, - .irq_subsample_pattern = 0x0000314C, - .framedrop_period = 0x00003150, - .framedrop_pattern = 0x00003154, - .frame_inc = 0x00003158, - .burst_limit = 0x0000315C, - .ubwc_regs = NULL, - }, - /* BUS Client 16 */ - { - .status0 = 0x00003200, - .status1 = 0x00003204, - .cfg = 0x00003208, - .header_addr = 0x0000320C, - .header_cfg = 0x00003210, - .image_addr = 0x00003214, - .image_addr_offset = 0x00003218, - .buffer_width_cfg = 0x0000321C, - .buffer_height_cfg = 0x00003220, - .packer_cfg = 0x00003224, - .stride = 0x00003228, - .irq_subsample_period = 0x00003248, - .irq_subsample_pattern = 0x0000324C, - .framedrop_period = 0x00003250, - .framedrop_pattern = 0x00003254, - .frame_inc = 0x00003258, - .burst_limit = 0x0000325C, - .ubwc_regs = NULL, - }, - /* BUS Client 17 */ - { - .status0 = 0x00003300, - .status1 = 0x00003304, - .cfg = 0x00003308, - .header_addr = 0x0000330C, - .header_cfg = 0x00003310, - .image_addr = 0x00003314, - .image_addr_offset = 0x00003318, - .buffer_width_cfg = 0x0000331C, - .buffer_height_cfg = 0x00003320, - .packer_cfg = 0x00003324, - .stride = 0x00003328, - .irq_subsample_period = 0x00003348, - .irq_subsample_pattern = 0x0000334C, - .framedrop_period = 0x00003350, - .framedrop_pattern = 0x00003354, - .frame_inc = 0x00003358, - .burst_limit = 0x0000335C, - .ubwc_regs = NULL, - }, - /* BUS Client 18 */ - { - .status0 = 0x00003400, - .status1 = 0x00003404, - .cfg = 0x00003408, - .header_addr = 0x0000340C, - .header_cfg = 0x00003410, - .image_addr = 0x00003414, - .image_addr_offset = 0x00003418, - .buffer_width_cfg = 0x0000341C, - .buffer_height_cfg = 0x00003420, - .packer_cfg = 0x00003424, - .stride = 0x00003428, - .irq_subsample_period = 0x00003448, - .irq_subsample_pattern = 0x0000344C, - .framedrop_period = 0x00003450, - .framedrop_pattern = 0x00003454, - .frame_inc = 0x00003458, - .burst_limit = 0x0000345C, - .ubwc_regs = NULL, - }, - /* BUS Client 19 */ - { - .status0 = 0x00003500, - .status1 = 0x00003504, - .cfg = 0x00003508, - .header_addr = 0x0000350C, - .header_cfg = 0x00003510, - .image_addr = 0x00003514, - .image_addr_offset = 0x00003518, - .buffer_width_cfg = 0x0000351C, - .buffer_height_cfg = 0x00003520, - .packer_cfg = 0x00003524, - .stride = 0x00003528, - .irq_subsample_period = 0x00003548, - .irq_subsample_pattern = 0x0000354C, - .framedrop_period = 0x00003550, - .framedrop_pattern = 0x00003554, - .frame_inc = 0x00003558, - .burst_limit = 0x0000355C, - .ubwc_regs = NULL, - }, - }, - .comp_grp_reg = { - /* AIS_VFE_BUS_VER2_COMP_GRP_0 */ - { - .comp_mask = 0x00002010, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_1 */ - { - .comp_mask = 0x00002014, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_2 */ - { - .comp_mask = 0x00002018, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_3 */ - { - .comp_mask = 0x0000201C, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_4 */ - { - .comp_mask = 0x00002020, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_5 */ - { - .comp_mask = 0x00002024, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_0 */ - { - .comp_mask = 0x0000202C, - .addr_sync_mask = 0x00002088, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_1 */ - { - .comp_mask = 0x00002030, - .addr_sync_mask = 0x0000208C, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_2 */ - { - .comp_mask = 0x00002034, - .addr_sync_mask = 0x00002090, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_3 */ - { - .comp_mask = 0x00002038, - .addr_sync_mask = 0x00002094, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_4 */ - { - .comp_mask = 0x0000203C, - .addr_sync_mask = 0x00002098, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_5 */ - { - .comp_mask = 0x00002040, - .addr_sync_mask = 0x0000209C, - }, - }, - .num_out = 18, - .vfe_out_hw_info = { - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI0, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI1, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI2, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FULL, - .max_width = 4096, - .max_height = 4096, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS4, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS16, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FD, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_PDAF, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - .max_width = -1, - .max_height = -1, - }, - }, - .reg_data = { - .ubwc_10bit_threshold_lossy_0 = 0, - .ubwc_10bit_threshold_lossy_1 = 0, - .ubwc_8bit_threshold_lossy_0 = 0, - .ubwc_8bit_threshold_lossy_1 = 0, - }, - .stats_data = &vfe170_stats_info, -}; - -static struct ais_vfe_hw_info ais_vfe170_hw_info = { - .irq_reg_info = &vfe170_top_irq_reg_info, - - .bus_version = AIS_VFE_BUS_VER_2_0, - .bus_hw_info = &vfe170_bus_hw_info, - - .top_version = AIS_VFE_TOP_VER_2_0, - .top_hw_info = &vfe170_top_hw_info, - - .camif_version = AIS_VFE_CAMIF_VER_2_0, - .camif_reg = &vfe170_camif_reg, - - .camif_lite_version = 0, - .camif_lite_reg = NULL, - -}; - -#endif /* _AIS_VFE170_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175.h deleted file mode 100755 index b9ab2d54e7d2..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175.h +++ /dev/null @@ -1,1223 +0,0 @@ -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE175_H_ -#define _AIS_VFE175_H_ - -#include "ais_vfe_camif_ver2.h" -#include "ais_vfe_camif_lite_ver2.h" -#include "ais_vfe_bus_ver2.h" -#include "ais_vfe_top_ver2.h" -#include "ais_vfe_core.h" - -static struct ais_irq_register_set vfe175_top_irq_reg_set[2] = { - { - .mask_reg_offset = 0x0000005C, - .clear_reg_offset = 0x00000064, - .status_reg_offset = 0x0000006C, - }, - { - .mask_reg_offset = 0x00000060, - .clear_reg_offset = 0x00000068, - .status_reg_offset = 0x00000070, - }, -}; - -static struct ais_irq_controller_reg_info vfe175_top_irq_reg_info = { - .num_registers = 2, - .irq_reg_set = vfe175_top_irq_reg_set, - .global_clear_offset = 0x00000058, - .global_clear_bitmask = 0x00000001, -}; - -static struct ais_vfe_camif_ver2_reg vfe175_camif_reg = { - .camif_cmd = 0x00000478, - .camif_config = 0x0000047C, - .line_skip_pattern = 0x00000488, - .pixel_skip_pattern = 0x0000048C, - .skip_period = 0x00000490, - .irq_subsample_pattern = 0x0000049C, - .epoch_irq = 0x000004A0, - .raw_crop_width_cfg = 0x00000CE4, - .raw_crop_height_cfg = 0x00000CE8, - .reg_update_cmd = 0x000004AC, - .vfe_diag_config = 0x00000C48, - .vfe_diag_sensor_status = 0x00000C4C, -}; - -static struct ais_vfe_camif_reg_data vfe_175_camif_reg_data = { - .raw_crop_first_pixel_shift = 16, - .raw_crop_first_pixel_mask = 0xFFFF, - .raw_crop_last_pixel_shift = 0x0, - .raw_crop_last_pixel_mask = 0x3FFF, - .raw_crop_first_line_shift = 16, - .raw_crop_first_line_mask = 0xFFFF, - .raw_crop_last_line_shift = 0, - .raw_crop_last_line_mask = 0x3FFF, - .input_mux_sel_shift = 5, - .input_mux_sel_mask = 0x3, - .extern_reg_update_shift = 4, - .extern_reg_update_mask = 1, - .pixel_pattern_shift = 0, - .pixel_pattern_mask = 0x7, - .dsp_mode_shift = 23, - .dsp_mode_mask = 0x1, - .dsp_en_shift = 3, - .dsp_en_mask = 0x1, - .reg_update_cmd_data = 0x1, - .epoch_line_cfg = 0x00140014, - .sof_irq_mask = 0x00000001, - .epoch0_irq_mask = 0x00000004, - .reg_update_irq_mask = 0x00000010, - .eof_irq_mask = 0x00000002, - .error_irq_mask0 = 0x0003FC00, - .error_irq_mask1 = 0xEFFF7E80, - .enable_diagnostic_hw = 0x1, -}; - -static struct ais_vfe_camif_lite_ver2_reg vfe175_camif_lite_reg = { - .camif_lite_cmd = 0x00000FC0, - .camif_lite_config = 0x00000FC4, - .lite_skip_period = 0x00000FC8, - .lite_irq_subsample_pattern = 0x00000FCC, - .lite_epoch_irq = 0x00000FD0, - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_camif_lite_ver2_reg_data vfe175_camif_lite_reg_data = { - .dual_pd_reg_update_cmd_data = 0x20, - .lite_epoch_line_cfg = 0x00140014, - .lite_sof_irq_mask = 0x00040000, - .lite_epoch0_irq_mask = 0x00100000, - .dual_pd_reg_upd_irq_mask = 0x04000000, - .lite_eof_irq_mask = 0x00080000, - .lite_error_irq_mask0 = 0x00400000, - .lite_error_irq_mask1 = 0x00004100, - .extern_reg_update_shift = 4, - .dual_pd_path_sel_shift = 24, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_lens_reg = { - .reset = 0x0000001C, - .cgc_ovd = 0x0000002C, - .enable = 0x00000040, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_stats_reg = { - .reset = 0x00000020, - .cgc_ovd = 0x00000030, - .enable = 0x00000044, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_color_reg = { - .reset = 0x00000024, - .cgc_ovd = 0x00000034, - .enable = 0x00000048, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_zoom_reg = { - .reset = 0x00000028, - .cgc_ovd = 0x00000038, - .enable = 0x0000004C, -}; - - -static struct ais_vfe_bus_ver2_stats_cfg_info vfe175_stats_info = { - .dmi_offset_info = { - .auto_increment = 0x00000100, - .cfg_offset = 0x00000C24, - .addr_offset = 0x00000C28, - .data_hi_offset = 0x00000C2C, - .data_lo_offset = 0x00000C30, - }, - .stats_cfg_offset = { - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI0 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI1 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI2 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI3 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FULL */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS4 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS16 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FD */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_PDAF */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - .cfg_offset = 0x00000AB8, - .num_cfg = 0x00000ABC, - .cfg_size = 0x00000AC0, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST */ - { - .res_index = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - .cfg_offset = 0x00000AD4, - .num_cfg = 0x00000AD8, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x36, - .bank_1 = 0x37, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - .cfg_offset = 0x00000AE4, - .num_cfg = 0x00000000, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x40, - .bank_1 = 0x41, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - .cfg_offset = 0x00000BC8, - .num_cfg = 0x00000BCC, - .cfg_size = 0x00000BD0, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - .cfg_offset = 0x00000BE4, - .num_cfg = 0x00000BE8, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x3A, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - .cfg_offset = 0x00000BEC, - .num_cfg = 0x00000BF0, - .cfg_size = 0x00000BF4, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - .cfg_offset = 0x00000BF8, - .num_cfg = 0x00000BFC, - .cfg_size = 0x00000C00, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - .cfg_offset = 0x00000C04, - .num_cfg = 0x00000C08, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x3B, - .bank_1 = 0x3C, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FULL_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS4_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS16_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_2PD */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_2PD, - .cfg_offset = 0x00000FF0, - .num_cfg = 0x00000FF4, - .cfg_size = 0x00000FF8, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x44, - .bank_1 = 0x45, - }, - }, - }, -}; - -static struct ais_vfe_top_ver2_reg_offset_common vfe175_top_common_reg = { - .hw_version = 0x00000000, - .hw_capability = 0x00000004, - .lens_feature = 0x00000008, - .stats_feature = 0x0000000C, - .color_feature = 0x00000010, - .zoom_feature = 0x00000014, - .global_reset_cmd = 0x00000018, - .module_ctrl = { - &vfe175_lens_reg, - &vfe175_stats_reg, - &vfe175_color_reg, - &vfe175_zoom_reg, - }, - .bus_cgc_ovd = 0x0000003C, - .core_cfg = 0x00000050, - .three_D_cfg = 0x00000054, - .violation_status = 0x0000007C, - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_ver2_reg vfe175_rdi_reg = { - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_reg_data vfe_175_rdi_0_data = { - .reg_update_cmd_data = 0x2, - .sof_irq_mask = 0x8000000, - .reg_update_irq_mask = 0x20, -}; - -static struct ais_vfe_rdi_reg_data vfe_175_rdi_1_data = { - .reg_update_cmd_data = 0x4, - .sof_irq_mask = 0x10000000, - .reg_update_irq_mask = 0x40, -}; - -static struct ais_vfe_rdi_reg_data vfe_175_rdi_2_data = { - .reg_update_cmd_data = 0x8, - .sof_irq_mask = 0x20000000, - .reg_update_irq_mask = 0x80, -}; - -static struct ais_vfe_top_ver2_hw_info vfe175_top_hw_info = { - .common_reg = &vfe175_top_common_reg, - .camif_hw_info = { - .common_reg = &vfe175_top_common_reg, - .camif_reg = &vfe175_camif_reg, - .reg_data = &vfe_175_camif_reg_data, - }, - .camif_lite_hw_info = { - .common_reg = &vfe175_top_common_reg, - .camif_lite_reg = &vfe175_camif_lite_reg, - .reg_data = &vfe175_camif_lite_reg_data, - }, - .rdi_hw_info = { - .common_reg = &vfe175_top_common_reg, - .rdi_reg = &vfe175_rdi_reg, - .reg_data = { - &vfe_175_rdi_0_data, - &vfe_175_rdi_1_data, - &vfe_175_rdi_2_data, - NULL, - }, - }, - .dump_data = { - .num_reg_dump_entries = 2, - .num_lut_dump_entries = 1, - .dmi_cfg = 0xc24, - .dmi_addr = 0xc28, - .dmi_data_path_hi = 0xc2C, - .dmi_data_path_lo = 0xc30, - .reg_entry = { - { - .reg_dump_start = 0x0, - .reg_dump_end = 0x1160, - }, - { - .reg_dump_start = 0x2000, - .reg_dump_end = 0x3978, - }, - }, - .lut_entry = { - { - .lut_word_size = 64, - .lut_bank_sel = 0x40, - .lut_addr_size = 180, - }, - }, - }, - .mux_type = { - AIS_VFE_CAMIF_VER_2_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_CAMIF_LITE_VER_2_0, - }, -}; - -static struct ais_irq_register_set vfe175_bus_irq_reg[3] = { - { - .mask_reg_offset = 0x00002044, - .clear_reg_offset = 0x00002050, - .status_reg_offset = 0x0000205C, - }, - { - .mask_reg_offset = 0x00002048, - .clear_reg_offset = 0x00002054, - .status_reg_offset = 0x00002060, - }, - { - .mask_reg_offset = 0x0000204C, - .clear_reg_offset = 0x00002058, - .status_reg_offset = 0x00002064, - }, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_ubwc_regs_client_3 = { - .tile_cfg = 0x0000252C, - .h_init = 0x00002530, - .v_init = 0x00002534, - .meta_addr = 0x00002538, - .meta_offset = 0x0000253C, - .meta_stride = 0x00002540, - .mode_cfg_0 = 0x00002544, - .mode_cfg_1 = 0x000025A4, - .bw_limit = 0x000025A0, - .threshlod_lossy_0 = 0x000025A8, - .threshlod_lossy_1 = 0x000025AC, - -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_ubwc_regs_client_4 = { - .tile_cfg = 0x0000262C, - .h_init = 0x00002630, - .v_init = 0x00002634, - .meta_addr = 0x00002638, - .meta_offset = 0x0000263C, - .meta_stride = 0x00002640, - .mode_cfg_0 = 0x00002644, - .mode_cfg_1 = 0x000026A4, - .bw_limit = 0x000026A0, - .threshlod_lossy_0 = 0x000026A8, - .threshlod_lossy_1 = 0x000026AC, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_ubwc_regs_client_20 = { - .tile_cfg = 0x0000362C, - .h_init = 0x00003630, - .v_init = 0x00003634, - .meta_addr = 0x00003638, - .meta_offset = 0x0000363C, - .meta_stride = 0x00003640, - .mode_cfg_0 = 0x00003644, - .mode_cfg_1 = 0x000036A4, - .bw_limit = 0x000036A0, - .threshlod_lossy_0 = 0x000036A8, - .threshlod_lossy_1 = 0x000036AC, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_ubwc_regs_client_21 = { - .tile_cfg = 0x0000372C, - .h_init = 0x00003730, - .v_init = 0x00003734, - .meta_addr = 0x00003738, - .meta_offset = 0x0000373C, - .meta_stride = 0x00003740, - .mode_cfg_0 = 0x00003744, - .mode_cfg_1 = 0x000037A4, - .bw_limit = 0x000037A0, - .threshlod_lossy_0 = 0x000037A8, - .threshlod_lossy_1 = 0x000037AC, -}; - -static struct ais_vfe_bus_ver2_hw_info vfe175_bus_hw_info = { - .common_reg = { - .hw_version = 0x00002000, - .hw_capability = 0x00002004, - .sw_reset = 0x00002008, - .cgc_ovd = 0x0000200C, - .pwr_iso_cfg = 0x000020CC, - .dual_master_comp_cfg = 0x00002028, - .irq_reg_info = { - .num_registers = 3, - .irq_reg_set = vfe175_bus_irq_reg, - .global_clear_offset = 0x00002068, - .global_clear_bitmask = 0x00000001, - }, - .comp_error_status = 0x0000206C, - .comp_ovrwr_status = 0x00002070, - .dual_comp_error_status = 0x00002074, - .dual_comp_ovrwr_status = 0x00002078, - .addr_sync_cfg = 0x0000207C, - .addr_sync_frame_hdr = 0x00002080, - .addr_sync_no_sync = 0x00002084, - .addr_fifo_status = 0x000020A8, - .debug_status_cfg = 0x0000226C, - .debug_status_0 = 0x00002270, - }, - .num_client = 24, - .is_lite = 0, - .bus_client_reg = { - /* BUS Client 0 */ - { - .status0 = 0x00002200, - .status1 = 0x00002204, - .cfg = 0x00002208, - .header_addr = 0x0000220C, - .header_cfg = 0x00002210, - .image_addr = 0x00002214, - .image_addr_offset = 0x00002218, - .buffer_width_cfg = 0x0000221C, - .buffer_height_cfg = 0x00002220, - .packer_cfg = 0x00002224, - .stride = 0x00002228, - .irq_subsample_period = 0x00002248, - .irq_subsample_pattern = 0x0000224C, - .framedrop_period = 0x00002250, - .framedrop_pattern = 0x00002254, - .frame_inc = 0x00002258, - .burst_limit = 0x0000225C, - .ubwc_regs = NULL, - }, - /* BUS Client 1 */ - { - .status0 = 0x00002300, - .status1 = 0x00002304, - .cfg = 0x00002308, - .header_addr = 0x0000230C, - .header_cfg = 0x00002310, - .image_addr = 0x00002314, - .image_addr_offset = 0x00002318, - .buffer_width_cfg = 0x0000231C, - .buffer_height_cfg = 0x00002320, - .packer_cfg = 0x00002324, - .stride = 0x00002328, - .irq_subsample_period = 0x00002348, - .irq_subsample_pattern = 0x0000234C, - .framedrop_period = 0x00002350, - .framedrop_pattern = 0x00002354, - .frame_inc = 0x00002358, - .burst_limit = 0x0000235C, - .ubwc_regs = NULL, - }, - /* BUS Client 2 */ - { - .status0 = 0x00002400, - .status1 = 0x00002404, - .cfg = 0x00002408, - .header_addr = 0x0000240C, - .header_cfg = 0x00002410, - .image_addr = 0x00002414, - .image_addr_offset = 0x00002418, - .buffer_width_cfg = 0x0000241C, - .buffer_height_cfg = 0x00002420, - .packer_cfg = 0x00002424, - .stride = 0x00002428, - .irq_subsample_period = 0x00002448, - .irq_subsample_pattern = 0x0000244C, - .framedrop_period = 0x00002450, - .framedrop_pattern = 0x00002454, - .frame_inc = 0x00002458, - .burst_limit = 0x0000245C, - .ubwc_regs = NULL, - }, - /* BUS Client 3 */ - { - .status0 = 0x00002500, - .status1 = 0x00002504, - .cfg = 0x00002508, - .header_addr = 0x0000250C, - .header_cfg = 0x00002510, - .image_addr = 0x00002514, - .image_addr_offset = 0x00002518, - .buffer_width_cfg = 0x0000251C, - .buffer_height_cfg = 0x00002520, - .packer_cfg = 0x00002524, - .stride = 0x00002528, - .irq_subsample_period = 0x00002548, - .irq_subsample_pattern = 0x0000254C, - .framedrop_period = 0x00002550, - .framedrop_pattern = 0x00002554, - .frame_inc = 0x00002558, - .burst_limit = 0x0000255C, - .ubwc_regs = &vfe175_ubwc_regs_client_3, - }, - /* BUS Client 4 */ - { - .status0 = 0x00002600, - .status1 = 0x00002604, - .cfg = 0x00002608, - .header_addr = 0x0000260C, - .header_cfg = 0x00002610, - .image_addr = 0x00002614, - .image_addr_offset = 0x00002618, - .buffer_width_cfg = 0x0000261C, - .buffer_height_cfg = 0x00002620, - .packer_cfg = 0x00002624, - .stride = 0x00002628, - .irq_subsample_period = 0x00002648, - .irq_subsample_pattern = 0x0000264C, - .framedrop_period = 0x00002650, - .framedrop_pattern = 0x00002654, - .frame_inc = 0x00002658, - .burst_limit = 0x0000265C, - .ubwc_regs = &vfe175_ubwc_regs_client_4, - }, - /* BUS Client 5 */ - { - .status0 = 0x00002700, - .status1 = 0x00002704, - .cfg = 0x00002708, - .header_addr = 0x0000270C, - .header_cfg = 0x00002710, - .image_addr = 0x00002714, - .image_addr_offset = 0x00002718, - .buffer_width_cfg = 0x0000271C, - .buffer_height_cfg = 0x00002720, - .packer_cfg = 0x00002724, - .stride = 0x00002728, - .irq_subsample_period = 0x00002748, - .irq_subsample_pattern = 0x0000274C, - .framedrop_period = 0x00002750, - .framedrop_pattern = 0x00002754, - .frame_inc = 0x00002758, - .burst_limit = 0x0000275C, - .ubwc_regs = NULL, - }, - /* BUS Client 6 */ - { - .status0 = 0x00002800, - .status1 = 0x00002804, - .cfg = 0x00002808, - .header_addr = 0x0000280C, - .header_cfg = 0x00002810, - .image_addr = 0x00002814, - .image_addr_offset = 0x00002818, - .buffer_width_cfg = 0x0000281C, - .buffer_height_cfg = 0x00002820, - .packer_cfg = 0x00002824, - .stride = 0x00002828, - .irq_subsample_period = 0x00002848, - .irq_subsample_pattern = 0x0000284C, - .framedrop_period = 0x00002850, - .framedrop_pattern = 0x00002854, - .frame_inc = 0x00002858, - .burst_limit = 0x0000285C, - .ubwc_regs = NULL, - }, - /* BUS Client 7 */ - { - .status0 = 0x00002900, - .status1 = 0x00002904, - .cfg = 0x00002908, - .header_addr = 0x0000290C, - .header_cfg = 0x00002910, - .image_addr = 0x00002914, - .image_addr_offset = 0x00002918, - .buffer_width_cfg = 0x0000291C, - .buffer_height_cfg = 0x00002920, - .packer_cfg = 0x00002924, - .stride = 0x00002928, - .irq_subsample_period = 0x00002948, - .irq_subsample_pattern = 0x0000294C, - .framedrop_period = 0x00002950, - .framedrop_pattern = 0x00002954, - .frame_inc = 0x00002958, - .burst_limit = 0x0000295C, - .ubwc_regs = NULL, - }, - /* BUS Client 8 */ - { - .status0 = 0x00002A00, - .status1 = 0x00002A04, - .cfg = 0x00002A08, - .header_addr = 0x00002A0C, - .header_cfg = 0x00002A10, - .image_addr = 0x00002A14, - .image_addr_offset = 0x00002A18, - .buffer_width_cfg = 0x00002A1C, - .buffer_height_cfg = 0x00002A20, - .packer_cfg = 0x00002A24, - .stride = 0x00002A28, - .irq_subsample_period = 0x00002A48, - .irq_subsample_pattern = 0x00002A4C, - .framedrop_period = 0x00002A50, - .framedrop_pattern = 0x00002A54, - .frame_inc = 0x00002A58, - .burst_limit = 0x00002A5C, - .ubwc_regs = NULL, - }, - /* BUS Client 9 */ - { - .status0 = 0x00002B00, - .status1 = 0x00002B04, - .cfg = 0x00002B08, - .header_addr = 0x00002B0C, - .header_cfg = 0x00002B10, - .image_addr = 0x00002B14, - .image_addr_offset = 0x00002B18, - .buffer_width_cfg = 0x00002B1C, - .buffer_height_cfg = 0x00002B20, - .packer_cfg = 0x00002B24, - .stride = 0x00002B28, - .irq_subsample_period = 0x00002B48, - .irq_subsample_pattern = 0x00002B4C, - .framedrop_period = 0x00002B50, - .framedrop_pattern = 0x00002B54, - .frame_inc = 0x00002B58, - .burst_limit = 0x00002B5C, - .ubwc_regs = NULL, - }, - /* BUS Client 10 */ - { - .status0 = 0x00002C00, - .status1 = 0x00002C04, - .cfg = 0x00002C08, - .header_addr = 0x00002C0C, - .header_cfg = 0x00002C10, - .image_addr = 0x00002C14, - .image_addr_offset = 0x00002C18, - .buffer_width_cfg = 0x00002C1C, - .buffer_height_cfg = 0x00002C20, - .packer_cfg = 0x00002C24, - .stride = 0x00002C28, - .irq_subsample_period = 0x00002C48, - .irq_subsample_pattern = 0x00002C4C, - .framedrop_period = 0x00002C50, - .framedrop_pattern = 0x00002C54, - .frame_inc = 0x00002C58, - .burst_limit = 0x00002C5C, - .ubwc_regs = NULL, - }, - /* BUS Client 11 */ - { - .status0 = 0x00002D00, - .status1 = 0x00002D04, - .cfg = 0x00002D08, - .header_addr = 0x00002D0C, - .header_cfg = 0x00002D10, - .image_addr = 0x00002D14, - .image_addr_offset = 0x00002D18, - .buffer_width_cfg = 0x00002D1C, - .buffer_height_cfg = 0x00002D20, - .packer_cfg = 0x00002D24, - .stride = 0x00002D28, - .irq_subsample_period = 0x00002D48, - .irq_subsample_pattern = 0x00002D4C, - .framedrop_period = 0x00002D50, - .framedrop_pattern = 0x00002D54, - .frame_inc = 0x00002D58, - .burst_limit = 0x00002D5C, - .ubwc_regs = NULL, - }, - /* BUS Client 12 */ - { - .status0 = 0x00002E00, - .status1 = 0x00002E04, - .cfg = 0x00002E08, - .header_addr = 0x00002E0C, - .header_cfg = 0x00002E10, - .image_addr = 0x00002E14, - .image_addr_offset = 0x00002E18, - .buffer_width_cfg = 0x00002E1C, - .buffer_height_cfg = 0x00002E20, - .packer_cfg = 0x00002E24, - .stride = 0x00002E28, - .irq_subsample_period = 0x00002E48, - .irq_subsample_pattern = 0x00002E4C, - .framedrop_period = 0x00002E50, - .framedrop_pattern = 0x00002E54, - .frame_inc = 0x00002E58, - .burst_limit = 0x00002E5C, - .ubwc_regs = NULL, - }, - /* BUS Client 13 */ - { - .status0 = 0x00002F00, - .status1 = 0x00002F04, - .cfg = 0x00002F08, - .header_addr = 0x00002F0C, - .header_cfg = 0x00002F10, - .image_addr = 0x00002F14, - .image_addr_offset = 0x00002F18, - .buffer_width_cfg = 0x00002F1C, - .buffer_height_cfg = 0x00002F20, - .packer_cfg = 0x00002F24, - .stride = 0x00002F28, - .irq_subsample_period = 0x00002F48, - .irq_subsample_pattern = 0x00002F4C, - .framedrop_period = 0x00002F50, - .framedrop_pattern = 0x00002F54, - .frame_inc = 0x00002F58, - .burst_limit = 0x00002F5C, - .ubwc_regs = NULL, - }, - /* BUS Client 14 */ - { - .status0 = 0x00003000, - .status1 = 0x00003004, - .cfg = 0x00003008, - .header_addr = 0x0000300C, - .header_cfg = 0x00003010, - .image_addr = 0x00003014, - .image_addr_offset = 0x00003018, - .buffer_width_cfg = 0x0000301C, - .buffer_height_cfg = 0x00003020, - .packer_cfg = 0x00003024, - .stride = 0x00003028, - .irq_subsample_period = 0x00003048, - .irq_subsample_pattern = 0x0000304C, - .framedrop_period = 0x00003050, - .framedrop_pattern = 0x00003054, - .frame_inc = 0x00003058, - .burst_limit = 0x0000305C, - .ubwc_regs = NULL, - }, - /* BUS Client 15 */ - { - .status0 = 0x00003100, - .status1 = 0x00003104, - .cfg = 0x00003108, - .header_addr = 0x0000310C, - .header_cfg = 0x00003110, - .image_addr = 0x00003114, - .image_addr_offset = 0x00003118, - .buffer_width_cfg = 0x0000311C, - .buffer_height_cfg = 0x00003120, - .packer_cfg = 0x00003124, - .stride = 0x00003128, - .irq_subsample_period = 0x00003148, - .irq_subsample_pattern = 0x0000314C, - .framedrop_period = 0x00003150, - .framedrop_pattern = 0x00003154, - .frame_inc = 0x00003158, - .burst_limit = 0x0000315C, - .ubwc_regs = NULL, - }, - /* BUS Client 16 */ - { - .status0 = 0x00003200, - .status1 = 0x00003204, - .cfg = 0x00003208, - .header_addr = 0x0000320C, - .header_cfg = 0x00003210, - .image_addr = 0x00003214, - .image_addr_offset = 0x00003218, - .buffer_width_cfg = 0x0000321C, - .buffer_height_cfg = 0x00003220, - .packer_cfg = 0x00003224, - .stride = 0x00003228, - .irq_subsample_period = 0x00003248, - .irq_subsample_pattern = 0x0000324C, - .framedrop_period = 0x00003250, - .framedrop_pattern = 0x00003254, - .frame_inc = 0x00003258, - .burst_limit = 0x0000325C, - .ubwc_regs = NULL, - }, - /* BUS Client 17 */ - { - .status0 = 0x00003300, - .status1 = 0x00003304, - .cfg = 0x00003308, - .header_addr = 0x0000330C, - .header_cfg = 0x00003310, - .image_addr = 0x00003314, - .image_addr_offset = 0x00003318, - .buffer_width_cfg = 0x0000331C, - .buffer_height_cfg = 0x00003320, - .packer_cfg = 0x00003324, - .stride = 0x00003328, - .irq_subsample_period = 0x00003348, - .irq_subsample_pattern = 0x0000334C, - .framedrop_period = 0x00003350, - .framedrop_pattern = 0x00003354, - .frame_inc = 0x00003358, - .burst_limit = 0x0000335C, - .ubwc_regs = NULL, - }, - /* BUS Client 18 */ - { - .status0 = 0x00003400, - .status1 = 0x00003404, - .cfg = 0x00003408, - .header_addr = 0x0000340C, - .header_cfg = 0x00003410, - .image_addr = 0x00003414, - .image_addr_offset = 0x00003418, - .buffer_width_cfg = 0x0000341C, - .buffer_height_cfg = 0x00003420, - .packer_cfg = 0x00003424, - .stride = 0x00003428, - .irq_subsample_period = 0x00003448, - .irq_subsample_pattern = 0x0000344C, - .framedrop_period = 0x00003450, - .framedrop_pattern = 0x00003454, - .frame_inc = 0x00003458, - .burst_limit = 0x0000345C, - .ubwc_regs = NULL, - }, - /* BUS Client 19 */ - { - .status0 = 0x00003500, - .status1 = 0x00003504, - .cfg = 0x00003508, - .header_addr = 0x0000350C, - .header_cfg = 0x00003510, - .image_addr = 0x00003514, - .image_addr_offset = 0x00003518, - .buffer_width_cfg = 0x0000351C, - .buffer_height_cfg = 0x00003520, - .packer_cfg = 0x00003524, - .stride = 0x00003528, - .irq_subsample_period = 0x00003548, - .irq_subsample_pattern = 0x0000354C, - .framedrop_period = 0x00003550, - .framedrop_pattern = 0x00003554, - .frame_inc = 0x00003558, - .burst_limit = 0x0000355C, - .ubwc_regs = NULL, - }, - /* BUS Client 20 */ - { - .status0 = 0x00003600, - .status1 = 0x00003604, - .cfg = 0x00003608, - .header_addr = 0x0000360C, - .header_cfg = 0x00003610, - .image_addr = 0x00003614, - .image_addr_offset = 0x00003618, - .buffer_width_cfg = 0x0000361C, - .buffer_height_cfg = 0x00003620, - .packer_cfg = 0x00003624, - .stride = 0x00003628, - .irq_subsample_period = 0x00003648, - .irq_subsample_pattern = 0x0000364C, - .framedrop_period = 0x00003650, - .framedrop_pattern = 0x00003654, - .frame_inc = 0x00003658, - .burst_limit = 0x0000365C, - .ubwc_regs = &vfe175_ubwc_regs_client_20, - }, - /* BUS Client 21 */ - { - .status0 = 0x00003700, - .status1 = 0x00003704, - .cfg = 0x00003708, - .header_addr = 0x0000370C, - .header_cfg = 0x00003710, - .image_addr = 0x00003714, - .image_addr_offset = 0x00003718, - .buffer_width_cfg = 0x0000371C, - .buffer_height_cfg = 0x00003720, - .packer_cfg = 0x00003724, - .stride = 0x00003728, - .irq_subsample_period = 0x00003748, - .irq_subsample_pattern = 0x0000374C, - .framedrop_period = 0x00003750, - .framedrop_pattern = 0x00003754, - .frame_inc = 0x00003758, - .burst_limit = 0x0000375C, - .ubwc_regs = &vfe175_ubwc_regs_client_21, - }, - /* BUS Client 22 */ - { - .status0 = 0x00003800, - .status1 = 0x00003804, - .cfg = 0x00003808, - .header_addr = 0x0000380C, - .header_cfg = 0x00003810, - .image_addr = 0x00003814, - .image_addr_offset = 0x00003818, - .buffer_width_cfg = 0x0000381C, - .buffer_height_cfg = 0x00003820, - .packer_cfg = 0x00003824, - .stride = 0x00003828, - .irq_subsample_period = 0x00003848, - .irq_subsample_pattern = 0x0000384C, - .framedrop_period = 0x00003850, - .framedrop_pattern = 0x00003854, - .frame_inc = 0x00003858, - .burst_limit = 0x0000385C, - .ubwc_regs = NULL, - }, - /* BUS Client 23 */ - { - .status0 = 0x00003900, - .status1 = 0x00003904, - .cfg = 0x00003908, - .header_addr = 0x0000390C, - .header_cfg = 0x00003910, - .image_addr = 0x00003914, - .image_addr_offset = 0x00003918, - .buffer_width_cfg = 0x0000391C, - .buffer_height_cfg = 0x00003920, - .packer_cfg = 0x00003924, - .stride = 0x00003928, - .irq_subsample_period = 0x00003948, - .irq_subsample_pattern = 0x0000394C, - .framedrop_period = 0x00003950, - .framedrop_pattern = 0x00003954, - .frame_inc = 0x00003958, - .burst_limit = 0x0000395C, - .ubwc_regs = NULL, - }, - }, - .comp_grp_reg = { - /* AIS_VFE_BUS_VER2_COMP_GRP_0 */ - { - .comp_mask = 0x00002010, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_1 */ - { - .comp_mask = 0x00002014, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_2 */ - { - .comp_mask = 0x00002018, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_3 */ - { - .comp_mask = 0x0000201C, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_4 */ - { - .comp_mask = 0x00002020, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_5 */ - { - .comp_mask = 0x00002024, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_0 */ - { - .comp_mask = 0x0000202C, - .addr_sync_mask = 0x00002088, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_1 */ - { - .comp_mask = 0x00002030, - .addr_sync_mask = 0x0000208C, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_2 */ - { - .comp_mask = 0x00002034, - .addr_sync_mask = 0x00002090, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_3 */ - { - .comp_mask = 0x00002038, - .addr_sync_mask = 0x00002094, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_4 */ - { - .comp_mask = 0x0000203C, - .addr_sync_mask = 0x00002098, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_5 */ - { - .comp_mask = 0x00002040, - .addr_sync_mask = 0x0000209C, - }, - }, - .num_out = 22, - .vfe_out_hw_info = { - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI0, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI1, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI2, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FULL, - .max_width = 4096, - .max_height = 4096, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS4, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS16, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FD, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_PDAF, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FULL_DISP, - .max_width = 4096, - .max_height = 4096, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS4_DISP, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS16_DISP, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_2PD, - .max_width = 1920, - .max_height = 1080, - }, - }, - .reg_data = { - .ubwc_10bit_threshold_lossy_0 = 0x8330002, - .ubwc_10bit_threshold_lossy_1 = 0x20204, - .ubwc_8bit_threshold_lossy_0 = 0x6210022, - .ubwc_8bit_threshold_lossy_1 = 0xE0E, - }, - .stats_data = &vfe175_stats_info, -}; - -static struct ais_vfe_hw_info ais_vfe175_hw_info = { - .irq_reg_info = &vfe175_top_irq_reg_info, - - .bus_version = AIS_VFE_BUS_VER_2_0, - .bus_hw_info = &vfe175_bus_hw_info, - - .top_version = AIS_VFE_TOP_VER_2_0, - .top_hw_info = &vfe175_top_hw_info, - - .camif_version = AIS_VFE_CAMIF_VER_2_0, - .camif_reg = &vfe175_camif_reg, - - .camif_lite_version = AIS_VFE_CAMIF_LITE_VER_2_0, - .camif_lite_reg = &vfe175_camif_lite_reg, - -}; - -#endif /* _AIS_VFE175_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175_130.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175_130.h deleted file mode 100755 index e834f5302d5f..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe175_130.h +++ /dev/null @@ -1,1327 +0,0 @@ -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE175_130_H_ -#define _AIS_VFE175_130_H_ - -#include "ais_vfe_camif_ver2.h" -#include "ais_vfe_camif_lite_ver2.h" -#include "ais_vfe_bus_ver2.h" -#include "ais_vfe_bus_rd_ver1.h" -#include "ais_vfe_top_ver2.h" -#include "ais_vfe_core.h" - -static struct ais_irq_register_set vfe175_130_top_irq_reg_set[2] = { - { - .mask_reg_offset = 0x0000005C, - .clear_reg_offset = 0x00000064, - .status_reg_offset = 0x0000006C, - }, - { - .mask_reg_offset = 0x00000060, - .clear_reg_offset = 0x00000068, - .status_reg_offset = 0x00000070, - }, -}; - -static struct ais_irq_controller_reg_info vfe175_130_top_irq_reg_info = { - .num_registers = 2, - .irq_reg_set = vfe175_130_top_irq_reg_set, - .global_clear_offset = 0x00000058, - .global_clear_bitmask = 0x00000001, -}; - -static struct ais_vfe_camif_ver2_reg vfe175_130_camif_reg = { - .camif_cmd = 0x00000478, - .camif_config = 0x0000047C, - .line_skip_pattern = 0x00000488, - .pixel_skip_pattern = 0x0000048C, - .skip_period = 0x00000490, - .irq_subsample_pattern = 0x0000049C, - .epoch_irq = 0x000004A0, - .raw_crop_width_cfg = 0x00000CE4, - .raw_crop_height_cfg = 0x00000CE8, - .reg_update_cmd = 0x000004AC, - .vfe_diag_config = 0x00000C48, - .vfe_diag_sensor_status = 0x00000C4C, -}; - -static struct ais_vfe_camif_reg_data vfe_175_130_camif_reg_data = { - .raw_crop_first_pixel_shift = 16, - .raw_crop_first_pixel_mask = 0xFFFF, - .raw_crop_last_pixel_shift = 0x0, - .raw_crop_last_pixel_mask = 0x3FFF, - .raw_crop_first_line_shift = 16, - .raw_crop_first_line_mask = 0xFFFF, - .raw_crop_last_line_shift = 0, - .raw_crop_last_line_mask = 0x3FFF, - .input_mux_sel_shift = 5, - .input_mux_sel_mask = 0x3, - .extern_reg_update_shift = 4, - .extern_reg_update_mask = 1, - .pixel_pattern_shift = 0, - .pixel_pattern_mask = 0x7, - .dsp_mode_shift = 23, - .dsp_mode_mask = 0x1, - .dsp_en_shift = 3, - .dsp_en_mask = 0x1, - .reg_update_cmd_data = 0x1, - .epoch_line_cfg = 0x00140014, - .sof_irq_mask = 0x00000001, - .epoch0_irq_mask = 0x00000004, - .reg_update_irq_mask = 0x00000010, - .eof_irq_mask = 0x00000002, - .error_irq_mask0 = 0x0003FC00, - .error_irq_mask1 = 0xEFFF7E80, - .enable_diagnostic_hw = 0x1, -}; - -static struct ais_vfe_fe_ver1_reg vfe175_130_fe_reg = { - .camif_cmd = 0x00000478, - .camif_config = 0x0000047C, - .line_skip_pattern = 0x00000488, - .pixel_skip_pattern = 0x0000048C, - .skip_period = 0x00000490, - .irq_subsample_pattern = 0x0000049C, - .epoch_irq = 0x000004A0, - .raw_crop_width_cfg = 0x00000CE4, - .raw_crop_height_cfg = 0x00000CE8, - .reg_update_cmd = 0x000004AC, - .vfe_diag_config = 0x00000C48, - .vfe_diag_sensor_status = 0x00000C4C, - .fe_cfg = 0x00000084, -}; - -static struct ais_vfe_fe_reg_data vfe_175_130_fe_reg_data = { - .raw_crop_first_pixel_shift = 16, - .raw_crop_first_pixel_mask = 0xFFFF, - .raw_crop_last_pixel_shift = 0x0, - .raw_crop_last_pixel_mask = 0x3FFF, - .raw_crop_first_line_shift = 16, - .raw_crop_first_line_mask = 0xFFFF, - .raw_crop_last_line_shift = 0, - .raw_crop_last_line_mask = 0x3FFF, - .input_mux_sel_shift = 5, - .input_mux_sel_mask = 0x3, - .extern_reg_update_shift = 4, - .extern_reg_update_mask = 1, - .pixel_pattern_shift = 0, - .pixel_pattern_mask = 0x7, - .dsp_mode_shift = 23, - .dsp_mode_mask = 0x1, - .dsp_en_shift = 3, - .dsp_en_mask = 0x1, - .reg_update_cmd_data = 0x1, - .epoch_line_cfg = 0x00140014, - .sof_irq_mask = 0x00000001, - .epoch0_irq_mask = 0x00000004, - .reg_update_irq_mask = 0x00000010, - .eof_irq_mask = 0x00000002, - .error_irq_mask0 = 0x0003FC00, - .error_irq_mask1 = 0xEFFF7E80, - .enable_diagnostic_hw = 0x1, - .fe_mux_data = 0x2, - .hbi_cnt_shift = 0x8, -}; - -static struct ais_vfe_camif_lite_ver2_reg vfe175_130_camif_lite_reg = { - .camif_lite_cmd = 0x00000FC0, - .camif_lite_config = 0x00000FC4, - .lite_skip_period = 0x00000FC8, - .lite_irq_subsample_pattern = 0x00000FCC, - .lite_epoch_irq = 0x00000FD0, - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_camif_lite_ver2_reg_data - vfe175_130_camif_lite_reg_data = { - .dual_pd_reg_update_cmd_data = 0x20, - .lite_epoch_line_cfg = 0x00140014, - .lite_sof_irq_mask = 0x00040000, - .lite_epoch0_irq_mask = 0x00100000, - .dual_pd_reg_upd_irq_mask = 0x04000000, - .lite_eof_irq_mask = 0x00080000, - .lite_error_irq_mask0 = 0x00400000, - .lite_error_irq_mask1 = 0x00004100, - .extern_reg_update_shift = 4, - .dual_pd_path_sel_shift = 24, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_130_lens_reg = { - .reset = 0x0000001C, - .cgc_ovd = 0x0000002C, - .enable = 0x00000040, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_130_stats_reg = { - .reset = 0x00000020, - .cgc_ovd = 0x00000030, - .enable = 0x00000044, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_130_color_reg = { - .reset = 0x00000024, - .cgc_ovd = 0x00000034, - .enable = 0x00000048, -}; - -static struct ais_vfe_top_ver2_reg_offset_module_ctrl vfe175_130_zoom_reg = { - .reset = 0x00000028, - .cgc_ovd = 0x00000038, - .enable = 0x0000004C, -}; - -static struct ais_vfe_bus_ver2_stats_cfg_info stats_175_130_info = { - .dmi_offset_info = { - .auto_increment = 0x00000100, - .cfg_offset = 0x00000C24, - .addr_offset = 0x00000C28, - .data_hi_offset = 0x00000C2C, - .data_lo_offset = 0x00000C30, - }, - .stats_cfg_offset = { - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI0 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI1 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI2 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RDI3 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FULL */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS4 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS16 */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FD */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_PDAF */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - .cfg_offset = 0x00000AB8, - .num_cfg = 0x00000ABC, - .cfg_size = 0x00000AC0, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST */ - { - .res_index = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - .cfg_offset = 0x00000AD4, - .num_cfg = 0x00000AD8, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x36, - .bank_1 = 0x37, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - .cfg_offset = 0x00000AE4, - .num_cfg = 0x00000000, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x40, - .bank_1 = 0x41, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - .cfg_offset = 0x00000BC8, - .num_cfg = 0x00000BCC, - .cfg_size = 0x00000BD0, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - .cfg_offset = 0x00000BE4, - .num_cfg = 0x00000BE8, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x3A, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - .cfg_offset = 0x00000BEC, - .num_cfg = 0x00000BF0, - .cfg_size = 0x00000BF4, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - .cfg_offset = 0x00000BF8, - .num_cfg = 0x00000BFC, - .cfg_size = 0x00000C00, - .is_lut = 0, - .lut = { - .size = -1, - .bank_0 = -1, - .bank_1 = -1, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - .cfg_offset = 0x00000C04, - .num_cfg = 0x00000C08, - .cfg_size = 0x00000000, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x3B, - .bank_1 = 0x3C, - }, - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_FULL_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS4_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_DS16_DISP */ - { - }, - /* AIS_VFE_BUS_VER2_VFE_OUT_2PD */ - { - .res_index = AIS_VFE_BUS_VER2_VFE_OUT_2PD, - .cfg_offset = 0x00000FF0, - .num_cfg = 0x00000FF4, - .cfg_size = 0x00000FF8, - .is_lut = 1, - .lut = { - .size = 180, - .bank_0 = 0x44, - .bank_1 = 0x45, - }, - }, - }, -}; - -static struct ais_vfe_top_ver2_reg_offset_common vfe175_130_top_common_reg = { - .hw_version = 0x00000000, - .hw_capability = 0x00000004, - .lens_feature = 0x00000008, - .stats_feature = 0x0000000C, - .color_feature = 0x00000010, - .zoom_feature = 0x00000014, - .global_reset_cmd = 0x00000018, - .module_ctrl = { - &vfe175_130_lens_reg, - &vfe175_130_stats_reg, - &vfe175_130_color_reg, - &vfe175_130_zoom_reg, - }, - .bus_cgc_ovd = 0x0000003C, - .core_cfg = 0x00000050, - .three_D_cfg = 0x00000054, - .violation_status = 0x0000007C, - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_ver2_reg vfe175_130_rdi_reg = { - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_reg_data vfe_175_130_rdi_0_data = { - .reg_update_cmd_data = 0x2, - .sof_irq_mask = 0x8000000, - .reg_update_irq_mask = 0x20, -}; - -static struct ais_vfe_rdi_reg_data vfe_175_130_rdi_1_data = { - .reg_update_cmd_data = 0x4, - .sof_irq_mask = 0x10000000, - .reg_update_irq_mask = 0x40, -}; - -static struct ais_vfe_rdi_reg_data vfe_175_130_rdi_2_data = { - .reg_update_cmd_data = 0x8, - .sof_irq_mask = 0x20000000, - .reg_update_irq_mask = 0x80, -}; - -static struct ais_vfe_top_ver2_hw_info vfe175_130_top_hw_info = { - .common_reg = &vfe175_130_top_common_reg, - .camif_hw_info = { - .common_reg = &vfe175_130_top_common_reg, - .camif_reg = &vfe175_130_camif_reg, - .reg_data = &vfe_175_130_camif_reg_data, - }, - .camif_lite_hw_info = { - .common_reg = &vfe175_130_top_common_reg, - .camif_lite_reg = &vfe175_130_camif_lite_reg, - .reg_data = &vfe175_130_camif_lite_reg_data, - }, - .rdi_hw_info = { - .common_reg = &vfe175_130_top_common_reg, - .rdi_reg = &vfe175_130_rdi_reg, - .reg_data = { - &vfe_175_130_rdi_0_data, - &vfe_175_130_rdi_1_data, - &vfe_175_130_rdi_2_data, - NULL, - }, - }, - .fe_hw_info = { - .common_reg = &vfe175_130_top_common_reg, - .fe_reg = &vfe175_130_fe_reg, - .reg_data = &vfe_175_130_fe_reg_data, - }, - .dump_data = { - .num_reg_dump_entries = 2, - .num_lut_dump_entries = 1, - .dmi_cfg = 0xc24, - .dmi_addr = 0xc28, - .dmi_data_path_hi = 0xc2C, - .dmi_data_path_lo = 0xc30, - .reg_entry = { - { - .reg_dump_start = 0x0, - .reg_dump_end = 0x1160, - }, - { - .reg_dump_start = 0x2000, - .reg_dump_end = 0x3978, - }, - }, - .lut_entry = { - { - .lut_word_size = 64, - .lut_bank_sel = 0x40, - .lut_addr_size = 180, - }, - }, - }, - .mux_type = { - AIS_VFE_CAMIF_VER_2_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_CAMIF_LITE_VER_2_0, - AIS_VFE_IN_RD_VER_1_0, - }, -}; - -static struct ais_irq_register_set vfe175_130_bus_rd_irq_reg[1] = { - { - .mask_reg_offset = 0x00005010, - .clear_reg_offset = 0x00005014, - .status_reg_offset = 0x0000501C, - }, -}; - -static struct ais_irq_register_set vfe175_130_bus_irq_reg[3] = { - { - .mask_reg_offset = 0x00002044, - .clear_reg_offset = 0x00002050, - .status_reg_offset = 0x0000205C, - }, - { - .mask_reg_offset = 0x00002048, - .clear_reg_offset = 0x00002054, - .status_reg_offset = 0x00002060, - }, - { - .mask_reg_offset = 0x0000204C, - .clear_reg_offset = 0x00002058, - .status_reg_offset = 0x00002064, - }, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_130_ubwc_regs_client_3 = { - .tile_cfg = 0x0000252C, - .h_init = 0x00002530, - .v_init = 0x00002534, - .meta_addr = 0x00002538, - .meta_offset = 0x0000253C, - .meta_stride = 0x00002540, - .mode_cfg_0 = 0x00002544, - .mode_cfg_1 = 0x000025A4, - .bw_limit = 0x000025A0, - .threshlod_lossy_0 = 0x000025A8, - .threshlod_lossy_1 = 0x000025AC, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_130_ubwc_regs_client_4 = { - .tile_cfg = 0x0000262C, - .h_init = 0x00002630, - .v_init = 0x00002634, - .meta_addr = 0x00002638, - .meta_offset = 0x0000263C, - .meta_stride = 0x00002640, - .mode_cfg_0 = 0x00002644, - .mode_cfg_1 = 0x000026A4, - .bw_limit = 0x000026A0, - .threshlod_lossy_0 = 0x000026A8, - .threshlod_lossy_1 = 0x000026AC, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_130_ubwc_regs_client_20 = { - .tile_cfg = 0x0000362C, - .h_init = 0x00003630, - .v_init = 0x00003634, - .meta_addr = 0x00003638, - .meta_offset = 0x0000363C, - .meta_stride = 0x00003640, - .mode_cfg_0 = 0x00003644, - .mode_cfg_1 = 0x000036A4, - .bw_limit = 0x000036A0, - .threshlod_lossy_0 = 0x000036A8, - .threshlod_lossy_1 = 0x000036AC, -}; - -static struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client - vfe175_130_ubwc_regs_client_21 = { - .tile_cfg = 0x0000372C, - .h_init = 0x00003730, - .v_init = 0x00003734, - .meta_addr = 0x00003738, - .meta_offset = 0x0000373C, - .meta_stride = 0x00003740, - .mode_cfg_0 = 0x00003744, - .mode_cfg_1 = 0x000037A4, - .bw_limit = 0x000037A0, - .threshlod_lossy_0 = 0x000037A8, - .threshlod_lossy_1 = 0x000037AC, -}; - -static struct ais_vfe_bus_rd_ver1_hw_info vfe175_130_bus_rd_hw_info = { - .common_reg = { - .hw_version = 0x00005000, - .hw_capability = 0x00005004, - .sw_reset = 0x00005008, - .cgc_ovd = 0x0000500C, - .pwr_iso_cfg = 0x000050CC, - .input_if_cmd = 0x00005020, - .test_bus_ctrl = 0x00005048, - .irq_reg_info = { - .num_registers = 1, - .irq_reg_set = vfe175_130_bus_rd_irq_reg, - .global_clear_offset = 0x00005018, - .global_clear_bitmask = 0x00000001, - }, - }, - .num_client = 1, - .bus_client_reg = { - /* BUS Client 0 */ - { - .cfg = 0x00005050, - .image_addr = 0x00005058, - .buffer_width_cfg = 0x0000505C, - .unpacker_cfg = 0x00005064, - .stride = 0x00005060, - .burst_limit = 0x00005080, - .latency_buf_allocation = 0x00005078, - .ubwc_regs = NULL, - }, - }, - .num_bus_rd_resc = 1, - .vfe_bus_rd_hw_info = { - { - .vfe_bus_rd_type = AIS_VFE_BUS_RD_VER1_VFE_BUSRD_RDI0, - .max_width = -1, - .max_height = -1, - }, - }, -}; - -static struct ais_vfe_bus_ver2_hw_info vfe175_130_bus_hw_info = { - .common_reg = { - .hw_version = 0x00002000, - .hw_capability = 0x00002004, - .sw_reset = 0x00002008, - .cgc_ovd = 0x0000200C, - .pwr_iso_cfg = 0x000020CC, - .dual_master_comp_cfg = 0x00002028, - .irq_reg_info = { - .num_registers = 3, - .irq_reg_set = vfe175_130_bus_irq_reg, - .global_clear_offset = 0x00002068, - .global_clear_bitmask = 0x00000001, - }, - .comp_error_status = 0x0000206C, - .comp_ovrwr_status = 0x00002070, - .dual_comp_error_status = 0x00002074, - .dual_comp_ovrwr_status = 0x00002078, - .addr_sync_cfg = 0x0000207C, - .addr_sync_frame_hdr = 0x00002080, - .addr_sync_no_sync = 0x00002084, - .addr_fifo_status = 0x000020A8, - }, - .num_client = 24, - .is_lite = 0, - .bus_client_reg = { - /* BUS Client 0 */ - { - .status0 = 0x00002200, - .status1 = 0x00002204, - .cfg = 0x00002208, - .header_addr = 0x0000220C, - .header_cfg = 0x00002210, - .image_addr = 0x00002214, - .image_addr_offset = 0x00002218, - .buffer_width_cfg = 0x0000221C, - .buffer_height_cfg = 0x00002220, - .packer_cfg = 0x00002224, - .stride = 0x00002228, - .irq_subsample_period = 0x00002248, - .irq_subsample_pattern = 0x0000224C, - .framedrop_period = 0x00002250, - .framedrop_pattern = 0x00002254, - .frame_inc = 0x00002258, - .burst_limit = 0x0000225C, - .ubwc_regs = NULL, - }, - /* BUS Client 1 */ - { - .status0 = 0x00002300, - .status1 = 0x00002304, - .cfg = 0x00002308, - .header_addr = 0x0000230C, - .header_cfg = 0x00002310, - .image_addr = 0x00002314, - .image_addr_offset = 0x00002318, - .buffer_width_cfg = 0x0000231C, - .buffer_height_cfg = 0x00002320, - .packer_cfg = 0x00002324, - .stride = 0x00002328, - .irq_subsample_period = 0x00002348, - .irq_subsample_pattern = 0x0000234C, - .framedrop_period = 0x00002350, - .framedrop_pattern = 0x00002354, - .frame_inc = 0x00002358, - .burst_limit = 0x0000235C, - .ubwc_regs = NULL, - }, - /* BUS Client 2 */ - { - .status0 = 0x00002400, - .status1 = 0x00002404, - .cfg = 0x00002408, - .header_addr = 0x0000240C, - .header_cfg = 0x00002410, - .image_addr = 0x00002414, - .image_addr_offset = 0x00002418, - .buffer_width_cfg = 0x0000241C, - .buffer_height_cfg = 0x00002420, - .packer_cfg = 0x00002424, - .stride = 0x00002428, - .irq_subsample_period = 0x00002448, - .irq_subsample_pattern = 0x0000244C, - .framedrop_period = 0x00002450, - .framedrop_pattern = 0x00002454, - .frame_inc = 0x00002458, - .burst_limit = 0x0000245C, - .ubwc_regs = NULL, - }, - /* BUS Client 3 */ - { - .status0 = 0x00002500, - .status1 = 0x00002504, - .cfg = 0x00002508, - .header_addr = 0x0000250C, - .header_cfg = 0x00002510, - .image_addr = 0x00002514, - .image_addr_offset = 0x00002518, - .buffer_width_cfg = 0x0000251C, - .buffer_height_cfg = 0x00002520, - .packer_cfg = 0x00002524, - .stride = 0x00002528, - .irq_subsample_period = 0x00002548, - .irq_subsample_pattern = 0x0000254C, - .framedrop_period = 0x00002550, - .framedrop_pattern = 0x00002554, - .frame_inc = 0x00002558, - .burst_limit = 0x0000255C, - .ubwc_regs = - &vfe175_130_ubwc_regs_client_3, - }, - /* BUS Client 4 */ - { - .status0 = 0x00002600, - .status1 = 0x00002604, - .cfg = 0x00002608, - .header_addr = 0x0000260C, - .header_cfg = 0x00002610, - .image_addr = 0x00002614, - .image_addr_offset = 0x00002618, - .buffer_width_cfg = 0x0000261C, - .buffer_height_cfg = 0x00002620, - .packer_cfg = 0x00002624, - .stride = 0x00002628, - .irq_subsample_period = 0x00002648, - .irq_subsample_pattern = 0x0000264C, - .framedrop_period = 0x00002650, - .framedrop_pattern = 0x00002654, - .frame_inc = 0x00002658, - .burst_limit = 0x0000265C, - .ubwc_regs = - &vfe175_130_ubwc_regs_client_4, - }, - /* BUS Client 5 */ - { - .status0 = 0x00002700, - .status1 = 0x00002704, - .cfg = 0x00002708, - .header_addr = 0x0000270C, - .header_cfg = 0x00002710, - .image_addr = 0x00002714, - .image_addr_offset = 0x00002718, - .buffer_width_cfg = 0x0000271C, - .buffer_height_cfg = 0x00002720, - .packer_cfg = 0x00002724, - .stride = 0x00002728, - .irq_subsample_period = 0x00002748, - .irq_subsample_pattern = 0x0000274C, - .framedrop_period = 0x00002750, - .framedrop_pattern = 0x00002754, - .frame_inc = 0x00002758, - .burst_limit = 0x0000275C, - .ubwc_regs = NULL, - }, - /* BUS Client 6 */ - { - .status0 = 0x00002800, - .status1 = 0x00002804, - .cfg = 0x00002808, - .header_addr = 0x0000280C, - .header_cfg = 0x00002810, - .image_addr = 0x00002814, - .image_addr_offset = 0x00002818, - .buffer_width_cfg = 0x0000281C, - .buffer_height_cfg = 0x00002820, - .packer_cfg = 0x00002824, - .stride = 0x00002828, - .irq_subsample_period = 0x00002848, - .irq_subsample_pattern = 0x0000284C, - .framedrop_period = 0x00002850, - .framedrop_pattern = 0x00002854, - .frame_inc = 0x00002858, - .burst_limit = 0x0000285C, - .ubwc_regs = NULL, - }, - /* BUS Client 7 */ - { - .status0 = 0x00002900, - .status1 = 0x00002904, - .cfg = 0x00002908, - .header_addr = 0x0000290C, - .header_cfg = 0x00002910, - .image_addr = 0x00002914, - .image_addr_offset = 0x00002918, - .buffer_width_cfg = 0x0000291C, - .buffer_height_cfg = 0x00002920, - .packer_cfg = 0x00002924, - .stride = 0x00002928, - .irq_subsample_period = 0x00002948, - .irq_subsample_pattern = 0x0000294C, - .framedrop_period = 0x00002950, - .framedrop_pattern = 0x00002954, - .frame_inc = 0x00002958, - .burst_limit = 0x0000295C, - .ubwc_regs = NULL, - }, - /* BUS Client 8 */ - { - .status0 = 0x00002A00, - .status1 = 0x00002A04, - .cfg = 0x00002A08, - .header_addr = 0x00002A0C, - .header_cfg = 0x00002A10, - .image_addr = 0x00002A14, - .image_addr_offset = 0x00002A18, - .buffer_width_cfg = 0x00002A1C, - .buffer_height_cfg = 0x00002A20, - .packer_cfg = 0x00002A24, - .stride = 0x00002A28, - .irq_subsample_period = 0x00002A48, - .irq_subsample_pattern = 0x00002A4C, - .framedrop_period = 0x00002A50, - .framedrop_pattern = 0x00002A54, - .frame_inc = 0x00002A58, - .burst_limit = 0x00002A5C, - .ubwc_regs = NULL, - }, - /* BUS Client 9 */ - { - .status0 = 0x00002B00, - .status1 = 0x00002B04, - .cfg = 0x00002B08, - .header_addr = 0x00002B0C, - .header_cfg = 0x00002B10, - .image_addr = 0x00002B14, - .image_addr_offset = 0x00002B18, - .buffer_width_cfg = 0x00002B1C, - .buffer_height_cfg = 0x00002B20, - .packer_cfg = 0x00002B24, - .stride = 0x00002B28, - .irq_subsample_period = 0x00002B48, - .irq_subsample_pattern = 0x00002B4C, - .framedrop_period = 0x00002B50, - .framedrop_pattern = 0x00002B54, - .frame_inc = 0x00002B58, - .burst_limit = 0x00002B5C, - .ubwc_regs = NULL, - }, - /* BUS Client 10 */ - { - .status0 = 0x00002C00, - .status1 = 0x00002C04, - .cfg = 0x00002C08, - .header_addr = 0x00002C0C, - .header_cfg = 0x00002C10, - .image_addr = 0x00002C14, - .image_addr_offset = 0x00002C18, - .buffer_width_cfg = 0x00002C1C, - .buffer_height_cfg = 0x00002C20, - .packer_cfg = 0x00002C24, - .stride = 0x00002C28, - .irq_subsample_period = 0x00002C48, - .irq_subsample_pattern = 0x00002C4C, - .framedrop_period = 0x00002C50, - .framedrop_pattern = 0x00002C54, - .frame_inc = 0x00002C58, - .burst_limit = 0x00002C5C, - .ubwc_regs = NULL, - }, - /* BUS Client 11 */ - { - .status0 = 0x00002D00, - .status1 = 0x00002D04, - .cfg = 0x00002D08, - .header_addr = 0x00002D0C, - .header_cfg = 0x00002D10, - .image_addr = 0x00002D14, - .image_addr_offset = 0x00002D18, - .buffer_width_cfg = 0x00002D1C, - .buffer_height_cfg = 0x00002D20, - .packer_cfg = 0x00002D24, - .stride = 0x00002D28, - .irq_subsample_period = 0x00002D48, - .irq_subsample_pattern = 0x00002D4C, - .framedrop_period = 0x00002D50, - .framedrop_pattern = 0x00002D54, - .frame_inc = 0x00002D58, - .burst_limit = 0x00002D5C, - .ubwc_regs = NULL, - }, - /* BUS Client 12 */ - { - .status0 = 0x00002E00, - .status1 = 0x00002E04, - .cfg = 0x00002E08, - .header_addr = 0x00002E0C, - .header_cfg = 0x00002E10, - .image_addr = 0x00002E14, - .image_addr_offset = 0x00002E18, - .buffer_width_cfg = 0x00002E1C, - .buffer_height_cfg = 0x00002E20, - .packer_cfg = 0x00002E24, - .stride = 0x00002E28, - .irq_subsample_period = 0x00002E48, - .irq_subsample_pattern = 0x00002E4C, - .framedrop_period = 0x00002E50, - .framedrop_pattern = 0x00002E54, - .frame_inc = 0x00002E58, - .burst_limit = 0x00002E5C, - .ubwc_regs = NULL, - }, - /* BUS Client 13 */ - { - .status0 = 0x00002F00, - .status1 = 0x00002F04, - .cfg = 0x00002F08, - .header_addr = 0x00002F0C, - .header_cfg = 0x00002F10, - .image_addr = 0x00002F14, - .image_addr_offset = 0x00002F18, - .buffer_width_cfg = 0x00002F1C, - .buffer_height_cfg = 0x00002F20, - .packer_cfg = 0x00002F24, - .stride = 0x00002F28, - .irq_subsample_period = 0x00002F48, - .irq_subsample_pattern = 0x00002F4C, - .framedrop_period = 0x00002F50, - .framedrop_pattern = 0x00002F54, - .frame_inc = 0x00002F58, - .burst_limit = 0x00002F5C, - .ubwc_regs = NULL, - }, - /* BUS Client 14 */ - { - .status0 = 0x00003000, - .status1 = 0x00003004, - .cfg = 0x00003008, - .header_addr = 0x0000300C, - .header_cfg = 0x00003010, - .image_addr = 0x00003014, - .image_addr_offset = 0x00003018, - .buffer_width_cfg = 0x0000301C, - .buffer_height_cfg = 0x00003020, - .packer_cfg = 0x00003024, - .stride = 0x00003028, - .irq_subsample_period = 0x00003048, - .irq_subsample_pattern = 0x0000304C, - .framedrop_period = 0x00003050, - .framedrop_pattern = 0x00003054, - .frame_inc = 0x00003058, - .burst_limit = 0x0000305C, - .ubwc_regs = NULL, - }, - /* BUS Client 15 */ - { - .status0 = 0x00003100, - .status1 = 0x00003104, - .cfg = 0x00003108, - .header_addr = 0x0000310C, - .header_cfg = 0x00003110, - .image_addr = 0x00003114, - .image_addr_offset = 0x00003118, - .buffer_width_cfg = 0x0000311C, - .buffer_height_cfg = 0x00003120, - .packer_cfg = 0x00003124, - .stride = 0x00003128, - .irq_subsample_period = 0x00003148, - .irq_subsample_pattern = 0x0000314C, - .framedrop_period = 0x00003150, - .framedrop_pattern = 0x00003154, - .frame_inc = 0x00003158, - .burst_limit = 0x0000315C, - .ubwc_regs = NULL, - }, - /* BUS Client 16 */ - { - .status0 = 0x00003200, - .status1 = 0x00003204, - .cfg = 0x00003208, - .header_addr = 0x0000320C, - .header_cfg = 0x00003210, - .image_addr = 0x00003214, - .image_addr_offset = 0x00003218, - .buffer_width_cfg = 0x0000321C, - .buffer_height_cfg = 0x00003220, - .packer_cfg = 0x00003224, - .stride = 0x00003228, - .irq_subsample_period = 0x00003248, - .irq_subsample_pattern = 0x0000324C, - .framedrop_period = 0x00003250, - .framedrop_pattern = 0x00003254, - .frame_inc = 0x00003258, - .burst_limit = 0x0000325C, - .ubwc_regs = NULL, - }, - /* BUS Client 17 */ - { - .status0 = 0x00003300, - .status1 = 0x00003304, - .cfg = 0x00003308, - .header_addr = 0x0000330C, - .header_cfg = 0x00003310, - .image_addr = 0x00003314, - .image_addr_offset = 0x00003318, - .buffer_width_cfg = 0x0000331C, - .buffer_height_cfg = 0x00003320, - .packer_cfg = 0x00003324, - .stride = 0x00003328, - .irq_subsample_period = 0x00003348, - .irq_subsample_pattern = 0x0000334C, - .framedrop_period = 0x00003350, - .framedrop_pattern = 0x00003354, - .frame_inc = 0x00003358, - .burst_limit = 0x0000335C, - .ubwc_regs = NULL, - }, - /* BUS Client 18 */ - { - .status0 = 0x00003400, - .status1 = 0x00003404, - .cfg = 0x00003408, - .header_addr = 0x0000340C, - .header_cfg = 0x00003410, - .image_addr = 0x00003414, - .image_addr_offset = 0x00003418, - .buffer_width_cfg = 0x0000341C, - .buffer_height_cfg = 0x00003420, - .packer_cfg = 0x00003424, - .stride = 0x00003428, - .irq_subsample_period = 0x00003448, - .irq_subsample_pattern = 0x0000344C, - .framedrop_period = 0x00003450, - .framedrop_pattern = 0x00003454, - .frame_inc = 0x00003458, - .burst_limit = 0x0000345C, - .ubwc_regs = NULL, - }, - /* BUS Client 19 */ - { - .status0 = 0x00003500, - .status1 = 0x00003504, - .cfg = 0x00003508, - .header_addr = 0x0000350C, - .header_cfg = 0x00003510, - .image_addr = 0x00003514, - .image_addr_offset = 0x00003518, - .buffer_width_cfg = 0x0000351C, - .buffer_height_cfg = 0x00003520, - .packer_cfg = 0x00003524, - .stride = 0x00003528, - .irq_subsample_period = 0x00003548, - .irq_subsample_pattern = 0x0000354C, - .framedrop_period = 0x00003550, - .framedrop_pattern = 0x00003554, - .frame_inc = 0x00003558, - .burst_limit = 0x0000355C, - .ubwc_regs = NULL, - }, - /* BUS Client 20 */ - { - .status0 = 0x00003600, - .status1 = 0x00003604, - .cfg = 0x00003608, - .header_addr = 0x0000360C, - .header_cfg = 0x00003610, - .image_addr = 0x00003614, - .image_addr_offset = 0x00003618, - .buffer_width_cfg = 0x0000361C, - .buffer_height_cfg = 0x00003620, - .packer_cfg = 0x00003624, - .stride = 0x00003628, - .irq_subsample_period = 0x00003648, - .irq_subsample_pattern = 0x0000364C, - .framedrop_period = 0x00003650, - .framedrop_pattern = 0x00003654, - .frame_inc = 0x00003658, - .burst_limit = 0x0000365C, - .ubwc_regs = - &vfe175_130_ubwc_regs_client_20, - }, - /* BUS Client 21 */ - { - .status0 = 0x00003700, - .status1 = 0x00003704, - .cfg = 0x00003708, - .header_addr = 0x0000370C, - .header_cfg = 0x00003710, - .image_addr = 0x00003714, - .image_addr_offset = 0x00003718, - .buffer_width_cfg = 0x0000371C, - .buffer_height_cfg = 0x00003720, - .packer_cfg = 0x00003724, - .stride = 0x00003728, - .irq_subsample_period = 0x00003748, - .irq_subsample_pattern = 0x0000374C, - .framedrop_period = 0x00003750, - .framedrop_pattern = 0x00003754, - .frame_inc = 0x00003758, - .burst_limit = 0x0000375C, - .ubwc_regs = - &vfe175_130_ubwc_regs_client_21, - }, - /* BUS Client 22 */ - { - .status0 = 0x00003800, - .status1 = 0x00003804, - .cfg = 0x00003808, - .header_addr = 0x0000380C, - .header_cfg = 0x00003810, - .image_addr = 0x00003814, - .image_addr_offset = 0x00003818, - .buffer_width_cfg = 0x0000381C, - .buffer_height_cfg = 0x00003820, - .packer_cfg = 0x00003824, - .stride = 0x00003828, - .irq_subsample_period = 0x00003848, - .irq_subsample_pattern = 0x0000384C, - .framedrop_period = 0x00003850, - .framedrop_pattern = 0x00003854, - .frame_inc = 0x00003858, - .burst_limit = 0x0000385C, - .ubwc_regs = NULL, - }, - /* BUS Client 23 */ - { - .status0 = 0x00003900, - .status1 = 0x00003904, - .cfg = 0x00003908, - .header_addr = 0x0000390C, - .header_cfg = 0x00003910, - .image_addr = 0x00003914, - .image_addr_offset = 0x00003918, - .buffer_width_cfg = 0x0000391C, - .buffer_height_cfg = 0x00003920, - .packer_cfg = 0x00003924, - .stride = 0x00003928, - .irq_subsample_period = 0x00003948, - .irq_subsample_pattern = 0x0000394C, - .framedrop_period = 0x00003950, - .framedrop_pattern = 0x00003954, - .frame_inc = 0x00003958, - .burst_limit = 0x0000395C, - .ubwc_regs = NULL, - }, - }, - .comp_grp_reg = { - /* AIS_VFE_BUS_VER2_COMP_GRP_0 */ - { - .comp_mask = 0x00002010, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_1 */ - { - .comp_mask = 0x00002014, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_2 */ - { - .comp_mask = 0x00002018, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_3 */ - { - .comp_mask = 0x0000201C, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_4 */ - { - .comp_mask = 0x00002020, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_5 */ - { - .comp_mask = 0x00002024, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_0 */ - { - .comp_mask = 0x0000202C, - .addr_sync_mask = 0x00002088, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_1 */ - { - .comp_mask = 0x00002030, - .addr_sync_mask = 0x0000208C, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_2 */ - { - .comp_mask = 0x00002034, - .addr_sync_mask = 0x00002090, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_3 */ - { - .comp_mask = 0x00002038, - .addr_sync_mask = 0x00002094, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_4 */ - { - .comp_mask = 0x0000203C, - .addr_sync_mask = 0x00002098, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_5 */ - { - .comp_mask = 0x00002040, - .addr_sync_mask = 0x0000209C, - }, - }, - .num_out = 22, - .vfe_out_hw_info = { - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI0, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI1, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI2, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FULL, - .max_width = 4096, - .max_height = 4096, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS4, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS16, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FD, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_PDAF, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = - AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_FULL_DISP, - .max_width = 4096, - .max_height = 4096, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS4_DISP, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_DS16_DISP, - .max_width = 1920, - .max_height = 1080, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_2PD, - .max_width = 1920, - .max_height = 1080, - }, - }, - .reg_data = { - .ubwc_10bit_threshold_lossy_0 = 0x8330002, - .ubwc_10bit_threshold_lossy_1 = 0x20204, - .ubwc_8bit_threshold_lossy_0 = 0x6210022, - .ubwc_8bit_threshold_lossy_1 = 0xE0E, - }, - .stats_data = &stats_175_130_info, -}; - -static struct ais_vfe_hw_info ais_vfe175_130_hw_info = { - .irq_reg_info = &vfe175_130_top_irq_reg_info, - - .bus_version = AIS_VFE_BUS_VER_2_0, - .bus_hw_info = &vfe175_130_bus_hw_info, - - .bus_rd_version = AIS_VFE_BUS_VER_2_0, - .bus_rd_hw_info = &vfe175_130_bus_rd_hw_info, - - .top_version = AIS_VFE_TOP_VER_2_0, - .top_hw_info = &vfe175_130_top_hw_info, - - .camif_version = AIS_VFE_CAMIF_VER_2_0, - .camif_reg = &vfe175_130_camif_reg, - - .camif_lite_version = AIS_VFE_CAMIF_LITE_VER_2_0, - .camif_lite_reg = &vfe175_130_camif_lite_reg, - -}; - -#endif /* _AIS_VFE175_130_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe17x.c b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe17x.c deleted file mode 100755 index 7e75089f7724..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe17x.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include "ais_vfe170.h" -#include "ais_vfe175.h" -#include "ais_vfe175_130.h" -#include "ais_vfe_lite17x.h" -#include "ais_vfe_hw_intf.h" -#include "ais_vfe_core.h" -#include "ais_vfe_dev.h" - -static const struct of_device_id ais_vfe_dt_match[] = { - { - .compatible = "qcom,ais-vfe170", - .data = &ais_vfe170_hw_info, - }, - { - .compatible = "qcom,ais-vfe175", - .data = &ais_vfe175_hw_info, - }, - { - .compatible = "qcom,ais-vfe175_130", - .data = &ais_vfe175_130_hw_info, - }, - { - .compatible = "qcom,ais-vfe-lite170", - .data = &ais_vfe_lite17x_hw_info, - }, - { - .compatible = "qcom,ais-vfe-lite175", - .data = &ais_vfe_lite17x_hw_info, - }, - {} -}; -MODULE_DEVICE_TABLE(of, ais_vfe_dt_match); - -static struct platform_driver ais_vfe_driver = { - .probe = ais_vfe_probe, - .remove = ais_vfe_remove, - .driver = { - .name = "ais_vfe17x", - .owner = THIS_MODULE, - .of_match_table = ais_vfe_dt_match, - .suppress_bind_attrs = true, - }, -}; - -static int __init ais_vfe_init_module(void) -{ - return platform_driver_register(&ais_vfe_driver); -} - -static void __exit ais_vfe_exit_module(void) -{ - platform_driver_unregister(&ais_vfe_driver); -} - -module_init(ais_vfe_init_module); -module_exit(ais_vfe_exit_module); -MODULE_DESCRIPTION("AIS VFE17X driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe_lite17x.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe_lite17x.h deleted file mode 100755 index fa042e9815c2..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe17x/ais_vfe_lite17x.h +++ /dev/null @@ -1,335 +0,0 @@ -/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_LITE17X_H_ -#define _AIS_VFE_LITE17X_H_ - -#include "ais_vfe_core.h" - -static struct ais_irq_register_set vfe17x_top_irq_reg_set[2] = { - { - .mask_reg_offset = 0x0000005C, - .clear_reg_offset = 0x00000064, - .status_reg_offset = 0x0000006C, - }, - { - .mask_reg_offset = 0x00000060, - .clear_reg_offset = 0x00000068, - .status_reg_offset = 0x00000070, - }, -}; - -static struct ais_irq_controller_reg_info vfe17x_top_irq_reg_info = { - .num_registers = 2, - .irq_reg_set = vfe17x_top_irq_reg_set, - .global_clear_offset = 0x00000058, - .global_clear_bitmask = 0x00000001, -}; - -static struct ais_vfe_top_ver2_reg_offset_common vfe17x_top_common_reg = { - .hw_version = 0x00000000, - .hw_capability = 0x00000004, - .lens_feature = 0x00000008, - .stats_feature = 0x0000000C, - .color_feature = 0x00000010, - .zoom_feature = 0x00000014, - .global_reset_cmd = 0x00000018, - .module_ctrl = { - NULL, - NULL, - NULL, - NULL, - }, - .bus_cgc_ovd = 0x0000003C, - .core_cfg = 0x00000000, - .three_D_cfg = 0x00000000, - .violation_status = 0x0000007C, - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_ver2_reg vfe17x_rdi_reg = { - .reg_update_cmd = 0x000004AC, -}; - -static struct ais_vfe_rdi_reg_data vfe17x_rdi_0_data = { - .reg_update_cmd_data = 0x2, - .sof_irq_mask = 0x8000000, - .reg_update_irq_mask = 0x20, -}; - -static struct ais_vfe_rdi_reg_data vfe17x_rdi_1_data = { - .reg_update_cmd_data = 0x4, - .sof_irq_mask = 0x10000000, - .reg_update_irq_mask = 0x40, -}; - -static struct ais_vfe_rdi_reg_data vfe17x_rdi_2_data = { - .reg_update_cmd_data = 0x8, - .sof_irq_mask = 0x20000000, - .reg_update_irq_mask = 0x80, -}; - -static struct ais_vfe_rdi_reg_data vfe17x_rdi_3_data = { - .reg_update_cmd_data = 0x10, - .sof_irq_mask = 0x40000000, - .reg_update_irq_mask = 0x100, -}; - -static struct ais_vfe_top_ver2_hw_info vfe17x_top_hw_info = { - .common_reg = &vfe17x_top_common_reg, - .camif_hw_info = { - .common_reg = NULL, - .camif_reg = NULL, - .reg_data = NULL, - }, - .rdi_hw_info = { - .common_reg = &vfe17x_top_common_reg, - .rdi_reg = &vfe17x_rdi_reg, - .reg_data = { - &vfe17x_rdi_0_data, - &vfe17x_rdi_1_data, - &vfe17x_rdi_2_data, - &vfe17x_rdi_3_data, - }, - }, - .mux_type = { - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - AIS_VFE_RDI_VER_1_0, - }, -}; - -static struct ais_irq_register_set vfe17x_bus_irq_reg[3] = { - { - .mask_reg_offset = 0x00002044, - .clear_reg_offset = 0x00002050, - .status_reg_offset = 0x0000205C, - }, - { - .mask_reg_offset = 0x00002048, - .clear_reg_offset = 0x00002054, - .status_reg_offset = 0x00002060, - }, - { - .mask_reg_offset = 0x0000204C, - .clear_reg_offset = 0x00002058, - .status_reg_offset = 0x00002064, - }, -}; - -static struct ais_vfe_bus_ver2_hw_info vfe17x_bus_hw_info = { - .common_reg = { - .hw_version = 0x00002000, - .hw_capability = 0x00002004, - .sw_reset = 0x00002008, - .cgc_ovd = 0x0000200C, - .pwr_iso_cfg = 0x000020CC, - .dual_master_comp_cfg = 0x00002028, - .irq_reg_info = { - .num_registers = 3, - .irq_reg_set = vfe17x_bus_irq_reg, - .global_clear_offset = 0x00002068, - .global_clear_bitmask = 0x00000001, - }, - .comp_error_status = 0x0000206C, - .comp_ovrwr_status = 0x00002070, - .dual_comp_error_status = 0x00002074, - .dual_comp_ovrwr_status = 0x00002078, - .addr_sync_cfg = 0x0000207C, - .addr_sync_frame_hdr = 0x00002080, - .addr_sync_no_sync = 0x00002084, - .addr_fifo_status = 0x000020A8, - }, - .num_client = 4, - .is_lite = 1, - .bus_client_reg = { - /* BUS Client 0 */ - { - .status0 = 0x00002200, - .status1 = 0x00002204, - .cfg = 0x00002208, - .header_addr = 0x0000220C, - .header_cfg = 0x00002210, - .image_addr = 0x00002214, - .image_addr_offset = 0x00002218, - .buffer_width_cfg = 0x0000221C, - .buffer_height_cfg = 0x00002220, - .packer_cfg = 0x00002224, - .stride = 0x00002228, - .irq_subsample_period = 0x00002248, - .irq_subsample_pattern = 0x0000224C, - .framedrop_period = 0x00002250, - .framedrop_pattern = 0x00002254, - .frame_inc = 0x00002258, - .burst_limit = 0x0000225C, - .ubwc_regs = NULL, - }, - /* BUS Client 1 */ - { - .status0 = 0x00002300, - .status1 = 0x00002304, - .cfg = 0x00002308, - .header_addr = 0x0000230C, - .header_cfg = 0x00002310, - .image_addr = 0x00002314, - .image_addr_offset = 0x00002318, - .buffer_width_cfg = 0x0000231C, - .buffer_height_cfg = 0x00002320, - .packer_cfg = 0x00002324, - .stride = 0x00002328, - .irq_subsample_period = 0x00002348, - .irq_subsample_pattern = 0x0000234C, - .framedrop_period = 0x00002350, - .framedrop_pattern = 0x00002354, - .frame_inc = 0x00002358, - .burst_limit = 0x0000235C, - .ubwc_regs = NULL, - }, - /* BUS Client 2 */ - { - .status0 = 0x00002400, - .status1 = 0x00002404, - .cfg = 0x00002408, - .header_addr = 0x0000240C, - .header_cfg = 0x00002410, - .image_addr = 0x00002414, - .image_addr_offset = 0x00002418, - .buffer_width_cfg = 0x0000241C, - .buffer_height_cfg = 0x00002420, - .packer_cfg = 0x00002424, - .stride = 0x00002428, - .irq_subsample_period = 0x00002448, - .irq_subsample_pattern = 0x0000244C, - .framedrop_period = 0x00002450, - .framedrop_pattern = 0x00002454, - .frame_inc = 0x00002458, - .burst_limit = 0x0000245C, - .ubwc_regs = NULL, - }, - /* BUS Client 3 */ - { - .status0 = 0x00002500, - .status1 = 0x00002504, - .cfg = 0x00002508, - .header_addr = 0x0000250C, - .header_cfg = 0x00002510, - .image_addr = 0x00002514, - .image_addr_offset = 0x00002518, - .buffer_width_cfg = 0x0000251C, - .buffer_height_cfg = 0x00002520, - .packer_cfg = 0x00002524, - .stride = 0x00002528, - .irq_subsample_period = 0x00002548, - .irq_subsample_pattern = 0x0000254C, - .framedrop_period = 0x00002550, - .framedrop_pattern = 0x00002554, - .frame_inc = 0x00002558, - .burst_limit = 0x0000255C, - .ubwc_regs = NULL, - }, - }, - .comp_grp_reg = { - /* AIS_VFE_BUS_VER2_COMP_GRP_0 */ - { - .comp_mask = 0x00002010, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_1 */ - { - .comp_mask = 0x00002014, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_2 */ - { - .comp_mask = 0x00002018, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_3 */ - { - .comp_mask = 0x0000201C, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_4 */ - { - .comp_mask = 0x00002020, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_5 */ - { - .comp_mask = 0x00002024, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_0 */ - { - .comp_mask = 0x0000202C, - .addr_sync_mask = 0x00002088, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_1 */ - { - .comp_mask = 0x00002030, - .addr_sync_mask = 0x0000208C, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_2 */ - { - .comp_mask = 0x00002034, - .addr_sync_mask = 0x00002090, - - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_3 */ - { - .comp_mask = 0x00002038, - .addr_sync_mask = 0x00002094, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_4 */ - { - .comp_mask = 0x0000203C, - .addr_sync_mask = 0x00002098, - }, - /* AIS_VFE_BUS_VER2_COMP_GRP_DUAL_5 */ - { - .comp_mask = 0x00002040, - .addr_sync_mask = 0x0000209C, - }, - }, - .num_out = 4, - .vfe_out_hw_info = { - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI0, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI1, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI2, - .max_width = -1, - .max_height = -1, - }, - { - .vfe_out_type = AIS_VFE_BUS_VER2_VFE_OUT_RDI3, - .max_width = -1, - .max_height = -1, - }, - }, -}; - -static struct ais_vfe_hw_info ais_vfe_lite17x_hw_info = { - .irq_reg_info = &vfe17x_top_irq_reg_info, - - .bus_version = AIS_VFE_BUS_VER_2_0, - .bus_hw_info = &vfe17x_bus_hw_info, - - .top_version = AIS_VFE_TOP_VER_2_0, - .top_hw_info = &vfe17x_top_hw_info, - -}; - -#endif /* _AIS_VFE_LITE17X_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_rd_ver1.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_rd_ver1.h deleted file mode 100755 index 2d3b856b8afd..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_rd_ver1.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_BUS_R_VER1_H_ -#define _AIS_VFE_BUS_R_VER1_H_ - -#include "ais_vfe_bus.h" - -#define AIS_VFE_BUS_RD_VER1_MAX_CLIENTS 1 - -enum ais_vfe_bus_rd_ver1_vfe_core_id { - AIS_VFE_BUS_RD_VER1_VFE_CORE_0, - AIS_VFE_BUS_RD_VER1_VFE_CORE_1, - AIS_VFE_BUS_RD_VER1_VFE_CORE_MAX, -}; - -enum ais_vfe_bus_rd_ver1_comp_grp_type { - AIS_VFE_BUS_RD_VER1_COMP_GRP_0, - AIS_VFE_BUS_RD_VER1_COMP_GRP_MAX, -}; - - -enum ais_vfe_bus_rd_ver1_vfe_bus_rd_type { - AIS_VFE_BUS_RD_VER1_VFE_BUSRD_RDI0, - AIS_VFE_BUS_RD_VER1_VFE_BUSRD_MAX, -}; - -/* - * struct ais_vfe_bus_rd_ver1_reg_offset_common: - * - * @Brief: Common registers across all BUS Clients - */ -struct ais_vfe_bus_rd_ver1_reg_offset_common { - uint32_t hw_version; - uint32_t hw_capability; - uint32_t sw_reset; - uint32_t cgc_ovd; - uint32_t pwr_iso_cfg; - uint32_t input_if_cmd; - uint32_t test_bus_ctrl; - struct ais_irq_controller_reg_info irq_reg_info; -}; - -/* - * struct ais_vfe_bus_rd_ver1_reg_offset_bus_client: - * - * @Brief: Register offsets for BUS Clients - */ -struct ais_vfe_bus_rd_ver1_reg_offset_bus_client { - uint32_t status0; - uint32_t status1; - uint32_t cfg; - uint32_t header_addr; - uint32_t header_cfg; - uint32_t image_addr; - uint32_t image_addr_offset; - uint32_t buffer_width_cfg; - uint32_t buffer_height_cfg; - uint32_t unpacker_cfg; - uint32_t stride; - void *ubwc_regs; - uint32_t burst_limit; - uint32_t latency_buf_allocation; - uint32_t buf_size; -}; - -/* - * struct ais_vfe_bus_rd_ver1_vfe_bus_hw_info: - * - * @Brief: HW capability of VFE Bus Client - */ -struct ais_vfe_bus_rd_ver1_vfe_bus_hw_info { - enum ais_vfe_bus_rd_ver1_vfe_bus_rd_type vfe_bus_rd_type; - uint32_t max_width; - uint32_t max_height; -}; - -/* - * struct ais_vfe_bus_rd_ver1_hw_info: - * - * @Brief: HW register info for entire Bus - * - * @common_reg: Common register details - * @bus_client_reg: Bus client register info - * @comp_reg_grp: Composite group register info - * @vfe_out_hw_info: VFE output capability - */ -struct ais_vfe_bus_rd_ver1_hw_info { - struct ais_vfe_bus_rd_ver1_reg_offset_common common_reg; - uint32_t num_client; - struct ais_vfe_bus_rd_ver1_reg_offset_bus_client - bus_client_reg[AIS_VFE_BUS_RD_VER1_MAX_CLIENTS]; - uint32_t num_bus_rd_resc; - struct ais_vfe_bus_rd_ver1_vfe_bus_hw_info - vfe_bus_rd_hw_info[AIS_VFE_BUS_RD_VER1_VFE_BUSRD_MAX]; -}; - -#endif /* _AIS_VFE_BUS_R_VER1_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver1.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver1.h deleted file mode 100755 index 110731aebf9f..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver1.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_BUS_VER1_H_ -#define _AIS_VFE_BUS_VER1_H_ - -enum ais_vfe_bus_ver1_pingpong_id { - AIS_VFE_BUS_VER1_PING, - AIS_VFE_BUS_VER1_PONG, - AIS_VFE_BUS_VER1_PINGPONG_MAX, -}; - -enum ais_vfe_bus_ver1_wm_type { - AIS_VFE_BUS_WM_TYPE_IMAGE, - AIS_VFE_BUS_WM_TYPE_STATS, - AIS_VFE_BUS_WM_TYPE_MAX, -}; - -enum ais_vfe_bus_ver1_comp_grp_type { - AIS_VFE_BUS_VER1_COMP_GRP_IMG0, - AIS_VFE_BUS_VER1_COMP_GRP_IMG1, - AIS_VFE_BUS_VER1_COMP_GRP_IMG2, - AIS_VFE_BUS_VER1_COMP_GRP_IMG3, - AIS_VFE_BUS_VER1_COMP_GRP_STATS0, - AIS_VFE_BUS_VER1_COMP_GRP_STATS1, - AIS_VFE_BUS_VER1_COMP_GRP_MAX, -}; - -struct ais_vfe_bus_ver1_common_reg { - uint32_t cmd_offset; - uint32_t cfg_offset; - uint32_t io_fmt_offset; - uint32_t argb_cfg_offset; - uint32_t xbar_cfg0_offset; - uint32_t xbar_cfg1_offset; - uint32_t xbar_cfg2_offset; - uint32_t xbar_cfg3_offset; - uint32_t ping_pong_status_reg; -}; - -struct ais_vfe_bus_ver1_wm_reg { - uint32_t wm_cfg_offset; - uint32_t ping_addr_offset; - uint32_t ping_max_addr_offset; - uint32_t pong_addr_offset; - uint32_t pong_max_addr_offset; - uint32_t addr_cfg_offset; - uint32_t ub_cfg_offset; - uint32_t image_size_offset; - uint32_t buffer_cfg_offset; - uint32_t framedrop_pattern_offset; - uint32_t irq_subsample_pattern_offset; - uint32_t ping_pong_status_bit; /* 0 - 31 */ - uint32_t composite_bit; /* 0 -31 */ -}; - -struct ais_vfe_bus_ver1_wm_resource_data { - uint32_t index; - uint32_t wm_type; - uint32_t res_type; - - uint32_t offset; - uint32_t width; - uint32_t height; - uint32_t stride; - uint32_t scanline; - - uint32_t burst_len; - - uint32_t framedrop_period; - uint32_t framedrop_pattern; - - uint32_t buf_valid[AIS_VFE_BUS_VER1_PINGPONG_MAX]; - uint32_t ub_size; - uint32_t ub_offset; - - struct ais_vfe_bus_ver1_wm_reg hw_regs; -}; - -struct ais_vfe_bus_ver1_comp_grp_reg { - enum ais_vfe_bus_ver1_comp_grp_type comp_grp_type; - uint32_t comp_grp_offset; -}; - -struct ais_vfe_bus_ver1_comp_grp { - struct ais_vfe_bus_ver1_comp_grp_reg reg_info; - struct list_head wm_list; - uint32_t cur_bit_mask; -}; - -#endif /* _AIS_VFE_BUS_VER1_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver2.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver2.h deleted file mode 100755 index 435fea779fd7..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/ais_vfe_bus_ver2.h +++ /dev/null @@ -1,251 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_BUS_VER2_H_ -#define _AIS_VFE_BUS_VER2_H_ - -#include "ais_vfe_bus.h" - -#define AIS_VFE_BUS_VER2_MAX_CLIENTS 24 - -#define AIS_VFE_BUS_ENABLE_DMI_DUMP BIT(0) -#define AIS_VFE_BUS_ENABLE_STATS_REG_DUMP BIT(1) - -enum ais_vfe_bus_ver2_vfe_core_id { - AIS_VFE_BUS_VER2_VFE_CORE_0, - AIS_VFE_BUS_VER2_VFE_CORE_1, - AIS_VFE_BUS_VER2_VFE_CORE_MAX, -}; - -enum ais_vfe_bus_ver2_comp_grp_type { - AIS_VFE_BUS_VER2_COMP_GRP_0, - AIS_VFE_BUS_VER2_COMP_GRP_1, - AIS_VFE_BUS_VER2_COMP_GRP_2, - AIS_VFE_BUS_VER2_COMP_GRP_3, - AIS_VFE_BUS_VER2_COMP_GRP_4, - AIS_VFE_BUS_VER2_COMP_GRP_5, - AIS_VFE_BUS_VER2_COMP_GRP_DUAL_0, - AIS_VFE_BUS_VER2_COMP_GRP_DUAL_1, - AIS_VFE_BUS_VER2_COMP_GRP_DUAL_2, - AIS_VFE_BUS_VER2_COMP_GRP_DUAL_3, - AIS_VFE_BUS_VER2_COMP_GRP_DUAL_4, - AIS_VFE_BUS_VER2_COMP_GRP_DUAL_5, - AIS_VFE_BUS_VER2_COMP_GRP_MAX, -}; - -enum ais_vfe_bus_ver2_vfe_out_type { - AIS_VFE_BUS_VER2_VFE_OUT_RDI0, - AIS_VFE_BUS_VER2_VFE_OUT_RDI1, - AIS_VFE_BUS_VER2_VFE_OUT_RDI2, - AIS_VFE_BUS_VER2_VFE_OUT_RDI3, - AIS_VFE_BUS_VER2_VFE_OUT_FULL, - AIS_VFE_BUS_VER2_VFE_OUT_DS4, - AIS_VFE_BUS_VER2_VFE_OUT_DS16, - AIS_VFE_BUS_VER2_VFE_OUT_RAW_DUMP, - AIS_VFE_BUS_VER2_VFE_OUT_FD, - AIS_VFE_BUS_VER2_VFE_OUT_PDAF, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BE, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_HDR_BHIST, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_TL_BG, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BF, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_AWB_BG, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_BHIST, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_RS, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_CS, - AIS_VFE_BUS_VER2_VFE_OUT_STATS_IHIST, - AIS_VFE_BUS_VER2_VFE_OUT_FULL_DISP, - AIS_VFE_BUS_VER2_VFE_OUT_DS4_DISP, - AIS_VFE_BUS_VER2_VFE_OUT_DS16_DISP, - AIS_VFE_BUS_VER2_VFE_OUT_2PD, - AIS_VFE_BUS_VER2_VFE_OUT_MAX, -}; - -struct ais_vfe_bus_ver2_dmi_lut_bank_info { - uint32_t size; - uint32_t bank_0; - uint32_t bank_1; -}; - -struct ais_vfe_bus_ver2_stats_cfg_offset { - uint32_t res_index; - uint32_t cfg_offset; - uint32_t num_cfg; - uint32_t cfg_size; - uint32_t is_lut; - struct ais_vfe_bus_ver2_dmi_lut_bank_info lut; -}; - -struct ais_vfe_bus_ver2_dmi_offset_common { - uint32_t auto_increment; - uint32_t cfg_offset; - uint32_t addr_offset; - uint32_t data_hi_offset; - uint32_t data_lo_offset; -}; - -struct ais_vfe_bus_ver2_stats_cfg_info { - struct ais_vfe_bus_ver2_dmi_offset_common - dmi_offset_info; - struct ais_vfe_bus_ver2_stats_cfg_offset - stats_cfg_offset[AIS_VFE_BUS_VER2_VFE_OUT_MAX]; -}; - -/* - * struct ais_vfe_bus_ver2_reg_offset_common: - * - * @Brief: Common registers across all BUS Clients - */ -struct ais_vfe_bus_ver2_reg_offset_common { - uint32_t hw_version; - uint32_t hw_capability; - uint32_t sw_reset; - uint32_t cgc_ovd; - uint32_t pwr_iso_cfg; - uint32_t dual_master_comp_cfg; - struct ais_irq_controller_reg_info irq_reg_info; - uint32_t comp_error_status; - uint32_t comp_ovrwr_status; - uint32_t dual_comp_error_status; - uint32_t dual_comp_ovrwr_status; - uint32_t addr_sync_cfg; - uint32_t addr_sync_frame_hdr; - uint32_t addr_sync_no_sync; - uint32_t addr_fifo_status; - uint32_t debug_status_cfg; - uint32_t debug_status_0; -}; - -/* - * struct ais_vfe_bus_ver2_reg_offset_ubwc_client: - * - * @Brief: UBWC register offsets for BUS Clients - */ -struct ais_vfe_bus_ver2_reg_offset_ubwc_client { - uint32_t tile_cfg; - uint32_t h_init; - uint32_t v_init; - uint32_t meta_addr; - uint32_t meta_offset; - uint32_t meta_stride; - uint32_t mode_cfg_0; - uint32_t bw_limit; -}; - -/* - * struct ais_vfe_bus_ver2_reg_offset_ubwc_client: - * - * @Brief: UBWC register offsets for BUS Clients - */ -struct ais_vfe_bus_ver2_reg_offset_ubwc_3_client { - uint32_t tile_cfg; - uint32_t h_init; - uint32_t v_init; - uint32_t meta_addr; - uint32_t meta_offset; - uint32_t meta_stride; - uint32_t mode_cfg_0; - uint32_t mode_cfg_1; - uint32_t bw_limit; - uint32_t threshlod_lossy_0; - uint32_t threshlod_lossy_1; -}; - - -/* - * struct ais_vfe_bus_ver2_reg_offset_bus_client: - * - * @Brief: Register offsets for BUS Clients - */ -struct ais_vfe_bus_ver2_reg_offset_bus_client { - uint32_t status0; - uint32_t status1; - uint32_t cfg; - uint32_t header_addr; - uint32_t header_cfg; - uint32_t image_addr; - uint32_t image_addr_offset; - uint32_t buffer_width_cfg; - uint32_t buffer_height_cfg; - uint32_t packer_cfg; - uint32_t stride; - uint32_t irq_subsample_period; - uint32_t irq_subsample_pattern; - uint32_t framedrop_period; - uint32_t framedrop_pattern; - uint32_t frame_inc; - uint32_t burst_limit; - void *ubwc_regs; -}; - -/* - * struct ais_vfe_bus_ver2_reg_offset_comp_grp: - * - * @Brief: Register offsets for Composite Group registers - * comp_mask: Comp group register address - * addr_sync_mask:Address sync group register address - */ -struct ais_vfe_bus_ver2_reg_offset_comp_grp { - uint32_t comp_mask; - uint32_t addr_sync_mask; -}; - -/* - * struct ais_vfe_bus_ver2_vfe_out_hw_info: - * - * @Brief: HW capability of VFE Bus Client - */ -struct ais_vfe_bus_ver2_vfe_out_hw_info { - enum ais_vfe_bus_ver2_vfe_out_type vfe_out_type; - uint32_t max_width; - uint32_t max_height; -}; - -/* - * struct ais_vfe_bus_ver2_reg_data: - * - * @Brief: Holds the bus register data - */ - -struct ais_vfe_bus_ver2_reg_data { - uint32_t ubwc_10bit_threshold_lossy_0; - uint32_t ubwc_10bit_threshold_lossy_1; - uint32_t ubwc_8bit_threshold_lossy_0; - uint32_t ubwc_8bit_threshold_lossy_1; -}; - -/* - * struct ais_vfe_bus_ver2_hw_info: - * - * @Brief: HW register info for entire Bus - * - * @common_reg: Common register details - * @bus_client_reg: Bus client register info - * @comp_reg_grp: Composite group register info - * @vfe_out_hw_info: VFE output capability - * @reg_data: bus register data; - */ -struct ais_vfe_bus_ver2_hw_info { - struct ais_vfe_bus_ver2_reg_offset_common common_reg; - uint32_t num_client; - uint32_t is_lite; - struct ais_vfe_bus_ver2_reg_offset_bus_client - bus_client_reg[AIS_VFE_BUS_VER2_MAX_CLIENTS]; - struct ais_vfe_bus_ver2_reg_offset_comp_grp - comp_grp_reg[AIS_VFE_BUS_VER2_COMP_GRP_MAX]; - uint32_t num_out; - struct ais_vfe_bus_ver2_vfe_out_hw_info - vfe_out_hw_info[AIS_VFE_BUS_VER2_VFE_OUT_MAX]; - struct ais_vfe_bus_ver2_reg_data reg_data; - struct ais_vfe_bus_ver2_stats_cfg_info *stats_data; -}; - -#endif /* _AIS_VFE_BUS_VER2_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/include/ais_vfe_bus.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/include/ais_vfe_bus.h deleted file mode 100755 index ab75979c0ee5..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_bus/include/ais_vfe_bus.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_BUS_H_ -#define _AIS_VFE_BUS_H_ - -#include -#include -#include "cam_hw_intf.h" -#include "ais_isp_hw.h" - -#define AIS_VFE_BUS_VER_1_0 0x1000 -#define AIS_VFE_BUS_VER_2_0 0x2000 -#define AIS_VFE_BUS_RD_VER_4_0 0x4000 - -#endif /* _AIS_VFE_BUS_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_lite_ver2.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_lite_ver2.h deleted file mode 100755 index b2748ecb04e6..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_lite_ver2.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_CAMIF_LITE_VER2_H_ -#define _AIS_VFE_CAMIF_LITE_VER2_H_ - -#include "ais_vfe_top.h" - -struct ais_vfe_camif_lite_ver2_reg { - uint32_t camif_lite_cmd; - uint32_t camif_lite_config; - uint32_t lite_skip_period; - uint32_t lite_irq_subsample_pattern; - uint32_t lite_epoch_irq; - uint32_t reg_update_cmd; -}; - -struct ais_vfe_camif_lite_ver2_reg_data { - uint32_t dual_pd_reg_update_cmd_data; - uint32_t lite_epoch_line_cfg; - uint32_t lite_sof_irq_mask; - uint32_t lite_epoch0_irq_mask; - uint32_t dual_pd_reg_upd_irq_mask; - uint32_t lite_eof_irq_mask; - uint32_t lite_error_irq_mask0; - uint32_t lite_error_irq_mask1; - uint32_t extern_reg_update_shift; - uint32_t dual_pd_path_sel_shift; -}; - -struct ais_vfe_camif_lite_ver2_hw_info { - struct ais_vfe_top_ver2_reg_offset_common *common_reg; - struct ais_vfe_camif_lite_ver2_reg *camif_lite_reg; - struct ais_vfe_camif_lite_ver2_reg_data *reg_data; -}; - -#endif /* _AIS_VFE_CAMIF_LITE_VER2_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_ver2.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_ver2.h deleted file mode 100755 index 2da18969cd46..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_camif_ver2.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_CAMIF_VER2_H_ -#define _AIS_VFE_CAMIF_VER2_H_ - -#include "ais_vfe_top.h" - -/* - * Debug values for camif module - */ -#define CAMIF_DEBUG_ENABLE_SENSOR_DIAG_STATUS BIT(0) - -struct ais_vfe_camif_ver2_reg { - uint32_t camif_cmd; - uint32_t camif_config; - uint32_t line_skip_pattern; - uint32_t pixel_skip_pattern; - uint32_t skip_period; - uint32_t irq_subsample_pattern; - uint32_t epoch_irq; - uint32_t raw_crop_width_cfg; - uint32_t raw_crop_height_cfg; - uint32_t reg_update_cmd; - uint32_t vfe_diag_config; - uint32_t vfe_diag_sensor_status; -}; - -struct ais_vfe_camif_reg_data { - uint32_t raw_crop_first_pixel_shift; - uint32_t raw_crop_first_pixel_mask; - - uint32_t raw_crop_last_pixel_shift; - uint32_t raw_crop_last_pixel_mask; - - uint32_t raw_crop_first_line_shift; - uint32_t raw_crop_first_line_mask; - - uint32_t raw_crop_last_line_shift; - uint32_t raw_crop_last_line_mask; - - uint32_t input_mux_sel_shift; - uint32_t input_mux_sel_mask; - uint32_t extern_reg_update_shift; - uint32_t extern_reg_update_mask; - - uint32_t pixel_pattern_shift; - uint32_t pixel_pattern_mask; - - uint32_t dsp_mode_shift; - uint32_t dsp_mode_mask; - uint32_t dsp_en_shift; - uint32_t dsp_en_mask; - - uint32_t reg_update_cmd_data; - uint32_t epoch_line_cfg; - uint32_t sof_irq_mask; - uint32_t epoch0_irq_mask; - uint32_t reg_update_irq_mask; - uint32_t eof_irq_mask; - uint32_t error_irq_mask0; - uint32_t error_irq_mask1; - - uint32_t enable_diagnostic_hw; -}; - -struct ais_vfe_camif_ver2_hw_info { - struct ais_vfe_top_ver2_reg_offset_common *common_reg; - struct ais_vfe_camif_ver2_reg *camif_reg; - struct ais_vfe_camif_reg_data *reg_data; -}; - -#endif /* _AIS_VFE_CAMIF_VER2_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_fe_ver1.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_fe_ver1.h deleted file mode 100755 index 424a86e4ab84..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_fe_ver1.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_FE_VER1_H_ -#define _AIS_VFE_FE_VER1_H_ - -#include "ais_vfe_top.h" - -struct ais_vfe_fe_ver1_reg { - uint32_t camif_cmd; - uint32_t camif_config; - uint32_t line_skip_pattern; - uint32_t pixel_skip_pattern; - uint32_t skip_period; - uint32_t irq_subsample_pattern; - uint32_t epoch_irq; - uint32_t raw_crop_width_cfg; - uint32_t raw_crop_height_cfg; - uint32_t reg_update_cmd; - uint32_t vfe_diag_config; - uint32_t vfe_diag_sensor_status; - uint32_t fe_cfg; -}; - -struct ais_vfe_fe_reg_data { - uint32_t raw_crop_first_pixel_shift; - uint32_t raw_crop_first_pixel_mask; - - uint32_t raw_crop_last_pixel_shift; - uint32_t raw_crop_last_pixel_mask; - - uint32_t raw_crop_first_line_shift; - uint32_t raw_crop_first_line_mask; - - uint32_t raw_crop_last_line_shift; - uint32_t raw_crop_last_line_mask; - - uint32_t input_mux_sel_shift; - uint32_t input_mux_sel_mask; - uint32_t extern_reg_update_shift; - uint32_t extern_reg_update_mask; - - uint32_t pixel_pattern_shift; - uint32_t pixel_pattern_mask; - - uint32_t dsp_mode_shift; - uint32_t dsp_mode_mask; - uint32_t dsp_en_shift; - uint32_t dsp_en_mask; - - uint32_t reg_update_cmd_data; - uint32_t epoch_line_cfg; - uint32_t sof_irq_mask; - uint32_t epoch0_irq_mask; - uint32_t reg_update_irq_mask; - uint32_t eof_irq_mask; - uint32_t error_irq_mask0; - uint32_t error_irq_mask1; - - uint32_t enable_diagnostic_hw; - uint32_t fe_mux_data; - uint32_t hbi_cnt_shift; -}; - -struct ais_vfe_fe_ver1_hw_info { - struct ais_vfe_top_ver2_reg_offset_common *common_reg; - struct ais_vfe_fe_ver1_reg *fe_reg; - struct ais_vfe_fe_reg_data *reg_data; -}; - -#endif /* _AIS_VFE_FE_VER1_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_rdi.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_rdi.h deleted file mode 100755 index 520f280351c6..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_rdi.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_RDI_H_ -#define _AIS_VFE_RDI_H_ - -#include "ais_vfe_top.h" - -#define AIS_VFE_RDI_VER2_MAX 4 - -struct ais_vfe_rdi_ver2_reg { - uint32_t reg_update_cmd; -}; - -struct ais_vfe_rdi_reg_data { - uint32_t reg_update_cmd_data; - uint32_t sof_irq_mask; - uint32_t reg_update_irq_mask; -}; - -struct ais_vfe_rdi_ver2_hw_info { - struct ais_vfe_top_ver2_reg_offset_common *common_reg; - struct ais_vfe_rdi_ver2_reg *rdi_reg; - struct ais_vfe_rdi_reg_data *reg_data[AIS_VFE_RDI_VER2_MAX]; -}; - -#endif /* _AIS_VFE_RDI_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_top_ver2.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_top_ver2.h deleted file mode 100755 index be0955c1a25d..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/ais_vfe_top_ver2.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_TOP_VER2_H_ -#define _AIS_VFE_TOP_VER2_H_ - -#include "ais_vfe_camif_ver2.h" -#include "ais_vfe_camif_lite_ver2.h" -#include "ais_vfe_rdi.h" -#include "ais_vfe_fe_ver1.h" - -#define AIS_VFE_TOP_VER2_MUX_MAX 6 - -#define AIS_VFE_MAX_REG_DUMP_ENTRIES 5 - -#define AIS_VFE_MAX_LUT_DUMP_ENTRIES 6 - -enum ais_vfe_top_ver2_module_type { - AIS_VFE_TOP_VER2_MODULE_LENS, - AIS_VFE_TOP_VER2_MODULE_STATS, - AIS_VFE_TOP_VER2_MODULE_COLOR, - AIS_VFE_TOP_VER2_MODULE_ZOOM, - AIS_VFE_TOP_VER2_MODULE_MAX, -}; - -struct ais_vfe_top_ver2_reg_offset_module_ctrl { - uint32_t reset; - uint32_t cgc_ovd; - uint32_t enable; -}; - -struct ais_vfe_top_reg_dump_entry { - uint32_t reg_dump_start; - uint32_t reg_dump_end; -}; - -struct ais_vfe_top_lut_dump_entry { - uint32_t lut_word_size; - uint32_t lut_bank_sel; - uint32_t lut_addr_size; -}; - -struct ais_vfe_top_dump_data { - uint32_t num_reg_dump_entries; - uint32_t num_lut_dump_entries; - uint32_t dmi_cfg; - uint32_t dmi_addr; - uint32_t dmi_data_path_hi; - uint32_t dmi_data_path_lo; - struct ais_vfe_top_reg_dump_entry - reg_entry[AIS_VFE_MAX_REG_DUMP_ENTRIES]; - struct ais_vfe_top_lut_dump_entry - lut_entry[AIS_VFE_MAX_LUT_DUMP_ENTRIES]; -}; - -struct ais_vfe_top_ver2_reg_offset_common { - uint32_t hw_version; - uint32_t hw_capability; - uint32_t lens_feature; - uint32_t stats_feature; - uint32_t color_feature; - uint32_t zoom_feature; - uint32_t global_reset_cmd; - struct ais_vfe_top_ver2_reg_offset_module_ctrl - *module_ctrl[AIS_VFE_TOP_VER2_MODULE_MAX]; - uint32_t bus_cgc_ovd; - uint32_t core_cfg; - uint32_t three_D_cfg; - uint32_t violation_status; - uint32_t reg_update_cmd; -}; - -struct ais_vfe_top_ver2_hw_info { - struct ais_vfe_top_ver2_reg_offset_common *common_reg; - struct ais_vfe_camif_ver2_hw_info camif_hw_info; - struct ais_vfe_camif_lite_ver2_hw_info camif_lite_hw_info; - struct ais_vfe_rdi_ver2_hw_info rdi_hw_info; - struct ais_vfe_fe_ver1_hw_info fe_hw_info; - struct ais_vfe_top_dump_data dump_data; - uint32_t mux_type[AIS_VFE_TOP_VER2_MUX_MAX]; -}; - -int ais_vfe_top_ver2_init(struct cam_hw_soc_info *soc_info, - struct cam_hw_intf *hw_intf, - void *top_hw_info, - struct ais_vfe_top **vfe_top); - -int ais_vfe_top_ver2_deinit(struct ais_vfe_top **vfe_top); - -#endif /* _AIS_VFE_TOP_VER2_H_ */ diff --git a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/include/ais_vfe_top.h b/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/include/ais_vfe_top.h deleted file mode 100755 index ceab7bdc8492..000000000000 --- a/drivers/media/platform/msm/ais/ais_isp/vfe_hw/vfe_top/include/ais_vfe_top.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _AIS_VFE_TOP_H_ -#define _AIS_VFE_TOP_H_ - -#include "cam_hw_intf.h" -#include "ais_isp_hw.h" - -#define AIS_VFE_TOP_VER_1_0 0x100000 -#define AIS_VFE_TOP_VER_2_0 0x200000 - -#define AIS_VFE_CAMIF_VER_1_0 0x10 -#define AIS_VFE_CAMIF_VER_2_0 0x20 - -#define AIS_VFE_CAMIF_LITE_VER_2_0 0x02 - -#define AIS_VFE_RDI_VER_1_0 0x1000 -#define AIS_VFE_IN_RD_VER_1_0 0x2000 - -struct ais_vfe_top { - void *top_priv; - struct cam_hw_ops hw_ops; -}; - -int ais_vfe_top_init(uint32_t top_version, - struct cam_hw_soc_info *soc_info, - struct cam_hw_intf *hw_intf, - void *top_hw_info, - struct ais_vfe_top **vfe_top); - -int ais_vfe_top_deinit(uint32_t top_version, - struct ais_vfe_top **vfe_top); - -#endif /* _AIS_VFE_TOP_H_*/ diff --git a/drivers/media/platform/msm/npu/npu_mgr.c b/drivers/media/platform/msm/npu/npu_mgr.c index bd180c7aca16..df5acd96f1c8 100755 --- a/drivers/media/platform/msm/npu/npu_mgr.c +++ b/drivers/media/platform/msm/npu/npu_mgr.c @@ -1694,6 +1694,13 @@ int32_t npu_host_unload_network(struct npu_client *client, return -EINVAL; } + if (network->is_unloading) { + pr_err("network is unloading\n"); + network_put(network); + mutex_unlock(&host_ctx->lock); + return -EINVAL; + } + if (!network->is_active) { pr_err("network is not active\n"); network_put(network); @@ -1706,6 +1713,8 @@ int32_t npu_host_unload_network(struct npu_client *client, goto free_network; } + network->is_unloading = true; + pr_err("Unload network %lld\n", network->id); /* prepare IPC packet for UNLOAD */ unload_packet.header.cmd_type = NPU_IPC_CMD_UNLOAD; @@ -1948,6 +1957,12 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, if (atomic_inc_return(&host_ctx->network_execute_cnt) == 1) npu_notify_cdsprm_cxlimit_activity(npu_dev, true); + if (network->is_unloading) { + pr_err("network is unloading\n"); + ret = -EINVAL; + goto exec_v2_done; + } + if (!network->is_active) { pr_err("network is not active\n"); ret = -EINVAL; diff --git a/drivers/media/platform/msm/npu/npu_mgr.h b/drivers/media/platform/msm/npu/npu_mgr.h index 7c9239a636ea..ed82911f1bd2 100755 --- a/drivers/media/platform/msm/npu/npu_mgr.h +++ b/drivers/media/platform/msm/npu/npu_mgr.h @@ -59,6 +59,7 @@ struct npu_network { atomic_t ref_cnt; bool is_valid; bool is_active; + bool is_unloading; bool fw_error; bool cmd_pending; bool cmd_async; diff --git a/drivers/media/platform/msm/npu_v2/npu_mgr.c b/drivers/media/platform/msm/npu_v2/npu_mgr.c index d786a31c8b37..bb77dd65a5ae 100755 --- a/drivers/media/platform/msm/npu_v2/npu_mgr.c +++ b/drivers/media/platform/msm/npu_v2/npu_mgr.c @@ -2602,6 +2602,13 @@ int32_t npu_host_unload_network(struct npu_client *client, return -EINVAL; } + if (network->is_unloading) { + NPU_ERR("network is unloading\n"); + network_put(network); + mutex_unlock(&host_ctx->lock); + return -EINVAL; + } + if (!network->is_active) { NPU_ERR("network is not active\n"); network_put(network); @@ -2614,6 +2621,8 @@ int32_t npu_host_unload_network(struct npu_client *client, goto free_network; } + network->is_unloading = true; + NPU_DBG("Unload network %lld\n", network->id); /* prepare IPC packet for UNLOAD */ unload_packet.header.cmd_type = NPU_IPC_CMD_UNLOAD; @@ -2745,6 +2754,12 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, return -EINVAL; } + if (network->is_unloading) { + NPU_ERR("network is unloading\n"); + ret = -EINVAL; + goto exec_v2_done; + } + if (!network->is_active) { NPU_ERR("network is not active\n"); ret = -EINVAL; diff --git a/drivers/media/platform/msm/npu_v2/npu_mgr.h b/drivers/media/platform/msm/npu_v2/npu_mgr.h index c666cf8f8f1a..af1e8597cbdc 100755 --- a/drivers/media/platform/msm/npu_v2/npu_mgr.h +++ b/drivers/media/platform/msm/npu_v2/npu_mgr.h @@ -91,6 +91,7 @@ struct npu_network { atomic_t ref_cnt; bool is_valid; bool is_active; + bool is_unloading; bool fw_error; bool is_async; struct npu_client *client; diff --git a/drivers/misc/qseecom.c b/drivers/misc/qseecom.c index 0b4c80430aab..f15f0babf99f 100755 --- a/drivers/misc/qseecom.c +++ b/drivers/misc/qseecom.c @@ -6424,7 +6424,7 @@ static int qseecom_create_key(struct qseecom_dev_handle *data, struct qseecom_create_key_req create_key_req; struct qseecom_key_generate_ireq generate_key_ireq; struct qseecom_key_select_ireq set_key_ireq; - uint32_t entries = 0; + int32_t entries = 0; ret = copy_from_user(&create_key_req, argp, sizeof(create_key_req)); if (ret) { @@ -6569,7 +6569,7 @@ static int qseecom_wipe_key(struct qseecom_dev_handle *data, struct qseecom_wipe_key_req wipe_key_req; struct qseecom_key_delete_ireq delete_key_ireq; struct qseecom_key_select_ireq clear_key_ireq; - uint32_t entries = 0; + int32_t entries = 0; ret = copy_from_user(&wipe_key_req, argp, sizeof(wipe_key_req)); if (ret) { diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index a05bf334722c..9abd78ccd678 100755 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -137,7 +137,7 @@ static void mmc_bus_shutdown(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); struct mmc_card *card = mmc_dev_to_card(dev); - struct mmc_host *host = card->host; + struct mmc_host *host; int ret; if (!drv) { @@ -150,6 +150,8 @@ static void mmc_bus_shutdown(struct device *dev) return; } + host = card->host; + if (dev->driver && drv->shutdown) drv->shutdown(card); diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c index f7e9ae0b2a1f..d024c1202de9 100755 --- a/drivers/mmc/core/sdio_cis.c +++ b/drivers/mmc/core/sdio_cis.c @@ -55,7 +55,7 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, for (i = 0; i < nr_strings; i++) { buffer[i] = string; - memcpy(string, buf, strlen(buf) + 1); + strlcpy(string, buf, strlen(buf) + 1); string += strlen(string) + 1; buf += strlen(buf) + 1; } diff --git a/drivers/mmc/host/sdhci-msm.h b/drivers/mmc/host/sdhci-msm.h index ca0dbeb861b9..6ac6e9259e08 100755 --- a/drivers/mmc/host/sdhci-msm.h +++ b/drivers/mmc/host/sdhci-msm.h @@ -237,7 +237,7 @@ struct sdhci_msm_host { u32 clk_rate; /* Keeps track of current clock rate that is set */ bool tuning_done; bool calibration_done; - int saved_tuning_phase; + u8 saved_tuning_phase; bool en_auto_cmd21; struct device_attribute auto_cmd21_attr; bool is_sdiowakeup_enabled; diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4af76dafc6fc..beafa5dc67c5 100755 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1877,7 +1877,8 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) * Check SDcard busy signal by DAT0 before sending CMD13 * about 10ms : 100us * 100 times */ - if (present && (mrq->cmd->opcode == MMC_SEND_STATUS)) { + if (present && (mrq->cmd->opcode == MMC_SEND_STATUS) && + mmc_can_retune(mmc)) { int tries = 100; while (sdhci_card_busy(mmc) && --tries) usleep_range(95, 105); diff --git a/drivers/muic/sm/sm5714/sm5714-muic.c b/drivers/muic/sm/sm5714/sm5714-muic.c index f22ff5aaace0..3a74777303ce 100755 --- a/drivers/muic/sm/sm5714/sm5714-muic.c +++ b/drivers/muic/sm/sm5714/sm5714-muic.c @@ -1577,14 +1577,23 @@ static void sm5714_muic_detect_dev(struct sm5714_muic_data *muic_data, int irq) new_dev = ATTACHED_DEV_UNOFFICIAL_TA_MUIC; pr_info("[%s:%s] LO_TA\n", MUIC_DEV_NAME, __func__); } else if (dev1 & DEV_TYPE1_U200) { - if (!vbvolt) { - pr_info("[%s:%s] DEV_TYPE1_U200 + NO VBUS\n", - MUIC_DEV_NAME, __func__); + if ((irq == SM5714_MUIC_IRQ_WORK) || (irq == SM5714_MUIC_IRQ_PROBE)) { + if (!vbvolt) { + pr_info("[%s:%s] DEV_TYPE1_U200 + NO VBUS\n", + MUIC_DEV_NAME, __func__); + return; + } + intr = MUIC_INTR_ATTACH; + new_dev = ATTACHED_DEV_UNOFFICIAL_TA_MUIC; + pr_info("[%s:%s] U200\n", MUIC_DEV_NAME, __func__); + + } else { + schedule_delayed_work(&muic_data->muic_U200_work, + msecs_to_jiffies(100)); /* 100ms */ + pr_info("[%s:%s] muic_U200_work start\n", + MUIC_DEV_NAME, __func__); return; } - intr = MUIC_INTR_ATTACH; - new_dev = ATTACHED_DEV_UNOFFICIAL_TA_MUIC; - pr_info("[%s:%s] U200\n", MUIC_DEV_NAME, __func__); } else if (dev1 & DEV_TYPE1_CDP) { if (!vbvolt) { pr_info("[%s:%s] DEV_TYPE1_CDP + NO VBUS\n", @@ -1756,6 +1765,7 @@ static irqreturn_t sm5714_muic_irq_thread(int irq, void *data) #if defined(CONFIG_MUIC_SUPPORT_PDIC) cancel_delayed_work(&muic_data->pdic_afc_work); #endif + cancel_delayed_work(&muic_data->muic_U200_work); } if (irq_num == SM5714_MUIC_IRQ_INT2_AFC_ERROR) { @@ -1815,6 +1825,19 @@ static void sm5714_muic_handle_event(struct work_struct *work) mutex_unlock(&muic_data->muic_mutex); } +static void sm5714_muic_U200_delayed_noti(struct work_struct *work) +{ + struct sm5714_muic_data *muic_data = static_data; + + pr_info("[%s:%s]\n", MUIC_DEV_NAME, __func__); + + mutex_lock(&muic_data->muic_mutex); + __pm_stay_awake(muic_data->wake_lock); + sm5714_muic_detect_dev(muic_data, SM5714_MUIC_IRQ_WORK); + __pm_relax(muic_data->wake_lock); + mutex_unlock(&muic_data->muic_mutex); +} + #if defined(CONFIG_VBUS_NOTIFIER) static int sm5714_muic_handle_vbus_notification(struct notifier_block *nb, unsigned long action, void *data) @@ -2250,6 +2273,16 @@ static int sm5714_muic_probe(struct platform_device *pdev) if (muic_data->pdata->init_switch_dev_cb) muic_data->pdata->init_switch_dev_cb(); + /* init works */ + INIT_WORK(&(muic_data->muic_event_work), sm5714_muic_handle_event); + INIT_DELAYED_WORK(&muic_data->muic_debug_work, + sm5714_muic_debug_reg_log); + schedule_delayed_work(&muic_data->muic_debug_work, + msecs_to_jiffies(10000)); + + INIT_DELAYED_WORK(&muic_data->muic_U200_work, + sm5714_muic_U200_delayed_noti); + /* initial cable detection */ sm5714_muic_irq_thread(SM5714_MUIC_IRQ_PROBE, muic_data); @@ -2274,12 +2307,6 @@ static int sm5714_muic_probe(struct platform_device *pdev) MUIC_DEV_NAME, __func__); #endif - INIT_WORK(&(muic_data->muic_event_work), sm5714_muic_handle_event); - INIT_DELAYED_WORK(&muic_data->muic_debug_work, - sm5714_muic_debug_reg_log); - schedule_delayed_work(&muic_data->muic_debug_work, - msecs_to_jiffies(10000)); - return 0; fail_init_irq: @@ -2311,6 +2338,7 @@ static int sm5714_muic_remove(struct platform_device *pdev) pr_info("[%s:%s]\n", MUIC_DEV_NAME, __func__); cancel_delayed_work_sync(&muic_data->muic_debug_work); + cancel_delayed_work_sync(&muic_data->muic_U200_work); disable_irq_wake(muic_data->i2c->irq); sm5714_muic_free_irqs(muic_data); #if defined(CONFIG_VBUS_NOTIFIER) @@ -2334,6 +2362,7 @@ static void sm5714_muic_shutdown(struct platform_device *pdev) int ret; cancel_delayed_work_sync(&muic_data->muic_debug_work); + cancel_delayed_work_sync(&muic_data->muic_U200_work); pr_info("[%s:%s]\n", MUIC_DEV_NAME, __func__); if (!muic_data->i2c) { diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index 21190dfbabb1..4e9fe75d7067 100755 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig @@ -199,7 +199,7 @@ config WANXL_BUILD_FIRMWARE depends on WANXL && !PREVENT_FIRMWARE_BUILD help Allows you to rebuild firmware run by the QUICC processor. - It requires m68k toolchains and hexdump programs. + It requires as68k, ld68k and hexdump programs. You should never need this option, say N. diff --git a/drivers/net/wireless/cnss2/main.h b/drivers/net/wireless/cnss2/main.h index dde407e1d979..36c89a7c7633 100755 --- a/drivers/net/wireless/cnss2/main.h +++ b/drivers/net/wireless/cnss2/main.h @@ -26,7 +26,6 @@ #define MAX_NO_OF_MAC_ADDR 4 #define QMI_WLFW_MAX_TIMESTAMP_LEN 32 -#define QMI_WLFW_MAX_NUM_MEM_SEG 32 #define CNSS_RDDM_TIMEOUT_MS 20000 #define RECOVERY_TIMEOUT 60000 @@ -297,10 +296,10 @@ struct cnss_plat_data { struct wlfw_soc_info soc_info; struct wlfw_fw_version_info fw_version_info; u32 fw_mem_seg_len; - struct cnss_fw_mem fw_mem[QMI_WLFW_MAX_NUM_MEM_SEG]; + struct cnss_fw_mem fw_mem[QMI_WLFW_MAX_NUM_MEM_SEG_V01]; struct cnss_fw_mem m3_mem; u32 qdss_mem_seg_len; - struct cnss_fw_mem qdss_mem[QMI_WLFW_MAX_NUM_MEM_SEG]; + struct cnss_fw_mem qdss_mem[QMI_WLFW_MAX_NUM_MEM_SEG_V01]; u32 *qdss_reg; struct cnss_pin_connect_result pin_result; struct dentry *root_dentry; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_cmn_struct.h b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_cmn_struct.h index 1041df038f20..0c660f52a74c 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_cmn_struct.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_cmn_struct.h @@ -2229,6 +2229,8 @@ struct cdp_monitor_filter { * @cfg_dp_tso_enable: get TSO enable config * @cfg_dp_lro_enable: get LRO enable config * @cfg_dp_gro_enable: get GRP enable config + * @cfg_dp_tc_based_dyn_gro_enable: get TC based dynamic gro enable config + * @cfg_dp_tc_ingress_prio: priority value to be checked for tc filters * @cfg_dp_tx_flow_start_queue_offset: get DP TX flow start queue offset * @cfg_dp_tx_flow_stop_queue_threshold: get DP TX flow stop queue threshold * @cfg_dp_ipa_uc_tx_buf_size: get IPA TX buf size config @@ -2250,6 +2252,8 @@ enum cdp_dp_cfg { cfg_dp_tso_enable, cfg_dp_lro_enable, cfg_dp_gro_enable, + cfg_dp_tc_based_dyn_gro_enable, + cfg_dp_tc_ingress_prio, cfg_dp_tx_flow_start_queue_offset, cfg_dp_tx_flow_stop_queue_threshold, cfg_dp_ipa_uc_tx_buf_size, diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_mob_def.h b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_mob_def.h index 579e6a5f3d34..f6b08a7d7a14 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_mob_def.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/inc/cdp_txrx_mob_def.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -312,6 +313,8 @@ struct txrx_pdev_cfg_param_t { struct ol_tx_sched_wrr_ac_specs_t ac_specs[TX_WMM_AC_NUM]; bool gro_enable; + bool tc_based_dyn_gro; + uint32_t tc_ingress_prio; bool tso_enable; bool lro_enable; bool enable_data_stall_detection; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_main.c b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_main.c index 3ad4dfc06386..3ce843d7ed4b 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_main.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_main.c @@ -9887,6 +9887,12 @@ static uint32_t dp_get_cfg(struct cdp_soc_t *soc, enum cdp_dp_cfg cfg) case cfg_dp_gro_enable: value = dpsoc->wlan_cfg_ctx->gro_enabled; break; + case cfg_dp_tc_based_dyn_gro_enable: + value = dpsoc->wlan_cfg_ctx->tc_based_dynamic_gro; + break; + case cfg_dp_tc_ingress_prio: + value = dpsoc->wlan_cfg_ctx->tc_ingress_prio; + break; case cfg_dp_tx_flow_start_queue_offset: value = dpsoc->wlan_cfg_ctx->tx_flow_start_queue_offset; break; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_rx.c b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_rx.c index d8d508bc6c9d..88931f7510e2 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_rx.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_rx.c @@ -2288,9 +2288,16 @@ done: deliver_list_tail = NULL; } - /* Get TID from struct cb->tid_val, save to tid */ - if (qdf_nbuf_is_rx_chfrag_start(nbuf)) - tid = qdf_nbuf_get_tid_val(nbuf); + /* Get TID from struct cb->tid_val, save to tid */ + if (qdf_nbuf_is_rx_chfrag_start(nbuf)) { + tid = qdf_nbuf_get_tid_val(nbuf); + if (tid >= CDP_MAX_DATA_TIDS) { + DP_STATS_INC(soc, rx.err.rx_invalid_tid_err, 1); + qdf_nbuf_free(nbuf); + nbuf = next; + continue; + } + } peer_id = QDF_NBUF_CB_RX_PEER_ID(nbuf); diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_stats.c b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_stats.c index 940cf09c4994..744e422a2dca 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_stats.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_stats.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -4675,6 +4676,10 @@ void dp_print_soc_cfg_params(struct dp_soc *soc) soc_cfg_ctx->sg_enabled); DP_PRINT_STATS("Gro enabled: %u ", soc_cfg_ctx->gro_enabled); + DP_PRINT_STATS("TC based dynamic GRO: %u ", + soc_cfg_ctx->tc_based_dynamic_gro); + DP_PRINT_STATS("TC ingress prio: %u ", + soc_cfg_ctx->tc_ingress_prio); DP_PRINT_STATS("rawmode enabled: %u ", soc_cfg_ctx->rawmode_enabled); DP_PRINT_STATS("peer flow ctrl enabled: %u ", diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_types.h b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_types.h index c44ded5c4abf..dc0414df580e 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_types.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/dp/wifi3.0/dp_types.h @@ -824,6 +824,8 @@ struct dp_soc_stats { uint32_t invalid_link_cookie; /* Nbuf sanity failure */ uint32_t nbuf_sanity_fail; + /* Rx invalid tid count */ + uint32_t rx_invalid_tid_err; } err; /* packet count per core - per ring */ diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/target_if/direct_buf_rx/src/target_if_direct_buf_rx_main.c b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/target_if/direct_buf_rx/src/target_if_direct_buf_rx_main.c index fbea3c9aa70a..b7f28b84a91e 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/target_if/direct_buf_rx/src/target_if_direct_buf_rx_main.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/target_if/direct_buf_rx/src/target_if_direct_buf_rx_main.c @@ -1023,6 +1023,11 @@ static QDF_STATUS target_if_dbr_replenish_ring(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_FAILURE; } + if (cookie >= mod_param->dbr_ring_cfg->num_ptr) { + direct_buf_rx_err("invalid cookie %d", cookie); + return QDF_STATUS_E_INVAL; + } + dbr_psoc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_TARGET_IF_COMP_DIRECT_BUF_RX); @@ -1504,6 +1509,11 @@ static void *target_if_dbr_vaddr_lookup( dbr_buf_pool = mod_param->dbr_buf_pool; + if (cookie >= mod_param->dbr_ring_cfg->num_ptr) { + direct_buf_rx_err("invalid cookie %d", cookie); + return NULL; + } + if (dbr_buf_pool[cookie].paddr == paddr) { return dbr_buf_pool[cookie].vaddr + dbr_buf_pool[cookie].offset; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/cfg_dp.h b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/cfg_dp.h index 4a21bb1ebd08..f9b909a9ae89 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/cfg_dp.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/cfg_dp.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -531,9 +532,46 @@ CFG_INI_BOOL("dp_sg_support", false, \ "DP SG Enable") +#define WLAN_CFG_GRO_ENABLE_MIN 0 +#define WLAN_CFG_GRO_ENABLE_MAX 3 +#define WLAN_CFG_GRO_ENABLE_DEFAULT 0 +#define DP_GRO_ENABLE_BIT_SET BIT(0) +#define DP_TC_BASED_DYNAMIC_GRO BIT(1) + +/* + * + * CFG_DP_GRO - Enable the GRO feature standalonely + * @Min: 0 + * @Max: 3 + * @Default: 0 + * + * This ini entry is used to enable/disable GRO feature standalonely. + * Value 0: Disable GRO feature + * Value 1: Enable GRO feature always + * Value 3: Enable GRO dynamic feature where TC rule can control GRO + * behavior + * + * Usage: External + * + * + */ #define CFG_DP_GRO \ - CFG_INI_BOOL("GROEnable", false, \ - "DP GRO Enable") + CFG_INI_UINT("GROEnable", \ + WLAN_CFG_GRO_ENABLE_MIN, \ + WLAN_CFG_GRO_ENABLE_MAX, \ + WLAN_CFG_GRO_ENABLE_DEFAULT, \ + CFG_VALUE_OR_DEFAULT, "DP GRO Enable") + +#define WLAN_CFG_TC_INGRESS_PRIO_MIN 0 +#define WLAN_CFG_TC_INGRESS_PRIO_MAX 0xFFFF +#define WLAN_CFG_TC_INGRESS_PRIO_DEFAULT 0 + +#define CFG_DP_TC_INGRESS_PRIO \ + CFG_INI_UINT("tc_ingress_prio", \ + WLAN_CFG_TC_INGRESS_PRIO_MIN, \ + WLAN_CFG_TC_INGRESS_PRIO_MAX, \ + WLAN_CFG_TC_INGRESS_PRIO_DEFAULT, \ + CFG_VALUE_OR_DEFAULT, "DP tc ingress prio") #define CFG_DP_OL_TX_CSUM \ CFG_INI_BOOL("dp_offload_tx_csum_support", false, \ @@ -904,6 +942,7 @@ CFG(CFG_DP_LRO) \ CFG(CFG_DP_SG) \ CFG(CFG_DP_GRO) \ + CFG(CFG_DP_TC_INGRESS_PRIO) \ CFG(CFG_DP_OL_TX_CSUM) \ CFG(CFG_DP_OL_RX_CSUM) \ CFG(CFG_DP_RAWMODE) \ diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.c b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.c index 9560d9df25d0..3a9cde3d0256 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -440,6 +441,7 @@ wlan_cfg_soc_attach(struct cdp_ctrl_objmgr_psoc *psoc) { struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt)); + uint32_t gro_bit_set; if (!wlan_cfg_ctx) return NULL; @@ -498,7 +500,13 @@ wlan_cfg_soc_attach(struct cdp_ctrl_objmgr_psoc *psoc) wlan_cfg_ctx->tso_enabled = cfg_get(psoc, CFG_DP_TSO); wlan_cfg_ctx->lro_enabled = cfg_get(psoc, CFG_DP_LRO); wlan_cfg_ctx->sg_enabled = cfg_get(psoc, CFG_DP_SG); - wlan_cfg_ctx->gro_enabled = cfg_get(psoc, CFG_DP_GRO); + gro_bit_set = cfg_get(psoc, CFG_DP_GRO); + if (gro_bit_set & DP_GRO_ENABLE_BIT_SET) { + wlan_cfg_ctx->gro_enabled = true; + if (gro_bit_set & DP_TC_BASED_DYNAMIC_GRO) + wlan_cfg_ctx->tc_based_dynamic_gro = true; + } + wlan_cfg_ctx->tc_ingress_prio = cfg_get(psoc, CFG_DP_TC_INGRESS_PRIO); wlan_cfg_ctx->ol_tx_csum_enabled = cfg_get(psoc, CFG_DP_OL_TX_CSUM); wlan_cfg_ctx->ol_rx_csum_enabled = cfg_get(psoc, CFG_DP_OL_RX_CSUM); wlan_cfg_ctx->rawmode_enabled = cfg_get(psoc, CFG_DP_RAWMODE); diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.h b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.h index e90327f7ed52..e37fd4067266 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -133,6 +134,8 @@ struct wlan_srng_cfg { * @lro_enabled: enable/disable LRO feature * @sg_enabled: enable disable scatter gather feature * @gro_enabled: enable disable GRO feature + * @tc_based_dynamic_gro: enable/disable tc based dynamic gro + * @tc_ingress_prio: ingress prio to be checked for dynamic gro * @ipa_enabled: Flag indicating if IPA is enabled * @ol_tx_csum_enabled: Flag indicating if TX csum is enabled * @ol_rx_csum_enabled: Flag indicating if Rx csum is enabled @@ -229,6 +232,8 @@ struct wlan_cfg_dp_soc_ctxt { bool lro_enabled; bool sg_enabled; bool gro_enabled; + bool tc_based_dynamic_gro; + uint32_t tc_ingress_prio; bool ipa_enabled; bool ol_tx_csum_enabled; bool ol_rx_csum_enabled; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wmi/src/wmi_unified_tlv.c b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wmi/src/wmi_unified_tlv.c index 9528541abee6..0fa0dcba6edc 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wmi/src/wmi_unified_tlv.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qca-wifi-host-cmn/wmi/src/wmi_unified_tlv.c @@ -12946,6 +12946,15 @@ extract_roam_scan_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf, dst->num_chan = MAX_ROAM_SCAN_CHAN; src_chan = ¶m_buf->roam_scan_chan_info[chan_idx]; + + if ((dst->num_chan + chan_idx) > + param_buf->num_roam_scan_chan_info) { + wmi_err("Invalid TLV. num_chan %d chan_idx %d num_roam_scan_chan_info %d", + dst->num_chan, chan_idx, + param_buf->num_roam_scan_chan_info); + return QDF_STATUS_SUCCESS; + } + for (i = 0; i < dst->num_chan; i++) { dst->chan_freq[i] = src_chan->channel; src_chan++; @@ -13053,6 +13062,14 @@ extract_roam_11kv_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf, if (dst->num_freq > MAX_ROAM_SCAN_CHAN) dst->num_freq = MAX_ROAM_SCAN_CHAN; + if ((dst->num_freq + rpt_idx) > + param_buf->num_roam_neighbor_report_chan_info) { + wmi_err("Invalid TLV. num_freq %d rpt_idx %d num_roam_neighbor_report_chan_info %d", + dst->num_freq, rpt_idx, + param_buf->num_roam_scan_chan_info); + return QDF_STATUS_SUCCESS; + } + for (i = 0; i < dst->num_freq; i++) { dst->freq[i] = src_freq->channel; src_freq++; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h index 0954728ea950..a2e87b08dc40 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/inc/wlan_policy_mgr_api.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c index e155b08a465c..3a4db4c8f238 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c index b1a090109508..1e85abbfe659 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/components/cmn_services/policy_mgr/src/wlan_policy_mgr_init_deinit.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/configs/default_defconfig b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/configs/default_defconfig index f4d3d76442ba..214f3275b292 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/configs/default_defconfig +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/configs/default_defconfig @@ -944,7 +944,6 @@ ifeq ($(CONFIG_LITHIUM), y) CONFIG_HIF_CPU_PERF_AFFINE_MASK := y CONFIG_WLAN_FEATURE_DP_RX_RING_HISTORY := y endif - CONFIG_DYNAMIC_RX_AGGREGATION := y CONFIG_RX_DESC_DEBUG_CHECK:= y CONFIG_WLAN_SUPPORT_DATA_STALL := y CONFIG_WLAN_DP_PER_RING_TYPE_CONFIG := y @@ -954,6 +953,8 @@ ifeq ($(CONFIG_LITHIUM), y) CONFIG_WLAN_DP_PENDING_MEM_FLUSH := y endif +CONFIG_DYNAMIC_RX_AGGREGATION := y + #Flag to enable hdd memory dump feature CONFIG_FEATURE_MEMDUMP_ENABLE := y diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/cds/src/cds_api.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/cds/src/cds_api.c index 2b91834c52a1..155ef075f581 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/cds/src/cds_api.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/cds/src/cds_api.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -404,6 +405,7 @@ static void cds_cdp_cfg_attach(struct wlan_objmgr_psoc *psoc) struct txrx_pdev_cfg_param_t cdp_cfg = {0}; void *soc = cds_get_context(QDF_MODULE_ID_SOC); struct hdd_context *hdd_ctx = gp_cds_context->hdd_context; + uint32_t gro_bit_set; cdp_cfg.is_full_reorder_offload = cfg_get(psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); @@ -430,7 +432,13 @@ static void cds_cdp_cfg_attach(struct wlan_objmgr_psoc *psoc) cdp_cfg.lro_enable = cfg_get(psoc, CFG_DP_LRO); cdp_cfg.enable_data_stall_detection = cfg_get(psoc, CFG_DP_ENABLE_DATA_STALL_DETECTION); - cdp_cfg.gro_enable = cfg_get(psoc, CFG_DP_GRO); + gro_bit_set = cfg_get(psoc, CFG_DP_GRO); + if (gro_bit_set & DP_GRO_ENABLE_BIT_SET) { + cdp_cfg.gro_enable = true; + if (gro_bit_set & DP_TC_BASED_DYNAMIC_GRO) + cdp_cfg.tc_based_dyn_gro = true; + } + cdp_cfg.tc_ingress_prio = cfg_get(psoc, CFG_DP_TC_INGRESS_PRIO); cdp_cfg.enable_flow_steering = cfg_get(psoc, CFG_DP_FLOW_STEERING_ENABLED); cdp_cfg.disable_intra_bss_fwd = @@ -867,6 +875,13 @@ QDF_STATUS cds_dp_open(struct wlan_objmgr_psoc *psoc) { QDF_STATUS qdf_status; struct dp_txrx_config dp_config; + struct hdd_context *hdd_ctx; + + hdd_ctx = gp_cds_context->hdd_context; + if (!hdd_ctx) { + cds_err("HDD context is null"); + return QDF_STATUS_E_FAILURE; + } qdf_status = cdp_pdev_attach(cds_get_context(QDF_MODULE_ID_SOC), gp_cds_context->htc_ctx, @@ -900,6 +915,14 @@ QDF_STATUS cds_dp_open(struct wlan_objmgr_psoc *psoc) cds_debug("CDS successfully Opened"); + if (cdp_cfg_get(gp_cds_context->dp_soc, cfg_dp_tc_based_dyn_gro_enable)) + hdd_ctx->dp_agg_param.tc_based_dyn_gro = true; + else + hdd_ctx->dp_agg_param.tc_based_dyn_gro = false; + + hdd_ctx->dp_agg_param.tc_ingress_prio = + cdp_cfg_get(gp_cds_context->dp_soc, cfg_dp_tc_ingress_prio); + return 0; intr_close: diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/ol/inc/ol_cfg.h b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/ol/inc/ol_cfg.h index 88b9374aac1a..6edb17ee754f 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/ol/inc/ol_cfg.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/ol/inc/ol_cfg.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -109,6 +110,8 @@ struct txrx_pdev_cfg_t { u8 credit_update_enabled; struct ol_tx_sched_wrr_ac_specs_t ac_specs[QCA_WLAN_AC_ALL]; bool gro_enable; + bool tc_based_dyn_gro; + uint32_t tc_ingress_prio; bool tso_enable; bool lro_enable; bool enable_data_stall_detection; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_cfg.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_cfg.c index 9df6b0bae340..5693d2e2a054 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_cfg.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_cfg.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -206,6 +207,8 @@ struct cdp_cfg *ol_pdev_cfg_attach(qdf_device_t osdev, void *pcfg_param) cfg_param->nan_ip_tcp_udp_checksum_offload; cfg_ctx->ce_classify_enabled = cfg_param->ce_classify_enabled; cfg_ctx->gro_enable = cfg_param->gro_enable; + cfg_ctx->tc_based_dyn_gro = cfg_param->tc_based_dyn_gro; + cfg_ctx->tc_ingress_prio = cfg_param->tc_ingress_prio; cfg_ctx->tso_enable = cfg_param->tso_enable; cfg_ctx->lro_enable = cfg_param->lro_enable; cfg_ctx->enable_data_stall_detection = diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_txrx.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_txrx.c index 548b295f763c..f494b59ea245 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_txrx.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/dp/txrx/ol_txrx.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -5898,6 +5899,12 @@ static uint32_t ol_txrx_get_cfg(struct cdp_soc_t *soc_hdl, enum cdp_dp_cfg cfg) case cfg_dp_gro_enable: value = cfg_ctx->gro_enable; break; + case cfg_dp_tc_based_dyn_gro_enable: + value = cfg_ctx->tc_based_dyn_gro; + break; + case cfg_dp_tc_ingress_prio: + value = cfg_ctx->tc_ingress_prio; + break; #ifdef QCA_LL_TX_FLOW_CONTROL_V2 case cfg_dp_tx_flow_start_queue_offset: value = cfg_ctx->tx_flow_start_queue_offset; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_main.h b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_main.h index 1be9e6c39348..992f7eb1725b 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_main.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_main.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1064,6 +1065,20 @@ struct rcpi_info { struct hdd_context; +#ifdef WLAN_FEATURE_DYNAMIC_RX_AGGREGATION +/** + * enum qdisc_filter_status - QDISC filter status + * @QDISC_FILTER_RTNL_LOCK_FAIL: rtnl lock acquire failed + * @QDISC_FILTER_PRIO_MATCH: qdisc filter with priority match + * @QDISC_FILTER_PRIO_MISMATCH: no filter match with configured priority + */ +enum qdisc_filter_status { + QDISC_FILTER_RTNL_LOCK_FAIL, + QDISC_FILTER_PRIO_MATCH, + QDISC_FILTER_PRIO_MISMATCH, +}; +#endif + /** * struct hdd_adapter - hdd vdev/net_device context * @vdev: object manager vdev context @@ -1384,7 +1399,7 @@ struct hdd_adapter { bool handle_feature_update; qdf_work_t netdev_features_update_work; - uint8_t gro_disallowed[DP_MAX_RX_THREADS]; + qdf_atomic_t gro_disallowed; uint8_t gro_flushed[DP_MAX_RX_THREADS]; }; @@ -1567,10 +1582,12 @@ enum hdd_sta_smps_param { * enum RX_OFFLOAD - Receive offload modes * @CFG_LRO_ENABLED: Large Rx offload * @CFG_GRO_ENABLED: Generic Rx Offload + * @CFG_DYNAMIC_GRO_ENABLED: Dynamic GRO enabled */ enum RX_OFFLOAD { CFG_LRO_ENABLED = 1, CFG_GRO_ENABLED, + CFG_DYNAMIC_GRO_ENABLED, }; /* One per STA: 1 for BCMC_STA_ID, 1 for each SAP_SELF_STA_ID, @@ -1691,7 +1708,9 @@ struct hdd_adapter_ops_history { * @sar_cmd_params: SAR command params to be configured to the FW * @rx_aggregation: rx aggregation enable or disable state * @gro_force_flush: gro force flushed indication flag + * @force_gro_enable: force GRO enable or disable flag * @adapter_ops_wq: High priority workqueue for handling adapter operations + * @rx_skip_qdisc_chk_conc: flag to skip ingress qdisc check in concurrency */ struct hdd_context { struct wlan_objmgr_psoc *psoc; @@ -2019,6 +2038,8 @@ struct hdd_context { struct { qdf_atomic_t rx_aggregation; uint8_t gro_force_flush[DP_MAX_RX_THREADS]; + bool tc_based_dyn_gro; + uint32_t tc_ingress_prio; } dp_agg_param; #ifdef FW_THERMAL_THROTTLE_SUPPORT uint8_t dutycycle_off_percent; @@ -2026,6 +2047,7 @@ struct hdd_context { qdf_workqueue_t *adapter_ops_wq; struct hdd_adapter_ops_history adapter_ops_history; + qdf_atomic_t rx_skip_qdisc_chk_conc; #ifdef SEC_CONFIG_WLAN_BEACON_CHECK qdf_mc_timer_t skip_bmiss_set_timer; bool bmiss_set_last; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_tx_rx.h b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_tx_rx.h index d3f178dfe3b6..e9030371a99c 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_tx_rx.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/inc/wlan_hdd_tx_rx.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_main.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_main.c index 86ce16a1552e..30b3da0e0161 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_main.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_main.c @@ -193,6 +193,11 @@ #include #include "wlan_global_lmac_if_api.h" +#ifdef WLAN_FEATURE_DYNAMIC_RX_AGGREGATION +#include +#endif + + #ifdef MODULE #define WLAN_MODULE_NAME module_name(THIS_MODULE) #else @@ -6407,8 +6412,9 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t sessio qdf_event_create(&adapter->peer_cleanup_done); hdd_sta_info_init(&adapter->sta_info_list); hdd_sta_info_init(&adapter->cache_sta_info_list); - - if (QDF_STATUS_SUCCESS == status) { + qdf_atomic_init(&adapter->gro_disallowed); + + if (QDF_STATUS_SUCCESS == status) { /* Add it to the hdd's session list. */ status = hdd_add_adapter_back(hdd_ctx, adapter); } @@ -9501,6 +9507,133 @@ void hdd_set_vdev_bundle_require_flag(uint16_t vdev_id, #endif #define HDD_BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) + + +#ifdef WLAN_FEATURE_DYNAMIC_RX_AGGREGATION +static enum qdisc_filter_status +__hdd_check_for_prio_filter_in_clsact_qdisc(struct tcf_block *block, + uint32_t prio) +{ + struct tcf_chain *chain; + struct tcf_proto *tp; + enum qdisc_filter_status ret = QDISC_FILTER_PRIO_MISMATCH; + + if (!rtnl_trylock()) + return QDISC_FILTER_RTNL_LOCK_FAIL; + + list_for_each_entry(chain, &block->chain_list, list) { + for (tp = rtnl_dereference(chain->filter_chain); tp; + tp = rtnl_dereference(tp->next)) { + if (tp->prio == (prio << 16)) + ret = QDISC_FILTER_PRIO_MATCH; + } + } + rtnl_unlock(); + + return ret; +} + +/** + * hdd_check_for_prio_filter_in_clsact_qdisc() - Check if priority 3 filter + * is configured in the ingress clsact qdisc + * @qdisc: pointer to clsact qdisc + * + * Return: true if priority 3 filter is present else false + */ +static enum qdisc_filter_status +hdd_check_for_prio_filter_in_clsact_qdisc(struct Qdisc *qdisc, uint32_t prio) +{ + const struct Qdisc_class_ops *cops; + struct tcf_block *ingress_block; + + cops = qdisc->ops->cl_ops; + if (qdf_unlikely(!cops || !cops->tcf_block)) + return QDISC_FILTER_PRIO_MISMATCH; + + ingress_block = cops->tcf_block(qdisc, TC_H_MIN_INGRESS); + if (qdf_unlikely(!ingress_block)) + return QDISC_FILTER_PRIO_MISMATCH; + + return __hdd_check_for_prio_filter_in_clsact_qdisc(ingress_block, prio); +} + +/** + * hdd_rx_check_qdisc_for_adapter() - Check if any ingress qdisc is configured + * for given adapter + * @adapter: pointer to HDD adapter context + * @rx_ctx_id: Rx context id + * + * The function checks if ingress qdisc is registered for a given + * net device. + * + * Return: None + */ +static void +hdd_rx_check_qdisc_for_adapter(struct hdd_adapter *adapter) +{ + struct hdd_context *hdd_ctx = adapter->hdd_ctx; + struct netdev_queue *ingress_q; + struct Qdisc *ingress_qdisc; + bool disable_gro = false; + enum qdisc_filter_status ret; + + if (!adapter->dev->ingress_queue) + goto reset_wl; + + rcu_read_lock(); + + ingress_q = rcu_dereference(adapter->dev->ingress_queue); + if (qdf_unlikely(!ingress_q)) + goto reset; + + ingress_qdisc = rcu_dereference(ingress_q->qdisc); + if (qdf_unlikely(!ingress_qdisc)) + goto reset; + + if (qdf_str_eq(ingress_qdisc->ops->id, "ingress")) { + disable_gro = true; + } else if (qdf_str_eq(ingress_qdisc->ops->id, "clsact")) { + ret = hdd_check_for_prio_filter_in_clsact_qdisc(ingress_qdisc, + hdd_ctx->dp_agg_param.tc_ingress_prio); + + if (ret == QDISC_FILTER_RTNL_LOCK_FAIL) { + rcu_read_unlock(); + return; + } else if (ret == QDISC_FILTER_PRIO_MISMATCH) { + goto reset; + } + + disable_gro = true; + } + + if (disable_gro) { + rcu_read_unlock(); + + if (qdf_likely(qdf_atomic_read(&adapter->gro_disallowed))) + return; + + hdd_debug("ingress qdisc/filter configured disable GRO"); + qdf_atomic_set(&adapter->gro_disallowed, 1); + + return; + } + +reset: + rcu_read_unlock(); + +reset_wl: + if (qdf_unlikely(qdf_atomic_read(&adapter->gro_disallowed))) { + hdd_debug("ingress qdisc/filter removed enable GRO"); + qdf_atomic_set(&adapter->gro_disallowed, 0); + } +} +#else +static inline void +hdd_rx_check_qdisc_for_adapter(struct hdd_adapter *adapter) +{ +} +#endif + static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; @@ -9542,6 +9675,11 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) continue; } + if (hdd_ctx->dp_agg_param.tc_based_dyn_gro || + hdd_ctx->ol_enable == CFG_DYNAMIC_GRO_ENABLED) + hdd_rx_check_qdisc_for_adapter(adapter); + + tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, adapter->prev_tx_packets); rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, @@ -13111,12 +13249,12 @@ int hdd_configure_cds(struct hdd_context *hdd_ctx) goto cds_disable; /* Donot disable rx offload on concurrency for lithium based targets */ - if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || - hdd_ctx->target_type == TARGET_TYPE_QCA6390 || - hdd_ctx->target_type == TARGET_TYPE_QCA6490)) - if (hdd_ctx->ol_enable) - dp_cbs.hdd_disable_rx_ol_in_concurrency = - hdd_disable_rx_ol_in_concurrency; + if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || + hdd_ctx->target_type == TARGET_TYPE_QCA6390 || + hdd_ctx->target_type == TARGET_TYPE_QCA6490)) + if (hdd_ctx->ol_enable) + dp_cbs.hdd_disable_rx_ol_in_concurrency = + hdd_disable_rx_ol_in_concurrency; dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; dp_cbs.hdd_ipa_set_mcc_mode_cb = hdd_ipa_set_mcc_mode; dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan.c index 1cee02031bfb..208654e4bacd 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -69,6 +69,8 @@ static int __wlan_hdd_cfg80211_nan_ext_request(struct wiphy *wiphy, { int ret_val; struct hdd_context *hdd_ctx = wiphy_priv(wiphy); + struct net_device *dev = wdev->netdev; + struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); hdd_enter_dev(wdev->netdev); @@ -86,7 +88,7 @@ static int __wlan_hdd_cfg80211_nan_ext_request(struct wiphy *wiphy, return -EPERM; } - return os_if_process_nan_req(hdd_ctx->psoc, + return os_if_process_nan_req(hdd_ctx->psoc, adapter->vdev_id, data, data_len); } diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan_datapath.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan_datapath.c index 599902f7a09a..bf5f80051758 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_nan_datapath.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -879,7 +880,8 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id, if (hdd_ctx->ol_enable && !ucfg_is_nan_dbs_supported(hdd_ctx->psoc)) { hdd_info("Disable LRO/GRO in NDI Mode"); - hdd_disable_rx_ol_in_concurrency(true); + hdd_disable_rx_ol_in_concurrency(true); + } hdd_bus_bw_compute_prev_txrx_stats(adapter); @@ -918,7 +920,7 @@ void hdd_cleanup_ndi(struct hdd_context *hdd_ctx, PM_STA_MODE, NULL) == 1)))) { hdd_info("Enable LRO/GRO"); - hdd_disable_rx_ol_in_concurrency(false); + hdd_disable_rx_ol_in_concurrency(false); } } diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_tx_rx.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_tx_rx.c index a6dc9e746c7d..d3f799f4e212 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_tx_rx.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/hdd/src/wlan_hdd_tx_rx.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1593,6 +1594,9 @@ static void hdd_resolve_rx_ol_mode(struct hdd_context *hdd_ctx) } else if (cdp_cfg_get(soc, cfg_dp_lro_enable)) { hdd_debug("Rx offload LRO is enabled"); hdd_ctx->ol_enable = CFG_LRO_ENABLED; + } else if (cdp_cfg_get(soc, cfg_dp_tc_based_dyn_gro_enable)) { + hdd_debug("Dynamic Rx offload GRO is enabled"); + hdd_ctx->ol_enable = CFG_DYNAMIC_GRO_ENABLED; } else { hdd_debug("Rx offload: GRO is enabled"); hdd_ctx->ol_enable = CFG_GRO_ENABLED; @@ -1622,8 +1626,10 @@ static QDF_STATUS hdd_gro_rx_bh_disable(struct hdd_adapter *adapter, gro_result_t gro_res; uint32_t rx_aggregation; uint8_t rx_ctx_id = QDF_NBUF_CB_RX_CTX_ID(skb); + int32_t gro_disallowed; rx_aggregation = qdf_atomic_read(&hdd_ctx->dp_agg_param.rx_aggregation); + gro_disallowed = qdf_atomic_read(&adapter->gro_disallowed); skb_set_hash(skb, QDF_NBUF_CB_RX_FLOW_ID(skb), PKT_HASH_TYPE_L4); @@ -1631,7 +1637,7 @@ static QDF_STATUS hdd_gro_rx_bh_disable(struct hdd_adapter *adapter, gro_res = napi_gro_receive(napi_to_use, skb); if (hdd_get_current_throughput_level(hdd_ctx) == PLD_BUS_WIDTH_IDLE || - !rx_aggregation || adapter->gro_disallowed[rx_ctx_id]) { + !rx_aggregation || gro_disallowed) { if (gro_res != GRO_DROP && gro_res != GRO_NORMAL) { adapter->hdd_stats.tx_rx_stats. rx_gro_low_tput_flush++; @@ -1639,7 +1645,7 @@ static QDF_STATUS hdd_gro_rx_bh_disable(struct hdd_adapter *adapter, } if (!rx_aggregation) hdd_ctx->dp_agg_param.gro_force_flush[rx_ctx_id] = 1; - if (adapter->gro_disallowed[rx_ctx_id]) + if (gro_disallowed) adapter->gro_flushed[rx_ctx_id] = 1; } local_bh_enable(); @@ -1852,7 +1858,8 @@ static void hdd_register_rx_ol_cb(struct hdd_context *hdd_ctx, cdp_register_rx_offld_flush_cb(soc, hdd_qdf_lro_flush); hdd_ctx->receive_offload_cb = hdd_lro_rx; hdd_debug("LRO is enabled"); - } else if (hdd_ctx->ol_enable == CFG_GRO_ENABLED) { + } else if (hdd_ctx->ol_enable == CFG_GRO_ENABLED || + hdd_ctx->ol_enable == CFG_DYNAMIC_GRO_ENABLED) { qdf_atomic_set(&hdd_ctx->dp_agg_param.rx_aggregation, 1); if (lithium_based_target) { /* no flush registration needed, it happens in DP thread */ @@ -2080,6 +2087,7 @@ QDF_STATUS hdd_rx_deliver_to_stack(struct hdd_adapter *adapter, } #else +#ifdef WLAN_FEATURE_DYNAMIC_RX_AGGREGATION #if defined(WLAN_SUPPORT_RX_FISA) /** * hdd_set_fisa_disallowed_for_vdev() - Set fisa disallowed bit for a vdev @@ -2106,72 +2114,6 @@ void hdd_set_fisa_disallowed_for_vdev(ol_txrx_soc_handle soc, uint8_t vdev_id, } #endif -#ifdef WLAN_FEATURE_DYNAMIC_RX_AGGREGATION -/** - * hdd_rx_check_qdisc_for_adapter() - Check if any ingress qdisc is configured - * for given adapter - * @adapter: pointer to HDD adapter context - * @rx_ctx_id: Rx context id - * - * The function checks if ingress qdisc is registered for a given - * net device. - * - * Return: None - */ -static void -hdd_rx_check_qdisc_for_adapter(struct hdd_adapter *adapter, uint8_t rx_ctx_id) -{ - ol_txrx_soc_handle soc = cds_get_context(QDF_MODULE_ID_SOC); - struct netdev_queue *ingress_q; - struct Qdisc *ingress_qdisc; - bool is_qdisc_ingress = false; - - /* - * This additional ingress_queue NULL check is to avoid - * doing RCU lock/unlock in the common scenario where - * ingress_queue is not configured by default - */ - if (qdf_likely(!adapter->dev->ingress_queue)) - goto reset_wl; - - rcu_read_lock(); - ingress_q = rcu_dereference(adapter->dev->ingress_queue); - - if (qdf_unlikely(!ingress_q)) - goto reset; - - ingress_qdisc = rcu_dereference(ingress_q->qdisc); - if (!ingress_qdisc) - goto reset; - - is_qdisc_ingress = qdf_str_eq(ingress_qdisc->ops->id, "ingress"); - if (!is_qdisc_ingress) - goto reset; - - rcu_read_unlock(); - - if (adapter->gro_disallowed[rx_ctx_id]) - return; - - hdd_debug("ingress qdisc configured disable GRO"); - adapter->gro_disallowed[rx_ctx_id] = 1; - hdd_set_fisa_disallowed_for_vdev(soc, adapter->vdev_id, rx_ctx_id, 1); - - return; - -reset: - rcu_read_unlock(); - -reset_wl: - if (adapter->gro_disallowed[rx_ctx_id]) { - hdd_debug("ingress qdisc removed enable GRO"); - hdd_set_fisa_disallowed_for_vdev(soc, adapter->vdev_id, - rx_ctx_id, 0); - adapter->gro_disallowed[rx_ctx_id] = 0; - adapter->gro_flushed[rx_ctx_id] = 0; - } -} - QDF_STATUS hdd_rx_deliver_to_stack(struct hdd_adapter *adapter, struct sk_buff *skb) { @@ -2179,14 +2121,33 @@ QDF_STATUS hdd_rx_deliver_to_stack(struct hdd_adapter *adapter, int status = QDF_STATUS_E_FAILURE; int netif_status; bool skb_receive_offload_ok = false; - uint8_t rx_ctx_id = QDF_NBUF_CB_RX_CTX_ID(skb); - - hdd_rx_check_qdisc_for_adapter(adapter, rx_ctx_id); + uint8_t rx_ctx_id; + ol_txrx_soc_handle soc = cds_get_context(QDF_MODULE_ID_SOC); if (QDF_NBUF_CB_RX_TCP_PROTO(skb) && !QDF_NBUF_CB_RX_PEER_CACHED_FRM(skb)) skb_receive_offload_ok = true; + if (hdd_ctx->ol_enable == CFG_DYNAMIC_GRO_ENABLED || + hdd_ctx->ol_enable == CFG_GRO_ENABLED) + rx_ctx_id = 0; + else + rx_ctx_id = QDF_NBUF_CB_RX_CTX_ID(skb); + + + if (qdf_atomic_read(&adapter->gro_disallowed) == 0 && + adapter->gro_flushed[rx_ctx_id] != 0) { + if (qdf_likely(soc)) + hdd_set_fisa_disallowed_for_vdev(soc, adapter->vdev_id, + rx_ctx_id, 0); + adapter->gro_flushed[rx_ctx_id] = 0; + } else if (qdf_atomic_read(&adapter->gro_disallowed) && + adapter->gro_flushed[rx_ctx_id] == 0) { + if (qdf_likely(soc)) + hdd_set_fisa_disallowed_for_vdev(soc, adapter->vdev_id, + rx_ctx_id, 1); + } + if (skb_receive_offload_ok && hdd_ctx->receive_offload_cb && !hdd_ctx->dp_agg_param.gro_force_flush[rx_ctx_id] && !adapter->gro_flushed[rx_ctx_id]) { @@ -2255,6 +2216,7 @@ QDF_STATUS hdd_rx_deliver_to_stack(struct hdd_adapter *adapter, !QDF_NBUF_CB_RX_PEER_CACHED_FRM(skb)) skb_receive_offload_ok = true; + if (skb_receive_offload_ok && hdd_ctx->receive_offload_cb) { status = hdd_ctx->receive_offload_cb(adapter, skb); diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/inc/qwlan_version.h b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/inc/qwlan_version.h index 191d916faff6..fe71a3fa5e25 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/inc/qwlan_version.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/inc/qwlan_version.h @@ -41,7 +41,7 @@ #define QWLAN_VERSION_EXTRA "Q-QCOM" #endif #else -#define QWLAN_VERSION_EXTRA "Q-HL210811A" +#define QWLAN_VERSION_EXTRA "Q-HL221101A" #endif #define QWLAN_VERSION_BUILD 3 @@ -54,7 +54,7 @@ #define QWLAN_VERSIONSTR "5.2.022.3Q-QCOM" #endif #else -#define QWLAN_VERSIONSTR "5.2.022.3Q-HL210811A" +#define QWLAN_VERSIONSTR "5.2.022.3Q-HL230707A" #endif #endif /* QWLAN_VERSION_H */ diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/src/pe/lim/lim_utils.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/src/pe/lim/lim_utils.c index 83ae3d74e47c..efa8ae9f5592 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/src/pe/lim/lim_utils.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/mac/src/pe/lim/lim_utils.c @@ -1869,22 +1869,16 @@ static void __lim_process_channel_switch_timeout(struct pe_session *pe_session) } /* - * If the channel-list that AP is asking us to switch is invalid - * then we cannot switch the channel. Just disassociate from AP. - * We will find a better AP !!! + * The channel switch request received from AP is carrying + * invalid channel. It's ok to ignore this channel switch + * request as it might be from spoof AP. If it's from genuine + * AP, it may lead to heart beat failure and result in + * disconnection. DUT can go ahead and reconnect to it/any + * other AP once it disconnects. */ - if ((pe_session->limMlmState == - eLIM_MLM_LINK_ESTABLISHED_STATE) && - (pe_session->limSmeState != eLIM_SME_WT_DISASSOC_STATE) && - (pe_session->limSmeState != eLIM_SME_WT_DEAUTH_STATE)) { - pe_err("Invalid channel! Disconnect"); - lim_tear_down_link_with_ap(mac, - mac->lim.lim_timers. - gLimChannelSwitchTimer.sessionId, - eSIR_MAC_UNSUPPORTED_CHANNEL_CSA, - eLIM_LINK_MONITORING_DISASSOC); - return; - } + pe_err("Invalid channel freq %u Ignore CSA request", + channel_freq); + return; } switch (pe_session->gLimChannelSwitch.state) { case eLIM_CHANNEL_SWITCH_PRIMARY_ONLY: diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_scan_roam.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_scan_roam.c index 3179f79e4e65..be67e3d75bc6 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_scan_roam.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_scan_roam.c @@ -4954,7 +4954,7 @@ int wma_extscan_hotlist_match_event_handler(void *handle, return -ENOMEM; dest_ap = &dest_hotlist->ap[0]; - dest_hotlist->numOfAps = event->total_entries; + dest_hotlist->numOfAps = numap; dest_hotlist->requestId = event->config_request_id; if (event->first_entry_index + @@ -5121,6 +5121,7 @@ static int wma_group_num_bss_to_scan_id(const u_int8_t *cmd_param_info, struct extscan_cached_scan_results *t_cached_result; struct extscan_cached_scan_result *t_scan_id_grp; int i, j; + uint32_t total_scan_num_results = 0; tSirWifiScanResult *ap; param_buf = (WMI_EXTSCAN_CACHED_RESULTS_EVENTID_param_tlvs *) @@ -5131,17 +5132,19 @@ static int wma_group_num_bss_to_scan_id(const u_int8_t *cmd_param_info, t_cached_result = cached_result; t_scan_id_grp = &t_cached_result->result[0]; - if ((t_cached_result->num_scan_ids * - QDF_MIN(t_scan_id_grp->num_results, - param_buf->num_bssid_list)) > param_buf->num_bssid_list) { - WMA_LOGE("%s:num_scan_ids %d, num_results %d num_bssid_list %d", - __func__, - t_cached_result->num_scan_ids, - t_scan_id_grp->num_results, - param_buf->num_bssid_list); + for (i = 0; i < t_cached_result->num_scan_ids; i++) { + total_scan_num_results += t_scan_id_grp->num_results; + t_scan_id_grp++; + } + + if (total_scan_num_results > param_buf->num_bssid_list) { + wma_err("total_scan_num_results %d, num_bssid_list %d", + total_scan_num_results, + param_buf->num_bssid_list); return -EINVAL; } + t_scan_id_grp = &t_cached_result->result[0]; WMA_LOGD("%s: num_scan_ids:%d", __func__, t_cached_result->num_scan_ids); for (i = 0; i < t_cached_result->num_scan_ids; i++) { @@ -5153,8 +5156,7 @@ static int wma_group_num_bss_to_scan_id(const u_int8_t *cmd_param_info, return -ENOMEM; ap = &t_scan_id_grp->ap[0]; - for (j = 0; j < QDF_MIN(t_scan_id_grp->num_results, - param_buf->num_bssid_list); j++) { + for (j = 0; j < t_scan_id_grp->num_results; j++) { ap->channel = src_hotlist->channel; ap->ts = WMA_MSEC_TO_USEC(src_rssi->tstamp); ap->rtt = src_hotlist->rtt; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_utils.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_utils.c index db7fa1c37739..b891b389e050 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_utils.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/core/wma/src/wma_utils.c @@ -1,5 +1,6 @@ /* - * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1122,9 +1123,9 @@ wma_fill_tx_stats(struct sir_wifi_ll_ext_stats *ll_stats, struct sir_wifi_tx *tx_stats; struct sir_wifi_ll_ext_peer_stats *peer_stats; uint32_t *tx_mpdu_aggr, *tx_succ_mcs, *tx_fail_mcs, *tx_delay; - uint32_t len, dst_len, param_len, tx_mpdu_aggr_array_len, - tx_succ_mcs_array_len, tx_fail_mcs_array_len, - tx_delay_array_len; + uint32_t len, dst_len, param_len, num_entries, + tx_mpdu_aggr_array_len, tx_succ_mcs_array_len, + tx_fail_mcs_array_len, tx_delay_array_len; result = *buf; dst_len = *buf_length; @@ -1203,6 +1204,12 @@ wma_fill_tx_stats(struct sir_wifi_ll_ext_stats *ll_stats, return QDF_STATUS_E_FAILURE; } + num_entries = fix_param->num_peer_ac_tx_stats * WLAN_MAX_AC; + if (num_entries > param_buf->num_tx_stats) { + wma_err("tx stats invalid arg, %d", num_entries); + return QDF_STATUS_E_FAILURE; + } + for (i = 0; i < fix_param->num_peer_ac_tx_stats; i++) { uint32_t peer_id = wmi_peer_tx[i].peer_id; struct sir_wifi_tx *ac; diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/inc/os_if_nan.h b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/inc/os_if_nan.h index f471b605983b..3c474fd489ba 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/inc/os_if_nan.h +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/inc/os_if_nan.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2019, 2021 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -150,12 +150,13 @@ static inline QDF_STATUS os_if_nan_set_ndp_delete_transaction_id( * os_if_process_nan_req: os_if api to handle NAN requests attached to the * vendor command QCA_NL80211_VENDOR_SUBCMD_NAN_EXT * @psoc: pointer to psoc object + * @vdev_id: NAN vdev id * @data: request data. contains vendor cmd tlvs * @data_len: length of data * * Return: status of operation */ -int os_if_process_nan_req(struct wlan_objmgr_psoc *psoc, +int os_if_process_nan_req(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id, const void *data, int data_len); #else diff --git a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/src/os_if_nan.c b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/src/os_if_nan.c index f78f41df5b09..6bbe063af01a 100755 --- a/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/src/os_if_nan.c +++ b/drivers/net/wireless/qualcomm/wcn39xx/qcacld-3.0/os_if/nan/src/os_if_nan.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -2600,7 +2600,7 @@ static int os_if_process_nan_enable_req(struct wlan_objmgr_psoc *psoc, return qdf_status_to_os_return(status); } -int os_if_process_nan_req(struct wlan_objmgr_psoc *psoc, +int os_if_process_nan_req(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id, const void *data, int data_len) { uint32_t nan_subcmd; @@ -2622,10 +2622,11 @@ int os_if_process_nan_req(struct wlan_objmgr_psoc *psoc, * These will be treated as passthrough by the driver. This is to make * sure that HW mode is not set to DBS by NAN Enable request. NAN state * machine will remain unaffected in this case. - */ - if (!ucfg_is_nan_dbs_supported(psoc)) - return os_if_nan_generic_req(psoc, tb); - + */ + if (!ucfg_is_nan_dbs_supported(psoc)) { + policy_mgr_check_and_stop_opportunistic_timer(psoc, vdev_id); + return os_if_nan_generic_req(psoc, tb); + } /* * Send all requests other than Enable/Disable as type GENERIC. * These will be treated as passthrough by the driver. diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index a5c07e3826ce..38673c072479 100755 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -119,6 +119,7 @@ struct msm_pinctrl { const struct msm_pinctrl_soc_data *soc; void __iomem *regs; void __iomem *pdc_regs; + void __iomem *spi_base; #ifdef CONFIG_FRAGMENTED_GPIO_ADDRESS_SPACE /* For holding per tile virtual address */ void __iomem *per_tile_regs[4]; @@ -1675,6 +1676,7 @@ static void add_dirconn_tlmm(struct irq_data *d, irq_hw_number_t irq) struct msm_pinctrl *pctrl; phys_addr_t spi_cfg_reg = 0; unsigned long flags; + u32 offset_local; offset = select_dir_conn_mux(d, &irq); if (offset < 0 || !parent_data) @@ -1695,16 +1697,17 @@ static void add_dirconn_tlmm(struct irq_data *d, irq_hw_number_t irq) if (pctrl->spi_cfg_regs) { spi_cfg_reg = pctrl->spi_cfg_regs + ((dir_conn_data->hwirq - 32) / 32) * 4; + offset_local = ((dir_conn_data->hwirq - 32) / 32) * 4; if (spi_cfg_reg < pctrl->spi_cfg_end) { raw_spin_lock_irqsave(&pctrl->lock, flags); - val = scm_io_read(spi_cfg_reg); + val = readl_relaxed(pctrl->spi_base + offset_local); /* * Clear the respective bit for edge type * interrupt */ val &= ~(1 << ((dir_conn_data->hwirq - 32) % 32)); - WARN_ON(scm_io_write(spi_cfg_reg, val)); + writel_relaxed(val, pctrl->spi_base + offset_local); raw_spin_unlock_irqrestore(&pctrl->lock, flags); } else pr_err("%s: type config failed for SPI: %lu\n", @@ -1758,6 +1761,7 @@ static int msm_dirconn_irq_set_type(struct irq_data *d, unsigned int type) unsigned int config_val = 0; unsigned int val = 0; unsigned long flags; + u32 offset_local; if (!parent_data) return 0; @@ -1785,13 +1789,14 @@ static int msm_dirconn_irq_set_type(struct irq_data *d, unsigned int type) if (pctrl->spi_cfg_regs && type != IRQ_TYPE_NONE) { spi_cfg_reg = pctrl->spi_cfg_regs + ((parent_data->hwirq - 32) / 32) * 4; + offset_local = ((parent_data->hwirq - 32) / 32) * 4; if (spi_cfg_reg < pctrl->spi_cfg_end) { raw_spin_lock_irqsave(&pctrl->lock, flags); - val = scm_io_read(spi_cfg_reg); + val = readl_relaxed(pctrl->spi_base + offset_local); val &= ~(1 << ((parent_data->hwirq - 32) % 32)); if (config_val) val |= (1 << ((parent_data->hwirq - 32) % 32)); - WARN_ON(scm_io_write(spi_cfg_reg, val)); + writel_relaxed(val, pctrl->spi_base + offset_local); raw_spin_unlock_irqrestore(&pctrl->lock, flags); } else pr_err("%s: type config failed for SPI: %lu\n", @@ -2153,7 +2158,7 @@ static int msm_pinctrl_hibernation_suspend(void) spi_cfg_reg = pctrl->spi_cfg_regs; for (j = 0; j < spi_cfg_regs_count; j++) pctrl->spi_cfg_regs_val[j] = - scm_io_read(spi_cfg_reg + j * 4); + readl_relaxed(pctrl->spi_base + j * 4); } /* All normal gpios will have common registers, first save them */ for (i = 0; i < soc->ngpios; i++) { @@ -2210,8 +2215,8 @@ static void msm_pinctrl_hibernation_resume(void) pctrl->spi_cfg_regs) / 4 + 2; spi_cfg_reg = pctrl->spi_cfg_regs; for (j = 0; j < spi_cfg_regs_count; j++) - WARN_ON(scm_io_write(spi_cfg_reg + j * 4, - pctrl->spi_cfg_regs_val[j])); + writel_relaxed(pctrl->spi_cfg_regs_val[j], + pctrl->spi_base + j * 4); } /* Restore normal gpios */ @@ -2452,6 +2457,7 @@ int msm_pinctrl_probe(struct platform_device *pdev, key = "spi_cfg"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, key); if (res) { + pctrl->spi_base = devm_ioremap_resource(&pdev->dev, res); pctrl->spi_cfg_regs = res->start; pctrl->spi_cfg_end = res->end; } diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 132103764c3a..d811aebf12c8 100755 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -274,7 +274,7 @@ static void ufshcd_update_uic_error_cnt(struct ufs_hba *hba, u32 reg, int type) #if IS_ENABLED(CONFIG_SCSI_UFS_SUPPORT_TW_MAN_GC) #define UFS_TW_MANUAL_FLUSH_THRESHOLD 5 #endif -#define UFS_TW_DISABLE_THRESHOLD 7 +#define UFS_TW_DISABLE_THRESHOLD 9 #define SEC_UFS_TW_INFO_DIFF(t, n, o, member) ({ \ (t)->member = (n)->member - (o)->member; \ diff --git a/drivers/sensors/isg6320.c b/drivers/sensors/isg6320.c index dd20b38db590..54784f462d1a 100755 --- a/drivers/sensors/isg6320.c +++ b/drivers/sensors/isg6320.c @@ -3022,6 +3022,7 @@ static int isg6320_probe(struct i2c_client *client, noti_input_dev = input_allocate_device(); if (!noti_input_dev) { pr_err("[GRIP_%d] input_allocate_device failed\n", data->ic_num); + input_free_device(input_dev); goto err_noti_input_alloc; } @@ -3037,6 +3038,8 @@ static int isg6320_probe(struct i2c_client *client, ret = isg6320_reset(data); if (ret < 0) { pr_err("[GRIP_%d] reset fail\n", data->ic_num); + input_free_device(input_dev); + input_free_device(noti_input_dev); goto err_soft_reset; } @@ -3071,6 +3074,8 @@ static int isg6320_probe(struct i2c_client *client, if (ret < 0) { pr_err("[GRIP_%d] fail to reg client->irq %d err %d\n", client->irq, data->ic_num, ret); + input_free_device(input_dev); + input_free_device(noti_input_dev); goto err_irq; } disable_irq(client->irq); @@ -3078,8 +3083,9 @@ static int isg6320_probe(struct i2c_client *client, ret = input_register_device(input_dev); if (ret) { - input_free_device(input_dev); pr_err("[GRIP_%d] fail to reg input dev %d\n", data->ic_num, ret); + input_free_device(input_dev); + input_free_device(noti_input_dev); goto err_register_input_dev; } @@ -3087,12 +3093,14 @@ static int isg6320_probe(struct i2c_client *client, input_dev->name); if (ret < 0) { pr_err("[GRIP_%d] fail to create symlink %d\n", data->ic_num, ret); + input_free_device(noti_input_dev); goto err_create_symlink; } ret = sysfs_create_group(&data->input_dev->dev.kobj, &isg6320_attribute_group); if (ret < 0) { pr_err("[GRIP_%d] fail to create sysfs group (%d)\n", data->ic_num, ret); + input_free_device(noti_input_dev); goto err_sysfs_create_group; } @@ -3117,12 +3125,13 @@ static int isg6320_probe(struct i2c_client *client, if (ret) { pr_err("[GRIP_%d] fail to reg sensor(%d)\n", data->ic_num, ret); + input_free_device(noti_input_dev); goto err_sensor_register; } ret = input_register_device(noti_input_dev); if (ret) { - input_free_device(noti_input_dev); pr_err("[GRIP_U] failed to register input dev for noti (%d)\n", ret); + input_free_device(noti_input_dev); goto err_register_input_dev_noti; } @@ -3169,8 +3178,8 @@ static int isg6320_probe(struct i2c_client *client, return 0; -err_sensor_register: err_register_input_dev_noti: +err_sensor_register: sysfs_remove_group(&input_dev->dev.kobj, &isg6320_attribute_group); err_sysfs_create_group: sensors_remove_symlink(&data->input_dev->dev.kobj, data->input_dev->name); diff --git a/drivers/sensors/sx9360.c b/drivers/sensors/sx9360.c index 816077fe49db..bb83a0e58478 100755 --- a/drivers/sensors/sx9360.c +++ b/drivers/sensors/sx9360.c @@ -1920,7 +1920,7 @@ static int sx9360_probe(struct i2c_client *client, goto exit_input_init; ret = sx9360_noti_input_init(data); if (ret < 0) - goto exit_input_init; + goto exit_noti_input_init; wake_lock_init(&data->grip_wake_lock, WAKE_LOCK_SUSPEND, "grip_wake_lock"); @@ -2010,8 +2010,9 @@ exit_of_node: wake_lock_destroy(&data->grip_wake_lock); sysfs_remove_group(&data->input->dev.kobj, &sx9360_attribute_group); sensors_remove_symlink(&data->input->dev.kobj, data->input->name); - input_unregister_device(data->input); input_unregister_device(data->noti_input_dev); +exit_noti_input_init: + input_unregister_device(data->input); exit_input_init: kfree(data); exit_kzalloc: diff --git a/drivers/thermal/qcom/qti_bus_scaling_cdev.c b/drivers/thermal/qcom/qti_bus_scaling_cdev.c deleted file mode 100755 index e5fd3b874c8c..000000000000 --- a/drivers/thermal/qcom/qti_bus_scaling_cdev.c +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (c) 2021, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#define pr_fmt(fmt) "%s:%s " fmt, KBUILD_MODNAME, __func__ - -#include -#include -#include -#include -#include - -#define DDR_CDEV_NAME "ddr-bus-scaling-cdev" - -struct ddr_cdev { - uint32_t cur_state; - uint32_t max_state; - uint32_t bus_clnt_handle; - struct thermal_cooling_device *cdev; - struct msm_bus_scale_pdata *ddr_bus_pdata; - struct device *dev; -}; - -/** - * ddr_set_cur_state - callback function to set the ddr state. - * @cdev: thermal cooling device pointer. - * @state: set this variable to the current cooling state. - * - * Callback for the thermal cooling device to change the - * DDR state. - * - * Return: 0 on success, an error code otherwise. - */ -static int ddr_set_cur_state(struct thermal_cooling_device *cdev, - unsigned long state) -{ - struct ddr_cdev *ddr_cdev = cdev->devdata; - int ret = 0; - - /* Request state should be less than max_level */ - if (state > ddr_cdev->max_state) - return -EINVAL; - - /* Check if the old cooling action is same as new cooling action */ - if (ddr_cdev->cur_state == state) - return 0; - - ret = msm_bus_scale_client_update_request(ddr_cdev->bus_clnt_handle, - state); - if (ret) { - dev_err(ddr_cdev->dev, - "Error placing DDR freq for idx:%d. err:%d\n", - state, ret); - return ret; - } - ddr_cdev->cur_state = state; - - dev_dbg(ddr_cdev->dev, "Requested DDR bus scaling state:%ld for %s\n", - state, ddr_cdev->cdev->type); - - return ret; -} - -/** - * ddr_get_cur_state - callback function to get the current cooling - * state. - * @cdev: thermal cooling device pointer. - * @state: fill this variable with the current cooling state. - * - * Callback for the thermal cooling device to return the - * current DDR state request. - * - * Return: 0 on success, an error code otherwise. - */ -static int ddr_get_cur_state(struct thermal_cooling_device *cdev, - unsigned long *state) -{ - struct ddr_cdev *ddr_cdev = cdev->devdata; - *state = ddr_cdev->cur_state; - - return 0; -} - -/** - * ddr_get_max_state - callback function to get the max cooling state. - * @cdev: thermal cooling device pointer. - * @state: fill this variable with the max cooling state. - * - * Callback for the thermal cooling device to return the DDR - * max cooling state. - * - * Return: 0 on success, an error code otherwise. - */ -static int ddr_get_max_state(struct thermal_cooling_device *cdev, - unsigned long *state) -{ - struct ddr_cdev *ddr_cdev = cdev->devdata; - *state = ddr_cdev->max_state; - - return 0; -} - -static struct thermal_cooling_device_ops ddr_cdev_ops = { - .get_max_state = ddr_get_max_state, - .get_cur_state = ddr_get_cur_state, - .set_cur_state = ddr_set_cur_state, -}; - -static int ddr_cdev_probe(struct platform_device *pdev) -{ - int ret = 0; - struct ddr_cdev *ddr_cdev = NULL; - struct device_node *np = pdev->dev.of_node; - struct device *dev = &pdev->dev; - char cdev_name[THERMAL_NAME_LENGTH] = "ddr-cdev"; - - ddr_cdev = devm_kzalloc(dev, sizeof(*ddr_cdev), GFP_KERNEL); - if (!ddr_cdev) - return -ENOMEM; - - ddr_cdev->ddr_bus_pdata = msm_bus_cl_get_pdata(pdev); - if (!ddr_cdev->ddr_bus_pdata) { - ret = -EINVAL; - dev_err(dev, "Unable to get ddr cdev bus pdata: %d\n"); - return ret; - } - - if (ddr_cdev->ddr_bus_pdata->num_usecases < 2) { - dev_err(dev, "Invalid number of ddr cdev levels, num_path:%d\n", - ddr_cdev->ddr_bus_pdata->num_usecases); - goto err_exit; - } - - ddr_cdev->bus_clnt_handle = msm_bus_scale_register_client( - ddr_cdev->ddr_bus_pdata); - if (!ddr_cdev->bus_clnt_handle) { - dev_err(dev, "%s: Failed to register ddr cdev client", - __func__); - ret = -ENXIO; - goto err_exit; - } - - ddr_cdev->cur_state = 0; - /* max_state is index */ - ddr_cdev->max_state = ddr_cdev->ddr_bus_pdata->num_usecases - 1; - ddr_cdev->dev = dev; - - /* Set initial value */ - ret = msm_bus_scale_client_update_request(ddr_cdev->bus_clnt_handle, - ddr_cdev->cur_state); - if (ret) { - dev_err(dev, "Error placing DDR freq request, index:%d err:%d\n", - ddr_cdev->cur_state, ret); - goto err_exit; - } - - ddr_cdev->cdev = thermal_of_cooling_device_register(np, cdev_name, - ddr_cdev, &ddr_cdev_ops); - if (IS_ERR(ddr_cdev->cdev)) { - ret = PTR_ERR(ddr_cdev->cdev); - dev_err(dev, "Cdev register failed for %s, ret:%d\n", - cdev_name, ret); - ddr_cdev->cdev = NULL; - goto err_exit; - } - dev_dbg(dev, "Cooling device [%s] registered.\n", cdev_name); - dev_set_drvdata(dev, ddr_cdev); - - return 0; -err_exit: - if (ddr_cdev->bus_clnt_handle) { - msm_bus_scale_unregister_client(ddr_cdev->bus_clnt_handle); - ddr_cdev->bus_clnt_handle = 0; - } - if (ddr_cdev->ddr_bus_pdata) { - msm_bus_cl_clear_pdata(ddr_cdev->ddr_bus_pdata); - ddr_cdev->ddr_bus_pdata = NULL; - } - return ret; -} - -static int ddr_cdev_remove(struct platform_device *pdev) -{ - struct ddr_cdev *ddr_cdev = - (struct ddr_cdev *)dev_get_drvdata(&pdev->dev); - - if (ddr_cdev->cdev) { - thermal_cooling_device_unregister(ddr_cdev->cdev); - ddr_cdev->cdev = NULL; - } - if (ddr_cdev->bus_clnt_handle) { - msm_bus_scale_client_update_request( - ddr_cdev->bus_clnt_handle, 0); - msm_bus_scale_unregister_client(ddr_cdev->bus_clnt_handle); - ddr_cdev->bus_clnt_handle = 0; - } - if (ddr_cdev->ddr_bus_pdata) { - msm_bus_cl_clear_pdata(ddr_cdev->ddr_bus_pdata); - ddr_cdev->ddr_bus_pdata = NULL; - } - - return 0; -} - -static const struct of_device_id ddr_cdev_match[] = { - { .compatible = "qcom,ddr-cooling-device", }, - {}, -}; - -static struct platform_driver ddr_cdev_driver = { - .probe = ddr_cdev_probe, - .remove = ddr_cdev_remove, - .driver = { - .name = KBUILD_MODNAME, - .of_match_table = ddr_cdev_match, - }, -}; -module_platform_driver(ddr_cdev_driver); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 3ff6f4b85c58..c56ddf2d88d9 100755 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -29,7 +29,7 @@ static char product_string[256]; #endif #ifdef CONFIG_USB_CONFIGFS_F_ACC -extern int acc_ctrlrequest(struct usb_composite_dev *cdev, +extern int acc_ctrlrequest_composite(struct usb_composite_dev *cdev, const struct usb_ctrlrequest *ctrl); void acc_disconnect(void); #endif @@ -1826,7 +1826,7 @@ static int android_setup(struct usb_gadget *gadget, #ifdef CONFIG_USB_CONFIGFS_F_ACC if (value < 0) - value = acc_ctrlrequest(cdev, c); + value = acc_ctrlrequest_composite(cdev, c); #endif if (value < 0) diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c index 4cf2d653c187..f815bb60b0c7 100755 --- a/drivers/usb/gadget/function/f_accessory.c +++ b/drivers/usb/gadget/function/f_accessory.c @@ -993,6 +993,26 @@ err: } EXPORT_SYMBOL_GPL(acc_ctrlrequest); +int acc_ctrlrequest_composite(struct usb_composite_dev *cdev, + const struct usb_ctrlrequest *ctrl) +{ + u16 w_length = le16_to_cpu(ctrl->wLength); + + if (w_length > USB_COMP_EP0_BUFSIZ) { + if (ctrl->bRequestType & USB_DIR_IN) { + /* Cast away the const, we are going to overwrite on purpose. */ + __le16 *temp = (__le16 *)&ctrl->wLength; + + *temp = cpu_to_le16(USB_COMP_EP0_BUFSIZ); + w_length = USB_COMP_EP0_BUFSIZ; + } else { + return -EINVAL; + } + } + return acc_ctrlrequest(cdev, ctrl); +} +EXPORT_SYMBOL_GPL(acc_ctrlrequest_composite); + static int __acc_function_bind(struct usb_configuration *c, struct usb_function *f, bool configfs) diff --git a/drivers/usb/gadget/function/f_ss_mon_gadget.c b/drivers/usb/gadget/function/f_ss_mon_gadget.c index ed5e91c4f9b2..b4e9c0f11962 100755 --- a/drivers/usb/gadget/function/f_ss_mon_gadget.c +++ b/drivers/usb/gadget/function/f_ss_mon_gadget.c @@ -321,6 +321,12 @@ static int ss_monitor_setup(struct usb_function *f, if (ctrl->bRequest == 0xA3) { pr_info("usb: [%s] RECEIVE PC GUID / line[%d]\n", __func__, __LINE__); + if (w_length > MAX_GUID_SIZE) { + pr_info("usb: [%s] Invalid GUID size / line[%d]\n", + __func__, __LINE__); + goto unknown; + } + value = w_length; req->complete = mtp_complete_get_guid; req->zero = 0; @@ -685,4 +691,4 @@ static struct usb_function *ss_mon_alloc(struct usb_function_instance *fi) DECLARE_USB_FUNCTION_INIT(ss_mon, ss_mon_alloc_inst, ss_mon_alloc); MODULE_AUTHOR("Samsung USB Team"); MODULE_DESCRIPTION("usb device monitor gadget"); -MODULE_LICENSE("GPL"); \ No newline at end of file +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/typec/sm/sm5714/sm5714_typec.c b/drivers/usb/typec/sm/sm5714/sm5714_typec.c index 295348e716c5..7d5c8633c66a 100755 --- a/drivers/usb/typec/sm/sm5714/sm5714_typec.c +++ b/drivers/usb/typec/sm/sm5714/sm5714_typec.c @@ -528,15 +528,10 @@ static void sm5714_notify_rp_current_level(void *_data) struct sm5714_phydrv_data *pdic_data = pd_data->phy_driver_data; struct i2c_client *i2c = pdic_data->i2c; u8 cc_status = 0, rp_currentlvl = 0; - bool short_cable = false; #if defined(CONFIG_TYPEC) enum typec_pwr_opmode mode = TYPEC_PWR_MODE_USB; #endif - sm5714_get_short_state(pd_data, &short_cable); - - if (short_cable) - return; #if defined(CONFIG_SM5714_WATER_DETECTION_ENABLE) if (pdic_data->is_water_detect) return; @@ -600,6 +595,11 @@ static void sm5714_notify_rp_abnormal(void *_data) struct i2c_client *i2c = pdic_data->i2c; u8 cc_status = 0, rp_currentlvl = RP_CURRENT_ABNORMAL; +#if defined(CONFIG_SM5714_WATER_DETECTION_ENABLE) + if (pdic_data->is_water_detect) + return; +#endif + sm5714_usbpd_read_reg(i2c, SM5714_REG_CC_STATUS, &cc_status); /* PDIC = SINK */ @@ -1522,6 +1522,7 @@ void sm5714_usbpd_set_rp_scr_sel(struct sm5714_usbpd_data *_data, int scr_sel) u8 data = 0; pr_info("%s: scr_sel : (%d)\n", __func__, scr_sel); + pdic_data->scr_sel = scr_sel; switch (scr_sel) { case PLUG_CTRL_RP80: @@ -1720,6 +1721,9 @@ void sm5714_protocol_layer_reset(void *_data) return; } + /* Rx Buffer Flushing */ + sm5714_usbpd_write_reg(i2c, SM5714_REG_RX_BUF_ST, 0x10); + /* Reset Protocol Layer */ sm5714_usbpd_write_reg(i2c, SM5714_REG_PD_CNTL4, SM5714_REG_CNTL_PROTOCOL_RESET_MESSAGE); @@ -1862,6 +1866,33 @@ static void sm5714_usbpd_abnormal_reset_check(struct sm5714_phydrv_data *pdic_da } } +#ifndef CONFIG_SEC_FACTORY +static int sm5714_usbpd_check_normal_audio_device(struct sm5714_phydrv_data *pdic_data) +{ + struct sm5714_usbpd_data *pd_data = dev_get_drvdata(pdic_data->dev); + struct i2c_client *i2c = pdic_data->i2c; + u8 adc_cc1 = 0, adc_cc2 = 0; + int ret = 0; + + sm5714_usbpd_set_rp_scr_sel(pd_data, PLUG_CTRL_RP180); + + sm5714_usbpd_write_reg(i2c, SM5714_REG_ADC_CNTL1, SM5714_ADC_PATH_SEL_CC1); + sm5714_adc_value_read(pdic_data, &adc_cc1); + + sm5714_usbpd_write_reg(i2c, SM5714_REG_ADC_CNTL1, SM5714_ADC_PATH_SEL_CC2); + sm5714_adc_value_read(pdic_data, &adc_cc2); + + if ((adc_cc1 <= 0xF) && (adc_cc2 <= 0xF)) { /* Ra/Ra */ + sm5714_usbpd_set_rp_scr_sel(pd_data, PLUG_CTRL_RP80); + ret = 1; + } + + pr_info("%s, CC1 : 0x%x, CC2 : 0x%x, ret = %d\n", __func__, adc_cc1, adc_cc2, ret); + + return ret; +} +#endif + #if defined(CONFIG_SM5714_WATER_DETECTION_ENABLE) static void sm5714_usbpd_check_normal_otg_device(struct sm5714_phydrv_data *pdic_data) { @@ -2013,6 +2044,18 @@ static bool sm5714_poll_status(void *_data, int irq) sm5714_usbpd_check_normal_otg_device(pdic_data); } #endif + + if (pdic_data->is_cc_abnormal_state && + !(status[4] & SM5714_REG_INT_STATUS5_CC_ABNORMAL)) { + pdic_data->is_cc_abnormal_state = false; +#if IS_ENABLED(CONFIG_BATTERY_SAMSUNG) + if ((status[0] & SM5714_REG_INT_STATUS1_ATTACH) && + !(intr[1] & SM5714_REG_INT_STATUS2_SRC_ADV_CHG) && + pdic_data->is_attached) + pdic_data->is_noti_src_adv = true; +#endif + } + if ((intr[4] & SM5714_REG_INT_STATUS5_CC_ABNORMAL) && (status[4] & SM5714_REG_INT_STATUS5_CC_ABNORMAL)) { pdic_data->is_cc_abnormal_state = true; @@ -2020,7 +2063,7 @@ static bool sm5714_poll_status(void *_data, int irq) if ((status[0] & SM5714_REG_INT_STATUS1_ATTACH) && pdic_data->is_attached) { /* rp abnormal */ - sm5714_notify_rp_abnormal(_data); + pdic_data->is_noti_src_adv = true; } #endif pr_info("%s, CC-VBUS SHORT\n", __func__); @@ -2045,7 +2088,7 @@ static bool sm5714_poll_status(void *_data, int irq) #if defined(CONFIG_BATTERY_SAMSUNG) if ((intr[1] & SM5714_REG_INT_STATUS2_SRC_ADV_CHG) && !(intr[3] & SM5714_REG_INT_STATUS4_RX_DONE)) - sm5714_notify_rp_current_level(data); + pdic_data->is_noti_src_adv = true; #endif if (intr[1] & SM5714_REG_INT_STATUS2_VBUS_0V) { @@ -2703,9 +2746,6 @@ static int sm5714_usbpd_notify_attach(void *data) struct sm5714_usbpd_manager_data *manager = &pd_data->manager; #if defined(CONFIG_USB_HOST_NOTIFY) struct otg_notify *o_notify = get_otg_notify(); -#endif -#if defined(CONFIG_PDIC_NOTIFIER) - bool short_cable = false; #endif u8 reg_data; int ret = 0; @@ -2762,17 +2802,10 @@ static int sm5714_usbpd_notify_attach(void *data) return true; #endif sm5714_usbpd_policy_reset(pd_data, PLUG_EVENT); -#if defined(CONFIG_PDIC_NOTIFIER) - sm5714_get_short_state(pd_data, &short_cable); +#if IS_ENABLED(CONFIG_PDIC_NOTIFIER) #if defined(CONFIG_BATTERY_SAMSUNG) - /* muic, battery */ - if (short_cable) { - /* rp abnormal */ - sm5714_notify_rp_abnormal(pd_data); - } else { - /* rp current */ - sm5714_notify_rp_current_level(pd_data); - } + if (!pdic_data->is_noti_src_adv) + pdic_data->is_noti_src_adv = true; #endif if (!(pdic_data->rid == REG_RID_523K || pdic_data->rid == REG_RID_619K)) { @@ -2814,6 +2847,10 @@ static int sm5714_usbpd_notify_attach(void *data) pdic_data->is_mpsm_exit = 0; dev_info(dev, "exit mpsm completion\n"); } +#ifndef CONFIG_SEC_FACTORY + if (pdic_data->scr_sel == PLUG_CTRL_RP180) + sm5714_usbpd_set_rp_scr_sel(pd_data, PLUG_CTRL_RP80); +#endif manager->pn_flag = false; /* add to turn on external 5V */ #if defined(CONFIG_DUAL_ROLE_USB_INTF) @@ -2865,8 +2902,14 @@ static int sm5714_usbpd_notify_attach(void *data) sm5714_set_src(i2c); msleep(180); /* don't over 310~620ms(tTypeCSinkWaitCap) */ /* cc_AUDIO */ - } else if (((reg_data & SM5714_ATTACH_TYPE) == SM5714_ATTACH_AUDIO) || - ((reg_data & SM5714_ATTACH_TYPE) == SM5714_ATTACH_AUDIO_CHARGE)) { + } else if ((reg_data & SM5714_ATTACH_TYPE) == SM5714_ATTACH_AUDIO) { +#ifndef CONFIG_SEC_FACTORY + if (sm5714_usbpd_check_normal_audio_device(pdic_data) == 0) { + /* Set 'CC_UNATT_SRC' state */ + sm5714_usbpd_write_reg(i2c, SM5714_REG_CC_CNTL3, 0x81); + return -1; + } +#endif dev_info(dev, "ccstat : cc_AUDIO\n"); manager->acc_type = PDIC_DOCK_UNSUPPORTED_AUDIO; sm5714_usbpd_check_accessory(manager); @@ -2936,6 +2979,7 @@ static void sm5714_usbpd_notify_detach(void *data) pdic_data->is_sbu_abnormal_state = false; #endif pdic_data->is_jig_case_on = false; + pdic_data->is_noti_src_adv = false; pdic_data->reset_done = 0; pdic_data->pd_support = 0; sm5714_usbpd_policy_reset(pd_data, PLUG_DETACHED); @@ -2984,9 +3028,9 @@ static void sm5714_usbpd_notify_detach(void *data) PDIC_NOTIFY_DETACH/*attach*/, USB_STATUS_NOTIFY_DETACH/*drp*/, 0); #if defined(CONFIG_DUAL_ROLE_USB_INTF) - if (!pdic_data->try_state_change) + if (!pdic_data->try_state_change && !(pdic_data->scr_sel == PLUG_CTRL_RP180)) #elif defined(CONFIG_TYPEC) - if (!pdic_data->typec_try_state_change) + if (!pdic_data->typec_try_state_change && !(pdic_data->scr_sel == PLUG_CTRL_RP180)) #endif sm5714_rprd_mode_change(pdic_data, TYPE_C_ATTACH_DRP); #endif /* end of CONFIG_PDIC_NOTIFIER */ @@ -3038,6 +3082,9 @@ static irqreturn_t sm5714_pdic_irq_thread(int irq, void *data) struct sm5714_usbpd_data *pd_data = dev_get_drvdata(dev); int ret = 0; unsigned int rid_status = 0; +#if IS_ENABLED(CONFIG_BATTERY_SAMSUNG) + bool short_cable = false; +#endif #if defined(CONFIG_SEC_FACTORY) u8 rid; #endif /* CONFIG_SEC_FACTORY */ @@ -3121,7 +3168,18 @@ hard_reset: mutex_unlock(&pdic_data->lpm_mutex); out: -#if defined(CONFIG_VBUS_NOTIFIER) +#if IS_ENABLED(CONFIG_BATTERY_SAMSUNG) + if (pdic_data->is_noti_src_adv) { + pdic_data->is_noti_src_adv = false; + sm5714_get_short_state(pd_data, &short_cable); + if (short_cable) + sm5714_notify_rp_abnormal(pd_data); + else + sm5714_notify_rp_current_level(pd_data); + } +#endif + +#if IS_ENABLED(CONFIG_VBUS_NOTIFIER) schedule_delayed_work(&pdic_data->vbus_noti_work, 0); #endif /* CONFIG_VBUS_NOTIFIER */ @@ -3133,6 +3191,8 @@ out: static int sm5714_usbpd_reg_init(struct sm5714_phydrv_data *_data) { struct i2c_client *i2c = _data->i2c; + u8 reg_data; + pr_info("%s", __func__); if (!lpcharge) /* Release SNK Only */ sm5714_usbpd_write_reg(i2c, SM5714_REG_CC_CNTL1, 0x41); @@ -3153,6 +3213,10 @@ static int sm5714_usbpd_reg_init(struct sm5714_phydrv_data *_data) #else sm5714_usbpd_write_reg(i2c, SM5714_REG_CORR_CNTL4, 0x00); #endif + sm5714_usbpd_read_reg(i2c, SM5714_REG_PD_STATE3, ®_data); + if (reg_data & 0x06) /* Reset Wait Policy Engine */ + sm5714_usbpd_write_reg(i2c, SM5714_REG_PD_CNTL4, + SM5714_REG_CNTL_NOTIFY_RESET_DONE); return 0; } @@ -3463,9 +3527,11 @@ static int sm5714_usbpd_probe(struct i2c_client *i2c, pdic_data->detach_valid = true; pdic_data->is_otg_vboost = false; pdic_data->is_jig_case_on = false; + pdic_data->is_noti_src_adv = false; pdic_data->is_timer_expired = false; pdic_data->reset_done = 0; pdic_data->abnormal_dev_cnt = 0; + pdic_data->scr_sel = PLUG_CTRL_RP80; pdic_data->is_cc_abnormal_state = false; #if defined(CONFIG_SM5714_SUPPORT_SBU) pdic_data->is_sbu_abnormal_state = false; diff --git a/fs/dlog_hook.c b/fs/dlog_hook.c index 4e9a53f6918f..1580349749b9 100755 --- a/fs/dlog_hook.c +++ b/fs/dlog_hook.c @@ -34,6 +34,7 @@ DEFINE_DLOG(dlog_rmdir); #define EXT_SHIFT 7 #define MAX_EXT (1 << 7) #define MAX_DEPTH 2 +#define MEDIA_MIN_SIZE (512 * 1024) struct dlog_keyword { struct hlist_node hlist; @@ -53,6 +54,7 @@ enum { enum { DLOG_SUPP_PART_DATA = 0, DLOG_SUPP_PART_EFS, + DLOG_SUPP_PART_FUSE, DLOG_SUPP_PART_MAX }; @@ -66,7 +68,7 @@ enum { static struct dlog_keyword_hash_tbl ht[DLOG_HT_MAX]; static const char *support_part[] = { - "data", "efs", NULL, + "data", "efs", "emulated", NULL, }; static const char *extensions[] = { @@ -295,7 +297,8 @@ void dlog_hook(struct dentry *dentry, struct inode *inode, struct path *path) /* for data partition`s only multimedia file */ if (is_ext(dentry->d_name.name, '.', &ht[DLOG_HT_EXTENSION])) { - store_log(dentry, inode, path, DLOG_MM, part_id); + if (i_size_read(inode) >= MEDIA_MIN_SIZE) + store_log(dentry, inode, path, DLOG_MM, part_id); goto out; } diff --git a/fs/exec.c b/fs/exec.c index 61b7410b72da..f44bc33c758d 100755 --- a/fs/exec.c +++ b/fs/exec.c @@ -1933,6 +1933,10 @@ static int do_execveat_common(int fd, struct filename *filename, goto out_unmark; bprm->argc = count(argv, MAX_ARG_STRINGS); + if (bprm->argc == 0) + pr_warn_once("process '%s' launched '%s' with NULL argv: empty string added\n", + current->comm, bprm->filename); + if ((retval = bprm->argc) < 0) goto out; @@ -1957,6 +1961,20 @@ static int do_execveat_common(int fd, struct filename *filename, if (retval < 0) goto out; + /* + * When argv is empty, add an empty string ("") as argv[0] to + * ensure confused userspace programs that start processing + * from argv[1] won't end up walking envp. See also + * bprm_stack_limits(). + */ + if (bprm->argc == 0) { + const char *argv[] = { "", NULL }; + retval = copy_strings_kernel(1, argv, bprm); + if (retval < 0) + goto out; + bprm->argc = 1; + } + retval = exec_binprm(bprm); if (retval < 0) goto out; diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 8d6f7c96b86d..59b3eabfda81 100755 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -923,6 +923,7 @@ int ext4_ext_tree_init(handle_t *handle, struct inode *inode) eh->eh_entries = 0; eh->eh_magic = EXT4_EXT_MAGIC; eh->eh_max = cpu_to_le16(ext4_ext_space_root(inode, 0)); + eh->eh_generation = 0; ext4_mark_inode_dirty(handle, inode); return 0; } @@ -1179,6 +1180,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, neh->eh_max = cpu_to_le16(ext4_ext_space_block(inode, 0)); neh->eh_magic = EXT4_EXT_MAGIC; neh->eh_depth = 0; + neh->eh_generation = 0; /* move remainder of path[depth] to the new leaf */ if (unlikely(path[depth].p_hdr->eh_entries != @@ -1256,6 +1258,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, neh->eh_magic = EXT4_EXT_MAGIC; neh->eh_max = cpu_to_le16(ext4_ext_space_block_idx(inode, 0)); neh->eh_depth = cpu_to_le16(depth - i); + neh->eh_generation = 0; fidx = EXT_FIRST_INDEX(neh); fidx->ei_block = border; ext4_idx_store_pblock(fidx, oldblock); diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 101e6cfa62cb..607d3bfeac3a 100755 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -784,10 +784,6 @@ static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr) ret++; } } - - f2fs_bug_on(F2FS_I_SB(cc->inode), - !compr && ret != cc->cluster_size && - !is_inode_flag_set(cc->inode, FI_COMPRESS_RELEASED)); } fail: f2fs_put_dnode(&dn); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index cecc97ef033f..78b338b5654f 100755 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -37,12 +37,15 @@ #endif extern int ignore_fs_panic; +extern void (*ufs_debug_func)(void *); #define f2fs_bug_on(sbi, condition) __f2fs_bug_on(sbi, condition, true) #define f2fs_bug_on_endio(sbi, condition) __f2fs_bug_on(sbi, condition, false) #define __f2fs_bug_on(sbi, condition, set_extra_blk) \ do { \ if (unlikely(condition)) { \ + if (ufs_debug_func) \ + ufs_debug_func(NULL); \ if (is_sbi_flag_set(sbi, SBI_POR_DOING)) { \ set_sbi_flag(sbi, SBI_NEED_FSCK); \ sbi->sec_stat.fs_por_error++; \ @@ -2780,41 +2783,6 @@ static inline void f2fs_change_bit(unsigned int nr, char *addr) *addr ^= mask; } - -enum F2FS_SEC_FUA_MODE { - F2FS_SEC_FUA_NONE = 0, - F2FS_SEC_FUA_ROOT, - F2FS_SEC_FUA_DIR, - - NR_F2FS_SEC_FUA_MODE, -}; - -#define __f2fs_is_cold_node(page) \ - (le32_to_cpu(F2FS_NODE(page)->footer.flag) & (1 << COLD_BIT_SHIFT)) - -static inline void f2fs_cond_set_fua(struct f2fs_io_info *fio) -{ - if (!fio->sbi->s_sec_cond_fua_mode) - return; - - if (fio->type == META) - fio->op_flags |= REQ_PREFLUSH | REQ_FUA; - else if ((fio->page && IS_NOQUOTA(fio->page->mapping->host)) || - (fio->ino == f2fs_qf_ino(fio->sbi->sb, USRQUOTA) || - fio->ino == f2fs_qf_ino(fio->sbi->sb, GRPQUOTA) || - fio->ino == f2fs_qf_ino(fio->sbi->sb, PRJQUOTA))) - fio->op_flags |= REQ_FUA; - else if (fio->sbi->s_sec_cond_fua_mode == F2FS_SEC_FUA_ROOT && - fio->ino == F2FS_ROOT_INO(fio->sbi)) - fio->op_flags |= REQ_FUA; - else if (fio->sbi->s_sec_cond_fua_mode == F2FS_SEC_FUA_DIR && fio->page && - ((fio->type == NODE && !__f2fs_is_cold_node(fio->page)) || - (fio->type == DATA && S_ISDIR(fio->page->mapping->host->i_mode)))) - fio->op_flags |= REQ_FUA; - // Directory Inode or Indirect Node -> COLD_BIT X - // ref. set_cold_node() -} - /* * On-disk inode flags (f2fs_inode::i_flags) */ @@ -3367,6 +3335,56 @@ static inline void f2fs_clear_page_private(struct page *page) f2fs_put_page(page, 0); } +/* @fs.sec -- 23c33f110b35408f8559496c6095c768 -- */ +enum F2FS_SEC_FUA_MODE { + F2FS_SEC_FUA_NONE = 0, + F2FS_SEC_FUA_ROOT, + F2FS_SEC_FUA_DIR, + + NR_F2FS_SEC_FUA_MODE, +}; + +#define __f2fs_is_cold_node(page) \ + (le32_to_cpu(F2FS_NODE(page)->footer.flag) & (1 << COLD_BIT_SHIFT)) + +static inline void f2fs_cond_set_fua(struct f2fs_io_info *fio) +{ + struct f2fs_sb_info *sbi = fio->sbi; + struct page *page = fio->page; + struct inode *inode = page->mapping->host; + + if (!sbi->s_sec_cond_fua_mode) + return; + + if (fio->type == META) + fio->op_flags |= REQ_PREFLUSH | REQ_FUA; + else if (IS_NOQUOTA(inode) || + (fio->ino == f2fs_qf_ino(sbi->sb, USRQUOTA) || + fio->ino == f2fs_qf_ino(sbi->sb, GRPQUOTA) || + fio->ino == f2fs_qf_ino(sbi->sb, PRJQUOTA))) + fio->op_flags |= REQ_FUA; + else if (sbi->s_sec_cond_fua_mode == F2FS_SEC_FUA_ROOT && + fio->ino == F2FS_ROOT_INO(sbi)) + fio->op_flags |= REQ_FUA; + else if (sbi->s_sec_cond_fua_mode == F2FS_SEC_FUA_DIR && + ((fio->type == NODE && !__f2fs_is_cold_node(page)) || + (fio->type == DATA && S_ISDIR(inode->i_mode)))) + fio->op_flags |= REQ_FUA; + // Directory Inode or Indirect Node -> COLD_BIT X + // ref. set_cold_node() + + /* + * P221011-01695 + * flush_group: Process group in which file's is very important. + * e.g., system_server, keystore, etc. + */ + if (fio->type == DATA && !(fio->op_flags & REQ_FUA) && + in_group_p(F2FS_OPTION(sbi).flush_group)) { + if (f2fs_is_atomic_file(inode) && f2fs_is_commit_atomic_write(inode)) + fio->op_flags |= REQ_FUA; + } +} + /* * file.c */ diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index d14a9e318dc4..1a3ae82f1950 100755 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3514,7 +3514,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) goto out; } - if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) { + if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) || + IS_IMMUTABLE(inode)) { ret = -EINVAL; goto out; } diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 1f9774708653..10f46e66dd36 100755 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -780,8 +780,6 @@ static int move_data_block(struct inode *inode, block_t bidx, int err = 0; bool lfs_mode = f2fs_lfs_mode(fio.sbi); - f2fs_cond_set_fua(&fio); - /* do not read out */ page = f2fs_grab_cache_page(inode->i_mapping, bidx, false); if (!page) @@ -900,6 +898,7 @@ static int move_data_block(struct inode *inode, block_t bidx, fio.op = REQ_OP_WRITE; fio.op_flags = REQ_SYNC; fio.new_blkaddr = newaddr; + f2fs_cond_set_fua(&fio); f2fs_submit_page_write(&fio); if (fio.retry) { err = -EAGAIN; diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 0cab7ef2d2c1..61d4be26f3cc 100755 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -539,6 +539,10 @@ struct mem_size_stats { unsigned long swap; #ifdef CONFIG_ZRAM_LRU_WRITEBACK unsigned long writeback; + unsigned long writeback_huge; + unsigned long same; + unsigned long huge; + unsigned long swap_shared; #endif unsigned long shared_hugetlb; unsigned long private_hugetlb; @@ -634,12 +638,11 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr, if (!non_swap_entry(swpent)) { int mapcount; - - mss->swap += PAGE_SIZE; #ifdef CONFIG_ZRAM_LRU_WRITEBACK - if (is_writeback_entry(swpent)) - mss->writeback += PAGE_SIZE; + int type; #endif + + mss->swap += PAGE_SIZE; mapcount = swp_swapcount(swpent); if (mapcount >= 2) { u64 pss_delta = (u64)PAGE_SIZE << PSS_SHIFT; @@ -649,6 +652,21 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr, } else { mss->swap_pss += (u64)PAGE_SIZE << PSS_SHIFT; } +#ifdef CONFIG_ZRAM_LRU_WRITEBACK + type = zram_get_entry_type(swp_offset(swpent)); + if (type == ZRAM_WB_TYPE || type == ZRAM_WB_HUGE_TYPE) + mss->writeback += PAGE_SIZE; + if (type == ZRAM_WB_HUGE_TYPE) + mss->writeback_huge += PAGE_SIZE; + if (mapcount >= 2) { + mss->swap_shared += PAGE_SIZE; + } else { + if (type == ZRAM_SAME_TYPE) + mss->same += PAGE_SIZE; + if (type == ZRAM_HUGE_TYPE) + mss->huge += PAGE_SIZE; + } +#endif } else if (is_migration_entry(swpent)) page = migration_entry_to_page(swpent); else if (is_device_private_entry(swpent)) @@ -950,6 +968,10 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) "SwapPss: %8lu kB\n" #ifdef CONFIG_ZRAM_LRU_WRITEBACK "Writeback: %8lu kB\n" + "WritebackHuge: %8lu kB\n" + "Same: %8lu kB\n" + "Huge: %8lu kB\n" + "SwapShared: %8lu kB\n" #endif "Locked: %8lu kB\n", mss->resident >> 10, @@ -969,6 +991,10 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) (unsigned long)(mss->swap_pss >> (10 + PSS_SHIFT)), #ifdef CONFIG_ZRAM_LRU_WRITEBACK mss->writeback >> 10, + mss->writeback_huge >> 10, + mss->huge >> 10, + mss->same >> 10, + mss->swap_shared >> 10, #endif (unsigned long)(mss->pss_locked >> (10 + PSS_SHIFT))); @@ -1823,14 +1849,16 @@ cont: } #ifdef CONFIG_ZRAM_LRU_WRITEBACK +static DEFINE_SPINLOCK(writeback_lock); +static bool writeback_ongoing; + static int writeback_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { struct mm_struct *mm = walk->mm; - struct zwbs **zwbs = walk->private; + struct list_head *list = walk->private; pte_t *pte, ptent; spinlock_t *ptl; - LIST_HEAD(swp_entry_list); if (pmd_trans_unstable(pmd)) return 0; @@ -1846,19 +1874,47 @@ static int writeback_pte_range(pmd_t *pmd, unsigned long addr, ptent = *pte; if (is_swap_pte(ptent)) { swp_entry_t entry = pte_to_swp_entry(ptent); + if (unlikely(non_swap_entry(entry))) continue; if (swp_swapcount(entry) > 1) continue; - swap_add_to_list(&swp_entry_list, entry); + zram_add_to_writeback_list(list, swp_offset(entry)); } } pte_unmap_unlock(pte - 1, ptl); - swap_writeback_list(zwbs, &swp_entry_list); cond_resched(); return 0; } + +static int prefetch_pte_range(pmd_t *pmd, unsigned long start, + unsigned long end, struct mm_walk *walk) +{ + struct mm_struct *mm = walk->mm; + pte_t *orig_pte, pte; + spinlock_t *ptl; + swp_entry_t entry; + unsigned long index; + + if (pmd_trans_unstable(pmd)) + return 0; + + for (index = start; index != end; index += PAGE_SIZE) { + orig_pte = pte_offset_map_lock(mm, pmd, start, &ptl); + pte = *(orig_pte + ((index - start) / PAGE_SIZE)); + pte_unmap_unlock(orig_pte, ptl); + + if (pte_present(pte) || pte_none(pte)) + continue; + entry = pte_to_swp_entry(pte); + if (unlikely(non_swap_entry(entry))) + continue; + + zram_prefetch_entry(swp_offset(entry)); + } + return 0; +} #endif enum reclaim_type { @@ -1868,6 +1924,7 @@ enum reclaim_type { RECLAIM_RANGE, #ifdef CONFIG_ZRAM_LRU_WRITEBACK RECLAIM_WRITEBACK, + PREFETCH_PROCESS, #endif }; @@ -1930,7 +1987,7 @@ static ssize_t reclaim_write(struct file *file, const char __user *buf, unsigned long end = 0; struct reclaim_param rp; #ifdef CONFIG_ZRAM_LRU_WRITEBACK - struct zwbs *zwbs[NR_ZWBS]; + LIST_HEAD(list); #endif int err = 0; @@ -1953,6 +2010,8 @@ static ssize_t reclaim_write(struct file *file, const char __user *buf, #ifdef CONFIG_ZRAM_LRU_WRITEBACK else if (!strcmp(type_buf, "writeback")) type = RECLAIM_WRITEBACK; + else if (!strcmp(type_buf, "prefetch")) + type = PREFETCH_PROCESS; #endif else goto out_err; @@ -1988,18 +2047,23 @@ static ssize_t reclaim_write(struct file *file, const char __user *buf, goto out_err; } - task = get_proc_task(file->f_path.dentry->d_inode); - if (!task) - return -ESRCH; #ifdef CONFIG_ZRAM_LRU_WRITEBACK + /* we only allow single MADV_WRITEBACK at a time */ if (type == RECLAIM_WRITEBACK) { - if (alloc_zwbs(zwbs)) { - pr_info("%s alloc_zwbs failed", __func__); - return -ENOMEM; + spin_lock(&writeback_lock); + if (writeback_ongoing) { + spin_unlock(&writeback_lock); + return -EBUSY; } + writeback_ongoing = true; + spin_unlock(&writeback_lock); } #endif + task = get_proc_task(file->f_path.dentry->d_inode); + if (!task) + return -ESRCH; + mm = get_task_mm(task); if (!mm) goto out; @@ -2011,12 +2075,6 @@ static ssize_t reclaim_write(struct file *file, const char __user *buf, rp.nr_reclaimed = 0; reclaim_walk.private = &rp; -#ifdef CONFIG_ZRAM_LRU_WRITEBACK - if (type == RECLAIM_WRITEBACK) { - reclaim_walk.pmd_entry = writeback_pte_range; - reclaim_walk.private = (void *)zwbs; - } -#endif down_read(&mm->mmap_sem); if (type == RECLAIM_RANGE) { @@ -2046,10 +2104,16 @@ static ssize_t reclaim_write(struct file *file, const char __user *buf, continue; #ifdef CONFIG_ZRAM_LRU_WRITEBACK - if (type == RECLAIM_WRITEBACK && vma->vm_file) + if ((type == RECLAIM_WRITEBACK || + type == PREFETCH_PROCESS) && vma->vm_file) continue; + if (type == RECLAIM_WRITEBACK) { + reclaim_walk.private = (void *)&list; + reclaim_walk.pmd_entry = writeback_pte_range; + } else if (type == PREFETCH_PROCESS) { + reclaim_walk.pmd_entry = prefetch_pte_range; + } #endif - rp.vma = vma; err = walk_page_range(vma->vm_start, vma->vm_end, &reclaim_walk); @@ -2067,8 +2131,12 @@ out: put_task_struct(task); #ifdef CONFIG_ZRAM_LRU_WRITEBACK if (type == RECLAIM_WRITEBACK) { - swap_writeback_list(zwbs, NULL); - free_zwbs(zwbs); + zram_writeback_list(&list); + flush_writeback_buffer(&list); + + spin_lock(&writeback_lock); + writeback_ongoing = false; + spin_unlock(&writeback_lock); } #endif return count; diff --git a/fs/sdfat/cache.c b/fs/sdfat/cache.c index f0170c560207..7f3dd5a41099 100755 --- a/fs/sdfat/cache.c +++ b/fs/sdfat/cache.c @@ -201,7 +201,18 @@ u8 *fcache_getblk(struct super_block *sb, u64 sec) return NULL; } move_to_mru(bp, &fsi->fcache.lru_list); - return bp->bh->b_data; + + if (likely(bp->bh->b_data)) + return bp->bh->b_data; + + sdfat_msg(sb, KERN_ERR, + "%s: no b_data (flag:0x%02x, sect:%llu), %s", + __func__, bp->flag, sec, bp->flag ? "EIO" : ",retry"); + + if (bp->flag) + return NULL; + + __fcache_ent_discard(sb, bp); } bp = __fcache_get(sb); @@ -227,7 +238,14 @@ u8 *fcache_getblk(struct super_block *sb, u64 sec) return NULL; } - return bp->bh->b_data; + if (likely(bp->bh->b_data)) + return bp->bh->b_data; + + sdfat_msg(sb, KERN_ERR, + "%s: no b_data after read (flag:0x%02x, sect:%llu)", + __func__, bp->flag, sec); + + return NULL; } static inline int __mark_delayed_dirty(struct super_block *sb, cache_ent_t *bp) @@ -567,7 +585,17 @@ u8 *dcache_getblk(struct super_block *sb, u64 sec) if (!(bp->flag & KEEPBIT)) // already in keep list move_to_mru(bp, &fsi->dcache.lru_list); - return bp->bh->b_data; + if (likely(bp->bh->b_data)) + return bp->bh->b_data; + + sdfat_msg(sb, KERN_ERR, + "%s: no b_data (flag:0x%02x, sect:%llu), %s", + __func__, bp->flag, sec, bp->flag ? "EIO" : ",retry"); + + if (bp->flag) + return NULL; + + __dcache_ent_discard(sb, bp); } bp = __dcache_get(sb); @@ -584,8 +612,14 @@ u8 *dcache_getblk(struct super_block *sb, u64 sec) return NULL; } - return bp->bh->b_data; + if (likely(bp->bh->b_data)) + return bp->bh->b_data; + sdfat_msg(sb, KERN_ERR, + "%s: no b_data after read (flag:0x%02x, sect:%llu)", + __func__, bp->flag, sec); + + return NULL; } s32 dcache_modify(struct super_block *sb, u64 sec) diff --git a/fs/sdfat/core.c b/fs/sdfat/core.c index 51d2ea23b47e..1a87070548af 100755 --- a/fs/sdfat/core.c +++ b/fs/sdfat/core.c @@ -54,6 +54,19 @@ static inline u64 inode_peek_iversion(struct inode *inode) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) +static u64 bdev_nr_sectors(struct block_device *bdev) +{ + struct hd_struct *part = bdev->bd_part; + + if (!part) + return 0; + + return (u64)(part->nr_sects); +} +#endif + + /*----------------------------------------------------------------------*/ /* Constant & Macro Definitions */ /*----------------------------------------------------------------------*/ @@ -388,6 +401,9 @@ static s32 __load_upcase_table(struct super_block *sb, u64 sector, u64 num_secto * memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *)); */ + /* trigger read upcase_table ahead */ + bdev_readahead(sb, sector, num_sectors); + fsi->vol_utbl = upcase_table; num_sectors += sector; @@ -1725,7 +1741,6 @@ s32 fscore_mount(struct super_block *sb) pbr_t *p_pbr; struct buffer_head *tmp_bh = NULL; struct gendisk *disk = sb->s_bdev->bd_disk; - struct hd_struct *part = sb->s_bdev->bd_part; struct sdfat_mount_options *opts = &(SDFAT_SB(sb)->options); FS_INFO_T *fsi = &(SDFAT_SB(sb)->fsi); @@ -1822,9 +1837,8 @@ free_bh: "detected volume size : %llu KB (disk : %llu KB, " "part : %llu KB)", (fsi->num_sectors * (sb->s_blocksize >> SECTOR_SIZE_BITS)) >> 1, - disk ? (u64)((disk->part0.nr_sects) >> 1) : 0, - part ? (u64)((part->nr_sects) >> 1) : 0); - + disk ? (u64)(get_capacity(disk) >> 1) : 0, + (u64)bdev_nr_sectors(sb->s_bdev) >> 1); ret = load_upcase_table(sb); if (ret) { sdfat_log_msg(sb, KERN_ERR, "failed to load upcase table"); diff --git a/fs/sdfat/core_exfat.c b/fs/sdfat/core_exfat.c index da401bbbed22..b5e65646eb35 100755 --- a/fs/sdfat/core_exfat.c +++ b/fs/sdfat/core_exfat.c @@ -1086,6 +1086,9 @@ s32 load_alloc_bmp(struct super_block *sb) sector = CLUS_TO_SECT(fsi, fsi->map_clu); + /* trigger read amap ahead */ + bdev_readahead(sb, sector, fsi->map_sectors); + for (j = 0; j < fsi->map_sectors; j++) { fsi->vol_amap[j] = NULL; ret = read_sect(sb, sector+j, &(fsi->vol_amap[j]), 1); diff --git a/fs/sdfat/core_fat.c b/fs/sdfat/core_fat.c index 23c134fc5541..ca2839b04b87 100755 --- a/fs/sdfat/core_fat.c +++ b/fs/sdfat/core_fat.c @@ -106,7 +106,7 @@ static u32 __calc_default_au_size(struct super_block *sb) * ex2) 16GB -> 8MB * ex3) >= 32GB -> 16MB */ - total_sect = disk->part0.nr_sects; + total_sect = get_capacity(disk); est_au_size = total_sect >> 2; /* au_size assumed that bytes per sector is 512 */ @@ -684,33 +684,36 @@ rewind: EXT_DENTRY_T *ext_ep = (EXT_DENTRY_T *)ep; u32 cur_ord = (u32)ext_ep->order; u32 cur_chksum = (s32)ext_ep->checksum; + u32 new_lfn = (cur_ord & MSDOS_LAST_LFN); s32 len = 13; u16 unichar; + cur_ord &= ~(MSDOS_LAST_LFN); num_empty = 0; candi_empty.eidx = -1; + /* check invalid lfn order */ + if (!cur_ord || (cur_ord > MAX_LFN_ORDER)) + goto reset_dentry_set; + /* check whether new lfn or not */ - if (cur_ord & MSDOS_LAST_LFN) { - cur_ord &= ~(MSDOS_LAST_LFN); + if (new_lfn) { chksum = cur_chksum; - len = (13 * (cur_ord-1)); + len = (13 * (cur_ord - 1)); uniname = (p_uniname->name + len); lfn_ord = cur_ord + 1; lfn_len = 0; /* check minimum name length */ - if (cur_ord && - (len > p_uniname->name_len)) { + if (len > p_uniname->name_len) { /* MISMATCHED NAME LENGTH */ lfn_len = -1; } len = 0; } - /* invalid lfn order */ - if (!cur_ord || (cur_ord > MAX_LFN_ORDER) || - ((cur_ord + 1) != lfn_ord)) + /* check if lfn is a consecutive number */ + if ((cur_ord + 1) != lfn_ord) goto reset_dentry_set; /* check checksum of directory entry set */ @@ -1354,6 +1357,23 @@ s32 mount_fat16(struct super_block *sb, pbr_t *p_pbr) return 0; } /* end of mount_fat16 */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) +static u8 bdev_get_partno(struct block_device *bdev) +{ + return bdev->bd_partno; +} +#else +static struct block_device *bdev_whole(struct block_device *bdev) +{ + return bdev->bd_contains; +} + +static u8 bdev_get_partno(struct block_device *bdev) +{ + return bdev->bd_part->partno; +} +#endif + static sector_t __calc_hidden_sect(struct super_block *sb) { struct block_device *bdev = sb->s_bdev; @@ -1362,10 +1382,10 @@ static sector_t __calc_hidden_sect(struct super_block *sb) if (!bdev) goto out; - hidden = bdev->bd_part->start_sect; + hidden = get_start_sect(bdev); /* a disk device, not a partition */ if (!hidden) { - if (bdev != bdev->bd_contains) + if (bdev != bdev_whole(bdev)) sdfat_log_msg(sb, KERN_WARNING, "hidden(0), but disk has a partition table"); goto out; @@ -1378,7 +1398,7 @@ static sector_t __calc_hidden_sect(struct super_block *sb) out: sdfat_log_msg(sb, KERN_INFO, "start_sect of part(%d) : %lld", - bdev ? bdev->bd_part->partno : -1, (s64)hidden); + bdev ? bdev_get_partno(bdev) : -1, (s64)hidden); return hidden; } diff --git a/fs/sdfat/misc.c b/fs/sdfat/misc.c index ce08c594f0cb..262e28ee023d 100755 --- a/fs/sdfat/misc.c +++ b/fs/sdfat/misc.c @@ -39,9 +39,11 @@ #include #include #include +#include #include "sdfat.h" #include "version.h" + #ifdef CONFIG_SDFAT_SUPPORT_STLOG #ifdef CONFIG_PROC_FSLOG #include @@ -52,6 +54,14 @@ #define ST_LOG(fmt, ...) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +#include +#ifndef _TIME_T +#define _TIME_T +typedef ktime_t time_t; +#endif +#endif + /************************************************************************* * FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY *************************************************************************/ @@ -203,14 +213,28 @@ EXPORT_SYMBOL(sdfat_log_version); #define SECS_PER_HOUR (60 * SECS_PER_MIN) #define SECS_PER_DAY (24 * SECS_PER_HOUR) +/* do not use time_t directly to prevent compile errors on 32bit kernel */ +#define time_do_div(ori, base) \ +({ \ + u64 __ori = ori; \ + do_div(__ori, base); \ + (time_t)__ori; \ +}) + +#define time_do_mod(ori, base) \ +({ \ + u64 __ori = ori; \ + (time_t)do_div(__ori, base); \ +}) + #define MAKE_LEAP_YEAR(leap_year, year) \ - do { \ - /* 2100 isn't leap year */ \ - if (unlikely(year > NO_LEAP_YEAR_2100)) \ - leap_year = ((year + 3) / 4) - 1; \ - else \ - leap_year = ((year + 3) / 4); \ - } while (0) +({ \ + /* 2100 isn't leap year */ \ + if (unlikely(year > NO_LEAP_YEAR_2100)) \ + leap_year = time_do_div((year + 3), 4) - 1; \ + else \ + leap_year = time_do_div((year + 3), 4); \ +}) /* Linear day numbers of the respective 1sts in non-leap years. */ static time_t accum_days_in_year[] = { @@ -298,8 +322,8 @@ void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, sdfat_timespec_t *ts, } #endif - day = second / SECS_PER_DAY - DAYS_DELTA_DECADE; - year = day / 365; + day = time_do_div(second, SECS_PER_DAY) - DAYS_DELTA_DECADE; + year = time_do_div(day, 365); MAKE_LEAP_YEAR(ld, year); if (year * 365 + ld > day) @@ -320,12 +344,12 @@ void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, sdfat_timespec_t *ts, } day -= accum_days_in_year[month]; - tp->Second = second % SECS_PER_MIN; - tp->Minute = (second / SECS_PER_MIN) % 60; - tp->Hour = (second / SECS_PER_HOUR) % 24; - tp->Day = day + 1; - tp->Month = month; - tp->Year = year; + tp->Second = (u16)time_do_mod(second, SECS_PER_MIN); + tp->Minute = (u16)time_do_mod(time_do_div(second, SECS_PER_MIN), 60); + tp->Hour = (u16)time_do_mod(time_do_div(second, SECS_PER_HOUR), 24); + tp->Day = (u16)(day + 1); + tp->Month = (u16)month; + tp->Year = (u16)year; } TIMESTAMP_T *tm_now(struct inode *inode, TIMESTAMP_T *tp) diff --git a/fs/sdfat/mpage.c b/fs/sdfat/mpage.c index 4f5037768fa5..10a802d7d325 100755 --- a/fs/sdfat/mpage.c +++ b/fs/sdfat/mpage.c @@ -123,7 +123,12 @@ static inline void __sdfat_submit_bio_write2(int flags, struct bio *bio) } #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static inline int bio_get_nr_vecs(struct block_device *bdev) +{ + return BIO_MAX_VECS; +} +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) static inline int bio_get_nr_vecs(struct block_device *bdev) { return BIO_MAX_PAGES; diff --git a/fs/sdfat/sdfat.c b/fs/sdfat/sdfat.c index 464402aab7b5..337066fb4c61 100755 --- a/fs/sdfat/sdfat.c +++ b/fs/sdfat/sdfat.c @@ -59,6 +59,10 @@ #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) #include #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +#include +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) #error SDFAT only supports linux kernel version 3.0 or higher @@ -111,11 +115,13 @@ static void sdfat_free_namebuf(DENTRY_NAMEBUF_T *nb); /************************************************************************* * INNER FUNCTIONS FOR FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY *************************************************************************/ -static int __sdfat_getattr(struct inode *inode, struct kstat *stat); static void __sdfat_writepage_end_io(struct bio *bio, int err); static inline void __lock_super(struct super_block *sb); static inline void __unlock_super(struct super_block *sb); static int __sdfat_create(struct inode *dir, struct dentry *dentry); +static int __sdfat_symlink(struct inode *dir, struct dentry *dentry, + const char *target); +static int __sdfat_setattr(struct dentry *dentry, struct iattr *attr); static int __sdfat_revalidate(struct dentry *dentry); static int __sdfat_revalidate_ci(struct dentry *dentry, unsigned int flags); static int __sdfat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync); @@ -140,7 +146,32 @@ static int __sdfat_cmpi(const struct dentry *dentry, unsigned int len, /************************************************************************* * FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY *************************************************************************/ -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static void sdfat_setattr_copy(struct inode *inode, struct iattr *attr) +{ + setattr_copy(&init_user_ns, inode, attr); +} + +static u32 sdfat_make_inode_generation(void) +{ + return prandom_u32(); +} +#else +static void sdfat_setattr_copy(struct inode *inode, struct iattr *attr) +{ + setattr_copy(inode, attr); +} + +static u32 sdfat_make_inode_generation(void) +{ + return (u32)get_seconds(); +} +#endif + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) + /* EMPTY */ +#else static inline void inode_set_iversion(struct inode *inode, u64 val) { inode->i_version = val; @@ -162,24 +193,6 @@ static inline void bio_set_dev(struct bio *bio, struct block_device *bdev) #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) -static int sdfat_getattr(const struct path *path, struct kstat *stat, - u32 request_mask, unsigned int query_flags) -{ - struct inode *inode = d_backing_inode(path->dentry); - - return __sdfat_getattr(inode, stat); -} -#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) */ -static int sdfat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) -{ - struct inode *inode = dentry->d_inode; - - return __sdfat_getattr(inode, stat); -} -#endif - - #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) static inline void __sdfat_clean_bdev_aliases(struct block_device *bdev, sector_t block) { @@ -201,36 +214,6 @@ static inline int wbc_to_write_flags(struct writeback_control *wbc) #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) -static int sdfat_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir, struct dentry *new_dentry, - unsigned int flags) -{ - /* - * The VFS already checks for existence, so for local filesystems - * the RENAME_NOREPLACE implementation is equivalent to plain rename. - * Don't support any other flags - */ - if (flags & ~RENAME_NOREPLACE) - return -EINVAL; - return __sdfat_rename(old_dir, old_dentry, new_dir, new_dentry); -} -#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) */ -static int sdfat_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir, struct dentry *new_dentry) -{ - return __sdfat_rename(old_dir, old_dentry, new_dir, new_dentry); -} - -static int setattr_prepare(struct dentry *dentry, struct iattr *attr) -{ - struct inode *inode = dentry->d_inode; - - return inode_change_ok(inode, attr); -} -#endif - - #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) static inline void __sdfat_submit_bio_write(struct bio *bio, struct writeback_control *wbc) @@ -256,7 +239,7 @@ static inline void __sdfat_submit_bio_write(struct bio *bio, { int write_flags = wbc_to_write_flags(wbc); - submit_bio(write_flags, bio); + submit_bio(WRITE | write_flags, bio); } static inline unsigned int __sdfat_full_name_hash(const struct dentry *unused, const char *name, unsigned int len) @@ -858,11 +841,6 @@ static sector_t sdfat_aop_bmap(struct address_space *mapping, sector_t block) return blocknr; } -static int sdfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) -{ - return __sdfat_mkdir(dir, dentry); -} - static int sdfat_show_options(struct seq_file *m, struct dentry *root) { return __sdfat_show_options(m, root->d_sb); @@ -895,11 +873,6 @@ static sector_t sdfat_aop_bmap(struct address_space *mapping, sector_t block) return blocknr; } -static int sdfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) -{ - return __sdfat_mkdir(dir, dentry); -} - static int sdfat_show_options(struct seq_file *m, struct vfsmount *mnt) { return __sdfat_show_options(m, mnt->mnt_sb); @@ -927,6 +900,115 @@ static int sdfat_file_fsync(struct file *filp, int datasync) /************************************************************************* * MORE FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY *************************************************************************/ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static int sdfat_getattr(struct user_namespace *mnt_uerns, + const struct path *path, struct kstat *stat, + unsigned int request_mask, unsigned int query_flags) +{ + struct inode *inode = d_backing_inode(path->dentry); + + generic_fillattr(&init_user_ns, inode, stat); + stat->blksize = SDFAT_SB(inode->i_sb)->fsi.cluster_size; + return 0; +} +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +static int sdfat_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags) +{ + struct inode *inode = d_backing_inode(path->dentry); + + generic_fillattr(inode, stat); + stat->blksize = SDFAT_SB(inode->i_sb)->fsi.cluster_size; + + return 0; +} +#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) */ +static int sdfat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) +{ + struct inode *inode = dentry->d_inode; + + generic_fillattr(inode, stat); + stat->blksize = SDFAT_SB(inode->i_sb)->fsi.cluster_size; + return 0; +} +#endif + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static int sdfat_setattr_prepare(struct dentry *dentry, struct iattr *attr) +{ + return setattr_prepare(&init_user_ns, dentry, attr); +} + +static int sdfat_rename(struct user_namespace *mnt_userns, + struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + unsigned int flags) +{ + /* + * The VFS already checks for existence, so for local filesystems + * the RENAME_NOREPLACE implementation is equivalent to plain rename. + * Don't support any other flags + */ + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; + return __sdfat_rename(old_dir, old_dentry, new_dir, new_dentry); +} +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) +static int sdfat_setattr_prepare(struct dentry *dentry, struct iattr *attr) +{ + return setattr_prepare(dentry, attr); +} + +static int sdfat_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + unsigned int flags) +{ + /* + * The VFS already checks for existence, so for local filesystems + * the RENAME_NOREPLACE implementation is equivalent to plain rename. + * Don't support any other flags + */ + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; + return __sdfat_rename(old_dir, old_dentry, new_dir, new_dentry); +} +#else +static int sdfat_setattr_prepare(struct dentry *dentry, struct iattr *attr) +{ + struct inode *inode = dentry->d_inode; + + return inode_change_ok(inode, attr); +} + +static int sdfat_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry) +{ + return __sdfat_rename(old_dir, old_dentry, new_dir, new_dentry); +} +#endif + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static int sdfat_mkdir(struct user_namespace *mnt_userns, struct inode *dir, + struct dentry *dentry, umode_t mode) +{ + return __sdfat_mkdir(dir, dentry); +} +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) +static int sdfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) +{ + return __sdfat_mkdir(dir, dentry); +} +#else +static int sdfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) +{ + return __sdfat_mkdir(dir, dentry); +} + +#endif + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) static void sdfat_writepage_end_io(struct bio *bio) { @@ -1118,8 +1200,40 @@ static void *sdfat_follow_link(struct dentry *dentry, struct nameidata *nd) } #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static int sdfat_symlink(struct user_namespace *mnt_userns, + struct inode *dir, struct dentry *dentry, + const char *target) +{ + return __sdfat_symlink(dir, dentry, target); +} -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) + +static int sdfat_setattr(struct user_namespace *mnt_userns, + struct dentry *dentry, struct iattr *attr) +{ + return __sdfat_setattr(dentry, attr); +} +#else +static int sdfat_symlink(struct inode *dir, struct dentry *dentry, + const char *target) +{ + return __sdfat_symlink(dir, dentry, target); +} + +static int sdfat_setattr(struct dentry *dentry, struct iattr *attr) +{ + return __sdfat_setattr(dentry, attr); +} +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) +static int sdfat_create(struct user_namespace *mnt_userns, struct inode *dir, + struct dentry *dentry, umode_t mode, bool excl) +{ + return __sdfat_create(dir, dentry); +} +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) static int sdfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) { @@ -2300,17 +2414,6 @@ static long sdfat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned lo return sdfat_dbg_ioctl(inode, filp, cmd, arg); } -static int __sdfat_getattr(struct inode *inode, struct kstat *stat) -{ - TMSG("%s entered\n", __func__); - - generic_fillattr(inode, stat); - stat->blksize = SDFAT_SB(inode->i_sb)->fsi.cluster_size; - - TMSG("%s exited\n", __func__); - return 0; -} - static void __sdfat_writepage_end_io(struct bio *bio, int err) { struct page *page = bio->bi_io_vec->bv_page; @@ -2600,7 +2703,8 @@ out: return err; } -static int sdfat_symlink(struct inode *dir, struct dentry *dentry, const char *target) +static int __sdfat_symlink(struct inode *dir, struct dentry *dentry, + const char *target) { struct super_block *sb = dir->i_sb; struct inode *inode; @@ -2929,7 +3033,7 @@ static int sdfat_block_truncate_page(struct inode *inode, loff_t from) return block_truncate_page(inode->i_mapping, from, sdfat_get_block); } -static int sdfat_setattr(struct dentry *dentry, struct iattr *attr) +static int __sdfat_setattr(struct dentry *dentry, struct iattr *attr) { struct sdfat_sb_info *sbi = SDFAT_SB(dentry->d_sb); @@ -2955,7 +3059,7 @@ static int sdfat_setattr(struct dentry *dentry, struct iattr *attr) attr->ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET); } - error = setattr_prepare(dentry, attr); + error = sdfat_setattr_prepare(dentry, attr); attr->ia_valid = ia_valid; if (error) goto out; @@ -2994,7 +3098,7 @@ static int sdfat_setattr(struct dentry *dentry, struct iattr *attr) inode, (u64)old_size, (u64)attr->ia_size); __sdfat_do_truncate(inode, old_size, attr->ia_size); } - setattr_copy(inode, attr); + sdfat_setattr_copy(inode, attr); mark_inode_dirty(inode); out: TMSG("%s exited with err(%d)\n", __func__, error); @@ -3078,6 +3182,9 @@ static const struct file_operations sdfat_file_operations = { .unlocked_ioctl = sdfat_generic_ioctl, .fsync = sdfat_file_fsync, .splice_read = generic_file_splice_read, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) + .splice_write = iter_file_splice_write, +#endif }; static const struct address_space_operations sdfat_da_aops; @@ -3528,6 +3635,12 @@ static int sdfat_readpage(struct file *file, struct page *page) return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +static void sdfat_readahead(struct readahead_control *rac) +{ + mpage_readahead(rac, sdfat_get_block); +} +#else static int sdfat_readpages(struct file *file, struct address_space *mapping, struct list_head *pages, unsigned int nr_pages) { @@ -3536,6 +3649,7 @@ static int sdfat_readpages(struct file *file, struct address_space *mapping, ret = mpage_readpages(mapping, pages, nr_pages, sdfat_get_block); return ret; } +#endif static inline void sdfat_submit_fullpage_bio(struct block_device *bdev, sector_t sector, unsigned int length, @@ -3881,7 +3995,11 @@ static inline ssize_t __sdfat_direct_IO(int rw, struct kiocb *iocb, static const struct address_space_operations sdfat_aops = { .readpage = sdfat_readpage, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + .readahead = sdfat_readahead, +#else .readpages = sdfat_readpages, +#endif .writepage = sdfat_writepage, .writepages = sdfat_writepages, .write_begin = sdfat_write_begin, @@ -3892,7 +4010,11 @@ static const struct address_space_operations sdfat_aops = { static const struct address_space_operations sdfat_da_aops = { .readpage = sdfat_readpage, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) + .readahead = sdfat_readahead, +#else .readpages = sdfat_readpages, +#endif .writepage = sdfat_writepage, .writepages = sdfat_da_writepages, .write_begin = sdfat_da_write_begin, @@ -3931,7 +4053,6 @@ static void sdfat_detach(struct inode *inode) spin_unlock(&sbi->inode_hash_lock); } - /* doesn't deal with root inode */ static int sdfat_fill_inode(struct inode *inode, const FILE_ID_T *fid) { @@ -3947,7 +4068,7 @@ static int sdfat_fill_inode(struct inode *inode, const FILE_ID_T *fid) inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; inode_inc_iversion(inode); - inode->i_generation = get_seconds(); + inode->i_generation = sdfat_make_inode_generation(); if (fsapi_read_inode(inode, &info) < 0) { MMSG("%s: failed to read stat!\n", __func__); @@ -4207,7 +4328,8 @@ static void sdfat_put_super(struct super_block *sb) struct sdfat_sb_info *sbi = SDFAT_SB(sb); int err; - sdfat_log_msg(sb, KERN_INFO, "trying to unmount..."); + sdfat_log_msg(sb, KERN_INFO, "trying to unmount(r%c)...", + sb_rdonly(sb) ? 'o' : 'w'); __cancel_delayed_work_sync(sbi); @@ -4951,7 +5073,8 @@ static int sdfat_fill_super(struct super_block *sb, void *data, int silent) struct block_device *bdev = sb->s_bdev; dev_t bd_dev = bdev ? bdev->bd_dev : 0; - sdfat_log_msg(sb, KERN_INFO, "trying to mount..."); + sdfat_log_msg(sb, KERN_INFO, "trying to mount(r%c)...", + sb_rdonly(sb) ? 'o' : 'w'); /* * GFP_KERNEL is ok here, because while we do hold the diff --git a/fs/sdfat/version.h b/fs/sdfat/version.h index c3008743a371..4f2b997de35e 100755 --- a/fs/sdfat/version.h +++ b/fs/sdfat/version.h @@ -23,5 +23,5 @@ /* */ /************************************************************************/ -/* @fs.sec -- 8304f2146e71f0f27864eebd58892245 -- */ -#define SDFAT_VERSION "2.4.5" +/* @fs.sec -- 8304f2146e71f0f27864eebd58892260 -- */ +#define SDFAT_VERSION "2.6.0" diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 2604f8750f54..3f920c81d110 100755 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -92,6 +92,7 @@ enum { CFTYPE_NO_PREFIX = (1 << 3), /* (DON'T USE FOR NEW FILES) no subsys prefix */ CFTYPE_WORLD_WRITABLE = (1 << 4), /* (DON'T USE FOR NEW FILES) S_IWUGO */ + CFTYPE_PRESSURE = (1 << 6), /* only if pressure feature is enabled */ /* internal flags, do not use outside cgroup core proper */ __CFTYPE_ONLY_ON_DFL = (1 << 16), /* only on default hierarchy */ diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 05ee3c0ad3e4..0a81fbc78d20 100755 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -643,6 +643,8 @@ static inline struct psi_group *cgroup_psi(struct cgroup *cgrp) return &cgrp->psi; } +bool cgroup_psi_enabled(void); + static inline void cgroup_init_kthreadd(void) { /* @@ -707,6 +709,11 @@ static inline struct psi_group *cgroup_psi(struct cgroup *cgrp) return NULL; } +static inline bool cgroup_psi_enabled(void) +{ + return false; +} + static inline bool task_under_cgroup_hierarchy(struct task_struct *task, struct cgroup *ancestor) { diff --git a/include/linux/muic/sm/sm5714/sm5714-muic.h b/include/linux/muic/sm/sm5714/sm5714-muic.h index b39723354805..e562c4797ed2 100755 --- a/include/linux/muic/sm/sm5714/sm5714-muic.h +++ b/include/linux/muic/sm/sm5714/sm5714-muic.h @@ -310,6 +310,7 @@ struct sm5714_muic_data { struct work_struct muic_event_work; struct delayed_work muic_debug_work; + struct delayed_work muic_U200_work; #if defined(CONFIG_IF_CB_MANAGER) struct muic_dev *muic_d; struct if_cb_manager *man; diff --git a/include/linux/olog.pb.h b/include/linux/olog.pb.h index 745214eb3c2e..53ddbaca357d 100755 --- a/include/linux/olog.pb.h +++ b/include/linux/olog.pb.h @@ -45,11 +45,14 @@ enum OlogTestEnum_ID { PERFLOG_SCREENSHOT = 21, PERFLOG_MUTEX = 22, PERFLOG_SYSTEMSERVER = 23, - PERFLOG_PERFETTOLOGGINGENABLED = 24 + PERFLOG_PERFETTOLOGGINGENABLED = 24, + PERFLOG_BIGDATA = 25, + PERFLOG_PSI = 26, + PERFLOG_JANK = 27 }; #if defined(KPERFMON_KERNEL) -int OlogTestEnum_ID_maxnum = 25; -char * OlogTestEnum_ID_strings[25] = { +int OlogTestEnum_ID_maxnum = 28; +char * OlogTestEnum_ID_strings[28] = { "UNKNOWN", " ", "LCDV", @@ -74,7 +77,10 @@ char * OlogTestEnum_ID_strings[25] = { "SCREENSHOT", "MUTEX", "SYSTEMSERVER", - "PERFETTOLOGGINGENABLED" + "PERFETTOLOGGINGENABLED", + "BIGDATA", + "PSI", + "JANK" }; #endif //KPERFMON_KERNEL diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 7268a54b8956..26a5ec8ab04c 100755 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -44,12 +44,15 @@ struct anon_vma { atomic_t refcount; /* - * Count of child anon_vmas and VMAs which points to this anon_vma. + * Count of child anon_vmas. Equals to the count of all anon_vmas that + * have ->parent pointing to this one, including itself. * * This counter is used for making decision about reusing anon_vma * instead of forking new one. See comments in function anon_vma_clone. */ - unsigned degree; + unsigned long num_children; + /* Count of VMAs whose ->anon_vma pointer points to this object. */ + unsigned long num_active_vmas; struct anon_vma *parent; /* Parent of this anon_vma */ diff --git a/include/linux/usb.h b/include/linux/usb.h index ac49fcdb9bab..76767c920452 100755 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1580,8 +1580,9 @@ struct urb { int error_count; /* (return) number of ISO errors */ void *context; /* (in) context for completion */ usb_complete_t complete; /* (in) completion routine */ + struct usb_iso_packet_descriptor iso_frame_desc[0]; + /* (in) ISO ONLY */ void *priv_data; /* (in) additional private data */ - struct usb_iso_packet_descriptor iso_frame_desc[]; /* (in) ISO ONLY */ }; /* ----------------------------------------------------------------------- */ diff --git a/include/linux/usb/typec/sm/sm5714/sm5714_typec.h b/include/linux/usb/typec/sm/sm5714/sm5714_typec.h index 135a13cfceec..450452719134 100755 --- a/include/linux/usb/typec/sm/sm5714/sm5714_typec.h +++ b/include/linux/usb/typec/sm/sm5714/sm5714_typec.h @@ -101,7 +101,6 @@ #define SM5714_ATTACH_AUDIO 0x03 #define SM5714_ATTACH_UN_ORI_DEBUG_SOURCE (0x01 << SM5714_ATTACH_SINK) #define SM5714_ATTACH_ORI_DEBUG_SOURCE 0x05 -#define SM5714_ATTACH_AUDIO_CHARGE (0x01 << 2) #define SM5714_ATTACH_TYPE 0x07 #define SM5714_ADV_CURR 0x18 #define SM5714_CABLE_FLIP 0x20 @@ -275,6 +274,7 @@ struct sm5714_phydrv_data { int power_role; int data_role; int vconn_source; + int scr_sel; msg_header_type header; data_obj_type obj[SM5714_MAX_NUM_MSG_OBJ]; u64 status_reg; @@ -290,6 +290,7 @@ struct sm5714_phydrv_data { #endif bool is_otg_vboost; bool is_jig_case_on; + bool is_noti_src_adv; bool is_mpsm_exit; bool suspended; bool is_timer_expired; diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 101b2ccd4555..ca85428994d8 100755 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -112,12 +112,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PGPGOUTCLEAN, PSWPIN, PSWPOUT, #endif #ifdef CONFIG_SPECULATIVE_PAGE_FAULT SPECULATIVE_PGFAULT, -#endif -#ifdef CONFIG_ZRAM_LRU_WRITEBACK - SQZR_OBJCNT, - SQZR_COUNT, - SQZR_READ, - SQZR_WRITE, #endif NR_VM_EVENT_ITEMS }; diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 25f41d8d136b..c197410302e8 100755 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -203,6 +203,22 @@ struct cgroup_namespace init_cgroup_ns = { static struct file_system_type cgroup2_fs_type; static struct cftype cgroup_base_files[]; +/* cgroup optional features */ +enum cgroup_opt_features { +#ifdef CONFIG_PSI + OPT_FEATURE_PRESSURE, +#endif + OPT_FEATURE_COUNT +}; + +static const char *cgroup_opt_feature_names[OPT_FEATURE_COUNT] = { +#ifdef CONFIG_PSI + "pressure", +#endif +}; + +static u16 cgroup_feature_disable_mask __read_mostly; + static int cgroup_apply_control(struct cgroup *cgrp); static void cgroup_finalize_control(struct cgroup *cgrp, int ret); static void css_task_iter_skip(struct css_task_iter *it, @@ -3413,6 +3429,18 @@ static void cgroup_pressure_release(struct kernfs_open_file *of) { psi_trigger_replace(&of->priv, NULL); } + +bool cgroup_psi_enabled(void) +{ + return (cgroup_feature_disable_mask & (1 << OPT_FEATURE_PRESSURE)) == 0; +} + +#else /* CONFIG_PSI */ +bool cgroup_psi_enabled(void) +{ + return false; +} + #endif /* CONFIG_PSI */ static int cgroup_file_open(struct kernfs_open_file *of) @@ -3617,6 +3645,8 @@ static int cgroup_addrm_files(struct cgroup_subsys_state *css, restart: for (cft = cfts; cft != cft_end && cft->name[0] != '\0'; cft++) { /* does cft->flags tell us to skip this file on @cgrp? */ + if ((cft->flags & CFTYPE_PRESSURE) && !cgroup_psi_enabled()) + continue; if ((cft->flags & __CFTYPE_ONLY_ON_DFL) && !cgroup_on_dfl(cgrp)) continue; if ((cft->flags & __CFTYPE_NOT_ON_DFL) && cgroup_on_dfl(cgrp)) @@ -3693,6 +3723,9 @@ static int cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) WARN_ON(cft->ss || cft->kf_ops); + if ((cft->flags & CFTYPE_PRESSURE) && !cgroup_psi_enabled()) + continue; + if (cft->seq_start) kf_ops = &cgroup_kf_ops; else @@ -4587,7 +4620,7 @@ static struct cftype cgroup_base_files[] = { #ifdef CONFIG_PSI { .name = "io.pressure", - .flags = CFTYPE_NOT_ON_ROOT, + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_PRESSURE, .seq_show = cgroup_io_pressure_show, .write = cgroup_io_pressure_write, .poll = cgroup_pressure_poll, @@ -4595,7 +4628,7 @@ static struct cftype cgroup_base_files[] = { }, { .name = "memory.pressure", - .flags = CFTYPE_NOT_ON_ROOT, + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_PRESSURE, .seq_show = cgroup_memory_pressure_show, .write = cgroup_memory_pressure_write, .poll = cgroup_pressure_poll, @@ -4603,7 +4636,7 @@ static struct cftype cgroup_base_files[] = { }, { .name = "cpu.pressure", - .flags = CFTYPE_NOT_ON_ROOT, + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_PRESSURE, .seq_show = cgroup_cpu_pressure_show, .write = cgroup_cpu_pressure_write, .poll = cgroup_pressure_poll, @@ -5770,6 +5803,15 @@ static int __init cgroup_disable(char *str) continue; cgroup_disable_mask |= 1 << i; } + + for (i = 0; i < OPT_FEATURE_COUNT; i++) { + if (strcmp(token, cgroup_opt_feature_names[i])) + continue; + cgroup_feature_disable_mask |= 1 << i; + pr_info("Disabling %s control group feature\n", + cgroup_opt_feature_names[i]); + break; + } } return 1; } diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index bc4b72527b02..b0dc6aa10c4f 100755 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -146,6 +146,7 @@ static int psi_bug __read_mostly; DEFINE_STATIC_KEY_FALSE(psi_disabled); +DEFINE_STATIC_KEY_TRUE(psi_cgroups_enabled); #ifdef CONFIG_PSI_DEFAULT_DISABLED static bool psi_enable; @@ -210,6 +211,9 @@ void __init psi_init(void) return; } + if (!cgroup_psi_enabled()) + static_branch_disable(&psi_cgroups_enabled); + psi_period = jiffies_to_nsecs(PSI_FREQ); group_init(&psi_system); } @@ -723,23 +727,23 @@ static u32 psi_group_change(struct psi_group *group, int cpu, static struct psi_group *iterate_groups(struct task_struct *task, void **iter) { + if (*iter == &psi_system) + return NULL; + #ifdef CONFIG_CGROUPS - struct cgroup *cgroup = NULL; + if (static_branch_likely(&psi_cgroups_enabled)) { + struct cgroup *cgroup = NULL; - if (!*iter) - cgroup = task->cgroups->dfl_cgrp; - else if (*iter == &psi_system) - return NULL; - else - cgroup = cgroup_parent(*iter); + if (!*iter) + cgroup = task->cgroups->dfl_cgrp; + else + cgroup = cgroup_parent(*iter); - if (cgroup && cgroup_parent(cgroup)) { - *iter = cgroup; - return cgroup_psi(cgroup); + if (cgroup && cgroup_parent(cgroup)) { + *iter = cgroup; + return cgroup_psi(cgroup); + } } -#else - if (*iter) - return NULL; #endif *iter = &psi_system; return &psi_system; diff --git a/mm/rmap.c b/mm/rmap.c index 63ecb38d0766..6843bb592a04 100755 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -82,7 +82,8 @@ static inline struct anon_vma *anon_vma_alloc(void) anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL); if (anon_vma) { atomic_set(&anon_vma->refcount, 1); - anon_vma->degree = 1; /* Reference for first vma */ + anon_vma->num_children = 0; + anon_vma->num_active_vmas = 0; anon_vma->parent = anon_vma; /* * Initialise the anon_vma root to point to itself. If called @@ -190,6 +191,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma) anon_vma = anon_vma_alloc(); if (unlikely(!anon_vma)) goto out_enomem_free_avc; + anon_vma->num_children++; /* self-parent link for new root */ allocated = anon_vma; } @@ -199,8 +201,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma) if (likely(!vma->anon_vma)) { vma->anon_vma = anon_vma; anon_vma_chain_link(vma, avc, anon_vma); - /* vma reference or self-parent link for new root */ - anon_vma->degree++; + anon_vma->num_active_vmas++; allocated = NULL; avc = NULL; } @@ -279,19 +280,19 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) anon_vma_chain_link(dst, avc, anon_vma); /* - * Reuse existing anon_vma if its degree lower than two, - * that means it has no vma and only one anon_vma child. + * Reuse existing anon_vma if it has no vma and only one + * anon_vma child. * - * Do not chose parent anon_vma, otherwise first child - * will always reuse it. Root anon_vma is never reused: + * Root anon_vma is never reused: * it has self-parent reference and at least one child. */ - if (!dst->anon_vma && anon_vma != src->anon_vma && - anon_vma->degree < 2) + if (!dst->anon_vma && + anon_vma->num_children < 2 && + anon_vma->num_active_vmas == 0) dst->anon_vma = anon_vma; } if (dst->anon_vma) - dst->anon_vma->degree++; + dst->anon_vma->num_active_vmas++; unlock_anon_vma_root(root); return 0; @@ -341,6 +342,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) anon_vma = anon_vma_alloc(); if (!anon_vma) goto out_error; + anon_vma->num_active_vmas++; avc = anon_vma_chain_alloc(GFP_KERNEL); if (!avc) goto out_error_free_anon_vma; @@ -361,7 +363,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) vma->anon_vma = anon_vma; anon_vma_lock_write(anon_vma); anon_vma_chain_link(vma, avc, anon_vma); - anon_vma->parent->degree++; + anon_vma->parent->num_children++; anon_vma_unlock_write(anon_vma); return 0; @@ -393,7 +395,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma) * to free them outside the lock. */ if (RB_EMPTY_ROOT(&anon_vma->rb_root.rb_root)) { - anon_vma->parent->degree--; + anon_vma->parent->num_children--; continue; } @@ -401,7 +403,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma) anon_vma_chain_free(avc); } if (vma->anon_vma) - vma->anon_vma->degree--; + vma->anon_vma->num_active_vmas--; unlock_anon_vma_root(root); /* @@ -412,7 +414,8 @@ void unlink_anon_vmas(struct vm_area_struct *vma) list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) { struct anon_vma *anon_vma = avc->anon_vma; - VM_WARN_ON(anon_vma->degree); + VM_WARN_ON(anon_vma->num_children); + VM_WARN_ON(anon_vma->num_active_vmas); put_anon_vma(anon_vma); list_del(&avc->same_vma); diff --git a/mm/vmstat.c b/mm/vmstat.c index 5a11a2d24789..a2c6c47da84e 100755 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1225,12 +1225,6 @@ const char * const vmstat_text[] = { #ifdef CONFIG_SPECULATIVE_PAGE_FAULT "speculative_pgfault" #endif -#ifdef CONFIG_ZRAM_LRU_WRITEBACK - "sqzr_objcnt", - "sqzr_count", - "sqzr_read", - "sqzr_write", -#endif #endif /* CONFIG_VM_EVENT_COUNTERS */ }; #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */ diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 93093d7c3824..fc32f5bc0734 100755 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -39,7 +39,7 @@ static LIST_HEAD(mgmt_chan_list); static DEFINE_MUTEX(mgmt_chan_list_lock); -static DEFINE_IDA(sock_cookie_ida); +// static DEFINE_IDA(sock_cookie_ida); static atomic_t monitor_promisc = ATOMIC_INIT(0); @@ -83,7 +83,7 @@ u32 hci_sock_get_cookie(struct sock *sk) { return hci_pi(sk)->cookie; } - +/* static bool hci_sock_gen_cookie(struct sock *sk) { int id = hci_pi(sk)->cookie; @@ -110,7 +110,7 @@ static void hci_sock_free_cookie(struct sock *sk) ida_simple_remove(&sock_cookie_ida, id); } } - +*/ static inline int hci_test_bit(int nr, const void *addr) { return *((const __u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31)); @@ -474,7 +474,7 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) return skb; } - +/* static struct sk_buff *create_monitor_ctrl_open(struct sock *sk) { struct hci_mon_hdr *hdr; @@ -483,7 +483,7 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk) u8 ver[3]; u32 flags; - /* No message needed when cookie is not present */ + // No message needed when cookie is not present if (!hci_pi(sk)->cookie) return NULL; @@ -503,7 +503,7 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk) mgmt_fill_version_info(ver); break; default: - /* No message for unsupported format */ + // No message for unsupported format return NULL; } @@ -538,7 +538,7 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk) struct hci_mon_hdr *hdr; struct sk_buff *skb; - /* No message needed when cookie is not present */ + // No message needed when cookie is not present if (!hci_pi(sk)->cookie) return NULL; @@ -548,7 +548,7 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk) case HCI_CHANNEL_CONTROL: break; default: - /* No message for unsupported format */ + // No message for unsupported format return NULL; } @@ -570,7 +570,7 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk) return skb; } - +*/ static struct sk_buff *create_monitor_ctrl_command(struct sock *sk, u16 index, u16 opcode, u16 len, const void *buf) @@ -597,7 +597,7 @@ static struct sk_buff *create_monitor_ctrl_command(struct sock *sk, u16 index, return skb; } - +/* static void __printf(2, 3) send_monitor_note(struct sock *sk, const char *fmt, ...) { @@ -691,7 +691,7 @@ static void send_monitor_control_replay(struct sock *mon_sk) read_unlock(&hci_sk_list.lock); } - +*/ /* Generate internal stack event */ static void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) { @@ -817,6 +817,7 @@ EXPORT_SYMBOL(hci_mgmt_chan_unregister); static int hci_sock_release(struct socket *sock) { + /* struct sock *sk = sock->sk; struct hci_dev *hdev; struct sk_buff *skb; @@ -835,7 +836,7 @@ static int hci_sock_release(struct socket *sock) case HCI_CHANNEL_RAW: case HCI_CHANNEL_USER: case HCI_CHANNEL_CONTROL: - /* Send event to monitor */ + // Send event to monitor skb = create_monitor_ctrl_close(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -852,15 +853,15 @@ static int hci_sock_release(struct socket *sock) hdev = hci_pi(sk)->hdev; if (hdev) { if (hci_pi(sk)->channel == HCI_CHANNEL_USER) { - /* When releasing a user channel exclusive access, - * call hci_dev_do_close directly instead of calling - * hci_dev_close to ensure the exclusive access will - * be released and the controller brought back down. - * - * The checking of HCI_AUTO_OFF is not needed in this - * case since it will have been cleared already when - * opening the user channel. - */ + // When releasing a user channel exclusive access, + // call hci_dev_do_close directly instead of calling + // hci_dev_close to ensure the exclusive access will + // be released and the controller brought back down. + // + // The checking of HCI_AUTO_OFF is not needed in this + // case since it will have been cleared already when + // opening the user channel. + hci_dev_do_close(hdev); hci_dev_clear_flag(hdev, HCI_USER_CHANNEL); mgmt_index_added(hdev); @@ -877,9 +878,10 @@ static int hci_sock_release(struct socket *sock) release_sock(sk); sock_put(sk); + */ return 0; } - +/* static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg) { bdaddr_t bdaddr; @@ -914,7 +916,7 @@ static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) return err; } -/* Ioctls that require bound socket */ +// Ioctls that require bound socket static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg) { @@ -957,10 +959,11 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, return -ENOIOCTLCMD; } - +*/ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { + /* void __user *argp = (void __user *)arg; struct sock *sk = sock->sk; int err; @@ -974,19 +977,19 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, goto done; } - /* When calling an ioctl on an unbound raw socket, then ensure - * that the monitor gets informed. Ensure that the resulting event - * is only send once by checking if the cookie exists or not. The - * socket cookie will be only ever generated once for the lifetime - * of a given socket. - */ + // When calling an ioctl on an unbound raw socket, then ensure + // that the monitor gets informed. Ensure that the resulting event + // is only send once by checking if the cookie exists or not. The + // socket cookie will be only ever generated once for the lifetime + // of a given socket. + if (hci_sock_gen_cookie(sk)) { struct sk_buff *skb; if (capable(CAP_NET_ADMIN)) hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); - /* Send event to monitor */ + // Send event to monitor skb = create_monitor_ctrl_open(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1050,11 +1053,14 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, done: release_sock(sk); return err; + */ + return 0; } static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) { + /* struct sockaddr_hci haddr; struct sock *sk = sock->sk; struct hci_dev *hdev = NULL; @@ -1100,12 +1106,12 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, hci_pi(sk)->channel = haddr.hci_channel; if (!hci_sock_gen_cookie(sk)) { - /* In the case when a cookie has already been assigned, - * then there has been already an ioctl issued against - * an unbound socket and with that triggerd an open - * notification. Send a close notification first to - * allow the state transition to bounded. - */ + // In the case when a cookie has already been assigned, + // then there has been already an ioctl issued against + // an unbound socket and with that triggered an open + // notification. Send a close notification first to + // allow the state transition to bounded. + skb = create_monitor_ctrl_close(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1119,7 +1125,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, hci_pi(sk)->hdev = hdev; - /* Send event to monitor */ + // Send event to monitor skb = create_monitor_ctrl_open(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1171,13 +1177,13 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, err = hci_dev_open(hdev->id); if (err) { if (err == -EALREADY) { - /* In case the transport is already up and - * running, clear the error here. - * - * This can happen when opening a user - * channel and HCI_AUTO_OFF grace period - * is still active. - */ + // In case the transport is already up and + // running, clear the error here. + + // This can happen when opening a user + // channel and HCI_AUTO_OFF grace period + // is still active. + err = 0; } else { hci_dev_clear_flag(hdev, HCI_USER_CHANNEL); @@ -1190,11 +1196,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, hci_pi(sk)->channel = haddr.hci_channel; if (!hci_sock_gen_cookie(sk)) { - /* In the case when a cookie has already been assigned, - * this socket will transition from a raw socket into - * a user channel socket. For a clean transition, send - * the close notification first. - */ + // In the case when a cookie has already been assigned, + // this socket will transition from a raw socket into + // a user channel socket. For a clean transition, send + // the close notification first. + skb = create_monitor_ctrl_close(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1203,14 +1209,14 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, } } - /* The user channel is restricted to CAP_NET_ADMIN - * capabilities and with that implicitly trusted. - */ + // The user channel is restricted to CAP_NET_ADMIN + // capabilities and with that implicitly trusted. + hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); hci_pi(sk)->hdev = hdev; - /* Send event to monitor */ + // Send event to monitor skb = create_monitor_ctrl_open(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1234,9 +1240,9 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, hci_pi(sk)->channel = haddr.hci_channel; - /* The monitor interface is restricted to CAP_NET_RAW - * capabilities and with that implicitly trusted. - */ + // The monitor interface is restricted to CAP_NET_RAW + // capabilities and with that implicitly trusted. + hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); send_monitor_note(sk, "Linux version %s (%s)", @@ -1275,34 +1281,34 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, goto done; } - /* Users with CAP_NET_ADMIN capabilities are allowed - * access to all management commands and events. For - * untrusted users the interface is restricted and - * also only untrusted events are sent. - */ + // Users with CAP_NET_ADMIN capabilities are allowed + // access to all management commands and events. For + // untrusted users the interface is restricted and + // also only untrusted events are sent. + if (capable(CAP_NET_ADMIN)) hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); hci_pi(sk)->channel = haddr.hci_channel; - /* At the moment the index and unconfigured index events - * are enabled unconditionally. Setting them on each - * socket when binding keeps this functionality. They - * however might be cleared later and then sending of these - * events will be disabled, but that is then intentional. - * - * This also enables generic events that are safe to be - * received by untrusted users. Example for such events - * are changes to settings, class of device, name etc. - */ + // At the moment the index and unconfigured index events + // are enabled unconditionally. Setting them on each + // socket when binding keeps this functionality. They + // however might be cleared later and then sending of these + // events will be disabled, but that is then intentional. + + // This also enables generic events that are safe to be + // received by untrusted users. Example for such events + // are changes to settings, class of device, name etc. + if (hci_pi(sk)->channel == HCI_CHANNEL_CONTROL) { if (!hci_sock_gen_cookie(sk)) { - /* In the case when a cookie has already been - * assigned, this socket will transtion from - * a raw socket into a control socket. To - * allow for a clean transtion, send the - * close notification first. - */ + // In the case when a cookie has already been + // assigned, this socket will transition from + // a raw socket into a control socket. To + // allow for a clean transition, send the + // close notification first. + skb = create_monitor_ctrl_close(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1311,7 +1317,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, } } - /* Send event to monitor */ + // Send event to monitor skb = create_monitor_ctrl_open(sk); if (skb) { hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, @@ -1334,11 +1340,14 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, done: release_sock(sk); return err; + */ + return 0; } static int hci_sock_getname(struct socket *sock, struct sockaddr *addr, int *addr_len, int peer) { + /* struct sockaddr_hci *haddr = (struct sockaddr_hci *)addr; struct sock *sk = sock->sk; struct hci_dev *hdev; @@ -1365,6 +1374,8 @@ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr, done: release_sock(sk); return err; + */ + return 0; } static void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, @@ -1992,6 +2003,7 @@ static struct proto hci_sk_proto = { static int hci_sock_create(struct net *net, struct socket *sock, int protocol, int kern) { + /* struct sock *sk; BT_DBG("sock %p", sock); @@ -2015,6 +2027,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_state = BT_OPEN; bt_sock_link(&hci_sk_list, sk); + */ return 0; } diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 7b150e6de1ad..85cd6b0688ff 100755 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -872,6 +872,11 @@ out: static __inline__ int neigh_max_probes(struct neighbour *n) { struct neigh_parms *p = n->parms; + if (n->dev != NULL && !strcmp(n->dev->name, "aware_data0")) { + return (NEIGH_VAR(p, UCAST_PROBES) * 2) + NEIGH_VAR(p, APP_PROBES) + + (n->nud_state & NUD_PROBE ? NEIGH_VAR(p, MCAST_REPROBES) : + NEIGH_VAR(p, MCAST_PROBES)); + } return NEIGH_VAR(p, UCAST_PROBES) + NEIGH_VAR(p, APP_PROBES) + (n->nud_state & NUD_PROBE ? NEIGH_VAR(p, MCAST_REPROBES) : NEIGH_VAR(p, MCAST_PROBES)); @@ -974,6 +979,9 @@ static void neigh_timer_handler(unsigned long arg) } } else { /* NUD_PROBE|NUD_INCOMPLETE */ + if (neigh->dev != NULL && !strcmp(neigh->dev->name, "aware_data0")) { + next = now + NEIGH_VAR(neigh->parms, RETRANS_TIME)/5; + } else next = now + NEIGH_VAR(neigh->parms, RETRANS_TIME); } @@ -986,6 +994,10 @@ static void neigh_timer_handler(unsigned long arg) } if (neigh->nud_state & NUD_IN_TIMER) { + if (neigh->dev != NULL && !strcmp(neigh->dev->name, "aware_data0")) { + if (time_before(next, jiffies + HZ/20)) + next = jiffies + HZ/20; + } else if (time_before(next, jiffies + HZ/2)) next = jiffies + HZ/2; if (!mod_timer(&neigh->timer, next)) @@ -1035,6 +1047,10 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) neigh_del_timer(neigh); neigh->nud_state = NUD_INCOMPLETE; neigh->updated = now; + if (neigh->dev != NULL && !strcmp(neigh->dev->name, "aware_data0")) { + next = now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME)/25, + HZ/25); + } else next = now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME), HZ/2); neigh_add_timer(neigh, next); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 00a3164b148d..c04972fb8354 100755 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1019,6 +1019,10 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, skb = skb_clone(skb, gfp_mask); if (unlikely(!skb)) return -ENOBUFS; + /* retransmit skbs might have a non zero value in skb->dev + * because skb->dev is aliased with skb->rbnode.rb_left + */ + skb->dev = NULL; } skb->skb_mstamp = tp->tcp_mstamp; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index dc8286114233..2acad96747af 100755 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -4037,14 +4037,14 @@ static void addrconf_dad_work(struct work_struct *w) } ifp->dad_probes--; - if (!strcmp(ifp->idev->dev->name, "aware_data0")) { - pr_info("Reduce waing time from %lu to %lu (HZ=%lu) to send NS for quick transmission for %s\n", + if (ifp->idev->dev != NULL && !strcmp(ifp->idev->dev->name, "aware_data0")) { + pr_info("Reduce wating time from %lu to %lu (HZ=%lu) to send NS for quick transmission for %s\n", NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME), - NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME)/10, + NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME)/100, HZ, ifp->idev->dev->name); addrconf_mod_dad_work(ifp, - NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME)/10); + NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME)/100); } else addrconf_mod_dad_work(ifp, NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME)); diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 2241c5f52394..c44030f2d8fd 100755 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -914,6 +914,15 @@ have_ifp: NEIGH_UPDATE_F_WEAK_OVERRIDE| NEIGH_UPDATE_F_OVERRIDE, NDISC_NEIGHBOUR_SOLICITATION, &ndopts); + + if (neigh != NULL && neigh->dev != NULL && !strcmp(neigh->dev->name, "aware_data0")) { + pr_info("ipv6 neigh_lookup is done by receiving NS" + " from [:%02x%02x] to [:%02x%02x] and sending NA for %s\n", + saddr->s6_addr[14], saddr->s6_addr[15], + daddr->s6_addr[14], daddr->s6_addr[15], + neigh->dev->name); + } + if (neigh || !dev->header_ops) { ndisc_send_na(dev, saddr, &msg->target, !!is_router, true, (ifp != NULL && inc), inc); @@ -1030,6 +1039,14 @@ static void ndisc_recv_na(struct sk_buff *skb) (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0), NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts); + if (neigh->dev != NULL && !strcmp(neigh->dev->name, "aware_data0")) { + pr_info("ipv6 neigh_lookup is done by receiving NA" + " from [:%02x%02x] to [:%02x%02x] for %s\n", + saddr->s6_addr[14], saddr->s6_addr[15], + daddr->s6_addr[14], daddr->s6_addr[15], + dev->name); + } + if ((old_flags & ~neigh->flags) & NTF_ROUTER) { /* * Change: router to host diff --git a/net/qrtr/fifo.c b/net/qrtr/fifo.c index 6da703791a25..63d2479c8d30 100755 --- a/net/qrtr/fifo.c +++ b/net/qrtr/fifo.c @@ -89,6 +89,9 @@ static void fifo_rx_peak(struct fifo_pipe *pipe, tail += offset; if (tail >= pipe->length) tail -= pipe->length; + + if (WARN_ON_ONCE(tail > pipe->length)) + return; len = min_t(size_t, count, pipe->length - tail); if (len) @@ -125,6 +128,9 @@ static size_t fifo_tx_avail(struct fifo_pipe *pipe) else avail = tail - head; + if (WARN_ON_ONCE(avail > pipe->length)) + avail = 0; + return avail; } @@ -135,6 +141,8 @@ static void fifo_tx_write(struct fifo_pipe *pipe, u32 head; head = le32_to_cpu(*pipe->head); + if (WARN_ON_ONCE(head > pipe->length)) + return; len = min_t(size_t, count, pipe->length - head); if (len) diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index 7f45e5ab8afc..e63f9c2e37e5 100755 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -225,11 +225,6 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp, if (err < 0) return err; - if (tb[TCA_FW_CLASSID]) { - f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]); - tcf_bind_filter(tp, &f->res, base); - } - #ifdef CONFIG_NET_CLS_IND if (tb[TCA_FW_INDEV]) { int ret; @@ -248,6 +243,11 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp, } else if (head->mask != 0xFFFFFFFF) return err; + if (tb[TCA_FW_CLASSID]) { + f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]); + tcf_bind_filter(tp, &f->res, base); + } + return 0; } diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 507fd5210c1c..f5e51f5e3437 100755 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -316,7 +316,9 @@ static int ctl_elem_read_user(struct snd_card *card, err = snd_power_wait(card, SNDRV_CTL_POWER_D0); if (err < 0) goto error; + down_read(&card->controls_rwsem); err = snd_ctl_elem_read(card, data); + up_read(&card->controls_rwsem); if (err < 0) goto error; err = copy_ctl_value_to_user(userdata, valuep, data, type, count); @@ -344,7 +346,9 @@ static int ctl_elem_write_user(struct snd_ctl_file *file, err = snd_power_wait(card, SNDRV_CTL_POWER_D0); if (err < 0) goto error; + down_write(&card->controls_rwsem); err = snd_ctl_elem_write(card, file, data); + up_write(&card->controls_rwsem); if (err < 0) goto error; err = copy_ctl_value_to_user(userdata, valuep, data, type, count); diff --git a/techpack/audio/4.0/asoc/msm-audio-effects-q6-v2.c b/techpack/audio/4.0/asoc/msm-audio-effects-q6-v2.c index db3bd87ebc0e..2c4739070756 100755 --- a/techpack/audio/4.0/asoc/msm-audio-effects-q6-v2.c +++ b/techpack/audio/4.0/asoc/msm-audio-effects-q6-v2.c @@ -1002,6 +1002,14 @@ int msm_audio_effects_pbe_handler(struct audio_client *ac, pbe->config.reserved = GET_NEXT(values, param_max_offset, rc); + if ((pbe->config.bandpass_filter_order > 3) || + (pbe->config.bandpass_filter_order < 1)) { + pr_err("%s: Invalid BPF order\n", + __func__); + rc = -EINVAL; + goto invalid_config; + } + p_coeffs = &pbe->config.p1LowPassCoeffs[0]; lpf_len = (pbe->config.xover_filter_order == 3) ? 10 : 5; hpf_len = (pbe->config.xover_filter_order == 3) ? 10 : 5; diff --git a/techpack/audio/4.0/asoc/msm-pcm-host-voice-v2.c b/techpack/audio/4.0/asoc/msm-pcm-host-voice-v2.c index 99d6e3732050..a0e5dd21c796 100755 --- a/techpack/audio/4.0/asoc/msm-pcm-host-voice-v2.c +++ b/techpack/audio/4.0/asoc/msm-pcm-host-voice-v2.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -610,6 +611,12 @@ static int hpcm_start_vocpcm(char *pcm_id, struct hpcm_drv *prtd, } } + if (*no_of_tp != no_of_tp_req && *no_of_tp > 2) { + pr_err("%s:: Invalid hpcm start request\n", __func__); + memset(&prtd->start_cmd, 0, sizeof(struct start_cmd)); + return -EINVAL; + } + if (prtd->mixer_conf.tx.enable && (get_tappnt_value(pcm_id) == TX)) { if (hpcm_all_dais_are_ready(prtd->mixer_conf.tx.direction, tp, HPCM_PREPARED)) { @@ -654,6 +661,11 @@ static void hpcm_copy_playback_data_from_queue(struct dai_data *dai_data, struct hpcm_buf_node, list); list_del(&buf_node->list); *len = buf_node->frame.len; + if (*len > HPCM_MAX_VOC_PKT_SIZE) { + pr_err("%s: Playback data len %d overflow\n", + __func__, *len); + return; + } memcpy((u8 *)dai_data->vocpcm_ion_buffer.kvaddr, &buf_node->frame.voc_pkt[0], buf_node->frame.len); @@ -681,6 +693,12 @@ static void hpcm_copy_capture_data_to_queue(struct dai_data *dai_data, if (dai_data->substream == NULL) return; + if (len > HPCM_MAX_VOC_PKT_SIZE) { + pr_err("%s: Copy capture data len %d overflow\n", + __func__, len); + return; + } + /* Copy out buffer packet into free_queue */ spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); diff --git a/techpack/audio/4.0/asoc/msm-pcm-q6-noirq.c b/techpack/audio/4.0/asoc/msm-pcm-q6-noirq.c index b75851646000..613dcd740384 100755 --- a/techpack/audio/4.0/asoc/msm-pcm-q6-noirq.c +++ b/techpack/audio/4.0/asoc/msm-pcm-q6-noirq.c @@ -601,7 +601,11 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct msm_audio *prtd = runtime->private_data; struct asm_softvolume_params softvol = { +#ifdef CONFIG_SND_SOC_SAMSUNG_AUDIO + .period = SOFT_VOLUME_MMAP_PERIOD, +#else .period = SOFT_VOLUME_PERIOD, +#endif .step = SOFT_VOLUME_STEP, .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, }; diff --git a/techpack/audio/4.0/asoc/msm-pcm-q6-v2.c b/techpack/audio/4.0/asoc/msm-pcm-q6-v2.c index db6b992cf98b..dedc268d715a 100755 --- a/techpack/audio/4.0/asoc/msm-pcm-q6-v2.c +++ b/techpack/audio/4.0/asoc/msm-pcm-q6-v2.c @@ -979,6 +979,13 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, xfer = size; offset = prtd->in_frame_info[idx].offset; pr_debug("Offset value = %d\n", offset); + if (offset >= size) { + pr_err("%s: Invalid dsp buf offset\n", __func__); + ret = -EFAULT; + q6asm_cpu_buf_release(OUT, prtd->audio_client); + goto fail; + } + if (copy_to_user(buf, bufptr+offset, xfer)) { pr_err("Failed to copy buf to user\n"); ret = -EFAULT; diff --git a/techpack/audio/4.0/asoc/msm-pcm-routing-v2.c b/techpack/audio/4.0/asoc/msm-pcm-routing-v2.c index 5610e0635374..e1e94f86dbfd 100755 --- a/techpack/audio/4.0/asoc/msm-pcm-routing-v2.c +++ b/techpack/audio/4.0/asoc/msm-pcm-routing-v2.c @@ -22427,7 +22427,7 @@ static int msm_routing_put_stereo_to_custom_stereo_control( if (topo_id < 0) pr_debug("%s:Err:custom stereo topo %d", __func__, topo_id); - pr_debug("idx %d\n", idx); + pr_debug("idx %d\n", idx); if (topo_id == DS2_ADM_COPP_TOPOLOGY_ID) rc = msm_ds2_dap_set_custom_stereo_onoff (msm_bedais[be_index].port_id, @@ -23676,38 +23676,38 @@ static const int int4_mi2s_rx_vi_fb_tx_stereo_ch_value[] = { }; static const struct soc_enum slim0_rx_vi_fb_lch_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0, ARRAY_SIZE(slim0_rx_vi_fb_tx_lch_mux_text), slim0_rx_vi_fb_tx_lch_mux_text, slim0_rx_vi_fb_tx_lch_value); static const struct soc_enum slim0_rx_vi_fb_rch_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0, ARRAY_SIZE(slim0_rx_vi_fb_tx_rch_mux_text), slim0_rx_vi_fb_tx_rch_mux_text, slim0_rx_vi_fb_tx_rch_value); static const struct soc_enum wsa_rx_0_vi_fb_lch_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0, 0, 0, ARRAY_SIZE(wsa_rx_0_vi_fb_tx_lch_mux_text), wsa_rx_0_vi_fb_tx_lch_mux_text, wsa_rx_0_vi_fb_tx_lch_value); static const struct soc_enum wsa_rx_0_vi_fb_rch_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0, 0, 0, ARRAY_SIZE(wsa_rx_0_vi_fb_tx_rch_mux_text), wsa_rx_0_vi_fb_tx_rch_mux_text, wsa_rx_0_vi_fb_tx_rch_value); static const struct soc_enum mi2s_rx_vi_fb_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_PRI_MI2S_RX, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_PRI_MI2S_RX, 0, 0, ARRAY_SIZE(mi2s_rx_vi_fb_tx_mux_text), mi2s_rx_vi_fb_tx_mux_text, mi2s_rx_vi_fb_tx_value); static const struct soc_enum int4_mi2s_rx_vi_fb_mono_ch_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0, ARRAY_SIZE(int4_mi2s_rx_vi_fb_tx_mono_mux_text), int4_mi2s_rx_vi_fb_tx_mono_mux_text, int4_mi2s_rx_vi_fb_tx_mono_ch_value); static const struct soc_enum int4_mi2s_rx_vi_fb_stereo_ch_mux_enum = - SOC_VALUE_ENUM_DOUBLE(SND_SOC_NOPM, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0, + SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0, ARRAY_SIZE(int4_mi2s_rx_vi_fb_tx_stereo_mux_text), int4_mi2s_rx_vi_fb_tx_stereo_mux_text, int4_mi2s_rx_vi_fb_tx_stereo_ch_value); diff --git a/techpack/audio/4.0/asoc/msm-pcm-voip-v2.c b/techpack/audio/4.0/asoc/msm-pcm-voip-v2.c index 8b6c5ec4c9b1..0efe607bfd5c 100755 --- a/techpack/audio/4.0/asoc/msm-pcm-voip-v2.c +++ b/techpack/audio/4.0/asoc/msm-pcm-voip-v2.c @@ -364,6 +364,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, switch (prtd->mode) { case MODE_AMR_WB: case MODE_AMR: { + if (pkt_len <= DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* Remove the DSP frame info header. Header format: * Bits 0-3: Frame rate * Bits 4-7: Frame type @@ -384,6 +391,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, case MODE_4GV_NB: case MODE_4GV_WB: case MODE_4GV_NW: { + if (pkt_len <= DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* Remove the DSP frame info header. * Header format: * Bits 0-3: frame rate @@ -421,6 +435,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, buf_node->frame.frm_hdr.timestamp = timestamp; voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; + if (pkt_len <= 2 * DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* There are two frames in the buffer. Length of the * first frame: */ @@ -455,6 +476,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, (*voc_pkt) & 0x03; buf_node->frame.frm_hdr.timestamp = timestamp; voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; + if (pkt_len <= 2 * DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* There are two frames in the buffer. Length * of the second frame: diff --git a/techpack/audio/4.0/dsp/msm_audio_ion.c b/techpack/audio/4.0/dsp/msm_audio_ion.c index 056d540134a9..d5eebf4a517a 100755 --- a/techpack/audio/4.0/dsp/msm_audio_ion.c +++ b/techpack/audio/4.0/dsp/msm_audio_ion.c @@ -1,6 +1,17 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. + * + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #include @@ -70,6 +81,7 @@ static void msm_audio_ion_add_allocation( mutex_unlock(&(msm_audio_ion_data->list_mutex)); } +/* This function is called with ion_data list mutex lock */ static int msm_audio_dma_buf_map(struct dma_buf *dma_buf, dma_addr_t *addr, size_t *len) { @@ -157,7 +169,6 @@ static int msm_audio_dma_buf_unmap(struct dma_buf *dma_buf) * should be explicitly acquired to avoid race condition * on adding elements to the list. */ - mutex_lock(&(msm_audio_ion_data.list_mutex)); list_for_each_safe(ptr, next, &(msm_audio_ion_data.alloc_list)) { @@ -180,7 +191,6 @@ static int msm_audio_dma_buf_unmap(struct dma_buf *dma_buf) break; } } - mutex_unlock(&(msm_audio_ion_data.list_mutex)); if (!found) { dev_err(cb_dev, @@ -235,6 +245,7 @@ int msm_audio_ion_get_smmu_info(struct device **cb_dev, return 0; } +/* This function is called with ion_data list mutex lock */ static void *msm_audio_ion_map_kernel(struct dma_buf *dma_buf) { int rc = 0; @@ -283,7 +294,6 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) * TBD: remove the below section once new API * for unmapping kernel virtual address is available. */ - mutex_lock(&(msm_audio_ion_data.list_mutex)); list_for_each_entry(alloc_data, &(msm_audio_ion_data.alloc_list), list) { if (alloc_data->dma_buf == dma_buf) { @@ -291,7 +301,6 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) break; } } - mutex_unlock(&(msm_audio_ion_data.list_mutex)); if (!vaddr) { dev_err(cb_dev, @@ -314,7 +323,8 @@ err: return rc; } -static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, +/* This function is called with ion_data list mutex lock */ +static int msm_audio_ion_buf_map(struct dma_buf *dma_buf, dma_addr_t *paddr, size_t *plen, void **vaddr) { int rc = 0; @@ -331,7 +341,9 @@ static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, if (IS_ERR_OR_NULL(*vaddr)) { pr_err("%s: ION memory mapping for AUDIO failed\n", __func__); rc = -ENOMEM; + mutex_lock(&(msm_audio_ion_data.list_mutex)); msm_audio_dma_buf_unmap(dma_buf); + mutex_unlock(&(msm_audio_ion_data.list_mutex)); goto err; } @@ -390,7 +402,7 @@ int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz, goto err; } - rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr); + rc = msm_audio_ion_buf_map(*dma_buf, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); goto err; @@ -490,7 +502,7 @@ int msm_audio_ion_import(struct dma_buf **dma_buf, int fd, } } - rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr); + rc = msm_audio_ion_buf_map(*dma_buf, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); goto err; @@ -516,6 +528,7 @@ EXPORT_SYMBOL(msm_audio_ion_import); * * Returns 0 on success or error on failure */ + /* This funtion is called with ion_data list mutex lock */ int msm_audio_ion_free(struct dma_buf *dma_buf) { int ret = 0; @@ -525,11 +538,15 @@ int msm_audio_ion_free(struct dma_buf *dma_buf) return -EINVAL; } + mutex_lock(&(msm_audio_ion_data.list_mutex)); ret = msm_audio_ion_unmap_kernel(dma_buf); - if (ret) + if (ret) { + mutex_unlock(&(msm_audio_ion_data.list_mutex)); return ret; + } msm_audio_dma_buf_unmap(dma_buf); + mutex_unlock(&(msm_audio_ion_data.list_mutex)); return 0; } diff --git a/techpack/audio/4.0/dsp/q6adm.c b/techpack/audio/4.0/dsp/q6adm.c index 415259dc1f7f..a99ec43b4d99 100755 --- a/techpack/audio/4.0/dsp/q6adm.c +++ b/techpack/audio/4.0/dsp/q6adm.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -1526,7 +1527,7 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) { uint32_t *payload; int port_idx, copp_idx, idx, client_id; - int num_modules; + uint32_t num_modules; int ret; if (data == NULL) { diff --git a/techpack/audio/4.0/dsp/q6afe.c b/techpack/audio/4.0/dsp/q6afe.c index b07d4b5552e0..ae7c5217fb04 100755 --- a/techpack/audio/4.0/dsp/q6afe.c +++ b/techpack/audio/4.0/dsp/q6afe.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -468,23 +469,48 @@ static int32_t sp_make_afe_callback(uint32_t opcode, uint32_t *payload, switch (param_hdr.param_id) { case AFE_PARAM_ID_CALIB_RES_CFG_V2: expected_size += sizeof(struct asm_calib_res_cfg); + if (param_hdr.param_size != sizeof(struct asm_calib_res_cfg)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.calib_data; break; case AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS: expected_size += sizeof(struct afe_sp_th_vi_ftm_params); + if (param_hdr.param_size != sizeof(struct afe_sp_th_vi_ftm_params)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.th_vi_resp; break; case AFE_PARAM_ID_SP_V2_TH_VI_V_VALI_PARAMS: expected_size += sizeof(struct afe_sp_th_vi_v_vali_params); + if (param_hdr.param_size != sizeof(struct afe_sp_th_vi_v_vali_params)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.th_vi_v_vali_resp; break; case AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS: expected_size += sizeof(struct afe_sp_ex_vi_ftm_params); + if (param_hdr.param_size != sizeof(struct afe_sp_ex_vi_ftm_params)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.ex_vi_resp; break; case AFE_PARAM_ID_SP_RX_TMAX_XMAX_LOGGING: expected_size += sizeof( struct afe_sp_rx_tmax_xmax_logging_param); + if (param_hdr.param_size != sizeof(struct afe_sp_rx_tmax_xmax_logging_param)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.xt_logging_resp; break; default: @@ -7511,6 +7537,14 @@ static int afe_sidetone_iir(u16 tx_port_id) pr_debug("%s: adding 2 to size:%d\n", __func__, size); size = size + 2; } + + if (size > MAX_SIDETONE_IIR_DATA_SIZE) { + pr_err("%s: iir_config size is out of bounds:%d\n", __func__, size); + mutex_unlock(&this_afe.cal_data[cal_index]->lock); + ret = -EINVAL; + goto done; + } + memcpy(&filter_data.iir_config, &st_iir_cal_info->iir_config, size); mutex_unlock(&this_afe.cal_data[cal_index]->lock); diff --git a/techpack/audio/4.0/dsp/q6asm.c b/techpack/audio/4.0/dsp/q6asm.c index 5614c1ef8029..f75151ef7c73 100755 --- a/techpack/audio/4.0/dsp/q6asm.c +++ b/techpack/audio/4.0/dsp/q6asm.c @@ -2294,7 +2294,16 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv) struct audio_port_data *port = &ac->port[OUT]; config_debug_fs_read_cb(); - + + if (data->payload_size != (READDONE_IDX_SEQ_ID + 1) * sizeof(uint32_t)) { + pr_err("%s: payload size of %d is less than expected %d.\n", + __func__, data->payload_size, + ((READDONE_IDX_SEQ_ID + 1) * sizeof(uint32_t))); + spin_unlock_irqrestore( + &(session[session_id].session_lock), + flags); + return -EINVAL; + } dev_vdbg(ac->dev, "%s: ReadDone: status=%d buff_add=0x%x act_size=%d offset=%d\n", __func__, payload[READDONE_IDX_STATUS], payload[READDONE_IDX_BUFADD_LSW], @@ -2401,7 +2410,16 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv) __func__, data->payload_size); break; case ASM_SESSION_CMDRSP_GET_MTMX_STRTR_PARAMS_V2: - q6asm_process_mtmx_get_param_rsp(ac, (void *) payload); + payload_size = sizeof(struct asm_mtmx_strtr_get_params_cmdrsp); + if (data->payload_size < payload_size) { + pr_err("%s: insufficient payload size = %d\n", + __func__, data->payload_size); + spin_unlock_irqrestore( + &(session[session_id].session_lock), flags); + return -EINVAL; + } + q6asm_process_mtmx_get_param_rsp(ac, + (struct asm_mtmx_strtr_get_params_cmdrsp *) payload); break; case ASM_STREAM_PP_EVENT: case ASM_STREAM_CMD_ENCDEC_EVENTS: diff --git a/techpack/audio/4.0/dsp/q6core.c b/techpack/audio/4.0/dsp/q6core.c index 7a6d16fdfcfe..a02838eb0193 100755 --- a/techpack/audio/4.0/dsp/q6core.c +++ b/techpack/audio/4.0/dsp/q6core.c @@ -197,7 +197,7 @@ EXPORT_SYMBOL(q6core_send_uevent); static int parse_fwk_version_info(uint32_t *payload, uint16_t payload_size) { size_t ver_size; - int num_services; + uint16_t num_services; pr_debug("%s: Payload info num services %d\n", __func__, payload[4]); diff --git a/techpack/audio/4.0/dsp/q6lsm.c b/techpack/audio/4.0/dsp/q6lsm.c index 8ad6ed624002..058e8a8e8666 100755 --- a/techpack/audio/4.0/dsp/q6lsm.c +++ b/techpack/audio/4.0/dsp/q6lsm.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2013-2019, Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -405,6 +406,10 @@ static int q6lsm_apr_send_pkt(struct lsm_client *client, void *handle, } pr_debug("%s: enter wait %d\n", __func__, wait); + if (mmap_handle_p) { + pr_debug("%s: Invalid mmap_handle\n", __func__); + return -EINVAL; + } if (wait) mutex_lock(&lsm_common.apr_lock); if (mmap_p) { @@ -450,6 +455,7 @@ static int q6lsm_apr_send_pkt(struct lsm_client *client, void *handle, if (mmap_p && *mmap_p == 0) ret = -ENOMEM; + mmap_handle_p = NULL; pr_debug("%s: leave ret %d\n", __func__, ret); return ret; } @@ -1910,7 +1916,8 @@ static int q6lsm_mmapcallback(struct apr_client_data *data, void *priv) case LSM_SESSION_CMDRSP_SHARED_MEM_MAP_REGIONS: if (atomic_read(&client->cmd_state) == CMD_STATE_WAIT_RESP) { spin_lock_irqsave(&mmap_lock, flags); - *mmap_handle_p = command; + if (mmap_handle_p) + *mmap_handle_p = command; /* spin_unlock_irqrestore implies barrier */ spin_unlock_irqrestore(&mmap_lock, flags); atomic_set(&client->cmd_state, CMD_STATE_CLEARED); diff --git a/techpack/audio/4.0/dsp/q6voice.c b/techpack/audio/4.0/dsp/q6voice.c index 52edf39708f8..af3cd885faa4 100755 --- a/techpack/audio/4.0/dsp/q6voice.c +++ b/techpack/audio/4.0/dsp/q6voice.c @@ -2769,6 +2769,13 @@ static int voice_send_cvs_register_cal_cmd(struct voice_data *v) goto unlock; } + if (col_data->cal_data.size >= MAX_COL_INFO_SIZE) { + pr_err("%s: Invalid cal data size %d!\n", + __func__, col_data->cal_data.size); + ret = -EINVAL; + goto unlock; + } + memcpy(&cvs_reg_cal_cmd.cvs_cal_data.column_info[0], (void *) &((struct audio_cal_info_voc_col *) col_data->cal_info)->data, diff --git a/techpack/audio/4.0/include/dsp/q6asm-v2.h b/techpack/audio/4.0/include/dsp/q6asm-v2.h index be5a06e910b2..90e9c95eeda6 100755 --- a/techpack/audio/4.0/include/dsp/q6asm-v2.h +++ b/techpack/audio/4.0/include/dsp/q6asm-v2.h @@ -144,6 +144,9 @@ enum { SOFT_PAUSE_CURVE_LOG, }; +#ifdef CONFIG_SND_SOC_SAMSUNG_AUDIO +#define SOFT_VOLUME_MMAP_PERIOD 0 /* ramp up/down for mmap 0ms */ +#endif #define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */ #define SOFT_VOLUME_STEP 0 /* Step value 0ms or 0us */ enum { diff --git a/techpack/audio/asoc/msm-audio-effects-q6-v2.c b/techpack/audio/asoc/msm-audio-effects-q6-v2.c index dc94c3d872ed..9b4f56418e28 100755 --- a/techpack/audio/asoc/msm-audio-effects-q6-v2.c +++ b/techpack/audio/asoc/msm-audio-effects-q6-v2.c @@ -957,6 +957,15 @@ int msm_audio_effects_pbe_handler(struct audio_client *ac, rc = -EINVAL; goto invalid_config; } + + if ((pbe->config.bandpass_filter_order > 3) || + (pbe->config.bandpass_filter_order < 1)) { + pr_err("%s: Invalid BPF order\n", + __func__); + rc = -EINVAL; + goto invalid_config; + } + if (command_config_state != CONFIG_SET) break; max_params_length = diff --git a/techpack/audio/asoc/msm-pcm-host-voice-v2.c b/techpack/audio/asoc/msm-pcm-host-voice-v2.c index 7486ad7dc80c..d176bdc00aab 100755 --- a/techpack/audio/asoc/msm-pcm-host-voice-v2.c +++ b/techpack/audio/asoc/msm-pcm-host-voice-v2.c @@ -1,4 +1,5 @@ /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -618,6 +619,12 @@ static int hpcm_start_vocpcm(char *pcm_id, struct hpcm_drv *prtd, } } + if (*no_of_tp != no_of_tp_req && *no_of_tp > 2) { + pr_err("%s:: Invalid hpcm start request\n", __func__); + memset(&prtd->start_cmd, 0, sizeof(struct start_cmd)); + return -EINVAL; + } + if (prtd->mixer_conf.tx.enable && (get_tappnt_value(pcm_id) == TX)) { if (hpcm_all_dais_are_ready(prtd->mixer_conf.tx.direction, tp, HPCM_PREPARED)) { @@ -662,6 +669,11 @@ static void hpcm_copy_playback_data_from_queue(struct dai_data *dai_data, struct hpcm_buf_node, list); list_del(&buf_node->list); *len = buf_node->frame.len; + if (*len > HPCM_MAX_VOC_PKT_SIZE) { + pr_err("%s: Playback data len %d overflow\n", + __func__, *len); + return; + } memcpy((u8 *)dai_data->vocpcm_ion_buffer.kvaddr, &buf_node->frame.voc_pkt[0], buf_node->frame.len); @@ -689,6 +701,12 @@ static void hpcm_copy_capture_data_to_queue(struct dai_data *dai_data, if (dai_data->substream == NULL) return; + if (len > HPCM_MAX_VOC_PKT_SIZE) { + pr_err("%s: Copy capture data len %d overflow\n", + __func__, len); + return; + } + /* Copy out buffer packet into free_queue */ spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); @@ -731,6 +749,13 @@ void hpcm_notify_evt_processing(uint8_t *data, char *session, return; } + if (prtd->mixer_conf.sess_indx < VOICE_INDEX || + prtd->mixer_conf.sess_indx >= MAX_SESSION) { + pr_err("%s:: Invalid session idx %d\n", + __func__, prtd->mixer_conf.sess_indx); + return; + } + if (notify_evt->tap_point == VSS_IVPCM_TAP_POINT_TX_DEFAULT) { tp = &prtd->session[prtd->mixer_conf.sess_indx].tx_tap_point; tmd = &prtd->mixer_conf.tx; diff --git a/techpack/audio/asoc/msm-pcm-q6-noirq.c b/techpack/audio/asoc/msm-pcm-q6-noirq.c index 7ef99e72a89f..d8df0fcccd14 100755 --- a/techpack/audio/asoc/msm-pcm-q6-noirq.c +++ b/techpack/audio/asoc/msm-pcm-q6-noirq.c @@ -609,7 +609,11 @@ static int msm_pcm_prepare(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct msm_audio *prtd = runtime->private_data; struct asm_softvolume_params softvol = { +#ifdef CONFIG_SND_SOC_SAMSUNG_AUDIO + .period = SOFT_VOLUME_MMAP_PERIOD, +#else .period = SOFT_VOLUME_PERIOD, +#endif .step = SOFT_VOLUME_STEP, .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, }; diff --git a/techpack/audio/asoc/msm-pcm-q6-v2.c b/techpack/audio/asoc/msm-pcm-q6-v2.c index 6fd99faade31..8470fc0e3670 100755 --- a/techpack/audio/asoc/msm-pcm-q6-v2.c +++ b/techpack/audio/asoc/msm-pcm-q6-v2.c @@ -998,6 +998,13 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, xfer = size; offset = prtd->in_frame_info[idx].offset; pr_debug("Offset value = %d\n", offset); + if (offset >= size) { + pr_err("%s: Invalid dsp buf offset\n", __func__); + ret = -EFAULT; + q6asm_cpu_buf_release(OUT, prtd->audio_client); + goto fail; + } + if (copy_to_user(buf, bufptr+offset, xfer)) { pr_err("Failed to copy buf to user\n"); ret = -EFAULT; diff --git a/techpack/audio/asoc/msm-pcm-voip-v2.c b/techpack/audio/asoc/msm-pcm-voip-v2.c index 9a14fbfae6c3..f86f1f833eaf 100755 --- a/techpack/audio/asoc/msm-pcm-voip-v2.c +++ b/techpack/audio/asoc/msm-pcm-voip-v2.c @@ -372,6 +372,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, switch (prtd->mode) { case MODE_AMR_WB: case MODE_AMR: { + if (pkt_len <= DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* Remove the DSP frame info header. Header format: * Bits 0-3: Frame rate * Bits 4-7: Frame type @@ -392,6 +399,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, case MODE_4GV_NB: case MODE_4GV_WB: case MODE_4GV_NW: { + if (pkt_len <= DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* Remove the DSP frame info header. * Header format: * Bits 0-3: frame rate @@ -429,6 +443,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, buf_node->frame.frm_hdr.timestamp = timestamp; voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; + if (pkt_len <= 2 * DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* There are two frames in the buffer. Length of the * first frame: */ @@ -463,6 +484,13 @@ static void voip_process_ul_pkt(uint8_t *voc_pkt, (*voc_pkt) & 0x03; buf_node->frame.frm_hdr.timestamp = timestamp; voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; + if (pkt_len <= 2 * DSP_FRAME_HDR_LEN) { + pr_err("%s: pkt_len %d is < required len\n", + __func__, pkt_len); + spin_unlock_irqrestore(&prtd->dsp_ul_lock, + dsp_flags); + return; + } /* There are two frames in the buffer. Length * of the second frame: diff --git a/techpack/audio/dsp/msm_audio_ion.c b/techpack/audio/dsp/msm_audio_ion.c index 1dec33e33f13..8c9e0a73a1df 100755 --- a/techpack/audio/dsp/msm_audio_ion.c +++ b/techpack/audio/dsp/msm_audio_ion.c @@ -1,6 +1,8 @@ /* * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. * + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. @@ -78,6 +80,7 @@ static void msm_audio_ion_add_allocation( mutex_unlock(&(msm_audio_ion_data->list_mutex)); } +/* This function is called with ion_data list mutex lock */ static int msm_audio_dma_buf_map(struct dma_buf *dma_buf, dma_addr_t *addr, size_t *len) { @@ -165,7 +168,6 @@ static int msm_audio_dma_buf_unmap(struct dma_buf *dma_buf) * should be explicitly acquired to avoid race condition * on adding elements to the list. */ - mutex_lock(&(msm_audio_ion_data.list_mutex)); list_for_each_safe(ptr, next, &(msm_audio_ion_data.alloc_list)) { @@ -188,7 +190,6 @@ static int msm_audio_dma_buf_unmap(struct dma_buf *dma_buf) break; } } - mutex_unlock(&(msm_audio_ion_data.list_mutex)); if (!found) { dev_err(cb_dev, @@ -243,6 +244,7 @@ int msm_audio_ion_get_smmu_info(struct device **cb_dev, return 0; } +/* This function is called with ion_data list mutex lock */ static void *msm_audio_ion_map_kernel(struct dma_buf *dma_buf) { int rc = 0; @@ -291,7 +293,6 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) * TBD: remove the below section once new API * for unmapping kernel virtual address is available. */ - mutex_lock(&(msm_audio_ion_data.list_mutex)); list_for_each_entry(alloc_data, &(msm_audio_ion_data.alloc_list), list) { if (alloc_data->dma_buf == dma_buf) { @@ -299,7 +300,6 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf) break; } } - mutex_unlock(&(msm_audio_ion_data.list_mutex)); if (!vaddr) { dev_err(cb_dev, @@ -322,7 +322,8 @@ err: return rc; } -static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, +/* This function is called with ion_data list mutex lock */ +static int msm_audio_ion_buf_map(struct dma_buf *dma_buf, dma_addr_t *paddr, size_t *plen, void **vaddr) { int rc = 0; @@ -339,7 +340,9 @@ static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr, if (IS_ERR_OR_NULL(*vaddr)) { pr_err("%s: ION memory mapping for AUDIO failed\n", __func__); rc = -ENOMEM; + mutex_lock(&(msm_audio_ion_data.list_mutex)); msm_audio_dma_buf_unmap(dma_buf); + mutex_unlock(&(msm_audio_ion_data.list_mutex)); goto err; } @@ -398,7 +401,7 @@ int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz, goto err; } - rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr); + rc = msm_audio_ion_buf_map(*dma_buf, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); goto err; @@ -498,7 +501,7 @@ int msm_audio_ion_import(struct dma_buf **dma_buf, int fd, } } - rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr); + rc = msm_audio_ion_buf_map(*dma_buf, paddr, plen, vaddr); if (rc) { pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc); goto err; @@ -524,6 +527,7 @@ EXPORT_SYMBOL(msm_audio_ion_import); * * Returns 0 on success or error on failure */ + /* This funtion is called with ion_data list mutex lock */ int msm_audio_ion_free(struct dma_buf *dma_buf) { int ret = 0; @@ -533,11 +537,15 @@ int msm_audio_ion_free(struct dma_buf *dma_buf) return -EINVAL; } + mutex_lock(&(msm_audio_ion_data.list_mutex)); ret = msm_audio_ion_unmap_kernel(dma_buf); - if (ret) + if (ret) { + mutex_unlock(&(msm_audio_ion_data.list_mutex)); return ret; + } msm_audio_dma_buf_unmap(dma_buf); + mutex_unlock(&(msm_audio_ion_data.list_mutex)); return 0; } diff --git a/techpack/audio/dsp/q6adm.c b/techpack/audio/dsp/q6adm.c index a7d4a378d896..7f7e0bff265a 100755 --- a/techpack/audio/dsp/q6adm.c +++ b/techpack/audio/dsp/q6adm.c @@ -1,4 +1,5 @@ /* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1563,7 +1564,7 @@ static int32_t adm_callback(struct apr_client_data *data, void *priv) { uint32_t *payload; int port_idx, copp_idx, idx, client_id; - int num_modules; + uint32_t num_modules; int ret; if (data == NULL) { diff --git a/techpack/audio/dsp/q6afe.c b/techpack/audio/dsp/q6afe.c index c21ecc908e12..5644cad72204 100755 --- a/techpack/audio/dsp/q6afe.c +++ b/techpack/audio/dsp/q6afe.c @@ -1,4 +1,5 @@ /* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -393,6 +394,11 @@ static int32_t sp_make_afe_callback(uint32_t opcode, uint32_t *payload, return -EINVAL; } expected_size += sizeof(struct param_hdr_v3); + if (payload_size < expected_size) { + pr_err("%s: Error: size %d is less than expected\n", + __func__, payload_size); + return -EINVAL; + } memcpy(¶m_hdr, &payload[1], sizeof(struct param_hdr_v3)); data_start = &payload[5]; break; @@ -404,24 +410,49 @@ static int32_t sp_make_afe_callback(uint32_t opcode, uint32_t *payload, switch (param_hdr.param_id) { case AFE_PARAM_ID_CALIB_RES_CFG_V2: expected_size += sizeof(struct asm_calib_res_cfg); + if (param_hdr.param_size != sizeof(struct asm_calib_res_cfg)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.calib_data; break; case AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS: expected_size += sizeof(struct afe_sp_th_vi_ftm_params); + if (param_hdr.param_size != sizeof(struct afe_sp_th_vi_ftm_params)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.th_vi_resp; break; case AFE_PARAM_ID_SP_V2_TH_VI_V_VALI_PARAMS: pr_err("%s: got response pkt\n", __func__); expected_size += sizeof(struct afe_sp_th_vi_v_vali_params); + if (param_hdr.param_size != sizeof(struct afe_sp_th_vi_v_vali_params)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.th_vi_v_vali_resp; break; case AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS: expected_size += sizeof(struct afe_sp_ex_vi_ftm_params); + if (param_hdr.param_size != sizeof(struct afe_sp_ex_vi_ftm_params)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.ex_vi_resp; break; case AFE_PARAM_ID_SP_RX_TMAX_XMAX_LOGGING: expected_size += sizeof( struct afe_sp_rx_tmax_xmax_logging_param); + if (param_hdr.param_size != sizeof(struct afe_sp_rx_tmax_xmax_logging_param)) { + pr_err("%s: Error: param_size %d is greater than expected\n", + __func__,param_hdr.param_size); + return -EINVAL; + } data_dest = (u32 *) &this_afe.xt_logging_resp; break; default: @@ -6924,6 +6955,14 @@ static int afe_sidetone_iir(u16 tx_port_id) pr_debug("%s: adding 2 to size:%d\n", __func__, size); size = size + 2; } + + if (size > MAX_SIDETONE_IIR_DATA_SIZE) { + pr_err("%s: iir_config size is out of bounds:%d\n", __func__, size); + mutex_unlock(&this_afe.cal_data[cal_index]->lock); + ret = -EINVAL; + goto done; + } + memcpy(&filter_data.iir_config, &st_iir_cal_info->iir_config, size); mutex_unlock(&this_afe.cal_data[cal_index]->lock); @@ -9262,4 +9301,4 @@ void afe_set_lsm_afe_port_id(int idx, int lsm_port) } this_afe.lsm_afe_ports[idx] = lsm_port; } -EXPORT_SYMBOL(afe_set_lsm_afe_port_id); \ No newline at end of file +EXPORT_SYMBOL(afe_set_lsm_afe_port_id); diff --git a/techpack/audio/dsp/q6asm.c b/techpack/audio/dsp/q6asm.c index 4b9c877fa5f0..cafaa986eb9f 100755 --- a/techpack/audio/dsp/q6asm.c +++ b/techpack/audio/dsp/q6asm.c @@ -2261,7 +2261,16 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv) struct audio_port_data *port = &ac->port[OUT]; config_debug_fs_read_cb(); - + + if (data->payload_size != (READDONE_IDX_SEQ_ID + 1) * sizeof(uint32_t)) { + pr_err("%s: payload size of %d is less than expected %d.\n", + __func__, data->payload_size, + ((READDONE_IDX_SEQ_ID + 1) * sizeof(uint32_t))); + spin_unlock_irqrestore( + &(session[session_id].session_lock), + flags); + return -EINVAL; + } dev_vdbg(ac->dev, "%s: ReadDone: status=%d buff_add=0x%x act_size=%d offset=%d\n", __func__, payload[READDONE_IDX_STATUS], payload[READDONE_IDX_BUFADD_LSW], @@ -2367,7 +2376,16 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv) __func__, data->payload_size); break; case ASM_SESSION_CMDRSP_GET_MTMX_STRTR_PARAMS_V2: - q6asm_process_mtmx_get_param_rsp(ac, (void *) payload); + payload_size = sizeof(struct asm_mtmx_strtr_get_params_cmdrsp); + if (data->payload_size < payload_size) { + pr_err("%s: insufficient payload size = %d\n", + __func__, data->payload_size); + spin_unlock_irqrestore( + &(session[session_id].session_lock), flags); + return -EINVAL; + } + q6asm_process_mtmx_get_param_rsp(ac, + (struct asm_mtmx_strtr_get_params_cmdrsp *) payload); break; case ASM_STREAM_PP_EVENT: case ASM_STREAM_CMD_ENCDEC_EVENTS: diff --git a/techpack/audio/dsp/q6core.c b/techpack/audio/dsp/q6core.c index 596e9ee63bc7..c16e7db1efeb 100755 --- a/techpack/audio/dsp/q6core.c +++ b/techpack/audio/dsp/q6core.c @@ -196,7 +196,7 @@ EXPORT_SYMBOL(q6core_send_uevent); static int parse_fwk_version_info(uint32_t *payload, uint16_t payload_size) { size_t ver_size; - int num_services; + uint16_t num_services; pr_debug("%s: Payload info num services %d\n", __func__, payload[4]); diff --git a/techpack/audio/dsp/q6lsm.c b/techpack/audio/dsp/q6lsm.c index aa864ddbee7b..fdff509e594d 100755 --- a/techpack/audio/dsp/q6lsm.c +++ b/techpack/audio/dsp/q6lsm.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2013-2019, Linux Foundation. All rights reserved. * + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. @@ -400,6 +401,10 @@ static int q6lsm_apr_send_pkt(struct lsm_client *client, void *handle, } pr_debug("%s: enter wait %d\n", __func__, wait); + if (mmap_handle_p) { + pr_debug("%s: Invalid mmap_handle\n", __func__); + return -EINVAL; + } if (wait) mutex_lock(&lsm_common.apr_lock); if (mmap_p) { @@ -443,6 +448,7 @@ static int q6lsm_apr_send_pkt(struct lsm_client *client, void *handle, if (wait) mutex_unlock(&lsm_common.apr_lock); + mmap_handle_p = NULL; pr_debug("%s: leave ret %d\n", __func__, ret); return ret; } @@ -1832,7 +1838,8 @@ static int q6lsm_mmapcallback(struct apr_client_data *data, void *priv) case LSM_SESSION_CMDRSP_SHARED_MEM_MAP_REGIONS: if (atomic_read(&client->cmd_state) == CMD_STATE_WAIT_RESP) { spin_lock_irqsave(&mmap_lock, flags); - *mmap_handle_p = command; + if (mmap_handle_p) + *mmap_handle_p = command; /* spin_unlock_irqrestore implies barrier */ spin_unlock_irqrestore(&mmap_lock, flags); atomic_set(&client->cmd_state, CMD_STATE_CLEARED); diff --git a/techpack/audio/dsp/q6voice.c b/techpack/audio/dsp/q6voice.c index d8e810ffa761..a8d735976de0 100755 --- a/techpack/audio/dsp/q6voice.c +++ b/techpack/audio/dsp/q6voice.c @@ -2654,6 +2654,13 @@ static int voice_send_cvs_register_cal_cmd(struct voice_data *v) goto unlock; } + if (col_data->cal_data.size >= MAX_COL_INFO_SIZE) { + pr_err("%s: Invalid cal data size %d!\n", + __func__, col_data->cal_data.size); + ret = -EINVAL; + goto unlock; + } + memcpy(&cvs_reg_cal_cmd.cvs_cal_data.column_info[0], (void *) &((struct audio_cal_info_voc_col *) col_data->cal_info)->data, diff --git a/techpack/audio/include/dsp/q6asm-v2.h b/techpack/audio/include/dsp/q6asm-v2.h index 7f4d900c7934..ac0dd39b9ca3 100755 --- a/techpack/audio/include/dsp/q6asm-v2.h +++ b/techpack/audio/include/dsp/q6asm-v2.h @@ -151,6 +151,9 @@ enum { SOFT_PAUSE_CURVE_LOG, }; +#ifdef CONFIG_SND_SOC_SAMSUNG_AUDIO +#define SOFT_VOLUME_MMAP_PERIOD 0 /* ramp up/down for mmap 0ms */ +#endif #define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */ #define SOFT_VOLUME_STEP 0 /* Step value 0ms or 0us */ enum {