From patchwork Sun Jan 12 22:17:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 856797 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1179438wrc; Sun, 12 Jan 2025 14:24:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX5Bx7UeP+XckZng3iXO0GU4x47EVhMGvC21fqQrNp42kWUVBdqcAc80FLQ4PXKQpQkvbnMQA==@linaro.org X-Google-Smtp-Source: AGHT+IELHa1PNb6kjh48gY1IcHiBqH1u/6hL2rjMDwcYfiAcbZYFZPKzEHHmCUu4SfcyJJzudUab X-Received: by 2002:a05:620a:370e:b0:7b7:142d:53c4 with SMTP id af79cd13be357-7bcd97a71f6mr3529657785a.54.1736720639964; Sun, 12 Jan 2025 14:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736720639; cv=none; d=google.com; s=arc-20240605; b=Tog/DKm+q+uv7MoshIe6qCV6lRa2iLlebe50IzA1fceQMnVERI9UoPBix7SwHoELNf YDgiye9b+hHcCcsmNK2Yn8lDNdA6cVIsY1BgJOZhmT3qN//l9eLqoNPdAsdE0RHtSU1Y Pr3qIBAu4PqMvVigrEx8kHWMcSF4wolC96YtQQskP10H06Rkjzx+P0cXzoRBHd84qTED fyyFb/W1iFV/3iMnls94gVQ1QDkV72s8ojCdxU8q9M7ERQv/HDnvodVGlGOcE0mRl0iG 5wzAarG3MdR2LKHdYDzQr1xN9KLIO3YxAIezvkxzzCpVmH6Y+qlhQEidV8XhgKW90TM0 OFUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1OAhYKzZLI8lTOKGbMAAzPTEW29D2+vTIYkkz2t6RXA=; fh=XFr5VEWnexyeyL31SttPR8eP70bUFi12UNF9+gSdaQ4=; b=bKIVJLTrAAAceTGYVRJhVzDsET4p3a6X0uc0HFVla7ASCRXHQ8Rce9BytIkokpLXXX EV0BBQXXnTAJtIwO0kMdxhfdpcJHP4XeTB3R1NtieOzH8iYbkuA9+e/UcTBnHQk++epv GRj5ry8Am4Z+kr37qrGw+I49jICFb5GjtN8cerBUDSHj/51FzqeX3p+j53ztsN3a6cC6 wMIEDXjPvUeqMXI5WgDEuhbgwho32wrOMnzrHaLkbASWUeDNeZ7Aj4njRz0KWVGJWdQx HDiBywY/xLaFMhWcwGutMdCs4JB63MTp/gEj4+nB3NGUUQFbOvzWFbNcjGexq/F6DDst 3wHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N9TWEKQ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7bce34fddf4si927371085a.421.2025.01.12.14.23.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Jan 2025 14:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N9TWEKQ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tX6JY-0002tX-HU; Sun, 12 Jan 2025 17:20:16 -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 1tX6It-0001a3-5T for qemu-devel@nongnu.org; Sun, 12 Jan 2025 17:19:32 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450: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 1tX6Ir-0006Xm-9c for qemu-devel@nongnu.org; Sun, 12 Jan 2025 17:19:30 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3862d161947so1872219f8f.3 for ; Sun, 12 Jan 2025 14:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736720367; x=1737325167; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1OAhYKzZLI8lTOKGbMAAzPTEW29D2+vTIYkkz2t6RXA=; b=N9TWEKQ5OLf4BHLDsx7zWwTtQSGqAMhAGaVDlKJmJh5SVRH5Lfbypn1Fi3mhWK3Bnz 2k7vqFwmAP14gQnNNFeNtxKGLLzSQ5lpabaAdtcH4WtzyJnKq7N83faCuxYWLCgA/dwh M54EHDgmZ2NIWReuqci0Rk4Me9jvrWBAmB5iyX+x89NZB2OLGQ9xqzUooEqA2vFUM6j8 jYkGgCGvtCyIjX5MbU7rACZy6r9KxSQQY1o6kiAtCe/DbILQx3+3EtTYM1V2f0Yjaosd FNqtdYEAHhqrTtqCMm4tzUZkfqYdmZpHTG4LTPhwkY6cdeqWlWin8i6BIXEaJ/tAzGq+ C0kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736720367; x=1737325167; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1OAhYKzZLI8lTOKGbMAAzPTEW29D2+vTIYkkz2t6RXA=; b=mCFJHcT+UuDbYxK+ITs1XLqdI9HCRM1XX5x99ju45wpDWnqTVwES+Bdk4ezQGHmxJq azgqjXAnFOR9iJUth2xrpqGnwPoIVnX55AIoMIa9AzyVzfS87E/aK7s70qBupfXmswb5 FnU7UqfyEHuKkEuaQ+J0AInn0xd4/RQVUY5e69vyo3qceQ7xqZWvnJL5PtTodJZA+o7P sccjEIWUwRc/HoX8HuhsyXuS/XlkO7Lds/8eA2ifqZV7jnwY/bw1/IMj32MkNNAj9mr0 EZCVJObKPV+hshXP+vp75W0ScIMf344NyjbVhQbJfSRRhndJ/dJUB+1V+ks6Vk7Zr3OJ AFcw== X-Gm-Message-State: AOJu0YwpDAKTrzZIh42RSP6IzUxMBJ/Fs2vmQteo2Nqngh0gMMAiNXGr RZMA7w0i8et6Pvn7AcLmDJ177YoDc5tXN6ZFBq/O6WKflhXsK+fQLf3YgJVCGgebLH462G7h111 EocM= X-Gm-Gg: ASbGnctBJRgbZs/MPOV0sdpYxJBWKmXX3RMybPYOeoXMUyVTYtB2Q7AZW12cgSGPK07 S57ijYVXlLVeIVZo7DymdY11lNi73AWeUbXRBrW+Nv5sD1k1KrIPypHG20Xnmc3eaE9F38Ut1FQ uRCUTt76b7AdC+/U5OfHsGAgh9P2K+rqP6OFori03r5mdu82Gqw5YNQJlPBMpOniPzPwDQ9MGtT M8+9IKY4L0C8Vc/k6wN2+vbPd23LAyupLaDCD/JqS3bVm1mG25ew0YcN10PShJrn0yDuUG+rp2S EXsnibG2B+AfIiH07Cb/x5MibFXRVnA= X-Received: by 2002:a5d:59ab:0:b0:385:fa26:f0d8 with SMTP id ffacd0b85a97d-38a872f6af0mr15624682f8f.8.1736720367214; Sun, 12 Jan 2025 14:19:27 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c1dc6sm10636757f8f.96.2025.01.12.14.19.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 12 Jan 2025 14:19:26 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL 24/49] hw/pci: Rename has_power to enabled Date: Sun, 12 Jan 2025 23:17:00 +0100 Message-ID: <20250112221726.30206-25-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250112221726.30206-1-philmd@linaro.org> References: <20250112221726.30206-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki 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 Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250109-reuse-v19-1-f541e82ca5f7@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci.h | 1 + include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 17 +++++++++++------ hw/pci/pci_host.c | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index cefeb388bde..4002bbeebde 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -674,6 +674,7 @@ static inline void pci_irq_deassert(PCIDevice *pci_dev) } MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); +void pci_set_enabled(PCIDevice *pci_dev, bool state); void pci_set_power(PCIDevice *pci_dev, bool state); #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 16ea7f4c19b..add208edfab 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 78907527f2e..2afa423925c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1598,7 +1598,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; } @@ -1686,7 +1686,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); @@ -2963,16 +2963,21 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int vector) void pci_set_power(PCIDevice *d, bool state) { - if (d->has_power == state) { + pci_set_enabled(d, state); +} + +void pci_set_enabled(PCIDevice *d, bool 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 4510890dfc1..80f91f409f9 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; }