Received: by 10.192.165.156 with SMTP id m28csp804181imm; Thu, 19 Apr 2018 07:51:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+2v6MY5TUsODEWY02kWKF+tNlBaGUo8G3XYNyzZcxTSRflqLjPzliTN6M2nlaeIckmqLwo X-Received: by 10.98.89.209 with SMTP id k78mr6132652pfj.54.1524149469592; Thu, 19 Apr 2018 07:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524149469; cv=none; d=google.com; s=arc-20160816; b=D9fnnx4yFSjifGgb0r71qNECuavE1aXDQ3vYrR3j3UB8rNMkUQ0VZt1vKdq3aZec/Q cf5/jiWxAdtuqMbQJpXebtPNrEzzMlkLDUHhQfaQ8H4kh1BUx0p/HGNt3VMK49AN/qX0 rZOkeOBPNk7W8XgR35KRlhg8CqxCvUMFOTFRL0YgDyXflXkJd8w8VTFiB9bpniUA+CXd rnWGea2nRHOo7peKMbUGcoFAg7AJF0a6Kxw0GpcKqfVrHCfwvTKQgq8DDxoLSdcKsWZ2 VPpMaD3n/ClEiJCKGH2OAJx/eFpONvY4WFAt+/1IavqmukJaQ+xqEQzX76iKy79yZF77 4x1w== 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=u8acoUbc+OqstDcm9YSP9ReAnFuq8lDaZIwMPIMMFYY=; b=p3sxIo4r2OOYrjqcmfXvdxNNYDzj9dLEhCFJzvLVz+vC9710Zne7cjc1lLsNfcIw19 B0a9byRCXjT9RgKrlUJ4F8cnQW5QrQuQpDGo9Im6RJTehexJj/h9oPd6k9E11YvsA0rw k8RWYnde3UR/YMQMGaMrJLga+2hgcC5gC62naEbup8Xz4a0qBH7PIziJMtmTNn6sFO3k 9dQYIy6rXb0HT6QzeAJ89kMGXXMzjPk7TmHzs1soS6+puu3D8Ak+z6t6/4zXLhL0n8zI jamxo9FmXOyk3HgIyllf/mz4VogynrZMdRuXJEmJgZe02DBd9zJHF2Vrvw+Tm9N2chrV CI/g== 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 79si3119169pga.440.2018.04.19.07.50.55; Thu, 19 Apr 2018 07:51:09 -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 S1753523AbeDSOt0 (ORCPT + 99 others); Thu, 19 Apr 2018 10:49:26 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:43040 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752841AbeDSOsa (ORCPT ); Thu, 19 Apr 2018 10:48:30 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3JEmPKP073464 for ; Thu, 19 Apr 2018 10:48:30 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2heuvc4knk-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 19 Apr 2018 10:48:28 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Apr 2018 15:48:23 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Apr 2018 15:48:19 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3JEmJwA56492226; Thu, 19 Apr 2018 14:48:19 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3943E5205F; Thu, 19 Apr 2018 14:39:05 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.146]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E959952045; Thu, 19 Apr 2018 14:39:04 +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 04/10] vfio: ccw: replace IO_REQ event with SSCH_REQ event Date: Thu, 19 Apr 2018 16:48:07 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524149293-12658-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1524149293-12658-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041914-0044-0000-0000-0000054A09D0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041914-0045-0000-0000-0000288A25F3 Message-Id: <1524149293-12658-5-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-19_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804190131 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch simplifies the IO request handling to handle the only implemented request: SSCH. Other request are invalid and get a return value of -EINVAL. This patch change the event name to VFIO_CCW_EVENT_SSCH_REQ to reflect what is done and prepare for future implementation of other requests. Signed-off-by: Pierre Morel --- drivers/s390/cio/vfio_ccw_fsm.c | 63 +++++++++++++------------------------ drivers/s390/cio/vfio_ccw_ops.c | 9 ++++-- drivers/s390/cio/vfio_ccw_private.h | 2 +- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c index 13751b4..f9855cd 100644 --- a/drivers/s390/cio/vfio_ccw_fsm.c +++ b/drivers/s390/cio/vfio_ccw_fsm.c @@ -19,14 +19,9 @@ static int fsm_io_helper(struct vfio_ccw_private *private) union orb *orb; int ccode; __u8 lpm; - unsigned long flags; sch = private->sch; - spin_lock_irqsave(sch->lock, flags); - private->state = VFIO_CCW_STATE_BUSY; - spin_unlock_irqrestore(sch->lock, flags); - orb = cp_get_orb(&private->cp, (u32)(addr_t)sch, sch->lpm); /* Issue "Start Subchannel" */ @@ -118,44 +113,30 @@ static int fsm_io_request(struct vfio_ccw_private *private, enum vfio_ccw_event event) { union orb *orb; - union scsw *scsw = &private->scsw; struct ccw_io_region *io_region = &private->io_region; struct mdev_device *mdev = private->mdev; private->state = VFIO_CCW_STATE_BOXED; - memcpy(scsw, io_region->scsw_area, sizeof(*scsw)); - - if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) { - orb = (union orb *)io_region->orb_area; - - io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev), - orb); - if (io_region->ret_code) - goto err_out; - - io_region->ret_code = cp_prefetch(&private->cp); - if (io_region->ret_code) { - cp_free(&private->cp); - goto err_out; - } - - /* Start channel program and wait for I/O interrupt. */ - io_region->ret_code = fsm_io_helper(private); - if (io_region->ret_code) { - cp_free(&private->cp); - goto err_out; - } - return private->state; - } else if (scsw->cmd.fctl & SCSW_FCTL_HALT_FUNC) { - /* XXX: Handle halt. */ - io_region->ret_code = -EOPNOTSUPP; + orb = (union orb *)io_region->orb_area; + + io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev), orb); + if (io_region->ret_code) + goto err_out; + + io_region->ret_code = cp_prefetch(&private->cp); + if (io_region->ret_code) { + cp_free(&private->cp); goto err_out; - } else if (scsw->cmd.fctl & SCSW_FCTL_CLEAR_FUNC) { - /* XXX: Handle clear. */ - io_region->ret_code = -EOPNOTSUPP; + } + + /* Start channel program and wait for I/O interrupt. */ + io_region->ret_code = fsm_io_helper(private); + if (io_region->ret_code) { + cp_free(&private->cp); goto err_out; } + return VFIO_CCW_STATE_BUSY; err_out: private->state = VFIO_CCW_STATE_IDLE; @@ -179,7 +160,7 @@ static int fsm_irq(struct vfio_ccw_private *private, if (private->io_trigger) eventfd_signal(private->io_trigger, 1); - return private->state; + return VFIO_CCW_STATE_IDLE; } /* @@ -206,31 +187,31 @@ static int fsm_sch_event(struct vfio_ccw_private *private, fsm_func_t *vfio_ccw_jumptable[NR_VFIO_CCW_STATES][NR_VFIO_CCW_EVENTS] = { [VFIO_CCW_STATE_NOT_OPER] = { [VFIO_CCW_EVENT_NOT_OPER] = fsm_nop, - [VFIO_CCW_EVENT_IO_REQ] = fsm_io_error, + [VFIO_CCW_EVENT_SSCH_REQ] = fsm_io_error, [VFIO_CCW_EVENT_INTERRUPT] = fsm_disabled_irq, [VFIO_CCW_EVENT_SCH_EVENT] = fsm_nop, }, [VFIO_CCW_STATE_STANDBY] = { [VFIO_CCW_EVENT_NOT_OPER] = fsm_notoper, - [VFIO_CCW_EVENT_IO_REQ] = fsm_io_error, + [VFIO_CCW_EVENT_SSCH_REQ] = fsm_io_error, [VFIO_CCW_EVENT_INTERRUPT] = fsm_irq, [VFIO_CCW_EVENT_SCH_EVENT] = fsm_sch_event, }, [VFIO_CCW_STATE_IDLE] = { [VFIO_CCW_EVENT_NOT_OPER] = fsm_notoper, - [VFIO_CCW_EVENT_IO_REQ] = fsm_io_request, + [VFIO_CCW_EVENT_SSCH_REQ] = fsm_io_request, [VFIO_CCW_EVENT_INTERRUPT] = fsm_irq, [VFIO_CCW_EVENT_SCH_EVENT] = fsm_sch_event, }, [VFIO_CCW_STATE_BOXED] = { [VFIO_CCW_EVENT_NOT_OPER] = fsm_notoper, - [VFIO_CCW_EVENT_IO_REQ] = fsm_io_busy, + [VFIO_CCW_EVENT_SSCH_REQ] = fsm_io_busy, [VFIO_CCW_EVENT_INTERRUPT] = fsm_irq, [VFIO_CCW_EVENT_SCH_EVENT] = fsm_sch_event, }, [VFIO_CCW_STATE_BUSY] = { [VFIO_CCW_EVENT_NOT_OPER] = fsm_notoper, - [VFIO_CCW_EVENT_IO_REQ] = fsm_io_busy, + [VFIO_CCW_EVENT_SSCH_REQ] = fsm_io_busy, [VFIO_CCW_EVENT_INTERRUPT] = fsm_irq, [VFIO_CCW_EVENT_SCH_EVENT] = fsm_sch_event, }, diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index 41eeb57..4da7b61 100644 --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -188,19 +188,22 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev, { struct vfio_ccw_private *private; struct ccw_io_region *region; + union scsw *scsw; if (*ppos + count > sizeof(*region)) return -EINVAL; private = dev_get_drvdata(mdev_parent_dev(mdev)); - if (private->state != VFIO_CCW_STATE_IDLE) - return -EACCES; region = &private->io_region; if (copy_from_user((void *)region + *ppos, buf, count)) return -EFAULT; - vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_IO_REQ); + scsw = (union scsw *) ®ion->scsw_area; + if ((scsw->cmd.fctl & SCSW_FCTL_START_FUNC) != SCSW_FCTL_START_FUNC) + return -EINVAL; + + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_SSCH_REQ); if (region->ret_code != 0) { private->state = VFIO_CCW_STATE_IDLE; return region->ret_code; diff --git a/drivers/s390/cio/vfio_ccw_private.h b/drivers/s390/cio/vfio_ccw_private.h index 3284e64..93aab87 100644 --- a/drivers/s390/cio/vfio_ccw_private.h +++ b/drivers/s390/cio/vfio_ccw_private.h @@ -76,7 +76,7 @@ enum vfio_ccw_state { */ enum vfio_ccw_event { VFIO_CCW_EVENT_NOT_OPER, - VFIO_CCW_EVENT_IO_REQ, + VFIO_CCW_EVENT_SSCH_REQ, VFIO_CCW_EVENT_INTERRUPT, VFIO_CCW_EVENT_SCH_EVENT, /* last element! */ -- 2.7.4