Re: [PATCH] drm/panfrost: Avoid user size passed to kvmalloc()

2021-12-16 Thread Tomeu Vizoso

On 12/16/21 6:49 PM, Alyssa Rosenzweig wrote:

This provides an easy method for user
space to trigger the OOM killer (by temporarily allocating large amounts
of kernel memory)


panfrost user space has a lot of easy ways to trigger to the OOM killer
unfortunately  if this is something we want to fix there are a lot
more patches coming :(


What are you thinking of, Alyssa?

My understanding is that the problem are kernel allocations that aren't 
accounted per userspace process. I would expect shmem-backed BOs to be 
taken into account by the OOM killer, so the offending process would be 
terminated without affecting the other processes in the system.


Cheers,

Tomeu


Re: [PATCH] drm/panfrost: Avoid user size passed to kvmalloc()

2021-12-16 Thread Dan Carpenter
On Thu, Dec 16, 2021 at 12:49:53PM -0500, Alyssa Rosenzweig wrote:
> > This provides an easy method for user
> > space to trigger the OOM killer (by temporarily allocating large amounts
> > of kernel memory)
> 
> panfrost user space has a lot of easy ways to trigger to the OOM killer
> unfortunately  if this is something we want to fix there are a lot
> more patches coming :(

My static checker is only looking at the new rule that kvmalloc() can't
allocate more than 2GB.  But eventually syzbot will figure out how to
trigger the other OOMs so fixing that is going to be a requirement at
some point.

regards,
dan carpenter


Re: [PATCH v4 00/22] Support HDMI audio on NVIDIA Tegra20

2021-12-16 Thread Vinod Koul
On 16-12-21, 17:29, Dmitry Osipenko wrote:
> 15.12.2021 22:19, Dmitry Osipenko пишет:
> > 15.12.2021 21:57, Mark Brown пишет:
> >> On Sat, Dec 04, 2021 at 05:37:03PM +0300, Dmitry Osipenko wrote:
> >>
> >>> I based S/PDIF patches on Arnd's Bergmann patch from a separate series [1]
> >>> that removes obsolete slave_id. This eases merging of the patches by
> >>> removing the merge conflict. This is a note for Mark Brown.
> >> That's not in my tree so I'll need either a pull request with the series
> >> or a resend after the merge window.
> > This patch is included as a part of this series, please see the patch #6.
> > 
> > I saw that Vinod Koul already merged it into his DMA tree [1] a day ago,
> > but there is no stable branch there.
> > 
> > [1]
> > https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git/log/?h=next
> > 
> 
> Vinod, will you be a able to create immutable branch for us with the
> "dmaengine: kill off dma_slave_config->slave_id" patches [1]?
> 
> [1] https://lore.kernel.org/all/2021112203.4103644-1-a...@kernel.org/

Here you go:

The following changes since commit fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf:

  Linux 5.16-rc1 (2021-11-14 13:56:52 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git 
tags/dmaengine_topic_slave_id_removal_5.17

for you to fetch changes up to 3c219644075795a99271d345efdfa8b256e55161:

  dmaengine: remove slave_id config field (2021-12-17 11:23:56 +0530)


dmaengine_topic_slave_id_removal_5.17

Tag for dmaengine slave_id removal topic branch which should be merged
into v5.17


Arnd Bergmann (11):
  ASoC: tegra20-spdif: stop setting slave_id
  dmaengine: tegra20-apb: stop checking config->slave_id
  ASoC: dai_dma: remove slave_id field
  spi: pic32: stop setting dma_config->slave_id
  mmc: bcm2835: stop setting chan_config->slave_id
  dmaengine: shdma: remove legacy slave_id parsing
  dmaengine: pxa/mmp: stop referencing config->slave_id
  dmaengine: sprd: stop referencing config->slave_id
  dmaengine: qcom-adm: stop abusing slave_id config
  dmaengine: xilinx_dpdma: stop using slave_id field
  dmaengine: remove slave_id config field

 drivers/dma/mmp_pdma.c |  6 --
 drivers/dma/pxa_dma.c  |  7 ---
 drivers/dma/qcom/qcom_adm.c| 56 
+---
 drivers/dma/sh/shdma-base.c|  8 
 drivers/dma/sprd-dma.c |  3 ---
 drivers/dma/tegra20-apb-dma.c  |  6 --
 drivers/dma/xilinx/xilinx_dpdma.c  | 17 +++--
 drivers/gpu/drm/xlnx/zynqmp_disp.c |  9 +++--
 drivers/mmc/host/bcm2835.c |  2 --
 drivers/mtd/nand/raw/qcom_nandc.c  | 14 --
 drivers/spi/spi-pic32.c|  2 --
 drivers/tty/serial/msm_serial.c| 15 +--
 include/linux/dma/qcom_adm.h   | 12 
 include/linux/dma/xilinx_dpdma.h   | 11 +++
 include/linux/dmaengine.h  |  4 
 include/sound/dmaengine_pcm.h  |  2 --
 sound/core/pcm_dmaengine.c |  5 ++---
 sound/soc/tegra/tegra20_spdif.c|  1 -
 18 files changed, 117 insertions(+), 63 deletions(-)
 create mode 100644 include/linux/dma/qcom_adm.h
 create mode 100644 include/linux/dma/xilinx_dpdma.h

Thanks
-- 
~Vinod


signature.asc
Description: PGP signature


[git pull] drm fixes for 5.16-rc6

2021-12-16 Thread Dave Airlie
Hi Linus,

Mostly amdgpu fixes this week scattered around the driver, otherwise
one i915, one ast, one simpledrm. There is a revert in the fb-helper
for places userspace was using a string that we tried to change.

Regards,
Dave.

drm-fixes-2021-12-17-1:
drm fixes for 5.16-rc6

i915:
- Fix a bound check in the DMC fw load.

ast:
- NULL ptr deref fix

simpledrm:
- pixel clock units fix

fb-helper:
- userspace regression revert

amdgpu:
- Fix RLC register offset
- GMC fix
- Properly cache SMU FW version on Yellow Carp
- Fix missing callback on DCN3.1
- Reset DMCUB before HW init
- Fix for GMC powergating on PCO
- Fix a possible memory leak in GPU metrics table handling on RN
The following changes since commit 2585cf9dfaaddf00b069673f27bb3f8530e2039c:

  Linux 5.16-rc5 (2021-12-12 14:53:01 -0800)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm tags/drm-fixes-2021-12-17-1

for you to fetch changes up to a2fbfd517117157e99160ff1b39b171872dcba07:

  Merge tag 'amd-drm-fixes-5.16-2021-12-15' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes (2021-12-17
15:01:01 +1000)


drm fixes for 5.16-rc6

i915:
- Fix a bound check in the DMC fw load.

ast:
- NULL ptr deref fix

simpledrm:
- pixel clock units fix

fb-helper:
- userspace regression revert

amdgpu:
- Fix RLC register offset
- GMC fix
- Properly cache SMU FW version on Yellow Carp
- Fix missing callback on DCN3.1
- Reset DMCUB before HW init
- Fix for GMC powergating on PCO
- Fix a possible memory leak in GPU metrics table handling on RN


Alejandro Concepcion-Rodriguez (1):
  drm: simpledrm: fix wrong unit with pixel clock

Dave Airlie (3):
  Merge tag 'drm-intel-fixes-2021-12-15' of
ssh://git.freedesktop.org/git/drm/drm-intel into drm-fixes
  Merge tag 'drm-misc-fixes-2021-12-16-1' of
ssh://git.freedesktop.org/git/drm/drm-misc into drm-fixes
  Merge tag 'amd-drm-fixes-5.16-2021-12-15' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes

Evan Quan (1):
  drm/amdgpu: correct the wrong cached state for GMC on PICASSO

Harshit Mogalapalli (1):
  drm/i915/display: Fix an unsigned subtraction which can never be negative.

Hawking Zhang (1):
  drm/amdgpu: don't override default ECO_BITs setting

Javier Martinez Canillas (1):
  Revert "drm/fb-helper: improve DRM fbdev emulation device names"

Jiasheng Jiang (1):
  drm/ast: potential dereference of null pointer

Lang Yu (1):
  drm/amd/pm: fix a potential gpu_metrics_table memory leak

Le Ma (1):
  drm/amdgpu: correct register access for RLC_JUMP_TABLE_RESTORE

Mario Limonciello (1):
  drm/amd/pm: fix reading SMU FW version from amdgpu_firmware_info on YC

Nicholas Kazlauskas (2):
  drm/amd/display: Set exit_optimized_pwr_state for DCN31
  drm/amd/display: Reset DMCUB before HW init

 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c   | 9 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c   | 1 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c   | 1 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c   | 1 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c   | 2 --
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +
 drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 1 +
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c  | 7 ++-
 drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c| 3 +++
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c| 3 +++
 drivers/gpu/drm/ast/ast_mode.c| 5 -
 drivers/gpu/drm/drm_fb_helper.c   | 8 +++-
 drivers/gpu/drm/i915/display/intel_dmc.c  | 2 +-
 drivers/gpu/drm/tiny/simpledrm.c  | 2 +-
 19 files changed, 45 insertions(+), 20 deletions(-)


Re: [PATCH v1, 12/12] media: mtk-vcodec: Add h264 slice api driver for mt8192

2021-12-16 Thread yunfei.d...@mediatek.com
Hi Nicolas,

Thanks for your suggestion.
On Wed, 2021-12-15 at 10:27 -0500, Nicolas Dufresne wrote:
> Hi Yunfei,
> 
> Le mercredi 15 décembre 2021 à 14:59 +0800, Yunfei Dong a écrit :
> > From: Yunfei Dong 
> > 
> > Adds h264 lat and core driver for mt8192.
> 
> This is purely a nit, but I have first notice the usage of "slice" in
> the
> namespace and the title, which lead me to think this new platform was
> V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED. I think some structure
> which are

> clearly frame_based should probably be renamed (its the namespace
> that is
> confusing) to reduce the confusion.
> 
This driver is frame_based used for mt8182 lat and core architecture.
I will fix the commit in next patch.

Thanks for your remind.

Best Regards,
Yunfei Dong
> p.s. Note that adding slice_based mode would be amazing for streaming
> with ultra
> low latency (think remote video games)
> 
> regards,
> Nicolas
> 
> > 
> > Signed-off-by: Yunfei Dong 
> > ---
> >  drivers/media/platform/mtk-vcodec/Makefile|   1 +
> >  .../mtk-vcodec/vdec/vdec_h264_req_lat_if.c| 620
> > ++
> >  .../media/platform/mtk-vcodec/vdec_drv_if.c   |   8 +-
> >  .../media/platform/mtk-vcodec/vdec_drv_if.h   |   1 +
> >  include/linux/remoteproc/mtk_scp.h|   2 +
> >  5 files changed, 631 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/media/platform/mtk-
> > vcodec/vdec/vdec_h264_req_lat_if.c
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/Makefile
> > b/drivers/media/platform/mtk-vcodec/Makefile
> > index 3f41d748eee5..1777d7606f0d 100644
> > --- a/drivers/media/platform/mtk-vcodec/Makefile
> > +++ b/drivers/media/platform/mtk-vcodec/Makefile
> > @@ -10,6 +10,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
> > vdec/vdec_vp9_if.o \
> > vdec/vdec_h264_req_if.o \
> > vdec/vdec_h264_req_common.o \
> > +   vdec/vdec_h264_req_lat_if.o \
> > mtk_vcodec_dec_drv.o \
> > vdec_drv_if.o \
> > vdec_vpu_if.o \
> > diff --git a/drivers/media/platform/mtk-
> > vcodec/vdec/vdec_h264_req_lat_if.c b/drivers/media/platform/mtk-
> > vcodec/vdec/vdec_h264_req_lat_if.c
> > new file mode 100644
> > index ..403d7df00e1d
> > --- /dev/null
> > +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_lat_if.c
> > @@ -0,0 +1,620 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (c) 2021 MediaTek Inc.
> > + * Author: Yunfei Dong 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "../mtk_vcodec_util.h"
> > +#include "../mtk_vcodec_dec.h"
> > +#include "../mtk_vcodec_intr.h"
> > +#include "../vdec_drv_base.h"
> > +#include "../vdec_drv_if.h"
> > +#include "../vdec_vpu_if.h"
> > +#include "vdec_h264_req_common.h"
> > +
> > +/**
> > + * enum vdec_h264_core_dec_err_type  - core decode error type
> > + */
> > +enum vdec_h264_core_dec_err_type {
> > +   TRANS_BUFFER_FULL = 1,
> > +   SLICE_HEADER_FULL,
> > +};
> > +
> > +/**
> > + * struct vdec_h264_slice_lat_dec_param  - parameters for decode
> > current frame
> > + * @sps : h264 sps syntax parameters
> > + * @pps : h264 pps syntax parameters
> > + * @slice_header: h264 slice header syntax parameters
> > + * @scaling_matrix : h264 scaling list parameters
> > + * @decode_params : decoder parameters of each frame used for
> > hardware decode
> > + * @h264_dpb_info : dpb reference list
> > + */
> > +struct vdec_h264_slice_lat_dec_param {
> > +   struct mtk_h264_sps_param sps;
> > +   struct mtk_h264_pps_param pps;
> > +   struct mtk_h264_slice_hd_param slice_header;
> > +   struct slice_api_h264_scaling_matrix scaling_matrix;
> > +   struct slice_api_h264_decode_param decode_params;
> > +   struct mtk_h264_dpb_info
> > h264_dpb_info[V4L2_H264_NUM_DPB_ENTRIES];
> > +};
> > +
> > +/**
> > + * struct vdec_h264_slice_info - decode information
> > + * @nal_info: nal info of current picture
> > + * @timeout : Decode timeout: 1 timeout, 0 no timeount
> > + * @bs_buf_size : bitstream size
> > + * @bs_buf_addr : bitstream buffer dma address
> > + * @y_fb_dma: Y frame buffer dma address
> > + * @c_fb_dma: C frame buffer dma address
> > + * @vdec_fb_va  : VDEC frame buffer struct virtual address
> > + * @crc : Used to check whether hardware's status is right
> > + */
> > +struct vdec_h264_slice_info {
> > +   uint16_t nal_info;
> > +   uint16_t timeout;
> > +   uint32_t bs_buf_size;
> > +   uint64_t bs_buf_addr;
> > +   uint64_t y_fb_dma;
> > +   uint64_t c_fb_dma;
> > +   uint64_t vdec_fb_va;
> > +   uint32_t crc[8];
> > +};
> > +
> > +/**
> > + * struct vdec_h264_slice_vsi - shared memory for decode
> > information exchange
> > + *between VPU and Host. The memory is allocated by VPU
> > then mapping to
> > + *Host in vdec_h264_slice_init() and freed in
> > vdec_h264_slice_deinit()
> > + *by VPU. AP-W/R : AP is writer/reader on this item. VPU-
> > W/R: VPU is
> 

回复: Re: Re: 回复: Re: [PATCH] drm/amdgpu: fixup bad vram size on gmc v8

2021-12-16 Thread 周宗敏
Dear Alex:>Is the issue reproducible with the same board in bare metal on x86?Or does it only happen with passthrough on ARM?Unfortunately, my current environment is not convenient to test this GPU board on x86 platform.but I can tell you the problem still occurs on ARM without passthrough to virtual machine.In addition,at end of 2020,my colleagues also found similar problems on MIPS platforms with Graphics chips of Radeon R7 340.So,I may think it can happen to no matter based on x86 ,ARM or mips.I hope the above information is helpful to you,and I also think it will be better for user if can root cause this issue.Best regards.

    
        主 题:Re: Re: 回复: Re: [PATCH] drm/amdgpu: fixup bad vram size on gmc v8
            日 期:2021-12-16 23:28
            发件人:Alex Deucher
            收件人:周宗敏
            
        
        Is the issue reproducible with the same board in bare metal on x86?  Or does it only happen with passthrough on ARM?  Looking through the archives, the SI patch I made was for an x86 laptop.  It would be nice to root cause this, but there weren't any gfx8 boards with more than 64G of vram, so I think it's safe.  That said, if you see similar issues with newer gfx IPs then we have an issue since the upper bit will be meaningful, so it would be nice to root cause this.AlexOn Thu, Dec 16, 2021 at 4:36 AM 周宗敏  wrote:Hi  Christian,I'm  testing for GPU passthrough feature, so I pass through this GPU to  virtual machine to use. It  based on arm64 system.As far as i know, Alex had dealt with a similar problems on dri/radeon/si.c .  Maybe they have a same reason to cause it?the history commit message is below:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ca223b029a261e82fb2f50c52eb85d510f4260eThanks very much.       主 题:Re: 回复: Re: [PATCH] drm/amdgpu: fixup bad vram size on gmc v8
            日 期:2021-12-16 16:15
            发件人:Christian König
            收件人:周宗敏Alex Deucher
            
        
        Hi Zongmin,
    
    that strongly sounds like the ASIC is not correctly initialized when
    trying to read the register.
    
    What board and environment are you using this GPU with? Is that a
    normal x86 system?
    
    Regards,
    Christian.
    
    Am 16.12.21 um 04:11 schrieb 周宗敏:
    the problematic boards that I have tested is [AMD/ATI] Lexa
            PRO [Radeon RX 550/550X] ;  and the vbios version :
            113-RXF9310-C09-BTWhen an exception occurs I can see the following changes in
            the values of vram size get from RREG32(mmCONFIG_MEMSIZE) ,it seems to have garbage in the upper 16 bits 
          
          and then I can also see some dmesg like below:when vram size register have garbage,we may see error
            message like below:amdgpu :09:00.0: VRAM: 4286582784M 0x00F4 -
            0x000FF8F4 (4286582784M used)the correct message should like below:amdgpu :09:00.0: VRAM: 4096M 0x00F4 -
            0x00F4 (4096M used)
          if you have any problems,please send me mail.thanks very much.
                主 题:Re: [PATCH] drm/amdgpu:
          fixup bad vram size on gmc v8            
        日 期:2021-12-16 04:23    
               
        发件人:Alex Deucher        
           
        收件人:Zongmin Zhou          
                 
               On Wed, Dec 15, 2021 at 10:31 AM Zongmin Zhouwrote:
          >
          > Some boards(like RX550) seem to have garbage in the upper
          > 16 bits of the vram size register.  Check for
          > this and clamp the size properly.  Fixes
          > boards reporting bogus amounts of vram.
          >
          > after add this patch,the maximum GPU VRAM size is 64GB,
          > otherwise only 64GB vram size will be used.
          
          Can you provide some examples of problematic boards and
          possibly a
          vbios image from the problematic board?  What values are you
          seeing?
          It would be nice to see what the boards are reporting and
          whether the
          lower 16 bits are actually correct or if it is some other
          issue.  This
          register is undefined until the asic has been initialized.
           The vbios
          programs it as part of it's asic init sequence (either via
          vesa/gop or
          the OS driver).
          
          Alex
          
          
          >
          > Signed-off-by: Zongmin Zhou
            > ---
            >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 13
            ++---
            >  1 file changed, 10 insertions(+), 3 deletions(-)
            >
            > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
            b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
            > index 492ebed2915b..63b890f1e8af 100644
            > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
            > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
            > @@ -515,10 +515,10 @@ static void

[PATCH] drm/amdgpu: potential dereference of null pointer

2021-12-16 Thread Jiasheng Jiang
The return value of dma_alloc_coherent() needs to be checked.
To avoid use of null pointer in memcpy_toio() in case of the failure of
alloc.

Fixes: 57430471e2fa ("drm/amdgpu: Add support for USBC PD FW download")
Signed-off-by: Jiasheng Jiang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index a09483beb968..613e25bf87e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -3034,6 +3034,10 @@ static ssize_t psp_usbc_pd_fw_sysfs_write(struct device 
*dev,
 
/* We need contiguous physical mem to place the FW  for psp to access */
cpu_addr = dma_alloc_coherent(adev->dev, usbc_pd_fw->size, _addr, 
GFP_KERNEL);
+   if (!cpu_addr) {
+   ret = -ENOMEM;
+   goto rel_buf;
+   }
 
ret = dma_mapping_error(adev->dev, dma_addr);
if (ret)
-- 
2.25.1



[PATCH v17, 17/19] media: mtk-vcodec: Use codec type to separate different hardware

2021-12-16 Thread Yunfei Dong
There is just one core thread, in order to separate different
hardware, using codec type to separeate it in scp driver.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../media/platform/mtk-vcodec/vdec_ipi_msg.h  | 12 ---
 .../media/platform/mtk-vcodec/vdec_vpu_if.c   | 34 ---
 .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  4 +++
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h 
b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
index 9d8079c4f976..5daca8d52ebb 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
@@ -35,6 +35,8 @@ enum vdec_ipi_msgid {
  * @msg_id : vdec_ipi_msgid
  * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2.
  * @inst_id : instance ID. Used if the ABI version >= 2.
+ * @codec_type : codec fourcc
+ * @reserved   : reserved param
  */
 struct vdec_ap_ipi_cmd {
uint32_t msg_id;
@@ -42,6 +44,8 @@ struct vdec_ap_ipi_cmd {
uint32_t vpu_inst_addr;
uint32_t inst_id;
};
+   uint32_t codec_type;
+   uint32_t reserved;
 };
 
 /**
@@ -59,12 +63,12 @@ struct vdec_vpu_ipi_ack {
 /**
  * struct vdec_ap_ipi_init - for AP_IPIMSG_DEC_INIT
  * @msg_id : AP_IPIMSG_DEC_INIT
- * @reserved   : Reserved field
+ * @codec_type : codec fourcc
  * @ap_inst_addr   : AP video decoder instance address
  */
 struct vdec_ap_ipi_init {
uint32_t msg_id;
-   uint32_t reserved;
+   uint32_t codec_type;
uint64_t ap_inst_addr;
 };
 
@@ -77,7 +81,7 @@ struct vdec_ap_ipi_init {
  * H264 decoder [0]:buf_sz [1]:nal_start
  * VP8 decoder  [0]:width/height
  * VP9 decoder  [0]:profile, [1][2] width/height
- * @reserved   : Reserved field
+ * @codec_type : codec fourcc
  */
 struct vdec_ap_ipi_dec_start {
uint32_t msg_id;
@@ -86,7 +90,7 @@ struct vdec_ap_ipi_dec_start {
uint32_t inst_id;
};
uint32_t data[3];
-   uint32_t reserved;
+   uint32_t codec_type;
 };
 
 /**
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index bfd8e87dceff..c84fac52fe26 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -100,18 +100,29 @@ static void vpu_dec_ipi_handler(void *data, unsigned int 
len, void *priv)
 
 static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
 {
-   int err;
+   int err, id, msgid;
 
-   mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
+   msgid = *(uint32_t *)msg;
+   mtk_vcodec_debug(vpu, "id=%X", msgid);
 
vpu->failure = 0;
vpu->signaled = 0;
 
-   err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, vpu->id, msg,
+   if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE) {
+   if (msgid == AP_IPIMSG_DEC_CORE ||
+   msgid == AP_IPIMSG_DEC_CORE_END)
+   id = vpu->core_id;
+   else
+   id = vpu->id;
+   } else {
+   id = vpu->id;
+   }
+
+   err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, id, msg,
 len, 2000);
if (err) {
mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
-  vpu->id, *(uint32_t *)msg, err);
+  id, msgid, err);
return err;
}
 
@@ -131,6 +142,7 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, 
unsigned int msg_id)
msg.vpu_inst_addr = vpu->inst_addr;
else
msg.inst_id = vpu->inst_id;
+   msg.codec_type = vpu->codec_type;
 
err = vcodec_vpu_send_msg(vpu, , sizeof(msg));
mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err);
@@ -149,14 +161,25 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
 
err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler, vpu->id,
 vpu->handler, "vdec", NULL);
-   if (err != 0) {
+   if (err) {
mtk_vcodec_err(vpu, "vpu_ipi_register fail status=%d", err);
return err;
}
 
+   if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE) {
+   err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler,
+vpu->core_id, vpu->handler,
+"vdec", NULL);
+   if (err) {
+   mtk_vcodec_err(vpu, "vpu_ipi_register core fail 
status=%d", err);
+   return err;
+   }
+   }
+
memset(, 0, sizeof(msg));
msg.msg_id = AP_IPIMSG_DEC_INIT;
msg.ap_inst_addr = (unsigned long)vpu;
+   msg.codec_type = vpu->codec_type;
 

[PATCH v17, 18/19] media: mtk-vcodec: Remove mtk_vcodec_release_dec_pm

2021-12-16 Thread Yunfei Dong
There are only two lines in mtk_vcodec_release_dec_pm, using
pm_runtime_disable and put_device instead directly.

Move pm_runtime_enable outside mtk_vcodec_init_dec_pm to symmetry with
pm_runtime_disable, after that, rename mtk_vcodec_init_dec_pm to *_clk since
it only has clock operations now.

Signed-off-by: Yunfei Dong 
Co-developed-by: Yong Wu 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c   | 10 +++---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c|  7 +--
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c| 12 ++--
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h|  3 +--
 4 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 1c2b96b4930b..d44894fa2f6e 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -128,12 +129,13 @@ static int mtk_vcodec_init_dec_resources(struct 
mtk_vcodec_dev *dev)
return ret;
}
 
-   ret = mtk_vcodec_init_dec_pm(pdev, >pm);
+   ret = mtk_vcodec_init_dec_clk(pdev, >pm);
if (ret < 0) {
dev_err(>dev, "failed to get mt vcodec clock source");
return ret;
}
 
+   pm_runtime_enable(>dev);
return 0;
 }
 
@@ -446,7 +448,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch))
destroy_workqueue(dev->core_workqueue);
 err_res:
-   mtk_vcodec_release_dec_pm(>pm);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvdec);
 err_dec_pm:
mtk_vcodec_fw_release(dev->fw_handler);
return ret;
@@ -489,7 +492,8 @@ static int mtk_vcodec_dec_remove(struct platform_device 
*pdev)
video_unregister_device(dev->vfd_dec);
 
v4l2_device_unregister(>v4l2_dev);
-   mtk_vcodec_release_dec_pm(>pm);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvdec);
mtk_vcodec_fw_release(dev->fw_handler);
return 0;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index 643cee119b60..8e1247d65a93 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "mtk_vcodec_drv.h"
@@ -140,9 +141,10 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
return -ENOMEM;
 
subdev_dev->plat_dev = pdev;
-   ret = mtk_vcodec_init_dec_pm(pdev, _dev->pm);
+   ret = mtk_vcodec_init_dec_clk(pdev, _dev->pm);
if (ret)
return ret;
+   pm_runtime_enable(>dev);
 
of_id = of_match_device(mtk_vdec_hw_match, dev);
if (!of_id) {
@@ -181,7 +183,8 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, subdev_dev);
return 0;
 err:
-   mtk_vcodec_release_dec_pm(_dev->pm);
+   pm_runtime_disable(subdev_dev->pm.dev);
+   put_device(subdev_dev->pm.larbvdec);
return ret;
 }
 
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 4cf03d38d141..b9f5ef979c69 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -15,7 +15,7 @@
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_util.h"
 
-int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+int mtk_vcodec_init_dec_clk(struct platform_device *pdev,
struct mtk_vcodec_pm *pm)
 {
struct device_node *node;
@@ -73,20 +73,12 @@ int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
}
}
 
-   pm_runtime_enable(>dev);
return 0;
 put_device:
put_device(pm->larbvdec);
return ret;
 }
-EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_pm);
-
-void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
-{
-   pm_runtime_disable(pm->dev);
-   put_device(pm->larbvdec);
-}
-EXPORT_SYMBOL_GPL(mtk_vcodec_release_dec_pm);
+EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk);
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
 {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
index 6ae29fea4e7f..c4121df9764f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
@@ -9,9 +9,8 @@
 
 #include "mtk_vcodec_drv.h"
 
-int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+int mtk_vcodec_init_dec_clk(struct platform_device *pdev,
 

[PATCH v17, 12/19] media: mtk-vcodec: Add new interface to lock different hardware

2021-12-16 Thread Yunfei Dong
For add new hardware, not only need to lock lat hardware, also
need to lock core hardware in case of different instance start
to decoder at the same time.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++--
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 5 +++--
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 2b334a8a81c6..130ecef2e766 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -105,12 +105,12 @@ static int vidioc_decoder_cmd(struct file *file, void 
*priv,
 
 void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx)
 {
-   mutex_unlock(>dev->dec_mutex);
+   mutex_unlock(>dev->dec_mutex[ctx->hw_id]);
 }
 
 void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx)
 {
-   mutex_lock(>dev->dec_mutex);
+   mutex_lock(>dev->dec_mutex[ctx->hw_id]);
 }
 
 void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx)
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 64359cf692f5..471b8c6ba7f2 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -279,7 +279,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
struct video_device *vfd_dec;
phandle rproc_phandle;
enum mtk_vcodec_fw_type fw_type;
-   int ret;
+   int i, ret;
 
dev = devm_kzalloc(>dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
@@ -311,7 +311,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_dec_pm;
}
 
-   mutex_init(>dec_mutex);
+   for (i = 0; i < MTK_VDEC_HW_MAX; i++)
+   mutex_init(>dec_mutex[i]);
mutex_init(>dev_mutex);
spin_lock_init(>irqlock);
 
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index adc5998ed424..517515ee9ac4 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -500,7 +500,7 @@ struct mtk_vcodec_dev {
int dec_irq;
int enc_irq;
 
-   struct mutex dec_mutex;
+   struct mutex dec_mutex[MTK_VDEC_HW_MAX];
struct mutex enc_mutex;
 
struct mtk_vcodec_pm pm;
-- 
2.25.1



[PATCH v17, 08/19] media: mtk-vcodec: Use pure single core for MT8183

2021-12-16 Thread Yunfei Dong
Separates different architecture for hardware: pure_sin_core
and lat_sin_core. MT8183 is pure single core. Uses .hw_arch to
distinguish.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../platform/mtk-vcodec/mtk_vcodec_dec_stateful.c  |  1 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_stateless.c |  2 ++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 10 ++
 3 files changed, 13 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
index c7f9259ad094..04ca43c77e5f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
@@ -626,4 +626,5 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
+   .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
 };
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 3294c8957ae5..23d997ac114d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -357,6 +357,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
+   .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
 };
 
 /* This platform data is used for one lat and one core architecture. */
@@ -375,4 +376,5 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = true,
+   .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
 };
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 7f97fbf0f073..6d07bf997cc1 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -324,6 +324,14 @@ enum mtk_chip {
MTK_MT8195,
 };
 
+/**
+ * struct mtk_vdec_hw_arch - Used to separate different hardware architecture
+ */
+enum mtk_vdec_hw_arch {
+   MTK_VDEC_PURE_SINGLE_CORE,
+   MTK_VDEC_LAT_SINGLE_CORE,
+};
+
 /**
  * struct mtk_vcodec_dec_pdata - compatible data for each IC
  * @init_vdec_params: init vdec params
@@ -342,6 +350,7 @@ enum mtk_chip {
  * @num_framesizes: count of video decoder frame sizes
  *
  * @chip: chip this decoder is compatible with
+ * @hw_arch: hardware arch is used to separate pure_sin_core and lat_sin_core
  *
  * @is_subdev_supported: whether support parent-node architecture(subdev)
  * @uses_stateless_api: whether the decoder uses the stateless API with 
requests
@@ -364,6 +373,7 @@ struct mtk_vcodec_dec_pdata {
const int num_framesizes;
 
enum mtk_chip chip;
+   enum mtk_vdec_hw_arch hw_arch;
 
bool is_subdev_supported;
bool uses_stateless_api;
-- 
2.25.1



[PATCH v17, 19/19] media: mtk-vcodec: Remove mtk_vcodec_release_enc_pm

2021-12-16 Thread Yunfei Dong
There are only two lines in mtk_vcodec_release_enc_pm, using
pm_runtime_disable and put_device instead directly.

Move pm_runtime_enable outside mtk_vcodec_release_enc_pm to symmetry with
pm_runtime_disable, after that, rename mtk_vcodec_init_enc_pm to *_clk since
it only has clock operations now.

Signed-off-by: Yunfei Dong 
Co-developed-by: Yong Wu 
Reviewed-by: AngeloGioacchino Del Regno 

---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 9 ++---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  | 9 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h  | 3 +--
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index 347f0d87e2ff..507ad1ea2104 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -257,7 +258,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
return PTR_ERR(dev->fw_handler);
 
dev->venc_pdata = of_device_get_match_data(>dev);
-   ret = mtk_vcodec_init_enc_pm(dev);
+   ret = mtk_vcodec_init_enc_clk(dev);
if (ret < 0) {
dev_err(>dev, "Failed to get mtk vcodec clock source!");
goto err_enc_pm;
@@ -369,7 +370,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 err_enc_alloc:
v4l2_device_unregister(>v4l2_dev);
 err_res:
-   mtk_vcodec_release_enc_pm(dev);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvenc);
 err_enc_pm:
mtk_vcodec_fw_release(dev->fw_handler);
return ret;
@@ -458,7 +460,8 @@ static int mtk_vcodec_enc_remove(struct platform_device 
*pdev)
video_unregister_device(dev->vfd_enc);
 
v4l2_device_unregister(>v4l2_dev);
-   mtk_vcodec_release_enc_pm(dev);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvenc);
mtk_vcodec_fw_release(dev->fw_handler);
return 0;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
index 0c8c8f86788c..0825c6ec4eb7 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
@@ -13,7 +13,7 @@
 #include "mtk_vcodec_enc_pm.h"
 #include "mtk_vcodec_util.h"
 
-int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
+int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
 {
struct device_node *node;
struct platform_device *pdev;
@@ -86,13 +86,6 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
return ret;
 }
 
-void mtk_vcodec_release_enc_pm(struct mtk_vcodec_dev *mtkdev)
-{
-   pm_runtime_disable(mtkdev->pm.dev);
-   put_device(mtkdev->pm.larbvenc);
-}
-
-
 void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
 {
struct mtk_vcodec_clk *enc_clk = >venc_clk;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
index b7ecdfd74823..bc455cefc0cd 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
@@ -9,8 +9,7 @@
 
 #include "mtk_vcodec_drv.h"
 
-int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *dev);
-void mtk_vcodec_release_enc_pm(struct mtk_vcodec_dev *dev);
+int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *dev);
 
 void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm);
 void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm);
-- 
2.25.1



[PATCH v17, 11/19] media: mtk-vcodec: Generalize power and clock on/off interfaces

2021-12-16 Thread Yunfei Dong
Generalizes power and clock on/off interfaces to support different hardware.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  6 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   |  2 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.h   |  4 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 76 +--
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.h   |  8 +-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  2 +
 .../platform/mtk-vcodec/mtk_vcodec_util.c | 59 +++---
 .../platform/mtk-vcodec/mtk_vcodec_util.h |  8 +-
 .../media/platform/mtk-vcodec/vdec_drv_if.c   | 21 ++---
 9 files changed, 146 insertions(+), 40 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 9802e5cc535f..64359cf692f5 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -46,7 +46,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
void __iomem *vdec_misc_addr = dev->reg_base[VDEC_MISC] +
VDEC_IRQ_CFG_REG;
 
-   ctx = mtk_vcodec_get_curr_ctx(dev);
+   ctx = mtk_vcodec_get_curr_ctx(dev, MTK_VDEC_CORE);
 
/* check if HW active or not */
cg_status = readl(dev->reg_base[0]);
@@ -193,7 +193,7 @@ static int fops_vcodec_open(struct file *file)
mtk_vcodec_dec_set_default_params(ctx);
 
if (v4l2_fh_is_singular(>fh)) {
-   ret = mtk_vcodec_dec_pw_on(>pm);
+   ret = mtk_vcodec_dec_pw_on(dev, MTK_VDEC_LAT0);
if (ret < 0)
goto err_load_fw;
/*
@@ -253,7 +253,7 @@ static int fops_vcodec_release(struct file *file)
mtk_vcodec_dec_release(ctx);
 
if (v4l2_fh_is_singular(>fh))
-   mtk_vcodec_dec_pw_off(>pm);
+   mtk_vcodec_dec_pw_off(dev, MTK_VDEC_LAT0);
v4l2_fh_del(>fh);
v4l2_fh_exit(>fh);
v4l2_ctrl_handler_free(>ctrl_hdl);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index b149c3058995..643cee119b60 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -65,7 +65,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void 
*priv)
void __iomem *vdec_misc_addr = dev->reg_base[VDEC_HW_MISC] +
VDEC_IRQ_CFG_REG;
 
-   ctx = mtk_vcodec_get_curr_ctx(dev->main_dev);
+   ctx = mtk_vcodec_get_curr_ctx(dev->main_dev, dev->hw_idx);
 
/* check if HW active or not */
cg_status = readl(dev->reg_base[VDEC_HW_SYS]);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
index 0db0c8c310da..c0cd0cdab9ee 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
@@ -32,6 +32,8 @@ enum mtk_vdec_hw_reg_idx {
  * @main_dev: main device
  * @reg_base: Mapped address of MTK Vcodec registers.
  *
+ * @curr_ctx: the context that is waiting for codec hardware
+ *
  * @dec_irq: decoder irq resource
  * @pm: power management control
  * @hw_idx: each hardware index
@@ -41,6 +43,8 @@ struct mtk_vdec_hw_dev {
struct mtk_vcodec_dev *main_dev;
void __iomem *reg_base[VDEC_HW_MAX];
 
+   struct mtk_vcodec_ctx *curr_ctx;
+
int dec_irq;
struct mtk_vcodec_pm pm;
int hw_idx;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 221cf60e9fbf..4cf03d38d141 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -5,11 +5,13 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
+#include "mtk_vcodec_dec_hw.h"
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_util.h"
 
@@ -86,10 +88,23 @@ void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
 }
 EXPORT_SYMBOL_GPL(mtk_vcodec_release_dec_pm);
 
-int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
+int mtk_vcodec_dec_pw_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
 {
+   struct mtk_vdec_hw_dev *subdev_dev;
+   struct mtk_vcodec_pm *pm;
int ret;
 
+   if (vdec_dev->vdec_pdata->is_subdev_supported) {
+   subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
+   if (!subdev_dev) {
+   mtk_v4l2_err("Failed to get hw dev\n");
+   return -EINVAL;
+   }
+   pm = _dev->pm;
+   } else {
+   pm = _dev->pm;
+   }
+
ret = pm_runtime_resume_and_get(pm->dev);
if (ret)
mtk_v4l2_err("pm_runtime_resume_and_get 

[PATCH v17, 14/19] media: mtk-vcodec: Support 34bits dma address for vdec

2021-12-16 Thread Yunfei Dong
Use the dma_set_mask_and_coherent helper to set vdec
DMA bit mask to support 34bits iova space(16GB) that
the mt8192 iommu HW support.

Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
regarding which iova range VDEC actually locate, it
depends on the dma-ranges property of vdec dtsi node.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 10215ccc85f7..1c2b96b4930b 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -322,6 +322,14 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}
}
 
+   if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(34));
+   if (ret) {
+   mtk_v4l2_err("Failed to set mask");
+   goto err_core_workq;
+   }
+   }
+
for (i = 0; i < MTK_VDEC_HW_MAX; i++)
mutex_init(>dec_mutex[i]);
mutex_init(>dev_mutex);
-- 
2.25.1



[PATCH v17, 15/19] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8192

2021-12-16 Thread Yunfei Dong
Adds decoder dt-bindings for mt8192.

Signed-off-by: Yunfei Dong 
Reviewed-by: Rob Herring 
---
 .../media/mediatek,vcodec-subdev-decoder.yaml | 265 ++
 1 file changed, 265 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml

diff --git 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
new file mode 100644
index ..d587fc3e39fb
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
@@ -0,0 +1,265 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/media/mediatek,vcodec-subdev-decoder.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: Mediatek Video Decode Accelerator With Multi Hardware
+
+maintainers:
+  - Yunfei Dong 
+
+description: |
+  Mediatek Video Decode is the video decode hardware present in Mediatek
+  SoCs which supports high resolution decoding functionalities. Required
+  parent and child device node.
+
+  About the Decoder Hardware Block Diagram, please check below:
+
++-++
+| ||
+| input -> lat HW -> lat buffer --|--> lat buffer -> core HW -> output |
+|||   | || |
++||---+-||-+
+  lat workqueue   |  core workqueue 

+
-||-||--
+ || ||  
+ \/ \/
+   +--+
+   |enable/disable|
+   |   clk powerirqiommu  |
+   | (lat/lat soc/core0/core1)|
+   +--+
+
+  As above, there are parent and child devices, child mean each hardware. The 
child device
+  controls the information of each hardware independent which include 
clk/power/irq.
+
+  There are two workqueues in parent device: lat workqueue and core workqueue. 
They are used
+  to lat and core hardware deocder. Lat workqueue need to get input bitstream 
and lat buffer,
+  then enable lat to decode, writing the result to lat buffer, dislabe 
hardware when lat decode
+  done. Core workqueue need to get lat buffer and output buffer, then enable 
core to decode,
+  writing the result to output buffer, disable hardware when core decode done. 
These two
+  hardwares will decode each frame cyclically.
+
+  For the smi common may not the same for each hardware, can't combine all 
hardware in one node,
+  or leading to iommu fault when access dram data.
+
+properties:
+  compatible:
+const: mediatek,mt8192-vcodec-dec
+
+  reg:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  mediatek,scp:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description: |
+  The node of system control processor (SCP), using
+  the remoteproc & rpmsg framework.
+
+  dma-ranges:
+maxItems: 1
+description: |
+  Describes the physical address space of IOMMU maps to memory.
+
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 1
+
+  ranges: true
+
+# Required child node:
+patternProperties:
+  '^vcodec-lat@[0-9a-f]+$':
+type: object
+
+properties:
+  compatible:
+const: mediatek,mtk-vcodec-lat
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  clocks:
+maxItems: 5
+
+  clock-names:
+items:
+  - const: sel
+  - const: soc-vdec
+  - const: soc-lat
+  - const: vdec
+  - const: top
+
+  assigned-clocks:
+maxItems: 1
+
+  assigned-clock-parents:
+maxItems: 1
+
+  power-domains:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - iommus
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+  - power-domains
+
+additionalProperties: false
+
+  '^vcodec-core@[0-9a-f]+$':
+type: object
+
+properties:
+  compatible:
+const: 

[PATCH v17, 16/19] media: mtk-vcodec: Add core dec and dec end ipi msg

2021-12-16 Thread Yunfei Dong
Add core dec and dec end ipi msg: AP_IPIMSG_DEC_CORE/AP_IPIMSG_DEC_CORE_END.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../media/platform/mtk-vcodec/vdec_ipi_msg.h   |  4 
 .../media/platform/mtk-vcodec/vdec_vpu_if.c| 12 
 .../media/platform/mtk-vcodec/vdec_vpu_if.h| 18 ++
 3 files changed, 34 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h 
b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
index 5f45a537beb4..9d8079c4f976 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
@@ -18,12 +18,16 @@ enum vdec_ipi_msgid {
AP_IPIMSG_DEC_END = 0xA002,
AP_IPIMSG_DEC_DEINIT = 0xA003,
AP_IPIMSG_DEC_RESET = 0xA004,
+   AP_IPIMSG_DEC_CORE = 0xA005,
+   AP_IPIMSG_DEC_CORE_END = 0xA006,
 
VPU_IPIMSG_DEC_INIT_ACK = 0xB000,
VPU_IPIMSG_DEC_START_ACK = 0xB001,
VPU_IPIMSG_DEC_END_ACK = 0xB002,
VPU_IPIMSG_DEC_DEINIT_ACK = 0xB003,
VPU_IPIMSG_DEC_RESET_ACK = 0xB004,
+   VPU_IPIMSG_DEC_CORE_ACK = 0xB005,
+   VPU_IPIMSG_DEC_CORE_END_ACK = 0xB006,
 };
 
 /**
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 5dffc459a33d..bfd8e87dceff 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -85,6 +85,8 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, 
void *priv)
case VPU_IPIMSG_DEC_END_ACK:
case VPU_IPIMSG_DEC_DEINIT_ACK:
case VPU_IPIMSG_DEC_RESET_ACK:
+   case VPU_IPIMSG_DEC_CORE_ACK:
+   case VPU_IPIMSG_DEC_CORE_END_ACK:
break;
 
default:
@@ -191,11 +193,21 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t 
*data, unsigned int len)
return err;
 }
 
+int vpu_dec_core(struct vdec_vpu_inst *vpu)
+{
+   return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_CORE);
+}
+
 int vpu_dec_end(struct vdec_vpu_inst *vpu)
 {
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_END);
 }
 
+int vpu_dec_core_end(struct vdec_vpu_inst *vpu)
+{
+   return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_CORE_END);
+}
+
 int vpu_dec_deinit(struct vdec_vpu_inst *vpu)
 {
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_DEINIT);
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
index c2ed5b6cab8b..ae24b75d1649 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
@@ -82,4 +82,22 @@ int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
  */
 int vpu_dec_reset(struct vdec_vpu_inst *vpu);
 
+/**
+ * vpu_dec_core - core start decoding, basically the function will be invoked 
once
+ * every frame.
+ *
+ * @vpu : instance for vdec_vpu_inst
+ */
+int vpu_dec_core(struct vdec_vpu_inst *vpu);
+
+/**
+ * vpu_dec_core_end - core end decoding, basically the function will be 
invoked once
+ *   when core HW decoding done and receive interrupt 
successfully. The
+ *   decoder in VPU will updata hardware information and deinit 
hardware
+ *   and check if there is a new decoded frame available to 
display.
+ *
+ * @vpu : instance for vdec_vpu_inst
+ */
+int vpu_dec_core_end(struct vdec_vpu_inst *vpu);
+
 #endif
-- 
2.25.1



[PATCH v17, 13/19] media: mtk-vcodec: Add work queue for core hardware decode

2021-12-16 Thread Yunfei Dong
Add work queue to process core hardware information.
First, get lat_buf from message queue, then call core
hardware of each codec(H264/VP9/AV1) to decode, finally
puts lat_buf back to the message.

Signed-off-by: Yunfei Dong 
Reviewed-by: Steve Cho 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  | 16 +++-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  3 ++
 .../platform/mtk-vcodec/vdec_msg_queue.c  | 41 ---
 .../platform/mtk-vcodec/vdec_msg_queue.h  |  8 ++--
 4 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 471b8c6ba7f2..10215ccc85f7 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -311,6 +311,17 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_dec_pm;
}
 
+   if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) {
+   vdec_msg_queue_init_ctx(>msg_queue_core_ctx, 
MTK_VDEC_CORE);
+   dev->core_workqueue = alloc_ordered_workqueue("core-decoder",
+   WQ_MEM_RECLAIM | WQ_FREEZABLE);
+   if (!dev->core_workqueue) {
+   mtk_v4l2_err("Failed to create core workqueue");
+   ret = -EINVAL;
+   goto err_res;
+   }
+   }
+
for (i = 0; i < MTK_VDEC_HW_MAX; i++)
mutex_init(>dec_mutex[i]);
mutex_init(>dev_mutex);
@@ -322,7 +333,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = v4l2_device_register(>dev, >v4l2_dev);
if (ret) {
mtk_v4l2_err("v4l2_device_register err=%d", ret);
-   goto err_res;
+   goto err_core_workq;
}
 
init_waitqueue_head(>queue);
@@ -423,6 +434,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
video_unregister_device(vfd_dec);
 err_dec_alloc:
v4l2_device_unregister(>v4l2_dev);
+err_core_workq:
+   if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch))
+   destroy_workqueue(dev->core_workqueue);
 err_res:
