Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026594rwb; Mon, 15 Aug 2022 16:24:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR5CnFryeD+iqRzZxzCIpTGLqdehpkh0HEfU3SQiUjKhdQLz+3laDSdFPTav6/blGVXtWSf6 X-Received: by 2002:a05:6402:28c8:b0:43e:8622:1c21 with SMTP id ef8-20020a05640228c800b0043e86221c21mr16332122edb.135.1660605767919; Mon, 15 Aug 2022 16:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605767; cv=none; d=google.com; s=arc-20160816; b=bwj6pxaYZ9Vky70NUU8QbAnuEhHjzWOvWVdh5+9m1hQxJjx3KTs9ZRAOlBQQlsGb+U +sx3JgOQkXuwe/zJYb5FOK8RwySnK9RNAAB2ow/9x44muRA4XDlRNK5GmGjQ4oE2doqm GWZdhq8xGvZmQDrQG0A2yLaUOhy0mnydXSDeD1zIlH/LmH89NTacbHBq3QXl8hIgHsWi 55xIVGTut5daia8DreqaRu5HrvZxsqNCTFL1VOwKTxh2LeStKrWe3Bc19+IiUxpQaXj+ 6xOAK//8hFY8ItkqUH/RNGyvdQgA7DDAFFipe/24jTgDlFpkcH0Zf3ESzE6s5K60AQeN AcXA== 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=XN8MDX8BA9Y6uXtb6x1BC12pJ89hDmjEZwhQbROI7z8=; b=noFN/xs8qgV59DCPshnkIJee1aQyWcDKsQ6C0HTAWKOiMmjyoaqHJqgq+3dfG4m4ld qmREMajgbYRS1QLRPLAli9lGBO3Sczlb6/sXG0yn/OVPuz0UfXlHC5sM+P/4ciKGmLrF qYA9GuJ0AdP7uDu87bbaVLEQ79Hf/1ENzNzZdn3HcC4RIdoqk+bHJQNl6DFCM7EHGtlb NYAmGfbb5JLUNzIYnZpMrD7lAW3LjiAwyUKWfrYaOMmneIdMg5IdXPGD/uX1KPaVvOBF gn/zKOt4YrFCTDMEY68cOzEWt7M3ABveX7YljJzQhfzaq4Hm3765DvFDlTvdLjUIv807 sDkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="IpNAh/Kc"; 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 sa41-20020a1709076d2900b00732eb37e3bdsi8465952ejc.884.2022.08.15.16.22.20; Mon, 15 Aug 2022 16:22:47 -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="IpNAh/Kc"; 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 S1350253AbiHOWjB (ORCPT + 99 others); Mon, 15 Aug 2022 18:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241207AbiHOWc2 (ORCPT ); Mon, 15 Aug 2022 18:32:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F82312E253; Mon, 15 Aug 2022 12:49:10 -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 5DABFB81144; Mon, 15 Aug 2022 19:48:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F13BC433C1; Mon, 15 Aug 2022 19:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592924; bh=kVKp/t6i6DaXjN4J5IYS3k0hIz/ioS3Y5JvQrfcQXvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IpNAh/Kcrcf5ynyHwY0E6H6praPZi9SdiALY1Y7wyPgKCHsvsb/aTLFt8MqBZspB6 MuOItF6aObRcEB6kBlAo+tAUOu9Tx9H4IR+DMvzJuPN5kPeFi0ilpA3oNwd4vy7w7U K1FOm30c52PnKb24E3067EFAiKIiELfoAaH+uRV0= 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.18 0867/1095] vfio/ccw: Fix FSM state if mdev probe fails Date: Mon, 15 Aug 2022 20:04:26 +0200 Message-Id: <20220815180505.232891227@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 ee182cfb467d..789175221e9a 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -107,9 +107,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 d8589afac272..8d76f5b26e2b 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