From patchwork Tue Oct 22 08:36:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13845307 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A378D1CDB7 for ; Tue, 22 Oct 2024 08:38:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOO-0001i4-4e; Tue, 22 Oct 2024 04:37:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3AOM-0001a1-3r for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:26 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AOK-0001Vm-Hf for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:25 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-718119fc061so2106593a34.2 for ; Tue, 22 Oct 2024 01:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586242; x=1730191042; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=s2ddjXKYpOMCpQhobDNCoLol3H9ldQZTsQ8bEMFv7Pc=; b=IEAZjWfqDvLC4KDips9sAT9oLHtbOl/RDKVVg698yVuuU03QD93hIEyR1C/SBFoJ4x C/yqNMxi0gm7VJby8c9D6nT6GAEblYUojdF0HJCOzX/Dz5XCI0wl1WKXQkwXwXWT9t8t krPD0qfFIyvZL9k/z+8hglIlWmVQcUnvsIix/33Amkri+/4YFDs+ED368rZF9DYJKS8f BqIF8nvdGlDbxZ/SI2sdg26+liYOjUVIH3cuy2ZG3AfzmxWObdnqJGZzQwSvMlJjdU9M 6L1nVjYQuTjhGY7J2IF6C0h5NNrmw3K+IwYnyR9ZbhBweOeRgkV3awN5db/ZAFZ0Yu0M vdjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586242; x=1730191042; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s2ddjXKYpOMCpQhobDNCoLol3H9ldQZTsQ8bEMFv7Pc=; b=VaGz/1zvWW+3LRCUxD5Vf/I2jz5dqcJYg8A7E83bhn4JADVZgcEe3UebqxqpEm0x2p MCe1irCylET8od9uTqfe0dCJWTq+1piRYbfCM9PsD6zOXqzma+LdXBXp1mtE62OW9jwz Q0BEWG1EDXM5Y5CpCDKmYPtqvF/MyIQjq1fgf/8FkwrWkJulY+gMM8YUEEZrwfZR0n84 +X0kOgAx78eIueJO7HgD8FoDg1E4oI3hm0Uo6+Hr9hhK9l3ubOT+OITDSYoNhFYRs1dk 53ftNn6rX0GWwtS9JzsSfxMSNmsefyIbAPicAWiWcxcrB7z4Vp2whyXYgvJqu1T0HPdC KnQw== X-Gm-Message-State: AOJu0Yx6oZ0bb/1X3ClpTGLSGOxtytEPpWjlohv2vnF21JasDritLq/z iPoKbGSTM9fKh2e3R02+TY8ONLXtvK+n3gZj4HSmLjUnY1hv7tC+Xw+cSlu92cg= X-Google-Smtp-Source: AGHT+IH35ts0/l0USCjFN6lwgA8BBJiwMJt4kRQTFjbSLwMYFlnC24azPznLSEhbX2QwhEqZTMAIWw== X-Received: by 2002:a05:6870:440e:b0:277:f51d:3ed3 with SMTP id 586e51a60fabf-2892c2def2emr11876088fac.16.1729586242433; Tue, 22 Oct 2024 01:37:22 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7eaeabd9c0esm4592104a12.79.2024.10.22.01.37.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:22 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:41 +0900 Subject: [PATCH v17 04/14] s390x/pci: Avoid creating zpci for VFs MIME-Version: 1.0 Message-Id: <20241022-reuse-v17-4-bd7c133237e4@daynix.com> References: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> In-Reply-To: <20241022-reuse-v17-0-bd7c133237e4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster , Matthew Rosato , Eric Farman , Harsh Prateek Bora , Shivaprasad G Bhat Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::32c; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org VFs are automatically created by PF, and creating zpci for them will result in unexpected usage of fids. Currently QEMU does not support multifunction for s390x so we don't need zpci for VFs anyway. Signed-off-by: Akihiko Odaki --- hw/s390x/s390-pci-bus.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 40b2567aa706..f06df757a34b 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1080,6 +1080,16 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev, pbdev = s390_pci_find_dev_by_target(s, dev->id); if (!pbdev) { + /* + * VFs are automatically created by PF, and creating zpci for them + * will result in unexpected usage of fids. Currently QEMU does not + * support multifunction for s390x so we don't need zpci for VFs + * anyway. + */ + if (pci_is_vf(pdev)) { + return; + } + pbdev = s390_pci_device_new(s, dev->id, errp); if (!pbdev) { return; @@ -1167,7 +1177,10 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, int32_t devfn; pbdev = s390_pci_find_dev_by_pci(s, PCI_DEVICE(dev)); - g_assert(pbdev); + if (!pbdev) { + g_assert(pci_is_vf(pci_dev)); + return; + } s390_pci_generate_plug_event(HP_EVENT_STANDBY_TO_RESERVED, pbdev->fh, pbdev->fid); @@ -1206,7 +1219,11 @@ static void s390_pcihost_unplug_request(HotplugHandler *hotplug_dev, * we've checked the PCI device already (to prevent endless recursion). */ pbdev = s390_pci_find_dev_by_pci(s, PCI_DEVICE(dev)); - g_assert(pbdev); + if (!pbdev) { + g_assert(pci_is_vf(PCI_DEVICE(dev))); + return; + } + pbdev->pci_unplug_request_processed = true; qdev_unplug(DEVICE(pbdev), errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) {