RE: [PATCH] drm/amd/powerplay: Fix hardmins not being sent to SMU for RV
[AMD Official Use Only - Internal Distribution Only] Reviewed-by: Evan Quan -Original Message- From: amd-gfx On Behalf Of Nicholas Kazlauskas Sent: Friday, August 21, 2020 11:32 PM To: amd-gfx@lists.freedesktop.org Cc: Wu, Hersen ; Kazlauskas, Nicholas Subject: [PATCH] drm/amd/powerplay: Fix hardmins not being sent to SMU for RV [Why] DC uses these to raise the voltage as needed for higher dispclk/dppclk and to ensure that we have enough bandwidth to drive the displays. There's a bug preventing these from actuially sending messages since it's checking the actual clock (which is 0) instead of the incoming clock (which shouldn't be 0) when deciding to send the hardmin. [How] Check the clocks != 0 instead of the actual clocks. Fixes: 9ed9203c3ee7 ("drm/amd/powerplay: rv dal-pplib interface refactor powerplay part") Cc: Hersen Wu Signed-off-by: Nicholas Kazlauskas --- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c index c9cfe90a2947..9ee8cf8267c8 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c @@ -204,8 +204,7 @@ static int smu10_set_min_deep_sleep_dcefclk(struct pp_hwmgr *hwmgr, uint32_t clo { struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend); -if (smu10_data->need_min_deep_sleep_dcefclk && -smu10_data->deep_sleep_dcefclk != clock) { +if (clock && smu10_data->deep_sleep_dcefclk != clock) { smu10_data->deep_sleep_dcefclk = clock; smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetMinDeepSleepDcefclk, @@ -219,8 +218,7 @@ static int smu10_set_hard_min_dcefclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t c { struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend); -if (smu10_data->dcf_actual_hard_min_freq && -smu10_data->dcf_actual_hard_min_freq != clock) { +if (clock && smu10_data->dcf_actual_hard_min_freq != clock) { smu10_data->dcf_actual_hard_min_freq = clock; smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetHardMinDcefclkByFreq, @@ -234,8 +232,7 @@ static int smu10_set_hard_min_fclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t cloc { struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend); -if (smu10_data->f_actual_hard_min_freq && -smu10_data->f_actual_hard_min_freq != clock) { +if (clock && smu10_data->f_actual_hard_min_freq != clock) { smu10_data->f_actual_hard_min_freq = clock; smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetHardMinFclkByFreq, -- 2.25.1 ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfxdata=02%7C01%7Cevan.quan%40amd.com%7Cfb748092bae64ab5310b08d845e757fe%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637336207270141080sdata=Fx4uvt6aq66As36HOBIIkGzMmIOS%2B2JbEpQzSGC6RfE%3Dreserved=0 ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH -next] amdgpu: fix Documentation builds for pm/ file movement
[AMD Official Use Only - Internal Distribution Only] Thanks for fixing this. The patch is reviewed-by: Evan Quan BR Evan -Original Message- From: Randy Dunlap Sent: Monday, August 24, 2020 6:36 AM To: dri-devel ; LKML ; amd-gfx@lists.freedesktop.org; Deucher, Alexander Cc: Quan, Evan ; Stephen Rothwell Subject: [PATCH -next] amdgpu: fix Documentation builds for pm/ file movement From: Randy Dunlap Fix Documentation errors for amdgpu.rst due to file rename (moved to another subdirectory). Error: Cannot open file ../drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c WARNING: kernel-doc '../scripts/kernel-doc -rst -enable-lineno -function hwmon ../drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c' failed with return code 1 Fixes: e098bc9612c2 ("drm/amd/pm: optimize the power related source code layout") Signed-off-by: Randy Dunlap Cc: Evan Quan Cc: Alex Deucher --- Documentation/gpu/amdgpu.rst | 24 1 file changed, 12 insertions(+), 12 deletions(-) --- linux-next-20200821.orig/Documentation/gpu/amdgpu.rst +++ linux-next-20200821/Documentation/gpu/amdgpu.rst @@ -153,7 +153,7 @@ This section covers hwmon and power/ther HWMON Interfaces -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: hwmon GPU sysfs Power State Interfaces @@ -164,52 +164,52 @@ GPU power controls are exposed via sysfs power_dpm_state ~~~ -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: power_dpm_state power_dpm_force_performance_level ~ -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: power_dpm_force_performance_level pp_table -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: pp_table pp_od_clk_voltage ~ -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: pp_od_clk_voltage pp_dpm_* -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: pp_dpm_sclk pp_dpm_mclk pp_dpm_socclk pp_dpm_fclk pp_dpm_dcefclk pp_dpm_pcie pp_power_profile_mode ~ -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: pp_power_profile_mode *_busy_percent ~~ -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: gpu_busy_percent -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: mem_busy_percent gpu_metrics ~ -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: gpu_metrics GPU Product Information @@ -239,7 +239,7 @@ serial_number unique_id - -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: unique_id GPU Memory Usage Information @@ -289,7 +289,7 @@ PCIe Accounting Information pcie_bw --- -.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: pcie_bw pcie_replay_count ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v6] drm/amdkfd: implement the dGPU fallback path for apu (v6)
Am 2020-08-23 um 8:07 a.m. schrieb Huang Rui: > We still have a few iommu issues which need to address, so force raven > as "dgpu" path for the moment. > > This is to add the fallback path to bypass IOMMU if IOMMU v2 is disabled > or ACPI CRAT table not correct. > > v2: Use ignore_crat parameter to decide whether it will go with IOMMUv2. > v3: Align with existed thunk, don't change the way of raven, only renoir > will use "dgpu" path by default. > v4: don't update global ignore_crat in the driver, and revise fallback > function if CRAT is broken. > v5: refine acpi crat good but no iommu support case, and rename the > title. > v6: fix the issue of dGPU initialized firstly, just modify the report > value in the node_show(). > > Signed-off-by: Huang Rui Reviewed-by: Felix Kuehling > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++- > drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- > drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 22 +++-- > drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 4 +-- > drivers/gpu/drm/amd/amdkfd/kfd_device.c | 5 ++- > .../amd/amdkfd/kfd_device_queue_manager_v9.c | 2 +- > drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 4 +-- > drivers/gpu/drm/amd/amdkfd/kfd_iommu.c| 10 +++--- > drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 ++- > drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 31 --- > 10 files changed, 70 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > index a9a4319c24ae..189f9d7e190d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > @@ -684,11 +684,14 @@ MODULE_PARM_DESC(debug_largebar, > * Ignore CRAT table during KFD initialization. By default, KFD uses the > ACPI CRAT > * table to get information about AMD APUs. This option can serve as a > workaround on > * systems with a broken CRAT table. > + * > + * Default is auto (according to asic type, iommu_v2, and crat table, to > decide > + * whehter use CRAT) > */ > int ignore_crat; > module_param(ignore_crat, int, 0444); > MODULE_PARM_DESC(ignore_crat, > - "Ignore CRAT table during KFD initialization (0 = use CRAT (default), 1 > = ignore CRAT)"); > + "Ignore CRAT table during KFD initialization (0 = auto (default), 1 = > ignore CRAT)"); > > /** > * DOC: halt_if_hws_hang (int) > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c > b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c > index 1b60e0ed6b5c..3ec5322ba88d 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c > @@ -1258,7 +1258,7 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev) > return true; > } > > - if (dev->device_info->needs_iommu_device) > + if (dev->use_iommu_v2) > return false; > > amdgpu_amdkfd_get_local_mem_info(dev->kgd, _info); > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c > b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c > index 59557e3e206a..aba40df189d9 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c > @@ -740,6 +740,25 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev, > return 0; > } > > + > +#ifdef CONFIG_ACPI > + > +static bool kfd_ignore_crat(void) > +{ > + bool ret; > + > + if (ignore_crat) > + return true; > + > +#ifndef KFD_SUPPORT_IOMMU_V2 > + ret = true; > +#else > + ret = false; > +#endif > + > + return ret; > +} > + > /* > * kfd_create_crat_image_acpi - Allocates memory for CRAT image and > * copies CRAT from ACPI (if available). > @@ -751,7 +770,6 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev, > * > * Return 0 if successful else return error code > */ > -#ifdef CONFIG_ACPI > int kfd_create_crat_image_acpi(void **crat_image, size_t *size) > { > struct acpi_table_header *crat_table; > @@ -775,7 +793,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t > *size) > return -EINVAL; > } > > - if (ignore_crat) { > + if (kfd_ignore_crat()) { > pr_info("CRAT table disabled by module option\n"); > return -ENODATA; > } > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c > b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c > index 3e5904f8876a..e4159b5f83d5 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c > @@ -309,7 +309,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev > *dbgdev, > for (i = 0; i < adw_info->num_watch_points; i++) { > dbgdev_address_watch_set_registers(adw_info, , , > , i, pdd->qpd.vmid, > - dbgdev->dev->device_info->needs_iommu_device); > + dbgdev->dev->use_iommu_v2); > > pr_debug("\t\t%30s\n",
[PATCH v6] drm/amdkfd: implement the dGPU fallback path for apu (v6)
We still have a few iommu issues which need to address, so force raven as "dgpu" path for the moment. This is to add the fallback path to bypass IOMMU if IOMMU v2 is disabled or ACPI CRAT table not correct. v2: Use ignore_crat parameter to decide whether it will go with IOMMUv2. v3: Align with existed thunk, don't change the way of raven, only renoir will use "dgpu" path by default. v4: don't update global ignore_crat in the driver, and revise fallback function if CRAT is broken. v5: refine acpi crat good but no iommu support case, and rename the title. v6: fix the issue of dGPU initialized firstly, just modify the report value in the node_show(). Signed-off-by: Huang Rui --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 22 +++-- drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 4 +-- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 5 ++- .../amd/amdkfd/kfd_device_queue_manager_v9.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 4 +-- drivers/gpu/drm/amd/amdkfd/kfd_iommu.c| 10 +++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 ++- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 31 --- 10 files changed, 70 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index a9a4319c24ae..189f9d7e190d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -684,11 +684,14 @@ MODULE_PARM_DESC(debug_largebar, * Ignore CRAT table during KFD initialization. By default, KFD uses the ACPI CRAT * table to get information about AMD APUs. This option can serve as a workaround on * systems with a broken CRAT table. + * + * Default is auto (according to asic type, iommu_v2, and crat table, to decide + * whehter use CRAT) */ int ignore_crat; module_param(ignore_crat, int, 0444); MODULE_PARM_DESC(ignore_crat, - "Ignore CRAT table during KFD initialization (0 = use CRAT (default), 1 = ignore CRAT)"); + "Ignore CRAT table during KFD initialization (0 = auto (default), 1 = ignore CRAT)"); /** * DOC: halt_if_hws_hang (int) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 1b60e0ed6b5c..3ec5322ba88d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1258,7 +1258,7 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev) return true; } - if (dev->device_info->needs_iommu_device) + if (dev->use_iommu_v2) return false; amdgpu_amdkfd_get_local_mem_info(dev->kgd, _info); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index 59557e3e206a..aba40df189d9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -740,6 +740,25 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev, return 0; } + +#ifdef CONFIG_ACPI + +static bool kfd_ignore_crat(void) +{ + bool ret; + + if (ignore_crat) + return true; + +#ifndef KFD_SUPPORT_IOMMU_V2 + ret = true; +#else + ret = false; +#endif + + return ret; +} + /* * kfd_create_crat_image_acpi - Allocates memory for CRAT image and * copies CRAT from ACPI (if available). @@ -751,7 +770,6 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev, * * Return 0 if successful else return error code */ -#ifdef CONFIG_ACPI int kfd_create_crat_image_acpi(void **crat_image, size_t *size) { struct acpi_table_header *crat_table; @@ -775,7 +793,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size) return -EINVAL; } - if (ignore_crat) { + if (kfd_ignore_crat()) { pr_info("CRAT table disabled by module option\n"); return -ENODATA; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c index 3e5904f8876a..e4159b5f83d5 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c @@ -309,7 +309,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev, for (i = 0; i < adw_info->num_watch_points; i++) { dbgdev_address_watch_set_registers(adw_info, , , , i, pdd->qpd.vmid, - dbgdev->dev->device_info->needs_iommu_device); + dbgdev->dev->use_iommu_v2); pr_debug("\t\t%30s\n", "* * * * * * * * * * * * * * * * * *"); pr_debug("\t\t%20s %08x\n", "register index :", i); @@ -399,7 +399,7 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev, for (i = 0; i < adw_info->num_watch_points; i++) {
[PATCH v2 20/24] drm/radeon: Backlight update
- Use macros for initialization - Replace direct access to backlight_properties with get and set operations Signed-off-by: Sam Ravnborg Cc: Alex Deucher Cc: Christian König Cc: amd-gfx@lists.freedesktop.org --- drivers/gpu/drm/radeon/atombios_encoders.c| 24 +-- .../gpu/drm/radeon/radeon_legacy_encoders.c | 16 + 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c index cc5ee1b3af84..300bec94dbff 100644 --- a/drivers/gpu/drm/radeon/atombios_encoders.c +++ b/drivers/gpu/drm/radeon/atombios_encoders.c @@ -145,14 +145,15 @@ atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level) static u8 radeon_atom_bl_level(struct backlight_device *bd) { u8 level; + int brightness = backlight_get_brightness(bd); /* Convert brightness to hardware level */ - if (bd->props.brightness < 0) + if (brightness < 0) level = 0; - else if (bd->props.brightness > RADEON_MAX_BL_LEVEL) + else if (brightness > RADEON_MAX_BL_LEVEL) level = RADEON_MAX_BL_LEVEL; else - level = bd->props.brightness; + level = brightness; return level; } @@ -185,12 +186,13 @@ static const struct backlight_ops radeon_atom_backlight_ops = { void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder, struct drm_connector *drm_connector) { + DECLARE_BACKLIGHT_INIT_RAW(props, 0, RADEON_MAX_BL_LEVEL); struct drm_device *dev = radeon_encoder->base.dev; struct radeon_device *rdev = dev->dev_private; struct backlight_device *bd; - struct backlight_properties props; struct radeon_backlight_privdata *pdata; struct radeon_encoder_atom_dig *dig; + int brightness; char bl_name[16]; /* Mac laptops with multiple GPUs use the gmux driver for backlight @@ -215,9 +217,6 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder, goto error; } - memset(, 0, sizeof(props)); - props.max_brightness = RADEON_MAX_BL_LEVEL; - props.type = BACKLIGHT_RAW; snprintf(bl_name, sizeof(bl_name), "radeon_bl%d", dev->primary->index); bd = backlight_device_register(bl_name, drm_connector->kdev, @@ -232,16 +231,17 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder, dig = radeon_encoder->enc_priv; dig->bl_dev = bd; - bd->props.brightness = radeon_atom_backlight_get_brightness(bd); + brightness = radeon_atom_backlight_get_brightness(bd); /* Set a reasonable default here if the level is 0 otherwise * fbdev will attempt to turn the backlight on after console * unblanking and it will try and restore 0 which turns the backlight * off again. */ - if (bd->props.brightness == 0) - bd->props.brightness = RADEON_MAX_BL_LEVEL; - bd->props.power = FB_BLANK_UNBLANK; - backlight_update_status(bd); + + if (brightness == 0) + brightness = RADEON_MAX_BL_LEVEL; + + backlight_enable_brightness(bd, brightness); DRM_INFO("radeon atom DIG backlight initialized\n"); rdev->mode_info.bl_encoder = radeon_encoder; diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c index 44d060f75318..55e656acaedb 100644 --- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c +++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c @@ -323,14 +323,15 @@ static uint8_t radeon_legacy_lvds_level(struct backlight_device *bd) { struct radeon_backlight_privdata *pdata = bl_get_data(bd); uint8_t level; + int brightness = backlight_get_brightness(bd); /* Convert brightness to hardware level */ - if (bd->props.brightness < 0) + if (brightness < 0) level = 0; - else if (bd->props.brightness > RADEON_MAX_BL_LEVEL) + else if (brightness > RADEON_MAX_BL_LEVEL) level = RADEON_MAX_BL_LEVEL; else - level = bd->props.brightness; + level = brightness; if (pdata->negative) level = RADEON_MAX_BL_LEVEL - level; @@ -371,10 +372,10 @@ static const struct backlight_ops radeon_backlight_ops = { void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, struct drm_connector *drm_connector) { + DECLARE_BACKLIGHT_INIT_RAW(props, 0, RADEON_MAX_BL_LEVEL); struct drm_device *dev = radeon_encoder->base.dev; struct radeon_device *rdev = dev->dev_private; struct backlight_device *bd; - struct backlight_properties props; struct radeon_backlight_privdata *pdata; uint8_t backlight_level; char
[PATCH v2 0/24] backlight: add init macros and accessors
The first patch trims backlight_update_status() so it can be called with a NULL backlight_device. Then the caller do not need to add this check just to avoid a NULL reference. The backlight drivers uses several different patterns when registering a backlight: - Register backlight and assign properties later - Define a local backlight_properties variable and use memset - Define a const backlight_properties and assign relevant properties On top of this there was differences in what members was assigned. To align how backlight drivers are initialized introduce following helper macros: - DECLARE_BACKLIGHT_INIT_FIRMWARE() - DECLARE_BACKLIGHT_INIT_PLATFORM() - DECLARE_BACKLIGHT_INIT_RAW() The macros are introduced in patch 2. The backlight drivers used direct access to backlight_properties. Encapsulate these in get/set access operations resulting in following benefits: - The access methods can be called with a NULL pointer so logic around the access can be made simpler. - The update_brightness and enable_brightness simplifies the users - The code is in most cases more readable with the access operations. - When everyone uses the access methods refactoring in the backlight core is simpler. The get/set operations are introduced in patch 3. The gpio backlight driver received a small overhaul in a set of three patches. The result is a smaller and more readable driver. The remaining patches updates all backlight users in drivers/gpu/drm/* With this patch set all of drivers/gpu/drm/: - All backlight references to FB_BLANK* are gone from drm/* - All direct references to backlight properties are gone - All panel drivers uses the devm_ variant for registering backlight Daniel Vetter had some concerns with this for future updates, but we are aligned now and can update if refoctoring demands it - All panel drivers uses the backlight support in drm_panel Individual patches are only sent to the people listed in the patch + a few more. Please check https://lore.kernel.org/dri-devel/ for the full series. v2: - Documented BACKLIGHT_PROPS as it may be used by drivers - Dropped backlight_set_power_{on,off}, they were a mistake (Daniel) - Added backlight_update_brightness() and use it (Daniel) - Added backlight_enable_brightness() and use it - Moved remaining drm_panel driver to use backlight support in drm_panel - gpio backlight driver overhaul The patches are made on top of the for-backlight-next branch at https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git The branch needs v5.8-rc1 backported to build as dev_err_probe() is used. The first 6 patches are candidates for the backlight tree. If they are applied then this should preferably be to an immutable branch we can merge to drm-misc-next where the drm patches shall go. The drm patches has known conflics and shall *not* be applied to the backlight tree, they are included in this patchset to show how the new functions are used. Diffstat for the drm bits alone looks nice: 25 files changed, 243 insertions(+), 460 deletions(-) Feedback welcome! Sam Cc: Alex Deucher Cc: amd-gfx@lists.freedesktop.org Cc: Andrzej Hajda Cc: Christian König Cc: Chris Wilson Cc: Daniel Thompson Cc: Ezequiel Garcia Cc: Hans de Goede Cc: Hoegeun Kwon Cc: Inki Dae Cc: Jani Nikula Cc: Jernej Skrabec Cc: Jingoo Han Cc: Jonas Karlman Cc: Joonas Lahtinen Cc: Jyri Sarha Cc: Kieran Bingham Cc: Konrad Dybcio Cc: Laurent Pinchart Cc: Lee Jones Cc: Linus Walleij Cc: linux-renesas-...@vger.kernel.org Cc: Maarten Lankhorst Cc: Manasi Navare Cc: Neil Armstrong Cc: Patrik Jakobsson Cc: Paweł Chmiel Cc: Philippe CORNU Cc: Rob Clark Cc: Robert Chiras Cc: Rodrigo Vivi Cc: Sam Ravnborg Cc: Sebastian Reichel Cc: Thierry Reding Cc: Tomi Valkeinen Cc: "Ville Syrjälä" Cc: Vinay Simha BN Cc: Wambui Karuga Cc: Zheng Bin Sam Ravnborg (24): backlight: Silently fail backlight_update_status() if no device backlight: Add DECLARE_* macro for device registration backlight: Add get/set operations for brightness properties backlight: gpio: Introduce backlight_{enable,disable} backlight: gpio: Use dev_err_probe() backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW drm/gma500: Backlight update drm/panel: asus-z00t-tm5p5-n35596: Backlight update drm/panel: jdi-lt070me05000: Backlight update drm/panel: novatek-nt35510: Backlight update drm/panel: orisetech-otm8009a: Backlight update drm/panel: raydium-rm67191: Backlight update drm/panel: samsung-s6e63m0: Backlight update drm/panel: samsung-s6e63j0x03: Backlight update drm/panel: samsung-s6e3ha2: Backlight update drm/panel: sony-acx424akp: Backlight update drm/panel: sony-acx565akm: Backlight update drm/bridge: parade-ps8622: Backlight update drm/tilcdc: Backlight update drm/radeon: Backlight update drm/amdgpu/atom: Backlight update drm/i915: Backlight update
[PATCH v2 21/24] drm/amdgpu/atom: Backlight update
- Use macros for initialization - Replace direct access to backlight_properties with get and set operations Signed-off-by: Sam Ravnborg Cc: Alex Deucher Cc: Christian König Cc: amd-gfx@lists.freedesktop.org Cc: Sam Ravnborg --- .../gpu/drm/amd/amdgpu/atombios_encoders.c| 19 ++- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c index 1e94a9b652f7..882e1a3dad8b 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c @@ -122,15 +122,16 @@ amdgpu_atombios_encoder_set_backlight_level(struct amdgpu_encoder *amdgpu_encode static u8 amdgpu_atombios_encoder_backlight_level(struct backlight_device *bd) { + int brightness = backlight_get_brightness(bd); u8 level; /* Convert brightness to hardware level */ - if (bd->props.brightness < 0) + if (brightness < 0) level = 0; - else if (bd->props.brightness > AMDGPU_MAX_BL_LEVEL) + else if (brightness > AMDGPU_MAX_BL_LEVEL) level = AMDGPU_MAX_BL_LEVEL; else - level = bd->props.brightness; + level = brightness; return level; } @@ -165,13 +166,12 @@ static const struct backlight_ops amdgpu_atombios_encoder_backlight_ops = { void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encoder, struct drm_connector *drm_connector) { + DECLARE_BACKLIGHT_INIT_RAW(props, 0, AMDGPU_MAX_BL_LEVEL); struct drm_device *dev = amdgpu_encoder->base.dev; struct amdgpu_device *adev = dev->dev_private; struct backlight_device *bd; - struct backlight_properties props; struct amdgpu_backlight_privdata *pdata; struct amdgpu_encoder_atom_dig *dig; - u8 backlight_level; char bl_name[16]; /* Mac laptops with multiple GPUs use the gmux driver for backlight @@ -193,9 +193,6 @@ void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encode goto error; } - memset(, 0, sizeof(props)); - props.max_brightness = AMDGPU_MAX_BL_LEVEL; - props.type = BACKLIGHT_RAW; snprintf(bl_name, sizeof(bl_name), "amdgpu_bl%d", dev->primary->index); bd = backlight_device_register(bl_name, drm_connector->kdev, @@ -207,14 +204,10 @@ void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encode pdata->encoder = amdgpu_encoder; - backlight_level = amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); - dig = amdgpu_encoder->enc_priv; dig->bl_dev = bd; - bd->props.brightness = amdgpu_atombios_encoder_get_backlight_brightness(bd); - bd->props.power = FB_BLANK_UNBLANK; - backlight_update_status(bd); + backlight_enable_brightness(bd, amdgpu_atombios_encoder_get_backlight_brightness(bd)); DRM_INFO("amdgpu atom DIG backlight initialized\n"); -- 2.25.1 ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx