From nobody Sat Nov 23 22:00:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1731080819074746.206762919825; Fri, 8 Nov 2024 07:46:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0090C1744; Fri, 8 Nov 2024 10:46:57 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6AF521759; Fri, 8 Nov 2024 10:44:07 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 500E31720; Fri, 8 Nov 2024 10:44:03 -0500 (EST) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 812331720 for ; Fri, 8 Nov 2024 10:43:50 -0500 (EST) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d8901cb98so2046648f8f.0 for ; Fri, 08 Nov 2024 07:43:50 -0800 (PST) Received: from localhost.localdomain ([89.101.134.25]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed970d10sm5176298f8f.20.2024.11.08.07.43.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 08 Nov 2024 07:43:48 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731080629; x=1731685429; darn=lists.libvirt.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=VTS56iSsTBU0rbweaIFAqMPbX9U8Q5qblgHU5lae1Ms=; b=LbRhMWxSLMXvEiBya+UuJNUGRPqGu8t5K4T79iE2yZRflDWoNQ9olHLXAhvZsNVBTy fAW4kI35IqqHgPEk96RvdnXTC+aWcfWN6u3/t4kDVDjbzbV2hbgfYI9ir5/XOzVkCt/W d1V0g2gi8/VpSS+B1y0YhMKpvKvmHDpSTSWQ4Z5Fi16nj/toq16C0uPxLxHuCKFeOLVm LQDnefrpgA1ZA6S4sHsI3w5Ri/JdYcYK8el9UoMr6lXYI3+oMPIIvram4Ya+3LxcyRwF TLGpz1JCic2Vt3endtr9atVdhEDQD0Gm6LdbuqfAkX3J4m6BeLaTrFlzyK7D7++o1y8i WD+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731080629; x=1731685429; 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=VTS56iSsTBU0rbweaIFAqMPbX9U8Q5qblgHU5lae1Ms=; b=uwAcjuuhTKrzAY3QzqPb6dDKN+oiLfWZCaAP7JFxghJYlhEGTQpZul1Rz/bo+oJcN3 NTxt2p3/w6wBpxu2uYXlvC3UX6Eo7de9XYsxfJ6ecCVMOo6IPvQcp45AFXkaNvB0gY5S yuwDbmA0Z54vciMSdkLaWq+UYiA2QckEOUB1FNmcp4u6fqiXH4RSMg9e87dfY2k5YhuJ lH8p3T+kUOZjAnbYU6tyXL/aTMVBVm6aQrVcJkYQqX4KxUtk9XDGqIZQDnvPMMpkDMmF soTNhP6ib3Vdf/bhR+YUkQMAqrCkTRaQgmsI1Bbn686VuJn61bg4o78fPtPhFKfmlc9I ur0A== X-Forwarded-Encrypted: i=1; AJvYcCU6GeXfvEYRRjRK/VlpPw81psUvr90h9DIuNF3/vZwza3YJ6gpqNR9EgyvwqGniePv8g3SNKQ==@lists.libvirt.org X-Gm-Message-State: AOJu0YyWnSaRANXNQC0ljDAW9Xv1L9QjmhkTptqLVeki5W4SDYdRhXJf Emz+5gFjOwmkj9mRBXgMtgfdCOaASoNyeuRff6ni85swuug7zIahd7CZ7XQ1iXA= X-Google-Smtp-Source: AGHT+IFPEx/7bYWHyFTs8RQSuTAEd3NlwToJF/KnnNzaIbLjCLyJebV7qM+E91J85CG0vX7r+ralOA== X-Received: by 2002:a5d:59a7:0:b0:37d:2d6f:3284 with SMTP id ffacd0b85a97d-381f1a6ca9bmr2972049f8f.9.1731080629309; Fri, 08 Nov 2024 07:43:49 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Anton Johansson Subject: [PATCH v3 06/17] hw/timer/xilinx_timer: Make device endianness configurable Date: Fri, 8 Nov 2024 15:43:06 +0000 Message-ID: <20241108154317.12129-7-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108154317.12129-1-philmd@linaro.org> References: <20241108154317.12129-1-philmd@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3PRBXXBSL5YU3FDMJTU5FVLTIR5RASNC X-Message-ID-Hash: 3PRBXXBSL5YU3FDMJTU5FVLTIR5RASNC X-MailFrom: philmd@linaro.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: Jason Wang , Paolo Bonzini , Richard Henderson , devel@lists.libvirt.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Edgar E. Iglesias" , Thomas Huth , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Peter Maydell , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731080821388116600 Content-Type: text/plain; charset="utf-8" Replace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN. Add the "little-endian" property to select the device endianness, defaulting to little endian. Set the proper endianness for each machine using the device. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/ppc/virtex_ml507.c | 1 + hw/timer/xilinx_timer.c | 35 +++++++++++++++--------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_= ml605_mmu.c index 64e8cadbee..f4ec983fee 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -127,6 +127,7 @@ petalogix_ml605_init(MachineState *machine) =20 /* 2 timers at irq 2 @ 100 Mhz. */ dev =3D qdev_new("xlnx.xps-timer"); + qdev_prop_set_bit(dev, "little-endian", true); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 100 * 1000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petal= ogix_s3adsp1800_mmu.c index f02d343e29..10d9713150 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -114,6 +114,7 @@ petalogix_s3adsp1800_init(MachineState *machine) =20 /* 2 timers at irq 2 @ 62 Mhz. */ dev =3D qdev_new("xlnx.xps-timer"); + qdev_prop_set_bit(dev, "little-endian", !TARGET_BIG_ENDIAN); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index f378e5c4a9..ea0b3a56fe 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -230,6 +230,7 @@ static void virtex_init(MachineState *machine) =20 /* 2 timers at irq 2 @ 62 Mhz. */ dev =3D qdev_new("xlnx.xps-timer"); + qdev_prop_set_bit(dev, "little-endian", false); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c index c117bff225..5bfb7e3929 100644 --- a/hw/timer/xilinx_timer.c +++ b/hw/timer/xilinx_timer.c @@ -3,6 +3,9 @@ * * Copyright (c) 2009 Edgar E. Iglesias. * + * DS573: https://docs.amd.com/v/u/en-US/xps_timer + * LogiCORE IP XPS Timer/Counter (v1.02a) + * * Permission is hereby granted, free of charge, to any person obtaining a= copy * of this software and associated documentation files (the "Software"), t= o deal * in the Software without restriction, including without limitation the r= ights @@ -69,6 +72,7 @@ struct XpsTimerState { SysBusDevice parent_obj; =20 + bool little_endian_model; MemoryRegion mmio; qemu_irq irq; uint8_t one_timer_only; @@ -189,18 +193,21 @@ timer_write(void *opaque, hwaddr addr, timer_update_irq(t); } =20 -static const MemoryRegionOps timer_ops =3D { - .read =3D timer_read, - .write =3D timer_write, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .impl =3D { - .min_access_size =3D 4, - .max_access_size =3D 4, +static const MemoryRegionOps timer_ops[2] =3D { + [0 ... 1] =3D { + .read =3D timer_read, + .write =3D timer_write, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, }, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 4 - } + [0].endianness =3D DEVICE_BIG_ENDIAN, + [1].endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 static void timer_hit(void *opaque) @@ -233,8 +240,9 @@ static void xilinx_timer_realize(DeviceState *dev, Erro= r **errp) ptimer_transaction_commit(xt->ptimer); } =20 - memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "xlnx.xps-ti= mer", - R_MAX * 4 * num_timers(t)); + memory_region_init_io(&t->mmio, OBJECT(t), + &timer_ops[t->little_endian_model], t, + "xlnx.xps-timer", R_MAX * 4 * num_timers(t)); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &t->mmio); } =20 @@ -247,6 +255,7 @@ static void xilinx_timer_init(Object *obj) } =20 static Property xilinx_timer_properties[] =3D { + DEFINE_PROP_BOOL("little-endian", XpsTimerState, little_endian_model, = true), DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 100= 0000), DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0), DEFINE_PROP_END_OF_LIST(), --=20 2.45.2