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 28FEACD3423 for ; Mon, 18 Sep 2023 23:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjIRXcb (ORCPT ); Mon, 18 Sep 2023 19:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjIRXc2 (ORCPT ); Mon, 18 Sep 2023 19:32:28 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1425C99 for ; Mon, 18 Sep 2023 16:32:21 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6563022e3d3so22241876d6.3 for ; Mon, 18 Sep 2023 16:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1695079940; x=1695684740; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TLMTysNlum9+o+e8fKNP7w+Tu5sJ8VKKnB80pE3BFH0=; b=IjvoLD0TTCc6A6xURATDmZNc7fa8hV3+sU4fcV85fqUzdrs2v6tS2Q4z0l0lfx4MFs /OilwIkmChsJjccGtXrEJCgB0v69ym33m3+13IDsmSfe4Je4zyR7rJxnDo5LIQXJSuES jnUgruyjVnKrOd+yLQsfM/BYyRjJmEnBJ6s1rSS09p+BSQ7CVRQ9THMdzlEaVQstZfFU HamNE+g+FeorfOP5SFZMe92/b5wqsr8WABbZrlKrvLdS71lEOMc0CPZAym0bE1wxaWGx aDec422XLLCjw/HrglC13N3evXASxgnJRTA4yWLU4qvzNtlVdwijGXg4Gkj+Mzq+F0KV cB4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695079940; x=1695684740; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TLMTysNlum9+o+e8fKNP7w+Tu5sJ8VKKnB80pE3BFH0=; b=h0KlNCgjDH+UAJ4IbfpM+UEjqWwW+2vZeAluMvVV1DBxzPXkqzY9z/vLusaoHgGkAh G9cJ+GfA9vFwmOd8QJX8AS8+xgWw8lFow6fFFl9aF+YN2taV3ZzLmXOWMHdJ5t1vMc6q Emr2GBX5+wMwhgA8Nnv5JQXo14yyB0L/o0r9++YFKw40WYtjhMZPob9EQOTZ3O53V0aQ 7uH6DhVJgtmVjC/d8qQ/jFbrrT6Gbtt3RxV0VINKeztypDxpqWXnOajBNRdHuWc5qCft WO/sc/fYlyFRMtlLcBWtvHTpwchZzl+Nnixk7OD2ls5PCcATvgSaTr/o6qs4c4XleY6h rLkw== X-Gm-Message-State: AOJu0YzuLKJ6ywAQJRPgtZNsbFN9LCdLKh5t+eIucZPRLG6fbt6nZkQ0 ea7KGEeNxT83STGrR+gBgfpJ9w== X-Google-Smtp-Source: AGHT+IHi0Q0ITncG6MvwdO9eyFMUFwfFVtfnb2S2HnVMbYlxJUgy6VpYKVg3eHv9VYd73T9cBmTR3w== X-Received: by 2002:a0c:da88:0:b0:651:65f4:31fa with SMTP id z8-20020a0cda88000000b0065165f431famr11660526qvj.39.1695079940190; Mon, 18 Sep 2023 16:32:20 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-26-201.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.26.201]) by smtp.gmail.com with ESMTPSA id s16-20020a0ce310000000b00655e83dfa16sm2709466qvl.11.2023.09.18.16.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 16:32:19 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qiNj1-0007pV-8S; Mon, 18 Sep 2023 20:32:19 -0300 Date: Mon, 18 Sep 2023 20:32:19 -0300 From: Jason Gunthorpe To: "Nelson, Shannon" Cc: alex.williamson@redhat.com, kevin.tian@intel.com, reinette.chatre@intel.com, tglx@linutronix.de, kvm@vger.kernel.org, brett.creeley@amd.com, linux-kernel@vger.kernel.org, Leon Romanovsky Subject: Re: [PATCH vfio] vfio/pci: remove msi domain on msi disable Message-ID: <20230918233219.GO13795@ziepe.ca> References: <20230914191406.54656-1-shannon.nelson@amd.com> <20230918141705.GE13795@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 18, 2023 at 10:48:54AM -0700, Nelson, Shannon wrote: > In our case, the VF device's msix count value found in PCI config space is > changed by device configuration management outside of the baremetal host and > read by the QEMU instance when it starts up, and then read by the vfio PCI > core when QEMU requests the first IRQ. Oh, you definitely can't do that! PCI config space is not allowed to change outside the OS's view and we added sriov_set_msix_vec_count() specifically as a way to provide the necessary synchronization between all the parts. Randomly changing, what should be immutable, parts of the config space from under a running OS is just non-compliant PCI behavior. > The msix vectors are freed, but the msi_domain is not, and the msi_domain > holds the MSIx count that it read when it was created. If the device's MSIx > count is increased, the next QEMU session will see the new number in PCI > config space and try to use that new larger number, but the msi_domain is > still using the smaller hwsize and the QEMU IRQ setup fails in > msi_insert_desc(). Correct, devices are not allowed to change these parameters autonomously, so there is no reason to accommodate this. > This patch adds a msi_remove_device_irq_domain() call when the irqs are > disabled in order to force a new read on the next IRQ allocation cycle. This > is limited to only the vfio use of the msi_domain. Definately no. > I suppose we could add this to the trailing end of callbacks in our own > driver, but this looks more like a generic vfio/msi issue than a driver > specific thing. Certainly not. > The other possibility is to force the user to always do a bind cycle between > QEMU sessions using the VF. This seems to be unnecessary overhead and was > not necessary when using the v6.1 kernel. To the user, this looks like a > regression - this is how it was reported to me. You need to use sriov_set_msix_vec_count() and only sriov_set_msix_vec_count() to change this parameter or I expect you will constantly experience problems. Jason