mtk_vcodec_release_dec_pm(>pm);
 err_dec_pm:
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 517515ee9ac4..3fc747cea5c9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -27,6 +27,7 @@
 #define MTK_VCODEC_MAX_PLANES  3
 #define MTK_V4L2_BENCHMARK 0
 #define WAIT_INTR_TIMEOUT_MS   1000
+#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
 
 /*
  * enum mtk_hw_reg_idx - MTK hw register base index
@@ -464,6 +465,7 @@ struct mtk_vcodec_enc_pdata {
  * @dec_capability: used to identify decode capability, ex: 4k
  * @enc_capability: used to identify encode capability
  *
+ * @core_workqueue: queue used for core hardware decode
  * @msg_queue_core_ctx: msg queue context used for core workqueue
  *
  * @subdev_dev: subdev hardware device
@@ -507,6 +509,7 @@ struct mtk_vcodec_dev {
unsigned int dec_capability;
unsigned int enc_capability;
 
+   struct workqueue_struct *core_workqueue;
struct vdec_msg_queue_ctx msg_queue_core_ctx;
 
void *subdev_dev[MTK_VDEC_HW_MAX];
diff --git a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c 
b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
index 913aefa67618..576e08200a10 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
@@ -68,6 +68,9 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, 
struct vdec_lat_buf
 
if (msg_ctx->hardware_index != MTK_VDEC_CORE)
wake_up_all(_ctx->ready_to_use);
+   else
+   queue_work(buf->ctx->dev->core_workqueue,
+   >ctx->msg_queue.core_work);
 
mtk_v4l2_debug(3, "enqueue buf type: %d addr: 0x%p num: %d",
msg_ctx->hardware_index, buf, msg_ctx->ready_num);
@@ -169,8 +172,7 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue 
*msg_queue)
return false;
 }
 
-void vdec_msg_queue_deinit(
-   struct vdec_msg_queue *msg_queue,
+void vdec_msg_queue_deinit(struct vdec_msg_queue *msg_queue,
struct mtk_vcodec_ctx *ctx)
 {
struct vdec_lat_buf *lat_buf;
@@ -196,10 +198,36 @@ void vdec_msg_queue_deinit(
}
 }
 
-int vdec_msg_queue_init(
-   struct vdec_msg_queue *msg_queue,
-   struct mtk_vcodec_ctx *ctx,
-   core_decode_cb_t core_decode,
+static void vdec_msg_queue_core_work(struct work_struct *work)
+{
+   struct vdec_msg_queue *msg_queue =
+   container_of(work, struct vdec_msg_queue, core_work);
+   struct mtk_vcodec_ctx *ctx =
+   container_of(msg_queue, struct mtk_vcodec_ctx, msg_queue);
+   

[PATCH v17, 10/19] media: mtk-vcodec: Add msg queue feature for lat and core architecture

2021-12-16 Thread Yunfei Dong
For lat and core architecture, lat thread will send message to core
thread when lat decode done. Core hardware will use the message
from lat to decode, then free message to lat thread when decode done.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 drivers/media/platform/mtk-vcodec/Makefile|   1 +
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   9 +
 .../platform/mtk-vcodec/vdec_msg_queue.c  | 260 ++
 .../platform/mtk-vcodec/vdec_msg_queue.h  | 143 ++
 4 files changed, 413 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_msg_queue.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index c61bfb179bcc..359619653a0e 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -12,6 +12,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
+   vdec_msg_queue.o \
mtk_vcodec_dec.o \
mtk_vcodec_dec_stateful.o \
mtk_vcodec_dec_stateless.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index f62752fbab8c..cbd602b7ecbb 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -15,7 +15,9 @@
 #include 
 #include 
 #include 
+
 #include "mtk_vcodec_util.h"
+#include "vdec_msg_queue.h"
 
 #define MTK_VCODEC_DRV_NAME"mtk_vcodec_drv"
 #define MTK_VCODEC_DEC_NAME"mtk-vcodec-dec"
@@ -282,6 +284,8 @@ struct vdec_pic_info {
  * @decoded_frame_cnt: number of decoded frames
  * @lock: protect variables accessed by V4L2 threads and worker thread such as
  *   mtk_video_dec_buf.
+ *
+ * @msg_queue: msg queue used to store lat buffer information.
  */
 struct mtk_vcodec_ctx {
enum mtk_instance_type type;
@@ -325,6 +329,7 @@ struct mtk_vcodec_ctx {
int decoded_frame_cnt;
struct mutex lock;
 
+   struct vdec_msg_queue msg_queue;
 };
 
 enum mtk_chip {
@@ -457,6 +462,8 @@ struct mtk_vcodec_enc_pdata {
  * @dec_capability: used to identify decode capability, ex: 4k
  * @enc_capability: used to identify encode capability
  *
+ * @msg_queue_core_ctx: msg queue context used for core workqueue
+ *
  * @subdev_dev: subdev hardware device
  * @subdev_prob_done: check whether all used hw device is prob done
  * @subdev_bitmap: used to record hardware is ready or not
@@ -498,6 +505,8 @@ struct mtk_vcodec_dev {
unsigned int dec_capability;
unsigned int enc_capability;
 
+   struct vdec_msg_queue_ctx msg_queue_core_ctx;
+
void *subdev_dev[MTK_VDEC_HW_MAX];
int (*subdev_prob_done)(struct mtk_vcodec_dev *vdec_dev);
DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
diff --git a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c 
b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
new file mode 100644
index ..913aefa67618
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Yunfei Dong 
+ */
+
+#include 
+#include 
+#include 
+
+#include "mtk_vcodec_dec_pm.h"
+#include "mtk_vcodec_drv.h"
+#include "vdec_msg_queue.h"
+
+#define VDEC_MSG_QUEUE_TIMEOUT_MS 1500
+
+/* the size used to store lat slice header information */
+#define VDEC_LAT_SLICE_HEADER_SZ(640 * SZ_1K)
+
+/* the size used to store avc error information */
+#define VDEC_ERR_MAP_SZ_AVC (17 * SZ_1K)
+
+/* core will read the trans buffer which decoded by lat to decode again.
+ * The trans buffer size of FHD and 4K bitstreams are different.
+ */
+static int vde_msg_queue_get_trans_size(int width, int height)
+{
+   if (width > 1920 || height > 1088)
+   return 30 * SZ_1M;
+   else
+   return 6 * SZ_1M;
+}
+
+void vdec_msg_queue_init_ctx(struct vdec_msg_queue_ctx *ctx, int 
hardware_index)
+{
+   init_waitqueue_head(>ready_to_use);
+   INIT_LIST_HEAD(>ready_queue);
+   spin_lock_init(>ready_lock);
+   ctx->ready_num = 0;
+   ctx->hardware_index = hardware_index;
+}
+
+static struct list_head *vdec_get_buf_list(int hardware_index, struct 
vdec_lat_buf *buf)
+{
+   switch (hardware_index) {
+   case MTK_VDEC_CORE:
+   return >core_list;
+   case MTK_VDEC_LAT0:
+   return >lat_list;
+   default:
+   return NULL;
+   }
+}
+
+int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct 
vdec_lat_buf *buf)
+{
+   struct list_head *head;
+
+   head = vdec_get_buf_list(msg_ctx->hardware_index, buf);
+   if (!head) {
+   mtk_v4l2_err("fail to qbuf: %d",msg_ctx->hardware_index);
+   

[PATCH v17, 07/19] dt-bindings: media: mtk-vcodec: Separate video encoder and decoder dt-bindings

2021-12-16 Thread Yunfei Dong
Separate decoder and encoder document for the dts are big difference.

Signed-off-by: Yunfei Dong 
Reviewed-by: Rob Herring 
---
 .../media/mediatek,vcodec-decoder.yaml| 176 +
 .../media/mediatek,vcodec-encoder.yaml| 187 ++
 .../bindings/media/mediatek-vcodec.txt| 131 
 3 files changed, 363 insertions(+), 131 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml
 create mode 100644 
Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml
 delete mode 100644 Documentation/devicetree/bindings/media/mediatek-vcodec.txt

diff --git 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml
new file mode 100644
index ..df1d677098fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml
@@ -0,0 +1,176 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,vcodec-decoder.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Video Decode Accelerator
+
+maintainers:
+  - Yunfei Dong 
+
+description: |+
+  Mediatek Video Decode is the video decode hardware present in Mediatek
+  SoCs which supports high resolution decoding functionalities.
+
+properties:
+  compatible:
+enum:
+  - mediatek,mt8173-vcodec-dec
+  - mediatek,mt8183-vcodec-dec
+
+  reg:
+maxItems: 12
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+maxItems: 8
+
+  clock-names:
+items:
+  - const: vcodecpll
+  - const: univpll_d2
+  - const: clk_cci400_sel
+  - const: vdec_sel
+  - const: vdecpll
+  - const: vencpll
+  - const: venc_lt_sel
+  - const: vdec_bus_clk_src
+
+  assigned-clocks: true
+
+  assigned-clock-parents: true
+
+  assigned-clock-rates: true
+
+  power-domains:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  dma-ranges:
+maxItems: 1
+description: |
+  Describes the physical address space of IOMMU maps to memory.
+
+  mediatek,larb:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description: |
+  Must contain the local arbiters in the current Socs.
+
+  mediatek,vpu:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description:
+  Describes point to vpu.
+
+  mediatek,scp:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description:
+  Describes point to scp.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - iommus
+  - assigned-clocks
+  - assigned-clock-parents
+
+allOf:
+  - if:
+  properties:
+compatible:
+  contains:
+enum:
+  - mediatek,mt8183-vcodec-dec
+
+then:
+  required:
+- mediatek,scp
+
+  - if:
+  properties:
+compatible:
+  contains:
+enum:
+  - mediatek,mt8173-vcodec-dec
+
+then:
+  required:
+- mediatek,vpu
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+#include 
+#include 
+#include 
+
+vcodec_dec: vcodec@1600 {
+  compatible = "mediatek,mt8173-vcodec-dec";
+  reg = <0x1600 0x100>,   /*VDEC_SYS*/
+  <0x1602 0x1000>,  /*VDEC_MISC*/
+  <0x16021000 0x800>,   /*VDEC_LD*/
+  <0x16021800 0x800>,   /*VDEC_TOP*/
+  <0x16022000 0x1000>,  /*VDEC_CM*/
+  <0x16023000 0x1000>,  /*VDEC_AD*/
+  <0x16024000 0x1000>,  /*VDEC_AV*/
+  <0x16025000 0x1000>,  /*VDEC_PP*/
+  <0x16026800 0x800>,   /*VP8_VD*/
+  <0x16027000 0x800>,   /*VP6_VD*/
+  <0x16027800 0x800>,   /*VP8_VL*/
+  <0x16028400 0x400>;   /*VP9_VD*/
+  interrupts = ;
+  mediatek,larb = <>;
+  iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+ < M4U_PORT_HW_VDEC_PP_EXT>,
+ < M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+ < M4U_PORT_HW_VDEC_UFO_EXT>,
+ < M4U_PORT_HW_VDEC_VLD_EXT>,
+ < M4U_PORT_HW_VDEC_VLD2_EXT>;
+  mediatek,vpu = <>;
+  power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+  clocks = < CLK_APMIXED_VCODECPLL>,
+ < CLK_TOP_UNIVPLL_D2>,
+ < CLK_TOP_CCI400_SEL>,
+ < CLK_TOP_VDEC_SEL>,
+ < CLK_TOP_VCODECPLL>,
+ < CLK_APMIXED_VENCPLL>,
+ < CLK_TOP_VENC_LT_SEL>,
+ < CLK_TOP_VCODECPLL_370P5>;
+  clock-names = "vcodecpll",
+  "univpll_d2",
+  "clk_cci400_sel",
+  "vdec_sel",
+  "vdecpll",
+

[PATCH v17, 06/19] media: mtk-vcodec: Add to support multi hardware decode

2021-12-16 Thread Yunfei Dong
There are more than two hardwares for decoder: LAT0, LAT1 and CORE. In order to
manage these hardwares, register each hardware as independent platform device
for the larbs are different.

Each hardware module controls its own information which includes 
interrupt/power/
clocks/registers.

Calling of_platform_populate in parent device, and use subdev_bitmap to record
whether the hardwares are registered.

Signed-off-by: Yunfei Dong 
Reviewed-by: Steve Cho 
---
 drivers/media/platform/mtk-vcodec/Makefile|   5 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  85 +---
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   | 198 ++
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.h   |  49 +
 .../mtk-vcodec/mtk_vcodec_dec_stateful.c  |   1 +
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c |   3 +
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  21 ++
 7 files changed, 330 insertions(+), 32 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index ca8e9e7a9c4e..c61bfb179bcc 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -2,7 +2,8 @@
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
   mtk-vcodec-enc.o \
-  mtk-vcodec-common.o
+  mtk-vcodec-common.o \
+  mtk-vcodec-dec-hw.o
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
vdec/vdec_vp8_if.o \
@@ -16,6 +17,8 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
mtk_vcodec_dec_stateless.o \
mtk_vcodec_dec_pm.o \
 
+mtk-vcodec-dec-hw-y := mtk_vcodec_dec_hw.o
+
 mtk-vcodec-enc-y := venc/venc_vp8_if.o \
venc/venc_h264_if.o \
mtk_vcodec_enc.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index c17927f79e22..f03f99108929 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -18,16 +18,12 @@
 
 #include "mtk_vcodec_drv.h"
 #include "mtk_vcodec_dec.h"
+#include "mtk_vcodec_dec_hw.h"
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_intr.h"
 #include "mtk_vcodec_util.h"
 #include "mtk_vcodec_fw.h"
 
-#define VDEC_HW_ACTIVE 0x10
-#define VDEC_IRQ_CFG   0x11
-#define VDEC_IRQ_CLR   0x10
-#define VDEC_IRQ_CFG_REG   0xa4
-
 static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
 {
struct mtk_vcodec_dev *dev = priv;
@@ -92,6 +88,42 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev 
*dev)
return 0;
 }
 
+static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev)
+{
+   struct platform_device *pdev = dev->plat_dev;
+   int ret;
+
+   ret = mtk_vcodec_get_reg_bases(dev);
+   if (ret)
+   return ret;
+
+   if (dev->vdec_pdata->is_subdev_supported)
+   return 0;
+
+   dev->dec_irq = platform_get_irq(pdev, 0);
+   if (dev->dec_irq < 0) {
+   dev_err(>dev, "failed to get irq number");
+   return dev->dec_irq;
+   }
+
+   irq_set_status_flags(dev->dec_irq, IRQ_NOAUTOEN);
+   ret = devm_request_irq(>dev, dev->dec_irq,
+   mtk_vcodec_dec_irq_handler, 0, pdev->name, dev);
+   if (ret) {
+   dev_err(>dev, "failed to install dev->dec_irq %d (%d)",
+   dev->dec_irq, ret);
+   return ret;
+   }
+
+   ret = mtk_vcodec_init_dec_pm(pdev, >pm);
+   if (ret < 0) {
+   dev_err(>dev, "failed to get mt vcodec clock source");
+   return ret;
+   }
+
+   return 0;
+}
+
 static int fops_vcodec_open(struct file *file)
 {
struct mtk_vcodec_dev *dev = video_drvdata(file);
@@ -113,6 +145,11 @@ static int fops_vcodec_open(struct file *file)
init_waitqueue_head(>queue);
mutex_init(>lock);
 
+   if (dev->vdec_pdata->is_subdev_supported && dev->subdev_prob_done) {
+   ret = dev->subdev_prob_done(dev);
+   if (ret)
+   goto err_ctrls_setup;
+   }
ctx->type = MTK_INST_DECODER;
ret = dev->vdec_pdata->ctrls_setup(ctx);
if (ret) {
@@ -217,7 +254,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 {
struct mtk_vcodec_dev *dev;
struct video_device *vfd_dec;
-   struct resource *res;
phandle rproc_phandle;
enum mtk_vcodec_fw_type fw_type;
int ret;
@@ -246,32 +282,10 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
if (IS_ERR(dev->fw_handler))
return PTR_ERR(dev->fw_handler);
 
-   ret = 

[PATCH v17, 09/19] media: mtk-vcodec: Add irq interface for multi hardware

2021-12-16 Thread Yunfei Dong
Adds irq interface for multi hardware.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  | 33 ---
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   |  2 +-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  | 25 ++
 .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  4 +--
 .../platform/mtk-vcodec/mtk_vcodec_intr.c | 27 +++
 .../platform/mtk-vcodec/mtk_vcodec_intr.h |  4 +--
 .../platform/mtk-vcodec/vdec/vdec_h264_if.c   |  2 +-
 .../mtk-vcodec/vdec/vdec_h264_req_if.c|  2 +-
 .../platform/mtk-vcodec/vdec/vdec_vp8_if.c|  2 +-
 .../platform/mtk-vcodec/vdec/vdec_vp9_if.c|  2 +-
 .../platform/mtk-vcodec/venc/venc_h264_if.c   |  2 +-
 .../platform/mtk-vcodec/venc/venc_vp8_if.c|  2 +-
 12 files changed, 69 insertions(+), 38 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index f03f99108929..9802e5cc535f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -24,6 +24,19 @@
 #include "mtk_vcodec_util.h"
 #include "mtk_vcodec_fw.h"
 
+static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev)
+{
+   switch (dev->vdec_pdata->hw_arch) {
+   case MTK_VDEC_PURE_SINGLE_CORE:
+   return MTK_VDEC_ONE_CORE;
+   case MTK_VDEC_LAT_SINGLE_CORE:
+   return MTK_VDEC_ONE_LAT_ONE_CORE;
+   default:
+   mtk_v4l2_err("hw arch %d not supported", 
dev->vdec_pdata->hw_arch);
+   return MTK_VDEC_NO_HW;
+   }
+}
+
 static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
 {
struct mtk_vcodec_dev *dev = priv;
@@ -55,7 +68,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
writel((readl(vdec_misc_addr) & ~VDEC_IRQ_CLR),
dev->reg_base[VDEC_MISC] + VDEC_IRQ_CFG_REG);
 
-   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED);
+   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, 0);
 
mtk_v4l2_debug(3,
"mtk_vcodec_dec_irq_handler :wake up ctx %d, 
dec_done_status=%x",
@@ -128,7 +141,7 @@ static int fops_vcodec_open(struct file *file)
 {
struct mtk_vcodec_dev *dev = video_drvdata(file);
struct mtk_vcodec_ctx *ctx = NULL;
-   int ret = 0;
+   int ret = 0, i, hw_count;
struct vb2_queue *src_vq;
 
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -142,14 +155,24 @@ static int fops_vcodec_open(struct file *file)
v4l2_fh_add(>fh);
INIT_LIST_HEAD(>list);
ctx->dev = dev;
-   init_waitqueue_head(>queue);
-   mutex_init(>lock);
+   if (ctx->dev->vdec_pdata->is_subdev_supported) {
+   hw_count = mtk_vcodec_get_hw_count(dev);
+   if (!hw_count || !dev->subdev_prob_done) {
+   ret = -EINVAL;
+   goto err_ctrls_setup;
+   }
 
-   if (dev->vdec_pdata->is_subdev_supported && dev->subdev_prob_done) {
ret = dev->subdev_prob_done(dev);
if (ret)
goto err_ctrls_setup;
+
+   for (i = 0; i < hw_count; i++)
+   init_waitqueue_head(>queue[i]);
+   } else {
+   init_waitqueue_head(>queue[0]);
}
+   mutex_init(>lock);
+
ctx->type = MTK_INST_DECODER;
ret = dev->vdec_pdata->ctrls_setup(ctx);
if (ret) {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index b6703b444827..b149c3058995 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -84,7 +84,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void 
*priv)
writel(dec_done_status | VDEC_IRQ_CFG, vdec_misc_addr);
writel(dec_done_status & ~VDEC_IRQ_CLR, vdec_misc_addr);
 
-   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED);
+   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx);
 
mtk_v4l2_debug(3, "wake up ctx %d, dec_done_status=%x",
ctx->id, dec_done_status);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 6d07bf997cc1..f62752fbab8c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -104,6 +104,16 @@ enum mtk_vdec_hw_id {
MTK_VDEC_HW_MAX,
 };
 
+/**
+ * struct mtk_vdec_hw_count - Supported hardware count
+ */
+enum mtk_vdec_hw_count {
+   MTK_VDEC_NO_HW = 0,
+   MTK_VDEC_ONE_CORE,
+   MTK_VDEC_ONE_LAT_ONE_CORE,
+   MTK_VDEC_MAX_HW_COUNT,
+};
+
 /*
  * struct mtk_video_fmt - Structure used to store information about 
pixelformats
  */
@@ -293,9 +303,9 @@ struct mtk_vcodec_ctx {
struct vdec_pic_info picinfo;

[PATCH v17, 05/19] media: mtk-vcodec: Support MT8192

2021-12-16 Thread Yunfei Dong
From: Yunfei Dong 

Adds MT8192's compatible "mediatek,mt8192-vcodec-dec".
Adds MT8192's device private data mtk_lat_sig_core_pdata.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec.h   |  1 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  4 
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c| 16 
 3 files changed, 21 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
index e08886a600a3..66cd6d2242c3 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -68,6 +68,7 @@ extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;
 extern const struct media_device_ops mtk_vcodec_media_ops;
 extern const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata;
 extern const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata;
 
 
 /*
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index af235fa4c487..c17927f79e22 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -392,6 +392,10 @@ static const struct of_device_id mtk_vcodec_match[] = {
.compatible = "mediatek,mt8183-vcodec-dec",
.data = _vdec_8183_pdata,
},
+   {
+   .compatible = "mediatek,mt8192-vcodec-dec",
+   .data = _lat_sig_core_pdata,
+   },
{},
 };
 
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 3d9f47555884..183cd67a334a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -357,3 +357,19 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
 };
+
+const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
+   .chip = MTK_MT8192,
+   .init_vdec_params = mtk_init_vdec_params,
+   .ctrls_setup = mtk_vcodec_dec_ctrls_setup,
+   .vdec_vb2_ops = _vdec_request_vb2_ops,
+   .vdec_formats = mtk_video_formats,
+   .num_formats = NUM_FORMATS,
+   .default_out_fmt = _video_formats[DEFAULT_OUT_FMT_IDX],
+   .default_cap_fmt = _video_formats[DEFAULT_CAP_FMT_IDX],
+   .vdec_framesizes = mtk_vdec_framesizes,
+   .num_framesizes = NUM_SUPPORTED_FRAMESIZE,
+   .uses_stateless_api = true,
+   .worker = mtk_vdec_worker,
+   .flush_decoder = mtk_vdec_flush_decoder,
+};
-- 
2.25.1



[PATCH v17, 04/19] media: mtk-vcodec: export decoder pm functions

2021-12-16 Thread Yunfei Dong
When mtk vcodec decoder is build as a module, we need to export
mtk-vcodec-dec pm functions to make them visible by the other components.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: Benjamin Gaignard 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 20bd157a855c..221cf60e9fbf 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -77,12 +77,14 @@ int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
put_device(pm->larbvdec);
return ret;
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_pm);
 
 void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
 {
pm_runtime_disable(pm->dev);
put_device(pm->larbvdec);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_release_dec_pm);
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
 {
@@ -94,6 +96,7 @@ int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_pw_on);
 
 void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
 {
@@ -103,6 +106,7 @@ void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
if (ret)
mtk_v4l2_err("pm_runtime_put_sync fail %d", ret);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_pw_off);
 
 void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
 {
@@ -129,6 +133,7 @@ void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
for (i -= 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_clock_on);
 
 void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
 {
@@ -139,3 +144,4 @@ void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
for (i = dec_clk->clk_num - 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_clock_off);
-- 
2.25.1



[PATCH v17, 01/19] media: mtk-vcodec: Get numbers of register bases from DT

2021-12-16 Thread Yunfei Dong
Different platforms may have different numbers of register bases. Gets the
numbers of register bases from dts (sizeof(u32) * 4 bytes for each).

Signed-off-by: Yunfei Dong 
Reviewed-by: Tzung-Bi Shih 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  | 37 ++-
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 40c39e1e596b..e1a82e233971 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -75,6 +75,30 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
return IRQ_HANDLED;
 }
 
+static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
+{
+   struct platform_device *pdev = dev->plat_dev;
+   int reg_num, i;
+
+   /* Sizeof(u32) * 4 bytes for each register base. */
+   reg_num = of_property_count_elems_of_size(pdev->dev.of_node, "reg",
+   sizeof(u32) * 4);
+   if (reg_num <= 0 || reg_num > NUM_MAX_VDEC_REG_BASE) {
+   dev_err(>dev, "Invalid register property size: %d\n", 
reg_num);
+   return -EINVAL;
+   }
+
+   for (i = 0; i < reg_num; i++) {
+   dev->reg_base[i] = devm_platform_ioremap_resource(pdev, i);
+   if (IS_ERR(dev->reg_base[i]))
+   return PTR_ERR(dev->reg_base[i]);
+
+   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
+   }
+
+   return 0;
+}
+
 static int fops_vcodec_open(struct file *file)
 {
struct mtk_vcodec_dev *dev = video_drvdata(file);
@@ -203,7 +227,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
struct resource *res;
phandle rproc_phandle;
enum mtk_vcodec_fw_type fw_type;
-   int i, ret;
+   int ret;
 
dev = devm_kzalloc(>dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
@@ -235,14 +259,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_dec_pm;
}
 
-   for (i = 0; i < NUM_MAX_VDEC_REG_BASE; i++) {
-   dev->reg_base[i] = devm_platform_ioremap_resource(pdev, i);
-   if (IS_ERR((__force void *)dev->reg_base[i])) {
-   ret = PTR_ERR((__force void *)dev->reg_base[i]);
-   goto err_res;
-   }
-   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
-   }
+   ret = mtk_vcodec_get_reg_bases(dev);
+   if (ret)
+   goto err_res;
 
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res == NULL) {
-- 
2.25.1



[PATCH v17, 03/19] media: mtk-vcodec: Refactor vcodec pm interface

2021-12-16 Thread Yunfei Dong
Using the needed params for pm init/release function and remove unused
param mtkdev in 'struct mtk_vcodec_pm'.

Signed-off-by: Yunfei Dong 
Reviewed-by: Tzung-Bi Shih 
Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: Steve Cho 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  6 ++---
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 22 ---
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.h   |  5 +++--
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  1 -
 .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |  1 -
 5 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index e5f6e400a587..af235fa4c487 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -246,7 +246,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
if (IS_ERR(dev->fw_handler))
return PTR_ERR(dev->fw_handler);
 
-   ret = mtk_vcodec_init_dec_pm(dev);
+   ret = mtk_vcodec_init_dec_pm(dev->plat_dev, >pm);
if (ret < 0) {
dev_err(>dev, "Failed to get mt vcodec clock source");
goto err_dec_pm;
@@ -377,7 +377,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 err_dec_alloc:
v4l2_device_unregister(>v4l2_dev);
 err_res:
-   mtk_vcodec_release_dec_pm(dev);
+   mtk_vcodec_release_dec_pm(>pm);
 err_dec_pm:
mtk_vcodec_fw_release(dev->fw_handler);
return ret;
@@ -416,7 +416,7 @@ static int mtk_vcodec_dec_remove(struct platform_device 
*pdev)
video_unregister_device(dev->vfd_dec);
 
v4l2_device_unregister(>v4l2_dev);
-   mtk_vcodec_release_dec_pm(dev);
+   mtk_vcodec_release_dec_pm(>pm);
mtk_vcodec_fw_release(dev->fw_handler);
return 0;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 6038db96f71c..20bd157a855c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -13,18 +13,15 @@
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_util.h"
 
-int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
+int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+   struct mtk_vcodec_pm *pm)
 {
struct device_node *node;
-   struct platform_device *pdev;
-   struct mtk_vcodec_pm *pm;
+   struct platform_device *larb_pdev;
struct mtk_vcodec_clk *dec_clk;
struct mtk_vcodec_clk_info *clk_info;
int i = 0, ret = 0;
 
-   pdev = mtkdev->plat_dev;
-   pm = >pm;
-   pm->mtkdev = mtkdev;
dec_clk = >vdec_clk;
node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
if (!node) {
@@ -32,13 +29,12 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
return -1;
}
 
-   pdev = of_find_device_by_node(node);
+   larb_pdev = of_find_device_by_node(node);
of_node_put(node);
-   if (WARN_ON(!pdev)) {
+   if (WARN_ON(!larb_pdev)) {
return -1;
}
-   pm->larbvdec = >dev;
-   pdev = mtkdev->plat_dev;
+   pm->larbvdec = _pdev->dev;
pm->dev = >dev;
 
dec_clk->clk_num =
@@ -82,10 +78,10 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
return ret;
 }
 
-void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev)
+void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
 {
-   pm_runtime_disable(dev->pm.dev);
-   put_device(dev->pm.larbvdec);
+   pm_runtime_disable(pm->dev);
+   put_device(pm->larbvdec);
 }
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
index 280aeaefdb65..a3df6aef6cb9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
@@ -9,8 +9,9 @@
 
 #include "mtk_vcodec_drv.h"
 
-int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev);
-void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev);
+int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+   struct mtk_vcodec_pm *pm);
+void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm);
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm);
 void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 1d2370608d0d..0fa9d85114b9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -195,7 +195,6 @@ struct mtk_vcodec_pm {
struct mtk_vcodec_clk   venc_clk;
struct device   *larbvenc;
struct device   *dev;
-   struct mtk_vcodec_dev   *mtkdev;
 

[PATCH v17, 00/19] Support multi hardware decode using of_platform_populate

2021-12-16 Thread Yunfei Dong
This series adds support for multi hardware decode into mtk-vcodec, by first 
adding use
of_platform_populate to manage each hardware information: interrupt, clock, 
register
bases and power. Secondly add core work queue to deal with core hardware 
message,
at the same time, add msg queue for different hardware share messages. Lastly, 
the
architecture of different specs are not the same, using specs type to separate 
them.

This series has been tested with both MT8183 and MT8173. Decoding was working 
for both chips.

Patches 1~3 rewrite get register bases and power on/off interface.
Patches 4 export decoder pm interfaces.
Patches 5 add to support 8192.
Patch 6 support multi hardware.
Patch 7 separate video encoder and decoder document
Patch 8-17 add interfaces to support core hardware.
Patch 18-19 remove mtk_vcodec_release_dec/enc_pm interfaces.
---
changes compared with v16:
- fix build warning for patch 13.

changes compared with v15:
- add Reviewed-by for patch 10.

changes compared with v14:
- rebase to latest media stage.

changes compared with v13:
- change some function position in case of ko dependency for patch 15.
- add reviewed-by for patch 06/13/15.

changes compared with v12:
- fix comments from rob for patch 15.
- fix comments from steve for 06 and 13.

changes compared with v11:
- fix comments from AngeloGioacchino for patch 09~11/19.
- fix comments from steve for patch 03/19.

changes compared with v10:
- fix comments from tzung-bi for patch 06/19.
- add more detail information for hardware block diagram 15/19

changes compared with v9:
- need not to build ko, just export pm interfaces for patch 04/19.
- fix comments for patch 06/19

changes compared with v8:
- add new patch 18~19 to remove mtk_vcodec_release_de/enc_pm interfaces.
- fix spelling mistakes for patch 17/19
- fix yaml comments for patch 15/19

Changes compared with v7:
- add new patch 4 to build decoder pm file as module
- add new patch 5 to support 8192
- fix comments for patch 6/17
- change some logic for using work queue instead of create thread for core 
hardware decode for patch 10/17
- using work queue for hardware decode instead of create thread for patch 13/17
- add returen value for patch 14/17
- fix yaml check fail 15/17

Changes compared with v6:
- Use of_platform_populate to manage multi hardware, not component framework 
for patch 4/15
- Re-write dtsi document for hardware architecture changed for patch 13/15 -The 
dtsi will write like below in patch 13/15:
vcodec_dec: vcodec_dec@1600 {
compatible = "mediatek,mt8192-vcodec-dec";
#address-cells = <2>;
#size-cells = <2>;
ranges;
reg = <0 0x1600 0 0x1000>;  /* VDEC_SYS */
mediatek,scp = <>;
iommus = < M4U_PORT_L4_VDEC_MC_EXT>;
dma-ranges = <0x1 0x0 0x0 0x4000 0x0 0xfff0>;
vcodec_lat {
compatible = "mediatek,mtk-vcodec-lat";
reg = <0 0x1601 0 0x800>;   /* VDEC_MISC */
reg-name = "reg-misc";
interrupts = ;
iommus = < M4U_PORT_L5_VDEC_LAT0_VLD_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_VLD2_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_AVC_MV_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_PRED_RD_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_TILE_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_WDMA_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_RG_CTRL_DMA_EXT>,
 < M4U_PORT_L5_VDEC_UFO_ENC_EXT>;
clocks = < CLK_TOP_VDEC_SEL>,
 <_soc CLK_VDEC_SOC_VDEC>,
 <_soc CLK_VDEC_SOC_LAT>,
 <_soc CLK_VDEC_SOC_LARB1>,
 < CLK_TOP_MAINPLL_D4>;
clock-names = "vdec-sel", "vdec-soc-vdec", "vdec-soc-lat",
  "vdec-vdec", "vdec-top";
assigned-clocks = < CLK_TOP_VDEC_SEL>;
assigned-clock-parents = < CLK_TOP_MAINPLL_D4>;
power-domains = < MT8192_POWER_DOMAIN_VDEC>;
};

vcodec_core {
compatible = "mediatek,mtk-vcodec-core";
reg = <0 0x16025000 0 0x1000>;  /* VDEC_CORE_MISC */
reg-names = "reg-misc";
interrupts = ;
iommus = < M4U_PORT_L4_VDEC_MC_EXT>,
 < M4U_PORT_L4_VDEC_UFO_EXT>,
 < M4U_PORT_L4_VDEC_PP_EXT>,
 < M4U_PORT_L4_VDEC_PRED_RD_EXT>,
 < M4U_PORT_L4_VDEC_PRED_WR_EXT>,
 < M4U_PORT_L4_VDEC_PPWRAP_EXT>,
 < M4U_PORT_L4_VDEC_TILE_EXT>,
 < M4U_PORT_L4_VDEC_VLD_EXT>,
 < M4U_PORT_L4_VDEC_VLD2_EXT>,
 < M4U_PORT_L4_VDEC_AVC_MV_EXT>,
 < M4U_PORT_L4_VDEC_RG_CTRL_DMA_EXT>;
clocks = < CLK_TOP_VDEC_SEL>,
 < CLK_VDEC_VDEC>,
 < CLK_VDEC_LAT>,
 < CLK_VDEC_LARB1>,
 < CLK_TOP_MAINPLL_D4>;
clock-names = "vdec-sel", "vdec-soc-vdec", 

[PATCH v17, 02/19] media: mtk-vcodec: Align vcodec wake up interrupt interface

2021-12-16 Thread Yunfei Dong
Vdec and venc can use the same function to wake up interrupt event.

Signed-off-by: Yunfei Dong 
Reviewed-by: Tzung-Bi Shih 
Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: Steve Cho 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 9 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 8 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 8 
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index e1a82e233971..e5f6e400a587 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -28,13 +28,6 @@
 #define VDEC_IRQ_CLR   0x10
 #define VDEC_IRQ_CFG_REG   0xa4
 
-/* Wake up context wait_queue */
-static void wake_up_ctx(struct mtk_vcodec_ctx *ctx)
-{
-   ctx->int_cond = 1;
-   wake_up_interruptible(>queue);
-}
-
 static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
 {
struct mtk_vcodec_dev *dev = priv;
@@ -66,7 +59,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
writel((readl(vdec_misc_addr) & ~VDEC_IRQ_CLR),
dev->reg_base[VDEC_MISC] + VDEC_IRQ_CFG_REG);
 
-   wake_up_ctx(ctx);
+   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED);
 
mtk_v4l2_debug(3,
"mtk_vcodec_dec_irq_handler :wake up ctx %d, 
dec_done_status=%x",
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 581522177308..1d2370608d0d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -473,4 +473,12 @@ static inline struct mtk_vcodec_ctx *ctrl_to_ctx(struct 
v4l2_ctrl *ctrl)
return container_of(ctrl->handler, struct mtk_vcodec_ctx, ctrl_hdl);
 }
 
+/* Wake up context wait_queue */
+static inline void wake_up_ctx(struct mtk_vcodec_ctx *ctx, unsigned int reason)
+{
+   ctx->int_cond = 1;
+   ctx->int_type = reason;
+   wake_up_interruptible(>queue);
+}
+
 #endif /* _MTK_VCODEC_DRV_H_ */
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index aeaecb8d416e..027546108f44 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -62,14 +62,6 @@ static const struct mtk_video_fmt 
mtk_video_formats_capture_vp8[] =  {
},
 };
 
-/* Wake up context wait_queue */
-static void wake_up_ctx(struct mtk_vcodec_ctx *ctx, unsigned int reason)
-{
-   ctx->int_cond = 1;
-   ctx->int_type = reason;
-   wake_up_interruptible(>queue);
-}
-
 static void clean_irq_status(unsigned int irq_status, void __iomem *addr)
 {
if (irq_status & MTK_VENC_IRQ_STATUS_PAUSE)
-- 
2.25.1



RE: [PATCH v8 11/16] drm/i915/gem: Use to_gt() helper for GGTT accesses

2021-12-16 Thread Sundaresan, Sujaritha


-Original Message-
From: dri-devel  On Behalf Of Andi 
Shyti
Sent: Tuesday, December 14, 2021 11:34 AM
To: Intel GFX ; DRI Devel 

Cc: Winiarski, Michal ; Andi Shyti 
; De Marchi, Lucas ; Chris Wilson 
; Andi Shyti 
Subject: [PATCH v8 11/16] drm/i915/gem: Use to_gt() helper for GGTT accesses

From: Michał Winiarski 

GGTT is currently available both through i915->ggtt and gt->ggtt, and we 
eventually want to get rid of the i915->ggtt one.
Use to_gt() for all i915->ggtt accesses to help with the future refactoring.

Signed-off-by: Michał Winiarski 
Cc: Michal Wajdeczko 
Signed-off-by: Andi Shyti 
---
 drivers/gpu/drm/i915/gem/i915_gem_context.h   |  2 +-
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c|  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_mman.c  | 19 ++-
 drivers/gpu/drm/i915/gem/i915_gem_pm.c|  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c  |  6 +++---
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c|  8 +---
 drivers/gpu/drm/i915/gem/i915_gem_tiling.c| 15 ---
 .../i915/gem/selftests/i915_gem_client_blt.c  |  2 +-  
.../drm/i915/gem/selftests/i915_gem_context.c |  2 +-
 .../drm/i915/gem/selftests/i915_gem_mman.c| 19 ++-
 .../drm/i915/gem/selftests/i915_gem_object.c  |  2 +-
 11 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h 
b/drivers/gpu/drm/i915/gem/i915_gem_context.h
index babfecb17ad1..e5b0f66ea1fe 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h
@@ -174,7 +174,7 @@ i915_gem_context_get_eb_vm(struct i915_gem_context *ctx)
 
vm = ctx->vm;
if (!vm)
-   vm = >i915->ggtt.vm;
+   vm = _gt(ctx->i915)->ggtt->vm;
vm = i915_vm_get(vm);
 
return vm;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index ec7c4a29a720..3078611d5bfe 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1106,7 +1106,7 @@ static inline struct i915_ggtt *cache_to_ggtt(struct 
reloc_cache *cache)  {
struct drm_i915_private *i915 =
container_of(cache, struct i915_execbuffer, reloc_cache)->i915;
-   return >ggtt;
+   return to_gt(i915)->ggtt;
 }
 
 static void reloc_cache_reset(struct reloc_cache *cache, struct 
i915_execbuffer *eb) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c 
b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 1ca5c062974e..a9effb34d7ed 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -295,7 +295,7 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
struct drm_device *dev = obj->base.dev;
struct drm_i915_private *i915 = to_i915(dev);
struct intel_runtime_pm *rpm = >runtime_pm;
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
bool write = area->vm_flags & VM_WRITE;
struct i915_gem_ww_ctx ww;
intel_wakeref_t wakeref;
@@ -388,16 +388,16 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
assert_rpm_wakelock_held(rpm);
 
/* Mark as being mmapped into userspace for later revocation */
-   mutex_lock(>ggtt.vm.mutex);
+   mutex_lock(_gt(i915)->ggtt->vm.mutex);
if (!i915_vma_set_userfault(vma) && !obj->userfault_count++)
-   list_add(>userfault_link, >ggtt.userfault_list);
-   mutex_unlock(>ggtt.vm.mutex);
+   list_add(>userfault_link, 
_gt(i915)->ggtt->userfault_list);
+   mutex_unlock(_gt(i915)->ggtt->vm.mutex);
 
/* Track the mmo associated with the fenced vma */
vma->mmo = mmo;
 
if (CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)
-   intel_wakeref_auto(>ggtt.userfault_wakeref,
+   intel_wakeref_auto(_gt(i915)->ggtt->userfault_wakeref,
   
msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
 
if (write) {
@@ -512,7 +512,7 @@ void i915_gem_object_release_mmap_gtt(struct 
drm_i915_gem_object *obj)
 * wakeref.
 */
wakeref = intel_runtime_pm_get(>runtime_pm);
-   mutex_lock(>ggtt.vm.mutex);
+   mutex_lock(_gt(i915)->ggtt->vm.mutex);
 
if (!obj->userfault_count)
goto out;
@@ -530,7 +530,7 @@ void i915_gem_object_release_mmap_gtt(struct 
drm_i915_gem_object *obj)
wmb();
 
 out:
-   mutex_unlock(>ggtt.vm.mutex);
+   mutex_unlock(_gt(i915)->ggtt->vm.mutex);
intel_runtime_pm_put(>runtime_pm, wakeref);  }
 
@@ -733,13 +733,14 @@ i915_gem_dumb_mmap_offset(struct drm_file *file,
  u32 handle,
  u64 *offset)
 {
+   struct drm_i915_private *i915 = to_i915(dev);
enum i915_mmap_type mmap_type;
 
if (HAS_LMEM(to_i915(dev)))
mmap_type = I915_MMAP_TYPE_FIXED;
 

[PATCH v2 35/37] drm/tegra: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/tegra/drm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 8d37d6b00562..48e35d686473 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1382,6 +1382,9 @@ static int __init host1x_drm_init(void)
 {
int err;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
err = host1x_driver_register(_drm_driver);
if (err < 0)
return err;
-- 
2.33.1



[PATCH v2 33/37] drm/sprd: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/sprd/sprd_drm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/sprd/sprd_drm.c b/drivers/gpu/drm/sprd/sprd_drm.c
index a077e2d4d721..dd7e3de780f3 100644
--- a/drivers/gpu/drm/sprd/sprd_drm.c
+++ b/drivers/gpu/drm/sprd/sprd_drm.c
@@ -186,6 +186,9 @@ static struct platform_driver *sprd_drm_drivers[]  = {
 
 static int __init sprd_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return platform_register_drivers(sprd_drm_drivers,
ARRAY_SIZE(sprd_drm_drivers));
 }
-- 
2.33.1



[PATCH v2 34/37] drm/sti: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/sti/sti_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index c7efb43b83ee..860b2230aa08 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -287,6 +287,9 @@ static struct platform_driver * const drivers[] = {
 
 static int sti_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_init(sti_drm_init);
-- 
2.33.1



[PATCH v2 37/37] drm/xen: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
Reviewed-by: Oleksandr Andrushchenko 
---

(no changes since v1)

 drivers/gpu/drm/xen/xen_drm_front.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/xen/xen_drm_front.c 
b/drivers/gpu/drm/xen/xen_drm_front.c
index e63088c2121d..0d8e6bd1ccbf 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -495,6 +495,9 @@ static int xen_drm_drv_init(struct xen_drm_front_info 
*front_info)
struct drm_device *drm_dev;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
DRM_INFO("Creating %s\n", xen_drm_driver.desc);
 
drm_info = kzalloc(sizeof(*drm_info), GFP_KERNEL);
-- 
2.33.1



[PATCH v2 24/37] drm/hyperv: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c 
b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
index 00e53de4812b..4a8941fa0815 100644
--- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
+++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
@@ -305,6 +305,9 @@ static int __init hyperv_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = pci_register_driver(_pci_driver);
if (ret != 0)
return ret;
-- 
2.33.1



[PATCH v2 36/37] drm/tilcdc: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index cc567c87057d..eee3c447fbac 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -604,6 +604,9 @@ static struct platform_driver tilcdc_platform_driver = {
 
 static int __init tilcdc_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
DBG("init");
tilcdc_panel_init();
return platform_driver_register(_platform_driver);
-- 
2.33.1



[PATCH v2 15/37] drm/stm: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/stm/drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 222869b232ae..143b508b68db 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -236,7 +236,7 @@ static struct platform_driver stm_drm_platform_driver = {
},
 };
 
-module_platform_driver(stm_drm_platform_driver);
+drm_module_platform_driver(stm_drm_platform_driver);
 
 MODULE_AUTHOR("Philippe Cornu ");
 MODULE_AUTHOR("Yannick Fertre ");
-- 
2.33.1



[PATCH v2 32/37] drm/rockchip: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index bec207de4544..ac190e2b1f7a 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -457,6 +457,9 @@ static int __init rockchip_drm_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
num_rockchip_sub_drivers = 0;
ADD_ROCKCHIP_SUB_DRIVER(vop_platform_driver, CONFIG_DRM_ROCKCHIP);
ADD_ROCKCHIP_SUB_DRIVER(rockchip_lvds_driver,
-- 
2.33.1



[PATCH v2 28/37] drm/mediatek: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index aec39724ebeb..e336358fee20 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -210,6 +210,9 @@ static int mtk_drm_kms_init(struct drm_device *drm)
struct device *dma_dev;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (!iommu_present(_bus_type))
return -EPROBE_DEFER;
 
-- 
2.33.1



[PATCH v2 12/37] drm/meson: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/meson/meson_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c 
b/drivers/gpu/drm/meson/meson_drv.c
index 80f1d439841a..36a107e9bafa 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -541,7 +541,7 @@ static struct platform_driver meson_drm_platform_driver = {
},
 };
 
-module_platform_driver(meson_drm_platform_driver);
+drm_module_platform_driver(meson_drm_platform_driver);
 
 MODULE_AUTHOR("Jasper St. Pierre ");
 MODULE_AUTHOR("Neil Armstrong ");
-- 
2.33.1



[PATCH v2 19/37] drm/tve200: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
Reviewed-by: Linus Walleij 
---

(no changes since v1)

 drivers/gpu/drm/tve200/tve200_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tve200/tve200_drv.c 
b/drivers/gpu/drm/tve200/tve200_drv.c
index 7fa71c8bb828..b1c35c13faeb 100644
--- a/drivers/gpu/drm/tve200/tve200_drv.c
+++ b/drivers/gpu/drm/tve200/tve200_drv.c
@@ -266,7 +266,7 @@ static struct platform_driver tve200_driver = {
.probe = tve200_probe,
.remove = tve200_remove,
 };
-module_platform_driver(tve200_driver);
+drm_module_platform_driver(tve200_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Linus Walleij ");
-- 
2.33.1



[PATCH v2 26/37] drm/ingenic: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 542c4af70661..7f10d6eed549 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1543,6 +1543,9 @@ static int ingenic_drm_init(void)
 {
int err;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU)) {
err = platform_driver_register(ingenic_ipu_driver_ptr);
if (err)
-- 
2.33.1



[PATCH v2 17/37] drm/tidss: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/tidss/tidss_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c 
b/drivers/gpu/drm/tidss/tidss_drv.c
index 7c784e90e40e..121fd413a75e 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -251,7 +251,7 @@ static struct platform_driver tidss_platform_driver = {
},
 };
 
-module_platform_driver(tidss_platform_driver);
+drm_module_platform_driver(tidss_platform_driver);
 
 MODULE_AUTHOR("Tomi Valkeinen ");
 MODULE_DESCRIPTION("TI Keystone DSS Driver");
-- 
2.33.1



[PATCH v2 31/37] drm: rcar-du: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 5a8131ef81d5..982e450233ed 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -701,6 +701,9 @@ static struct platform_driver rcar_du_platform_driver = {
 
 static int __init rcar_du_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
rcar_du_of_init(rcar_du_of_table);
 
return platform_driver_register(_du_platform_driver);
-- 
2.33.1



[PATCH v2 29/37] drm/msm: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/msm/msm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 892c04365239..8f30e68ae3b5 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -518,6 +518,9 @@ static int msm_drm_init(struct device *dev, const struct 
drm_driver *drv)
struct msm_mdss *mdss;
int ret, i;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ddev = drm_dev_alloc(drv, dev);
if (IS_ERR(ddev)) {
DRM_DEV_ERROR(dev, "failed to allocate drm_device\n");
-- 
2.33.1



[PATCH v2 05/37] drm/malidp: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/arm/malidp_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 78d15b04b105..fe3215ec39c4 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -1008,7 +1008,7 @@ static struct platform_driver malidp_platform_driver = {
},
 };
 
-module_platform_driver(malidp_platform_driver);
+drm_module_platform_driver(malidp_platform_driver);
 
 MODULE_AUTHOR("Liviu Dudau ");
 MODULE_DESCRIPTION("ARM Mali DP DRM driver");
-- 
2.33.1



[PATCH v2 23/37] drm/gma500: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/gma500/psb_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 65cf1c79dd7c..eeb681be9c95 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -538,6 +538,9 @@ static struct pci_driver psb_pci_driver = {
 
 static int __init psb_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return pci_register_driver(_pci_driver);
 }
 
-- 
2.33.1



[PATCH v2 22/37] drm/exynos: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index d8f1cf4d6b69..f9f10413a4f2 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -464,6 +464,9 @@ static int exynos_drm_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = exynos_drm_register_devices();
if (ret)
return ret;
-- 
2.33.1



[PATCH v2 09/37] drm/hisilicon/kirin: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 98ae9a48f3fe..2ac125edb0a1 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -307,7 +307,7 @@ static struct platform_driver kirin_drm_platform_driver = {
},
 };
 
-module_platform_driver(kirin_drm_platform_driver);
+drm_module_platform_driver(kirin_drm_platform_driver);
 
 MODULE_AUTHOR("Xinliang Liu ");
 MODULE_AUTHOR("Xinliang Liu ");
-- 
2.33.1



[PATCH v2 30/37] drm/omap: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/omapdrm/omap_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 2720a58ccd90..eaf67b9e5f12 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -727,6 +727,9 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
 
DBG("%s", dev_name(dev));
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
/* Allocate and initialize the DRM device. */
ddev = drm_dev_alloc(_drm_driver, dev);
if (IS_ERR(ddev))
-- 
2.33.1



[PATCH v2 27/37] drm/mcde: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
Reviewed-by: Linus Walleij 
---

(no changes since v1)

 drivers/gpu/drm/mcde/mcde_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 5b5afc6aaf8e..0b2910e69b42 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -491,6 +491,9 @@ static int __init mcde_drm_register(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = platform_register_drivers(component_drivers,
ARRAY_SIZE(component_drivers));
if (ret)
-- 
2.33.1



[PATCH v2 20/37] drm/xlnx: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/xlnx/zynqmp_dpsub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c 
b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
index ac37053412a1..311796106b70 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
@@ -286,7 +286,7 @@ static struct platform_driver zynqmp_dpsub_driver = {
},
 };
 
-module_platform_driver(zynqmp_dpsub_driver);
+drm_module_platform_driver(zynqmp_dpsub_driver);
 
 MODULE_AUTHOR("Xilinx, Inc.");
 MODULE_DESCRIPTION("ZynqMP DP Subsystem Driver");
-- 
2.33.1



[PATCH v2 14/37] drm/shmobile: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 80078a9fd7f6..c99adb8e74ce 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -295,7 +295,7 @@ static struct platform_driver shmob_drm_platform_driver = {
},
 };
 
-module_platform_driver(shmob_drm_platform_driver);
+drm_module_platform_driver(shmob_drm_platform_driver);
 
 MODULE_AUTHOR("Laurent Pinchart ");
 MODULE_DESCRIPTION("Renesas SH Mobile DRM Driver");
-- 
2.33.1



[PATCH v2 18/37] drm/arc: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index f8531c50a072..42c5a7137a47 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -427,7 +427,7 @@ static struct platform_driver arcpgu_platform_driver = {
   },
 };
 
-module_platform_driver(arcpgu_platform_driver);
+drm_module_platform_driver(arcpgu_platform_driver);
 
 MODULE_AUTHOR("Carlos Palminha ");
 MODULE_DESCRIPTION("ARC PGU DRM driver");
-- 
2.33.1



[PATCH v2 21/37] drm/armada: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/armada/armada_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 8e3e98f13db4..4f9b0a9f13e3 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -273,6 +273,9 @@ static int __init armada_drm_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = platform_driver_register(_lcd_platform_driver);
if (ret)
return ret;
-- 
2.33.1



[PATCH v2 25/37] drm/imx: Add support for the nomodeset kernel parameter

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/imx/imx-drm-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index cb685fe2039b..a57812ec36b1 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -341,6 +341,9 @@ static struct platform_driver * const drivers[] = {
 
 static int __init imx_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_init(imx_drm_init);
-- 
2.33.1



[PATCH v2 16/37] drm/sun4i: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/sun4i/sun4i_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index b630614b3d72..4a209e7d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -441,7 +441,7 @@ static struct platform_driver sun4i_drv_platform_driver = {
.pm = _drv_drm_pm_ops,
},
 };
-module_platform_driver(sun4i_drv_platform_driver);
+drm_module_platform_driver(sun4i_drv_platform_driver);
 
 MODULE_AUTHOR("Boris Brezillon ");
 MODULE_AUTHOR("Maxime Ripard ");
-- 
2.33.1



[PATCH v2 13/37] drm: mxsfb: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 86d78634a979..c843314d5b49 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -410,7 +410,7 @@ static struct platform_driver mxsfb_platform_driver = {
},
 };
 
-module_platform_driver(mxsfb_platform_driver);
+drm_module_platform_driver(mxsfb_platform_driver);
 
 MODULE_AUTHOR("Marek Vasut ");
 MODULE_DESCRIPTION("Freescale MXS DRM/KMS driver");
-- 
2.33.1



[PATCH v2 03/37] drm/komeda: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/arm/display/komeda/komeda_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
index e7933930a657..0d426240b1c9 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "komeda_dev.h"
 #include "komeda_kms.h"
@@ -198,7 +199,7 @@ static struct platform_driver komeda_platform_driver = {
},
 };
 
-module_platform_driver(komeda_platform_driver);
+drm_module_platform_driver(komeda_platform_driver);
 
 MODULE_AUTHOR("James.Qian.Wang ");
 MODULE_DESCRIPTION("Komeda KMS driver");
-- 
2.33.1



[PATCH v2 11/37] drm/kmb: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/kmb/kmb_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c
index ed2424350773..4a835f90fe3a 100644
--- a/drivers/gpu/drm/kmb/kmb_drv.c
+++ b/drivers/gpu/drm/kmb/kmb_drv.c
@@ -628,7 +628,7 @@ static struct platform_driver kmb_platform_driver = {
},
 };
 
-module_platform_driver(kmb_platform_driver);
+drm_module_platform_driver(kmb_platform_driver);
 
 MODULE_AUTHOR("Intel Corporation");
 MODULE_DESCRIPTION("Keembay Display driver");
-- 
2.33.1



[PATCH v2 07/37] drm/atmel-hlcdc: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 1656d27b78b6..3c01ede792bb 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -833,7 +833,7 @@ static struct platform_driver 
atmel_hlcdc_dc_platform_driver = {
.of_match_table = atmel_hlcdc_dc_of_match,
},
 };
-module_platform_driver(atmel_hlcdc_dc_platform_driver);
+drm_module_platform_driver(atmel_hlcdc_dc_platform_driver);
 
 MODULE_AUTHOR("Jean-Jacques Hiblot ");
 MODULE_AUTHOR("Boris Brezillon ");
-- 
2.33.1



[PATCH v2 06/37] drm/aspeed: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c 
b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index 65f172807a0d..383799378c97 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -359,7 +359,7 @@ static struct platform_driver aspeed_gfx_platform_driver = {
},
 };
 
-module_platform_driver(aspeed_gfx_platform_driver);
+drm_module_platform_driver(aspeed_gfx_platform_driver);
 
 MODULE_AUTHOR("Joel Stanley ");
 MODULE_DESCRIPTION("ASPEED BMC DRM/KMS driver");
-- 
2.33.1



[PATCH v2 10/37] drm/imx/dcss: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
Reviewed-by: Lucas Stach 
---

(no changes since v1)

 drivers/gpu/drm/imx/dcss/dcss-drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/dcss/dcss-drv.c 
b/drivers/gpu/drm/imx/dcss/dcss-drv.c
index 8dc2f85c514b..f3d2bb07facb 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-drv.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-drv.c
@@ -131,7 +131,7 @@ static struct platform_driver dcss_platform_driver = {
},
 };
 
-module_platform_driver(dcss_platform_driver);
+drm_module_platform_driver(dcss_platform_driver);
 
 MODULE_AUTHOR("Laurentiu Palcu ");
 MODULE_DESCRIPTION("DCSS driver for i.MX8MQ");
-- 
2.33.1



[PATCH v2 08/37] drm/fsl-dcu: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 660fe573db96..b24265f69523 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -368,7 +368,7 @@ static struct platform_driver fsl_dcu_drm_platform_driver = 
{
},
 };
 
-module_platform_driver(fsl_dcu_drm_platform_driver);
+drm_module_platform_driver(fsl_dcu_drm_platform_driver);
 
 MODULE_DESCRIPTION("Freescale DCU DRM Driver");
 MODULE_LICENSE("GPL");
-- 
2.33.1



[PATCH v2 02/37] drm/hisilicon/hibmc: Use drm_module_pci_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific PCI driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 610fc8e135f9..398a68b1a08c 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -379,7 +379,7 @@ static struct pci_driver hibmc_pci_driver = {
.driver.pm =_pm_ops,
 };
 
-module_pci_driver(hibmc_pci_driver);
+drm_module_pci_driver(hibmc_pci_driver);
 
 MODULE_DEVICE_TABLE(pci, hibmc_pci_table);
 MODULE_AUTHOR("RongrongZou ");
-- 
2.33.1



[PATCH v2 04/37] drm/arm/hdlcd: Use drm_module_platform_driver() to register the driver

2021-12-16 Thread Javier Martinez Canillas
The macro calls to a DRM specific platform driver init handler that checks
whether the driver is allowed to be registered or not.

Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 drivers/gpu/drm/arm/hdlcd_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 479c2422a2e0..1959ee7592c4 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -434,7 +434,7 @@ static struct platform_driver hdlcd_platform_driver = {
},
 };
 
