Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3300862imm; Fri, 25 May 2018 03:22:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp5RNly7uc/PhkgvXI0Oa27fDScH7YLri7/B2rQI1BzlYb7Sd4mnrtsE6gKSxHk0+pQhgYb X-Received: by 2002:a65:61a5:: with SMTP id i5-v6mr1440486pgv.405.1527243762490; Fri, 25 May 2018 03:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527243762; cv=none; d=google.com; s=arc-20160816; b=Adta7juCVag+3Sn6lz0zSRFn8suREvriRS61ax1pazRnuUdv3u/bTrS5l1R5jf1N8Y 4OFqHFvrWRi57pU7uNRnBsFWade9zg1vko9arQPnuq3t1uF4Lqd+E1r2nlwy/T8ZV7Q2 5dtnJMZZBMCcHe/bPkzMi84UPFE7SqoqZFmy4equP/SGK311638TLcIKwmVCXfRcmMSN kEue20pJcEqZcUiJw02OS6PCMsr7mewTOjXzrkdXqDLeGtVcoOOcRFVM8peVkRz4gCyG lkgG35V5y4+yu3iJns9KF73A1HB9CP6Ap7bgr1QAIHTiWbwepgGt0UKt94UKY/fGoAsH HeHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=6n+BwpXiVynRnxBK09mNBatH+Noa+O9nEJVgleA55w8=; b=a/uipde7IblKQWhxMFoEanSr/MbdmkUZw7jtIntJ0fLfzGrPRmDwc50J/prJh8JYgJ b5FTKcHonbURT+66BGniOTEMHIbD5HV8g8gN9Ytl/28fXKYjy2zKgHvzwMQdQDL9OX7k 7TIGK0j4z0/gaTjZOxjkoYq0suGmiCVQLlkX466LL/Fcl20i0Wa6b3/I13pcgAurXift gMA9nnk7ynOx32T0fIym+xwAoVMXqmPLDhSSBYc6mkT5KJuCM0HJNFEUljEnxyiYKiLv wCx5xXyeKxonsSBWNwTbZJwOXOm+je7rjn2e/jKIX60UcppJJyBM21oW9QSj3tUHjfWf wB0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k72-v6si24230989pfa.53.2018.05.25.03.22.27; Fri, 25 May 2018 03:22:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966141AbeEYKVm (ORCPT + 99 others); Fri, 25 May 2018 06:21:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54900 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965883AbeEYKVh (ORCPT ); Fri, 25 May 2018 06:21:37 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4P9sA2N017009 for ; Fri, 25 May 2018 06:21:36 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j6fk8tuu5-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.7.4