Commit 0f5d050c authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

s390/cio: allow to reset channel measurement block

Prior to commit 1bc6664b a call to
enable_cmf for a device for which channel measurement was already
enabled resulted in a reset of the measurement data.

What looked like bugs at the time (a 2nd allocation was triggered
but failed, reset was called regardless of previous failures, and
errors have not been reported to userspace) was actually something
at least one userspace tool depended on. Restore that behavior in
a sane way.

Fixes: 1bc6664b ("s390/cio: use device_lock during cmb activation")
Cc: #v4.4+
Signed-off-by: default avatarSebastian Ott <>
Reviewed-by: default avatarCornelia Huck <>
Reviewed-by: default avatarPeter Oberparleiter <>
Signed-off-by: default avatarMartin Schwidefsky <>
parent 8f50af49
......@@ -756,6 +756,17 @@ static void reset_cmb(struct ccw_device *cdev)
static int cmf_enabled(struct ccw_device *cdev)
int enabled;
enabled = !!cdev->private->cmb;
return enabled;
static struct attribute_group cmf_attr_group;
static struct cmb_operations cmbops_basic = {
......@@ -1156,13 +1167,8 @@ static ssize_t cmb_enable_show(struct device *dev,
char *buf)
struct ccw_device *cdev = to_ccwdev(dev);
int enabled;
enabled = !!cdev->private->cmb;
return sprintf(buf, "%d\n", enabled);
return sprintf(buf, "%d\n", cmf_enabled(cdev));
static ssize_t cmb_enable_store(struct device *dev,
......@@ -1202,15 +1208,20 @@ int ccw_set_cmf(struct ccw_device *cdev, int enable)
* @cdev: The ccw device to be enabled
* Returns %0 for success or a negative error value.
* Note: If this is called on a device for which channel measurement is already
* enabled a reset of the measurement data is triggered.
* Context:
* non-atomic
int enable_cmf(struct ccw_device *cdev)
int ret;
int ret = 0;
if (cmf_enabled(cdev)) {
goto out_unlock;
ret = cmbops->alloc(cdev);
if (ret)
......@@ -1229,7 +1240,7 @@ int enable_cmf(struct ccw_device *cdev)
if (ret)
return ret;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment