Commit Graph

286 Commits

Author SHA1 Message Date
Joakim Zhang 0612dea846 MLK-22215 mxc: emvsim: correct irq mask and clear irq status before receiving
Just clean up the code and normalize the code.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:48:01 +08:00
Joakim Zhang 88a1ff5c08 MLK-22214 mxc: emvsim: clean up the code in ATR stage
Clean up the code in ATR stage.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:59 +08:00
Joakim Zhang 05d7253157 MLK-22213 mxc: emvsim: read TS character before updating value of GPCNT1
Should read TS character before updating value of GPCNT1, because TS
character will also cost 12 etus.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:58 +08:00
Joakim Zhang f0fba896a3 MLK-22211 mxc: emvsim: should not clear PEF/FEF flag in irq handler
Shouldn't clear PEF/FEF flag in irq handler as they are just a flag which
can't trigger interrupt. And they will be check later in irq handler.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:57 +08:00
Joakim Zhang c79402071a MLK-22210 mxc: emvsim: enable ICM mode
Once detected a valid TS, the ICM bit is cleared and the data format bit,
IC bit , is set to appropriate value depending on the data format
detected using the initial character.

When TS is 0x3B (direct convention) in cold reset, and then become 0x3F
(inverse convention) in warm reset, it will not in ICM mode.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:57 +08:00
Gao Pan 557037b6bd MLK-18485 emvsim: enable CWT for ATR
Enable CWT for ATR, and switch to RX_DATA_IM to detect receiving data
in fifo.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:56 +08:00
Gao Pan 4265cbdb4b MLK-17416 imx8: sim: add usleep_range() before reading SPDP Bit
Card Presence Detect Status Bit SPDP in EMV_SIM_PCSR is
synchronized by two posedge of low_ref_clk which is 32KHz.

So there should be 1.5 low_ref_clk cycles(about 90us) before
reading SPDP Bit.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:56 +08:00
Gao Pan bbc881815d MLK-17319-1 imx8: sim: add driver to support EMVSIM module
The EMVSIM module is designed to facilitate communication to
Smart Cards compatible to the EMV ver4.3 standard and compatible
with ISO/IEC 7816-3 Standard.

This patch adds driver to support EMVSIM module for imx8.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Reviewed-by: Andy Duan <fugang.duan@nxp.com>
2019-11-25 15:47:55 +08:00
Julien Olivain c0fa458f65 MLK-13473: imx_sim: fix module device table name
This fixes the build when this driver is built as a module, when
CONFIG_MXC_SIM=m

Signed-off-by: Julien Olivain <julien.olivain@nxp.com>
2019-11-25 15:47:55 +08:00
Gao Pan 3135b8110b MLK-14642 imx: sim: fix segment fault caused by user address access
Kernel space cannot access user space memory directly.
In fact, the issue always exited. Since 4.4, the kernel
handle the action as page abort.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:54 +08:00
Gao Pan 34a04d8706 MLK-11472 sim: imx: set sim1 IOMUX to default state
SIM1 IOMUX is changed into reset state in LPSR mode.As a result,
sim can't work again.

This patch sets sim1 IOMUX to default state after existing from LPSR mode.

(cherry-picked from commit 8e237775cd413645bfd806e4c648954e1a773a2d)

Signed-off-by: Gao Pan <b54642@freescale.com>
2019-11-25 15:47:54 +08:00
Gao Pan 957de2871d MLK-11777 sim: imx: remove useless code
sim_activate() process is contained in the cold reset.
Thus, it is redundant and should be removed.

This patch also adds comments to cold reset process.

Signed-off-by: Gao Pan <b54642@freescale.com>
2019-11-25 15:47:54 +08:00
Gao Pan 44ab966c17 MLK-11354 sim: imx: relapce devm_request_and_ioremap with devm_ioremap_resource
The API devm_request_and_ioremap meets compile error
on branch imx_4.1.y. It is recommend to replace the api
with devm_ioremap_resource.

Signed-off-by: Gao Pan <b54642@freescale.com>
2019-11-25 15:47:53 +08:00
Luwei Zhou 1305ce8ff1 MLK-10976: mxc: sim: Using timer interrupt to implement precise timing.
The EMV4.3 has strict requirement about the reset sequence. The old code use the mdelay, udelay to
achievet, which is not precise enough. Replace it with the timer interrupt. The EMV4.3 requires
40000~45000 clock cycles duration when reset is low.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from a006fe283c8b97f0a711cb0829bfbdaaf4a5f31f)
2019-11-25 15:47:53 +08:00
Luwei Zhou 81d3ff9421 MLK-10968: mxc: sim: Add the init delay detection function in the driver.
In EMV4.3 after warm/cold reset, there would be a receiving window. The receiving
window would be 42000 clock length.If the receiving window expires without receiving
one byte, IFD need to take actions as EMV4.3 spec. The driver need to support this
to identify the sequence of the receiving window expiring event and the receiving event.
Since theinterrupt latency in linux OS is not certain, we need to tune this setting to
pass the cases. Current tuning parameter can work.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from faf1d8d881a6ad2c6b88fdf312cef142996937c1)
2019-11-25 15:47:52 +08:00
Luwei Zhou 0d5d107690 MLK-10959: mxc: sim: Disable cwt timer when tx and enable in rx.
The CWT timer is used to detect the the character interval in the data traffic.
When tx, SIM IP can guarantee the interval based our setting. When RX, we need
to enalbe the CWT timer to check whether the interval is in the range. This patch
fix this.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from 9c92dfd070e7427eb1e0166f368b89b4a7ac1bff)
2019-11-25 15:47:52 +08:00
Luwei Zhou 50b2602a93 MLK-10913-1: mxc: sim: Add the SIM driver support for i.MX6UL-EVK platform.
Modify the driver to support the SIM on i.MX6UL-EVK platform. The main modification is:
1. Add port index to support different port on platform.
2. Add POS-CARD support. The POS card has external IC to assert when SVEN to low. Add support.
3. Using a function to calculate the strict timing delay.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from 17d1315b0704e2db63ee6bd7aaefa0c796f53104)
2019-11-25 15:47:51 +08:00
Luwei Zhou 3867b4bd9f MLK-10600-2: mxc: sim: add an option to enable SIM driver build
Add the option to enable SIM driver build.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
Signed-off-by: Gao Pan <b45643@freescale.com>
(cherry picked from 0f7a6fa3c141bfc7333d9056639b7a5b1154ed1d)
2019-11-25 15:47:50 +08:00
Luwei Zhou fb80f7afe2 MLK-10600-1: mxc: sim: Add SIM IP driver support on the i.MX7d-12x12-arm2 platform.
This driver is based on the current code which runs the the EMV test on the i.MX258 platform.
Since there are still many cases that can't pass on the i.MX258 and i.MX7d platform. The
driver will need to be improved after per-test work. Just check in as a base code. There
would be definitly some timing improvement work to do in the future.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from 3ac1ad5b2a68ecb052ccacca4ac7459ead04415e)
2019-11-25 15:47:50 +08:00
ming_qian bcaa7c17aa LF-80:[8QM_MEK/8QXP_MEK]mxc:vpu_malone:clear eos flag when output streamoff
if the eos flag is not clear after output streamoff,
it may cause firmware hang with multi instances

