Skip to contentSkip to conversation

Add ability to import new asic from script file (v2)

PATCH New Tom St Denis 1 participant 1 message Jul 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add ability to import new asic from script file (v2)

This is meant for NPI support only as publicly released designs can simply add to the static definitions.

This is used by using the --force (-f) option with a filename that has a @ prefixed on, e.g.

umr -O bits -f @demo/npi/newchip -lr gfx10

Will read the file 'newchip' and import the ip/reg/bit definitions and then can proceed as normal producing this output:

[WARNING]: Should use --pci when using create_asic_from_script()

        new_chip.gfx10.mmSUPER_SECRET => 0x12345670
                new_chip.gfx10.mmSUPER_SECRET.enable[0:0]

You will need to use --pci to specify a precise device otherwise it won't be able to talk to it.

(v2): Added fakerizo demo and updated PCI detection logic to be more robust

---
 demo/npi/README                   |   2 +
 demo/npi/fakerizo                 |  26 ++++
 demo/npi/new_chip                 |   2 +
 src/app/main.c                    |   1 +
 src/lib/CMakeLists.txt            |   1 +
 src/lib/create_asic_from_script.c | 286 ++++++++++++++++++++++++++++++++++++++
 src/lib/discover.c                |  18 ++-
 src/lib/discover_by_name.c        |   3 +
 src/umr.h                         |   3 +
 9 files changed, 338 insertions(+), 4 deletions(-)
 create mode 100644 demo/npi/README
 create mode 100644 demo/npi/fakerizo
 create mode 100644 demo/npi/new_chip
 create mode 100644 src/lib/create_asic_from_script.c
demo/npi/README new file +2 -0
new file mode 100644
index 000000000000..4ada3e57a0f1
@@ -0,0 +1,2 @@
+Added fakerizo which is a "fake" Carrizo so I could test the new
+PCI detection logic which should be somewhat more future proof.
demo/npi/fakerizo new file +26 -0
new file mode 100644
index 000000000000..8ec3a18f7c57
@@ -0,0 +1,26 @@
+reg gfx80 mmGRBM_STATUS mmio 0x801
+bit gfx80 mmGRBM_STATUS ME0PIPE0_CMDFIFO_AVAIL 0 3 
+bit gfx80 mmGRBM_STATUS SRBM_RQ_PENDING 5 5 
+bit gfx80 mmGRBM_STATUS ME0PIPE0_CF_RQ_PENDING 7 7 
+bit gfx80 mmGRBM_STATUS ME0PIPE0_PF_RQ_PENDING 8 8 
+bit gfx80 mmGRBM_STATUS GDS_DMA_RQ_PENDING 9 9 
+bit gfx80 mmGRBM_STATUS DB_CLEAN 12 12 
+bit gfx80 mmGRBM_STATUS CB_CLEAN 13 13 
+bit gfx80 mmGRBM_STATUS TA_BUSY 14 14 
+bit gfx80 mmGRBM_STATUS GDS_BUSY 15 15 
+bit gfx80 mmGRBM_STATUS WD_BUSY_NO_DMA 16 16 
+bit gfx80 mmGRBM_STATUS VGT_BUSY 17 17 
+bit gfx80 mmGRBM_STATUS IA_BUSY_NO_DMA 18 18 
+bit gfx80 mmGRBM_STATUS IA_BUSY 19 19 
+bit gfx80 mmGRBM_STATUS SX_BUSY 20 20 
+bit gfx80 mmGRBM_STATUS WD_BUSY 21 21 
+bit gfx80 mmGRBM_STATUS SPI_BUSY 22 22 
+bit gfx80 mmGRBM_STATUS BCI_BUSY 23 23 
+bit gfx80 mmGRBM_STATUS SC_BUSY 24 24 
+bit gfx80 mmGRBM_STATUS PA_BUSY 25 25 
+bit gfx80 mmGRBM_STATUS DB_BUSY 26 26 
+bit gfx80 mmGRBM_STATUS CP_COHERENCY_BUSY 28 28 
+bit gfx80 mmGRBM_STATUS CP_BUSY 29 29 
+bit gfx80 mmGRBM_STATUS CB_BUSY 30 30 
+bit gfx80 mmGRBM_STATUS GUI_ACTIVE 31 31 
+
demo/npi/new_chip new file +2 -0
new file mode 100644
index 000000000000..deb4148b12d6
@@ -0,0 +1,2 @@
+reg gfx10 mmSUPER_SECRET mmio 0x12345670
+bit gfx10 mmSUPER_SECRET enable 0 0
src/app/main.c +1 -0
index ac3c25e2937e..4fc26510be32 100644
@@ -178,6 +178,7 @@ int main(int argc, char **argv)
 			if (i + 1 < argc && sscanf(argv[i+1], "%04x:%02x:%02x.%01x",
 				&options.pci.domain, &options.pci.bus, &options.pci.slot,
 				&options.pci.func ) >= 4) {
+				options.use_pci = 1; // implied by the --pci option
 				++i;
 			} else {
 				printf("--pci requires domain:bus:slot.function\n");
src/lib/CMakeLists.txt +1 -0
index dfdf44cf4ad2..217ae80cdfd7 100644
@@ -7,6 +7,7 @@ add_library(umrcore STATIC
   bitfield_print.c
   close_asic.c
   create_asic_helper.c
+  create_asic_from_script.c
   create_mmio_accel.c
   discover_by_did.c
   discover_by_name.c
src/lib/create_asic_from_script.c new file +286 -0

286 lines not on this page · raw message

src/lib/discover.c +14 -4
index 5a7bfa4e6dac..0c4ee1c09ad8 100644
@@ -101,6 +101,7 @@ struct umr_asic *umr_discover_asic(struct umr_options *options)
 	unsigned did;
 	struct umr_asic *asic;
 	long trydid = options->forcedid;
+	int busmatch = 0;
 
 	// Try to map to instance if we have a specific pci device
 	if (options->pci.domain || options->pci.bus ||
@@ -254,8 +255,14 @@ struct umr_asic *umr_discover_asic(struct umr_options *options)
 						options->pci.func != asic->pci.pdevice->func)) {
 						asic->pci.pdevice = pci_device_next(pci_iter);
 					}
+
+					// indicate we found an exact match for the pci bus/slot
+					// this is used because NPI use cases won't have names to
+					// match against in is_did_match()
+					if (asic->pci.pdevice)
+						busmatch = 1;
 				}
