Skip to content

Commit 3cd1bb6

Browse files
committed
Handle 32-bit PCI domains
1 parent 6c67a19 commit 3cd1bb6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/driver.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ driver_get_device_1_svc(ptr_t ctxptr, u_int idx, driver_get_device_res *res, may
444444
{
445445
struct driver *ctx = (struct driver *)ctxptr;
446446
int domainid, deviceid, busid;
447-
char buf[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE];
447+
char buf[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE + 1];
448448

449449
memset(res, 0, sizeof(*res));
450450
if (idx >= MAX_DEVICES) {
@@ -459,8 +459,8 @@ driver_get_device_1_svc(ptr_t ctxptr, u_int idx, driver_get_device_res *res, may
459459
goto fail;
460460
if (call_cuda(ctx, cuDeviceGetAttribute, &deviceid, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, device_handles[idx].cuda) < 0)
461461
goto fail;
462-
snprintf(buf, sizeof(buf), "%04x:%02x:%02x.0", domainid, busid, deviceid);
463-
if (call_nvml(ctx, nvmlDeviceGetHandleByPciBusId, buf, &device_handles[idx].nvml) < 0)
462+
snprintf(buf, sizeof(buf), "%08x:%02x:%02x.0", domainid, busid, deviceid);
463+
if (call_nvml(ctx, nvmlDeviceGetHandleByPciBusId_v2, buf, &device_handles[idx].nvml) < 0)
464464
goto fail;
465465

466466
res->driver_get_device_res_u.dev = (ptr_t)&device_handles[idx];
@@ -527,12 +527,16 @@ driver_get_device_busid_1_svc(ptr_t ctxptr, ptr_t dev, driver_get_device_busid_r
527527
{
528528
struct driver *ctx = (struct driver *)ctxptr;
529529
struct driver_device *handle = (struct driver_device *)dev;
530-
nvmlPciInfo_t pci;
530+
int domainid, deviceid, busid;
531531

532532
memset(res, 0, sizeof(*res));
533-
if (call_nvml(ctx, nvmlDeviceGetPciInfo_v2, handle->nvml, &pci) < 0)
533+
if (call_cuda(ctx, cuDeviceGetAttribute, &domainid, CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, handle->cuda) < 0)
534+
goto fail;
535+
if (call_cuda(ctx, cuDeviceGetAttribute, &busid, CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, handle->cuda) < 0)
536+
goto fail;
537+
if (call_cuda(ctx, cuDeviceGetAttribute, &deviceid, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, handle->cuda) < 0)
534538
goto fail;
535-
if ((res->driver_get_device_busid_res_u.busid = xstrdup(ctx->err, pci.busId)) == NULL)
539+
if (xasprintf(ctx->err, &res->driver_get_device_busid_res_u.busid, "%08x:%02x:%02x.0", domainid, busid, deviceid) < 0)
536540
goto fail;
537541
return (true);
538542

src/nvc_mount.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ mount_procfs_gpu(struct error *err, const struct nvc_container *cnt, const char
189189
char *mnt = NULL;
190190
mode_t mode;
191191

192-
if (xasprintf(err, &gpu, "%s/gpus/%s", NV_PROC_DRIVER, busid) < 0)
192+
/* XXX The driver procfs uses 16-bit PCI domain */
193+
if (xasprintf(err, &gpu, "%s/gpus/%s", NV_PROC_DRIVER, busid + 4) < 0)
193194
return (NULL);
194195
if (file_mode(err, gpu, &mode) < 0)
195196
goto fail;

0 commit comments

Comments
 (0)