drm/amd/display: Exit idle optimizations before HDCP execution
Subsystems (3)
Sasha Levin
maintainerPATCH 1/7 drm/amd/display: Exit idle optimizations before HDCP execution
From: Nicholas Kazlauskas <[email protected]>
[ Upstream commit f30a3bea92bdab398531129d187629fb1d28f598 ]
[WHY]
PSP can access DCN registers during command submission and we need to ensure that DCN is not in PG before doing so.
[HOW]
Add a callback to DM to lock and notify DC for idle optimization exit. It can't be DC directly because of a potential race condition with the link protection thread and the rest of DM operation.
--- drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c | 10 ++++++++++ drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h | 8 ++++++++ 2 files changed, 18 insertions(+)
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c +10 -0
@@ -86,6 +86,14 @@ static uint8_t is_cp_desired_hdcp2(struct mod_hdcp *hdcp) !hdcp->connection.is_hdcp2_revoked; } +static void exit_idle_optimizations (struct mod_hdcp *hdcp) +{ +struct mod_hdcp_dm *dm = &hdcp->config.dm; + +if (dm->funcs.exit_idle_optimizations) + dm->funcs.exit_idle_optimizations (dm->handle); +} +static enum mod_hdcp_status execution (struct mod_hdcp *hdcp,struct mod_hdcp_event_context *event_ctx,union mod_hdcp_transition_input *input)
@@ -448,6 +456,8 @@ enum mod_hdcp_status mod_hdcp_process_event(struct mod_hdcp *hdcp,memset (&event_ctx,0 ,sizeof (struct mod_hdcp_event_context )); event_ctx.event = event; +exit_idle_optimizations (hdcp); +/* execute and transition */ exec_status =execution (hdcp, &event_ctx, &hdcp->auth.trans_input); trans_status = transition(
drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h +8 -0
@@ -143,6 +143,13 @@ struct mod_hdcp_ddc { } funcs; }; +struct mod_hdcp_dm { +void *handle; +struct { +void (*exit_idle_optimizations)(void *handle); + } funcs; +}; +struct mod_hdcp_psp {void *handle;void *funcs;
@@ -252,6 +259,7 @@ struct mod_hdcp_display_query {struct mod_hdcp_config {struct mod_hdcp_psp psp;struct mod_hdcp_ddc ddc; +struct mod_hdcp_dm dm;uint8_t index; };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/7 ASoC: Intel: sof_sdw: add JD2 quirk for HP Omen 14
From: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 4fee07fbf47d2a5f1065d985459e5ce7bf7969f0 ]
The default JD1 does not seem to work, use JD2 instead.
--- sound/soc/intel/boards/sof_sdw.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/soc/intel/boards/sof_sdw.c +9 -0
@@ -216,6 +216,15 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { }, .driver_data = (void *)(SOF_SDW_PCH_DMIC), }, + { + .callback = sof_sdw_quirk_cb, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), + DMI_MATCH(DMI_PRODUCT_NAME, "OMEN Transcend Gaming Laptop"), + }, + .driver_data = (void *)(RT711_JD2), + }, + /* LunarLake devices */ { .callback = sof_sdw_quirk_cb,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/7 drm/lima: add mask irq callback to gp and pp
In reply to Sasha LevinFrom: Erico Nunes <[email protected]>
[ Upstream commit 49c13b4d2dd4a831225746e758893673f6ae961c ]
This is needed because we want to reset those devices in device-agnostic code such as lima_sched.
In particular, masking irqs will be useful before a hard reset to prevent race conditions.
--- drivers/gpu/drm/lima/lima_bcast.c | 12 ++++++++++++ drivers/gpu/drm/lima/lima_bcast.h | 3 +++ drivers/gpu/drm/lima/lima_gp.c | 8 ++++++++ drivers/gpu/drm/lima/lima_pp.c | 18 ++++++++++++++++++ drivers/gpu/drm/lima/lima_sched.h | 1 + 5 files changed, 42 insertions(+)
drivers/gpu/drm/lima/lima_bcast.c +12 -0
@@ -43,6 +43,18 @@ void lima_bcast_suspend(struct lima_ip *ip) } +int lima_bcast_mask_irq (struct lima_ip *ip) +{ +bcast_write (LIMA_BCAST_BROADCAST_MASK ,0 ); +bcast_write (LIMA_BCAST_INTERRUPT_MASK ,0 ); +return 0 ; +} + +int lima_bcast_reset (struct lima_ip *ip) +{ +return lima_bcast_hw_init (ip); +} +int lima_bcast_init (struct lima_ip *ip) {int i;
drivers/gpu/drm/lima/lima_bcast.h +3 -0
@@ -13,4 +13,7 @@ void lima_bcast_fini(struct lima_ip *ip);void lima_bcast_enable (struct lima_device *dev,int num_pp); +int lima_bcast_mask_irq (struct lima_ip *ip); +int lima_bcast_reset (struct lima_ip *ip); +#endif
drivers/gpu/drm/lima/lima_gp.c +8 -0
@@ -212,6 +212,13 @@ static void lima_gp_task_mmu_error(struct lima_sched_pipe *pipe)lima_sched_pipe_task_done (pipe); } +static void lima_gp_task_mask_irq (struct lima_sched_pipe *pipe) +{ +struct lima_ip *ip = pipe->processor[0 ]; + +gp_write (LIMA_GP_INT_MASK ,0 ); +} +static int lima_gp_task_recover (struct lima_sched_pipe *pipe) {struct lima_ip *ip = pipe->processor[0 ];
@@ -344,6 +351,7 @@ int lima_gp_pipe_init(struct lima_device *dev) pipe->task_error = lima_gp_task_error; pipe->task_mmu_error = lima_gp_task_mmu_error; pipe->task_recover = lima_gp_task_recover; + pipe->task_mask_irq = lima_gp_task_mask_irq;return 0 ; }
drivers/gpu/drm/lima/lima_pp.c +18 -0
@@ -408,6 +408,9 @@ static void lima_pp_task_error(struct lima_sched_pipe *pipe)lima_pp_hard_reset (ip); } + +if (pipe->bcast_processor) +lima_bcast_reset (pipe->bcast_processor); }static void lima_pp_task_mmu_error (struct lima_sched_pipe *pipe)
@@ -416,6 +419,20 @@ static void lima_pp_task_mmu_error(struct lima_sched_pipe *pipe)lima_sched_pipe_task_done (pipe); } +static void lima_pp_task_mask_irq (struct lima_sched_pipe *pipe) +{ +int i; + +for (i =0 ; i < pipe->num_processor; i++) { +struct lima_ip *ip = pipe->processor[i]; + +pp_write (LIMA_PP_INT_MASK ,0 ); + } + +if (pipe->bcast_processor) +lima_bcast_mask_irq (pipe->bcast_processor); +} +static struct kmem_cache *lima_pp_task_slab;static int lima_pp_task_slab_refcnt;
@@ -447,6 +464,7 @@ int lima_pp_pipe_init(struct lima_device *dev) pipe->task_fini = lima_pp_task_fini; pipe->task_error = lima_pp_task_error; pipe->task_mmu_error = lima_pp_task_mmu_error; + pipe->task_mask_irq = lima_pp_task_mask_irq;return 0 ; }
drivers/gpu/drm/lima/lima_sched.h +1 -0
@@ -83,6 +83,7 @@ struct lima_sched_pipe {void (*task_error)(struct lima_sched_pipe *pipe);void (*task_mmu_error)(struct lima_sched_pipe *pipe);int (*task_recover)(struct lima_sched_pipe *pipe); +void (*task_mask_irq)(struct lima_sched_pipe *pipe);struct work_struct recover_work; };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/7 drm/lima: mask irqs in timeout path before hard reset
In reply to Sasha LevinFrom: Erico Nunes <[email protected]>
[ Upstream commit a421cc7a6a001b70415aa4f66024fa6178885a14 ]
There is a race condition in which a rendering job might take just long enough to trigger the drm sched job timeout handler but also still complete before the hard reset is done by the timeout handler. This runs into race conditions not expected by the timeout handler. In some very specific cases it currently may result in a refcount imbalance on lima_pm_idle, with a stack dump such as:
[10136.669170] WARNING: CPU: 0 PID: 0 at drivers/gpu/drm/lima/lima_devfreq.c:205 lima_devfreq_record_idle+0xa0/0xb0 ... [10136.669459] pc : lima_devfreq_record_idle+0xa0/0xb0 ... [10136.669628] Call trace: [10136.669634] lima_devfreq_record_idle+0xa0/0xb0 [10136.669646] lima_sched_pipe_task_done+0x5c/0xb0 [10136.669656] lima_gp_irq_handler+0xa8/0x120 [10136.669666] __handle_irq_event_percpu+0x48/0x160 [10136.669679] handle_irq_event+0x4c/0xc0
We can prevent that race condition entirely by masking the irqs at the beginning of the timeout handler, at which point we give up on waiting for that job entirely.
The irqs will be enabled again at the next hard reset which is already done as a recovery by the timeout handler.
--- drivers/gpu/drm/lima/lima_sched.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/lima/lima_sched.c +7 -0
@@ -419,6 +419,13 @@ static void lima_sched_timedout_job(struct drm_sched_job *job)struct lima_sched_task *task =to_lima_task (job);struct lima_device *ldev = pipe->ldev; +/* +* The task might still finish while this timeout handler runs. +* To prevent a race condition on its completion, mask all irqs +* on the running core until the next hard reset completes. +*/ + pipe->task_mask_irq (pipe); +if (!pipe->error)DRM_ERROR ("lima job timeout\n" );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/7 media: lgdt3306a: Add a check against null-pointer-def
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit c1115ddbda9c930fba0fdd062e7a8873ebaf898d ]
The driver should check whether the client provides the platform_data.
The following log reveals it:
[ 29.610324] BUG: KASAN: null-ptr-deref in kmemdup+0x30/0x40 [ 29.610730] Read of size 40 at addr 0000000000000000 by task bash/414 [ 29.612820] Call Trace: [ 29.613030] <TASK> [ 29.613201] dump_stack_lvl+0x56/0x6f [ 29.613496] ? kmemdup+0x30/0x40 [ 29.613754] print_report.cold+0x494/0x6b7 [ 29.614082] ? kmemdup+0x30/0x40 [ 29.614340] kasan_report+0x8a/0x190 [ 29.614628] ? kmemdup+0x30/0x40 [ 29.614888] kasan_check_range+0x14d/0x1d0 [ 29.615213] memcpy+0x20/0x60 [ 29.615454] kmemdup+0x30/0x40 [ 29.615700] lgdt3306a_probe+0x52/0x310 [ 29.616339] i2c_device_probe+0x951/0xa90
--- drivers/media/dvb-frontends/lgdt3306a.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/dvb-frontends/lgdt3306a.c +5 -0
@@ -2213,6 +2213,11 @@ static int lgdt3306a_probe(struct i2c_client *client,struct dvb_frontend *fe;int ret; +if (!client->dev.platform_data) { +dev_err (&client->dev,"platform data is mandatory\n" ); +return -EINVAL ; + } + config =kmemdup (client->dev.platform_data,sizeof (struct lgdt3306a_config ),GFP_KERNEL );if (config ==NULL ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/7 powerpc/pseries: Enforce hcall result buffer validity and size
In reply to Sasha LevinFrom: Nathan Lynch <[email protected]>
[ Upstream commit ff2e185cf73df480ec69675936c4ee75a445c3e4 ]
plpar_hcall(), plpar_hcall9(), and related functions expect callers to provide valid result buffers of certain minimum size. Currently this is communicated only through comments in the code and the compiler has no idea.
For example, if I write a bug like this:
long retbuf[PLPAR_HCALL_BUFSIZE]; // should be PLPAR_HCALL9_BUFSIZE plpar_hcall9(H_ALLOCATE_VAS_WINDOW, retbuf, ...);
This compiles with no diagnostics emitted, but likely results in stack corruption at runtime when plpar_hcall9() stores results past the end of the array. (To be clear this is a contrived example and I have not found a real instance yet.)
To make this class of error less likely, we can use explicitly-sized array parameters instead of pointers in the declarations for the hcall APIs. When compiled with -Warray-bounds[1], the code above now provokes a diagnostic like this:
error: array argument is too small;
is of size 32, callee requires at least 72 [-Werror,-Warray-bounds]
60 | plpar_hcall9(H_ALLOCATE_VAS_WINDOW, retbuf,
| ^ ~~~~~~[1] Enabled for LLVM builds but not GCC for now. See commit
0da6e5fd6c37 ("gcc: disable '-Warray-bounds' for gcc-13 too") and
related changes.--- arch/powerpc/include/asm/hvcall.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/hvcall.h +4 -4
@@ -453,7 +453,7 @@ long plpar_hcall_norets_notrace(unsigned long opcode, ...);* Used for all but the craziest of phyp interfaces (see plpar_hcall9) */ #define PLPAR_HCALL_BUFSIZE 4 -long plpar_hcall (unsigned long opcode,unsigned long *retbuf, ...); +long plpar_hcall (unsigned long opcode,unsigned long retbuf[static PLPAR_HCALL_BUFSIZE ], ...);/** * plpar_hcall_raw: - Make a hypervisor call without calculating hcall stats
@@ -467,7 +467,7 @@ long plpar_hcall(unsigned long opcode, unsigned long *retbuf, ...);* plpar_hcall, but plpar_hcall_raw works in real mode and does not * calculate hypervisor call statistics. */ -long plpar_hcall_raw (unsigned long opcode,unsigned long *retbuf, ...); +long plpar_hcall_raw (unsigned long opcode,unsigned long retbuf[static PLPAR_HCALL_BUFSIZE ], ...);/** * plpar_hcall9: - Make a pseries hypervisor call with up to 9 return arguments
@@ -478,8 +478,8 @@ long plpar_hcall_raw(unsigned long opcode, unsigned long *retbuf, ...);* PLPAR_HCALL9_BUFSIZE to size the return argument buffer. */ #define PLPAR_HCALL9_BUFSIZE 9 -long plpar_hcall9 (unsigned long opcode,unsigned long *retbuf, ...); -long plpar_hcall9_raw (unsigned long opcode,unsigned long *retbuf, ...); +long plpar_hcall9 (unsigned long opcode,unsigned long retbuf[static PLPAR_HCALL9_BUFSIZE ], ...); +long plpar_hcall9_raw (unsigned long opcode,unsigned long retbuf[static PLPAR_HCALL9_BUFSIZE ], ...);struct hvcall_mpp_data {unsigned long entitled_mem;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/7 powerpc/io: Avoid clang null pointer arithmetic warnings
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
[ Upstream commit 03c0f2c2b2220fc9cf8785cd7b61d3e71e24a366 ]
With -Wextra clang warns about pointer arithmetic using a null pointer. When building with CONFIG_PCI=n, that triggers a warning in the IO accessors, eg:
In file included from linux/arch/powerpc/include/asm/io.h:672:
linux/arch/powerpc/include/asm/io-defs.h:23:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
23 | DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port), pio, port)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
linux/arch/powerpc/include/asm/io.h:591:53: note: expanded from macro '__do_inb'
591 | #define __do_inb(port) readb((PCI_IO_ADDR)_IO_BASE + port);
| ~~~~~~~~~~~~~~~~~~~~~ ^That is because when CONFIG_PCI=n, _IO_BASE is defined as 0.
Although _IO_BASE is defined as plain 0, the cast (PCI_IO_ADDR) converts it to void * before the addition with port happens.
Instead the addition can be done first, and then the cast. The resulting value will be the same, but avoids the warning, and also avoids void pointer arithmetic which is apparently non-standard.
--- arch/powerpc/include/asm/io.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/io.h +12 -12
@@ -541,12 +541,12 @@ __do_out_asm(_rec_outl, "stwbrx")#define __do_inw (port) _rec_inw(port)#define __do_inl (port) _rec_inl(port)#else /* CONFIG_PPC32 */ -#define __do_outb (val, port) writeb(val,(PCI_IO_ADDR)_IO_BASE+port); -#define __do_outw (val, port) writew(val,(PCI_IO_ADDR)_IO_BASE+port); -#define __do_outl (val, port) writel(val,(PCI_IO_ADDR)_IO_BASE+port); -#define __do_inb (port) readb((PCI_IO_ADDR)_IO_BASE + port); -#define __do_inw (port) readw((PCI_IO_ADDR)_IO_BASE + port); -#define __do_inl (port) readl((PCI_IO_ADDR)_IO_BASE + port); +#define __do_outb (val, port) writeb(val,(PCI_IO_ADDR)(_IO_BASE+port)); +#define __do_outw (val, port) writew(val,(PCI_IO_ADDR)(_IO_BASE+port)); +#define __do_outl (val, port) writel(val,(PCI_IO_ADDR)(_IO_BASE+port)); +#define __do_inb (port) readb((PCI_IO_ADDR)(_IO_BASE + port)); +#define __do_inw (port) readw((PCI_IO_ADDR)(_IO_BASE + port)); +#define __do_inl (port) readl((PCI_IO_ADDR)(_IO_BASE + port));#endif /* !CONFIG_PPC32 */ #ifdef CONFIG_EEH
@@ -562,12 +562,12 @@ __do_out_asm(_rec_outl, "stwbrx")#define __do_writesw (a, b, n) _outsw(PCI_FIX_ADDR(a),(b),(n))#define __do_writesl (a, b, n) _outsl(PCI_FIX_ADDR(a),(b),(n)) -#define __do_insb (p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) -#define __do_insw (p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) -#define __do_insl (p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) -#define __do_outsb (p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) -#define __do_outsw (p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) -#define __do_outsl (p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) +#define __do_insb (p, b, n) readsb((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n)) +#define __do_insw (p, b, n) readsw((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n)) +#define __do_insl (p, b, n) readsl((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n)) +#define __do_outsb (p, b, n) writesb((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n)) +#define __do_outsw (p, b, n) writesw((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n)) +#define __do_outsl (p, b, n) writesl((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))#define __do_memset_io (addr, c, n) \ _memset_io(PCI_FIX_ADDR(addr), c, n)
Signature · 1 line
2.43.0
Hi!
Quoted 8 lines
[WHY]
PSP can access DCN registers during command submission and we need to ensure that DCN is not in PG before doing so.[HOW]
Add a callback to DM to lock and notify DC for idle optimization exit. It can't be DC directly because of a potential race condition with the link protection thread and the rest of DM operation.
Why is this picked for 5.10-stable?
It adds an callback, but noone is going to use it in 5.10.
Best regards,
Pavel
Quoted 23 lines
+++
b/drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.hdrivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h +8
-0@@ -143,6 +143,13 @@ struct mod_hdcp_ddc { } funcs; }; +struct mod_hdcp_dm { +void *handle; +struct { +void (*exit_idle_optimizations)(void *handle); + } funcs; +}; +struct mod_hdcp_psp {void *handle;void *funcs;@@ -252,6 +259,7 @@ struct mod_hdcp_display_query {struct mod_hdcp_config {struct mod_hdcp_psp psp;struct mod_hdcp_ddc ddc; +struct mod_hdcp_dm dm;uint8_t index; };
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany