diff options
author | Frederic Barrat <fbarrat@linux.vnet.ibm.com> | 2016-03-04 06:26:28 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-03-08 21:05:43 -0500 |
commit | 5be587b1110132b4f05e0bc3515a145365e910fe (patch) | |
tree | 102af0ae101eef7c75f39bb696cda28ed45c8f65 /drivers/misc/cxl/sysfs.c | |
parent | cca44c0192b03d179786ec34b070e7de42966cc6 (diff) |
cxl: Introduce implementation-specific API
The backend API (in cxl.h) lists some low-level functions whose
implementation is different on bare-metal and in a guest. Each
environment implements its own functions, and the common code uses
them through function pointers, defined in cxl_backend_ops
Co-authored-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/sysfs.c')
-rw-r--r-- | drivers/misc/cxl/sysfs.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c index 02006f7109a8..300eafe4ed43 100644 --- a/drivers/misc/cxl/sysfs.c +++ b/drivers/misc/cxl/sysfs.c | |||
@@ -69,7 +69,7 @@ static ssize_t reset_adapter_store(struct device *device, | |||
69 | if ((rc != 1) || (val != 1)) | 69 | if ((rc != 1) || (val != 1)) |
70 | return -EINVAL; | 70 | return -EINVAL; |
71 | 71 | ||
72 | if ((rc = cxl_reset(adapter))) | 72 | if ((rc = cxl_ops->adapter_reset(adapter))) |
73 | return rc; | 73 | return rc; |
74 | return count; | 74 | return count; |
75 | } | 75 | } |
@@ -211,7 +211,7 @@ static ssize_t reset_store_afu(struct device *device, | |||
211 | goto err; | 211 | goto err; |
212 | } | 212 | } |
213 | 213 | ||
214 | if ((rc = __cxl_afu_reset(afu))) | 214 | if ((rc = cxl_ops->afu_reset(afu))) |
215 | goto err; | 215 | goto err; |
216 | 216 | ||
217 | rc = count; | 217 | rc = count; |
@@ -348,7 +348,7 @@ static ssize_t mode_store(struct device *device, struct device_attribute *attr, | |||
348 | } | 348 | } |
349 | 349 | ||
350 | /* | 350 | /* |
351 | * cxl_afu_deactivate_mode needs to be done outside the lock, prevent | 351 | * afu_deactivate_mode needs to be done outside the lock, prevent |
352 | * other contexts coming in before we are ready: | 352 | * other contexts coming in before we are ready: |
353 | */ | 353 | */ |
354 | old_mode = afu->current_mode; | 354 | old_mode = afu->current_mode; |
@@ -357,9 +357,9 @@ static ssize_t mode_store(struct device *device, struct device_attribute *attr, | |||
357 | 357 | ||
358 | mutex_unlock(&afu->contexts_lock); | 358 | mutex_unlock(&afu->contexts_lock); |
359 | 359 | ||
360 | if ((rc = _cxl_afu_deactivate_mode(afu, old_mode))) | 360 | if ((rc = cxl_ops->afu_deactivate_mode(afu, old_mode))) |
361 | return rc; | 361 | return rc; |
362 | if ((rc = cxl_afu_activate_mode(afu, mode))) | 362 | if ((rc = cxl_ops->afu_activate_mode(afu, mode))) |
363 | return rc; | 363 | return rc; |
364 | 364 | ||
365 | return count; | 365 | return count; |
@@ -389,7 +389,7 @@ static ssize_t afu_eb_read(struct file *filp, struct kobject *kobj, | |||
389 | struct cxl_afu *afu = to_cxl_afu(container_of(kobj, | 389 | struct cxl_afu *afu = to_cxl_afu(container_of(kobj, |
390 | struct device, kobj)); | 390 | struct device, kobj)); |
391 | 391 | ||
392 | return cxl_afu_read_err_buffer(afu, buf, off, count); | 392 | return cxl_ops->afu_read_err_buffer(afu, buf, off, count); |
393 | } | 393 | } |
394 | 394 | ||
395 | static struct device_attribute afu_attrs[] = { | 395 | static struct device_attribute afu_attrs[] = { |
@@ -469,10 +469,12 @@ static ssize_t afu_read_config(struct file *filp, struct kobject *kobj, | |||
469 | struct afu_config_record *cr = to_cr(kobj); | 469 | struct afu_config_record *cr = to_cr(kobj); |
470 | struct cxl_afu *afu = to_cxl_afu(container_of(kobj->parent, struct device, kobj)); | 470 | struct cxl_afu *afu = to_cxl_afu(container_of(kobj->parent, struct device, kobj)); |
471 | 471 | ||
472 | u64 i, j, val; | 472 | u64 i, j, val, rc; |
473 | 473 | ||
474 | for (i = 0; i < count;) { | 474 | for (i = 0; i < count;) { |
475 | val = cxl_afu_cr_read64(afu, cr->cr, off & ~0x7); | 475 | rc = cxl_ops->afu_cr_read64(afu, cr->cr, off & ~0x7, &val); |
476 | if (rc) | ||
477 | val = ~0ULL; | ||
476 | for (j = off & 0x7; j < 8 && i < count; i++, j++, off++) | 478 | for (j = off & 0x7; j < 8 && i < count; i++, j++, off++) |
477 | buf[i] = (val >> (j * 8)) & 0xff; | 479 | buf[i] = (val >> (j * 8)) & 0xff; |
478 | } | 480 | } |
@@ -517,9 +519,17 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c | |||
517 | return ERR_PTR(-ENOMEM); | 519 | return ERR_PTR(-ENOMEM); |
518 | 520 | ||
519 | cr->cr = cr_idx; | 521 | cr->cr = cr_idx; |
520 | cr->device = cxl_afu_cr_read16(afu, cr_idx, PCI_DEVICE_ID); | 522 | |
521 | cr->vendor = cxl_afu_cr_read16(afu, cr_idx, PCI_VENDOR_ID); | 523 | rc = cxl_ops->afu_cr_read16(afu, cr_idx, PCI_DEVICE_ID, &cr->device); |
522 | cr->class = cxl_afu_cr_read32(afu, cr_idx, PCI_CLASS_REVISION) >> 8; | 524 | if (rc) |
525 | goto err; | ||
526 | rc = cxl_ops->afu_cr_read16(afu, cr_idx, PCI_VENDOR_ID, &cr->vendor); | ||
527 | if (rc) | ||
528 | goto err; | ||
529 | rc = cxl_ops->afu_cr_read32(afu, cr_idx, PCI_CLASS_REVISION, &cr->class); | ||
530 | if (rc) | ||
531 | goto err; | ||
532 | cr->class >>= 8; | ||
523 | 533 | ||
524 | /* | 534 | /* |
525 | * Export raw AFU PCIe like config record. For now this is read only by | 535 | * Export raw AFU PCIe like config record. For now this is read only by |