-module_platform_driver(hdlcd_platform_driver);
+drm_module_platform_driver(hdlcd_platform_driver);
 
 MODULE_AUTHOR("Liviu Dudau");
 MODULE_DESCRIPTION("ARM HDLCD DRM driver");
-- 
2.33.1



[PATCH v2 01/37] drm: Add drm_module_{pci, platform}_driver() helper macros

2021-12-16 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, the
nomodeset parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, so let's add two
helper macros that can be used by DRM drivers for PCI and platform devices
to have module init functions that checks if the drivers could be loaded.

Suggested-by: Thomas Zimmermann 
Signed-off-by: Javier Martinez Canillas 
---

(no changes since v1)

 include/drm/drm_drv.h | 50 +++
 1 file changed, 50 insertions(+)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index f6159acb8856..4001d73428c5 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -29,6 +29,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -604,4 +606,52 @@ int drm_dev_set_unique(struct drm_device *dev, const char 
*name);
 
 extern bool drm_firmware_drivers_only(void);
 
+/**
+ * drm_pci_register_driver() - register a DRM driver for PCI devices
+ * @drv: PCI driver structure
+ *
+ * Returns zero on success or a negative errno code on failure.
+ */
+static inline int drm_pci_register_driver(struct pci_driver *drv)
+{
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
+   return pci_register_driver(drv);
+}
+
+/**
+ * drm_module_pci_driver() - helper macro for registering a DRM PCI driver
+ *
+ * Helper macro for DRM PCI drivers which do not do anything special in their
+ * module init/exit and just need the DRM specific module init.
+ */
+#define drm_module_pci_driver(__pci_driver) \
+   module_driver(__pci_driver, drm_pci_register_driver, \
+ pci_unregister_driver)
+
+/**
+ * drm_platform_driver_register - register a DRM driver for platform devices
+ * @drv: platform driver structure
+ *
+ * Returns zero on success or a negative errno code on failure.
+ */
+static inline int drm_platform_driver_register(struct platform_driver *drv)
+{
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
+   return platform_driver_register(drv);
+}
+
+/**
+ * drm_module_platform_driver() - helper macro for registering a DRM platform 
driver
+ *
+ * Helper macro for DRM platform drivers which do not do anything special in 
their
+ * module init/exit and just need the DRM specific module init.
+ */
+#define drm_module_platform_driver(__platform_driver) \
+   module_driver(__platform_driver, drm_platform_driver_register, \
+ platform_driver_unregister)
+
 #endif
-- 
2.33.1



[PATCH v2 00/37] drm: Make drivers to honour the nomodeset parameter

2021-12-16 Thread Javier Martinez Canillas
The nomodeset kernel command line parameter is used to prevent the KMS/DRM
drivers to be registered/probed. But only a few drivers implement support
for this and most DRM drivers just ignore it.

This patch series is a v2 to make DRM drivers to honour nomodeset. It is
posted as separate patches to make easier for drivers maintainers to ack
or pick them independently at their own pace.

The drm_module_{pci,platform}_driver() helper macros are added, which are
just wrappers around module_{pci,platform}_driver() but adding a check for
drm_firmware_drivers_only() and returning -ENODEV if that is true.

PCI and platform DRM drivers are then modified in the following patches to
make use of those macros.

For drivers that have custom module init/exit, the check is added to these
functions instead. Since the drm_*_module_driver() macros are only for the
default case when the init/exit just register/unregister the driver type.

In v1 all KMS/DRM drivers were included but v2 only includes KMS drivers,
and only the the PCI and platform DRM drivers. A follow-up series might
do the same for rendering-only and USB/SPI/I2C drivers, but it will need
more discussion to agree if that's desirable.

I've built tested with 'make allmodconfig && make M=drivers/gpu/drm' but I
don't have hardware to test the drivers, so review/testing is appreciated.

