Received: by 10.192.165.156 with SMTP id m28csp841170imm; Thu, 19 Apr 2018 08:24:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OX1BpjcwC43jv8dR4VRgPu1V5lCL5KipiKvlzl3rdSgc7b3vK6nRLh8SVjoXrC9DWR/dK X-Received: by 10.99.106.4 with SMTP id f4mr4824716pgc.225.1524151447506; Thu, 19 Apr 2018 08:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524151447; cv=none; d=google.com; s=arc-20160816; b=1Cmy+KOpSs31SqlnaZS0ALjE7V+OWwe+3xF5tmKUAwwSqceBjkGENp3KqqubqrNSwF xrvf2nNKoklxNjghOLQUQOCXGK+4XcpO/bVwNLnkT6fIIXfopWGCh6YZdO55bbZcRWaV aQZTEsaZqfQlkkYVkM9/b8XAOcUfy3139LDo6Ry1UcX425EcgU9ELbGrROLMQgCc+Xbs qxKUDkBCCI8qtHIhZw8nUf3/ZhM+nmK0TwZooHvEy4+iWEdlnZa2aNPVzQq/bErJrkgH XDQFn0FGu+0zi/KQloNzgw7wVN+faMARf7TYEVQ/B4D8tF8D4Sm5OD1MGVcOzpdo9d15 Pahg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=oICt1UzLO3OoxXvatfgJLzKMIySwr432KY8wxHftSpo=; b=zoMhjT+DzoJbJXy3aiezKuEDCS6YH3SQynV4aWkxjAiioCU745vrCgWLaR/NqAhIY8 0VRjNzpZdj9eS4bagwG83OFSWEtLiHDPLjoBEAduc6XGKif2GNQUCxDSub/dgaAsVYwU OtYZJCZPvhNgY/YAEcovkne/PnacgjpTsdG/4sshl36lM2qOsmP7/X3jGGuo9WRyswAt 78F8kpBVjuwXDIq01lDx0KG/yO3iS+IazkuJ9GQr5DgVEo2h2yc3PTatyoWhmS1WRELE M+IzhO6M1A+S6bqtA0mb0+KdLei2Rz3xfTKZNK3/0GppUVGw3IS/97yj6vdK5s/0v+Mg xMnw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11-v6si3610191pls.145.2018.04.19.08.23.53; Thu, 19 Apr 2018 08:24:07 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbeDSPWy (ORCPT + 99 others); Thu, 19 Apr 2018 11:22:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48586 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751070AbeDSPWw (ORCPT ); Thu, 19 Apr 2018 11:22:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DADA41662E2; Thu, 19 Apr 2018 15:22:52 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EC2584420; Thu, 19 Apr 2018 15:22:50 +0000 (UTC) Date: Thu, 19 Apr 2018 17:22:48 +0200 From: Cornelia Huck To: Pierre Morel Cc: Dong Jia Shi , Halil Pasic , linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vfio-ccw: process ssch with interrupts disabled Message-ID: <20180419172248.0d10db2a.cohuck@redhat.com> In-Reply-To: References: <20180413140509.9042-1-cohuck@redhat.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 19 Apr 2018 15:22:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 19 Apr 2018 15:22:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Apr 2018 16:14:25 +0200 Pierre Morel wrote: > 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. I'll take a look at your state machine series later, but it is certainly material for the next release. [I also have my halt/clear implementation which I wanted to send this week, but other things have been eating up my bandwidth. Well, the week is not over yet...] > 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. I'd like to queue a small patch like this for the current release which is also suitable for stable. We can still rework things on top. > Acked-by: Pierre Morel Thanks!