Received: by 10.192.165.156 with SMTP id m28csp796052imm; Thu, 19 Apr 2018 07:42:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx49/kowrKGvveUVPpiNZG1t/2/B7DjDJewQj0Z4AhEwEEDlbfmQ3UO79zXcq3vM5q6qvng4b X-Received: by 2002:a17:902:41:: with SMTP id 59-v6mr6476848pla.345.1524148971966; Thu, 19 Apr 2018 07:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524148971; cv=none; d=google.com; s=arc-20160816; b=JrcQKPmEGVlsH05Hrdup95W1F9Cq2uXOtCWdlog2I9Qm+Io46pcpOwu4DfBAV5NVmR GxmuMkpQ3GlRUDTXyz2nSWjsRLfe99Ea9WTAgUUln8Mi0y+oRdQbZI0tDoOWg1E03j1U Gi/6wG+rihuvrBXJhBYOlcpBxJXyE02Rog9iya7rv2WXrxrqsNso8iQ+miJDH85mTqOa w8IVwEEQV2eR1j0Rry9ySV4Z2sR2xmT6tmv2CFFRgivc2LsENEckzQ+1RMbEtxiUCDI1 9DBiQLF+gVUpYRrXRwQyncm6f1hMCFn0B+VqTF06XuRnBdHGUhKWKN3xKUWglBf6laaL /2JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:arc-authentication-results; bh=zOqXsM39Po1/Sw0hB5JE6eB1yaocc1Mvz2vNHA3s2SM=; b=a4FDsKhoHrkCt1+aang+OwNSkymmv3cyABSsZxxlvdRKWsNAFfvP+u8RlMl0EOi4/a twXQCcTrTJRWsZcUO/jfrOg/zKCSX6CZYrPIv+dnL0+kBGSr5fLBk35jHcshooLDPJYD 9sgHnSeFUkWoOSxbZgRkJsNWEoAxbo8hZXtJ38ydf/jZo1nGAJ7kMcSh9M/90rv5eguy dNI9kAVOEU5Js3DlBvcfjPzTRFIdFaarFwpV9aodIk3wtyhJ/AP6nuk5NuZtE/b2K8fN AOnPGNwuMc0gLBx9DWbtwl3ctstdZ8NJHcqCd+KIn17vCkPnPZz06xb2bpZD6yMPdzA1 3HLA== 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 m18si3318124pfi.296.2018.04.19.07.42.37; Thu, 19 Apr 2018 07:42:51 -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 S1753649AbeDSOlE (ORCPT + 99 others); Thu, 19 Apr 2018 10:41:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58270 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752958AbeDSOk6 (ORCPT ); Thu, 19 Apr 2018 10:40:58 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3JEdEBX076420 for ; Thu, 19 Apr 2018 10:40:57 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hevepaavk-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 19 Apr 2018 10:40:57 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Apr 2018 15:40:54 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Apr 2018 15:40:51 +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 w3JEeiRt50397242; Thu, 19 Apr 2018 14:40:50 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6766A2096; Thu, 19 Apr 2018 14:05:11 +0100 (BST) Received: from [9.152.224.146] (unknown [9.152.224.146]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 958D7A208F; Thu, 19 Apr 2018 14:05:11 +0100 (BST) Subject: Re: [PATCH] vfio-ccw: process ssch with interrupts disabled To: Cornelia Huck , Dong Jia Shi , Halil Pasic Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180413140509.9042-1-cohuck@redhat.com> From: Pierre Morel Date: Thu, 19 Apr 2018 16:14:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180413140509.9042-1-cohuck@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18041914-0012-0000-0000-000005CCAA13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041914-0013-0000-0000-00001949029F Message-Id: 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=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-1804190129 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/04/2018 16:05, Cornelia Huck wrote: > When we call ssch, an interrupt might already be pending once we > return from the START SUBCHANNEL instruction. Therefore we need to > make sure interrupts are disabled until after we're done with our > processing. > > Note that the subchannel lock is the same as the ccwdevice lock that > is mentioned in the documentation for ccw_device_start() and friends. > > Signed-off-by: Cornelia Huck > --- > drivers/s390/cio/vfio_ccw_fsm.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c > index ff6963ad6e39..3c800642134e 100644 > --- a/drivers/s390/cio/vfio_ccw_fsm.c > +++ b/drivers/s390/cio/vfio_ccw_fsm.c > @@ -20,12 +20,12 @@ static int fsm_io_helper(struct vfio_ccw_private *private) > int ccode; > __u8 lpm; > unsigned long flags; > + int ret; > > 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); > > @@ -38,10 +38,12 @@ static int fsm_io_helper(struct vfio_ccw_private *private) > * Initialize device status information > */ > sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND; > - return 0; > + ret = 0; > + break; > case 1: /* Status pending */ > case 2: /* Busy */ > - return -EBUSY; > + ret = -EBUSY; > + break; > case 3: /* Device/path not operational */ > { > lpm = orb->cmd.lpm; > @@ -51,13 +53,16 @@ static int fsm_io_helper(struct vfio_ccw_private *private) > sch->lpm = 0; > > if (cio_update_schib(sch)) > - return -ENODEV; > - > - return sch->lpm ? -EACCES : -ENODEV; > + ret = -ENODEV; > + else > + ret = sch->lpm ? -EACCES : -ENODEV; > + break; > } > default: > - return ccode; > + ret = ccode; > } > + spin_unlock_irqrestore(sch->lock, flags); > + return ret; > } > > static void fsm_notoper(struct vfio_ccw_private *private, I have been working on a patch to solve this problem between others, I provide it soon. It is much more intrusive, reworking interrupts and state machine. So may be you do not like it. If we stay on this patch, even this is quite a long spinlock around ssch and stsch, and we need it in the current implementation. Acked-by: Pierre Morel -- Pierre Morel Linux/KVM/QEMU in Böblingen - Germany