Skip to contentSkip to conversation

Fixes for vfio-ccw

GIT PULL Cornelia Huck 1 participant 4 messages Apr 13, 2017 – Apr 24, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 1877888d0ad21858693d8a5594734b125a068638:

MAINTAINERS: Add vfio-ccw maintainers (2017-03-31 12:55:12 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git tags/vfio-ccw-20170413

for you to fetch changes up to 129cc19a94513081e9250323cd57e12ed48b3613:

vfio: ccw: improve error handling for vfio_ccw_mdev_remove (2017-04-12 12:34:17 +0200)

----------------------------------------------------------------
Two fixes for the new vfio-ccw support.

----------------------------------------------------------------

Dong Jia Shi (2):
vfio: ccw: remove unnecessary NULL checks of a pointer
vfio: ccw: improve error handling for vfio_ccw_mdev_remove

 drivers/s390/cio/vfio_ccw_fsm.c |  6 +-----
 drivers/s390/cio/vfio_ccw_ops.c | 34 ++++++----------------------------
 2 files changed, 7 insertions(+), 33 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

[PULL 1/2] vfio: ccw: remove unnecessary NULL checks of a pointer

From: Dong Jia Shi <[email protected]>

Remove several unnecessary checks for the @private pointer, since it can never be NULL in these places.

Message-Id: <[email protected]>

---
 drivers/s390/cio/vfio_ccw_fsm.c |  6 +-----
 drivers/s390/cio/vfio_ccw_ops.c | 17 -----------------
 2 files changed, 1 insertion(+), 22 deletions(-)
drivers/s390/cio/vfio_ccw_fsm.c +1 -5
index 55b6cc55758e..80a0559cd7ce 100644
@@ -161,12 +161,8 @@ static void fsm_io_request(struct vfio_ccw_private *private,
 static void fsm_irq(struct vfio_ccw_private *private,
 		    enum vfio_ccw_event event)
 {
-	struct irb *irb;
+	struct irb *irb = this_cpu_ptr(&cio_irb);
 
-	if (!private)
-		return;
-
-	irb = this_cpu_ptr(&cio_irb);
 	memcpy(&private->irb, irb, sizeof(*irb));
 
 	queue_work(vfio_ccw_work_q, &private->io_work);
drivers/s390/cio/vfio_ccw_ops.c +0 -17
index b2e615404034..55d0c87e73c3 100644
@@ -19,9 +19,6 @@ static int vfio_ccw_mdev_reset(struct mdev_device *mdev)
 	int ret;
 
 	private = dev_get_drvdata(mdev_parent_dev(mdev));
-	if (!private)
-		return -ENODEV;
-
 	sch = private->sch;
 	/*
 	 * TODO:
@@ -49,9 +46,6 @@ static int vfio_ccw_mdev_notifier(struct notifier_block *nb,
 	struct vfio_ccw_private *private =
 		container_of(nb, struct vfio_ccw_private, nb);
 
-	if (!private)
-		return NOTIFY_STOP;
-
 	/*
 	 * Vendor drivers MUST unpin pages in response to an
 	 * invalidation.
@@ -134,9 +128,6 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)
 		dev_get_drvdata(mdev_parent_dev(mdev));
 	int ret;
 
-	if (!private)
-		goto out;
-
 	if ((private->state == VFIO_CCW_STATE_NOT_OPER) ||
 	    (private->state == VFIO_CCW_STATE_STANDBY))
 		goto out;
@@ -187,9 +178,6 @@ static ssize_t vfio_ccw_mdev_read(struct mdev_device *mdev,
 		return -EINVAL;
 
 	private = dev_get_drvdata(mdev_parent_dev(mdev));
-	if (!private)
-		return -ENODEV;
-
 	region = &private->io_region;
 	if (copy_to_user(buf, (void *)region + *ppos, count))
 		return -EFAULT;
@@ -209,8 +197,6 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
 		return -EINVAL;
 
 	private = dev_get_drvdata(mdev_parent_dev(mdev));
-	if (!private)
-		return -ENODEV;
 	if (private->state != VFIO_CCW_STATE_IDLE)
 		return -EACCES;
 
@@ -274,9 +260,6 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev,
 		return -EINVAL;
 
 	private = dev_get_drvdata(mdev_parent_dev(mdev));
-	if (!private)
-		return -ENODEV;
-
 	ctx = &private->io_trigger;
 
 	switch (flags & VFIO_IRQ_SET_DATA_TYPE_MASK) {
Signature · 1 line
2.11.0
#2 lore raw

[PULL 2/2] vfio: ccw: improve error handling for vfio_ccw_mdev_remove

In reply to Cornelia Huck

From: Dong Jia Shi <[email protected]>

When vfio_ccw_mdev_reset fails during the remove process of the mdev, the current implementation simply returns.

The failure indicates that the subchannel device is in a NOT_OPER state, thus the right thing to do should be removing the mdev.

While we are at here, reverse the condition check to make the code more concise and readable.

Message-Id: <[email protected]>

---
 drivers/s390/cio/vfio_ccw_ops.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/s390/cio/vfio_ccw_ops.c +6 -11
index 55d0c87e73c3..e72abbc18ee3 100644
@@ -126,19 +126,14 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)
 {
 	struct vfio_ccw_private *private =
 		dev_get_drvdata(mdev_parent_dev(mdev));
-	int ret;
-
-	if ((private->state == VFIO_CCW_STATE_NOT_OPER) ||
-	    (private->state == VFIO_CCW_STATE_STANDBY))
-		goto out;
-
-	ret = vfio_ccw_mdev_reset(mdev);
-	if (ret)
-		return ret;
 
-	private->state = VFIO_CCW_STATE_STANDBY;
+	if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
+	    (private->state != VFIO_CCW_STATE_STANDBY)) {
+		if (!vfio_ccw_mdev_reset(mdev))
+			private->state = VFIO_CCW_STATE_STANDBY;
+		/* The state will be NOT_OPER on error. */
+	}
 
-out:
 	private->mdev = NULL;
 	atomic_inc(&private->avail);
 
Signature · 1 line
2.11.0
#3 lore raw
In reply to Cornelia Huck
Quoted 17 lines · On Thu, 13 Apr 2017 12:57:46 +0200 Cornelia Huck <[email protected]>…

The following changes since commit 1877888d0ad21858693d8a5594734b125a068638:

MAINTAINERS: Add vfio-ccw maintainers (2017-03-31 12:55:12 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git tags/vfio-ccw-20170413

for you to fetch changes up to 129cc19a94513081e9250323cd57e12ed48b3613:

vfio: ccw: improve error handling for vfio_ccw_mdev_remove (2017-04-12 12:34:17 +0200)

----------------------------------------------------------------
Two fixes for the new vfio-ccw support.

----------------------------------------------------------------

Quoted 8 lines

Dong Jia Shi (2):
vfio: ccw: remove unnecessary NULL checks of a pointer
vfio: ccw: improve error handling for vfio_ccw_mdev_remove

 drivers/s390/cio/vfio_ccw_fsm.c |  6 +-----
 drivers/s390/cio/vfio_ccw_ops.c | 34 ++++++----------------------------
 2 files changed, 7 insertions(+), 33 deletions(-)

ping