Commit Graph

866705 Commits

Author SHA1 Message Date
Su Yuefu
e8ce286fac media: i2c: add sc223a sensor driver
Signed-off-by: Su Yuefu <yuefu.su@rock-chips.com>
Change-Id: Ib7b04474b80318889bc356c25506cc8e1497902a
2021-10-27 10:52:35 +08:00
Andy Yan
43f90e774d drm/rockchip: vop2: Reset plane->rotation to DRM_MODE_ROTATE_0
Some application(e.g Kwin) may use it as a default rotation.
We should set it a valid rotation here.

Change-Id: Idef8fa5097b54710e2ead32a197d5d1e6bf78d94
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2021-10-27 10:24:32 +08:00
Finley Xiao
790f77f1a1 arm64: dts: rockchip: rk3568: Add vop-frame-bw-dmc-freq
Fix vop POST_BUF_EMPTY irq err when rotate screen.

Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Change-Id: I3c0d5c52efa8612ce6bf24f6748ccab7c1c05a57
2021-10-26 18:07:07 +08:00
Finley Xiao
4163c2ca85 PM / devfreq: rockchip_dmc: Change frequency according to vop frame bandwidth
Sometimes the vop line bandwidth is not high, the vop also report
buf empty err, and the frame bandwidth is high at this time, so change
ddr frequency according to frame bandwidth can fix the error.

Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Change-Id: Ia893a07def99aaaa4da421b6d619a8fd3eec9745
2021-10-26 18:07:07 +08:00
Sandy Huang
15201ca7b3 drm/rockchip: vop2: add calculate current frame data size
Signed-off-by: Sandy Huang <hjc@rock-chips.com>
Change-Id: Ie9c92c651b8c379c77aac941d03bf3f772ed7eea
2021-10-26 18:07:04 +08:00
Yiqing Zeng
7bda16fadf media: i2c: sc5239 fix logic gain error
sc5239 have logic gain for analog, it can improve the image quality for
raw data.

Signed-off-by: Yiqing Zeng <zack.zeng@rock-chips.com>
Change-Id: I03a17f21d1457aa60a7438b4a4895493e879be28
2021-10-26 17:53:36 +08:00
Algea Cao
f4e8f555a4 drm/rockchip: dw_hdmi: Add rk356x hdmitx phy pll cfg
After testing, if use previous hdmitx pll cfg , rk356x some
chips will appear 297M tmds clock output abnormal. After
signal testing, it was decided to update the vendor
recommended pll cfg.

Signed-off-by: Algea Cao <algea.cao@rock-chips.com>
Change-Id: If1ca2f9e5922c9b95b1d90055640daafcacc2301
2021-10-26 16:43:27 +08:00
Cai YiWei
05332f7eb9 media: rockchip: isp: sync multi vir dev stream on/off
Change-Id: I851b0390952a4f3921405a7cd24b8af7fbaff532
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
2021-10-26 10:15:08 +08:00
Cai YiWei
193fab7512 media: rockchip: ispp: remove tnr iir first frame skip
Change-Id: Iac599ac81059c92f929ccd0997d32e419c338642
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
2021-10-26 10:14:51 +08:00
Cai YiWei
01bbe48cae media: rockchip: isp/ispp sync alloc buf with dma sg case
Change-Id: If4c80315efd9ce3ac80de3ec72d537ca1c27776d
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
2021-10-26 10:14:43 +08:00
Cai YiWei
4ab1b65d86 media: rockchip: isp/ispp to version v1.7.0
Change-Id: I3c07a83f9e5a4e7b2bfee30cc5e36c252ecc429f
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
2021-10-26 10:14:21 +08:00
Cai YiWei
9539d807c2 media: rockchip: isp: rawwr and rawrd memory mode
Three mode:
0: raw12/raw10/raw8 8bit memory compact
1: raw12/raw10 16bit memory one pixel
   big endian for rv1126/rv1109
   |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
   | 3| 2| 1| 0| -| -| -| -|11|10| 9| 8| 7| 6| 5| 4|
   little align for rk356x
   |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
   | -| -| -| -|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
2: raw12/raw10 16bit memory one pixel
   big align for rv1126/rv1109/rk356x
   |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
   |11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| -| -| -| -|