Best regards,
Javier

Changes in v2:
- Add drm_module_{pci,platform}_driver() macros and put the check there
  (Thomas Zimmermann).
- Use the drm_module_*_driver() macros if possible (Thomas Zimmermann).
- Leave the DRM drivers that don't set the DRIVER_MODESET driver feature
  (Lucas Stach).
- Leave USB/SPI/I2C drivers and only include PCI and platform ones
  (Noralf Trønnes).
- Add collected Reviewed-by tags

Javier Martinez Canillas (37):
  drm: Add drm_module_{pci,platform}_driver() helper macros
  drm/hisilicon/hibmc: Use drm_module_pci_driver() to register the
driver
  drm/komeda: Use drm_module_platform_driver() to register the driver
  drm/arm/hdlcd: Use drm_module_platform_driver() to register the driver
  drm/malidp: Use drm_module_platform_driver() to register the driver
  drm/aspeed: Use drm_module_platform_driver() to register the driver
  drm/atmel-hlcdc: Use drm_module_platform_driver() to register the
driver
  drm/fsl-dcu: Use drm_module_platform_driver() to register the driver
  drm/hisilicon/kirin: Use drm_module_platform_driver() to register the
driver
  drm/imx/dcss: Use drm_module_platform_driver() to register the driver
  drm/kmb: Use drm_module_platform_driver() to register the driver
  drm/meson: Use drm_module_platform_driver() to register the driver
  drm: mxsfb: Use drm_module_platform_driver() to register the driver
  drm/shmobile: Use drm_module_platform_driver() to register the driver
  drm/stm: Use drm_module_platform_driver() to register the driver
  drm/sun4i: Use drm_module_platform_driver() to register the driver
  drm/tidss: Use drm_module_platform_driver() to register the driver
  drm/arc: Use drm_module_platform_driver() to register the driver
  drm/tve200: Use drm_module_platform_driver() to register the driver
  drm/xlnx: Use drm_module_platform_driver() to register the driver
  drm/armada: Add support for the nomodeset kernel parameter
  drm/exynos: Add support for the nomodeset kernel parameter
  drm/gma500: Add support for the nomodeset kernel parameter
  drm/hyperv: Add support for the nomodeset kernel parameter
  drm/imx: Add support for the nomodeset kernel parameter
  drm/ingenic: Add support for the nomodeset kernel parameter
  drm/mcde: Add support for the nomodeset kernel parameter
  drm/mediatek: Add support for the nomodeset kernel parameter
  drm/msm: Add support for the nomodeset kernel parameter
  drm/omap: Add support for the nomodeset kernel parameter
  drm: rcar-du: Add support for the nomodeset kernel parameter
  drm/rockchip: Add support for the nomodeset kernel parameter
  drm/sprd: Add support for the nomodeset kernel parameter
  drm/sti: Add support for the nomodeset kernel parameter
  drm/tegra: Add support for the nomodeset kernel parameter
  drm/tilcdc: Add support for the nomodeset kernel parameter
  drm/xen: Add support for the nomodeset kernel parameter

 .../gpu/drm/arm/display/komeda/komeda_drv.c   |  3 +-
 drivers/gpu/drm/arm/hdlcd_drv.c   |  2 +-
 drivers/gpu/drm/arm/malidp_drv.c  |  2 +-
 drivers/gpu/drm/armada/armada_drv.c   |  3 ++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c   |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c  |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c   |  3 ++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c |  2 +-
 drivers/gpu/drm/gma500/psb_drv.c  |  3 ++
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |  2 +-
 .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c   |  2 +-
 drivers/gpu/drm/hyperv/hyperv_drm_drv.c   |  3 ++
 drivers/gpu/drm/imx/dcss/dcss-drv.c   |  2 +-
 drivers/gpu/drm/imx/imx-drm-core.c

[PATCH v6] drm/msm/dp: Add sc8180x DP controllers

2021-12-16 Thread Bjorn Andersson
The sc8180x has 2 DP and 1 eDP controllers, add support for these to the
DP driver.

Signed-off-by: Bjorn Andersson 
---

Changes since v5:
- Dropped DPU hw catalog change from the patch
- Rebased the patch

 drivers/gpu/drm/msm/dp/dp_display.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c 
b/drivers/gpu/drm/msm/dp/dp_display.c
index 8d9c19dbf33e..a9f5368559b4 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -143,10 +143,21 @@ static const struct msm_dp_config sc7280_dp_cfg = {
.num_descs = 2,
 };
 
+static const struct msm_dp_config sc8180x_dp_cfg = {
+   .descs = (const struct msm_dp_desc[]) {
+   [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae9, 
.connector_type = DRM_MODE_CONNECTOR_DisplayPort },
+   [MSM_DP_CONTROLLER_1] = { .io_start = 0x0ae98000, 
.connector_type = DRM_MODE_CONNECTOR_DisplayPort },
+   [MSM_DP_CONTROLLER_2] = { .io_start = 0x0ae9a000, 
.connector_type = DRM_MODE_CONNECTOR_eDP },
+   },
+   .num_descs = 3,
+};
+
 static const struct of_device_id dp_dt_match[] = {
{ .compatible = "qcom,sc7180-dp", .data = _dp_cfg },
{ .compatible = "qcom,sc7280-dp", .data = _dp_cfg },
{ .compatible = "qcom,sc7280-edp", .data = _dp_cfg },
+   { .compatible = "qcom,sc8180x-dp", .data = _dp_cfg },
+   { .compatible = "qcom,sc8180x-edp", .data = _dp_cfg },
{}
 };
 
-- 
2.33.1



[GIT PULL] mediatek drm next for 5.17

2021-12-16 Thread Chun-Kuang Hu
Hi, Dave & Daniel:

This includes:

1. Add support for MT8192
2. CMDQ refinement.
3. Miscellaneous clean up and reorder.
4. Set the default value of rotation to DRM_MODE_ROTATE_0

Regards,
Chun-Kuang.

The following changes since commit fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf:

  Linux 5.16-rc1 (2021-11-14 13:56:52 -0800)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git 
tags/mediatek-drm-next-5.17

for you to fetch changes up to d95b00f1a8c57f10a7c83bec5a245391c7666f36:

  drm/mediatek: Set the default value of rotation to DRM_MODE_ROTATE_0 
(2021-12-14 07:17:50 +0800)


Mediatek DRM Next for Linux 5.16

1. Add support for MT8192
2. CMDQ refinement.
3. Miscellaneous clean up and reorder.
4. Set the default value of rotation to DRM_MODE_ROTATE_0


Chun-Kuang Hu (4):
  drm/mediatek: Use mailbox rx_callback instead of cmdq_task_cb
  drm/mediatek: Remove the pointer of struct cmdq_client
  drm/mediatek: Detect CMDQ execution timeout
  drm/mediatek: Add cmdq_handle in mtk_crtc

Mark Yacoub (1):
  drm/mediatek: Set the default value of rotation to DRM_MODE_ROTATE_0

Yongqiang Niu (5):
  drm/mediatek: Add component OVL_2L2
  drm/mediatek: Add component POSTMASK
  drm/mediatek: Add component RDMA4
  drm/mediatek: Add support for Mediatek SoC MT8192
  drm/mediatek: Clear pending flag when cmdq packet is done

jason-jh.lin (4):
  drm/mediatek: Add mbox_free_channel in mtk_drm_crtc_destroy
  drm/mediatek: Remove unused define in mtk_drm_ddp_comp.c
  drm/mediatek: Rename the define of register offset
  drm/mediatek: Adjust to the alphabetic order for mediatek-drm

 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c   |   6 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c |  20 +++
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c|   6 +
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 175 +++---
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 217 
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |  23 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 142 +++---
 drivers/gpu/drm/mediatek/mtk_drm_plane.c|   3 +-
 8 files changed, 414 insertions(+), 178 deletions(-)


[PATCH v2] drm/msm/dp: Only create debugfs for PRIMARY minor

2021-12-16 Thread Bjorn Andersson
dpu_kms_debugfs_init() is invoked for each minor being registered. Most
of the files created are unrelated to the minor, so there's no reason to
present them per minor.
The exception to this is the DisplayPort code, which ends up invoking
dp_debug_get() for each minor, each time associate the allocated object
with dp->debug.

As such dp_debug will create debugfs files in both the PRIMARY and the
RENDER minor's debugfs directory, but only the last reference will be
remembered.

The only use of this reference today is in the cleanup path in
dp_display_deinit_sub_modules() and the dp_debug_private object does
outlive the debugfs entries in either case, so there doesn't seem to be
any adverse effects of this, but per the code the current behavior is
unexpected, so change it to only create debugfs files for the PRIMARY
minor.

Signed-off-by: Bjorn Andersson 
---

Changes since v1:
- Moved the check up from msm_dp_debugfs_init() to dpu_kms_debugfs_init()

 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 2ee70072a1b4..a54f7d373f14 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -193,6 +193,10 @@ static int dpu_kms_debugfs_init(struct msm_kms *kms, 
struct drm_minor *minor)
if (!p)
return -EINVAL;
 
+   /* Only create one set of debugfs per DP instance */
+   if (minor->type != DRM_MINOR_PRIMARY)
+   return 0;
+
dev = dpu_kms->dev;
priv = dev->dev_private;
 
-- 
2.33.1



[PATCH] drm/i915/guc: Request RP0 before loading firmware

2021-12-16 Thread Vinay Belgaumkar
By default, GT (and GuC) run at RPn. Requesting for RP0
before firmware load can speed up DMA and HuC auth as well.
In addition to writing to 0xA008, we also need to enable
swreq in 0xA024 so that Punit will pay heed to our request.

SLPC will restore the frequency back to RPn after initialization,
but we need to manually do that for the non-SLPC path.

We don't need a manual override in the SLPC disabled case, just
use the intel_rps_set function to ensure consistent RPS state.

Signed-off-by: Vinay Belgaumkar 
---
 drivers/gpu/drm/i915/gt/intel_rps.c   | 59 +++
 drivers/gpu/drm/i915/gt/intel_rps.h   |  2 +
 drivers/gpu/drm/i915/gt/uc/intel_uc.c |  9 
 drivers/gpu/drm/i915/i915_reg.h   |  4 ++
 4 files changed, 74 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c 
b/drivers/gpu/drm/i915/gt/intel_rps.c
index 07ff7ba7b2b7..d576b34c7d6f 100644
--- a/drivers/gpu/drm/i915/gt/intel_rps.c
+++ b/drivers/gpu/drm/i915/gt/intel_rps.c
@@ -2226,6 +2226,65 @@ u32 intel_rps_read_state_cap(struct intel_rps *rps)
return intel_uncore_read(uncore, GEN6_RP_STATE_CAP);
 }
 
+static void intel_rps_set_manual(struct intel_rps *rps, bool enable)
+{
+   struct intel_uncore *uncore = rps_to_uncore(rps);
+   u32 state = enable ? GEN9_RPSWCTL_ENABLE : GEN9_RPSWCTL_DISABLE;
+
+   /* Allow punit to process software requests */
+   intel_uncore_write(uncore, GEN6_RP_CONTROL, state);
+}
+
+void intel_rps_raise_unslice(struct intel_rps *rps)
+{
+   struct intel_uncore *uncore = rps_to_uncore(rps);
+   u32 rp0_unslice_req;
+
+   mutex_lock(>lock);
+
+   if (rps_uses_slpc(rps)) {
+   /* RP limits have not been initialized yet for SLPC path */
+   rp0_unslice_req = ((intel_rps_read_state_cap(rps) >> 0)
+  & 0xff) * GEN9_FREQ_SCALER;
+
+   intel_rps_set_manual(rps, true);
+   intel_uncore_write(uncore, GEN6_RPNSWREQ,
+  ((rp0_unslice_req <<
+  GEN9_SW_REQ_UNSLICE_RATIO_SHIFT) |
+  GEN9_IGNORE_SLICE_RATIO));
+   intel_rps_set_manual(rps, false);
+   } else {
+   intel_rps_set(rps, rps->rp0_freq);
+   }
+
+   mutex_unlock(>lock);
+}
+
+void intel_rps_lower_unslice(struct intel_rps *rps)
+{
+   struct intel_uncore *uncore = rps_to_uncore(rps);
+   u32 rpn_unslice_req;
+
+   mutex_lock(>lock);
+
+   if (rps_uses_slpc(rps)) {
+   /* RP limits have not been initialized yet for SLPC path */
+   rpn_unslice_req = ((intel_rps_read_state_cap(rps) >> 16)
+  & 0xff) * GEN9_FREQ_SCALER;
+
+   intel_rps_set_manual(rps, true);
+   intel_uncore_write(uncore, GEN6_RPNSWREQ,
+  ((rpn_unslice_req <<
+  GEN9_SW_REQ_UNSLICE_RATIO_SHIFT) |
+  GEN9_IGNORE_SLICE_RATIO));
+   intel_rps_set_manual(rps, false);
+   } else {
+   intel_rps_set(rps, rps->min_freq);
+   }
+
+   mutex_unlock(>lock);
+}
+
 /* External interface for intel_ips.ko */
 
 static struct drm_i915_private __rcu *ips_mchdev;
diff --git a/drivers/gpu/drm/i915/gt/intel_rps.h 
b/drivers/gpu/drm/i915/gt/intel_rps.h
index aee12f37d38a..c6d76a3d1331 100644
--- a/drivers/gpu/drm/i915/gt/intel_rps.h
+++ b/drivers/gpu/drm/i915/gt/intel_rps.h
@@ -45,6 +45,8 @@ u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
 u32 intel_rps_read_punit_req(struct intel_rps *rps);
 u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
 u32 intel_rps_read_state_cap(struct intel_rps *rps);
+void intel_rps_raise_unslice(struct intel_rps *rps);
+void intel_rps_lower_unslice(struct intel_rps *rps);
 
 void gen5_rps_irq_handler(struct intel_rps *rps);
 void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index 2fef3b0bbe95..3693c4e7dad0 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -8,6 +8,7 @@
 #include "intel_guc.h"
 #include "intel_guc_ads.h"
 #include "intel_guc_submission.h"
+#include "gt/intel_rps.h"
 #include "intel_uc.h"
 
 #include "i915_drv.h"
@@ -462,6 +463,8 @@ static int __uc_init_hw(struct intel_uc *uc)
else
attempts = 1;
 