-			} while (asic->pci.pdevice && !(asic->pci.pdevice->vendor_id == 0x1002 && is_did_match(asic, asic->pci.pdevice->device_id)));
+			} while (asic->pci.pdevice && !(busmatch || (asic->pci.pdevice->vendor_id == 0x1002 && is_did_match(asic, asic->pci.pdevice->device_id))));
 
 			if (!asic->pci.pdevice) {
 				fprintf(stderr, "[ERROR]: Could not find ASIC with DID of %04lx\n", (unsigned long)asic->did);
@@ -282,11 +289,14 @@ struct umr_asic *umr_discover_asic(struct umr_options *options)
 				}
 			}
 
-			// scan for a 256K/512K region
+			// scan for a region 256K <= X <= 1024K which is 32-bit, non IO, non prefetchable
 			if (use_region == 6) {
 				for (use_region = 0; use_region < 6; use_region++)
-					if ((asic->family < FAMILY_AI && asic->pci.pdevice->regions[use_region].size == (256UL * 1024)) ||
-					    (asic->family >= FAMILY_AI && asic->pci.pdevice->regions[use_region].size == (512UL * 1024)))
+					if (asic->pci.pdevice->regions[use_region].is_64 == 0 &&
+					    asic->pci.pdevice->regions[use_region].is_prefetchable == 0 &&
+					    asic->pci.pdevice->regions[use_region].is_IO == 0 &&
+					    asic->pci.pdevice->regions[use_region].size >= (256UL * 1024) &&
+					    asic->pci.pdevice->regions[use_region].size <= (1024UL * 1024))
 						break;
 			}
 
src/lib/discover_by_name.c +3 -0
index ffeffcc72369..4570929ef759 100644
@@ -55,6 +55,9 @@ struct umr_asic *umr_discover_asic_by_name(struct umr_options *options, char *na
 	unsigned x;
 	struct umr_asic *asic, *tmp;
 
+	if (name[0] == '@')
+		return umr_create_asic_from_script(options, name + 1);
+
 	asic = NULL;
 	for (x = 0; x < (sizeof(devices)/sizeof(devices[0])); x++)
 		if (!strcmp(devices[x].name, name))
src/umr.h +3 -0
index f3d359172d03..265deec7eb68 100644
@@ -55,6 +55,8 @@ enum chipfamily {
 	FAMILY_VI,
 	FAMILY_AI,
 	FAMILY_RV,
+
+	FAMILY_NPI, // reserves for new devices that are not public yet
 };
 
 enum regclass {
@@ -428,6 +430,7 @@ struct umr_ip_block *umr_create_bif51(struct umr_options *options);
 
 /* asic constructors */
 struct umr_asic *umr_create_asic_helper(char *name, int family, ...);
+struct umr_asic *umr_create_asic_from_script(struct umr_options *options, char *name);
 struct umr_asic *umr_create_bonaire(struct umr_options *options);
 struct umr_asic *umr_create_carrizo(struct umr_options *options);
 struct umr_asic *umr_create_fiji(struct umr_options *options);
Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx