From patchwork Mon Sep 30 07:34:49 2024 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: 831520 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp1828232wrw; Mon, 30 Sep 2024 00:48:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZBLaQeJxB1yTSBrC3810FYW3q+9L6FtJztdp7mfT8/5j9DVnDJSMK5oJVj43hrqBIqh6VKw==@linaro.org X-Google-Smtp-Source: AGHT+IFlacHafwS/2rK9fGGPTkGAZZr3lkhUhXM0YYqzjIj7eW5sxBDOUhzzTfP6xVNQ4ZBT4rRl X-Received: by 2002:a05:6214:5f0d:b0:6c5:3122:ffac with SMTP id 6a1803df08f44-6cb3b6497ccmr125304236d6.45.1727682516444; Mon, 30 Sep 2024 00:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727682516; cv=none; d=google.com; s=arc-20240605; b=MMxvvhoqL0mzUabN8bSnMrJLh1N7Xmy39Q+PSbd5XaFUqwdGL1idrtSOvU40VEEX7x 5qEHx0Y4UCMAGRiEqNMnb6WwdjQY/9q8BzNjNnm/T2jmuq0XEoUmbrd0k/orn1gvDBfN HqB8h75J4V6FMTVi0pr63aXy6GvOrrDAnpZZL5pWNIStpzLyMPSD+1V6kvFamxtNj8fI JHTP+hlvDBcJDk08WRACGxi98ypLHy5rQHImfd5oxKgH1pJVODZ65ByGC/p3vbZ0M0aP 1ituIh/tEfiNkCvK5KQ8VYBSUxUwUuMQJ1XNAIjIoryJfEC4zmZo1CaayOi7PY25c3O3 OPzg== 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=J3QK0sGMtG8TI1HL5/V5FwLZQoUZnlZNYr8FgmUN/RY=; fh=Wy2Q3sNWPDKxNwELUcZZKTFep4jJmSUk04d3iQNw3B8=; b=hLac8JOxCn9I3UGYeHYi5TmUyFML9DwIjGywndU0IaGbi7Y+51+m7k/A36csIafM97 qkpQxVVRD2aMhd9nWYNUM09rWvKH+nMomXA9e1TjIdsoLSRV4+mj09tzhB6Nlftyyqq1 0XuqchNVwHza/shEbZy92Tbh691ro5+sVB3jLIbTzzgk4Q1rlrD41/PoZtnczGLplmgP UffAt/MPA2FYZBLCw4sezNw5Gyb9ClQU4nr/fL6tsJJyNwLiG3sn+R1ciRDyDi+oYvV+ Z59ymkst5p/3aSvLgUbBiiv2r+ASIuO3nBQ6vit78TuwhCahk9jiBpBB6HrP3DesLRu4 5EkA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gmg7saSj; 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 6a1803df08f44-6cb3b671995si80776196d6.246.2024.09.30.00.48.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2024 00:48:36 -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=gmg7saSj; 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 [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svB5i-0006no-VS; Mon, 30 Sep 2024 03:45:15 -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 1svB58-0006ha-DP for qemu-devel@nongnu.org; Mon, 30 Sep 2024 03:44:52 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450: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 1svB4D-0000X2-Au for qemu-devel@nongnu.org; Mon, 30 Sep 2024 03:44:20 -0400 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5c87c7d6ad4so3757393a12.3 for ; Mon, 30 Sep 2024 00:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727682143; x=1728286943; 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=J3QK0sGMtG8TI1HL5/V5FwLZQoUZnlZNYr8FgmUN/RY=; b=gmg7saSjmuJPt+O7T36M1yCxWkLpwIUlEGmprRhXN8JUGQa2oj1NQO5ZQYYktuMCLz /CAKbT/Qd+b/tUm3G6+gmTearftvZXk46Q6A4lPrOUoLZIyFue78acxJe524U1Rt4eCV 6kP91RJUbYIiAOOuIIzbKgnzu5uTSSAMCG7Csev8T1/L2UGXE1yHOZLOLM1ba9LYuMC2 SJoec0iUCzl3tLaHLm/u60JdNY+szQwQm5zMVjKoslYheK0vMRJs5SxurxjRFjvMScTG XqQVHVON6CDj2UIM/EBomP1eBlDB4QRJEnLkkM7fL5ocgbY7hh8cgyqvM6zUunvAnE8o VKug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727682143; x=1728286943; 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=J3QK0sGMtG8TI1HL5/V5FwLZQoUZnlZNYr8FgmUN/RY=; b=AmM8QIJW3cPAA200KWmB/rzwnPedoVmo0ziXWwlmKciZiTUp9CpFwsD8Uk27v+K4EQ JUUFKBzZhiPQNiEJb+8mXAExHCHGOMTcpgtVtTGxZlj0XJBKWlSTG6noaLrfgRyqutHz TvjaQ4WkBOCOL4Ll4J5ET3N/Zj2EQOqlSf58ldVG7VoUeOY67vNhvUMmbQF5nEakCbjI QpLEMIqGhJ13qVpQhyVPOnM4/YzvRneYoftfMCYKp8zA0osdycuOMC9Xq/evlrP5Zay/ 6QJdd3Z8TrknSdGOgKyxNlUc7bBE9pQupMt7fVBM8oDfk+1ZnwKlPwPriOqEgjKlVVzC K5bw== X-Gm-Message-State: AOJu0YxjlyabFC6CrJv6mzmQ1ddGXrYjVTgFdBEY+ciSNIGgyN8quR4J Bispflsh6SmNoUpd1P7Ys1kPcXXuPoI/jlXhZdPTNDa5F25BhtsHMS/l3Z3PLorjqCXV7E/ZCYY 1CAs= X-Received: by 2002:a5d:630c:0:b0:37c:d1fb:82fb with SMTP id ffacd0b85a97d-37cd5b3172dmr5782965f8f.36.1727681794106; Mon, 30 Sep 2024 00:36:34 -0700 (PDT) Received: from localhost.localdomain (186.red-88-28-13.dynamicip.rima-tde.net. [88.28.13.186]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a54dedsm142631145e9.44.2024.09.30.00.36.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Sep 2024 00:36:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Jason Wang , Aleksandar Rikalo , Anton Johansson , Peter Maydell , Huacai Chen , "Michael S. Tsirkin" , Sven Schnelle , Jiaxun Yang , qemu-arm@nongnu.org, Aurelien Jarno , Pierrick Bouvier , Max Filippov , Paul Burton Subject: [PATCH 12/13] hw/pci/pci_device: Introduce ld/st_endian_pci_dma() API Date: Mon, 30 Sep 2024 09:34:49 +0200 Message-ID: <20240930073450.33195-13-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930073450.33195-1-philmd@linaro.org> References: <20240930073450.33195-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=philmd@linaro.org; helo=mail-ed1-x535.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=no 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 Introduce the ld/st_endian_pci_dma() API, which takes an extra boolean argument to dispatch to ld/st_{be,le}_pci_dma() methods. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier --- TODO: Update docstring regexp --- include/hw/pci/pci_device.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index ff619241a4..dc9b17dded 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -300,7 +300,29 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr, #define PCI_DMA_DEFINE_LDST_END(_l, _s, _bits) \ PCI_DMA_DEFINE_LDST(_l##_le, _s##_le, _bits) \ - PCI_DMA_DEFINE_LDST(_l##_be, _s##_be, _bits) + PCI_DMA_DEFINE_LDST(_l##_be, _s##_be, _bits) \ + static inline MemTxResult ld##_l##_endian_pci_dma(bool is_big_endian, \ + PCIDevice *dev, \ + dma_addr_t addr, \ + uint##_bits##_t *val, \ + MemTxAttrs attrs) \ + { \ + AddressSpace *pci_as = pci_get_address_space(dev); \ + return is_big_endian \ + ? ld##_l##_be_dma(pci_as, addr, val, attrs) \ + : ld##_l##_le_dma(pci_as, addr, val, attrs); \ + } \ + static inline MemTxResult st##_s##_endian_pci_dma(bool is_big_endian, \ + PCIDevice *dev, \ + dma_addr_t addr, \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ + { \ + AddressSpace *pci_as = pci_get_address_space(dev); \ + return is_big_endian \ + ? st##_s##_be_dma(pci_as, addr, val, attrs) \ + : st##_s##_le_dma(pci_as, addr, val, attrs); \ + } PCI_DMA_DEFINE_LDST(ub, b, 8); PCI_DMA_DEFINE_LDST_END(uw, w, 16)