Change-Id: Iabd5600d1a880057f0a20e187b15d337079a14c6
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
2021-10-25 16:07:56 +08:00
Zefa Chen
03d58d32a5 media: rockchip: cif support config memory mode
cif memory mode
 0: raw12/raw10/raw8 8bit memory compact
 1: raw12/raw10 16bit memory one pixel
    low align for rv1126/rv1109/rk356x
    |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
    | -| -| -| -|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
 2: raw12/raw10 16bit memory one pixel
    high align for rv1126/rv1109/rk356x
    |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
    |11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| -| -| -| -|

 note: rv1109/rv1126/rk356x dvp only support uncompact mode,
       and can be set low align or high align

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: I59d619645650dfa10c9b2c168d8c741292f9f90f
2021-10-25 16:07:56 +08:00
Zorro Liu
ecb04d26a3 drm/rockchip: ebc_dev: release version v2.13
create independent workqueqe to do auto refresh work

Signed-off-by: Zorro Liu <lyx@rock-chips.com>
Change-Id: I71421e4391fe9c1f85023b08057d75a4e11e9c85
2021-10-25 14:24:02 +08:00
Ding Wei
570ca7f242 video: rockchip: mpp: fix issue for devices register to service
The device must be registered last. If there is an error, the device
should not succeed.

Change-Id: Ie342c8bbf30e8a94822dcb2e0417fe1230e4482a
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2021-10-22 18:29:17 +08:00
Simon Xue
607ec674a1 PCI: rockchip: update rockchip-pcie-dma driver
1. reduce buffer size to 128KB
2. invalidate buffer cache on demand
3. reduce scantimer interval to 100us

Can improve NPU fps from 45 to 95, the main reason is that
most of data packages of NPU less than 1MB, setting buffer
size to 128KB got a well result after testing.

Signed-off-by: Simon Xue <xxm@rock-chips.com>
Change-Id: Ib9e57b95a608110f4ec00c74a84cbe6deb63caf7
2021-10-22 17:25:53 +08:00
Ding Wei
64f0c74249 video: rockchip: mpp: rkvenc: probe issue for devfreq init error
When devfreq initially fails, the device can still continue to execute,
but there is no devfreq function.

Change-Id: I2a39a77e0a85cb43854b6adbe0476905abcc9a3b
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2021-10-22 17:12:09 +08:00
Sugar Zhang
d5a8a6f035 FROMGIT: ASoC: rockchip: Use generic dmaengine code
This reverts commit 75b31192fe.

The original purpose of customized pcm was to config prealloc buffer size
flexibly. but, we can do the same thing by soc-generic-dmaengine-pcm.

And the generic one can generated the better config by querying DMA
capabilities from dmaengine driver rather than the Hard-Coded one.

e.g.

the customized one:

  static const struct snd_pcm_hardware snd_rockchip_hardware = {
         .info                   = SNDRV_PCM_INFO_MMAP |
                                   SNDRV_PCM_INFO_MMAP_VALID |
                                   SNDRV_PCM_INFO_PAUSE |
                                   SNDRV_PCM_INFO_RESUME |
                                   SNDRV_PCM_INFO_INTERLEAVED,
  ...

the generic one:

  ret = dma_get_slave_caps(chan, &dma_caps);
  if (ret == 0) {
          if (dma_caps.cmd_pause && dma_caps.cmd_resume)
                  hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME;
          if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT)
                  hw.info |= SNDRV_PCM_INFO_BATCH;
  ...

So, let's revert back to use the generic dmaengine pcm.

Change-Id: I30eee2e8047b69d7311fd6da0cfd2b5872b81e17
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Reviewed-by: John Keeping <john@metanate.com>
Link: https://lore.kernel.org/r/1632792957-80428-1-git-send-email-sugar.zhang@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 5ba8ecf227
 git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.16)
2021-10-22 16:50:06 +08:00
Sugar Zhang
ba2cfd68f4 FROMGIT: ASoC: dmaengine: Introduce module option prealloc_buffer_size_kbytes
Currently, The fixed 512KB prealloc buffer size is too larger for
tiny memory kernel (such as 16MB memory). This patch adds the module
option "prealloc_buffer_size_kbytes" to specify prealloc buffer size.

It's suitable for cards which use the generic dmaengine pcm driver
with no config.

