Skip to content

Commit b0aee16

Browse files
committed
Remove redundant AFU name from error messages
The errmsg function already provides AFU identification, so there is no need to repeat it. Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
1 parent 11d1fdd commit b0aee16

3 files changed

Lines changed: 24 additions & 33 deletions

File tree

src/afu.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,8 @@ static ocxl_err afu_open(ocxl_afu *afu)
426426
ev.data.ptr = &afu->fd_info; // Already set up in afu_init
427427
if (epoll_ctl(afu->epoll_fd, EPOLL_CTL_ADD, afu->fd, &ev) == -1) {
428428
ocxl_err rc = OCXL_NO_DEV;
429-
errmsg(afu, rc, "Could not add device fd %d to epoll fd %d for AFU '%s': %d: '%s'",
430-
afu->fd, afu->epoll_fd, afu->identifier.afu_name,
431-
errno, strerror(errno));
429+
errmsg(afu, rc, "Could not add device fd %d to epoll fd %d: %d: '%s'",
430+
afu->fd, afu->epoll_fd, errno, strerror(errno));
432431
return rc;
433432
}
434433

src/irq.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ void irq_dealloc(ocxl_afu * afu, ocxl_irq * irq)
4444
{
4545
if (irq->addr) {
4646
if (munmap(irq->addr, afu->page_size)) {
47-
errmsg(afu, OCXL_INTERNAL_ERROR, "Could not unmap IRQ page for AFU '%s': %d: '%s'",
48-
afu->identifier.afu_name, errno, strerror(errno));
47+
errmsg(afu, OCXL_INTERNAL_ERROR, "Could not unmap IRQ page: %d: '%s'",
48+
errno, strerror(errno));
4949
}
5050
irq->addr = NULL;
5151
}
@@ -108,8 +108,7 @@ static ocxl_err irq_allocate(ocxl_afu * afu, ocxl_irq * irq, void *info)
108108

109109
int fd = eventfd(0, EFD_CLOEXEC);
110110
if (fd < 0) {
111-
errmsg(afu, ret, "Could not open eventfd for AFU '%s': %d: '%s'",
112-
afu->identifier.afu_name, errno, strerror(errno));
111+
errmsg(afu, ret, "Could not open eventfd : %d: '%s'", errno, strerror(errno));
113112
goto errend;
114113
}
115114
irq->event.eventfd = fd;
@@ -129,17 +128,16 @@ static ocxl_err irq_allocate(ocxl_afu * afu, ocxl_irq * irq, void *info)
129128
irq->addr = mmap(NULL, afu->page_size, PROT_WRITE, MAP_SHARED,
130129
my_afu->fd, irq->event.irq_offset);
131130
if (irq->addr == MAP_FAILED) {
132-
errmsg(afu, ret, "mmap for IRQ for AFU '%s': %d: '%s'", afu->identifier.afu_name, errno, strerror(errno));
131+
errmsg(afu, ret, "mmap for IRQ failed: %d: '%s'", errno, strerror(errno));
133132
goto errend;
134133
}
135134

136135
struct epoll_event ev;
137136
ev.events = EPOLLIN;
138137
ev.data.ptr = &irq->fd_info;
139138
if (epoll_ctl(my_afu->epoll_fd, EPOLL_CTL_ADD, irq->event.eventfd, &ev) == -1) {
140-
errmsg(afu, ret, "Could not add IRQ fd %d to epoll fd %d for AFU '%s': %d: '%s'",
141-
irq->event.eventfd, my_afu->epoll_fd, my_afu->identifier.afu_name,
142-
errno, strerror(errno));
139+
errmsg(afu, ret, "Could not add IRQ fd %d to epoll fd %d: %d: '%s'",
140+
irq->event.eventfd, my_afu->epoll_fd, errno, strerror(errno));
143141
goto errend;
144142
}
145143

@@ -166,14 +164,14 @@ ocxl_err ocxl_irq_alloc(ocxl_afu_h afu, void *info, ocxl_irq_h * irq)
166164
if (my_afu->irq_count == my_afu->irq_max_count) {
167165
ocxl_err rc = grow_buffer(my_afu, (void **)&my_afu->irqs, &my_afu->irq_max_count, sizeof(ocxl_irq), INITIAL_IRQ_COUNT);
168166
if (rc != OCXL_OK) {
169-
errmsg(my_afu, rc, "Could not grow IRQ buffer for AFU '%s'", my_afu->identifier.afu_name);
167+
errmsg(my_afu, rc, "Could not grow IRQ buffer");
170168
return rc;
171169
}
172170
}
173171

174172
ocxl_err rc = irq_allocate(my_afu, &my_afu->irqs[my_afu->irq_count], info);
175173
if (rc != OCXL_OK) {
176-
errmsg(my_afu, rc, "Could not allocate IRQ for AFU '%s'", my_afu->identifier.afu_name);
174+
errmsg(my_afu, rc, "Could not allocate IRQ");
177175
return rc;
178176
}
179177
my_afu->irqs[my_afu->irq_count].irq_number = my_afu->irq_count;
@@ -327,12 +325,11 @@ static ocxl_event_action read_afu_event(ocxl_afu_h afu, uint16_t event_api_versi
327325
return OCXL_EVENT_ACTION_NONE;
328326
}
329327

330-
errmsg(afu, OCXL_INTERNAL_ERROR, "read of event header from fd %d for AFU '%s' failed: %d: %s",
331-
my_afu->fd, my_afu->identifier.afu_name, errno, strerror(errno));
328+
errmsg(afu, OCXL_INTERNAL_ERROR, "read of event header from fd %d failed: %d: %s",
329+
my_afu->fd, errno, strerror(errno));
332330
return OCXL_EVENT_ACTION_FAIL;
333331
} else if (buf_used < sizeof(ocxl_kernel_event_header)) {
334-
errmsg(afu, OCXL_INTERNAL_ERROR, "short read of event header from fd %d for AFU '%s'",
335-
my_afu->fd, my_afu->identifier.afu_name);
332+
errmsg(afu, OCXL_INTERNAL_ERROR, "short read of event header from fd %d", my_afu->fd);
336333
return OCXL_EVENT_ACTION_FAIL;
337334
}
338335

@@ -401,8 +398,8 @@ int ocxl_afu_event_check_versioned(ocxl_afu_h afu, int timeout, ocxl_event *even
401398

402399
int count;
403400
if ((count = epoll_wait(my_afu->epoll_fd, my_afu->epoll_events, event_count, timeout)) == -1) {
404-
errmsg(my_afu, OCXL_INTERNAL_ERROR, "epoll_wait failed waiting for AFU events on AFU '%s': %d: '%s'",
405-
my_afu->identifier.afu_name, errno, strerror(errno));
401+
errmsg(my_afu, OCXL_INTERNAL_ERROR, "epoll_wait failed waiting for AFU events: %d: '%s'",
402+
errno, strerror(errno));
406403
return -1;
407404
}
408405

@@ -434,9 +431,8 @@ int ocxl_afu_event_check_versioned(ocxl_afu_h afu, int timeout, ocxl_event *even
434431

435432
case EPOLL_SOURCE_IRQ:
436433
if (read(info->irq->event.eventfd, &count, sizeof(count)) < 0) {
437-
errmsg(my_afu, OCXL_INTERNAL_ERROR, "read of eventfd %d for AFU '%s' IRQ %d failed: %d: %s",
438-
info->irq->event.eventfd, my_afu->identifier.afu_name,
439-
info->irq->irq_number, errno, strerror(errno));
434+
errmsg(my_afu, OCXL_INTERNAL_ERROR, "read of eventfd %d IRQ %d failed: %d: %s",
435+
info->irq->event.eventfd, info->irq->irq_number, errno, strerror(errno));
440436
continue;
441437
}
442438
events[triggered].type = OCXL_EVENT_IRQ;

src/mmio.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static ocxl_err register_mmio(ocxl_afu *afu, void *addr, size_t size, ocxl_mmio_
6868
if (afu->mmio_count == afu->mmio_max_count) {
6969
ocxl_err rc = grow_buffer(afu, (void **)&afu->mmios, &afu->mmio_max_count, sizeof(ocxl_mmio_area), INITIAL_MMIO_COUNT);
7070
if (rc != OCXL_OK) {
71-
errmsg(afu, rc, "Could not grow MMIO buffer for AFU '%s'", afu->identifier.afu_name);
71+
errmsg(afu, rc, "Could not grow MMIO buffer");
7272
return rc;
7373
}
7474
}
@@ -98,14 +98,14 @@ ocxl_err global_mmio_open(ocxl_afu *afu)
9898
int length = snprintf(path, sizeof(path), "%s/global_mmio_area", afu->sysfs_path);
9999
if (length >= sizeof(path)) {
100100
ocxl_err rc = OCXL_NO_DEV;
101-
errmsg(afu, rc, "global MMIO path truncated for AFU '%s'", afu->identifier.afu_name);
101+
errmsg(afu, rc, "global MMIO path truncated");
102102
return rc;
103103
}
104104

105105
int fd = open(path, O_RDWR | O_CLOEXEC);
106106
if (fd < 0) {
107107
ocxl_err rc = OCXL_NO_DEV;
108-
errmsg(afu, rc, "Could not open global MMIO for AFU '%s': Error %d: %s", path, errno, strerror(errno));
108+
errmsg(afu, rc, "Could not open global MMIO '%s': Error %d: %s", path, errno, strerror(errno));
109109
return rc;
110110
}
111111

@@ -157,16 +157,14 @@ static ocxl_err global_mmio_map(ocxl_afu *afu, size_t size, int prot, uint64_t f
157157
void *addr = mmap(NULL, size, prot, MAP_SHARED, afu->global_mmio_fd, offset);
158158
if (addr == MAP_FAILED) {
159159
ocxl_err rc = OCXL_NO_MEM;
160-
errmsg(afu, rc, "Could not map global MMIO on AFU '%s', %d: %s",
161-
afu->identifier.afu_name, errno, strerror(errno));
160+
errmsg(afu, rc, "Could not map global MMIO, %d: %s", errno, strerror(errno));
162161
return rc;
163162
}
164163

165164
ocxl_mmio_h mmio_region;
166165
ocxl_err rc = register_mmio(afu, addr, size, OCXL_GLOBAL_MMIO, &mmio_region);
167166
if (rc != OCXL_OK) {
168-
errmsg(afu, rc, "Could not register global MMIO region with AFU '%s'",
169-
afu->identifier.afu_name);
167+
errmsg(afu, rc, "Could not register global MMIO region");
170168
return rc;
171169
}
172170

@@ -214,16 +212,14 @@ static ocxl_err mmio_map(ocxl_afu *afu, size_t size, int prot, uint64_t flags, o
214212
void *addr = mmap(NULL, afu->per_pasid_mmio.length, prot, MAP_SHARED, afu->fd, 0);
215213
if (addr == MAP_FAILED) {
216214
ocxl_err rc = OCXL_NO_MEM;
217-
errmsg(afu, rc, "Could not map per-PASID MMIO on AFU '%s', %d: %s",
218-
afu->identifier.afu_name, errno, strerror(errno));
215+
errmsg(afu, rc, "Could not map per-PASID MMIO: %d: %s", errno, strerror(errno));
219216
return rc;
220217
}
221218

222219
ocxl_mmio_h mmio_region;
223220
ocxl_err rc = register_mmio(afu, addr, size, OCXL_PER_PASID_MMIO, &mmio_region);
224221
if (rc != OCXL_OK) {
225-
errmsg(afu, rc, "Could not register global MMIO region with AFU '%s'",
226-
afu->identifier.afu_name);
222+
errmsg(afu, rc, "Could not register global MMIO region", afu->identifier.afu_name);
227223
return rc;
228224
}
229225

0 commit comments

Comments
 (0)