Signed-off-by: ming_qian <ming.qian@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Reviewed-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:47 +08:00
ming_qian c521bad20c MLK-22999 mxc: vpu_malone: release debugfs after open to avoid memory leak
VPU decoder driver create some debug fs,
but don't set the release function,
in open function, it will alloc some memory,
it should be freed when release function is called.
otherwise, memory will be leaked.

Signed-off-by: ming_qian <ming.qian@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Reviewed-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:47 +08:00
Shijie Qin 9fde70430f MLK-22991 mxc: vpu_malone vpu_windsor: check is vpu poweroff when suspend
the csr register 'CM0Px_CPUWAIT' will be cleared to '1' after
reset(poweroff then poweron), hence we could check is vpu poweroff
when suspend according to this value.

Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
Reviewed-by: ming_qian <ming.qian@nxp.com>
Acked-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:46 +08:00
ming_qian 8801852a4c MLK-22963 mxc vpu_windsor: fix call vzalloc during spinlock
platform vzalloc may call wait_completion to sleep,
but sleep is forbidden during spinlock,
so use mutex instead

Signed-off-by: ming_qian <ming.qian@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Acked-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:45 +08:00
ming_qian 23f0876ea4 MLK-22945 mxc vpu_malone: disable decode ctx before release it.
If close is called without calling streamoff,
the status of decode is enable,
some buffer status may be wrong.
disable before release it will avoid such error.

Signed-off-by: ming_qian <ming.qian@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Acked-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:45 +08:00
Zhou Peng 0775816459 vpu: hantro: Fix kconfig to depend on ARCH_MXC instead
Replace ARCH_FSL_IMX8MQ with ARCH_MXC in hantro 850 Kconfig

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:45 +08:00
Julien Olivain cd5340e7f6 MLK-22952 mxc: vpu_windsor: add missing semicolon
Add a missing semicolon. This missing semicolon is not breaking the
build in defconfig since the next MODULE_DEVICE_TABLE() expand to an
empty string, so the next semicolon is used. When this macro expands
to a non-empty string, the build breaks. This was found by a
"make allmodconfig" build.

Signed-off-by: Julien Olivain <julien.olivain@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Acked-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:44 +08:00
Julien Olivain d1a0de782c MLK-22951 mxc: vpu_malone: add missing semicolon
Add a missing semicolon. This missing semicolon is not breaking the
build in defconfig since the next MODULE_DEVICE_TABLE() expand to an
empty string, so the next semicolon is used. When this macro expands
to a non-empty string, the build breaks. This was found by a
"make allmodconfig" build.

Signed-off-by: Julien Olivain <julien.olivain@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Acked-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:44 +08:00
Leonard Crestez 874558fb16 vpu: hantro: Fix kconfig to depend on ARCH_MXC instead
Upstream rejected per-SOC kconfig symbols such as CONFIG_ARCH_FSL_IMX8MQ
so just use CONFIG_ARCH_MXC instead.

There is already an ARM64 check in drivers/mxc/Kconfig so this
shouldn't change anything except that we can drop CONFIG_ARCH_FSL_IMX8MQ
from linux-nxp tree.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Acked-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:44 +08:00
ming_qian 008627cc26 MLK-22920 vpu: windsor encoder: change the writeable flag synchronously
If the writeable flag is not change synchronously,
the flag may not changed correct,
it'll case the encode stream hang.
It's likely to happen when small resolution stream do suspend.

Signed-off-by: ming_qian <ming.qian@nxp.com>
Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
2019-11-25 15:47:43 +08:00
Shijie Qin 23401f11ca MLK-22913 vpu: windsor malone: fix kernel panic caused by directly read MU
- After switch to use mailbox, shall not read MU register directly
- VPU shall always poweroff when suspend, hence related check
  unnecessary.
- Remain the API to unify code of 4.19 kernel version

[  123.773671] Call trace:
[  123.776123]  vpu_resume+0x90/0x1d8
[  123.779534]  platform_pm_resume+0x24/0x48
[  123.783542]  dpm_run_callback.isra.15+0x38/0xec
[  123.788075]  device_resume+0x74/0x11c
[  123.791740]  dpm_resume+0xdc/0x20c
[  123.795144]  dpm_resume_end+0x14/0x28
[  123.798809]  suspend_devices_and_enter+0x190/0x5a4
[  123.803596]  pm_suspend+0x258/0x320
[  123.807091]  state_store+0x84/0x108
[  123.810581]  kobj_attr_store+0x14/0x24
[  123.814333]  sysfs_kf_write+0x40/0x48
[  123.817993]  kernfs_fop_write+0xe8/0x1e4
[  123.821916]  __vfs_write+0x18/0x3c
[  123.825318]  vfs_write+0xb8/0x1ac
[  123.828634]  ksys_write+0x60/0xd8
[  123.831946]  __arm64_sys_write+0x18/0x20
[  123.835879]  el0_svc_common.constprop.2+0xb0/0x160
[  123.840669]  el0_svc_handler+0x20/0x7c
[  123.844422]  el0_svc+0x8/0x640
[  123.847484] Code: d65f03c0 f940d296 914042d6 910092d6 (b94002d6)
[  123.853581] ---[ end trace d17f2f7d780f8e3f ]---

Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
Reviewed-by: Zhou Peng <eagle.zhou@nxp.com>
Reviewed-by: ming_qian <ming.qian@nxp.com>
2019-11-25 15:47:42 +08:00
Shijie Qin b8ce664bea vpu: windor encoder: malone decoder: fix kernel panic caused by MU_Init
- Remove MU_Init() and other related operations after switch to
  mailbox
- Remain API for unify code between 4.19 and 5.x

[   30.052738] Call trace:
[   30.055182]  MU_Init+0x10/0x80
[   30.058237]  vpu_resume+0x48/0x1e8
[   30.061638]  platform_pm_resume+0x24/0x60
[   30.065653]  dpm_run_callback.isra.16+0x1c/0x70
[   30.070186]  device_resume+0x88/0x148
[   30.073850]  dpm_resume+0xd4/0x1e0
[   30.077253]  dpm_resume_end+0x14/0x28
[   30.080918]  suspend_devices_and_enter+0x14c/0x500
[   30.085706]  pm_suspend+0x1f4/0x260
[   30.089194]  state_store+0x84/0xf0
[   30.092603]  kobj_attr_store+0x14/0x28
[   30.096357]  sysfs_kf_write+0x48/0x58
[   30.100016]  kernfs_fop_write+0xe0/0x1f8
[   30.103940]  __vfs_write+0x18/0x40
[   30.107339]  vfs_write+0x19c/0x1f0
[   30.110738]  ksys_write+0x64/0xf0
[   30.114054]  __arm64_sys_write+0x14/0x20
[   30.117989]  el0_svc_common.constprop.2+0xb0/0x168
[   30.122779]  el0_svc_handler+0x20/0x80
[   30.126534]  el0_svc+0x8/0xc

Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
2019-11-25 15:47:42 +08:00
Shijie Qin 68a85f9823 vpu: malone decoder: enable mailbox and unify code
- Enable mailbox for vpu decoder
  The mailbox of mu_m0 is used by imx8qxp and imx8qm

- Unify code between 4.19 and 5.x
  Update code from 4.19
  Separate sc and mu contents to vpu_mu.h/vpu_mu.c
  Separate pm_domain contents to vpu_pm.h/vpu_pm.c
  Add kfifo for better hold received mu message
  Sync v4l2 change
  Use ktime_get_real_ts64() replace do_gettimeofday()

Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
2019-11-25 15:47:42 +08:00
Shijie Qin de893e3f79 vpu: windsor encoder: enable mailbox and unify code
- Enable mailbox for vpu encoder
  The mailbox of mu1_m0 is used by imx8qxp
  The mailbox of mu2_m0 are used by imx8qm