Change-Id: I76cc278f523d41083ba30b36d801d2839682d158
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Link: https://lore.kernel.org/r/1632394246-59341-1-git-send-email-sugar.zhang@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit b0e3b0a707
 git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.16)
2021-10-22 16:49:55 +08:00
Andy Yan
0c5249aab1 drm/rockchip: vop2: Adjust wait critical time zone policy when there are two pending vp
Current policy:

If there are two pending config done vp, and one of them is
at critical time zone, wait for the one wich has long time
to vsync.

This may lead a very long wait, for example: VP0 is 3840 x 2160,
VP2 is 1920 x 1080, they are all have pending cfg done bits,
and the vcnt of VP0 is 1367, the vcnt of VP2 is 995, VP2 is
at the critical time zone, we will wait VP0 vsync(almost half frame time)
according to this policy. This lead a very long wait.

The new policy:

If there are two pending config done vp, and one of them is
at critical time zone, compare the left vcnt time of the
two vp:

if (first_vp_left_time > second_vp_left_time) {
	if ((first_vp_left_time - second_vp_left_time) > first_vp_safe_time)
		wait_vp = second_done_vp;
	else
		wait_vp = first_done_vp;
} else {
	if ((second_vp_left_time - first_vp_left_time) > second_vp_safe_time)
               wait_vp = first_done_vp;
	else
		wait_vp = second_done_vp;
}

Change-Id: I7154ad716841c6c28947ddfecc845c7271cc507a
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2021-10-22 15:58:15 +08:00
David Wu
2c264016e4 net: ethernet: stmmac: dwmac-rk: Disable delayline if it is invalid
If delayline can't get from DTB or invalid, don't enable delayline.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Change-Id: I9769af42d02c67d2ea3fd24de5def45a1ec1cc17
2021-10-21 15:11:34 +08:00
Yandong Lin
8649265280 video: rockchip: mpp: Fix report wrong dev when pagefault
On some platforms(such as px30), vepu and vdpu shared the
same mmu.So when registering the iommu handle function,
there will be overwriting.Results in the reported device mismatch
when page fault.

Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: Id07c7f3088c52fcb987797c689296154c670078c
2021-10-21 14:43:46 +08:00
Ding Wei
88ce0688ff driver core: Export symbol: device_links_read_lock/unlock
The symbols is used for rockchip video codec driver,
which located driver/rockchip/video/mpp. When mpp is build
for module, it will be error.

Error message:
ERROR: "device_links_read_unlock"
[drivers/video/rockchip/mpp/rk_vcodec.ko] undefined!
ERROR: "device_links_read_lock" [drivers/video/rockchip/mpp/rk_vcodec.ko] undefined!
make[2]: *** [__modpost] Error 1
make[1]: *** [modules] Error 2
make: *** [kernel.img] Error 2
make: *** Deleting file `kernel.img'`

Change-Id: Ie412341c03ad71d257392a22249b62bedd0be58b
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2021-10-21 09:23:29 +08:00
Wyon Bi
2d50781c01 clk/rockchip/regmap: rk618: Bypass PLL by default
Fixes: 962d002400 ("clk/rockchip/regmap: Prepare RK628 PLL support")
Change-Id: I9d76d96f0aa73e97f8ab9ce47f5ac28f22608342
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2021-10-20 17:39:05 +08:00
Cai YiWei
8965ce1d73 media: rockchip: isp: dmatx default config with mipi sensor input
Change-Id: I51f27921b650d614e552d810995172d4ea17ef08
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
2021-10-20 17:38:44 +08:00
Zefa Chen
295c091894 include: uapi/linux/rk-camera-module.h modify otp struct
1. modify af inf
2. add module info

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: I455e649c1ffe471e1b5239d95ae929ad85113248
2021-10-20 16:02:33 +08:00
William Wu
11f9c06cc3 usb: dwc3: gadget: wait for disconnect done before runtime suspend
The dwc3 gadget call pm_runtime_get in the __dwc3_gadget_ep_queue()
to increment the device's usage count, and call pm_runtime_put in
the dwc3_gadget_giveback() to decrement the device's usage count
if the request is completed successfully or disconnection happens.

Test on RK3399 IND Type-C interface with HUSB311 (Type-C port
controller chip), if plug out the USB cable, the extcon notifier
from tcpm framework comes earlier than the dwc3 disconnect event.
This cause the dwc3 fails to enter the runtime suspend immediately
in the disconnection process of __dwc3_set_mode().

This patch waits for the dwc3 disconnect event done before doing
pm_runtime_put_sync_suspend. If it takes 1000ms to wait for the
disconnect event timeout, just print warning log and still do
the pm_runtime_put_sync_suspend, and then the dwc3 can also enter
runtime suspend automatically (DWC3_DEFAULT_AUTOSUSPEND_DELAY is
5000ms) after the disconnect event done.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: Ie6086d469b5d24f841532992e4e95f0c91c37022
2021-10-20 15:55:41 +08:00
Zorro Liu
02456ae203 mfd: rk808: disable rk817 int when shutdown
rk817 int pin is connect to sleep pin on ebook hardware design,
cpu unable to pull high sleep pin to shutdown devices,
when pmic occurs interrupt, so we just disable pmic int
on shutdown process to avoid this.

TEST:Press the Power button frequently while shutting down ebook devices

Signed-off-by: Zorro Liu <lyx@rock-chips.com>
Change-Id: I2a3a45be371b78720a94b1380fbb101a5597cfc6
2021-10-20 15:16:36 +08:00
Elaine Zhang
fd5fd8b70e regulator: rk860x: Add binding document for Rockchip Rk860x
Add rk860x-regulator.yaml document for Rockchip Rk860x Buck.

Change-Id: I374a9c3b17f0f9382d7213a5d3a1a8ece9f0ae1d
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-10-19 15:14:10 +08:00
Elaine Zhang
e193e5488c regulator: rk860x: Add RK860X dcdc support
RK860X main features:
    - 2.7V to 5.5V Input Voltage Range;
    - 2.4MHz Constant Switching Frequency;
    - 6A Available Load Current;
    - Programmable Output Voltage: 0.7125V to 1.5V in 12.5mV
      Steps(RK8600/RK8601), 0.5V to 1.5V in 6.25mV(RK8602/RK8603);
    - PFM/PWM Operation for Optimum Increased Efficiency;

Change-Id: Ib564dee94151d42c0288d2141c6b66c70bc019b9
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-10-19 15:10:59 +08:00
Ding Wei
4e57d971b6 video: rockchip: mpp: rcu_read_lock/unlock -> device_links_read_lock/unlock
reason:
1. might_sleep is called by pm_runtime_xx, thus, it cannot covered by
   rcu_read_lock/unlock which is atomic context.
2. it need use device_links_read_lock/unlock when meets dev->links.suppliers.

relative call trace:
[ 1804.810833  ] mpp_rkvdec2 fdf80200.rkvdec: resetting...
[ 1804.811030  ] BUG: sleeping function called from invalid context at
drivers/base/power/runtime.c:1005
[ 1804.811090  ] in_atomic(): 0, irqs_disabled(): 0, pid: 3043, name:
[ 1804.811149  ] CPU: 2 PID: 3043 Comm: rkvdec Tainted: G        W
4.19.206 #215
[ 1804.811192  ] Hardware name: Rockchip RK3566 EVB1 DDR4 V10 Board (DT)
[ 1804.811236  ] Call trace:
[ 1804.811316  ]  dump_backtrace+0x0/0x178
[ 1804.811366  ]  show_stack+0x14/0x20
[ 1804.811421  ]  dump_stack+0x94/0xb4
[ 1804.811474  ]  ___might_sleep+0xf0/0x118
[ 1804.811505  ]  __might_sleep+0x50/0x88
[ 1804.811535  ]  __pm_runtime_idle+0x9c/0xa0
[ 1804.811681  ]  mpp_iommu_refresh+0x54/0xd0 [rk_vcodec]
[ 1804.811789  ]  rkvdec2_link_reset+0xac/0x128 [rk_vcodec]
[ 1804.811873  ]  rkvdec2_link_isr+0xe4/0x6d0 [rk_vcodec]
[ 1804.811995  ]  rkvdec2_link_worker+0xc0/0xb08 [rk_vcodec]
[ 1804.812053  ]  kthread_worker_fn+0xe8/0x1f8
[ 1804.812099  ]  kthread+0x138/0x168
[ 1804.812130  ]  ret_from_fork+0x10/0x18
[ 1804.812243  ] mpp_rkvdec2 fdf80200.rkvdec: reset done

