From patchwork Tue Oct 22 08:36:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13845302 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 B000ED1CDB6 for ; Tue, 22 Oct 2024 08:38:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3AOF-0001O8-Nc; Tue, 22 Oct 2024 04:37:19 -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 1t3AO5-0001Li-Q5 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:10 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3AO3-0001RR-Ci for qemu-devel@nongnu.org; Tue, 22 Oct 2024 04:37:09 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7ea7ad1e01fso3583668a12.0 for ; Tue, 22 Oct 2024 01:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1729586226; x=1730191026; 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=Fw3oQA7+IEOjChncnUMV1961OLXeMOoul99vLyfGf7Q=; b=jfpx2CBTxyFCPYwBDX8FgyBFwCEakMeBVhCGneyXbAZ00a3UfqM16vFP8uGRjFgipj qm2rV9vA27rB2rFRYqmcl37gJvudljG4+5JsMTGvDVwfmK9Ig//pbl0OcqJshr6ma+Ed /JjVVaarv5XWO0PWnfqB2MIYC6xjUvdXEYBuzTtszyPXNe/lgPZ7y7cz6LAYy1Wto4Xy 1WinUyNzmORwDpgBVQdHm0RHzZ18y3+yjo81jeiBcUqb6pktQhZZNtc6jpuadUvCz+x/ OuotoZqKUBYK0TwR3gNHDZgHssc7tYmiBLTWl14RcEsRHTs23VWNP7XYq/9RAfOd9H54 IIhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729586226; x=1730191026; 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=Fw3oQA7+IEOjChncnUMV1961OLXeMOoul99vLyfGf7Q=; b=h5Q8K4M9qdUTEI7Ysj9i4gCbm6iFh2TGoiL4fOHdUrzbuu+VDupwcbou82rI3tvuhF /BlOIgJvTMXjmKgjZhZxBK53r42ybFfANwIz8mSqiApZwDcjQil7c0lNpi2fYy1yolTn S4z/fu9fE1piisNSLiXRJSD7K+DL8x/NI0Yfr4KuGj+pQmOR4ZjSl87ygQpgkF+ZuMIm rLC2QVhVG1zT/Jjlh0/xiad22keiTArSFNIU3eypC06AXQ/AV0RJSscqfyONrQNthlk0 0aZIlgD6DDx0wKDKJSZ9rOVro357j/UHeYebdCaTiYdWHYphQbfpPZxfAhWlOpZsZ1dg 0Q/A== X-Gm-Message-State: AOJu0YzNgLj+bYvCYGU2WQX7LzPBfUb4YHcXAD1uvDjjq3XgXz+a9gEl d4XTh9rFTZ2l8PeDfeOd0Wt8ej+JJOlRx7mG/tG1wqulSs6wS1SYK/zwOEZCC4Q= X-Google-Smtp-Source: AGHT+IHHDLBoOC7WiWvMBKOAtm0/pnpL/hUil7P+gHM84Funoh9qSdo0Y93DSFItUquvHH8HioX4pg== X-Received: by 2002:a05:6a20:4c1f:b0:1d9:13da:db15 with SMTP id adf61e73a8af0-1d96c41aafamr3462268637.24.1729586224673; Tue, 22 Oct 2024 01:37:04 -0700 (PDT) Received: from localhost ([157.82.202.230]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71ec141b799sm4191782b3a.192.2024.10.22.01.37.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Oct 2024 01:37:04 -0700 (PDT) From: Akihiko Odaki Date: Tue, 22 Oct 2024 17:36:38 +0900 Subject: [PATCH v17 01/14] hw/pci: Rename has_power to enabled MIME-Version: 1.0 Message-Id: <20241022-reuse-v17-1-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::535; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x535.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 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) } 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); +} #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 91df40f98973..cbc42349d561 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; /* PCI config space */ uint8_t *config; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 87da35ca9ba6..eff408b4e9f4 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1530,7 +1530,7 @@ static void pci_update_mappings(PCIDevice *d) continue; new_addr = pci_bar_address(d, i, r->type, r->size); - if (!d->has_power) { + if (!d->enabled) { new_addr = PCI_BAR_UNMAPPED; } @@ -1618,7 +1618,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); } msi_write_config(d, addr, val_in, l); @@ -2893,18 +2893,18 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int vector) return msg; } -void pci_set_power(PCIDevice *d, bool state) +void pci_set_enabled(PCIDevice *d, bool state) { - if (d->has_power == state) { + if (d->enabled == state) { return; } - d->has_power = state; + d->enabled = 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, 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; } @@ -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; }