[Intel-xe] [PATCH 1/3] drm/xe/kunit: Move fake pci data to test-priv

Lucas De Marchi lucas.demarchi at intel.com
Sat Nov 18 04:26:26 UTC 2023


On Fri, Nov 17, 2023 at 04:15:07PM -0800, Matt Roper wrote:
>On Fri, Nov 17, 2023 at 03:14:09PM -0800, Lucas De Marchi wrote:
>> Instead of passing as parameter to xe_pci_fake_device_init(), use
>> test->priv to pass parameters down the call stack. The main advantage is
>> that then the data is readily available on other functions by using
>> kunit_get_current_test().
>>
>> This is a preparation to fix the initialization of fake devices when
>> they were supposed to be using GMD_ID.
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
>> ---
>>  drivers/gpu/drm/xe/tests/xe_pci.c      | 16 +++++++++-------
>>  drivers/gpu/drm/xe/tests/xe_pci_test.h | 17 +++++------------
>>  drivers/gpu/drm/xe/tests/xe_rtp_test.c |  4 +++-
>>  drivers/gpu/drm/xe/tests/xe_wa_test.c  |  7 ++++++-
>>  4 files changed, 23 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c
>> index a40879da2fbe..d1bc029f7a13 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_pci.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_pci.c
>> @@ -7,6 +7,7 @@
>>
>>  #include "tests/xe_test.h"
>>
>> +#include <kunit/test-bug.h>
>>  #include <kunit/test.h>
>>  #include <kunit/visibility.h>
>>
>> @@ -106,14 +107,15 @@ void xe_call_for_each_media_ip(xe_media_fn xe_fn)
>>  }
>>  EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_media_ip);
>>
>> -int xe_pci_fake_device_init(struct xe_device *xe, enum xe_platform platform,
>> -			    enum xe_subplatform subplatform)
>> +int xe_pci_fake_device_init(struct xe_device *xe)
>>  {
>> +	struct kunit *test = kunit_get_current_test();
>> +	struct xe_pci_fake_data *data = test->priv;
>>  	const struct pci_device_id *ent = pciidlist;
>>  	const struct xe_device_desc *desc;
>>  	const struct xe_subplatform_desc *subplatform_desc;
>>
>> -	if (platform == XE_TEST_PLATFORM_ANY) {
>> +	if (!data) {
>>  		desc = (const void *)ent->driver_data;
>>  		subplatform_desc = NULL;
>>  		goto done;
>> @@ -121,14 +123,14 @@ int xe_pci_fake_device_init(struct xe_device *xe, enum xe_platform platform,
>>
>>  	for (ent = pciidlist; ent->device; ent++) {
>>  		desc = (const void *)ent->driver_data;
>> -		if (desc->platform == platform)
>> +		if (desc->platform == data->platform)
>>  			break;
>>  	}
>>
>>  	if (!ent->device)
>>  		return -ENODEV;
>>
>> -	if (subplatform == XE_TEST_SUBPLATFORM_ANY) {
>> +	if (data->subplatform == XE_SUBPLATFORM_UNINITIALIZED) {
>
>Is this case possible with any of our current tests?  It doesn't look
>like it is.

humn.... I'll dig the git history later to nd out why I added it as I
don't remember.

>
>Reviewed-by: Matt Roper <matthew.d.roper at intel.com>

thanks
Lucas De Marchi


More information about the Intel-xe mailing list