Change-Id: Id8453483b021a092e298736640e725a8e48c862b
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2021-10-19 14:53:20 +08:00
Jon Lin
85546e9ff7 drivers: rkflash: Support new spiflash
1.spinand: GD5F1GQ5REYIG, GD5F2GQ5REYIG, GD5F2GM7RxG, GD5F2GM7UxG,
DS35M2GA-IB, DS35Q2GB-IB, DS35M1GB-IB, TX25G01
2.spinor: GD25Q64E, GD25LQ255E, GD25LQ256C, GD25LB512MEYIG, XM25QH64C,
XM25QH128C, XM25QH256C, XM25QU128C, XM25QU64C

Change-Id: Ic9313b296528b7586a5139c13c77bd3ec477c359
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-10-19 14:52:28 +08:00
Zefa Chen
bc216fc845 include: uapi/linux/rk-camera-module.h otp support pdaf
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: I4bcd2d1ff866059821ef1ddc7248530cd37a9062
2021-10-19 14:27:49 +08:00
Zhenke Fan
c20c1dc6bb include: uapi/linux/rk-camera-module.h modify the rkmodule_lsc_inf
Signed-off-by: Zhenke Fan <fanzy.fan@rock-chips.com>
Change-Id: I89403b779bcd6191e6fe76e1412275ad1752d414
2021-10-19 11:11:22 +08:00
Shawn Lin
0feb50f920 PCI: rockchip: dw: Fix gen switch case when link is up
L0 may be detected just in time if Gen1 training is finished.
But if EP supports higher Gen mode, Gen switch just happen
there but we keep on accessing devices, which leads unstable
link state and fail to detect the device finally.

And a bit more time before accessing devices to avoid this risky
case.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Change-Id: If7eddce430b4590922b5c8f765be8a240b562d92
2021-10-19 09:01:33 +08:00
Joseph Chen
00ae76eb0b mfd: rk808: correct condition check to set pm_power_off as NULL
Fixes porting:
(62e9bedcf2 UPSTREAM: mfd: rk808: Check pm_power_off pointer)

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2fdb6bf8dc40260a68fb5b1155617f6dfebb4707
2021-10-18 14:43:21 +08:00
Joseph Chen
ff3fb24350 mfd: rk808: format and imporve the coding style
Try to keep the same as develop-5.10 code for easily
compare files.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I19bf821f17d06ad9d46d3319e33c2e3c7823fdce
2021-10-18 14:43:21 +08:00
Jon Lin
b3411ad8b4 drivers: rkflash: Recheck the cache only the spinand devices in need
The operation of reading back flash cache after programing is not
universal. At present, only ESMT devices are found to have this anomaly.

Change-Id: I3ec21eebc4aa7b8a259129ed2c036e1168553f27
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-10-15 19:45:26 +08:00
YouMin Chen
72edc8e464 arm64: dts: rockchip: rk3568: remove ddr_timing node
Signed-off-by: YouMin Chen <cym@rock-chips.com>
Change-Id: Iaef7442a52bfadee989c507e4fb9e60d50f9c49e
2021-10-15 19:27:33 +08:00
YouMin Chen
6a53296ce8 PM / devfreq: rockchip_dmc: remove of_get_rk3568_timings
For rk3568, ddr timings adjustment is no longer supported in dmc drive.

Signed-off-by: YouMin Chen <cym@rock-chips.com>
Change-Id: I63f0c5fea8c5acf8e6ef8f44b62968deb7bd823e
2021-10-15 19:26:59 +08:00
YouMin Chen
afda73facd arm64: dts: rockchip: rk3568: add dmc_fsp node
Add dmc_fsp node for initialize dmc frequency set point on U-Boot.

Signed-off-by: YouMin Chen <cym@rock-chips.com>
Change-Id: I9fcd1ae498a64b5a4698c42ad05af96740b59e61
2021-10-15 15:59:42 +08:00
YouMin Chen
ed286b021c arm64: dts: rockchip: rk3568-dram-default-timing: add ddr params
Add ddr parameters for initialize dmc frequency set point.

