Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2122389imn; Mon, 1 Aug 2022 11:57:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Fad1yd1hRPKWaHd7ushUqEOHi2U2tJFtBkfe9av3uzYpfJNK93VePw2DZRuMSv6nsfNnC X-Received: by 2002:a63:4855:0:b0:41b:b5fc:a51 with SMTP id x21-20020a634855000000b0041bb5fc0a51mr11062228pgk.18.1659380245574; Mon, 01 Aug 2022 11:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659380245; cv=none; d=google.com; s=arc-20160816; b=IKNob6VWekI2ejQ5km7zzbjatsdJyxjrxf3sF1Zvs3a/82mIXC+FFPWwuL6DAedjT0 LZS40sGQN7nKoYFECAsggFD7GJrewEDRXgyLCSOUZ0Z1f7zEM1rswftfGBLq5YU+StbU lL4Gl3eCkzzw0Uu0OReFOStLN4h7+H71BpkaZYz7MabHKs3GShKAcGVUpxPoKp7Zulvr u56/54TSJgQqBlj3Nqo7q+WPmfYhOX+wDQPGi7r9I2inWR3gqOOsaFwCf5F4X9pl2paG RyTPtmw6vWYI9PP3rZfE2YAy79ZOGLQ3qBdE21T+MwPQzdggJSa2VUiaLe1fTXMm7bbW BqVw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=9VSxu6kH6OVSyxacr8C8nn8K1lJQbLqb/x2+RqZOLy0=; b=K9xDM+fg4ulkvILXj9bTsyHJCPAk/+MTIdo9QzV8bUBZ+aye23sIZkICTEZ342JW4P 8JMIAM66fOoYgt+VPuVAt5EUUvwkTX0XusroB6kPbPoNXIaqSJb/4jWa+uWppAIAgFrm jYuLebx2vaZFeNztqByMZ20nqRszBvTJw4huOzPSy22U57mc51S/OxTMHg6dhsBIUhZD KRoNkCG44usgszRXb7Kig/33Ctm7Dz7mov9YuYPttzEfBcQ7oLjhlu/hkbnXznkqYeze /7j+EYS3732WfR11YTd8do3q2Ns8fclT68E40hZpDmS7vCfWxdGdb+Jd+NZRw/K+NFua zJxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QvNgiCjj; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a056a0014d200b0052d472f00f7si537280pfu.358.2022.08.01.11.57.08; Mon, 01 Aug 2022 11:57:25 -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=@redhat.com header.s=mimecast20190719 header.b=QvNgiCjj; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbiHASnA (ORCPT + 99 others); Mon, 1 Aug 2022 14:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbiHASm7 (ORCPT ); Mon, 1 Aug 2022 14:42:59 -0400 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 4168A764E for ; Mon, 1 Aug 2022 11:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659379377; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9VSxu6kH6OVSyxacr8C8nn8K1lJQbLqb/x2+RqZOLy0=; b=QvNgiCjjg/jSdCPKebxoYEWTwFwczJk7X6OtbeQt6dSJou1eV8PFwegR2ChVG26E8UDyum Au/lixGBMBAH3IsKfP2FVfgtmClENf5Q02UiNdsovhk11b2YhLUxlAgANo0/y5cpViHemx SDQnSKgy85tZaGTkQTAxJHkFuIb/cKs= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-jNxKWb_UMsOwGjuTVMqC3w-1; Mon, 01 Aug 2022 14:42:56 -0400 X-MC-Unique: jNxKWb_UMsOwGjuTVMqC3w-1 Received: by mail-il1-f199.google.com with SMTP id q10-20020a056e020c2a00b002dedb497c7fso408217ilg.16 for ; Mon, 01 Aug 2022 11:42:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=9VSxu6kH6OVSyxacr8C8nn8K1lJQbLqb/x2+RqZOLy0=; b=fnYbWWiOsdUkCgusub3blw/OWa0B53x3Y3oaJUbk2nYIMaKf3jAjfeUnsgGkeDyo0W gOZ+OeR/Y7j9UyqIrJt3ktzpNjTH2hbGcdODO6f6fQDIU4nkl3pra7IgB3nF1xJUb/DK 68eK1aWr6pxz+2UDS9S+sv8hQeNoXoav5+89tGcFFSkF1FFkSz2yi3IkdNFyjvQ8xt5p oK697oPTHrsQhJA7N25l7nRZe7MbuhByuDMb6g/aoAu/XkJXYuUNdn3l3rQbHnImHkyt PByeso7C0UpBf1V0JKDTCOL0pKILQTSY21bZnPrpUaxuISk4DBWQNVlpxXULdufcqgeT qh5A== X-Gm-Message-State: AJIora/8Fx30UVtAzPHt1w96lvxm7XS/JCyaVMQUjZdn7tzlv1wiufAK K1lUD6Z7q9IQhqICIHBR5AEQ8O0rrJW8KRSj9cP7Ec8tBKALXoCoLUH5RabE04jUdGApkJkjnbA 9KEkZ4hQ16w07/T01CyfBIqRX X-Received: by 2002:a05:6e02:12c7:b0:2dc:8862:15ed with SMTP id i7-20020a056e0212c700b002dc886215edmr6218135ilm.253.1659379375623; Mon, 01 Aug 2022 11:42:55 -0700 (PDT) X-Received: by 2002:a05:6e02:12c7:b0:2dc:8862:15ed with SMTP id i7-20020a056e0212c700b002dc886215edmr6218115ilm.253.1659379375287; Mon, 01 Aug 2022 11:42:55 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id cs12-20020a056638470c00b003427bb38ccasm771291jab.54.2022.08.01.11.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Aug 2022 11:42:54 -0700 (PDT) Date: Mon, 1 Aug 2022 12:42:53 -0600 From: Alex Williamson To: Abhishek Sahu Cc: Jason Gunthorpe , Cornelia Huck , Yishai Hadas , Shameer Kolothum , Kevin Tian , "Rafael J . Wysocki" , Max Gurtovoy , Bjorn Helgaas , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v5 1/5] vfio: Add the device features for the low power entry and exit Message-ID: <20220801124253.11c24d91.alex.williamson@redhat.com> In-Reply-To: References: <20220719121523.21396-1-abhsahu@nvidia.com> <20220719121523.21396-2-abhsahu@nvidia.com> <20220721163445.49d15daf.alex.williamson@redhat.com> <20220725160928.43a17560.alex.williamson@redhat.com> <20220726172356.GH4438@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 On Wed, 27 Jul 2022 11:37:02 +0530 Abhishek Sahu wrote: > On 7/26/2022 10:53 PM, Jason Gunthorpe wrote: > > On Tue, Jul 26, 2022 at 06:17:18PM +0530, Abhishek Sahu wrote: > >> Thanks Alex for your thorough review of uAPI. > >> I have incorporated all the suggestions. > >> Following is the updated uAPI. > >> > >> /* > >> * Upon VFIO_DEVICE_FEATURE_SET, allow the device to be moved into a low power > >> * state with the platform-based power management. Device use of lower power > >> * states depends on factors managed by the runtime power management core, > >> * including system level support and coordinating support among dependent > >> * devices. Enabling device low power entry does not guarantee lower power > >> * usage by the device, nor is a mechanism provided through this feature to > >> * know the current power state of the device. If any device access happens > >> * (either from the host or through the vfio uAPI) when the device is in the > >> * low power state, then the host will move the device out of the low power > >> * state as necessary prior to the access. Once the access is completed, the > >> * device may re-enter the low power state. For single shot low power support > >> * with wake-up notification, see > >> * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP below. Access to mmap'd > >> * device regions is disabled on LOW_POWER_ENTRY and may only be resumed after > >> * calling LOW_POWER_EXIT. > >> */ > >> #define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3 > >> > >> /* > >> * This device feature has the same behavior as > >> * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY with the exception that the user > >> * provides an eventfd for wake-up notification. > > > > It feels like this should be one entry point instead of two. > > > > A flag "automatic re-sleep" and an optional eventfd (-1 means not > > provided) seems to capture both of these behaviors in a bit clearer > > and extendable way. I think the mutual exclusion between re-entrant mode and one-shot is quite a bit more subtle in the version below, so I don't particularly find this cleaner. Potentially we could have variant drivers support one w/o the other in the previously proposed model as well. It's interesting to see this suggestion since since we seem to have a theme of making features single purpose elsewhere. Thanks, Alex > > We discussed about that in the earlier version of the patch series. > Since we have different exit related handling, so to avoid confusion > we proceeded with 2 separate variants for the low power entry. Also, > we don't need any parameter for the first case. > > But, I can do the changes to make a single entry point, if we conclude > for that. > > From my side, I have explored how the uAPI looks like if > we go with this approach. > > /* > * Upon VFIO_DEVICE_FEATURE_SET, allow the device to be moved into a low power > * state with the platform-based power management. Device use of lower power > * states depends on factors managed by the runtime power management core, > * including system level support and coordinating support among dependent > * devices. Enabling device low power entry does not guarantee lower power > * usage by the device, nor is a mechanism provided through this feature to > * know the current power state of the device. If any device access happens > * (either from the host or through the vfio uAPI) when the device is in the > * low power state, then the host will move the device out of the low power > * state as necessary prior to the access. Once the access is completed, the > * device re-entry to a low power state will be controlled through > * VFIO_DEVICE_LOW_POWER_REENTERY_DISABLE flag. > * > * If LOW_POWER_REENTERY_DISABLE flag is not set, the device may re-enter the > * low power state. Access to mmap'd device regions is disabled on > * LOW_POWER_ENTRY and may only be resumed after calling LOW_POWER_EXIT. > * > * If LOW_POWER_REENTERY_DISABLE flag is set, then user needs to provide an > * eventfd for wake-up notification. When the device moves out of the low > * power state for the wake-up, the host will not allow the device to re-enter > * a low power state without a subsequent user call to LOW_POWER_ENTRY. > * Access to mmap'd device regions is disabled on LOW_POWER_ENTRY and may only > * be resumed after the low power exit. The low power exit can happen either > * through LOW_POWER_EXIT or through any other access (where the wake-up > * notification has been generated). The access to mmap'd device regions will > * not trigger low power exit. > * > * The notification through the provided eventfd will be generated only when > * the device has entered and is resumed from a low power state after > * calling this device feature IOCTL. A device that has not entered low power > * state, as managed through the runtime power management core, will not > * generate a notification through the provided eventfd on access. Calling the > * LOW_POWER_EXIT feature is optional in the case where notification has been > * signaled on the provided eventfd that a resume from low power has occurred. > * > * The wakeup_eventfd needs to be valid only if LOW_POWER_REENTERY_DISABLE > * flag is set, otherwise, it will be ignored. > */ > #define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3 > > struct vfio_device_low_power_entry_with_wakeup { > __u32 flags; > #define VFIO_DEVICE_LOW_POWER_REENTERY_DISABLE (1 << 0) > __s32 wakeup_eventfd; > }; > > /* > * Upon VFIO_DEVICE_FEATURE_SET, disallow use of device low power states as > * previously enabled via VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY device feature. > * This device feature IOCTL may itself generate a wakeup eventfd notification > * if the device had previously entered a low power state with > * VFIO_DEVICE_LOW_POWER_REENTERY_DISABLE flag set. > */ > #define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 4 > > Thanks, > Abhishek >