+   intel_rps_raise_unslice(_to_gt(uc)->rps);
+
while (attempts--) {
/*
 * Always reset the GuC just before (re)loading, so
@@ -499,6 +502,9 @@ static int __uc_init_hw(struct intel_uc *uc)
ret = intel_guc_slpc_enable(>slpc);
if (ret)
goto err_submission;
+   } else {
+   /* Restore GT back to RPn for non-SLPC path */
+   intel_rps_lower_unslice(_to_gt(uc)->rps);
 

Re: [Intel-gfx] [PATCH v8 12/16] drm/i915/display: Use to_gt() helper for GGTT accesses

2021-12-16 Thread Sundaresan, Sujaritha



On 12/14/2021 11:33 AM, Andi Shyti wrote:

From: Michał Winiarski 

GGTT is currently available both through i915->ggtt and gt->ggtt, and we
eventually want to get rid of the i915->ggtt one.
Use to_gt() for all i915->ggtt accesses to help with the future
refactoring.

Signed-off-by: Michał Winiarski 
Cc: Michal Wajdeczko 
Signed-off-by: Andi Shyti 
---
  drivers/gpu/drm/i915/display/intel_fbc.c   | 2 +-
  drivers/gpu/drm/i915/display/intel_fbdev.c | 2 +-
  drivers/gpu/drm/i915/display/intel_plane_initial.c | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c 
b/drivers/gpu/drm/i915/display/intel_fbc.c
index 8be01b93015f..98319c0322d7 100644
--- a/drivers/gpu/drm/i915/display/intel_fbc.c
+++ b/drivers/gpu/drm/i915/display/intel_fbc.c
@@ -595,7 +595,7 @@ static void ivb_fbc_activate(struct intel_fbc *fbc)
else if (DISPLAY_VER(i915) == 9)
skl_fbc_program_cfb_stride(fbc);
  
-	if (i915->ggtt.num_fences)

+   if (to_gt(i915)->ggtt->num_fences)
snb_fbc_program_fence(fbc);
  
  	intel_de_write(i915, ILK_DPFC_CONTROL,

diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index adc3a81be9f7..41d279db2be6 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -180,7 +180,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
struct drm_device *dev = helper->dev;
struct drm_i915_private *dev_priv = to_i915(dev);
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
-   struct i915_ggtt *ggtt = _priv->ggtt;
+   struct i915_ggtt *ggtt = to_gt(dev_priv)->ggtt;
const struct i915_ggtt_view view = {
.type = I915_GGTT_VIEW_NORMAL,
};
diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c 
b/drivers/gpu/drm/i915/display/intel_plane_initial.c
index 01ce1d72297f..e4186a0b8edb 100644
--- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
+++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
@@ -94,7 +94,7 @@ initial_plane_vma(struct drm_i915_private *i915,
goto err_obj;
}
  
-	vma = i915_vma_instance(obj, >ggtt.vm, NULL);

+   vma = i915_vma_instance(obj, _gt(i915)->ggtt->vm, NULL);
if (IS_ERR(vma))
goto err_obj;

Reviewed-by : Sujaritha Sundaresan 
  


Re: [Intel-gfx] [PATCH v8 13/16] drm/i915/gt: Use to_gt() helper for GGTT accesses

2021-12-16 Thread Sundaresan, Sujaritha



On 12/14/2021 11:33 AM, Andi Shyti wrote:

From: Michał Winiarski 

GGTT is currently available both through i915->ggtt and gt->ggtt, and we
eventually want to get rid of the i915->ggtt one.
Use to_gt() for all i915->ggtt accesses to help with the future
refactoring.

Signed-off-by: Michał Winiarski 
Cc: Michal Wajdeczko 
Signed-off-by: Andi Shyti 
---
  drivers/gpu/drm/i915/gt/intel_ggtt.c | 14 +++---
  drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c |  6 +++---
  drivers/gpu/drm/i915/gt/intel_region_lmem.c  |  4 ++--
  drivers/gpu/drm/i915/gt/selftest_reset.c |  2 +-
  4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 971e737b37b2..ec3b998392ff 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -89,7 +89,7 @@ int i915_ggtt_init_hw(struct drm_i915_private *i915)
 * beyond the end of the batch buffer, across the page boundary,
 * and beyond the end of the GTT if we do not provide a guard.
 */
-   ret = ggtt_init_hw(>ggtt);
+   ret = ggtt_init_hw(to_gt(i915)->ggtt);
if (ret)
return ret;
  
@@ -725,14 +725,14 @@ int i915_init_ggtt(struct drm_i915_private *i915)

  {
int ret;
  
-	ret = init_ggtt(>ggtt);

+   ret = init_ggtt(to_gt(i915)->ggtt);
if (ret)
return ret;
  
  	if (INTEL_PPGTT(i915) == INTEL_PPGTT_ALIASING) {

-   ret = init_aliasing_ppgtt(>ggtt);
+   ret = init_aliasing_ppgtt(to_gt(i915)->ggtt);
if (ret)
-   cleanup_init_ggtt(>ggtt);
+   cleanup_init_ggtt(to_gt(i915)->ggtt);
}
  
  	return 0;

@@ -775,7 +775,7 @@ static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
   */
  void i915_ggtt_driver_release(struct drm_i915_private *i915)
  {
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
  
  	fini_aliasing_ppgtt(ggtt);
  
@@ -790,7 +790,7 @@ void i915_ggtt_driver_release(struct drm_i915_private *i915)

   */
  void i915_ggtt_driver_late_release(struct drm_i915_private *i915)
  {
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
  
  	GEM_WARN_ON(kref_read(>vm.resv_ref) != 1);

dma_resv_fini(>vm._resv);
@@ -1232,7 +1232,7 @@ int i915_ggtt_probe_hw(struct drm_i915_private *i915)
  {
int ret;
  
-	ret = ggtt_probe_hw(>ggtt, to_gt(i915));

+   ret = ggtt_probe_hw(to_gt(i915)->ggtt, to_gt(i915));
if (ret)
return ret;
  
diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c

index f8948de72036..beabf3bc9b75 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
@@ -728,8 +728,8 @@ static void detect_bit_6_swizzle(struct i915_ggtt *ggtt)
swizzle_y = I915_BIT_6_SWIZZLE_NONE;
}
  
-	i915->ggtt.bit_6_swizzle_x = swizzle_x;

-   i915->ggtt.bit_6_swizzle_y = swizzle_y;
+   to_gt(i915)->ggtt->bit_6_swizzle_x = swizzle_x;
+   to_gt(i915)->ggtt->bit_6_swizzle_y = swizzle_y;
  }
  
  /*

@@ -896,7 +896,7 @@ void intel_gt_init_swizzling(struct intel_gt *gt)
struct intel_uncore *uncore = gt->uncore;
  
  	if (GRAPHICS_VER(i915) < 5 ||

-   i915->ggtt.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_NONE)
+   to_gt(i915)->ggtt->bit_6_swizzle_x == I915_BIT_6_SWIZZLE_NONE)
return;
  
  	intel_uncore_rmw(uncore, DISP_ARB_CTL, 0, DISP_TILE_SURFACE_SWIZZLING);

diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c 
b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
index fde2dcb59809..21215a080088 100644
--- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c
+++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
@@ -15,7 +15,7 @@
  static int init_fake_lmem_bar(struct intel_memory_region *mem)
  {
struct drm_i915_private *i915 = mem->i915;
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
unsigned long n;
int ret;
  
@@ -131,7 +131,7 @@ intel_gt_setup_fake_lmem(struct intel_gt *gt)

if (!i915->params.fake_lmem_start)
return ERR_PTR(-ENODEV);
  
-	GEM_BUG_ON(i915_ggtt_has_aperture(>ggtt));

+   GEM_BUG_ON(i915_ggtt_has_aperture(to_gt(i915)->ggtt));
  
  	/* Your mappable aperture belongs to me now! */

mappable_end = pci_resource_len(pdev, 2);
diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c 
b/drivers/gpu/drm/i915/gt/selftest_reset.c
index 8a873f6bda7f..37c38bdd5f47 100644
--- a/drivers/gpu/drm/i915/gt/selftest_reset.c
+++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
@@ -19,7 +19,7 @@ __igt_reset_stolen(struct intel_gt *gt,
   intel_engine_mask_t mask,
   const char *msg)
  {
-   struct i915_ggtt *ggtt = >i915->ggtt;
+   struct i915_ggtt *ggtt = gt->ggtt;

Re: [Intel-gfx] [PATCH v8 14/16] drm/i915/selftests: Use to_gt() helper for GGTT accesses

2021-12-16 Thread Sundaresan, Sujaritha



On 12/14/2021 11:33 AM, Andi Shyti wrote:

From: Michał Winiarski 

GGTT is currently available both through i915->ggtt and gt->ggtt, and we
eventually want to get rid of the i915->ggtt one.
Use to_gt() for all i915->ggtt accesses to help with the future
refactoring.

Signed-off-by: Michał Winiarski 
Cc: Michal Wajdeczko 
Signed-off-by: Andi Shyti 
---
  drivers/gpu/drm/i915/selftests/i915_gem.c| 8 
  drivers/gpu/drm/i915/selftests/i915_gem_gtt.c| 6 +++---
  drivers/gpu/drm/i915/selftests/i915_request.c| 2 +-
  drivers/gpu/drm/i915/selftests/i915_vma.c| 2 +-
  drivers/gpu/drm/i915/selftests/mock_gem_device.c | 2 +-
  5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c 
b/drivers/gpu/drm/i915/selftests/i915_gem.c
index b5576888cd78..1628b81d0a35 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem.c
@@ -41,7 +41,7 @@ static int switch_to_context(struct i915_gem_context *ctx)
  
  static void trash_stolen(struct drm_i915_private *i915)

  {
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
const u64 slot = ggtt->error_capture.start;
const resource_size_t size = resource_size(>dsm);
unsigned long page;
@@ -99,7 +99,7 @@ static void igt_pm_suspend(struct drm_i915_private *i915)
intel_wakeref_t wakeref;
  
  	with_intel_runtime_pm(>runtime_pm, wakeref) {

-   i915_ggtt_suspend(>ggtt);
+   i915_ggtt_suspend(to_gt(i915)->ggtt);
i915_gem_suspend_late(i915);
}
  }
@@ -109,7 +109,7 @@ static void igt_pm_hibernate(struct drm_i915_private *i915)
intel_wakeref_t wakeref;
  
  	with_intel_runtime_pm(>runtime_pm, wakeref) {

-   i915_ggtt_suspend(>ggtt);
+   i915_ggtt_suspend(to_gt(i915)->ggtt);
  
  		i915_gem_freeze(i915);

i915_gem_freeze_late(i915);
@@ -125,7 +125,7 @@ static void igt_pm_resume(struct drm_i915_private *i915)
 * that runtime-pm just works.
 */
with_intel_runtime_pm(>runtime_pm, wakeref) {
-   i915_ggtt_resume(>ggtt);
+   i915_ggtt_resume(to_gt(i915)->ggtt);
i915_gem_resume(i915);
}
  }
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 48123c3e1ff0..9afe7cf9d068 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -1122,7 +1122,7 @@ static int exercise_ggtt(struct drm_i915_private *i915,
 u64 hole_start, u64 hole_end,
 unsigned long end_time))
  {
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
u64 hole_start, hole_end, last = 0;
struct drm_mm_node *node;
IGT_TIMEOUT(end_time);
@@ -1182,7 +1182,7 @@ static int igt_ggtt_page(void *arg)
const unsigned int count = PAGE_SIZE/sizeof(u32);
I915_RND_STATE(prng);
struct drm_i915_private *i915 = arg;
-   struct i915_ggtt *ggtt = >ggtt;
+   struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
struct drm_i915_gem_object *obj;
intel_wakeref_t wakeref;
struct drm_mm_node tmp;
@@ -2110,7 +2110,7 @@ int i915_gem_gtt_live_selftests(struct drm_i915_private 
*i915)
SUBTEST(igt_cs_tlb),
};
  
-	GEM_BUG_ON(offset_in_page(i915->ggtt.vm.total));

+   GEM_BUG_ON(offset_in_page(to_gt(i915)->ggtt->vm.total));
  
  	return i915_subtests(tests, i915);

  }
diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c 
b/drivers/gpu/drm/i915/selftests/i915_request.c
index 92a859b34190..7f66f6d299b2 100644
--- a/drivers/gpu/drm/i915/selftests/i915_request.c
+++ b/drivers/gpu/drm/i915/selftests/i915_request.c
@@ -843,7 +843,7 @@ static struct i915_vma *empty_batch(struct drm_i915_private 
*i915)
  
  	intel_gt_chipset_flush(to_gt(i915));
  
-	vma = i915_vma_instance(obj, >ggtt.vm, NULL);

+   vma = i915_vma_instance(obj, _gt(i915)->ggtt->vm, NULL);
if (IS_ERR(vma)) {
err = PTR_ERR(vma);
goto err;
diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c 
b/drivers/gpu/drm/i915/selftests/i915_vma.c
index 1f10fe36619b..6ac15d3bc5bc 100644
--- a/drivers/gpu/drm/i915/selftests/i915_vma.c
+++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
@@ -967,7 +967,7 @@ static int igt_vma_remapped_gtt(void *arg)
intel_wakeref_t wakeref;
int err = 0;
  
-	if (!i915_ggtt_has_aperture(>ggtt))

+   if (!i915_ggtt_has_aperture(to_gt(i915)->ggtt))
return 0;
  
  	obj = i915_gem_object_create_internal(i915, 10 * 10 * PAGE_SIZE);

diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c 
b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
index 8aa7b1d33865..0b469ae0f474 100644
--- 

Re: [PATCH v3] dt-bindings: display: tegra: Convert to json-schema

2021-12-16 Thread Rob Herring
On Thu, Dec 16, 2021 at 03:20:12PM +0100, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Convert the Tegra host1x controller bindings from the free-form text
> format to json-schema.
> 
> This also adds the missing display-hub DT bindings that were not
> previously documented.
> 
> Signed-off-by: Thierry Reding 
> ---
> Sorry Rob for making you look at this again. However, I think it's much
> cleaner than earlier versions of this because of the split into separate
> YAML files, so hopefully it's not too bad. I've got a couple of DT fixes
> in the Tegra tree that will allow this to successfully validate all of
> these host1x and child nodes.

Mostly looks good. A few things below.

> 
> Note that some of these can possibly be moved into a different directory
> now since they aren't all that display-related, but I'll do that in a
> separate patch to keep this simpler to review.
> 
> Changes in v3:
> - split into separate YAML files for simplicity
> - add display-hub DT bindings
> 
> Changes in v2:
> - use additionalProperties instead of unevaluatedProperties where
>   sufficient
> - drop redundant $ref and add missing maxItems properties
> - drop documentation for standard properties
> - remove status properties from example
> - drop spurious comments
> 
>  .../display/tegra/nvidia,tegra114-mipi.txt|  41 --
>  .../display/tegra/nvidia,tegra114-mipi.yaml   |  74 +++
>  .../display/tegra/nvidia,tegra124-dpaux.yaml  | 149 +
>  .../display/tegra/nvidia,tegra124-sor.yaml| 209 ++
>  .../display/tegra/nvidia,tegra124-vic.yaml|  71 ++
>  .../display/tegra/nvidia,tegra186-dc.yaml |  85 +++
>  .../tegra/nvidia,tegra186-display.yaml| 310 +
>  .../tegra/nvidia,tegra186-dsi-padctl.yaml |  46 ++
>  .../display/tegra/nvidia,tegra20-dc.yaml  | 174 +
>  .../display/tegra/nvidia,tegra20-dsi.yaml | 174 +
>  .../display/tegra/nvidia,tegra20-epp.yaml |  57 ++
>  .../display/tegra/nvidia,tegra20-gr2d.yaml|  58 ++
>  .../display/tegra/nvidia,tegra20-gr3d.yaml| 109 +++
>  .../display/tegra/nvidia,tegra20-hdmi.yaml| 116 
>  .../display/tegra/nvidia,tegra20-host1x.txt   | 622 --
>  .../display/tegra/nvidia,tegra20-host1x.yaml  | 334 ++
>  .../display/tegra/nvidia,tegra20-isp.yaml |  55 ++
>  .../display/tegra/nvidia,tegra20-mpe.yaml |  58 ++
>  .../display/tegra/nvidia,tegra20-tvo.yaml |  51 ++
>  .../display/tegra/nvidia,tegra20-vi.yaml  | 151 +
>  .../display/tegra/nvidia,tegra210-csi.yaml|  52 ++
>  .../pinctrl/nvidia,tegra124-dpaux-padctl.txt  |  59 --
>  22 files changed, 2333 insertions(+), 722 deletions(-)
>  delete mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra114-mipi.txt
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra114-mipi.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra124-dpaux.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra124-sor.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra124-vic.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra186-dc.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra186-display.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra186-dsi-padctl.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dsi.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-epp.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-gr2d.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-gr3d.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-hdmi.yaml
>  delete mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-isp.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-mpe.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-tvo.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml
>  create mode 100644 
> Documentation/devicetree/bindings/display/tegra/nvidia,tegra210-csi.yaml
>  delete mode 100644 
> Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt

[...]

> diff --git 
> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra124-sor.yaml 
> 

[PATCH v2] drm/cma-helper: Describe what a "contiguous chunk" actually means

2021-12-16 Thread Daniel Thompson
Since it's inception in 2012 it has been understood that the DRM GEM CMA
helpers do not depend on CMA as the backend allocator. In fact the first
bug fix to ensure the cma-helpers work correctly with an IOMMU backend
appeared in 2014. However currently the documentation for
drm_gem_cma_create() talks about "a contiguous chunk of memory" without
making clear which address space it will be a contiguous part of.
Additionally the CMA introduction is actively misleading because it only
contemplates the CMA backend.

This matters because when the device accesses the bus through an IOMMU
(and don't use the CMA backend) then the allocated memory is contiguous
only in the IOVA space. This is a significant difference compared to the
CMA backend and the behaviour can be a surprise even to someone who does
a reasonable level of code browsing (but doesn't find all the relevant
function pointers ;-) ).

Improve the kernel doc comments accordingly.

Signed-off-by: Daniel Thompson 
---

Notes:
Changes in v2:
- Oops. I did a final proof read and acidentally committed these
  changes as a seperate patch. This means that v1 contains only
  one tenth of the actual patch. This is fixed in v2. Many apologies
  for the noise!

 drivers/gpu/drm/drm_gem_cma_helper.c | 35 
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c 
b/drivers/gpu/drm/drm_gem_cma_helper.c
index 9d05674550a4..81d7181deebd 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -25,12 +25,18 @@
 /**
  * DOC: cma helpers
  *
- * The Contiguous Memory Allocator reserves a pool of memory at early boot
- * that is used to service requests for large blocks of contiguous memory.
+ * The DRM GEM/CMA helpers are a means to provide buffer objects that are
+ * presented to the device as a contiguous chunk of memory. This is useful
+ * for devices that do not support scatter-gather DMA (either directly or
+ * by using a built-in IOMMU).
  *
- * The DRM GEM/CMA helpers use this allocator as a means to provide buffer
- * objects that are physically contiguous in memory. This is useful for
- * display drivers that are unable to map scattered buffers via an IOMMU.
+ * For devices the access the memory bus through an (external) IOMMU then
+ * the buffer objects can be scattered in physical memory but linearized
+ * in the IOVA space by the IOMMU.
+ *
+ * For other devices we must rely on the Contiguous Memory Allocator to
+ * reserve a pool of memory at early boot. This is then used to service 
requests
+ * for large blocks of physically contiguous memory.
  */

 static const struct drm_gem_object_funcs drm_gem_cma_default_funcs = {
@@ -103,8 +109,14 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size, 
bool private)
  * @drm: DRM device
  * @size: size of the object to allocate
  *
- * This function creates a CMA GEM object and allocates a contiguous chunk of
- * memory as backing store.
+ * This function creates a CMA GEM object and allocates memory as backing 
store.
+ * The allocated memory will occupy a contiguous chunk of bus address space.
+ *
+ * For devices that are directly connected to the memory bus then the allocated
+ * memory will be physically contiguous. For devices that access through an
+ * IOMMU, then the allocated memory is not expected to be physically contiguous
+ * because having contiguous IOVAs is sufficient to meet a devices DMA
+ * requirements.
  *
  * Returns:
  * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative
@@ -154,9 +166,12 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_create);
  * @size: size of the object to allocate
  * @handle: return location for the GEM handle
  *
- * This function creates a CMA GEM object, allocating a physically contiguous
- * chunk of memory as backing store. The GEM object is then added to the list
- * of object associated with the given file and a handle to it is returned.
+ * This function creates a CMA GEM object, allocating a chunk of memory as
+ * backing store. The GEM object is then added to the list of object associated
+ * with the given file and a handle to it is returned.
+ *
+ * The allocated memory will occupy a contiguous chunk of bus address space.
+ * See drm_gem_cma_create() for more details.
  *
  * Returns:
  * A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative

base-commit: 2585cf9dfaaddf00b069673f27bb3f8530e2039c
--
2.34.1



Re: [Intel-gfx] [PATCH v8 16/16] drm/i915: Remove unused i915->ggtt

2021-12-16 Thread Sundaresan, Sujaritha



On 12/14/2021 11:33 AM, Andi Shyti wrote:

The reference to the GGTT from the private date is not used
anymore. Remove it.

-Quick spellcheck for "data".


Suggested-by: Matt Roper 
Signed-off-by: Andi Shyti 
Cc: Michał Winiarski 
---
  drivers/gpu/drm/i915/gt/intel_gt.c|  7 +--
  drivers/gpu/drm/i915/gt/intel_gt.h|  2 +-
  drivers/gpu/drm/i915/i915_driver.c|  4 +++-
  drivers/gpu/drm/i915/i915_drv.h   |  2 --
  drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 20 ++-
  drivers/gpu/drm/i915/selftests/i915_vma.c | 20 ++-
  .../gpu/drm/i915/selftests/mock_gem_device.c  |  9 +++--
  drivers/gpu/drm/i915/selftests/mock_gtt.c |  9 -
  drivers/gpu/drm/i915/selftests/mock_gtt.h |  3 ++-
  9 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index f98f0fb21efb..298ff32c8d0c 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -3,6 +3,7 @@
   * Copyright © 2019 Intel Corporation
   */
  
+#include 

  #include 
  
  #include "intel_gt_debugfs.h"

@@ -85,9 +86,11 @@ int intel_gt_probe_lmem(struct intel_gt *gt)
return 0;
  }
  
-void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt)

+int intel_gt_assign_ggtt(struct intel_gt *gt)
  {
-   gt->ggtt = ggtt;
+   gt->ggtt = drmm_kzalloc(>i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
+
+   return gt->ggtt ? 0 : -ENOMEM;
  }
  
  static const struct intel_mmio_range icl_l3bank_steering_table[] = {

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h 
b/drivers/gpu/drm/i915/gt/intel_gt.h
index 3ace129eb2af..94e1bac8c0cc 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt.h
@@ -36,7 +36,7 @@ static inline struct intel_gt *huc_to_gt(struct intel_huc 
*huc)
  
  void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);

  void __intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private 
*i915);
-void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt);
+int intel_gt_assign_ggtt(struct intel_gt *gt);
  int intel_gt_probe_lmem(struct intel_gt *gt);
  int intel_gt_init_mmio(struct intel_gt *gt);
  int __must_check intel_gt_init_hw(struct intel_gt *gt);
diff --git a/drivers/gpu/drm/i915/i915_driver.c 
b/drivers/gpu/drm/i915/i915_driver.c
index 3c984553d86f..5f2343389b5e 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -571,7 +571,9 @@ static int i915_driver_hw_probe(struct drm_i915_private 
*dev_priv)
  
  	i915_perf_init(dev_priv);
  
-	intel_gt_init_hw_early(to_gt(dev_priv), _priv->ggtt);

+   ret = intel_gt_assign_ggtt(to_gt(dev_priv));
+   if (ret)
+   goto err_perf;
  
  	ret = i915_ggtt_probe_hw(dev_priv);

if (ret)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 65724e4df3bd..8266df3e11ac 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -838,8 +838,6 @@ struct drm_i915_private {
struct drm_atomic_state *modeset_restore_state;
struct drm_modeset_acquire_ctx reset_ctx;
  
-	struct i915_ggtt ggtt; /* VM representing the global address space */

-
struct i915_gem_mm mm;
  
  	/* Kernel Modesetting */

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 9afe7cf9d068..f62f7dac57f2 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -1737,26 +1737,28 @@ int i915_gem_gtt_mock_selftests(void)
SUBTEST(igt_gtt_insert),
};
struct drm_i915_private *i915;
-   struct i915_ggtt *ggtt;
+   struct intel_gt *gt;
int err;
  
  	i915 = mock_gem_device();

if (!i915)
return -ENOMEM;
  
-	ggtt = kmalloc(sizeof(*ggtt), GFP_KERNEL);

-   if (!ggtt) {
-   err = -ENOMEM;
+   /* allocate the ggtt */
+   err = intel_gt_assign_ggtt(to_gt(i915));
+   if (err)
goto out_put;
-   }
-   mock_init_ggtt(i915, ggtt);
  
-	err = i915_subtests(tests, ggtt);

+   gt = to_gt(i915);
+
+   mock_init_ggtt(gt);
+
+   err = i915_subtests(tests, gt->ggtt);
  
  	mock_device_flush(i915);

i915_gem_drain_freed_objects(i915);
-   mock_fini_ggtt(ggtt);
-   kfree(ggtt);
+   mock_fini_ggtt(gt->ggtt);
+
  out_put:
mock_destroy_device(i915);
return err;
diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c 
b/drivers/gpu/drm/i915/selftests/i915_vma.c
index 6ac15d3bc5bc..a87cba4eb92f 100644
--- a/drivers/gpu/drm/i915/selftests/i915_vma.c
+++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
@@ -907,26 +907,28 @@ int i915_vma_mock_selftests(void)
SUBTEST(igt_vma_partial),
};
struct drm_i915_private *i915;
-   

[PATCH] drm/hisilicon/hibmc: Allow to be built if COMPILE_TEST is enabled

2021-12-16 Thread Javier Martinez Canillas
The commit feeb07d0ca5a ("drm/hisilicon/hibmc: Make CONFIG_DRM_HISI_HIBMC
depend on ARM64") made the driver Kconfig symbol to depend on ARM64 since
it only supports that architecture and loading the module on others would
lead to incorrect video modes being used.

But it also prevented the driver to be built on other architectures which
is useful to have compile test coverage when doing subsystem wide changes.

Make the dependency instead to be (ARM64 || COMPILE_TEST), so the driver
is buildable when the CONFIG_COMPILE_TEST option is enabled.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/hisilicon/hibmc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/Kconfig 
b/drivers/gpu/drm/hisilicon/hibmc/Kconfig
index 43943e980203..073adfe438dd 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/Kconfig
+++ b/drivers/gpu/drm/hisilicon/hibmc/Kconfig
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config DRM_HISI_HIBMC
tristate "DRM Support for Hisilicon Hibmc"
-   depends on DRM && PCI && ARM64
+   depends on DRM && PCI && (ARM64 || COMPILE_TEST)
select DRM_KMS_HELPER
select DRM_VRAM_HELPER
select DRM_TTM
-- 
2.33.1



Re: [Intel-gfx] [PATCH] drm/i915/guc: Check for wedged before doing stuff

2021-12-16 Thread John Harrison

On 12/16/2021 00:47, Tvrtko Ursulin wrote:

On 15/12/2021 22:45, john.c.harri...@intel.com wrote:

From: John Harrison 

A fault injection probe test hit a BUG_ON in a GuC error path. It
showed that the GuC code could potentially attempt to do many things
when the device is actually wedged. So, add a check in to prevent that.

Signed-off-by: John Harrison 
---
  drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

index 9739da6f..88f002c4d41b 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1350,7 +1350,8 @@ submission_disabled(struct intel_guc *guc)
  struct i915_sched_engine * const sched_engine = guc->sched_engine;
    return unlikely(!sched_engine ||
- !__tasklet_is_enabled(_engine->tasklet));
+ !__tasklet_is_enabled(_engine->tasklet) ||
+    test_bit(I915_WEDGED, _to_gt(guc)->reset.flags));


Or intel_gt_is_wedged ?
Hmm. I just copied the test from somewhere else. Is there any particular 
reason why other bits of code would be doing the explicit test_bit 
rather than calling the helper? I see the helper has a BUG_ON. Can that 
fire if called at the wrong time in the reset path?


