From nobody Thu Nov 14 18:02:21 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=1708432047; cv=none; d=zohomail.com; s=zohoarc; b=ei0HlwiCVp4pT/Jfu7gVmE4p8MnuehsNmz6r4C/X0Gny4S7WtUUjpfyJlZdS/geeqVXYS6m1CBDt8Hb+Tpia9G6/CHzAbSunGKTVj8PqI/DTK4UD0j6en92yyadiQ72WYLXkBvlHlvn2DoUT3ArWVRZMxR2xsfkGjLLxAErQcxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708432047; 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=biLtOdxmw7ScC2PCt1aJFruhA/YjrGKZOxrMI1yTmlI=; b=ZJBvrCN8PgyAeD5JlO7yW1W794DE7xYysSrczcolrew05daGa4cu+5BbbjKbedp3m5V0ENVQJFeZd0W1GQ0IOLEWkiX8ZsQHxx719lvsczvWeqrVaSA1jnnuS6iQMf7GYoFqe0E60igSY9lAi5RzcgsuNcXCMVAvRICcW9/Jgxk= 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 170843204799032.46751805545398; Tue, 20 Feb 2024 04:27:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcPBz-0005Gq-Iz; Tue, 20 Feb 2024 07:25:47 -0500 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 1rcPBY-0004mI-BF for qemu-devel@nongnu.org; Tue, 20 Feb 2024 07:25:25 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcPBU-00063W-FS for qemu-devel@nongnu.org; Tue, 20 Feb 2024 07:25:19 -0500 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e0a37751cbso4037910b3a.2 for ; Tue, 20 Feb 2024 04:25:12 -0800 (PST) Received: from localhost ([157.82.203.206]) by smtp.gmail.com with UTF8SMTPSA id e15-20020a056a0000cf00b006e3be1a64f7sm5307286pfj.160.2024.02.20.04.25.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 04:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1708431912; x=1709036712; 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=biLtOdxmw7ScC2PCt1aJFruhA/YjrGKZOxrMI1yTmlI=; b=VjwJj5kIkR2kjIfh5lYZ50vdGlTw8DawN5uR4UFtFlRNA5IOBIVQsgrn9cvp5C5Tj+ BTtOmKsABFLqQhvn1bf4MOo4VzoNwbQFMpJECwpAUxo4pAko3RaD8Y0CuxYPdPiPjQwf r5pCgq6DSlIHPbJuDUWZA3lo8xH+Gii+bjTarZ/qDJtsWLmhqKZgaSCgewqIUXVgDGzK +t3Xjpj2p0TXTZ34P+OH9subBwBjxr1WGneE9wKCdvAdNljWoJHFvYOrPUGRCWqLgp8S qRNG73Vse2dtdrgd+eT9E5m18c0zqBiVlIhi/xEbnL6GJXgnSqnFvThYTOxBtYBDBy4/ EFUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708431912; x=1709036712; 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=biLtOdxmw7ScC2PCt1aJFruhA/YjrGKZOxrMI1yTmlI=; b=DuF71DdB+o5esWO10CSltCsPtnRPA4C8zKUdYSiEk3Xq6BE9nC/FTloum7IkHhOLty BnBHgKFdS/7KYww8ZWrDtpR1+5c9EFIhTC/pSkrouX8nWgNIADhL2axHHSzl3MGozurO 3YA3c+LoKKCJo0ZPDHHkpZIdxP+c/Ra2h7p2dEboa5BNXg+rVPkti/VA78/p7CxXeRdh uor+PYN3rPduVFwYwxTcAhK78FTg1phxfIVHz4KUDDhZtNA9drHKZcX6b78HbYUpbc61 cgoLn8rKY56i5ele90u3/Rwqldwvx16NNQiztB/fNgRqoV8msp2+4vOzgE+Mkz2lrbdM E5jQ== X-Gm-Message-State: AOJu0YxjSRfu1PtcYOPTV2nGy/SqV3BUGfpGWxnX7A1xLSI1e9Sc4V6b EA3DpFoH1u6PDMXw3tQT1V0MRfQAoiZnS0sOjyLO0xdlR+Dds7rWC9tu9uNXhcw= X-Google-Smtp-Source: AGHT+IES+twjYRRKeqDkEtOEzECODUkMY2tZfJ1LeuaMTcvfj+JuwKZpyMJ/r43rirvCktjAABWh6A== X-Received: by 2002:a05:6a21:3401:b0:1a0:9115:48c8 with SMTP id yn1-20020a056a21340100b001a0911548c8mr7658665pzb.51.1708431911994; Tue, 20 Feb 2024 04:25:11 -0800 (PST) From: Akihiko Odaki Date: Tue, 20 Feb 2024 21:24:41 +0900 Subject: [PATCH v6 06/15] 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: <20240220-reuse-v6-6-2e42a28b0cf2@daynix.com> References: <20240220-reuse-v6-0-2e42a28b0cf2@daynix.com> In-Reply-To: <20240220-reuse-v6-0-2e42a28b0cf2@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 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1708432049860100003 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 eaa3fc99d884..6c92b2f70008 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -642,6 +642,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 d3dd0f64b273..d57f9ce83884 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -56,7 +56,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 e7a39cb203ae..8bde13f7cd1e 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); @@ -2811,18 +2811,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.43.1