drm/amd/display: Exit idle optimizations before HDCP execution
Subsystems (7)
Sasha Levin
maintainerPATCH 1/16 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
@@ -88,6 +88,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)
@@ -543,6 +551,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
@@ -156,6 +156,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;
@@ -272,6 +279,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/16 ima: Fix use-after-free on a dentry's dname.name
From: Stefan Berger <[email protected]>
[ Upstream commit be84f32bb2c981ca670922e047cdde1488b233de ]
->d_name.name can change on rename and the earlier value can be freed; there are conditions sufficient to stabilize it (->d_lock on dentry, ->d_lock on its parent, ->i_rwsem exclusive on the parent's inode, rename_lock), but none of those are met at any of the sites. Take a stable snapshot of the name instead.
--- security/integrity/ima/ima_api.c | 16 ++++++++++++---- security/integrity/ima/ima_template_lib.c | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-)
security/integrity/ima/ima_api.c +12 -4
@@ -244,8 +244,8 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,const char *audit_cause ="failed" ;struct inode *inode =file_inode (file);struct inode *real_inode =d_real_inode (file_dentry (file)); -const char *filename = file->f_path.dentry->d_name.name;struct ima_max_digest_data hash; +struct name_snapshot filename;struct kstat stat;int result =0 ;int length;
@@ -316,9 +316,13 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,if (file->f_flags &O_DIRECT ) audit_cause ="failed(directio)" ; +take_dentry_name_snapshot (&filename, file->f_path.dentry); +integrity_audit_msg (AUDIT_INTEGRITY_DATA , inode, - filename,"collect_data" , audit_cause, - result,0 ); + filename.name.name,"collect_data" , + audit_cause, result,0 ); + +release_dentry_name_snapshot (&filename); }return result; }
@@ -431,6 +435,7 @@ void ima_audit_measurement(struct integrity_iint_cache *iint,*/ const char *ima_d_path (const struct path *path,char **pathbuf,char *namebuf) { +struct name_snapshot filename;char *pathname =NULL ; *pathbuf =__getname ();
@@ -444,7 +449,10 @@ const char *ima_d_path(const struct path *path, char **pathbuf, char *namebuf) }if (!pathname) { -strscpy (namebuf, path->dentry->d_name.name,NAME_MAX ); +take_dentry_name_snapshot (&filename, path->dentry); +strscpy (namebuf, filename.name.name,NAME_MAX ); +release_dentry_name_snapshot (&filename); + pathname = namebuf; }
security/integrity/ima/ima_template_lib.c +14 -3
@@ -483,7 +483,10 @@ static int ima_eventname_init_common(struct ima_event_data *event_data, bool size_limit) {const char *cur_filename =NULL ; +struct name_snapshot filename;u32 cur_filename_len =0 ; +bool snapshot = false; +int ret;BUG_ON (event_data->filename ==NULL && event_data->file ==NULL );
@@ -496,7 +499,10 @@ static int ima_eventname_init_common(struct ima_event_data *event_data, }if (event_data->file) { - cur_filename = event_data->file->f_path.dentry->d_name.name; +take_dentry_name_snapshot (&filename, + event_data->file->f_path.dentry); + snapshot = true; + cur_filename = filename.name.name; cur_filename_len =strlen (cur_filename); }else /*
@@ -505,8 +511,13 @@ static int ima_eventname_init_common(struct ima_event_data *event_data,*/ cur_filename_len =IMA_EVENT_NAME_LEN_MAX ; out: -return ima_write_template_field_data (cur_filename, cur_filename_len, -DATA_FMT_STRING , field_data); + ret =ima_write_template_field_data (cur_filename, cur_filename_len, +DATA_FMT_STRING , field_data); + +if (snapshot) +release_dentry_name_snapshot (&filename); + +return ret; }/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/16 platform/x86: toshiba_acpi: Add quirk for buttons on Z830
In reply to Sasha LevinFrom: Arvid Norlander <[email protected]>
[ Upstream commit 23f1d8b47d125dcd8c1ec62a91164e6bc5d691d0 ]
The Z830 has some buttons that will only work properly as "quickstart" buttons. To enable them in that mode, a value between 1 and 7 must be used for HCI_HOTKEY_EVENT. Windows uses 0x5 on this laptop so use that for maximum predictability and compatibility.
As there is not yet a known way of auto detection, this patch uses a DMI quirk table. A module parameter is exposed to allow setting this on other models for testing.
--- drivers/platform/x86/toshiba_acpi.c | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-)
drivers/platform/x86/toshiba_acpi.c +33 -3
@@ -57,6 +57,11 @@ module_param(turn_on_panel_on_resume, int, 0644);MODULE_PARM_DESC (turn_on_panel_on_resume,"Call HCI_PANEL_POWER_ON on resume (-1 = auto, 0 = no, 1 = yes" ); +static int hci_hotkey_quickstart =-1 ; +module_param (hci_hotkey_quickstart, int,0644 ); +MODULE_PARM_DESC (hci_hotkey_quickstart, +"Call HCI_HOTKEY_EVENT with value 0x5 for quickstart button support (-1 = auto, 0 = no, 1 = yes" ); +#define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"/* Scan code for Fn key on TOS1900 models */
@@ -136,6 +141,7 @@ MODULE_PARM_DESC(turn_on_panel_on_resume,#define HCI_ACCEL_MASK 0x7fff#define HCI_ACCEL_DIRECTION_MASK 0x8000#define HCI_HOTKEY_DISABLE 0x0b +#define HCI_HOTKEY_ENABLE_QUICKSTART 0x05#define HCI_HOTKEY_ENABLE 0x09#define HCI_HOTKEY_SPECIAL_FUNCTIONS 0x10#define HCI_LCD_BRIGHTNESS_BITS 3
@@ -2730,10 +2736,15 @@ static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev)return -ENODEV ;/* +* Enable quickstart buttons if supported. +* * Enable the "Special Functions" mode only if they are * supported and if they are activated. */ -if (dev->kbd_function_keys_supported && dev->special_functions) +if (hci_hotkey_quickstart) + result =hci_write (dev,HCI_HOTKEY_EVENT , +HCI_HOTKEY_ENABLE_QUICKSTART ); +else if (dev->kbd_function_keys_supported && dev->special_functions) result =hci_write (dev,HCI_HOTKEY_EVENT ,HCI_HOTKEY_SPECIAL_FUNCTIONS );else
@@ -3257,7 +3268,14 @@ static const char *find_hci_method(acpi_handle handle)* works. toshiba_acpi_resume() uses HCI_PANEL_POWER_ON to avoid changing * the configured brightness level. */ -static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = { +#define QUIRK_TURN_ON_PANEL_ON_RESUME BIT(0) +/* +* Some Toshibas use "quickstart" keys. On these, HCI_HOTKEY_EVENT must use +* the value HCI_HOTKEY_ENABLE_QUICKSTART. +*/ +#define QUIRK_HCI_HOTKEY_QUICKSTART BIT(1) + +static const struct dmi_system_id toshiba_dmi_quirks[] = { {/* Toshiba Portégé R700 */ /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
@@ -3265,6 +3283,7 @@ static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = {DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"), }, + .driver_data = (void *)QUIRK_TURN_ON_PANEL_ON_RESUME, }, {/* Toshiba Satellite/Portégé R830 */
@@ -3274,6 +3293,7 @@ static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = {DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), DMI_MATCH(DMI_PRODUCT_NAME, "R830"), }, + .driver_data = (void *)QUIRK_TURN_ON_PANEL_ON_RESUME, }, {/* Toshiba Satellite/Portégé Z830 */
@@ -3281,6 +3301,7 @@ static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), DMI_MATCH(DMI_PRODUCT_NAME, "Z830"), }, + .driver_data = (void *)(QUIRK_TURN_ON_PANEL_ON_RESUME | QUIRK_HCI_HOTKEY_QUICKSTART), }, };
@@ -3289,6 +3310,8 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)struct toshiba_acpi_dev *dev;const char *hci_method;u32 dummy; +const struct dmi_system_id *dmi_id; +long quirks =0 ;int ret =0 ;if (toshiba_acpi)
@@ -3441,8 +3464,15 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) }#endif + dmi_id =dmi_first_match (toshiba_dmi_quirks); +if (dmi_id) + quirks = (long )dmi_id->driver_data; +if (turn_on_panel_on_resume ==-1 ) - turn_on_panel_on_resume =dmi_check_system (turn_on_panel_on_resume_dmi_ids); + turn_on_panel_on_resume = !!(quirks &QUIRK_TURN_ON_PANEL_ON_RESUME ); + +if (hci_hotkey_quickstart ==-1 ) + hci_hotkey_quickstart = !!(quirks &QUIRK_HCI_HOTKEY_QUICKSTART );toshiba_wwan_available (dev);if (dev->wwan_supported)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/16 ASoC: Intel: sof_sdw: add JD2 quirk for HP Omen 14
In reply to Sasha LevinFrom: 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
@@ -502,6 +502,15 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { SOF_BT_OFFLOAD_SSP(1) | SOF_SSP_BT_OFFLOAD_PRESENT), }, + { + .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 5/16 ASoC: Intel: sof_sdw: add quirk for Dell SKU 0C0F
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit b10cb955c6c0b8dbd9a768166d71cc12680b7fdf ]
The JD1 jack detection doesn't seem to work, use JD2. Also use the 4 speaker configuration.
--- sound/soc/intel/boards/sof_sdw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/soc/intel/boards/sof_sdw.c +10 -0
@@ -436,6 +436,16 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {RT711_JD2 | SOF_SDW_FOUR_SPK), }, + { + .callback = sof_sdw_quirk_cb, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc" ), +DMI_EXACT_MATCH (DMI_PRODUCT_SKU ,"0C0F" ) + }, + .driver_data = (void *)(SOF_SDW_TGL_HDMI | +RT711_JD2 | + SOF_SDW_FOUR_SPK), + }, { .callback = sof_sdw_quirk_cb, .matches = {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/16 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
@@ -80,6 +80,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 7/16 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
@@ -402,6 +402,13 @@ static enum drm_gpu_sched_stat lima_sched_timedout_job(struct drm_sched_job *jobstruct 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 8/16 platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 Pro 1380F/L data
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 3eee73ad42c3899d97e073bf2c41e7670a3c575c ]
The Lenovo Yoga Tablet 2 Pro 1380F/L is a x86 ACPI tablet which ships with Android x86 as factory OS. Its DSDT contains a bunch of I2C devices which are not actually there, causing various resource conflicts. Enumeration of these is skipped through the acpi_quirk_skip_i2c_client_enumeration().
Add support for manually instantiating the I2C + other devices which are actually present on this tablet by adding the necessary device info to the x86-android-tablets module.
--- .../platform/x86/x86-android-tablets/dmi.c | 18 ++ .../platform/x86/x86-android-tablets/lenovo.c | 216 ++++++++++++++++++ .../x86-android-tablets/x86-android-tablets.h | 1 + 3 files changed, 235 insertions(+)
drivers/platform/x86/x86-android-tablets/dmi.c +18 -0
@@ -104,6 +104,24 @@ const struct dmi_system_id x86_android_tablet_ids[] __initconst = { }, .driver_data = (void *)&lenovo_yogabook_x91_info, }, + { +/* +* Lenovo Yoga Tablet 2 Pro 1380F/L (13") This has more or less +* the same BIOS as the 830F/L or 1050F/L (8" and 10") below, +* but unlike the 8" / 10" models which share the same mainboard +* this model has a different mainboard. +* This match for the 13" model MUST come before the 8" + 10" +* match since that one will also match the 13" model! +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corp." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"VALLEYVIEW C0 PLATFORM" ), +DMI_MATCH (DMI_BOARD_NAME ,"BYT-T FFD8" ), +/* Full match so as to NOT match the 830/1050 BIOS */ + DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21.X64.0005.R00.1504101516"), + }, + .driver_data = (void *)&lenovo_yoga_tab2_1380_info, + }, {/* * Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10"
drivers/platform/x86/x86-android-tablets/lenovo.c +216 -0
228 lines not on this page · raw message
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +1 -0
@@ -99,6 +99,7 @@ extern const struct x86_dev_info czc_p10t;extern const struct x86_dev_info lenovo_yogabook_x90_info;extern const struct x86_dev_info lenovo_yogabook_x91_info;extern const struct x86_dev_info lenovo_yoga_tab2_830_1050_info; +extern const struct x86_dev_info lenovo_yoga_tab2_1380_info;extern const struct x86_dev_info lenovo_yt3_info;extern const struct x86_dev_info medion_lifetab_s10346_info;extern const struct x86_dev_info nextbook_ares8_info;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/16 ALSA: hda/realtek: Add quirks for Lenovo 13X
In reply to Sasha LevinFrom: Stefan Binding <[email protected]>
[ Upstream commit 25f46354dca912c84f1f79468fd636a94b8d287a ]
Add laptop using CS35L41 HDA.
This laptop does not have _DSD, so require entries in property configuration table for cs35l41_hda driver.
Message-ID: <[email protected]>
--- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_realtek.c +2 -0
@@ -10254,6 +10254,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3852 ,"Lenovo Yoga 7 14ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3855 ,"Legion 7 16ITHG6" ,ALC287_FIXUP_LEGION_16ITHG6 ), +SND_PCI_QUIRK (0x17aa ,0x3865 ,"Lenovo 13X" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x17aa ,0x3866 ,"Lenovo 13X" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x3869 ,"Lenovo Yoga7 14IAL7" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ),SND_PCI_QUIRK (0x17aa ,0x387d ,"Yoga S780-16 pro Quad AAC" ,ALC287_FIXUP_TAS2781_I2C ), SND_PCI_QUIRK(0x17aa, 0x387e, "Yoga S780-16 pro Quad YC", ALC287_FIXUP_TAS2781_I2C),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/16 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
@@ -2176,6 +2176,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 11/16 powerpc: make fadump resilient with memory add/remove events
In reply to Sasha LevinFrom: Sourabh Jain <[email protected]>
[ Upstream commit c6c5b14dac0d1bd0da8b4d1d3b77f18eb9085fcb ]
Due to changes in memory resources caused by either memory hotplug or online/offline events, the elfcorehdr, which describes the CPUs and memory of the crashed kernel to the kernel that collects the dump (known as second/fadump kernel), becomes outdated. Consequently, attempting dump collection with an outdated elfcorehdr can lead to failed or inaccurate dump collection.
Memory hotplug or online/offline events is referred as memory add/remove events in reset of the commit message.
The current solution to address the aforementioned issue is as follows:
Monitor memory add/remove events in userspace using udev rules, and re-register fadump whenever there are changes in memory resources. This leads to the creation of a new elfcorehdr with updated system memory information.
There are several notable issues associated with re-registering fadump for every memory add/remove events.
1. Bulk memory add/remove events with udev-based fadump re-registration can lead to race conditions and, more importantly, it creates a wide window during which fadump is inactive until all memory add/remove events are settled.
2. Re-registering fadump for every memory add/remove event is inefficient.
3. The memory for elfcorehdr is allocated based on the memblock regions available during early boot and remains fixed thereafter. However, if elfcorehdr is later recreated with additional memblock regions, its size will increase, potentially leading to memory corruption.
Address the aforementioned challenges by shifting the creation of elfcorehdr from the first kernel (also referred as the crashed kernel), where it was created and frequently recreated for every memory add/remove event, to the fadump kernel. As a result, the elfcorehdr only needs to be created once, thus eliminating the necessity to re-register fadump during memory add/remove events.
At present, the first kernel prepares fadump header and stores it in the fadump reserved area. The fadump header includes the start address of the elfcorehdr, crashing CPU details, and other relevant information. In the event of a crash in the first kernel, the second/fadump boots and accesses the fadump header prepared by the first kernel. It then performs the following steps in a platform-specific function [rtas|opal]_fadump_process:
1. Sanity check for fadump header
2. Update CPU notes in elfcorehdr
Along with the above, update the setup_fadump()/fadump.c to create elfcorehdr and set its address to the global variable elfcorehdr_addr for the vmcore module to process it in the second/fadump kernel.
Section below outlines the information required to create the elfcorehdr and the changes made to make it available to the fadump kernel if it's not already.
To create elfcorehdr, the following crashed kernel information is
required: CPU notes, vmcoreinfo, and memory ranges.
At present, the CPU notes are already prepared in the fadump kernel, so no changes are needed in that regard. The fadump kernel has access to all crashed kernel memory regions, including boot memory regions that are relocated by firmware to fadump reserved areas, so no changes for that either. However, it is necessary to add new members to the fadump header, i.e., the 'fadump_crash_info_header' structure, in order to pass the crashed kernel's vmcoreinfo address and its size to fadump kernel.
In addition to the vmcoreinfo address and size, there are a few other attributes also added to the fadump_crash_info_header structure.
1. version:
It stores the fadump header version, which is currently set to 1. This provides flexibility to update the fadump crash info header in the future without changing the magic number. For each change in the fadump header, the version will be increased. This will help the updated kernel determine how to handle kernel dumps from older kernels. The magic number remains relevant for checking fadump header corruption.
2. pt_regs_sz/cpu_mask_sz:
Store size of pt_regs and cpu_mask structure of first kernel. These attributes are used to prevent dump processing if the sizes of pt_regs or cpu_mask structure differ between the first and fadump kernels.
Note: if either first/crashed kernel or second/fadump kernel do not have the changes introduced here then kernel fail to collect the dump and prints relevant error message on the console.
--- arch/powerpc/include/asm/fadump-internal.h | 31 +- arch/powerpc/kernel/fadump.c | 361 +++++++++++-------- arch/powerpc/platforms/powernv/opal-fadump.c | 22 +- arch/powerpc/platforms/pseries/rtas-fadump.c | 34 +- 4 files changed, 242 insertions(+), 206 deletions(-)
arch/powerpc/include/asm/fadump-internal.h +29 -2
@@ -42,13 +42,38 @@ static inline u64 fadump_str_to_u64(const char *str)#define FADUMP_CPU_UNKNOWN (~((u32)0)) -#define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPINF") +/* +* The introduction of new fields in the fadump crash info header has +* led to a change in the magic key from `FADMPINF` to `FADMPSIG` for +* identifying a kernel crash from an old kernel. +* +* To prevent the need for further changes to the magic number in the +* event of future modifications to the fadump crash info header, a +* version field has been introduced to track the fadump crash info +* header version. +* +* Consider a few points before adding new members to the fadump crash info +* header structure: +* +* - Append new members; avoid adding them in between. +* - Non-primitive members should have a size member as well. +* - For every change in the fadump header, increment the +* fadump header version. This helps the updated kernel decide how to +* handle kernel dumps from older kernels. +*/ +#define FADUMP_CRASH_INFO_MAGIC_OLD fadump_str_to_u64("FADMPINF") +#define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPSIG") +#define FADUMP_HEADER_VERSION 1/* fadump crash info structure */ struct fadump_crash_info_header {u64 magic_number; -u64 elfcorehdr_addr; +u32 version;u32 crashing_cpu; +u64 vmcoreinfo_raddr; +u64 vmcoreinfo_size; +u32 pt_regs_sz; +u32 cpu_mask_sz;struct pt_regs regs;struct cpumask cpu_mask; };
@@ -94,6 +119,8 @@ struct fw_dump {u64 boot_mem_regs_cnt;unsigned long fadumphdr_addr; +u64 elfcorehdr_addr; +u64 elfcorehdr_size;unsigned long cpu_notes_buf_vaddr;unsigned long cpu_notes_buf_size;
arch/powerpc/kernel/fadump.c +205 -156
481 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-fadump.c +3 -19
@@ -513,8 +513,8 @@ opal_fadump_build_cpu_notes(struct fw_dump *fadump_conf,final_note (note_buf);pr_debug ("Updating elfcore header (%llx) with cpu notes\n" , - fdh->elfcorehdr_addr); -fadump_update_elfcore_header (__va (fdh->elfcorehdr_addr)); + fadump_conf->elfcorehdr_addr); +fadump_update_elfcore_header ((char *)fadump_conf->elfcorehdr_addr);return 0 ; }
@@ -526,12 +526,7 @@ static int __init opal_fadump_process(struct fw_dump *fadump_conf)if (!opal_fdm_active || !fadump_conf->fadumphdr_addr)return rc; -/* Validate the fadump crash info header */ fdh =__va (fadump_conf->fadumphdr_addr); -if (fdh->magic_number !=FADUMP_CRASH_INFO_MAGIC ) { -pr_err ("Crash info header is not valid.\n" ); -return rc; - }#ifdef CONFIG_OPAL_CORE /*
@@ -545,18 +540,7 @@ static int __init opal_fadump_process(struct fw_dump *fadump_conf) kernel_initiated = true;#endif - rc =opal_fadump_build_cpu_notes (fadump_conf, fdh); -if (rc) -return rc; - -/* -* We are done validating dump info and elfcore header is now ready -* to be exported. set elfcorehdr_addr so that vmcore module will -* export the elfcore header through '/proc/vmcore'. -*/ - elfcorehdr_addr = fdh->elfcorehdr_addr; - -return rc; +return opal_fadump_build_cpu_notes (fadump_conf, fdh); } static void opal_fadump_region_show(struct fw_dump *fadump_conf,
arch/powerpc/platforms/pseries/rtas-fadump.c +5 -29
@@ -375,11 +375,8 @@ static int __init rtas_fadump_build_cpu_notes(struct fw_dump *fadump_conf) }final_note (note_buf); -if (fdh) { -pr_debug ("Updating elfcore header (%llx) with cpu notes\n" , - fdh->elfcorehdr_addr); -fadump_update_elfcore_header (__va (fdh->elfcorehdr_addr)); - } +pr_debug ("Updating elfcore header (%llx) with cpu notes\n" , fadump_conf->elfcorehdr_addr); +fadump_update_elfcore_header ((char *)fadump_conf->elfcorehdr_addr);return 0 ; error_out:
@@ -389,14 +386,11 @@ static int __init rtas_fadump_build_cpu_notes(struct fw_dump *fadump_conf) }/* -* Validate and process the dump data stored by firmware before exporting -* it through '/proc/vmcore'. +* Validate and process the dump data stored by the firmware, and update +* the CPU notes of elfcorehdr. */ static int __init rtas_fadump_process (struct fw_dump *fadump_conf) { -struct fadump_crash_info_header *fdh; -int rc =0 ; -if (!fdm_active || !fadump_conf->fadumphdr_addr)return -EINVAL ;
@@ -415,25 +409,7 @@ static int __init rtas_fadump_process(struct fw_dump *fadump_conf)return -EINVAL ; } -/* Validate the fadump crash info header */ - fdh =__va (fadump_conf->fadumphdr_addr); -if (fdh->magic_number !=FADUMP_CRASH_INFO_MAGIC ) { -pr_err ("Crash info header is not valid.\n" ); -return -EINVAL ; - } - - rc =rtas_fadump_build_cpu_notes (fadump_conf); -if (rc) -return rc; - -/* -* We are done validating dump info and elfcore header is now ready -* to be exported. set elfcorehdr_addr so that vmcore module will -* export the elfcore header through '/proc/vmcore'. -*/ - elfcorehdr_addr = fdh->elfcorehdr_addr; - -return 0 ; +return rtas_fadump_build_cpu_notes (fadump_conf); } static void rtas_fadump_region_show(struct fw_dump *fadump_conf,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/16 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
@@ -494,7 +494,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
@@ -508,7 +508,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
@@ -519,8 +519,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 ], ...);/* pseries hcall tracing */ extern struct static_key hcall_tracepoint_key;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/16 media: intel/ipu6: Fix build with !ACPI
In reply to Sasha LevinFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 8810e055b57543f3465cf3c15ba4980f9f14a84e ]
Modify the code so it can be compiled tested in configurations that do not have ACPI enabled.
It fixes the following errors:drivers/media/pci/intel/ipu-bridge.c:103:30: error: implicit declaration of function ‘acpi_device_handle’; did you mean ‘acpi_fwnode_handle’? [-Werror=implicit-function-declaration] drivers/media/pci/intel/ipu-bridge.c:103:30: warning: initialization of ‘acpi_handle’ {aka ‘void *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion] drivers/media/pci/intel/ipu-bridge.c:110:17: error: implicit declaration of function ‘for_each_acpi_dev_match’ [-Werror=implicit-function-declaration] drivers/media/pci/intel/ipu-bridge.c:110:74: error: expected ‘;’ before ‘for_each_acpi_consumer_dev’drivers/media/pci/intel/ipu-bridge.c:104:29: warning: unused variable ‘consumer’ [-Wunused-variable]drivers/media/pci/intel/ipu-bridge.c:103:21: warning: unused variable ‘handle’ [-Wunused-variable]drivers/media/pci/intel/ipu-bridge.c:166:38: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:185:43: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:191:30: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:196:30: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:202:30: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:223:31: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:236:18: error: implicit declaration of function ‘acpi_get_physical_device_location’ [-Werror=implicit-function-declaration] drivers/media/pci/intel/ipu-bridge.c:236:56: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:238:31: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:256:31: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:275:31: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:280:30: error: invalid use of undefined type ‘struct acpi_device’drivers/media/pci/intel/ipu-bridge.c:469:26: error: implicit declaration of function ‘acpi_device_hid’; did you mean ‘dmi_device_id’? [-Werror=implicit-function-declaration] drivers/media/pci/intel/ipu-bridge.c:468:74: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=] drivers/media/pci/intel/ipu-bridge.c:637:58: error: expected ‘;’ before ‘{’ tokendrivers/media/pci/intel/ipu-bridge.c:696:1: warning: label ‘err_put_adev’ defined but not used [-Wunused-label] drivers/media/pci/intel/ipu-bridge.c:693:1: warning: label ‘err_put_ivsc’ defined but not used [-Wunused-label] drivers/media/pci/intel/ipu-bridge.c:691:1: warning: label ‘err_free_swnodes’ defined but not used [-Wunused-label] drivers/media/pci/intel/ipu-bridge.c:632:40: warning: unused variable ‘primary’ [-Wunused-variable]drivers/media/pci/intel/ipu-bridge.c:632:31: warning: unused variable ‘fwnode’ [-Wunused-variable]drivers/media/pci/intel/ipu-bridge.c:733:73: error: expected ‘;’ before ‘{’ tokendrivers/media/pci/intel/ipu-bridge.c:725:24: warning: unused variable ‘csi_dev’ [-Wunused-variable]drivers/media/pci/intel/ipu-bridge.c:724:43: warning: unused variable ‘adev’ [-Wunused-variable]drivers/media/pci/intel/ipu-bridge.c:599:12: warning: ‘ipu_bridge_instantiate_ivsc’ defined but not used [-Wunused-function] drivers/media/pci/intel/ipu-bridge.c:444:13: warning: ‘ipu_bridge_create_connection_swnodes’ defined but not used [-Wunused-function] drivers/media/pci/intel/ipu-bridge.c:297:13: warning: ‘ipu_bridge_create_fwnode_properties’ defined but not used [-Wunused-function] drivers/media/pci/intel/ipu-bridge.c:155:12: warning: ‘ipu_bridge_check_ivsc_dev’ defined but not used [-Wunused-function]
--- drivers/media/pci/intel/ipu-bridge.c | 66 ++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 19 deletions(-)
drivers/media/pci/intel/ipu-bridge.c +47 -19
@@ -14,6 +14,8 @@#include <media/ipu-bridge.h> #include <media/v4l2-fwnode.h> +#define ADEV_DEV (adev) ACPI_PTR(&((adev)->dev)) +/* * 92335fcf-3203-4472-af93-7b4453ac29da *
@@ -84,6 +86,7 @@ static const char * const ipu_vcm_types[] = { "lc898212axb", }; +#if IS_ENABLED (CONFIG_ACPI )/* * Used to figure out IVSC acpi device by ipu_bridge_get_ivsc_acpi_dev() * instead of device and driver match to probe IVSC device.
@@ -97,13 +100,13 @@ static const struct acpi_device_id ivsc_acpi_ids[] = {static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev (struct acpi_device *adev) { -acpi_handle handle =acpi_device_handle (adev); -struct acpi_device *consumer, *ivsc_adev;unsigned int i;for (i =0 ; i <ARRAY_SIZE (ivsc_acpi_ids); i++) {const struct acpi_device_id *acpi_id = &ivsc_acpi_ids[i]; +struct acpi_device *consumer, *ivsc_adev; +acpi_handle handle =acpi_device_handle (adev);for_each_acpi_dev_match (ivsc_adev, acpi_id->id,NULL ,-1 )/* camera sensor depends on IVSC in DSDT if exist */ for_each_acpi_consumer_dev (ivsc_adev, consumer)
@@ -115,6 +118,12 @@ static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev return NULL; } +#else +static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev (struct acpi_device *adev) +{ +return NULL ; +} +#endif static int ipu_bridge_match_ivsc_dev (struct device *dev,const void *adev) {
@@ -160,7 +169,7 @@ static int ipu_bridge_check_ivsc_dev(struct ipu_sensor *sensor, csi_dev =ipu_bridge_get_ivsc_csi_dev (adev);if (!csi_dev) {acpi_dev_put (adev); -dev_err (&adev->dev,"Failed to find MEI CSI dev\n" ); +dev_err (ADEV_DEV (adev),"Failed to find MEI CSI dev\n" );return -ENODEV ; }
@@ -179,24 +188,25 @@ static int ipu_bridge_read_acpi_buffer(struct acpi_device *adev, char *id,acpi_status status;int ret =0 ; - status =acpi_evaluate_object (adev->handle, id,NULL , &buffer); + status =acpi_evaluate_object (ACPI_PTR (adev->handle), + id,NULL , &buffer);if (ACPI_FAILURE (status))return -ENODEV ; obj = buffer.pointer;if (!obj) { -dev_err (&adev->dev,"Couldn't locate ACPI buffer\n" ); +dev_err (ADEV_DEV (adev),"Couldn't locate ACPI buffer\n" );return -ENODEV ; }if (obj->type !=ACPI_TYPE_BUFFER ) { -dev_err (&adev->dev,"Not an ACPI buffer\n" ); +dev_err (ADEV_DEV (adev),"Not an ACPI buffer\n" ); ret = -ENODEV ; goto out_free_buff; }if (obj->buffer.length > size) { -dev_err (&adev->dev,"Given buffer is too small\n" ); +dev_err (ADEV_DEV (adev),"Given buffer is too small\n" ); ret = -EINVAL ; goto out_free_buff; }
@@ -217,7 +227,7 @@ static u32 ipu_bridge_parse_rotation(struct acpi_device *adev,case IPU_SENSOR_ROTATION_INVERTED :return 180 ;default : -dev_warn (&adev->dev, +dev_warn (ADEV_DEV (adev),"Unknown rotation %d. Assume 0 degree rotation\n" , ssdb->degree);return 0 ;
@@ -227,12 +237,14 @@ static u32 ipu_bridge_parse_rotation(struct acpi_device *adev,static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation (struct acpi_device *adev) {enum v4l2_fwnode_orientation orientation; -struct acpi_pld_info *pld; -acpi_status status; +struct acpi_pld_info *pld =NULL ; +acpi_status status =AE_ERROR ; +#if IS_ENABLED (CONFIG_ACPI ) status =acpi_get_physical_device_location (adev->handle, &pld); +#endif if (ACPI_FAILURE (status)) { -dev_warn (&adev->dev,"_PLD call failed, using default orientation\n" ); +dev_warn (ADEV_DEV (adev),"_PLD call failed, using default orientation\n" );return V4L2_FWNODE_ORIENTATION_EXTERNAL ; }
@@ -250,7 +262,8 @@ static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_dev orientation =V4L2_FWNODE_ORIENTATION_EXTERNAL ;break ;default : -dev_warn (&adev->dev,"Unknown _PLD panel val %d\n" , pld->panel); +dev_warn (ADEV_DEV (adev),"Unknown _PLD panel val %d\n" , + pld->panel); orientation =V4L2_FWNODE_ORIENTATION_EXTERNAL ;break ; }
@@ -269,12 +282,12 @@ int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor)return ret;if (ssdb.vcmtype >ARRAY_SIZE (ipu_vcm_types)) { -dev_warn (&adev->dev,"Unknown VCM type %d\n" , ssdb.vcmtype); +dev_warn (ADEV_DEV (adev),"Unknown VCM type %d\n" , ssdb.vcmtype); ssdb.vcmtype =0 ; }if (ssdb.lanes >IPU_MAX_LANES ) { -dev_err (&adev->dev,"Number of lanes in SSDB is invalid\n" ); +dev_err (ADEV_DEV (adev),"Number of lanes in SSDB is invalid\n" );return -EINVAL ; }
@@ -462,8 +475,14 @@ static void ipu_bridge_create_connection_swnodes(struct ipu_bridge *bridge, sensor->ipu_properties);if (sensor->csi_dev) { +const char *device_hid ="" ; + +#if IS_ENABLED (CONFIG_ACPI ) + device_hid =acpi_device_hid (sensor->ivsc_adev); +#endif +snprintf (sensor->ivsc_name,sizeof (sensor->ivsc_name),"%s-%u" , -acpi_device_hid (sensor->ivsc_adev), sensor->link); + device_hid, sensor->link); nodes[SWNODE_IVSC_HID ] =NODE_SENSOR (sensor->ivsc_name, sensor->ivsc_properties);
@@ -628,11 +647,15 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, {struct fwnode_handle *fwnode, *primary;struct ipu_sensor *sensor; -struct acpi_device *adev; +struct acpi_device *adev =NULL ;int ret; +#if IS_ENABLED (CONFIG_ACPI )for_each_acpi_dev_match (adev, cfg->hid,NULL ,-1 ) { -if (!adev->status.enabled) +#else +while (true) { +#endif +if (!ACPI_PTR (adev->status.enabled))continue ;if (bridge->n_sensors >=IPU_MAX_PORTS ) {
@@ -668,7 +691,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, goto err_free_swnodes; } - sensor->adev =acpi_dev_get (adev); + sensor->adev =ACPI_PTR (acpi_dev_get (adev)); primary =acpi_fwnode_handle (adev); primary->secondary = fwnode;
@@ -724,11 +747,16 @@ static int ipu_bridge_ivsc_is_ready(void)unsigned int i;for (i =0 ; i <ARRAY_SIZE (ipu_supported_sensors); i++) { +#if IS_ENABLED (CONFIG_ACPI )const struct ipu_sensor_config *cfg = &ipu_supported_sensors[i];for_each_acpi_dev_match (sensor_adev, cfg->hid,NULL ,-1 ) { -if (!sensor_adev->status.enabled) +#else +while (true) { + sensor_adev =NULL ; +#endif +if (!ACPI_PTR (sensor_adev->status.enabled))continue ; adev =ipu_bridge_get_ivsc_acpi_dev (sensor_adev);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/16 media: mtk-vcodec: potential null pointer deference in SCP
In reply to Sasha LevinFrom: Fullway Wang <[email protected]>
[ Upstream commit 53dbe08504442dc7ba4865c09b3bbf5fe849681b ]
The return value of devm_kzalloc() needs to be checked to avoid NULL pointer deference. This is similar to CVE-2022-3113.
--- .../media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c +2 -0
@@ -79,6 +79,8 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use } fw =devm_kzalloc (&plat_dev->dev,sizeof (*fw),GFP_KERNEL ); +if (!fw) +return ERR_PTR (-ENOMEM ); fw->type =SCP ; fw->ops = &mtk_vcodec_rproc_msg; fw->scp = scp;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/16 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
@@ -585,12 +585,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
@@ -606,12 +606,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
Sasha Levin
maintainerPATCH 16/16 platform/x86: p2sb: Don't init until unassigned resources have been assigned
In reply to Sasha LevinFrom: Ben Fradella <[email protected]>
[ Upstream commit 2c6370e6607663fc5fa0fd9ed58e2e01014898c7 ]
The P2SB could get an invalid BAR from the BIOS, and that won't be fixed up until pcibios_assign_resources(), which is an fs_initcall().
- Move p2sb_fs_init() to an fs_initcall_sync(). This is still early enough to avoid a race with any dependent drivers.
- Add a check for IORESOURCE_UNSET in p2sb_valid_resource() to catch unset BARs going forward.
- Return error values from p2sb_fs_init() so that the 'initcall_debug' cmdline arg provides useful data.
--- drivers/platform/x86/p2sb.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/platform/x86/p2sb.c +15 -14
@@ -56,12 +56,9 @@ static int p2sb_get_devfn(unsigned int *devfn)return 0 ; } -static bool p2sb_valid_resource (struct resource *res) +static bool p2sb_valid_resource (const struct resource *res) { -if (res->flags) -return true; - -return false; +return res->flags & ~IORESOURCE_UNSET ; }/* Copy resource from the first BAR of the device in question */
@@ -220,16 +217,20 @@ EXPORT_SYMBOL_GPL(p2sb_bar);static int __init p2sb_fs_init (void ) { -p2sb_cache_resources (); -return 0 ; +return p2sb_cache_resources (); }/* -* pci_rescan_remove_lock to avoid access to unhidden P2SB devices can -* not be locked in sysfs pci bus rescan path because of deadlock. To -* avoid the deadlock, access to P2SB devices with the lock at an early -* step in kernel initialization and cache required resources. This -* should happen after subsys_initcall which initializes PCI subsystem -* and before device_initcall which requires P2SB resources. +* pci_rescan_remove_lock() can not be locked in sysfs PCI bus rescan path +* because of deadlock. To avoid the deadlock, access P2SB devices with the lock +* at an early step in kernel initialization and cache required resources. +* +* We want to run as early as possible. If the P2SB was assigned a bad BAR, +* we'll need to wait on pcibios_assign_resources() to fix it. So, our list of +* initcall dependencies looks something like this: +* +* ... +* subsys_initcall (pci_subsys_init) +* fs_initcall (pcibios_assign_resources) */ -fs_initcall (p2sb_fs_init); +fs_initcall_sync (p2sb_fs_init);
Signature · 1 line
2.43.0