John.



Regards,

Tvrtko


  }
    static void disable_submission(struct intel_guc *guc)





[pull] amdgpu, amdkfd, radeon drm-next-5.17

2021-12-16 Thread Alex Deucher
Hi Dave, Daniel,

More updates for 5.17.

The following changes since commit 3c021931023a30316db415044531b116b85e6ebd:

  drm/amdgpu: replace drm_detect_hdmi_monitor() with drm_display_info.is_hdmi 
(2021-12-07 13:13:07 -0500)

are available in the Git repository at:

  https://gitlab.freedesktop.org/agd5f/linux.git 
tags/amd-drm-next-5.17-2021-12-16

for you to fetch changes up to a342655865b2f14d1fbf346356d3b3360e63e872:

  drm/radeon: Fix syntax errors in comments (2021-12-14 16:11:02 -0500)


amdgpu:
- Add some display debugfs entries
- RAS fixes
- SR-IOV fixes
- W=1 fixes
- Documentation fixes
- IH timestamp fix
- Misc power fixes
- IP discovery fixes
- Large driver documentation updates
- Multi-GPU memory use reductions
- Misc display fixes and cleanups
- Add new SMU debug option

amdkfd:
- SVM fixes

radeon:
- Fix typo in comment


Anthony Koo (1):
  drm/amd/display: [FW Promotion] Release 0.0.97

Aric Cyr (1):
  drm/amd/display: 3.2.166

Aurabindo Pillai (1):
  drm/amd/display: Add feature flags to disable LTTPR

Eric Bernstein (1):
  drm/amd/display: ODM + MPO window on only one half of ODM

Evan Quan (2):
  drm/amdgpu: move smu_debug_mask to a more proper place
  drm/amdgpu: correct the wrong cached state for GMC on PICASSO

Fangzhi Zuo (1):
  drm/amd/display: Add Debugfs Entry to Force in SST Sequence

Felix Kuehling (4):
  drm/amdkfd: Fix error handling in svm_range_add
  drm/amdkfd: Fix svm_range_is_same_attrs
  drm/amdkfd: Don't split unchanged SVM ranges
  drm/amdkfd: Make KFD support on Hawaii experimental

Graham Sider (1):
  drm/amdkfd: add Navi2x to GWS init conditions

Guchun Chen (1):
  drm/amdgpu: use adev_to_drm to get drm_device pointer

Hawking Zhang (6):
  drm/amdgpu: add helper to load ip_discovery binary from file
  drm/amdgpu: rename discovery_read_binary helper
  drm/amdgpu: add helper to verify ip discovery binary signature
  drm/amdgpu: read and authenticate ip discovery binary
  drm/amdgpu: don't override default ECO_BITs setting
  drm/amdgpu: check df_funcs and its callback pointers

Isabella Basso (10):
  drm/amd: Mark IP_BASE definition as __maybe_unused
  drm/amd: fix improper docstring syntax
  drm/amdgpu: fix function scopes
  drm/amdkfd: fix function scopes
  drm/amd: append missing includes
  drm/amdgpu: fix location of prototype for amdgpu_kms_compat_ioctl
  drm/amdgpu: fix amdgpu_ras_mca_query_error_status scope
  drm/amdgpu: remove unnecessary variables
  drm/amdgpu: re-format file header comments
  drm/amd/display: fix function scopes

Jingwen Chen (2):
  drm/amd/amdgpu: fix psp tmr bo pin count leak in SRIOV
  drm/amd/amdgpu: fix gmc bo pin count leak in SRIOV

Jonathan Kim (1):
  drm/amdgpu: disable default navi2x co-op kernel support

Lang Yu (5):
  drm/amdgpu: remove power on/off SDMA in SMU hw_init/fini()
  drm/amdgpu: only hw fini SMU fisrt for ASICs need that
  drm/amdgpu: introduce a kind of halt state for amdgpu device
  drm/amdgpu: add support for SMU debug option
  drm/amd/pm: fix a potential gpu_metrics_table memory leak

Le Ma (1):
  drm/amdgpu: correct register access for RLC_JUMP_TABLE_RESTORE

Leslie Shi (2):
  drm/amdgpu: add modifiers in amdgpu_vkms_plane_init()
  drm/amdgpu: fix incorrect VCN revision in SRIOV

Lijo Lazar (1):
  drm/amd/pm: Skip power state allocation

Mario Limonciello (4):
  drm/amd: add some extra checks that is_dig_enabled is defined
  drm/amd: move variable to local scope
  drm/amd/pm: fix reading SMU FW version from amdgpu_firmware_info on YC
  drivers/amd/pm: drop statement to print FW version for smu_v13

Martin Leung (1):
  drm/amd/display: implement dc_mode_memclk

Michael Strauss (1):
  drm/amd/display: Force det buf size to 192KB with 3+ streams and upscaling

Michel Dänzer (2):
  drm/amd/display: Reduce stack size for 
dml31_ModeSupportAndSystemConfigurationFull
  drm/amd/display: Reduce stack size for dml31 UseMinimumDCFCLK

Mikita Lipski (1):
  drm/amd/display: parse and check PSR SU caps

Nicholas Kazlauskas (2):
  drm/amd/display: Set exit_optimized_pwr_state for DCN31
  drm/amd/display: Reset DMCUB before HW init

Philip Yang (3):
  drm/amdgpu: Handle fault with same timestamp
  drm/amdgpu: Detect if amdgpu in IOMMU direct map mode
  drm/amdgpu: Reduce SG bo memory usage for mGPUs

Rodrigo Siqueira (6):
  Documentation/gpu: Reorganize DC documentation
  Documentation/gpu: Document amdgpu_dm_visual_confirm debugfs entry
  Documentation/gpu: Document pipe split visual confirmation
  Documentation/gpu: How to collect DTN log
  Documentation/gpu: Add basic overview of DC pipeline
  Documentation/gpu: Add amdgpu and dc glossary

Solomon Chiu (1):
  

Re: [PATCH 0/9] drm/i915/gvt: Constify static structs

2021-12-16 Thread Wang, Zhi A
On 12/12/2021 3:25 PM, Rikard Falkeborn worte:
> On Fri, Dec 10, 2021 at 09:00:56AM +, Wang, Zhi A wrote:
>> On 12/4/2021 12:55 PM, Rikard Falkeborn wrote:
>>> Constify a number of static structs that are never modified to allow the
>>> compiler to put them in read-only memory. In order to do this, constify a
>>> number of local variables and pointers in structs.
>>>
>>> This is most important for structs that contain function pointers, and
>>> the patches for those structs are placed first in the series.
>>>
>>> Rikard Falkeborn (9):
>>> drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
>>> drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
>>> drm/i915/gvt: Constify intel_gvt_irq_ops
>>> drm/i915/gvt: Constify intel_gvt_sched_policy_ops
>>> drm/i915/gvt: Constify gvt_mmio_block
>>> drm/i915/gvt: Constify cmd_interrupt_events
>>> drm/i915/gvt: Constify formats
>>> drm/i915/gvt: Constify gtt_type_table_entry
>>> drm/i915/gvt: Constify vgpu_types
>>>
>>>drivers/gpu/drm/i915/gvt/cmd_parser.c   |  2 +-
>>>drivers/gpu/drm/i915/gvt/fb_decoder.c   | 24 -
>>>drivers/gpu/drm/i915/gvt/gtt.c  | 68 -
>>>drivers/gpu/drm/i915/gvt/gtt.h  |  4 +-
>>>drivers/gpu/drm/i915/gvt/gvt.h  |  2 +-
>>>drivers/gpu/drm/i915/gvt/handlers.c | 12 ++---
>>>drivers/gpu/drm/i915/gvt/interrupt.c| 10 ++--
>>>drivers/gpu/drm/i915/gvt/interrupt.h|  2 +-
>>>drivers/gpu/drm/i915/gvt/sched_policy.c |  2 +-
>>>drivers/gpu/drm/i915/gvt/scheduler.h|  2 +-
>>>drivers/gpu/drm/i915/gvt/vgpu.c |  4 +-
>>>11 files changed, 66 insertions(+), 66 deletions(-)
>>>
>> Thanks so much for the contribuition. You only need to refine the PATCH
>> 2 a little bit and re-send it.
>>
> Thanks for reviewing. Just to clarify, did you mean patch 7 (since
> that's the one you commented on)? And is it enough to send just that
> patch or do you want the entire series resent?
>
> Rikard

Hi Rikard,  no worries then. I have already corrected them and queue 
them in the gvt-next branch, you can double check them if you like. They 
are going through a QA test cycle first and later start their journey to 
the upstream. All good. :) Thanks so much for the contribution again.

Zhi.



Re: [PATCH] mediatek: Set default value for Panel Orientation connector prop.

2021-12-16 Thread Mark Yacoub
This makes sense. Thanks for pointing that out I wasn't aware of it.
I'll take a closer look and try to come up with something better.

Thanks Chun-Kuang!

On Thu, Dec 16, 2021 at 11:53 AM Chun-Kuang Hu  wrote:
>
> Hi, Mark:
>
> Mark Yacoub  於 2021年12月16日 週四 上午1:25寫道:
> >
> > On Wed, Dec 15, 2021 at 11:14 AM Chun-Kuang Hu  
> > wrote:
> > >
> > > Hi, Mark:
> > >
> > > Mark Yacoub  於 2021年12月14日 週二 下午11:13寫道:
> > > >
> > > > Hey CK, can we have this merged?
> > > > Thank you!
> > > >
> > > > On Mon, Oct 25, 2021 at 9:13 PM Sean Paul  wrote:
> > > > >
> > > > > On Fri, Oct 22, 2021 at 01:24:03PM -0400, Mark Yacoub wrote:
> > > > > > From: Mark Yacoub 
> > > > > >
> > > > > > [Why]
> > > > > > Creating the prop uses UNKNOWN as the initial value, which is not a
> > > > > > supported value if the props is to be supported.
> > > > > >
> > > > > > [How]
> > > > > > Set the panel orientation default value to NORMAL right after 
> > > > > > creating
> > > > > > the prop.
> > > > >
> > > > > Reviewed-by: Sean Paul 
> > > > >
> > > > > >
> > > > > > Tested on Jacuzzi(MTK)
> > > > > > Fixes IGT@kms_properties@get_properties-sanity-{atomic,non-atomic}
> > > > > >
> > > > > > Signed-off-by: Mark Yacoub 
> > > > > > ---
> > > > > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 2 ++
> > > > > >  1 file changed, 2 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
> > > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > > index 0ad7157660afa..b7c2528a8f41c 100644
> > > > > > --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > > +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > > @@ -1039,6 +1039,8 @@ static int mtk_dsi_encoder_init(struct 
> > > > > > drm_device *drm, struct mtk_dsi *dsi)
> > > > > >   DRM_ERROR("Unable to init panel orientation\n");
> > > > > >   goto err_cleanup_encoder;
> > > > > >   }
> > > > > > + drm_connector_set_panel_orientation(dsi->connector,
> > > > > > + 
> > > > > > DRM_MODE_PANEL_ORIENTATION_NORMAL);
> > >
> > > In drm_connector_set_panel_orientation() [1], I find that the
> > > orientation could be set only once. Once you set it to normal, it
> > > could not be set to other orientation. Right?
> > >
> > Hello,
> > Yeah this looks true, and makes sense according to the documentation:
> > https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html#:~:text=one%20standardized%20property%3A-,panel%20orientation%3A,-On%20some%20devices
> >
> > Panel orientation has to do with the how the hardware is mounted, in
> > contrast with the Rotation property. All the HW we have right now has
> > a normal panel orientation so it makes sense to be set this way. Among
>
> Many evidence [1], [2], [3], show that Chromebook plan to have other
> orientation on mt8183, so I think you should consider this.
>
> [1] 
> https://patchwork.kernel.org/project/linux-mediatek/patch/20210409045314.3420733-2-hsi...@chromium.org/
> [2] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c?h=v5.16-rc5#n1474
> [3] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts?h=v5.16-rc5#n22
>
> Regards,
> Chun-Kuang.
>
>
>
> > other drivers, panel orientation is always set right after the
> > property is initialized.
> >
> > > [1] 
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/drm_connector.c?h=v5.16-rc5#n2302
> > >
> > > Regards,
> > > Chun-Kuang.
> > >
> > > > > >
> > > > > >   drm_connector_attach_encoder(dsi->connector, >encoder);
> > > > > >
> > > > > > --
> > > > > > 2.33.0.1079.g6e70778dc9-goog
> > > > > >
> > > > >
> > > > > --
> > > > > Sean Paul, Software Engineer, Google / Chromium OS


[PATCH] drm/amd/display: fix dereference before NULL check

2021-12-16 Thread José Expósito
The "plane_state" pointer was access before checking if it was NULL.

Avoid a possible NULL pointer dereference by accessing the plane
address after the check.

Addresses-Coverity-ID: 1474582 ("Dereference before null check")
Fixes: 3f68c01be9a22 ("drm/amd/display: add cyan_skillfish display support")
Signed-off-by: José Expósito 
---
 drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
index cfd09b3f705e..fe22530242d2 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_hwseq.c
@@ -134,11 +134,12 @@ void dcn201_update_plane_addr(const struct dc *dc, struct 
pipe_ctx *pipe_ctx)
PHYSICAL_ADDRESS_LOC addr;
struct dc_plane_state *plane_state = pipe_ctx->plane_state;
struct dce_hwseq *hws = dc->hwseq;
-   struct dc_plane_address uma = plane_state->address;
+   struct dc_plane_address uma;
 
if (plane_state == NULL)
return;
 
+   uma = plane_state->address;
addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, );
 
plane_address_in_gpu_space_to_uma(hws, );
-- 
2.25.1



Re: [PATCH] drm/panfrost: Avoid user size passed to kvmalloc()

2021-12-16 Thread Alyssa Rosenzweig
> This provides an easy method for user
> space to trigger the OOM killer (by temporarily allocating large amounts
> of kernel memory)

panfrost user space has a lot of easy ways to trigger to the OOM killer
unfortunately  if this is something we want to fix there are a lot
more patches coming :(


Re: [PATCH] drm/panfrost: Avoid user size passed to kvmalloc()

2021-12-16 Thread Rob Herring
On Thu, Dec 16, 2021 at 10:16 AM Steven Price  wrote:
>
> panfrost_copy_in_sync() takes the number of fences from user space
> (in_sync_count) and used to kvmalloc() an array to hold that number of
> fences before processing them. This provides an easy method for user
> space to trigger the OOM killer (by temporarily allocating large amounts
> of kernel memory) or hit the WARN_ONCE() added by 7661809d493b ("mm:
> don't allow oversized kvmalloc() calls").
>
> Since we don't expect there to be a large number of fences we can
> instead iterate over the fences one-by-one and avoid the temporary
> allocation altogether. This also makes the code simpler.

Doesn't the BO lookup suffer from the same issue?

Rob


[PATCH] drm/cma-helper: Describe what a "contiguous chunk" actually means

2021-12-16 Thread Daniel Thompson
Since it's inception in 2012 it has been understood that the DRM GEM CMA
helpers do not depend on CMA as the backend allocator. In fact the first
bug fix to ensure the cma-helpers work correctly with an IOMMU backend
appeared in 2014. However currently the documentation for
drm_gem_cma_create() talks about "a contiguous chunk of memory" without
making clear which address space it will be a contiguous part of.
Additionally the CMA introduction is actively misleading because it only
contemplates the CMA backend.

This matters because when the device accesses the bus through an IOMMU
(and don't use the CMA backend) then the allocated memory is contiguous
only in the IOVA space. This is a significant difference compared to the
CMA bankend and the behaviour can be a surprise even to someone who does
a reasonable level of code browsing (but doesn't find all the relevant
function pointers ;-) ).

Improve the kernel doc comments accordingly.

Signed-off-by: Daniel Thompson 
---
 drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c 
b/drivers/gpu/drm/drm_gem_cma_helper.c
index 8467783e92f3..81d7181deebd 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -32,10 +32,10 @@
  *
  * For devices the access the memory bus through an (external) IOMMU then
  * the buffer objects can be scattered in physical memory but linearized
- * in the IOVA space by the MMU.
+ * in the IOVA space by the IOMMU.
  *
  * For other devices we must rely on the Contiguous Memory Allocator to
- * reserve a pool of memory at early boot that is used to service requests
+ * reserve a pool of memory at early boot. This is then used to service 
requests
  * for large blocks of physically contiguous memory.
  */


base-commit: 2585cf9dfaaddf00b069673f27bb3f8530e2039c
prerequisite-patch-id: bfcd9122d2546ec77e0bd987663777192002bc91
--
2.34.1



Re: [PATCH] drm/vkms: set plane modifiers

2021-12-16 Thread José Expósito
On Wed, Dec 15, 2021 at 05:23:10PM +, Simon Ser wrote:
> You'll need to set the format_mod_supported hook as well, otherwise the kernel
> will expose a bogus IN_FORMATS prop with one modifier and zero formats.

Hi Simon,

Thank you very much for reviewing this patch, I just started learning
about DRM and this kind of reviews are really helpful :)

I was a bit confused by the docs[1]: (*stars* added in the relevant parts)

> format_mod_supported:
>
> This *optional* hook is used for the DRM to determine if the given
> format/modifier combination is valid for the plane. This allows the
> DRM to generate the correct format bitmask (which formats apply to
> which modifier), and to valdiate modifiers at atomic_check time.
>
> *If not present*, then any modifier in the plane’s modifier list is
> allowed with any of the plane’s formats.

How I read it: "format_mod_supported" can be ignored where no filtering
is intended.

Looking at "create_in_format_blob" this does not look like a bug... But
I am not sure. You probably know the answer.
Whether the anwser is to chage the docs or "create_in_format_blob" I can
send a patch.

For what is worth, after extrating the relevant bits from Weston's
"drm_plane_populate_formats" function to my test program [2], formats
are not listed if "format_mod_supported" is not implemented. The same
applies to drm_info.
So, for the moment I emailed v2 implementing "format_mod_supported" [3].

By the way, this could be related to [4], see commit
b36a6bb8a151c056e1046e9d5b1192d90d9941c9. If we decided that the docs
are wrong I can send a patch as well.

Thanks again for your input,
Jose

[1] 
https://www.kernel.org/doc/html/latest/gpu/drm-kms.html?highlight=in_formats#c.drm_plane_funcs
[2] https://github.com/JoseExposito/drm-sandbox/blob/main/in_formats.c
[3] 
https://lore.kernel.org/dri-devel/20211216170140.15803-1-jose.exposit...@gmail.com/T/
[4] 
https://lists.freedesktop.org/archives/wayland-devel/2021-December/042072.html


[PATCH v2 2/2] drm/vkms: set plane modifiers

2021-12-16 Thread José Expósito
Where no modifiers are exposed, usually linear modifier is assumed.
However, userspace code is starting to expect IN_FORMATS even when the
only supported modifiers are linear [1].

To avoid possible issues, explicitly set the DRM_FORMAT_MOD_LINEAR
modifier.

[1] 
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/599/diffs?commit_id=5aea1bc522f0874e6cc07f5120fbcf1736706536

Suggested-by: Chris Healy 
Signed-off-by: José Expósito 

---

v2: Implement format_mod_supported (Simon Ser)
---
 drivers/gpu/drm/vkms/vkms_plane.c | 34 ++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vkms/vkms_plane.c 
b/drivers/gpu/drm/vkms/vkms_plane.c
index 76a06dd92ac1..7e0d021494c3 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -20,6 +20,11 @@ static const u32 vkms_plane_formats[] = {
DRM_FORMAT_XRGB
 };
 
+static const u64 vkms_plane_modifiers[] = {
+   DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_INVALID
+};
+
 static struct drm_plane_state *
 vkms_plane_duplicate_state(struct drm_plane *plane)
 {
@@ -100,12 +105,39 @@ static void vkms_formats_for_plane_type(enum 
drm_plane_type type,
}
 }
 
+static bool vkms_format_mod_supported(struct drm_plane *plane, u32 format,
+ u64 modifier)
+{
+   bool modifier_found = false;
+   unsigned int i;
+   const u32 *formats;
+   int nformats;
+
+   for (i = 0; i < ARRAY_SIZE(vkms_plane_modifiers) - 1; i++) {
+   if (vkms_plane_modifiers[i] == modifier)
+   modifier_found = true;
+   }
+
+   if (!modifier_found)
+   return false;
+
+   vkms_formats_for_plane_type(plane->type, , );
+
+   for (i = 0; i < nformats; i++) {
+   if (formats[i] == format)
+   return true;
+   }
+
+   return false;
+}
+
 static const struct drm_plane_funcs vkms_plane_funcs = {
.update_plane   = drm_atomic_helper_update_plane,
.disable_plane  = drm_atomic_helper_disable_plane,
.reset  = vkms_plane_reset,
.atomic_duplicate_state = vkms_plane_duplicate_state,
.atomic_destroy_state   = vkms_plane_destroy_state,
+   .format_mod_supported   = vkms_format_mod_supported,
 };
 
 static void vkms_plane_atomic_update(struct drm_plane *plane,
@@ -190,7 +222,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device 
*vkmsdev,
plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << 
index,
   _plane_funcs,
   formats, nformats,
-  NULL, type, NULL);
+  vkms_plane_modifiers, type, NULL);
if (IS_ERR(plane))
return plane;
 
-- 
2.25.1



[PATCH v2 1/2] drm/vkms: add function to get plane formats

2021-12-16 Thread José Expósito
Move the logic to get the plane formats depending on the plane type to
its own function.
Refactor, no functional changes.

Signed-off-by: José Expósito 
---
 drivers/gpu/drm/vkms/vkms_plane.c | 37 ---
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_plane.c 
b/drivers/gpu/drm/vkms/vkms_plane.c
index 32409e15244b..76a06dd92ac1 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -83,6 +83,23 @@ static void vkms_plane_reset(struct drm_plane *plane)
__drm_gem_reset_shadow_plane(plane, _state->base);
 }
 
+static void vkms_formats_for_plane_type(enum drm_plane_type type,
+   const u32 **formats, int *nformats)
+{
+   switch (type) {
+   case DRM_PLANE_TYPE_CURSOR:
+   case DRM_PLANE_TYPE_OVERLAY:
+   *formats = vkms_plane_formats;
+   *nformats = ARRAY_SIZE(vkms_plane_formats);
+   break;
+   case DRM_PLANE_TYPE_PRIMARY:
+   default:
+   *formats = vkms_formats;
+   *nformats = ARRAY_SIZE(vkms_formats);
+   break;
+   }
+}
+
 static const struct drm_plane_funcs vkms_plane_funcs = {
.update_plane   = drm_atomic_helper_update_plane,
.disable_plane  = drm_atomic_helper_disable_plane,
@@ -167,24 +184,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device 
*vkmsdev,
const u32 *formats;
int nformats;
 
-   switch (type) {
-   case DRM_PLANE_TYPE_PRIMARY:
-   formats = vkms_formats;
-   nformats = ARRAY_SIZE(vkms_formats);
-   funcs = _primary_helper_funcs;
-   break;
-   case DRM_PLANE_TYPE_CURSOR:
-   case DRM_PLANE_TYPE_OVERLAY:
-   formats = vkms_plane_formats;
-   nformats = ARRAY_SIZE(vkms_plane_formats);
-   funcs = _primary_helper_funcs;
-   break;
-   default:
-   formats = vkms_formats;
-   nformats = ARRAY_SIZE(vkms_formats);
-   funcs = _primary_helper_funcs;
-   break;
-   }
+   funcs = _primary_helper_funcs;
+   vkms_formats_for_plane_type(type, , );
 
plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << 
index,
   _plane_funcs,
-- 
2.25.1



Re: [PATCH] mediatek: Set default value for Panel Orientation connector prop.

2021-12-16 Thread Chun-Kuang Hu
Hi, Mark:

Mark Yacoub  於 2021年12月16日 週四 上午1:25寫道:
>
> On Wed, Dec 15, 2021 at 11:14 AM Chun-Kuang Hu  
> wrote:
> >
> > Hi, Mark:
> >
> > Mark Yacoub  於 2021年12月14日 週二 下午11:13寫道:
> > >
> > > Hey CK, can we have this merged?
> > > Thank you!
> > >
> > > On Mon, Oct 25, 2021 at 9:13 PM Sean Paul  wrote:
> > > >
> > > > On Fri, Oct 22, 2021 at 01:24:03PM -0400, Mark Yacoub wrote:
> > > > > From: Mark Yacoub 
> > > > >
> > > > > [Why]
> > > > > Creating the prop uses UNKNOWN as the initial value, which is not a
> > > > > supported value if the props is to be supported.
> > > > >
> > > > > [How]
> > > > > Set the panel orientation default value to NORMAL right after creating
> > > > > the prop.
> > > >
> > > > Reviewed-by: Sean Paul 
> > > >
> > > > >
> > > > > Tested on Jacuzzi(MTK)
> > > > > Fixes IGT@kms_properties@get_properties-sanity-{atomic,non-atomic}
> > > > >
> > > > > Signed-off-by: Mark Yacoub 
> > > > > ---
> > > > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 2 ++
> > > > >  1 file changed, 2 insertions(+)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
> > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > index 0ad7157660afa..b7c2528a8f41c 100644
> > > > > --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > @@ -1039,6 +1039,8 @@ static int mtk_dsi_encoder_init(struct 
> > > > > drm_device *drm, struct mtk_dsi *dsi)
> > > > >   DRM_ERROR("Unable to init panel orientation\n");
> > > > >   goto err_cleanup_encoder;
> > > > >   }
> > > > > + drm_connector_set_panel_orientation(dsi->connector,
> > > > > + 
> > > > > DRM_MODE_PANEL_ORIENTATION_NORMAL);
> >
> > In drm_connector_set_panel_orientation() [1], I find that the
> > orientation could be set only once. Once you set it to normal, it
> > could not be set to other orientation. Right?
> >
> Hello,
> Yeah this looks true, and makes sense according to the documentation:
> https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html#:~:text=one%20standardized%20property%3A-,panel%20orientation%3A,-On%20some%20devices
>
> Panel orientation has to do with the how the hardware is mounted, in
> contrast with the Rotation property. All the HW we have right now has
> a normal panel orientation so it makes sense to be set this way. Among

