From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FF62C433F5 for ; Wed, 2 Mar 2022 16:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240024AbiCBQIc (ORCPT ); Wed, 2 Mar 2022 11:08:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240278AbiCBQI2 (ORCPT ); Wed, 2 Mar 2022 11:08:28 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7601E32057 for ; Wed, 2 Mar 2022 08:07:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646237262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kijBMrzxo7OdLpiSqnAt9AQTzfbPdM8vboePrFXlyXA=; b=DxhwmfhD12a1Gz3qg5Sk/OV8D0gY/kO6d0KWFE7OSqDfh8sCcRbz6d/+XbOap8kKbHlfct mcIDTlg+HZSHApNsyExzJollxA2ydKR3xHP2DoDqLXsyclgQS2UWlL81+5g/RZDUbvE9qc kY1dBndbL+CnXzdsXP3BnRGlWTy/Tpo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-uU2zv3bJOMWGdofAbFUdcQ-1; Wed, 02 Mar 2022 11:07:37 -0500 X-MC-Unique: uU2zv3bJOMWGdofAbFUdcQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 438A2801AFE; Wed, 2 Mar 2022 16:07:35 +0000 (UTC) Received: from localhost (unknown [10.39.194.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D504A83C1D; Wed, 2 Mar 2022 16:07:23 +0000 (UTC) From: Cornelia Huck To: Alex Williamson , Jason Gunthorpe Cc: Yishai Hadas , bhelgaas@google.com, saeedm@nvidia.com, linux-pci@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, kuba@kernel.org, leonro@nvidia.com, kwankhede@nvidia.com, mgurtovoy@nvidia.com, maorg@nvidia.com, ashok.raj@intel.com, kevin.tian@intel.com, shameerali.kolothum.thodi@huawei.com Subject: Re: [PATCH V9 mlx5-next 09/15] vfio: Define device migration protocol v2 In-Reply-To: <20220302083440.539a1f33.alex.williamson@redhat.com> Organization: Red Hat GmbH References: <20220224142024.147653-1-yishaih@nvidia.com> <20220224142024.147653-10-yishaih@nvidia.com> <87tucgiouf.fsf@redhat.com> <20220302142732.GK219866@nvidia.com> <20220302083440.539a1f33.alex.williamson@redhat.com> User-Agent: Notmuch/0.34 (https://notmuchmail.org) Date: Wed, 02 Mar 2022 17:07:21 +0100 Message-ID: <87mti8ibie.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Wed, Mar 02 2022, Alex Williamson wrote: > On Wed, 2 Mar 2022 10:27:32 -0400 > Jason Gunthorpe wrote: > >> On Wed, Mar 02, 2022 at 12:19:20PM +0100, Cornelia Huck wrote: >> > > +/* >> > > + * vfio_mig_get_next_state - Compute the next step in the FSM >> > > + * @cur_fsm - The current state the device is in >> > > + * @new_fsm - The target state to reach >> > > + * @next_fsm - Pointer to the next step to get to new_fsm >> > > + * >> > > + * Return 0 upon success, otherwise -errno >> > > + * Upon success the next step in the state progression between cur_fsm and >> > > + * new_fsm will be set in next_fsm. >> > >> > What about non-success? Can the caller make any assumption about >> > next_fsm in that case? Because... >> >> I checked both mlx5 and acc, both properly ignore the next_fsm value >> on error. This oddness aros when Alex asked to return an errno instead >> of the state value. > > Right, my assertion was that only the driver itself should be able to > transition to the ERROR state. vfio_mig_get_next_state() should never > advise the driver to go to the error state, it can only report that a > transition is invalid. The driver may stay in the current state if an > error occurs here, which is why we added the ability to get the device > state. Thanks, > > Alex So, should the function then write anything to next_fsm if it returns -errno? (Maybe I'm misunderstanding.) Or should the caller always expect that something may be written to new_fsm, and simply only look at it if the function returns success? (I think that the code as-is is likely ok, I just want to make sure I'm not missing something. Apologies if that seems nitpicky.)