Signed-off-by: YouMin Chen <cym@rock-chips.com>
Change-Id: I3445fa2dbabca5774306cc1052cd3c1d472b6867
2021-10-15 15:57:38 +08:00
YouMin Chen
26dd1e440a include: linux: rockchip: add share mem page type for ddr fsp
Signed-off-by: YouMin Chen <cym@rock-chips.com>
Change-Id: Ie12446e746f4990287873d8ca52675f3398f45ae
2021-10-15 15:57:38 +08:00
YouMin Chen
f824af94ae dt-bindings: memory: add macro definition about LPDDR4 and LPDDR4X
Signed-off-by: YouMin Chen <cym@rock-chips.com>
Change-Id: I7bcf1f8c9f1d282a68d59dcc14fecaa7c0f59090
2021-10-15 15:57:38 +08:00
Ding Wei
fd69926be3 video: rockchip: mpp: Use spinlock for queue->running_lock
reason: mpp_iommu_handle is called by irq for iommu, thus it cannot
use mutex which might case sleep, thus use spinlock instead.

Call trace:
[   71.047958 ] Call trace:
[   71.047974 ]  dump_backtrace+0x0/0x160
[   71.047988 ]  show_stack+0x14/0x1c
[   71.048003 ]  dump_stack+0xd0/0x120
[   71.048018 ]  ___might_sleep+0x1f4/0x204
[   71.048032 ]  __might_sleep+0x4c/0x80
[   71.048045 ]  __mutex_lock_common+0x60/0x1028
[   71.048057 ]  mutex_lock_nested+0x28/0x30
[   71.048073 ]  mpp_iommu_handle+0x44/0x1c8
[   71.048088 ]  report_iommu_fault+0x3c/0x198
[   71.048102 ]  rk_iommu_irq+0x2a4/0x3bc
[   71.048117 ]  __handle_irq_event_percpu+0x114/0x3c4
[   71.048131 ]  handle_irq_event+0x5c/0xd0
[   71.048143 ]  handle_fasteoi_irq+0x124/0x220
[   71.048156 ]  __handle_domain_irq+0x9c/0xf4
[   71.048169 ]  gic_handle_irq+0x108/0x180
[   71.048181 ]  el1_irq+0xec/0x1a0
[   71.048194 ]  _raw_spin_unlock_irqrestore+0x3c/0x78
[   71.048209 ]  vop2_crtc_atomic_flush+0x1c78/0x202c
[   71.048223 ]  drm_atomic_helper_commit_planes+0x1a4/0x210
[   71.048238 ]  rockchip_atomic_commit_complete+0x1a4/0x390
[   71.048252 ]  rockchip_drm_atomic_commit+0x22c/0x24c
[   71.048266 ]  drm_mode_atomic_ioctl+0xa18/0xddc
[   71.048280 ]  drm_ioctl+0x2d8/0x46c
[   71.048296 ]  do_vfs_ioctl+0x4dc/0x794
[   71.048308 ]  __arm64_sys_ioctl+0x70/0x98
[   71.048322 ]  el0_svc_common+0xa0/0x18c
[   71.048335 ]  el0_svc_handler+0x28/0x60
[   71.048348 ]  el0_svc+0x8/0xc

Change-Id: Ie8e79995ec4bebf4ccbb509a57306541de861754
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2021-10-15 15:46:58 +08:00
Zhaoyang Huang
3ea11abdbe UPSTREAM: psi: Fix race between psi_trigger_create/destroy
Race detected between psi_trigger_destroy/create as shown below, which
cause panic by accessing invalid psi_system->poll_wait->wait_queue_entry
and psi_system->poll_timer->entry->next. Under this modification, the
race window is removed by initialising poll_wait and poll_timer in
group_init which are executed only once at beginning.

  psi_trigger_destroy()                   psi_trigger_create()

  mutex_lock(trigger_lock);
  rcu_assign_pointer(poll_task, NULL);
  mutex_unlock(trigger_lock);
					  mutex_lock(trigger_lock);
					  if (!rcu_access_pointer(group->poll_task)) {
					    timer_setup(poll_timer, poll_timer_fn, 0);
					    rcu_assign_pointer(poll_task, task);
					  }
					  mutex_unlock(trigger_lock);

  synchronize_rcu();
  del_timer_sync(poll_timer); <-- poll_timer has been reinitialized by
                                  psi_trigger_create()

