Received: by 10.192.165.156 with SMTP id m28csp805073imm; Thu, 19 Apr 2018 07:52:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+2U9vK6LAEjs2LLze7jwuhud1vXn9U4TtlzOdSpKyLVlFvcTWUdTnUWqlnzLaqOTIB51xe X-Received: by 10.98.202.10 with SMTP id n10mr6110782pfg.220.1524149521651; Thu, 19 Apr 2018 07:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524149521; cv=none; d=google.com; s=arc-20160816; b=d9rdnKIJL2PmTLhh1Q9uKg9tPIU3w/cT6HQPwlICefeRU46pRGUOqj/J9XRqd2rc0Q FZf8Qaf+dXKNgOcTShJc6NzP4ELWuuW0UMVU3CFVJEnnzKdw8CFYMJWoqqonoUKM6oX1 w1lWNDcXdBmvPK+kemNka1KsVwlyeKFsQnfwJVNqKwlAlo/B5gk03qUtNGs6IXBmPqvs 9E/lyqW0ee9ZpbH/g+sQyIQnz7ejMwjk8fbtY7xdIVQq03lbTI7lNEXRvPMtklpnu5bQ 7Ny10tZmE27eFF+AUvTTRVTtZK1aON6MAdBF7Nqchu+vsZWGPsqKvh1XytAfr6y0SwyS rgJA== 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=a/8lZRONv9LCC7SQfORGjy/ZEejYCTFrsBGG1PnVg0U=; b=YZBlWP+IV6p+dAY6GcfTNSlVTJyvIY8puIMrKNCLUCU+QaNk14Hb6l8Wp8Sa1XlRbs X0XIPqPEASY4lVsqAbqBWLe7yQ8xhLzJ9dZjkqiNd7VZepnCot9StwzlA7+UDSU/+j9x Qsog/Al2Mjm3gOx0i9wjH/8doqcbMNE2V3ckKiQZYYcHHl+iw/I5v2IFM4jljPqEEG+U VJwVooxesLrSoSZix9t95l9swYWI1pBfHhvolSsN2bG0EW1fzZcI0swkM8KNwXn84r1M KM2dkjf3/jHU5HlcmHlK2Eft2YbbnbDl+yxLzp4rOU3VTajKZLo8is7GajpEjmLd5a2C jVIw== 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 y72-v6si3746044plh.72.2018.04.19.07.51.48; Thu, 19 Apr 2018 07:52:01 -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 S1753843AbeDSOuQ (ORCPT + 99 others); Thu, 19 Apr 2018 10:50:16 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56712 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753333AbeDSOuO (ORCPT ); Thu, 19 Apr 2018 10:50:14 -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 w3JEoCto039009 for ; Thu, 19 Apr 2018 10:50:13 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hevq0hsjr-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 19 Apr 2018 10:49:22 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Apr 2018 15:48:17 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Apr 2018 15:48:15 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3JEmFxU57933900; Thu, 19 Apr 2018 14:48:15 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4FB075203F; Thu, 19 Apr 2018 14:39:01 +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 0B9E052043; Thu, 19 Apr 2018 14:39:01 +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 01/10] vfio: ccw: Moving state change out of IRQ context Date: Thu, 19 Apr 2018 16:48:04 +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-0040-0000-0000-00000430CE30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041914-0041-0000-0000-00002634E5E2 Message-Id: <1524149293-12658-2-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=1015 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 Having state changes out of IRQ context allows to protect critical sections with mutexes. Next patches in the serie will use this possibility. We use work queues to thread the interrupts. Signed-off-by: Pierre Morel --- drivers/s390/cio/vfio_ccw_drv.c | 21 ++++++++------------- drivers/s390/cio/vfio_ccw_fsm.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index ea6a2d0..f1b158c 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -70,20 +70,9 @@ int vfio_ccw_sch_quiesce(struct subchannel *sch) static void vfio_ccw_sch_io_todo(struct work_struct *work) { struct vfio_ccw_private *private; - struct irb *irb; private = container_of(work, struct vfio_ccw_private, io_work); - irb = &private->irb; - - if (scsw_is_solicited(&irb->scsw)) { - cp_update_scsw(&private->cp, &irb->scsw); - cp_free(&private->cp); - } - memcpy(private->io_region.irb_area, irb, sizeof(*irb)); - - if (private->io_trigger) - eventfd_signal(private->io_trigger, 1); - + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_INTERRUPT); if (private->mdev) private->state = VFIO_CCW_STATE_IDLE; } @@ -94,9 +83,15 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) static void vfio_ccw_sch_irq(struct subchannel *sch) { struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev); + struct irb *irb = this_cpu_ptr(&cio_irb); inc_irq_stat(IRQIO_CIO); - vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_INTERRUPT); + memcpy(&private->irb, irb, sizeof(*irb)); + + WARN_ON(work_pending(&private->io_work)); + queue_work(vfio_ccw_work_q, &private->io_work); + if (private->completion) + complete(private->completion); } static int vfio_ccw_sch_probe(struct subchannel *sch) diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c index c30420c..af88551 100644 --- a/drivers/s390/cio/vfio_ccw_fsm.c +++ b/drivers/s390/cio/vfio_ccw_fsm.c @@ -162,14 +162,16 @@ 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 = this_cpu_ptr(&cio_irb); + struct irb *irb = &private->irb; - memcpy(&private->irb, irb, sizeof(*irb)); - - queue_work(vfio_ccw_work_q, &private->io_work); + if (scsw_is_solicited(&irb->scsw)) { + cp_update_scsw(&private->cp, &irb->scsw); + cp_free(&private->cp); + } + memcpy(private->io_region.irb_area, irb, sizeof(*irb)); - if (private->completion) - complete(private->completion); + if (private->io_trigger) + eventfd_signal(private->io_trigger, 1); } /* -- 2.7.4