From patchwork Fri May 25 10:21:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10426947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13F75602D8 for ; Fri, 25 May 2018 10:22:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1CB929615 for ; Fri, 25 May 2018 10:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5E6B29640; Fri, 25 May 2018 10:22:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9960829615 for ; Fri, 25 May 2018 10:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966097AbeEYKVl (ORCPT ); Fri, 25 May 2018 06:21:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39026 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966031AbeEYKVh (ORCPT ); Fri, 25 May 2018 06:21:37 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4P9sM8K017646 for ; Fri, 25 May 2018 06:21:37 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j6fb73ker-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 25 May 2018 06:21:36 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 25 May 2018 11:21:34 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 25 May 2018 11:21:32 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4PALWpk4850126; Fri, 25 May 2018 10:21:32 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46CC3A404D; Fri, 25 May 2018 11:12:50 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11DDFA4057; Fri, 25 May 2018 11:12:50 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.33]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 25 May 2018 11:12:50 +0100 (BST) From: Pierre Morel To: pasic@linux.vnet.ibm.com, bjsdjshi@linux.vnet.ibm.com Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, cohuck@redhat.com Subject: [PATCH v2 10/10] vfio: ccw: Let user wait when busy on IO Date: Fri, 25 May 2018 12:21:18 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527243678-3140-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1527243678-3140-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052510-0012-0000-0000-000005DA7F95 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052510-0013-0000-0000-00001957D353 Message-Id: <1527243678-3140-11-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-25_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805250113 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the current implementation, we do not want to start a new SSCH command before the last one ends. Currently the user needs to poll on the -EBUSY error to wait before sending a new request. Let's be friendly with global warming and let the user sleep until he may send a new request. Let's make the caller wait until the last SSCH ends. Signed-off-by: Pierre Morel --- drivers/s390/cio/vfio_ccw_fsm.c | 4 ++++ drivers/s390/cio/vfio_ccw_ops.c | 6 ++++++ drivers/s390/cio/vfio_ccw_private.h | 1 + 3 files changed, 11 insertions(+) diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c index c37052d..97b74a1 100644 --- a/drivers/s390/cio/vfio_ccw_fsm.c +++ b/drivers/s390/cio/vfio_ccw_fsm.c @@ -200,6 +200,10 @@ static int fsm_irq(struct vfio_ccw_private *private) if (private->io_trigger) eventfd_signal(private->io_trigger, 1); + + if (private->io_completion) + complete(private->io_completion); + return VFIO_CCW_STATE_IDLE; } diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index b202e73..39beb6e 100644 --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -183,6 +183,7 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev, struct vfio_ccw_private *private; struct ccw_io_region *region; union scsw *scsw; + DECLARE_COMPLETION_ONSTACK(completion); if (*ppos + count > sizeof(*region)) return -EINVAL; @@ -196,6 +197,11 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev, scsw = (union scsw *) ®ion->scsw_area; switch (scsw->cmd.fctl) { case SCSW_FCTL_START_FUNC: + if (private->state == VFIO_CCW_STATE_BUSY) { + private->io_completion = &completion; + if (wait_for_completion_interruptible(&completion)) + return -EINTR; + } vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_SSCH_REQ); break; default: diff --git a/drivers/s390/cio/vfio_ccw_private.h b/drivers/s390/cio/vfio_ccw_private.h index ab5e37fa..e2e4f6d 100644 --- a/drivers/s390/cio/vfio_ccw_private.h +++ b/drivers/s390/cio/vfio_ccw_private.h @@ -39,6 +39,7 @@ struct vfio_ccw_private { struct subchannel *sch; int state; struct completion *completion; + struct completion *io_completion; atomic_t avail; struct mdev_device *mdev; struct notifier_block nb;