Skip to content

Commit a8563a3

Browse files
davejiangvinodkoul
authored andcommitted
dmanegine: idxd: reformat opcap output to match bitmap_parse() input
To make input and output consistent and prepping for the per WQ operation configuration support, change the output of opcap display to match the input that is expected by bitmap_parse() helper function. The output will be a bitmap with field width as the number of bits using the %*pb format specifier for printk() family. Signed-off-by: Dave Jiang <[email protected]> Co-developed-by: Fenghua Yu <[email protected]> Signed-off-by: Fenghua Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 22bd0df commit a8563a3

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

drivers/dma/idxd/idxd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ struct idxd_device {
310310
struct work_struct work;
311311

312312
struct idxd_pmu *idxd_pmu;
313+
314+
unsigned long *opcap_bmap;
313315
};
314316

315317
/* IDXD software descriptor */

drivers/dma/idxd/init.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,19 @@ static void idxd_read_table_offsets(struct idxd_device *idxd)
375375
dev_dbg(dev, "IDXD Perfmon Offset: %#x\n", idxd->perfmon_offset);
376376
}
377377

378+
static void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count)
379+
{
380+
int i, j, nr;
381+
382+
for (i = 0, nr = 0; i < count; i++) {
383+
for (j = 0; j < BITS_PER_LONG_LONG; j++) {
384+
if (val[i] & BIT(j))
385+
set_bit(nr, bmap);
386+
nr++;
387+
}
388+
}
389+
}
390+
378391
static void idxd_read_caps(struct idxd_device *idxd)
379392
{
380393
struct device *dev = &idxd->pdev->dev;
@@ -433,6 +446,7 @@ static void idxd_read_caps(struct idxd_device *idxd)
433446
IDXD_OPCAP_OFFSET + i * sizeof(u64));
434447
dev_dbg(dev, "opcap[%d]: %#llx\n", i, idxd->hw.opcap.bits[i]);
435448
}
449+
multi_u64_to_bmap(idxd->opcap_bmap, &idxd->hw.opcap.bits[0], 4);
436450
}
437451

438452
static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_data *data)
@@ -454,6 +468,12 @@ static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_d
454468
if (idxd->id < 0)
455469
return NULL;
456470

471+
idxd->opcap_bmap = bitmap_zalloc_node(IDXD_MAX_OPCAP_BITS, GFP_KERNEL, dev_to_node(dev));
472+
if (!idxd->opcap_bmap) {
473+
ida_free(&idxd_ida, idxd->id);
474+
return NULL;
475+
}
476+
457477
device_initialize(conf_dev);
458478
conf_dev->parent = dev;
459479
conf_dev->bus = &dsa_bus_type;

drivers/dma/idxd/registers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ struct opcap {
9090
u64 bits[4];
9191
};
9292

93+
#define IDXD_MAX_OPCAP_BITS 256U
94+
9395
#define IDXD_OPCAP_OFFSET 0x40
9496

9597
#define IDXD_TABLE_OFFSET 0x60

drivers/dma/idxd/sysfs.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,14 +1180,8 @@ static ssize_t op_cap_show(struct device *dev,
11801180
struct device_attribute *attr, char *buf)
11811181
{
11821182
struct idxd_device *idxd = confdev_to_idxd(dev);
1183-
int i, rc = 0;
1184-
1185-
for (i = 0; i < 4; i++)
1186-
rc += sysfs_emit_at(buf, rc, "%#llx ", idxd->hw.opcap.bits[i]);
11871183

1188-
rc--;
1189-
rc += sysfs_emit_at(buf, rc, "\n");
1190-
return rc;
1184+
return sysfs_emit(buf, "%*pb\n", IDXD_MAX_OPCAP_BITS, idxd->opcap_bmap);
11911185
}
11921186
static DEVICE_ATTR_RO(op_cap);
11931187

@@ -1412,6 +1406,7 @@ static void idxd_conf_device_release(struct device *dev)
14121406
kfree(idxd->wqs);
14131407
kfree(idxd->engines);
14141408
ida_free(&idxd_ida, idxd->id);
1409+
bitmap_free(idxd->opcap_bmap);
14151410
kfree(idxd);
14161411
}
14171412

0 commit comments

Comments
 (0)