tests/amdgpu: Fix device_id option
PATCH 1/1 tests/amdgpu: Fix device_id option
The device_id option [-d] was badly broken. This commit fixes the width (was 8 is now 16 bits) as well as enables searches without specifying a bus id. It was also comparing "dev" from the bus field which is not the PCI device id.
--- tests/amdgpu/amdgpu_test.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tests/amdgpu/amdgpu_test.c +9 -9
@@ -264,25 +264,25 @@ static void amdgpu_print_devices()/* Find a match AMD device in PCI bus * Return the index of the device or -1 if not found */ -static int amdgpu_find_device (uint8_t bus,uint8_t dev) +static int amdgpu_find_device (uint8_t bus,uint16_t dev) {int i;drmDevicePtr device; -for (i =0 ; i <MAX_CARDS_SUPPORTED && drm_amdgpu[i] >=0 ; i++) +for (i =0 ; i <MAX_CARDS_SUPPORTED && drm_amdgpu[i] >=0 ; i++) {if (drmGetDevice2 (drm_amdgpu[i],DRM_DEVICE_GET_PCI_REVISION , &device) ==0 ) {if (device->bustype ==DRM_BUS_PCI ) -if (device->businfo.pci->bus == bus && - device->businfo.pci->dev == dev) { - +if ((bus ==0xFF || device->businfo.pci->bus == bus) && + device->deviceinfo.pci->device_id == dev) {drmFreeDevice (&device);return i; }drmFreeDevice (&device); } + }return -1 ; }
@@ -325,7 +325,7 @@ int main(int argc, char **argv) pci_bus_id =atoi (optarg);break ;case 'd' : - pci_device_id =atoi (optarg); +sscanf (optarg,"%x" , &pci_device_id);break ;case 'p' : display_devices =1 ;
@@ -359,10 +359,10 @@ int main(int argc, char **argv)exit (EXIT_SUCCESS ); } -if (pci_bus_id >0 ) { +if (pci_bus_id >0 || pci_device_id) {/* A device was specified to run the test */ - test_device_index =amdgpu_find_device ((uint8_t )pci_bus_id, - (uint8_t )pci_device_id); + test_device_index =amdgpu_find_device (pci_bus_id, + pci_device_id);if (test_device_index >=0 ) {/* Most tests run on device of drm_amdgpu[0].
Signature · 6 lines
2.12.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Monday, June 05, 2017 2:04 PM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH drm] tests/amdgpu: Fixdevice_idoption
Quoted 6 lines
The
device_idoption [-d] was badly broken. This commit fixes the width (was 8 is now 16 bits) as well as enables searches without specifying a bus id. It was also comparing "dev" from the bus field which is not the PCI device id.Signed-off-by Tom St Denis <[email protected]>
Quoted 70 lines
--- tests/amdgpu/amdgpu_test.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)tests/amdgpu/amdgpu_test.c +3
-5@@ -264,25 +264,25 @@ static void amdgpu_print_devices()/* Find a match AMD device in PCI bus * Return the index of the device or -1 if not found */ -static int amdgpu_find_device (uint8_t bus,uint8_t dev) +static int amdgpu_find_device (uint8_t bus,uint16_t dev) {int i;drmDevicePtr device; -for (i =0 ; i <MAX_CARDS_SUPPORTED && drm_amdgpu[i] >=0 ; i++) +for (i =0 ; i <MAX_CARDS_SUPPORTED && drm_amdgpu[i] >=0 ; i++) {if (drmGetDevice2 (drm_amdgpu[i],DRM_DEVICE_GET_PCI_REVISION , &device) ==0 ) {if (device->bustype ==DRM_BUS_PCI ) -if (device->businfo.pci->bus == bus && - device->businfo.pci->dev == dev) { - + if ((bus == 0xFF || device->businfo.pci->bus== bus) &&
tests/amdgpu/amdgpu_test.c +1
-0+ device->deviceinfo.pci->device_id ==dev) {
tests/amdgpu/amdgpu_test.c +5
-4drmFreeDevice (&device);return i; }drmFreeDevice (&device); } + }return -1 ; }@@ -325,7 +325,7 @@ int main(int argc, char **argv) pci_bus_id =atoi (optarg);break ;case 'd' : - pci_device_id =atoi (optarg); +sscanf (optarg,"%x" , &pci_device_id);break ;case 'p' : display_devices =1 ;@@ -359,10 +359,10 @@ int main(int argc, char **argv)exit (EXIT_SUCCESS ); } -if (pci_bus_id >0 ) { +if (pci_bus_id >0 || pci_device_id) {/* A device was specified to run the test */ - test_device_index =amdgpu_find_device ((uint8_t )pci_bus_id, - (uint8_t )pci_device_id); + test_device_index =amdgpu_find_device (pci_bus_id, + pci_device_id);tests/amdgpu/amdgpu_test.c +0
-1if (test_device_index >=0 ) {/* Most tests run on device of drm_amdgpu[0]. -- 2.12.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx