From patchwork Sun May 4 21:56:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 887223 Delivered-To: patch@linaro.org Received: by 2002:a5d:430f:0:b0:38f:210b:807b with SMTP id h15csp1767393wrq; Sun, 4 May 2025 14:59:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKP2kNYmSymVLow/lrNmn5lsi4JrWswY3RtfEOpobyk09VJto1JuoraANyvaW2LT6GdtReHA==@linaro.org X-Google-Smtp-Source: AGHT+IF/kpMZ0T+RBu1nUu7rEIsRu7JpDuKgwsN+7RUx6FEMYS2KfDUig6SOQAUr9/yQFmlGL6EH X-Received: by 2002:a05:622a:11c8:b0:477:1edc:baaa with SMTP id d75a77b69052e-48dfeff48demr82543191cf.6.1746395958862; Sun, 04 May 2025 14:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746395958; cv=none; d=google.com; s=arc-20240605; b=RTPKOc0T/T5PKhgGMKxXgTnmTH9g2ojK4wkHRC+dRxAMMmwKG2TEzcl7fi5sH/NcpH SbW7qoF1cHbJUhspC/IpHF9Jez0aRmgqJcMbyohcajHL/ruSAOJQEg5/1jUpdUmtljTo uDXymuPv/DA100stBn9OU5a45KqszyPjXykKrkAymNgt9yfPmgHtQYCdYdatCWhfN5/2 NGpOMG/FMfDjJEF4+RJG2hR55bWamL5qW3kM6FOPseBfBB0udNiR6kWJgP/rn61wg7w+ /s2MgJ7jSTDx0hixgOpyabAucz5Aw4bqK/i5uj8o7RFTYa2RuDJ6uU7fs+qHgwihB0/9 IEkw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=Fwa6vL14YZTfst2loVGLMHYQVKFZcNKU8l3yQjztZTQ=; fh=Fwi3q9EbXc3ZtmrTDB48CrbzpMgTdqkfDZWEKzWlLvg=; b=GNvsCRCFM/vl9h1XvSNzyYmx63BHpQnGw2xnqvsaA1OnmxT+FeWjSRu9zPmV54AF3/ vRrAseJrvzP0Uef7/k11MCZqTblgsHwBwnZx47qNFXCfFRasTzKNmo/2UZG5Y9UeKtyR FqPiEO8+UwXPpnN6S1S8x5vcNp5k0NpmStRbMyWM9QPvhX9v1PJaiKiE8dzn8JwVn6sE yfAysLa3dBioT/Ylo/gu20EG4AGOe2CHmSBQKMxd4+3Y+SpD7ipgizrNs1/W3CjfNALF 7xlykAU36MPZOkWi1M226+I9S5l6LR6JmjTwfB3WV/KMyrwAKv324ULtZ1XZARU6pU+7 50Tg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pmJUQiSx; 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 d75a77b69052e-48d5a29c346si41706661cf.524.2025.05.04.14.59.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 May 2025 14:59:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=pmJUQiSx; 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 1uBhLJ-0007Ox-0x; Sun, 04 May 2025 17:57:49 -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 1uBhLH-0007Nq-C6 for qemu-devel@nongnu.org; Sun, 04 May 2025 17:57:47 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uBhLF-0005Ac-HI for qemu-devel@nongnu.org; Sun, 04 May 2025 17:57:47 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-22c33e5013aso38879885ad.0 for ; Sun, 04 May 2025 14:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746395864; x=1747000664; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Fwa6vL14YZTfst2loVGLMHYQVKFZcNKU8l3yQjztZTQ=; b=pmJUQiSxXFsAnEGLrouWwFlwbX9g9bL3IecR4U385nF7NIRq9j/1+bMFlKldGAdAIC p3q8ZR40xVqogHJF4TqR5ztfqsFB5FprYRl6q5olQcjQQgoh7tPF4yOqJmGgzlr1+c9G lCT3i9sUhTvXG2QGCG65lBpMGEj2ctoa/JLNv3nv7620RNimSHSETbZheayU404YSO1I 7P8UgCokiPw9TtZ4NGirTwZwAcecnbLsgBSeHw8zk6EDGh6LZB/zUEVVLtRyiMHBvyZ8 rM7KAM1Jnz1MSS2gRmP2s+IFGXaFOROQBqCgS0mPm+Ao/DN0APTE/XgjmZ6gfZ9wWV/W x1PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746395864; x=1747000664; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Fwa6vL14YZTfst2loVGLMHYQVKFZcNKU8l3yQjztZTQ=; b=ZBqtGuoILqRYpBcDWz3o2qYSSKY5IXiIT1Vyoi5RHZEqsIaQRzqgxzPwmk3smF6iXP IN+ajwuA8JjcJL6tdJlpAwcThxDwJnV8AFDZcAkSJQDseWe1zXKqyN70j9cGpg+df6IB JsRe2m8P4JSKYosVLR1yOcRvOwHpYGRtNk+oHFv6GAbazL+fcGgOB/tWYzzK3P3FbYsJ umS57hoK3Wq0Ze32IQeIXkvpKZqhqNw6Y+HTyVSKeIdu5h7WiFiHXVDkg7Asu8avxC0b lGMTCt0i5etVbvu0VtPd3fmRaXVusLEBJ00WwG+mLywpCKyN3RIyTlhCaA8o0vBLi76c KxQg== X-Gm-Message-State: AOJu0Yw7JyVjbDq0g2C9VKBi1xT95/qO7046zmJGq+1pMflgeacZ/FaG 1/XFz2niWm9L3V7Kybg3C/wb8leuaU8UeN80XwYIb12r9DFtnHXuiEpEekuYxgHSdQjmVdJr8MB pelU= X-Gm-Gg: ASbGncsAROQnTZSPaR2W0gb75GRFamjGw46Ny2P7SNDzze4T3mM/ojI5Lx5UwT1ZMdo frhpBsmdbUx+dzfOSGL6m1xXwyuUp7zSWjZBoflS1njifQjozUygCcc7NwqINu6nQ918mteMnVa AVOGGogB163EE7trAa2mupgLGfITVQ4Q9rRZS9BB/7vFq5q1H2X+mc8XgLbGBrqt2rwSGH5qgZg QR6dg6Ye1pANRiL+iSyN54xUOOle0mcbqcZM05jXh2qfbmDqPvsqeOyUCnH53UV303z5wQEdek1 qT3/4DJpqvzjXxJv3iRqBedp/x96zQLoA/KPrAxuFfyrrbHh X-Received: by 2002:a17:903:2b0c:b0:21f:2ded:76ea with SMTP id d9443c01a7336-22e1eae4269mr91622705ad.36.1746395863786; Sun, 04 May 2025 14:57:43 -0700 (PDT) Received: from gromero0.. ([200.150.181.215]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22e152204fesm41664875ad.137.2025.05.04.14.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 May 2025 14:57:43 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, philmd@linaro.org, alex.bennee@linaro.org, gustavo.romero@linaro.org Subject: [PATCH] hw/pci/pci.c: Turn DPRINTF into trace events Date: Sun, 4 May 2025 21:56:30 +0000 Message-Id: <20250504215639.54860-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x62e.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=unavailable 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 Remove PCI_DPRINTF() macro and use trace events instead. Signed-off-by: Gustavo Romero --- 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"