Many evidence [1], [2], [3], show that Chromebook plan to have other
orientation on mt8183, so I think you should consider this.

[1] 
https://patchwork.kernel.org/project/linux-mediatek/patch/20210409045314.3420733-2-hsi...@chromium.org/
[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c?h=v5.16-rc5#n1474
[3] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts?h=v5.16-rc5#n22

Regards,
Chun-Kuang.



> other drivers, panel orientation is always set right after the
> property is initialized.
>
> > [1] 
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/drm_connector.c?h=v5.16-rc5#n2302
> >
> > Regards,
> > Chun-Kuang.
> >
> > > > >
> > > > >   drm_connector_attach_encoder(dsi->connector, >encoder);
> > > > >
> > > > > --
> > > > > 2.33.0.1079.g6e70778dc9-goog
> > > > >
> > > >
> > > > --
> > > > Sean Paul, Software Engineer, Google / Chromium OS


Re: [PATCH] dt-bindings: display: bridge: document Toshiba TC358768 cells and panel node

2021-12-16 Thread Dmitry Osipenko
16.12.2021 18:13, Rob Herring пишет:
> On Wed, Dec 15, 2021 at 9:38 AM David Heidelberg  wrote:
>>
>> Properties #address-cells and #size-cells are valid.
>> The bridge node can also contains panel node.
>>
>> Signed-off-by: David Heidelberg 
>> ---
>>  .../bindings/display/bridge/toshiba,tc358768.yaml  | 10 ++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/display/bridge/toshiba,tc358768.yaml 
>> b/Documentation/devicetree/bindings/display/bridge/toshiba,tc358768.yaml
>> index eacfe7165083..3186d9dffd98 100644
>> --- a/Documentation/devicetree/bindings/display/bridge/toshiba,tc358768.yaml
>> +++ b/Documentation/devicetree/bindings/display/bridge/toshiba,tc358768.yaml
>> @@ -69,6 +69,16 @@ properties:
>>- port@0
>>- port@1
>>
>> +  '#address-cells':
>> +const: 1
>> +
>> +  '#size-cells':
>> +const: 0
>> +
>> +patternProperties:
>> +  "^panel@[0-3]$":
>> +$ref: ../panel/panel-common.yaml
> 
> It's possible to attach something that doesn't use panel-common.yaml
> and if it did, it would be applied by that schema.
> 
> What you need is to just reference dsi-controller.yaml at the top level.

It works, thank you.

Then we will also need to rename the "dsi-bridge" node to just "dsi" in
the new ASUS TF700T device-tree since dsi-controller.yaml wants that name.


[PATCH] drm/panfrost: Avoid user size passed to kvmalloc()

2021-12-16 Thread Steven Price
panfrost_copy_in_sync() takes the number of fences from user space
(in_sync_count) and used to kvmalloc() an array to hold that number of
fences before processing them. This provides an easy method for user
space to trigger the OOM killer (by temporarily allocating large amounts
of kernel memory) or hit the WARN_ONCE() added by 7661809d493b ("mm:
don't allow oversized kvmalloc() calls").

Since we don't expect there to be a large number of fences we can
instead iterate over the fences one-by-one and avoid the temporary
allocation altogether. This also makes the code simpler.

Reported-by: Dan Carpenter 
Signed-off-by: Steven Price 
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 44 -
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c 
b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 96bb5a465627..12ab55e5782c 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -186,47 +186,31 @@ panfrost_copy_in_sync(struct drm_device *dev,
  struct drm_panfrost_submit *args,
  struct panfrost_job *job)
 {
-   u32 *handles;
-   int ret = 0;
-   int i, in_fence_count;
-
-   in_fence_count = args->in_sync_count;
-
-   if (!in_fence_count)
-   return 0;
-
-   handles = kvmalloc_array(in_fence_count, sizeof(u32), GFP_KERNEL);
-   if (!handles) {
-   ret = -ENOMEM;
-   DRM_DEBUG("Failed to allocate incoming syncobj handles\n");
-   goto fail;
-   }
+   int i;
+   u32 __user *user_handles = u64_to_user_ptr(args->in_syncs);
 
-   if (copy_from_user(handles,
-  (void __user *)(uintptr_t)args->in_syncs,
-  in_fence_count * sizeof(u32))) {
-   ret = -EFAULT;
-   DRM_DEBUG("Failed to copy in syncobj handles\n");
-   goto fail;
-   }
-
-   for (i = 0; i < in_fence_count; i++) {
+   for (i = 0; i < args->in_sync_count; i++) {
struct dma_fence *fence;
+   u32 handle;
+   int ret;
+
+   ret = copy_from_user(, user_handles + i,
+sizeof(handle));
+   if (ret)
+   return -EFAULT;
 
-   ret = drm_syncobj_find_fence(file_priv, handles[i], 0, 0,
+   ret = drm_syncobj_find_fence(file_priv, handle, 0, 0,
 );
if (ret)
-   goto fail;
+   return ret;
 
ret = drm_sched_job_add_dependency(>base, fence);
 
if (ret)
-   goto fail;
+   return ret;
}
 
-fail:
-   kvfree(handles);
-   return ret;
+   return 0;
 }
 
 static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
-- 
2.30.2



Re: [PATCH 53/60] drm/repaper: Add support for the nomodeset kernel parameter

2021-12-16 Thread Noralf Trønnes



Den 15.12.2021 02.00, skrev Javier Martinez Canillas:
> According to disable Documentation/admin-guide/kernel-parameters.txt, this
> parameter can be used to disable kernel modesetting.
> 
> DRM drivers will not perform display-mode changes or accelerated rendering
> and only the systewm system framebuffer will be available if it was set-up.
> 
> But only a few DRM drivers currently check for nomodeset, make this driver
> to also support the command line parameter.
> 
> Signed-off-by: Javier Martinez Canillas 
> ---

Acked-by: Noralf Trønnes 


Re: [PATCH 52/60] drm/mi0283qt: Add support for the nomodeset kernel parameter

2021-12-16 Thread Noralf Trønnes



Den 15.12.2021 02.00, skrev Javier Martinez Canillas:
> According to disable Documentation/admin-guide/kernel-parameters.txt, this
> parameter can be used to disable kernel modesetting.
> 
> DRM drivers will not perform display-mode changes or accelerated rendering
> and only the systewm system framebuffer will be available if it was set-up.
> 
> But only a few DRM drivers currently check for nomodeset, make this driver
> to also support the command line parameter.
> 
> Signed-off-by: Javier Martinez Canillas 
> ---

Acked-by: Noralf Trønnes 


Re: [PATCH 11/60] drm/gud: Add support for the nomodeset kernel parameter

2021-12-16 Thread Noralf Trønnes



Den 16.12.2021 09.20, skrev Thomas Zimmermann:
> Hi
> 
> Am 15.12.21 um 22:37 schrieb Noralf Trønnes:
>>
>>
>> Den 15.12.2021 01.59, skrev Javier Martinez Canillas:
>>> According to disable Documentation/admin-guide/kernel-parameters.txt,
>>> this
>>> parameter can be used to disable kernel modesetting.
>>>
>>> DRM drivers will not perform display-mode changes or accelerated
>>> rendering
>>> and only the systewm system framebuffer will be available if it was
>>> set-up.
>>>
>>> But only a few DRM drivers currently check for nomodeset, make this
>>> driver
>>> to also support the command line parameter.
>>>
>>> Signed-off-by: Javier Martinez Canillas 
>>> ---
>>>
>>
>> I don't understand why this is applicable to USB drivers, there's no way
>> the firmware can setup a framebuffer and continue pushing pixels over
>> USB when Linux has been given control over the USB bus?
>>
>> The same argument goes for the SPI drivers in drm/tiny/ as well.
> 
> The intended semantics of the option is to disable every display output
> except for the buffer provided by the firmware.
> 

If that's the case this patch is:

Acked-by: Noralf Trønnes 

> With USB it still would still disable the driver. That's useful if only
> for debugging. There are also systems with hard-wired USB displays where
> one cannot just unplug the adapter.
> 
> Admittedly, USB graphics is a bit of an odd use case, but neither is it
> too far fetched IMHO.
> 
> Best regards
> Thomas
> 
>>
>> Noralf.
>>
>>>   drivers/gpu/drm/gud/gud_drv.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/gud/gud_drv.c
>>> b/drivers/gpu/drm/gud/gud_drv.c
>>> index 3f9d4b9a1e3d..4d253d249512 100644
>>> --- a/drivers/gpu/drm/gud/gud_drv.c
>>> +++ b/drivers/gpu/drm/gud/gud_drv.c
>>> @@ -446,6 +446,9 @@ static int gud_probe(struct usb_interface *intf,
>>> const struct usb_device_id *id)
>>>   u32 *formats;
>>>   int ret, i;
>>>   +    if (drm_firmware_drivers_only())
>>> +    return -ENODEV;
>>> +
>>>   ret = usb_find_bulk_out_endpoint(intf->cur_altsetting, _out);
>>>   if (ret)
>>>   return ret;
>>>
> 


Re: [PATCH v11 0/8] MIPS: JZ4780 and CI20 HDMI

2021-12-16 Thread H. Nikolaus Schaller
Hi Paul and Thomas,
thanks for already applying some of the patches of this series!

> Am 16.12.2021 um 16:24 schrieb Paul Cercueil :
> 
> Hi,
> 
> Patches 1 and 2 added to drm-misc-next.
> 
> I'll pick the rest when the regulator situation is sorted out.
> 

I had started working on the regulator and while testing and trying to read the 
EDID
something has damaged my monitor so that it does no longer report proper EDID 
information
(for the second time, so that I can't pledge for another warrany repair). Maybe 
controlling
+5V for this specific monitor must be done very carefully and in a specific 
sequence...

So I will need some more days for building a more robust test setup and doing 
verification
of the driver. Well I have other monitors, but this was the cheapest one and 
available
for such experiments :)

Generally the idea is to replace the regulator with a ddc-en-gpios property of 
the connector.

Unfortunately it does not work to control it by atomic enable/disable in the 
connector driver
(it is not called at all). So I have been working on an approach following the 
concept how
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c does it.

Sorry for the delay, but a V12 will come.

BR and thanks,
Nikolaus



[PATCH v4 3/3] drm/i915/migrate: add acceleration support for DG2

2021-12-16 Thread Matthew Auld
This is all kinds of awkward since we now have to contend with using 64K
GTT pages when mapping anything in LMEM(including the page-tables
themselves).

v2(Ram)
  - Document the ppGTT layout and add a better description for the
different windows.

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Ramalingam C 
Reviewed-by: Ramalingam C 
---
 drivers/gpu/drm/i915/gt/intel_migrate.c | 209 +++-
 1 file changed, 170 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_migrate.c 
b/drivers/gpu/drm/i915/gt/intel_migrate.c
index 64ffaacac1e0..c8f564b976e3 100644
--- a/drivers/gpu/drm/i915/gt/intel_migrate.c
+++ b/drivers/gpu/drm/i915/gt/intel_migrate.c
@@ -33,6 +33,38 @@ static bool engine_supports_migration(struct intel_engine_cs 
*engine)
return true;
 }
 
+static void xehpsdv_toggle_pdes(struct i915_address_space *vm,
+   struct i915_page_table *pt,
+   void *data)
+{
+   struct insert_pte_data *d = data;
+
+   /*
+* Insert a dummy PTE into every PT that will map to LMEM to ensure
+* we have a correctly setup PDE structure for later use.
+*/
+   vm->insert_page(vm, 0, d->offset, I915_CACHE_NONE, PTE_LM);
+   GEM_BUG_ON(!pt->is_compact);
+   d->offset += SZ_2M;
+}
+
+static void xehpsdv_insert_pte(struct i915_address_space *vm,
+  struct i915_page_table *pt,
+  void *data)
+{
+   struct insert_pte_data *d = data;
+
+   /*
+* We are playing tricks here, since the actual pt, from the hw
+* pov, is only 256bytes with 32 entries, or 4096bytes with 512
+* entries, but we are still guaranteed that the physical
+* alignment is 64K underneath for the pt, and we are careful
+* not to access the space in the void.
+*/
+   vm->insert_page(vm, px_dma(pt), d->offset, I915_CACHE_NONE, PTE_LM);
+   d->offset += SZ_64K;
+}
+
 static void insert_pte(struct i915_address_space *vm,
   struct i915_page_table *pt,
   void *data)
@@ -75,7 +107,32 @@ static struct i915_address_space *migrate_vm(struct 
intel_gt *gt)
 * i.e. within the same non-preemptible window so that we do not switch
 * to another migration context that overwrites the PTE.
 *
-* TODO: Add support for huge LMEM PTEs
+* This changes quite a bit on platforms with HAS_64K_PAGES support,
+* where we instead have three windows, each CHUNK_SIZE in size. The
+* first is reserved for mapping system-memory, and that just uses the
+* 512 entry layout using 4K GTT pages. The other two windows just map
+* lmem pages and must use the new compact 32 entry layout using 64K GTT
+* pages, which ensures we can address any lmem object that the user
+* throws at us. We then also use the xehpsdv_toggle_pdes as a way of
+* just toggling the PDE bit(GEN12_PDE_64K) for us, to enable the
+* compact layout for each of these page-tables, that fall within the
+* [CHUNK_SIZE, 3 * CHUNK_SIZE) range.
+*
+* We lay the ppGTT out as:
+*
+* [0, CHUNK_SZ) -> first window/object, maps smem
+* [CHUNK_SZ, 2 * CHUNK_SZ) -> second window/object, maps lmem src
+* [2 * CHUNK_SZ, 3 * CHUNK_SZ) -> third window/object, maps lmem dst
+*
+* For the PTE window it's also quite different, since each PTE must
+* point to some 64K page, one for each PT(since it's in lmem), and yet
+* each is only <= 4096bytes, but since the unused space within that PTE
+* range is never touched, this should be fine.
+*
+* So basically each PT now needs 64K of virtual memory, instead of 4K,
+* which looks like:
+*
+* [3 * CHUNK_SZ, 3 * CHUNK_SZ + ((3 * CHUNK_SZ / SZ_2M) * SZ_64K)] -> 
PTE
 */
 
vm = i915_ppgtt_create(gt, I915_BO_ALLOC_PM_EARLY);
@@ -87,6 +144,9 @@ static struct i915_address_space *migrate_vm(struct intel_gt 
*gt)
goto err_vm;
}
 
+   if (HAS_64K_PAGES(gt->i915))
+   stash.pt_sz = I915_GTT_PAGE_SIZE_64K;
+
/*
 * Each engine instance is assigned its own chunk in the VM, so
 * that we can run multiple instances concurrently
@@ -106,14 +166,20 @@ static struct i915_address_space *migrate_vm(struct 
intel_gt *gt)
 * We copy in 8MiB chunks. Each PDE covers 2MiB, so we need
 * 4x2 page directories for source/destination.
 */
-   sz = 2 * CHUNK_SZ;
+   if (HAS_64K_PAGES(gt->i915))
+   sz = 3 * CHUNK_SZ;
+   else
+   sz = 2 * CHUNK_SZ;
d.offset = base + sz;
 
/*
 * We need another page directory setup so that we can write
 

[PATCH v4 2/3] drm/i915/gtt: add xehpsdv_ppgtt_insert_entry

2021-12-16 Thread Matthew Auld
If this is LMEM then we get a 32 entry PT, with each PTE pointing to
some 64K block of memory, otherwise it's just the usual 512 entry PT.
This very much assumes the caller knows what they are doing.

Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Ramalingam C 
Reviewed-by: Ramalingam C 
---
 drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 50 ++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c 
b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c
index 5db11d8f7c7a..b6e9bfecb023 100644
--- a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c
@@ -728,13 +728,56 @@ static void gen8_ppgtt_insert_entry(struct 
i915_address_space *vm,
gen8_pdp_for_page_index(vm, idx);
struct i915_page_directory *pd =
i915_pd_entry(pdp, gen8_pd_index(idx, 2));
+   struct i915_page_table *pt = i915_pt_entry(pd, gen8_pd_index(idx, 1));
gen8_pte_t *vaddr;
 
-   vaddr = px_vaddr(i915_pt_entry(pd, gen8_pd_index(idx, 1)));
+   GEM_BUG_ON(pt->is_compact);
+
+   vaddr = px_vaddr(pt);
vaddr[gen8_pd_index(idx, 0)] = gen8_pte_encode(addr, level, flags);
clflush_cache_range([gen8_pd_index(idx, 0)], sizeof(*vaddr));
 }
 
+static void __xehpsdv_ppgtt_insert_entry_lm(struct i915_address_space *vm,
+   dma_addr_t addr,
+   u64 offset,
+   enum i915_cache_level level,
+   u32 flags)
+{
+   u64 idx = offset >> GEN8_PTE_SHIFT;
+   struct i915_page_directory * const pdp =
+   gen8_pdp_for_page_index(vm, idx);
+   struct i915_page_directory *pd =
+   i915_pd_entry(pdp, gen8_pd_index(idx, 2));
+   struct i915_page_table *pt = i915_pt_entry(pd, gen8_pd_index(idx, 1));
+   gen8_pte_t *vaddr;
+
+   GEM_BUG_ON(!IS_ALIGNED(addr, SZ_64K));
+   GEM_BUG_ON(!IS_ALIGNED(offset, SZ_64K));
+
+   if (!pt->is_compact) {
+   vaddr = px_vaddr(pd);
+   vaddr[gen8_pd_index(idx, 1)] |= GEN12_PDE_64K;
+   pt->is_compact = true;
+   }
+
+   vaddr = px_vaddr(pt);
+   vaddr[gen8_pd_index(idx, 0) / 16] = gen8_pte_encode(addr, level, flags);
+}
+
+static void xehpsdv_ppgtt_insert_entry(struct i915_address_space *vm,
+  dma_addr_t addr,
+  u64 offset,
+  enum i915_cache_level level,
+  u32 flags)
+{
+   if (flags & PTE_LM)
+   return __xehpsdv_ppgtt_insert_entry_lm(vm, addr, offset,
+  level, flags);
+
+   return gen8_ppgtt_insert_entry(vm, addr, offset, level, flags);
+}
+
 static int gen8_init_scratch(struct i915_address_space *vm)
 {
u32 pte_flags;
@@ -937,7 +980,10 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt,
 
ppgtt->vm.bind_async_flags = I915_VMA_LOCAL_BIND;
ppgtt->vm.insert_entries = gen8_ppgtt_insert;
-   ppgtt->vm.insert_page = gen8_ppgtt_insert_entry;
+   if (HAS_64K_PAGES(gt->i915))
+   ppgtt->vm.insert_page = xehpsdv_ppgtt_insert_entry;
+   else
+   ppgtt->vm.insert_page = gen8_ppgtt_insert_entry;
ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc;
ppgtt->vm.clear_range = gen8_ppgtt_clear;
ppgtt->vm.foreach = gen8_ppgtt_foreach;
-- 
2.31.1



[PATCH v4 1/3] drm/i915/gtt: allow overriding the pt alignment

2021-12-16 Thread Matthew Auld
On some platforms we have alignment restrictions when accessing LMEM
from the GTT. In the next few patches we need to be able to modify the
page-tables directly via the GTT itself.

Suggested-by: Ramalingam C 
Signed-off-by: Matthew Auld 
Cc: Thomas Hellström 
Cc: Ramalingam C 
Reviewed-by: Ramalingam C 
---
 drivers/gpu/drm/i915/gt/intel_gtt.h   | 10 +-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c | 16 
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h 
b/drivers/gpu/drm/i915/gt/intel_gtt.h
index 01e9a98846fb..5ca5caa667b8 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -199,6 +199,14 @@ void *__px_vaddr(struct drm_i915_gem_object *p);
 struct i915_vm_pt_stash {
/* preallocated chains of page tables/directories */
struct i915_page_table *pt[2];
+   /*
+* Optionally override the alignment/size of the physical page that
+* contains each PT. If not set defaults back to the usual
+* I915_GTT_PAGE_SIZE_4K. This does not influence the other paging
+* structures. MUST be a power-of-two. ONLY applicable on discrete
+* platforms.
+*/
+   int pt_sz;
 };
 
 struct i915_vma_ops {
@@ -586,7 +594,7 @@ void free_scratch(struct i915_address_space *vm);
 
 struct drm_i915_gem_object *alloc_pt_dma(struct i915_address_space *vm, int 
sz);
 struct drm_i915_gem_object *alloc_pt_lmem(struct i915_address_space *vm, int 
sz);
-struct i915_page_table *alloc_pt(struct i915_address_space *vm);
+struct i915_page_table *alloc_pt(struct i915_address_space *vm, int sz);
 struct i915_page_directory *alloc_pd(struct i915_address_space *vm);
 struct i915_page_directory *__alloc_pd(int npde);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c 
b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
index b8238f5bc8b1..3c90aea25072 100644
--- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
@@ -12,7 +12,7 @@
 #include "gen6_ppgtt.h"
 #include "gen8_ppgtt.h"
 
-struct i915_page_table *alloc_pt(struct i915_address_space *vm)
+struct i915_page_table *alloc_pt(struct i915_address_space *vm, int sz)
 {
struct i915_page_table *pt;
 
@@ -20,7 +20,7 @@ struct i915_page_table *alloc_pt(struct i915_address_space 
*vm)
if (unlikely(!pt))
return ERR_PTR(-ENOMEM);
 
-   pt->base = vm->alloc_pt_dma(vm, I915_GTT_PAGE_SIZE_4K);
+   pt->base = vm->alloc_pt_dma(vm, sz);
if (IS_ERR(pt->base)) {
kfree(pt);
return ERR_PTR(-ENOMEM);
@@ -219,17 +219,25 @@ int i915_vm_alloc_pt_stash(struct i915_address_space *vm,
   u64 size)
 {
unsigned long count;
-   int shift, n;
+   int shift, n, pt_sz;
 
shift = vm->pd_shift;
if (!shift)
return 0;
 
+   pt_sz = stash->pt_sz;
+   if (!pt_sz)
+   pt_sz = I915_GTT_PAGE_SIZE_4K;
+   else
+   GEM_BUG_ON(!IS_DGFX(vm->i915));
+
+   GEM_BUG_ON(!is_power_of_2(pt_sz));
+
count = pd_count(size, shift);
while (count--) {
struct i915_page_table *pt;
 
-   pt = alloc_pt(vm);
+   pt = alloc_pt(vm, pt_sz);
if (IS_ERR(pt)) {
i915_vm_free_pt_stash(vm, stash);
return PTR_ERR(pt);
-- 
2.31.1



[PATCH v4 0/3] DG2 accelerated migration/clearing support

2021-12-16 Thread Matthew Auld
Enable accelerated moves and clearing on DG2. On such HW we have minimum page
size restrictions when accessing LMEM from the GTT, where we now have to use 64K
GTT pages or larger. With the ppGTT the page-table also has a slightly different
layout from past generations when using the 64K GTT mode(which is still enabled
on via some PDE bit), where it is now compacted down to 32 qword entries. Note
that on discrete the paging structures must also be placed in LMEM, and we need
to able to modify them via the GTT itself(see patch 3), which is one of the
complications here.

v2: Add missing cover letter
v3:
  - Add some r-b tags
  - Drop the GTT_MAPPABLE approach. We can instead simply pass along the
required size/alignment using alloc_pt().
v4:
  - Drop already merged patches, and add some r-b tags
  - Add some better docs to patch 3

Matthew Auld (3):
  drm/i915/gtt: allow overriding the pt alignment
  drm/i915/gtt: add xehpsdv_ppgtt_insert_entry
  drm/i915/migrate: add acceleration support for DG2

 drivers/gpu/drm/i915/gt/gen8_ppgtt.c|  50 +-
 drivers/gpu/drm/i915/gt/intel_gtt.h |  10 +-
 drivers/gpu/drm/i915/gt/intel_migrate.c | 209 +++-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c   |  16 +-
 4 files changed, 239 insertions(+), 46 deletions(-)

-- 
2.31.1



Re: [PATCH v4 13/22] ASoC: tegra20: i2s: Filter out unsupported rates

2021-12-16 Thread Thierry Reding
On Sat, Dec 04, 2021 at 05:37:16PM +0300, Dmitry Osipenko wrote:
> Support new nvidia,fixed-parent-rate device-tree property which instructs
> I2S that board wants parent clock rate to stay at a fixed rate. This allows
> to play audio over S/PDIF and I2S simultaneously. The root of the problem
> is that audio components on Tegra share the same audio PLL, and thus, only
> a subset of rates can be supported if we want to play audio simultaneously.
> Filter out audio rates that don't match parent clock rate if device-tree
> has the nvidia,fixed-parent-rate property.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  sound/soc/tegra/tegra20_i2s.c | 49 +++
>  1 file changed, 49 insertions(+)

Acked-by: Thierry Reding 


signature.asc
Description: PGP signature


  1   2   3   >