From nobody Sun Nov 24 14:49:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1722852152; cv=none; d=zohomail.com; s=zohoarc; b=a29S4HvNUVPC+VtEt2a0OtiBdA3S7LopQgMc0EUH2BWmDLM4wIg4DuR6FmK799cknZS3yrIDilbkB8X2I3ZiM2fuBUG2qs/2CxqeGY0/6fhb0P/43XWe2Ljhrq/m3ALkPcXvz4fw5643EwT5E43rvRC2gbn5lVZaRrWep4Cjots= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722852152; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=nTtbZC6Yebb0731l6CSK3y3TQNKNQtlJ9n8bZSo3G/FG4y0vPfLA1MBbryf1t4oO0u2ahytTn0ePQZfhY+KoK6yci2Z9AePf29afl8yBhWNx7OdEKpF47liGs2ETHniSLXVrCjhktzRg1fwwI8R9nc6wU5xO+sKF+rmmGvBl4XQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722852152709156.5318471162808; Mon, 5 Aug 2024 03:02:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sauV1-0002wr-K8; Mon, 05 Aug 2024 05:59:31 -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 1sauV0-0002st-GI for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:30 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sauUy-0001DO-SI for qemu-devel@nongnu.org; Mon, 05 Aug 2024 05:59:30 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7b0c9bbddb4so4779575a12.3 for ; Mon, 05 Aug 2024 02:59:28 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2cffb0c4682sm6553710a91.28.2024.08.05.02.59.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Aug 2024 02:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722851967; x=1723456767; 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=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=LtdanKyaCA1Q16fC/xKAHqqM4fDWmr3XMLDol9I5LnM2QW6+Kw3EGRPOKUXmiwEBcs TEkO8VAn2lapgJfpo87Vly5EFAnq1qivj0B4fPpNyQv2wuvaBY0xKLjZZWzDarmclZvs 5/S8SI7pF22m064rLZ+6B0/MHL+NNTiKO0J5btXLYp3ywIXqkO1nXKSOiYn1BwJO402Y n+uEdeEVv4nEyRaTndT1u1iGRsWc/jogIuJS/YZIUdegKIwomQAfUePyh896HhBNeL36 NLMqfpCqoZo6WA0hCa28zoWzajcHYa6jYV1QHxw+qkAYZVh/Kwmisg+BIhzz7YIkKhM1 dESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722851967; x=1723456767; 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=8641KY8iAUQPaIzKnmIv+VtshKd/QMdL5rBm/qrvkYc=; b=WX7qmbNURfkaZL3YDtIoAp/LLUVG/pZDYKLDa6l5pK8B6a6Z6HP48j0o6CVecuxCwC 4467QusTsVyfoLQ5CL8VTnEzRjPa28U+usGL0xv65vnxmbyGyP/oS7fNSYUJHPFH2d7R IqMS9wR2A2T7xqpqWVWhd5ZLkcsOn/TdwbblgOvLiAV7hTasDhDznDURxdrdMuABA1qA v91IslleoVcyv4NwX+ra9HCzpg10r7+kqmMe4twne2Lfi8/LsZj4yl2kCZGy3t8mPI+8 JrffeSpqStGaGmN9NHS1S4ISPahojcqvsQzulF2EiHBB6U6M53cN3TIjENCbA60fOKQB hQZg== X-Gm-Message-State: AOJu0YxRKaPz4bx+TI5uN1Oi00Xq7I64zfXh6BCSlPY303IR9cW6bepw quEXVFfM5F6dJIE2oI0pfymDXHew4Rub0Ux+asePT/KMxAq5rTvkcFjmj/at+90= X-Google-Smtp-Source: AGHT+IHdnu5ZOKLBGuvVw7c7mRd5SA7aE/PXVzDPlyWMXFEpysfV5eI1Jb+RDBrfS67Et9PC930FAA== X-Received: by 2002:a05:6a20:6a13:b0:1c2:8af6:31d3 with SMTP id adf61e73a8af0-1c699550d06mr11919545637.10.1722851967499; Mon, 05 Aug 2024 02:59:27 -0700 (PDT) From: Akihiko Odaki Date: Mon, 05 Aug 2024 18:58:58 +0900 Subject: [PATCH for-9.2 v13 01/12] hw/pci: Rename has_power to enabled MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240805-reuse-v13-1-aaeaa4d7dfd2@daynix.com> References: <20240805-reuse-v13-0-aaeaa4d7dfd2@daynix.com> In-Reply-To: <20240805-reuse-v13-0-aaeaa4d7dfd2@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_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::530; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x530.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722852154893116600 The renamed state will not only represent powering state of PFs, but also represent SR-IOV VF enablement in the future. Signed-off-by: Akihiko Odaki --- include/hw/pci/pci.h | 7 ++++++- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 14 +++++++------- hw/pci/pci_host.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index eb26cac81098..fe04b4fafd04 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -678,6 +678,11 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) } =20 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); -void pci_set_power(PCIDevice *pci_dev, bool state); +void pci_set_enabled(PCIDevice *pci_dev, bool state); + +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + pci_set_enabled(pci_dev, state); +} =20 #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 15694f248948..f38fb3111954 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -57,7 +57,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; struct PCIDevice { DeviceState qdev; bool partially_hotplugged; - bool has_power; + bool enabled; =20 /* PCI config space */ uint8_t *config; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fab86d056721..b532888e8f6c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1525,7 +1525,7 @@ static void pci_update_mappings(PCIDevice *d) continue; =20 new_addr =3D pci_bar_address(d, i, r->type, r->size); - if (!d->has_power) { + if (!d->enabled) { new_addr =3D PCI_BAR_UNMAPPED; } =20 @@ -1613,7 +1613,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t = addr, uint32_t val_in, int pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + & PCI_COMMAND_MASTER) && d->enabled); } =20 msi_write_config(d, addr, val_in, l); @@ -2884,18 +2884,18 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int = vector) return msg; } =20 -void pci_set_power(PCIDevice *d, bool state) +void pci_set_enabled(PCIDevice *d, bool state) { - if (d->has_power =3D=3D state) { + if (d->enabled =3D=3D state) { return; } =20 - d->has_power =3D state; + d->enabled =3D state; pci_update_mappings(d); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); - if (!d->has_power) { + & PCI_COMMAND_MASTER) && d->enabled); + if (!d->enabled) { pci_device_reset(d); } } diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index dfe6fe618401..0d82727cc9dd 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -86,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uin= t32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return; } =20 @@ -111,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev= , uint32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return ~0x0; } =20 --=20 2.45.2