From patchwork Fri Sep 13 03:44:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13802972 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 9C4BEEEE27A for ; Fri, 13 Sep 2024 03:46:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soxFD-0004Z1-7s; Thu, 12 Sep 2024 23:45:15 -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 1soxFC-0004Vn-BQ for qemu-devel@nongnu.org; Thu, 12 Sep 2024 23:45:14 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soxFA-0008FU-KC for qemu-devel@nongnu.org; Thu, 12 Sep 2024 23:45:14 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2059112f0a7so3765585ad.3 for ; Thu, 12 Sep 2024 20:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1726199111; x=1726803911; 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=FgOxw6et8+pj5F2p1F6QQep3GannhEQmn82AQXkbvpE=; b=drPuds6t4G6qjD+kFV1Ix6djApEvKDh8s/16ObHjJw83y73ey4Wb8lIrrU52r/omBl gjDQppSIsANxCRSEfa0ZoaM085U1Q5n/CWBFyzv4Ujta32SQ6XN3jGDxSh2oMnILctJY XOda0oMkJ4uaKSCg5CV872KCpANvtCdvocz5bzVCkYfTZeMmnBXOE1FYpao/kAsOd8oA HmtcTnF6DMSYc+se1iTlv0fdRVWnR2ygUbJz0T51m9rJ7G8BHhG3XA7Nnjk2WARXLohE t/8ZijQwAS+8cvxKEscn7ydWEPv3HjemDS8Dpu8Ys0seiOC8KwFaZltXDu5A2MqYHo7I nqYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726199111; x=1726803911; 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=FgOxw6et8+pj5F2p1F6QQep3GannhEQmn82AQXkbvpE=; b=JLw3ni/IB6URmUkQELINY7+oLBpZaZN1Zqemf0QWWipfOYOH5Q6MpHF+YK8w2M+CuM g7Pi0Gq5NJNtBHOihLxyNEOI3YjA45cKSUgihVx7YE07MjwlUkNjIkGdHqv2pvq1oYOm 35DLYbEJGsrLxcqFg6ON58PdTnrNItfr3BRFcnRU1zmdwJpJDKkzpN12hNZlaV7bGwcX a/hxlYiJZmalj7F4Xt/I/gUzQ+aCHCTlBmzc0S6q15iBl0ssn4n8xEUCvZei6wY96rNQ USM34feUfXTR85sW5tsvlInhBN3/9G63ewd7El92MVQWqHPMMPrtbU5UN8ps7zBLbaom O1mA== X-Gm-Message-State: AOJu0YwCWZk6telOHF/yQ/Ct2tYT5uVYwIMu1wzQpGa/3Jk9PPVc8I8o 1lzOg6phAsmBvvQPAUZPoj+BAUwl93dI1Dyf6w5jO+xIklTGrlu3AfVRlkCzlVM= X-Google-Smtp-Source: AGHT+IECMOqMzkhyw7zOjDUJJapN09wVaeNCGst9cBYdEBU8bjlfEGsR5+Dlj6qfaz5sp7jHmZ8FIg== X-Received: by 2002:a17:903:444c:b0:206:8c18:a538 with SMTP id d9443c01a7336-20782a69a99mr18064105ad.32.1726199110659; Thu, 12 Sep 2024 20:45:10 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-2076afe9a83sm20401465ad.217.2024.09.12.20.45.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Sep 2024 20:45:10 -0700 (PDT) From: Akihiko Odaki Date: Fri, 13 Sep 2024 12:44:34 +0900 Subject: [PATCH v16 06/13] s390x/pci: Check for multifunction after device realization MIME-Version: 1.0 Message-Id: <20240913-reuse-v16-6-d016b4b4f616@daynix.com> References: <20240913-reuse-v16-0-d016b4b4f616@daynix.com> In-Reply-To: <20240913-reuse-v16-0-d016b4b4f616@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 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::634; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x634.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=unavailable 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 The SR-IOV PFs set the multifunction bit during device realization so check them after that. There is no functional change because we explicitly ignore the multifunction bit for SR-IOV devices. Signed-off-by: Akihiko Odaki --- hw/s390x/s390-pci-bus.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index eab9a4f97830..e645192562ae 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -971,21 +971,7 @@ static void s390_pcihost_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, "this device"); } - if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - PCIDevice *pdev = PCI_DEVICE(dev); - - /* - * Multifunction is not supported due to the lack of CLP. However, - * do not check for multifunction capability for SR-IOV devices because - * SR-IOV devices automatically add the multifunction capability whether - * the user intends to use the functions other than the PF. - */ - if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION && - !pdev->exp.sriov_cap) { - error_setg(errp, "multifunction not supported in s390"); - return; - } - } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { S390PCIBusDevice *pbdev = S390_PCI_DEVICE(dev); if (!s390_pci_alloc_idx(s, pbdev)) { @@ -1076,6 +1062,18 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { pdev = PCI_DEVICE(dev); + /* + * Multifunction is not supported due to the lack of CLP. However, + * do not check for multifunction capability for SR-IOV devices because + * SR-IOV devices automatically add the multifunction capability whether + * the user intends to use the functions other than the PF. + */ + if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION && + !pdev->exp.sriov_cap) { + error_setg(errp, "multifunction not supported in s390"); + return; + } + if (!dev->id) { /* In the case the PCI device does not define an id */ /* we generate one based on the PCI address */