Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3096453rwb; Mon, 15 Aug 2022 18:02:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6dc/0FqvGEf/TEZnyEZCZK1BWEog37leRAS8w9dXvfIeqvudWDj1AQdSsZ1AKp3GvvrSbm X-Received: by 2002:a17:907:6d16:b0:731:17b5:699 with SMTP id sa22-20020a1709076d1600b0073117b50699mr12788747ejc.23.1660611610788; Mon, 15 Aug 2022 18:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611610; cv=none; d=google.com; s=arc-20160816; b=k6m1rD0nvkcthtge5Y9OkxMrbQHO3BLuLmClytu2MXTV50NCCnHerLNZ9YgX0mqkZ5 7Dyp02Mrk7OC/tT0nXwdEYpI3p1QUGa9iEDGjJzsKBu3WzY5CaiCpSpt+Wq4bFhHh5qT yiHdj/aG8ImAXev3RfKyIRTCx/92qba3jgHzuBS/DZuZoodg7TkKhEWsZlXVw+9Cj9OO ON+fKDf02qeawmO7nOktjluyfE7od8YEfY5ZdHJk/qeewfmkiqDH28LoxHtR0maUw58L OqN8eCGiHBHBcOIRGBKyzHCpL7dti5SWTJMcINcsw1MR36nfqonvVq0ake5M5ypnP+Bq jDvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vkwy8Yzzo/+iqFJcfXOlLD2bDI67/Qj02qriR7da0eY=; b=yIOwj+de+vPYV0q8YVJOZAKstB3UqF+44uFAOSW7TII+ftCKfD8fmxk960E775H1FH li3M306/Righ5KphW1/NbaNck49vWriXdrPsHttaDpq6plaHpriv/YkMxb+W6hAaSqIs 7XrtTXsZqhdjTf7F10d1d002VQ0xhJaLNKkZtXNPit1lnBXfd9MQrghS1dTIeCmSs5Op jG1FDtY5s17pNDqWbzIyK7G64ASidYTe6m2dBZX935EtOJ+sbUPrKiljy+e+xziC3o3d 0WVq0Pnv7lBq3NulTprZickDpofZXrozQsSPtRpHg3oM21eKbQfg84gmdWvMjUSIDpYv wt8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="behzgG/z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn2-20020a17090794c200b007314ba7a583si9211691ejc.908.2022.08.15.17.59.39; Mon, 15 Aug 2022 18:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="behzgG/z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233509AbiHPAub (ORCPT + 99 others); Mon, 15 Aug 2022 20:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347452AbiHPAp5 (ORCPT ); Mon, 15 Aug 2022 20:45:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6417A193579; Mon, 15 Aug 2022 13:41:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1668BB80EA9; Mon, 15 Aug 2022 20:41:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 521B5C433C1; Mon, 15 Aug 2022 20:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596104; bh=UMR9Q6e1EIqM0Fs6+TNQ242WxfelHSW1T1pAVmYgAec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=behzgG/z5SfODjVcI6gD5bCO2XxwqVu2/9ZqesPqJZfBbA+n2KYnMkC6Jtr3BUvSN X/baHSYGQGDMVJweHYrKNKEvMezLraAp+I5cZ+Xpl8ezmeWirvWDFdI2rFVRj5yBiY lEvG4je7GN9ZyMwfy8o9Pnx/+y0mNlWKQMmvp22c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Farman , Jason Gunthorpe , Matthew Rosato , Alex Williamson , Sasha Levin Subject: [PATCH 5.19 0939/1157] vfio/ccw: Fix FSM state if mdev probe fails Date: Mon, 15 Aug 2022 20:04:55 +0200 Message-Id: <20220815180517.076977276@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Farman [ Upstream commit f6c876d67e956de8d69349b0ee43bc7277c09e5c ] The FSM is in STANDBY state when arriving in vfio_ccw_mdev_probe(), and this routine converts it to IDLE as part of its processing. The error exit sets it to IDLE (again) but clears the private->mdev pointer. The FSM should of course be managing the state itself, but the correct thing for vfio_ccw_mdev_probe() to do would be to put the state back the way it found it. The corresponding check of private->mdev in vfio_ccw_sch_io_todo() can be removed, since the distinction is unnecessary at this point. Fixes: 3bf1311f351ef ("vfio/ccw: Convert to use vfio_register_emulated_iommu_dev()") Signed-off-by: Eric Farman Reviewed-by: Jason Gunthorpe Reviewed-by: Matthew Rosato Link: https://lore.kernel.org/r/20220707135737.720765-3-farman@linux.ibm.com Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/s390/cio/vfio_ccw_drv.c | 5 +++-- drivers/s390/cio/vfio_ccw_ops.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index 35055eb94115..179eb614fa5b 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -106,9 +106,10 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) /* * Reset to IDLE only if processing of a channel program * has finished. Do not overwrite a possible processing - * state if the final interrupt was for HSCH or CSCH. + * state if the interrupt was unsolicited, or if the final + * interrupt was for HSCH or CSCH. */ - if (private->mdev && cp_is_finished) + if (cp_is_finished) private->state = VFIO_CCW_STATE_IDLE; if (private->io_trigger) diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c index 0e05bff78b8e..9a05dadcbb75 100644 --- a/drivers/s390/cio/vfio_ccw_ops.c +++ b/drivers/s390/cio/vfio_ccw_ops.c @@ -146,7 +146,7 @@ static int vfio_ccw_mdev_probe(struct mdev_device *mdev) vfio_uninit_group_dev(&private->vdev); atomic_inc(&private->avail); private->mdev = NULL; - private->state = VFIO_CCW_STATE_IDLE; + private->state = VFIO_CCW_STATE_STANDBY; return ret; } -- 2.35.1