So, trigger_lock/RCU correctly protects destruction of
group->poll_task but misses this race affecting poll_timer and
poll_wait.

Change-Id: I256e7679052ff960683b096e6d804cd4719cfa12
Fixes: 461daba06b ("psi: eliminate kthread_worker from psi trigger scheduling mechanism")
Co-developed-by: ziwei.dai <ziwei.dai@unisoc.com>
Signed-off-by: ziwei.dai <ziwei.dai@unisoc.com>
Co-developed-by: ke.wang <ke.wang@unisoc.com>
Signed-off-by: ke.wang <ke.wang@unisoc.com>
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Link: https://lkml.kernel.org/r/1623371374-15664-1-git-send-email-huangzhaoyang@gmail.com
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit 8f91efd870)
2021-10-14 18:55:05 +08:00
Suren Baghdasaryan
5d41e8fcf1 UPSTREAM: psi: eliminate kthread_worker from psi trigger scheduling mechanism
Each psi group requires a dedicated kthread_delayed_work and
kthread_worker. Since no other work can be performed using psi_group's
kthread_worker, the same result can be obtained using a task_struct and
a timer directly. This makes psi triggering simpler by removing lists
and locks involved with kthread_worker usage and eliminates the need for
poll_scheduled atomic use in the hot path.

Change-Id: Ib28d84949de068a8bc97dccb187ac3e68980a319
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200528195442.190116-1-surenb@google.com
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit 461daba06b)
2021-10-14 18:55:05 +08:00
William Wu
81e84034e8 usb: dwc3: gadget: increase intr ep resize tx fifo to 64B
For RV1109/RV1126 platforms, it resizes the tx fifos for
all of the usb device endpoints by default, it aims to
support UVC composite device, so just only set 16 bytes
for the tx fifo of the intr endpoints. But for the other
USB functions, like MTP function, it requires 64 bytes
tx fifo for its intr endpoint.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I27634dab473dad9a3e3d500cde7156c3eda514e8
2021-10-14 15:59:17 +08:00
Rafael J. Wysocki
00b9fb0f42 UPSTREAM: PM: runtime: Defer suspending suppliers
Because the PM-runtime status of the device is not updated in
__rpm_callback(), attempts to suspend the suppliers of the given
device triggered by the rpm_put_suppliers() call in there may
cause a supplier to be suspended completely before the status of
the consumer is updated to RPM_SUSPENDED, which is confusing.

To avoid that (1) modify __rpm_callback() to only decrease the
PM-runtime usage counter of each supplier and (2) make rpm_suspend()
try to suspend the suppliers after changing the consumer's status to
RPM_SUSPENDED, in analogy with the device's parent.

Change-Id: I2dbdf3999bc8a06bbbe29f57eb9cc1c49ec1aeff
Link: https://lore.kernel.org/linux-pm/CAPDyKFqm06KDw_p8WXsM4dijDbho4bb6T4k50UqqvR1_COsp8g@mail.gmail.com/
Fixes: 21d5c57b37 ("PM / runtime: Use device links")
Reported-by: elaine.zhang <zhangqing@rock-chips.com>
Diagnosed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 5244f5e2d8)
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-10-13 18:37:54 +08:00
Rafael J. Wysocki
c133510b15 UPSTREAM: Revert "PM: runtime: Update device status before letting suppliers suspend"
Revert commit 44cc89f764 ("PM: runtime: Update device status
before letting suppliers suspend") that introduced a race condition
into __rpm_callback() which allowed a concurrent rpm_resume() to
run and resume the device prematurely after its status had been
changed to RPM_SUSPENDED by __rpm_callback().

Change-Id: Id45cafe9a26bf1a97a9e12e510894c1e4c889e4b
Fixes: 44cc89f764 ("PM: runtime: Update device status before letting suppliers suspend")
Link: https://lore.kernel.org/linux-pm/24dfb6fc-5d54-6ee2-9195-26428b7ecf8a@intel.com/
Reported-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: 4.10+ <stable@vger.kernel.org> # 4.10+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
(cherry picked from commit 0cab893f40)
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-10-13 18:35:44 +08:00