- Unify code between 4.19 and 5.x
  Update code from 4.19
  Separate sc and mu contents to vpu_encoder_mu.h/.c
  Separate pm_domain contents to vpu_encoder_pm.h/.c
  Add kfifo for better hold received mu message
  Sync v4l2 change

Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
2019-11-25 15:47:41 +08:00
Shijie Qin 82e0fc6154 vpu: windsor encoder: add vpuenc2 power domain for imx8qm
Add vpuenc2 power for imx8qm.
Unify name as vpuenc1 and vpuenc2

Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
2019-11-25 15:47:40 +08:00
Dong Aisheng 6f8ceefb9a vpu: hantro_845_h1: fix compat_ptr building issue
compat_ptr() depends on CONFIG_COMPAT.
Make hx280enc_ioctl() conditionally compiled to avoid a build
break in case CONFIG_COMPAT is not defined.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:39 +08:00
Zhou Peng e9d52b0f5e vpu: imx6: add decoder/encoder
fix dma_alloc_attrs failure issue:
need to set valid device pointer instead of null pointer in
parameters of functions: dma_alloc_coherent/dma_free_coherent

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:39 +08:00
Zhou Peng bca0c6dcb1 vpu: imx6: add decoder/encoder
add vpu source and enable it in makefile/kconfig

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:39 +08:00
Zhou Peng efd24bb953 vpu: hantro: add encoder for imx845 h1
add hantro 845 source code, include h1

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
[ Aisheng: merge Kconfig&Makefile changes ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:38 +08:00
Zhou Peng 4602d72fc0 vpu: hantro: add decoder for imx845
add hantro 845 source code, include g1/g2

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
[ Aisheng: merge Kconfig&Makefile changes ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:38 +08:00
Zhou Peng bb61f55140 vpu: malone: encoder: add mu2 power domain for imx8qm
add mu2 power domain

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:38 +08:00
Zhou Peng 3ca2128468 vpu: hantro: fix build error when enabling 'CONFIG_DEVICE_THERMAL'
comment undefined function hantro_update_voltage() which was already disabled due to other build issues.

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:37 +08:00
Dong Aisheng 92e1bbb20a media: vpu_windsor: fix boot warning by intialize device_caps
Caused by:
049e684 media: v4l2-dev: fix WARN_ON(!vdev->device_caps)
3c13505 media: v4l2-dev/ioctl: require non-zero device_caps, verify sane querycap results

[    1.672018] WARNING: CPU: 0 PID: 61 at ../drivers/media/v4l2-core/v4l2-dev.c:864 __video_register_device+0x70/0x1524
[    1.682454] Modules linked in:
[    1.685501] CPU: 0 PID: 61 Comm: kworker/0:1 Not tainted 5.3.0-rc2-next-20190730-01100-gb0d5e17 #476
[    1.694617] Hardware name: Freescale i.MX8QXP MEK (DT)
[    1.699751] Workqueue: events deferred_probe_work_func
[    1.704870] pstate: 60000005 (nZCv daif -PAN -UAO)
[    1.709647] pc : __video_register_device+0x70/0x1524
[    1.714603] lr : __video_register_device+0x70/0x1524
[    1.719550] sp : ffff00001207ba70
[    1.722849] x29: ffff00001207ba70 x28: ffff00001005bcd8
[    1.728148] x27: ffff80083b4e23b8 x26: ffff0000119a0230
[    1.733448] x25: ffff80083af4d800 x24: 0000000000000001
[    1.738747] x23: 0000000000000000 x22: ffff80083bfc7c10
[    1.744046] x21: ffff80083fa285c0 x20: ffff000011041d90
[    1.749346] x19: ffff000011989000 x18: ffff000014ffffff
[    1.754645] x17: 0000000037cab0d3 x16: ffff000014ffffff
[    1.759945] x15: ffff0000113e6000 x14: 0000008000000000
[    1.765244] x13: 0000000000000000 x12: 00000000000000e9
[    1.770543] x11: ffffffffffffffff x10: 00000000000000ea
[    1.775843] x9 : ffff0000119a34c0 x8 : 5d20657265682074
[    1.781142] x7 : 7563205b2d2d2d2d x6 : ffff0000106dc978
[    1.786441] x5 : 0000000000000000 x4 : 0000000000000000
[    1.791741] x3 : 00000000ffffffff x2 : 1e3af7ec181d8600
[    1.797040] x1 : 0000000000000000 x0 : 0000000000000024
[    1.802342] Call trace:
[    1.804779]  __video_register_device+0x70/0x1524
[    1.809383]  vpu_enc_probe+0x290/0xb94
[    1.813117]  platform_drv_probe+0x4c/0xb0
[    1.817112]  really_probe+0x1c4/0x2d0
[    1.820761]  driver_probe_device+0x58/0xfc
[    1.824842]  __device_attach_driver+0x90/0xac
[    1.829190]  bus_for_each_drv+0x68/0xbc
[    1.833008]  __device_attach+0xe0/0x138
[    1.836831]  device_initial_probe+0x10/0x18
[    1.841000]  bus_probe_device+0x90/0x98
[    1.844823]  deferred_probe_work_func+0x70/0xa4
[    1.849346]  process_one_work+0x13c/0x2b4
[    1.853337]  worker_thread+0x35c/0x3e4
[    1.857077]  kthread+0xf8/0x124
[    1.860204]  ret_from_fork+0x10/0x18

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:37 +08:00
Dong Aisheng 5ae24aba1c media: vpu_malone: fix boot warning by intialize device_caps
Caused by:
049e684 media: v4l2-dev: fix WARN_ON(!vdev->device_caps)
3c13505 media: v4l2-dev/ioctl: require non-zero device_caps, verify sane querycap results

[    1.650814] WARNING: CPU: 2 PID: 32 at ../drivers/media/v4l2-core/v4l2-dev.c:864 __video_register_device+0x70/0x1524
[    1.661231] Modules linked in:
[    1.664277] CPU: 2 PID: 32 Comm: kworker/2:1 Not tainted 5.3.0-rc2-next-20190730-01098-g446d4cd #475
[    1.673393] Hardware name: Freescale i.MX8QXP MEK (DT)
[    1.678527] Workqueue: events deferred_probe_work_func
[    1.683647] pstate: 60000005 (nZCv daif -PAN -UAO)
[    1.688424] pc : __video_register_device+0x70/0x1524
[    1.693379] lr : __video_register_device+0x70/0x1524
[    1.698327] sp : ffff000011d8ba90
[    1.701626] x29: ffff000011d8ba90 x28: ffff000011d33cd8
[    1.706925] x27: ffff80083bee7838 x26: ffff0000119a0230
[    1.712224] x25: ffff80083ae63000 x24: 0000000000000001
[    1.717523] x23: 0000000000000000 x22: ffff000011989000
[    1.722823] x21: ffff80083bfc7810 x20: 0000000000000000
[    1.728122] x19: ffff000011989000 x18: ffff000010035fff
[    1.733422] x17: 0000000096ae19b6 x16: ffff000010035fff
[    1.738721] x15: ffff0000113e6000 x14: 0000008000000000
[    1.744020] x13: 0000000000000000 x12: 00000000000000e9
[    1.749320] x11: ffffffffffffffff x10: 00000000000000ea
[    1.754619] x9 : ffff0000119a34c0 x8 : 5d20657265682074
[    1.759918] x7 : 7563205b2d2d2d2d x6 : ffff0000106dc978
[    1.765218] x5 : 0000000000000000 x4 : 0000000000000000
[    1.770517] x3 : 00000000ffffffff x2 : 1e0ac921e89b3600
[    1.775816] x1 : 0000000000000000 x0 : 0000000000000024
[    1.781118] Call trace:
[    1.783557]  __video_register_device+0x70/0x1524
[    1.788160]  vpu_probe+0x2e4/0x9cc
[    1.791546]  platform_drv_probe+0x4c/0xb0
[    1.795540]  really_probe+0x1c4/0x2d0
[    1.799188]  driver_probe_device+0x58/0xfc
[    1.803271]  __device_attach_driver+0x90/0xac
[    1.807619]  bus_for_each_drv+0x68/0xbc
[    1.811439]  __device_attach+0xe0/0x138
[    1.815260]  device_initial_probe+0x10/0x18
[    1.819429]  bus_probe_device+0x90/0x98
[    1.823252]  deferred_probe_work_func+0x70/0xa4
[    1.827775]  process_one_work+0x13c/0x2b4
[    1.831766]  worker_thread+0x35c/0x3e4
[    1.835506]  kthread+0xf8/0x124
[    1.838633]  ret_from_fork+0x10/0x18
[    1.842193] ---[ end trace ee5db4b471a8d91f ]---

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:36 +08:00
Dong Aisheng 9d9cc0d614 MLK-21985-3 vpu: windsor: b0: fix build for next 20190607 upgrade
Due to below commit:
7e98b7b542 ("media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap, out}_mplane")

../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1586:2: error: unknown field ‘vidioc_enum_fmt_vid_cap_mplane’ specified in initializer
  .vidioc_enum_fmt_vid_cap_mplane = vpu_enc_v4l2_ioctl_enum_fmt_vid_cap_mplane,
  ^
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1587:2: error: unknown field ‘vidioc_enum_fmt_vid_out_mplane’ specified in initializer
  .vidioc_enum_fmt_vid_out_mplane = vpu_enc_v4l2_ioctl_enum_fmt_vid_out_mplane,
  ^
../scripts/Makefile.build:278: recipe for target 'drivers/mxc/vpu_windsor/vpu_encoder_b0.o' failed
make[4]: *** [drivers/mxc/vpu_windsor/vpu_encoder_b0.o] Error 1

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:36 +08:00
Dong Aisheng 937fff6194 MLK-21985-2 vpu: malone: b0: fix build for next 20190607 upgrade
Due to below commit:
7e98b7b542 ("media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap, out}_mplane")

We met the following build error:
../drivers/mxc/vpu_malone/vpu_b0.c:1721:2: error: unknown field ‘vidioc_enum_fmt_vid_cap_mplane’ specified in initializer
  .vidioc_enum_fmt_vid_cap_mplane = v4l2_ioctl_enum_fmt_vid_cap_mplane,
  ^
../drivers/mxc/vpu_malone/vpu_b0.c:1722:2: error: unknown field ‘vidioc_enum_fmt_vid_out_mplane’ specified in initializer
  .vidioc_enum_fmt_vid_out_mplane = v4l2_ioctl_enum_fmt_vid_out_mplane,

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:35 +08:00
Dong Aisheng 353bbca001 MLK-21876-22 vpu: build for ARM64 only
Current VPU drivers only support ARM64, not need to compile
for ARM32.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:35 +08:00
Zhou Peng feb3fc549f vpu: windsor encoder: porting from 4.19 rc3 release
Fix build error for kernel 5.x:
- power domain adjustment
  use dev_pm_domain_attach_by_name()/device_link_add
- remove sc fw api
  comment fuse related function
- definition of vb2_qbuf() changed
  set 'media_device' for vb2_qbuf()
- 'vidioc_g_crop'/'vidioc_s_crop' removed
  comment function 'v4l2_ioctl_g_crop'
- remove legacy macro, such as 'VB2_BUF_STATE_PREPARED'

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:34 +08:00
Zhou Peng 6c775159dd vpu: windsor encoder: porting from 4.19 rc3 release
updating source in drivers/mxc/vpu_windsor

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:34 +08:00
Zhou Peng fbfef11442 vpu: malone decoder: porting from 4.19 rc3 release
Fix build error for kernel 5.x:
- power domain adjustment
  use dev_pm_domain_attach_by_name()/device_link_add
- remove sc fw api
  comment fuse related function
- definition of vb2_qbuf() changed
  set 'media_device' for vb2_qbuf()
- 'vidioc_g_crop' removed
  comment function 'v4l2_ioctl_g_crop'

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:33 +08:00
Zhou Peng 79a1c026fa vpu: malone decoder: porting from 4.19 rc3 release
updating source in drivers/mxc/vpu_malone

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:32 +08:00
Dong Aisheng 67b35d2120 vpu: windsor: fix build error
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c: In function ‘show_buffer_info’:
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:3951:23: error: ‘VB2_BUF_STATE_REQUEUEING’ undeclared (first use in this function)
    " %d:requeueing,", VB2_BUF_STATE_REQUEUEING);

Due to this macro was removed by the following commit:
commit c6e4e2c403
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Thu Feb 28 07:35:46 2019 -0500

    media: vb2: drop VB2_BUF_STATE_REQUEUEING

    The last user of this state has been converted, so we can now drop
    this. Requeueing causes the queue to become unordered, which causes
    problems with requests and (in the future) fences.

    Since it is no longer needed, just get rid of this.

    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:31 +08:00
Dong Aisheng 3f0ca5ec74 vpu: windsor: remove deprecated using of VB2_BUF_STATE_PREPARED
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c: In function ‘show_buffer_info’:
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:4001:21: error: ‘VB2_BUF_STATE_PREPARED’ undeclared (first use in this function)
    " %d:prepared,", VB2_BUF_STATE_PREPARED);

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:31 +08:00
Dong Aisheng d450dea80f vpu: windsor: remove deprecated using of s_crop/g_crop
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c: At top level:
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1415:2: error: unknown field ‘vidioc_g_crop’ specified in initializer
  .vidioc_g_crop                  = vpu_enc_v4l2_ioctl_g_crop,
  ^
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1415:2: warning: initialization from incompatible pointer type
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1415:2: warning: (near initialization for ‘vpu_enc_v4l2_ioctl_ops.vidioc_dqbuf’)
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1416:2: error: unknown field ‘vidioc_s_crop’ specified in initializer
  .vidioc_s_crop   = vpu_enc_v4l2_ioctl_s_crop,
  ^

