From patchwork Wed May 7 18:03:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 888078 Delivered-To: patch@linaro.org Received: by 2002:a5d:4683:0:b0:38f:210b:807b with SMTP id u3csp513887wrq; Wed, 7 May 2025 11:05:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrN3kQE7PMZlQs+Y3/tLNgzUzjUHTtqV5uqUa0dEHHog7TY/uEezVMIfkyd05Dqj22ywKDAQ==@linaro.org X-Google-Smtp-Source: AGHT+IGjVftV+y/QQViLJYS3yDB8AKzqkXJMeEkEAZOxb2u9nTuvysNeDBY5oeoNtsTs/qZiXcTO X-Received: by 2002:adf:f502:0:b0:3a0:b550:c6f1 with SMTP id ffacd0b85a97d-3a0b550c6f6mr2890026f8f.9.1746641111039; Wed, 07 May 2025 11:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746641111; cv=none; d=google.com; s=arc-20240605; b=Pus4vA5I49gPeK89g4SaSSOg/0+5jSyE0BHnq5FPJggq/SOH0tNpIXOu5g1LrDAQKM wVNEvI3iFL9xbPTZnq6LHZKtG5Qn80qJvgGpvNvQhwA71elR4NL97aO5vNGa4X+xkS7E 5AlTBMi9Gpmzs9eIgwmwB5pG6XUVB3eJOHP/1uvLZMQNjSXviBbQJq1pRQNuJyx7z+up BT2+OV4AU6dNDtbnA8bDJFom4rjzcAlrBAL2tnbdiEq6LfEYKUEg0Ru7BviP7LxTyixi UM+XtHKzBY+p2xIAkvywICuTvsF+PKoSh+Ul0TVqAIsT88OPz+32UttIZXzGHeCjme5M 0RmA== 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; bh=+FmINfEuzwMzGHrtY9oGOYa+RnnhD8jDDpsSsdmEKc8=; fh=IwCXGV4wPY6ObB9cIuDHqEqMPAzAKMp05WxPgfySCiA=; b=kSstCxuvqpa1kNqw02oK/CqIWfhiKnukNGx6GcBexMk9SSx4anE3XkVE52MMxHDyyo l+AqnVGiYs0MWvRXTE+qz8I4be2gLRMyJhPwkvMLMc8wPzaNwz04FunQVTTNdeyHnB6x WHAq2L9GexuuKCbqjWJjoTgeuJepJXUSN/hH9MTyW5dDKm7Bkot8dqySFGe/uDRHt6BD DOPeePLLQoXpRi9tUXghk4a9KUA+hbMM82lFBlQlmbBTFajxAZhSjNl0S7sX0vSuF96k znmuSERMcvAx1h4TFGGNwIZ/tl+gGfAzZn6wlVHlHnzFPcTJNpq84mu7kiZ2xmgPmzQ7 Tnbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-3a0b37afcb5si2252245f8f.404.2025.05.07.11.05.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 May 2025 11:05:11 -0700 (PDT) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uCj86-000889-5i; Wed, 07 May 2025 14:04:27 -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 1uCj83-00086t-AZ; Wed, 07 May 2025 14:04:23 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uCj81-00089l-Ct; Wed, 07 May 2025 14:04:23 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E112811FEF7; Wed, 07 May 2025 21:03:59 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id BDA7A2066FC; Wed, 7 May 2025 21:04:12 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: Gustavo Romero , qemu-trivial@nongnu.org, Michael Tokarev Subject: [PULL 02/21] hw/pci/pci.c: Turn DPRINTF into trace events Date: Wed, 7 May 2025 21:03:53 +0300 Message-Id: <20250507180412.182797-3-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250507180412.182797-1-mjt@tls.msk.ru> References: <20250507180412.182797-1-mjt@tls.msk.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: Gustavo Romero Remove PCI_DPRINTF() macro and use trace events instead. Signed-off-by: Gustavo Romero Reviewed-by: Michael Tokarev Signed-off-by: Michael Tokarev --- hw/pci/pci.c | 19 ++++++------------- hw/pci/trace-events | 4 ++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fe38c4c028..352b3d12c8 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -54,13 +54,6 @@ #include "hw/xen/xen.h" #include "hw/i386/kvm/xen_evtchn.h" -//#define DEBUG_PCI -#ifdef DEBUG_PCI -# define PCI_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) -#else -# define PCI_DPRINTF(format, ...) do { } while (0) -#endif - bool pci_available = true; static char *pcibus_get_dev_path(DeviceState *dev); @@ -2439,12 +2432,12 @@ static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, uint32_t size) /* Only a valid rom will be patched. */ rom_magic = pci_get_word(ptr); if (rom_magic != 0xaa55) { - PCI_DPRINTF("Bad ROM magic %04x\n", rom_magic); + trace_pci_bad_rom_magic(rom_magic, 0xaa55); return; } pcir_offset = pci_get_word(ptr + 0x18); if (pcir_offset + 8 >= size || memcmp(ptr + pcir_offset, "PCIR", 4)) { - PCI_DPRINTF("Bad PCIR offset 0x%x or signature\n", pcir_offset); + trace_pci_bad_pcir_offset(pcir_offset); return; } @@ -2453,8 +2446,8 @@ static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, uint32_t size) rom_vendor_id = pci_get_word(ptr + pcir_offset + 4); rom_device_id = pci_get_word(ptr + pcir_offset + 6); - PCI_DPRINTF("%s: ROM id %04x%04x / PCI id %04x%04x\n", pdev->romfile, - vendor_id, device_id, rom_vendor_id, rom_device_id); + trace_pci_rom_and_pci_ids(pdev->romfile, vendor_id, device_id, + rom_vendor_id, rom_device_id); checksum = ptr[6]; @@ -2462,7 +2455,7 @@ static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, uint32_t size) /* Patch vendor id and checksum (at offset 6 for etherboot roms). */ checksum += (uint8_t)rom_vendor_id + (uint8_t)(rom_vendor_id >> 8); checksum -= (uint8_t)vendor_id + (uint8_t)(vendor_id >> 8); - PCI_DPRINTF("ROM checksum %02x / %02x\n", ptr[6], checksum); + trace_pci_rom_checksum_change(ptr[6], checksum); ptr[6] = checksum; pci_set_word(ptr + pcir_offset + 4, vendor_id); } @@ -2471,7 +2464,7 @@ static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, uint32_t size) /* Patch device id and checksum (at offset 6 for etherboot roms). */ checksum += (uint8_t)rom_device_id + (uint8_t)(rom_device_id >> 8); checksum -= (uint8_t)device_id + (uint8_t)(device_id >> 8); - PCI_DPRINTF("ROM checksum %02x / %02x\n", ptr[6], checksum); + trace_pci_rom_checksum_change(ptr[6], checksum); ptr[6] = checksum; pci_set_word(ptr + pcir_offset + 6, device_id); } diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 6a9968962f..02c80d3ec8 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -6,6 +6,10 @@ pci_pm_transition(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, u pci_update_mappings_del(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64 pci_update_mappings_add(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64 pci_route_irq(int dev_irq, const char *dev_path, int parent_irq, const char *parent_path) "IRQ %d @%s -> IRQ %d @%s" +pci_bad_rom_magic(uint16_t bad_rom_magic, uint16_t good_rom_magic) "Bad ROM magic number: %04"PRIX16". Should be: %04"PRIX16 +pci_bad_pcir_offset(uint16_t pcir_offset) "Bad PCIR offset 0x%"PRIx16" or signature" +pci_rom_and_pci_ids(char *romfile, uint16_t vendor_id, uint16_t device_id, uint16_t rom_vendor_id, uint16_t rom_device_id) "%s: ROM ID %04"PRIx16":%04"PRIx16" | PCI ID %04"PRIx16":%04"PRIx16 +pci_rom_checksum_change(uint8_t old_checksum, uint8_t new_checksum) "ROM checksum changed from %02"PRIx8" to %02"PRIx8 # pci_host.c pci_cfg_read(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, unsigned offs, unsigned val) "%s %02x:%02x.%x @0x%x -> 0x%x"