mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 02:21:39 -04:00
drm/amd/display: move stutter quirk to quirks file
[WHAT] dm_should_disable_stutter() and its amdgpu_stutter_quirk PCI match table are self-contained quirk logic. Move them out of amdgpu_dm.c into amdgpu_dm_quirks.c alongside the existing DMI quirk handling. The helper is called from amdgpu_dm_init(), so it becomes a plain exported function instead of STATIC_IFN_KUNIT, and its declaration moves from the KUnit-only block to a regular prototype in amdgpu_dm.h. Relocate its KUnit tests from the amdgpu_dm suite to the amdgpu_dm_quirks suite. No functional change. Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Fangzhi Zuo <jerry.zuo@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -410,39 +410,6 @@ static void mmhub_read_system_context(struct amdgpu_device *adev, struct dc_phy_
|
||||
|
||||
}
|
||||
|
||||
struct amdgpu_stutter_quirk {
|
||||
u16 chip_vendor;
|
||||
u16 chip_device;
|
||||
u16 subsys_vendor;
|
||||
u16 subsys_device;
|
||||
u8 revision;
|
||||
};
|
||||
|
||||
static const struct amdgpu_stutter_quirk amdgpu_stutter_quirk_list[] = {
|
||||
/* https://bugzilla.kernel.org/show_bug.cgi?id=214417 */
|
||||
{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
|
||||
{ 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
STATIC_IFN_KUNIT bool dm_should_disable_stutter(struct pci_dev *pdev)
|
||||
{
|
||||
const struct amdgpu_stutter_quirk *p = amdgpu_stutter_quirk_list;
|
||||
|
||||
while (p && p->chip_device != 0) {
|
||||
if (pdev->vendor == p->chip_vendor &&
|
||||
pdev->device == p->chip_device &&
|
||||
pdev->subsystem_vendor == p->subsys_vendor &&
|
||||
pdev->subsystem_device == p->subsys_device &&
|
||||
pdev->revision == p->revision) {
|
||||
return true;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
EXPORT_IF_KUNIT(dm_should_disable_stutter);
|
||||
|
||||
|
||||
void*
|
||||
dm_allocate_gpu_mem(
|
||||
struct amdgpu_device *adev,
|
||||
|
||||
@@ -1134,6 +1134,8 @@ bool amdgpu_dm_is_headless(struct amdgpu_device *adev);
|
||||
bool amdgpu_dm_crtc_complete_writeback(struct amdgpu_crtc *acrtc);
|
||||
|
||||
void retrieve_dmi_info(struct amdgpu_display_manager *dm);
|
||||
struct pci_dev;
|
||||
bool dm_should_disable_stutter(struct pci_dev *pdev);
|
||||
|
||||
void amdgpu_dm_emulated_link_detect(struct dc_link *link);
|
||||
void amdgpu_dm_apply_delay_after_dpcd_poweroff(struct amdgpu_device *adev,
|
||||
@@ -1178,8 +1180,6 @@ bool is_dc_timing_adjust_needed(struct dm_crtc_state *old_state,
|
||||
struct dm_crtc_state *new_state);
|
||||
void set_multisync_trigger_params(struct dc_stream_state *stream);
|
||||
void set_master_stream(struct dc_stream_state *stream_set[], int stream_count);
|
||||
struct pci_dev;
|
||||
bool dm_should_disable_stutter(struct pci_dev *pdev);
|
||||
void reset_freesync_config_for_crtc(struct dm_crtc_state *new_crtc_state);
|
||||
void get_freesync_config_for_crtc(struct dm_crtc_state *new_crtc_state,
|
||||
struct dm_connector_state *new_con_state);
|
||||
|
||||
@@ -178,3 +178,35 @@ void retrieve_dmi_info(struct amdgpu_display_manager *dm)
|
||||
}
|
||||
}
|
||||
EXPORT_IF_KUNIT(retrieve_dmi_info);
|
||||
|
||||
struct amdgpu_stutter_quirk {
|
||||
u16 chip_vendor;
|
||||
u16 chip_device;
|
||||
u16 subsys_vendor;
|
||||
u16 subsys_device;
|
||||
u8 revision;
|
||||
};
|
||||
|
||||
static const struct amdgpu_stutter_quirk amdgpu_stutter_quirk_list[] = {
|
||||
/* https://bugzilla.kernel.org/show_bug.cgi?id=214417 */
|
||||
{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
|
||||
{ 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
bool dm_should_disable_stutter(struct pci_dev *pdev)
|
||||
{
|
||||
const struct amdgpu_stutter_quirk *p = amdgpu_stutter_quirk_list;
|
||||
|
||||
while (p && p->chip_device != 0) {
|
||||
if (pdev->vendor == p->chip_vendor &&
|
||||
pdev->device == p->chip_device &&
|
||||
pdev->subsystem_vendor == p->subsys_vendor &&
|
||||
pdev->subsystem_device == p->subsys_device &&
|
||||
pdev->revision == p->revision) {
|
||||
return true;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
EXPORT_IF_KUNIT(dm_should_disable_stutter);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <kunit/test.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
#include "dc.h"
|
||||
#include "amdgpu_mode.h"
|
||||
@@ -83,11 +84,75 @@ static void dm_test_quirks_no_dmi_match_both_false(struct kunit *test)
|
||||
KUNIT_EXPECT_FALSE(test, dm->edp0_on_dp1_quirk);
|
||||
}
|
||||
|
||||
/* Tests for dm_should_disable_stutter() */
|
||||
|
||||
/**
|
||||
* dm_test_should_disable_stutter_match - Test the quirk device matches
|
||||
* @test: The KUnit test context
|
||||
*/
|
||||
static void dm_test_should_disable_stutter_match(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
|
||||
pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, pdev);
|
||||
|
||||
pdev->vendor = 0x1002;
|
||||
pdev->device = 0x15dd;
|
||||
pdev->subsystem_vendor = 0x1002;
|
||||
pdev->subsystem_device = 0x15dd;
|
||||
pdev->revision = 0xc8;
|
||||
|
||||
KUNIT_EXPECT_TRUE(test, dm_should_disable_stutter(pdev));
|
||||
}
|
||||
|
||||
/**
|
||||
* dm_test_should_disable_stutter_no_match - Test a non-quirk device does not match
|
||||
* @test: The KUnit test context
|
||||
*/
|
||||
static void dm_test_should_disable_stutter_no_match(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
|
||||
pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, pdev);
|
||||
|
||||
pdev->vendor = 0x1002;
|
||||
pdev->device = 0x1234;
|
||||
|
||||
KUNIT_EXPECT_FALSE(test, dm_should_disable_stutter(pdev));
|
||||
}
|
||||
|
||||
/**
|
||||
* dm_test_should_disable_stutter_revision_differs - Test a partial match (revision) fails
|
||||
* @test: The KUnit test context
|
||||
*/
|
||||
static void dm_test_should_disable_stutter_revision_differs(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
|
||||
pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, pdev);
|
||||
|
||||
/* Everything matches the quirk except the revision */
|
||||
pdev->vendor = 0x1002;
|
||||
pdev->device = 0x15dd;
|
||||
pdev->subsystem_vendor = 0x1002;
|
||||
pdev->subsystem_device = 0x15dd;
|
||||
pdev->revision = 0x00;
|
||||
|
||||
KUNIT_EXPECT_FALSE(test, dm_should_disable_stutter(pdev));
|
||||
}
|
||||
|
||||
static struct kunit_case amdgpu_dm_quirks_tests[] = {
|
||||
/* retrieve_dmi_info */
|
||||
KUNIT_CASE(dm_test_quirks_aux_hpd_discon_reset),
|
||||
KUNIT_CASE(dm_test_quirks_edp0_on_dp1_reset),
|
||||
KUNIT_CASE(dm_test_quirks_no_dmi_match_both_false),
|
||||
/* dm_should_disable_stutter */
|
||||
KUNIT_CASE(dm_test_should_disable_stutter_match),
|
||||
KUNIT_CASE(dm_test_should_disable_stutter_no_match),
|
||||
KUNIT_CASE(dm_test_should_disable_stutter_revision_differs),
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -1737,66 +1737,6 @@ static void dm_test_per_frame_master_sync_skips_null_stream(struct kunit *test)
|
||||
stream);
|
||||
}
|
||||
|
||||
/* Tests for dm_should_disable_stutter() */
|
||||
|
||||
/**
|
||||
* dm_test_should_disable_stutter_match - Test the quirk device matches
|
||||
* @test: The KUnit test context
|
||||
*/
|
||||
static void dm_test_should_disable_stutter_match(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
|
||||
pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, pdev);
|
||||
|
||||
pdev->vendor = 0x1002;
|
||||
pdev->device = 0x15dd;
|
||||
pdev->subsystem_vendor = 0x1002;
|
||||
pdev->subsystem_device = 0x15dd;
|
||||
pdev->revision = 0xc8;
|
||||
|
||||
KUNIT_EXPECT_TRUE(test, dm_should_disable_stutter(pdev));
|
||||
}
|
||||
|
||||
/**
|
||||
* dm_test_should_disable_stutter_no_match - Test a non-quirk device does not match
|
||||
* @test: The KUnit test context
|
||||
*/
|
||||
static void dm_test_should_disable_stutter_no_match(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
|
||||
pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, pdev);
|
||||
|
||||
pdev->vendor = 0x1002;
|
||||
pdev->device = 0x1234;
|
||||
|
||||
KUNIT_EXPECT_FALSE(test, dm_should_disable_stutter(pdev));
|
||||
}
|
||||
|
||||
/**
|
||||
* dm_test_should_disable_stutter_revision_differs - Test a partial match (revision) fails
|
||||
* @test: The KUnit test context
|
||||
*/
|
||||
static void dm_test_should_disable_stutter_revision_differs(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
|
||||
pdev = kunit_kzalloc(test, sizeof(*pdev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, pdev);
|
||||
|
||||
/* Everything matches the quirk except the revision */
|
||||
pdev->vendor = 0x1002;
|
||||
pdev->device = 0x15dd;
|
||||
pdev->subsystem_vendor = 0x1002;
|
||||
pdev->subsystem_device = 0x15dd;
|
||||
pdev->revision = 0x00;
|
||||
|
||||
KUNIT_EXPECT_FALSE(test, dm_should_disable_stutter(pdev));
|
||||
}
|
||||
|
||||
/* Tests for amdgpu_dm_apply_delay_after_dpcd_poweroff() */
|
||||
|
||||
/**
|
||||
@@ -1938,10 +1878,6 @@ static struct kunit_case amdgpu_dm_tests[] = {
|
||||
KUNIT_CASE(dm_test_per_frame_master_sync_single_stream),
|
||||
KUNIT_CASE(dm_test_per_frame_master_sync_two_streams),
|
||||
KUNIT_CASE(dm_test_per_frame_master_sync_skips_null_stream),
|
||||
/* dm_should_disable_stutter */
|
||||
KUNIT_CASE(dm_test_should_disable_stutter_match),
|
||||
KUNIT_CASE(dm_test_should_disable_stutter_no_match),
|
||||
KUNIT_CASE(dm_test_should_disable_stutter_revision_differs),
|
||||
/* amdgpu_dm_apply_delay_after_dpcd_poweroff */
|
||||
KUNIT_CASE(dm_test_apply_delay_null_sink),
|
||||
KUNIT_CASE(dm_test_apply_delay_zero_wait),
|
||||
|
||||
Reference in New Issue
Block a user