Module owner can double check later if need implement the same function
in other callbackes.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:30 +08:00
Dong Aisheng 79ab5d4a80 vpu: windsor: fix build failure
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c: In function ‘vpu_enc_v4l2_ioctl_qbuf’:
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1048:8: warning: passing argument 2 of ‘vb2_qbuf’ from incompatible pointer type
  ret = vb2_qbuf(&q_data->vb2_q, buf);
        ^
In file included from ../include/media/v4l2-mem2mem.h:20:0,
                 from ../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:47:
../include/media/videobuf2-v4l2.h:144:5: note: expected ‘struct media_device *’ but argument is of type ‘struct v4l2_buffer *’
 int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
     ^
../drivers/mxc/vpu_windsor/vpu_encoder_b0.c:1048:8: error: too few arguments to function ‘vb2_qbuf’
  ret = vb2_qbuf(&q_data->vb2_q, buf);

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:30 +08:00
Dong Aisheng 5c1f0bf1e6 vpu: malone: fix build failure
../drivers/mxc/vpu_malone/vpu_b0.c: In function ‘v4l2_ioctl_qbuf’:
../drivers/mxc/vpu_malone/vpu_b0.c:920:8: warning: passing argument 2 of ‘vb2_qbuf’ from incompatible pointer type
  ret = vb2_qbuf(&q_data->vb2_q, buf);
        ^
In file included from ../include/media/v4l2-mem2mem.h:20:0,
                 from ../drivers/mxc/vpu_malone/vpu_b0.c:47:
../include/media/videobuf2-v4l2.h:144:5: note: expected ‘struct media_device *’ but argument is of type ‘struct v4l2_buffer *’
 int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
     ^
../drivers/mxc/vpu_malone/vpu_b0.c:920:8: error: too few arguments to function ‘vb2_qbuf’
  ret = vb2_qbuf(&q_data->vb2_q, buf);
        ^
In file included from ../include/media/v4l2-mem2mem.h:20:0,
                 from ../drivers/mxc/vpu_malone/vpu_b0.c:47:
../include/media/videobuf2-v4l2.h:144:5: note: declared here
 int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev,
     ^
../drivers/mxc/vpu_malone/vpu_b0.c: At top level:
../drivers/mxc/vpu_malone/vpu_b0.c:1150:2: error: unknown field ‘vidioc_g_crop’ specified in initializer
  .vidioc_g_crop                  = v4l2_ioctl_g_crop,

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:30 +08:00
Dong Aisheng 373b49bfe3 vpu: hantro: fix build failure
../drivers/mxc/hantro/hantrodec.c: In function ‘hantrodec_ioctl’:
../drivers/mxc/hantro/hantrodec.c:1033:62: error: macro "access_ok" passed 3 arguments, but takes just 2
   err = !access_ok(VERIFY_WRITE, (void *) arg, _IOC_SIZE(cmd));
                                                              ^
../drivers/mxc/hantro/hantrodec.c:1033:10: error: ‘access_ok’ undeclared (first use in this function)
   err = !access_ok(VERIFY_WRITE, (void *) arg, _IOC_SIZE(cmd));
          ^
../drivers/mxc/hantro/hantrodec.c:1033:10: note: each undeclared identifier is reported only once for each function it appears in
../drivers/mxc/hantro/hantrodec.c:1035:61: error: macro "access_ok" passed 3 arguments, but takes just 2
   err = !access_ok(VERIFY_READ, (void *) arg, _IOC_SIZE(cmd));
                                                             ^
  CC      drivers/mtd/nand/raw/nand_base.o
  CC      drivers/irqchip/irq-mvebu-odmi.o
  CC      drivers/mtd/nand/raw/nand_legacy.o
../drivers/mxc/hantro/hantrodec.c: In function ‘get_hantro_core_desc32’:
../drivers/mxc/hantro/hantrodec.c:1266:61: error: macro "access_ok" passed 3 arguments, but takes just 2
  if (!access_ok(VERIFY_READ, up, sizeof(struct core_desc_32)) ||
                                                             ^
../drivers/mxc/hantro/hantrodec.c:1266:7: error: ‘access_ok’ undeclared (first use in this function)
  if (!access_ok(VERIFY_READ, up, sizeof(struct core_desc_32)) ||
       ^
../drivers/mxc/hantro/hantrodec.c: In function ‘put_hantro_core_desc32’:
../drivers/mxc/hantro/hantrodec.c:1280:62: error: macro "access_ok" passed 3 arguments, but takes just 2
  if (!access_ok(VERIFY_WRITE, up, sizeof(struct core_desc_32)) ||
                                                              ^
../drivers/mxc/hantro/hantrodec.c:1280:7: error: ‘access_ok’ undeclared (first use in this function)
  if (!access_ok(VERIFY_WRITE, up, sizeof(struct core_desc_32)) ||
       ^
../scripts/Makefile.build:278: recipe for target 'drivers/mxc/hantro/hantrodec.o' failed
make[4]: *** [drivers/mxc/hantro/hantrodec.o] Error 1
../scripts/Makefile.build:489: recipe for target 'drivers/mxc/hantro' failed
make[3]: *** [drivers/mxc/hantro] Error 2
../scripts/Makefile.build:489: recipe for target 'drivers/mxc' failed
make[2]: *** [drivers/mxc] Error 2
make[2]: *** Waiting for unfinished jobs...

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:30 +08:00
Zhou Peng 1875e0954b arm64: vpu: m850d: hantro: mxc config
enable hantro decoder in mxc config
drivers/mxc/Kconfig
drivers/mxc/Makefile

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:29 +08:00
Zhou Peng 83ac8664e5 arm64: vpu: m850d: hantro
Add hantro decoder driver:
drivers/mxc/hantro
include/linux/hantrodec.h
include/uapi/linux/hantrodec.h

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:28 +08:00
Zhou Peng 7339b6c620 Add directory driver/mxc and related scripts
Related build scripts:
drivers/Kconfig
drivers/Makefile
drivers/mxc/Kconfig
drivers/mxc/Makefile

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:27 +08:00
Zhou Peng 95b1763c0a Add Malone decoder and windsor encoder for QXP/QM
Add vpu driver:
drivers/mxc/vpu_malone
drivers/mxc/vpu_windsor

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
2019-11-25 15:47:27 +08:00
Xianzhong d79b5a2808 LF-84 [#imx-1834] remove gpu coherent_dma_mask setting
gpu_probe set coherent_dma_mask with 40BIT configuration,
L5.4 dma_alloc_wc will return physical address beyond 4GB,
that will cause GPU hang and kernel panic problem on QM.

default coherent_dma_mask is 32BIT, can meet GPU requirement,
this patch remove coherent_dma_mask setting from GPU driver.

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:24 +08:00
Ya Zhou 9bfda82aee MGS-5245 [#imx-1755] [8MN_EVK] VTK: fix the gpu dump when enable vProfile
fix the gpu dump when enable vProfile on 8MN_EVK

Date: 7th Nov ,2019
Signed-off-by Ya Zhou <ya.zhou@nxp.com>

(cherry picked from commit 053c97c0387673c4e730d9b2f780f8cde5fcdf5b)
2019-11-25 15:47:23 +08:00
Xianzhong dfc0a717ce MGS-5307 gpu: integrate 6.4.0.p2 driver
Port M815 GPU patches from 6.2.4.p4 to 6.4.0,
More bug-fixings for vulkan 1.1.3 and NNCTS 1.2.

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:23 +08:00
Yuantian Tang 4f78081163 QSDK-5959 [#ccc] update the platform driver to support layerscape soc
Update the imx platform gpu driver to accommodate layerscape soc,
so that both platform can share the same platform driver.

Signed-off-by: Tang Yuantian <andy.tang@nxp.com>
2019-11-25 15:47:19 +08:00
Xianzhong 929cd8167a MGS-5261 [#imx-1771] fix dummy draw hang for 8MM GPU
dummy draw is required for 8MM GPU errata - HBN1285,
this fix shall be applied for GPU power-up transition,
otherwise GPU shader hang with the unnecessary flush.

check GPU MMU state to enable dummy draw fix only.

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:19 +08:00
Xianzhong 5e9a2ac12a MGS-5284 [#imx-1786] fix GPU panic with vm_mmap failure
When vm_mmap fail, code jump to OnError with error status and userLogical variable != 0.
Then _CMAFSLUnmapUser is called with a invalid virtual address (MdlMap->vmaAddr) and cause panic.

Check userLogical to avoid GPU kernel panic for error handling.

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:18 +08:00
Xianzhong fe4bb99bf8 MGS-5283 [#imx-1784] fix GPU AXI bus error
Fix GPU safe memory with gcvALLOC_FLAG_4GB_ADDR

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:17 +08:00
Xianzhong f79ac90c9a MGS-5283 [#imx-1238] fix GPU memory without CMA
Fix GPU memory problem when disable CMA allocator,
set LINUX_CMA_FSL=0 in gc_hal_kernel_platform_imx.config

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:17 +08:00
Xianzhong 3c6cb83114 MGS-4376 [#imx-1238] fix low performance with CMA allocator
there are lots of PFNs busy message when run GPU tests:
 [  622.370671] alloc_contig_range: [4ea70, 4ea7c) PFNs busy
 [  626.518072] alloc_contig_range: [4ea90, 4ea9c) PFNs busy

this problem is related with CMA migration for fragments,

move CMA allocator after GFP to avoid memory migration,
also fix CMA preempt for contiguous memory request.

can improve CTS and gpubench benchmarks on M850D.

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
(cherry picked from commit ad77ed61b72c8362b04361acd2deb685fee15436)
2019-11-25 15:47:17 +08:00
Ella Feng 80b7bdd8b4 MGS-5176-2 [#imx-1744] Need free the pages if malloc memory failed
When alloc NonContiguous1MPages, if malloc fail, need free the pages to avoid memory leak

Date: 24 Oct, 2019
Signed-off-by: Xianzhong Li <xianzhong.li@nxp.com>
2019-11-25 15:47:16 +08:00
Ella Feng ce7c0558a8 MGS-5176 [#imx-1744] Coverity issue of 6.4.0.p1.
The intension of this code is that, if current core is null, go to get the next one.
If it's already the last one, no need to do this.

Date: 23 Oct, 2019
Signed-off-by: Ella Feng <ella.feng@nxp.com>
2019-11-25 15:47:15 +08:00
Xianzhong 475535f320 MGS-5252 Integrate Vivante 6.4.0.p1 GPU driver
Fix Coverity high impact and Vulkan 1.1.3 issues

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:15 +08:00
Leonard Crestez d06a28f58e gpu-viv: Fix writecombine/wc build error
Upstream removed the _writecombine aliases

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2019-11-25 15:47:14 +08:00
Minjie Zhuang 08f009a338 gpu:Remove dma.h to avoid Linux 5.x build problem
Log:
    ../drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c:87:17:
fatal error: dma.h: No such file or directory
     #include <dma.h>
                     ^
    compilation terminated.
    ../scripts/Makefile.build:280: recipe for target
'drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.o' failed
    make[4]: ***
[drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.o] Error 1

Signed-off-by: Minjie Zhuang<minjie.zhuang@nxp.com>
2019-11-25 15:47:13 +08:00
Dong Aisheng cc07713a0d gpu: fix build break due to dma headfile include
It's caused by GPU upgrade overwrite the former fix.

Log:
../drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c:87:17: fatal error: dma.h: No such file or directory
 #include <dma.h>
                 ^
compilation terminated.
../scripts/Makefile.build:280: recipe for target 'drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.o' failed
make[4]: *** [drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.o] Error 1

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:12 +08:00
Minjie Zhuang e9371a7092 gpu:Integrate 6.4.0 kernel driver for Linux L5.x
Containing update SCU API and upgrade kernel to 640 driver for Linux L5.x

drivers/mxc/gpu-viv/*

Signed-off-by: Minjie Zhuang<minjie.zhuang@nxp.com>
2019-11-25 15:47:12 +08:00
Minjie Zhuang 97bf98e7f2 gpu: Update SCU API and change the method to distinguish 8QM/8QXP from other boards
The SCU API used in this file is for 4.19 kernel version and need to upgrade,
Need to modify the method to distinguish 8QM.8QXP by compatible string

drivers/mxc/gpu-viv/hal/os/linux/kernel/platform/freescale/gc_hal_kernel_platform_imx.c
2019-11-25 15:47:10 +08:00
Dong Aisheng 0d03d5163c MLK-21876-11 gpu: fix build for next-20190524 upgrade
Failed on imx v6_v7 build.

../drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c:86:17: fatal error: dma.h: No such file or directory
 #include <dma.h>
                 ^
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:09 +08:00
Dong Aisheng 35802f523c gpu: imx: fix gpu boot hang by defer driver register time
GPU driver can't support DEFER_PROBE well.
So let's defer the driver register time to make booting ok first.

[    1.255193] galcore: clk_get clk_core failed
[    1.259741] Galcore version 6.2.4.190076
[    1.342888] Unable to handle kernel NULL pointer dereference at virtual address 00000000000001a0
[    1.351377] Mem abort info:
[    1.354134]   ESR = 0x96000004
[    1.357160]   Exception class = DABT (current EL), IL = 32 bits
[    1.363078]   SET = 0, FnV = 0
[    1.366116]   EA = 0, S1PTW = 0
[    1.369244] Data abort info:
[    1.372101]   ISV = 0, ISS = 0x00000004
[    1.375932]   CM = 0, WnR = 0
[    1.378887] [00000000000001a0] user address but active_mm is swapper
[    1.385234] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[    1.390781] Modules linked in:
[    1.393823] Process swapper/0 (pid: 1, stack limit = 0x(____ptrval____))
[    1.400515] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.1.0-rc5-next-20190418-00708-g2e89357-dirty #159
[    1.409892] Hardware name: Freescale i.MX8QXP MEK (DT)
[    1.415020] pstate: 60000005 (nZCv daif -PAN -UAO)
[    1.419808] pc : __pm_runtime_resume+0x20/0x74
[    1.424233] lr : _SetPower+0x48/0x54
[    1.427786] sp : ffff00001005b670
[    1.431088] x29: ffff00001005b670 x28: ffff80083bbd1a20
[    1.436387] x27: 0000000000000000 x26: 0000000000000000
[    1.441686] x25: 0000000000000000 x24: 0000000000000001
[    1.446985] x23: 0000000000000001 x22: 0000000000000001
[    1.452285] x21: ffff80083ad42800 x20: ffff80083ad42800
[    1.457584] x19: 0000000000000000 x18: 0000000000000030
[    1.462884] x17: 0000000080000000 x16: ffff000012c80000
[    1.468183] x15: ffff7e0020eb9040 x14: ffff80083f9eff80
[    1.473482] x13: 0000000000000000 x12: 00000000ffffffc1
[    1.478782] x11: 0000000000000005 x10: 0101010101010101
[    1.484081] x9 : 0000000000000000 x8 : ffff80083ad19798
[    1.489380] x7 : 0000000000000000 x6 : 000000000000003f
[    1.494680] x5 : 0000000000000040 x4 : 0000000000000000
[    1.499979] x3 : 00000000000001a0 x2 : ffff000011680470
[    1.505278] x1 : 0000000000000004 x0 : 0000000000000000
[    1.510580] Call trace:
[    1.513017]  __pm_runtime_resume+0x20/0x74
[    1.517099]  _SetPower+0x48/0x54
[    1.520312]  gckOS_SetGPUPower+0x6c/0x148
[    1.524311]  gctaOS_SetGPUPower+0x1c/0x24
[    1.528306]  gctaHARDWARE_Construct+0x8c/0x390
[    1.532733]  gcTA_Construct+0x6c/0x148
[    1.536474]  gckGALDEVICE_Construct+0x364/0x8f8
[    1.540989]  drv_init+0x1ec/0x34c
[    1.544291]  gpu_probe+0x1fc/0x244
[    1.547680]  platform_drv_probe+0x4c/0xb0
[    1.551675]  really_probe+0x1f8/0x2c8
[    1.555323]  driver_probe_device+0x58/0xfc
[    1.559406]  device_driver_attach+0x68/0x70
[    1.563578]  __driver_attach+0x94/0xdc
[    1.567312]  bus_for_each_dev+0x64/0xc0
[    1.571134]  driver_attach+0x20/0x28
[    1.574698]  bus_add_driver+0x148/0x1fc
[    1.578519]  driver_register+0x68/0x120
[    1.582342]  __platform_driver_register+0x4c/0x54
[    1.587035]  gpu_init+0x54/0x94
[    1.590162]  do_one_initcall+0x58/0x1b8
[    1.593985]  kernel_init_freeable+0x1cc/0x288
[    1.598329]  kernel_init+0x10/0x100
[    1.601802]  ret_from_fork+0x10/0x18
[    1.605367] Code: aa0003f3 361000e1 91068263 f9800071 (885f7c60)
[    1.611458] ---[ end trace e1dc4ddcfc5850c0 ]---
[    1.616118] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    1.623695] SMP: stopping secondary CPUs
[    1.627606] Kernel Offset: disabled
[    1.631078] CPU features: 0x002,20002008
[    1.634985] Memory Limit: none
[    1.638031] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:09 +08:00
Dong Aisheng ce86151b5c gpu: more build fix
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:09 +08:00
Dong Aisheng b54acb9c76 gpu: fix totalram_pages build error
../drivers/mxc/gpu-viv/hal/os/linux/kernel/platform/freescale/gc_hal_kernel_platform_imx.c: In function ‘_AdjustParam’:
../drivers/mxc/gpu-viv/hal/os/linux/kernel/platform/freescale/gc_hal_kernel_platform_imx.c:1520:46: error: invalid operands to binary * (have ‘long unsigned int (*)(void)’ and ‘long unsigned int’)
         ((Args->baseAddress + totalram_pages * PAGE_SIZE) > 0x100000000))

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:08 +08:00
Dong Aisheng 5ec394df46 gpu: fix do_gettimeofday build error
This api was removed from kernel. Use new instead.

../drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c: In function ‘gckOS_GetTime’:
../drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c:3006:5: error: implicit declaration of function ‘do_gettimeofday’ [-Werror=implicit-function-declaration]
     do_gettimeofday(&tv);

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:07 +08:00
Dong Aisheng a780e02ff3 gpu: fix access_ok build error
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2019-11-25 15:47:06 +08:00
Xianzhong d421c76cc1 MGS-4530-3 [#imx-1314] include dma-direct.h to fix gpu build for L4.19
error: implicit declaration of function ‘dma_to_phys’; did you mean ‘virt_to_phys’? [-Werror=implicit-function-declaration]
     page = phys_to_page(dma_to_phys(&Allocator->os->device->platform->device->dev, mdl_priv->physical));
                         ^
./include/asm-generic/memory_model.h:54:40: note: in definition of macro ‘__pfn_to_page’
 #define __pfn_to_page(pfn) (vmemmap + (pfn))
                                        ^~~
./include/asm-generic/memory_model.h:78:30: note: in expansion of macro ‘PHYS_PFN’
 #define __phys_to_pfn(paddr) PHYS_PFN(paddr)
                              ^~~~~~~~
./arch/arm64/include/asm/memory.h:255:41: note: in expansion of macro ‘__phys_to_pfn’
 #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
                                         ^~~~~~~~~~~~~
gc_hal_kernel_allocator_cma.c:237:12: note: in expansion of macro ‘phys_to_page’
     page = phys_to_page(dma_to_phys(&Allocator->os->device->platform->device->dev, mdl_priv->physical));
            ^~~~~~~~~~~~

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:06 +08:00
Xianzhong 40cc89f4fc MGS-4530-2 disable busfreq-imx to fix L4.19 dash build
gc_hal_kernel_platform_imx.c:90:14: fatal error: linux/busfreq-imx.h: No such file or directory
 #    include <linux/busfreq-imx.h>

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:06 +08:00
Xianzhong 30638182fd MGS-4530-1 add 6.2.4.p4 gpu driver for L4.19
add mxc config to include drivers/mxc/gpu-viv

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
2019-11-25 15:47:05 +08:00