From nobody Tue Feb 10 10:19:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.53 as permitted sender) client-ip=209.85.128.53; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f53.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1625999802; cv=none; d=zohomail.com; s=zohoarc; b=erEB8xYPM0A2bJK5SfM9mzL9nfRU8MpXzXzIbZPdKzMNW5DVlxUbKPYJL7Djaao27BuczktXs+beAW71GhGl96Sna5cB9Egrz/MsBw8K3dFXQSpTcv2TDPsEmX1nvwpJMxpU0AH9f5KVIcsqfxr8IHXVJhHq5dRS3jGXSvshwVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625999802; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qQHrIVyJXHGkbXKhjJkgDmeXIckABcf9Z2uGW8Bcsrk=; b=VFBpt+GHxAUnBLZHnvoo6MdQCYi6kW8z9t4MbapPGSAxAttXzsMF0om4ivRqBvIIZyfaGU8K/iHx4mIY/C/7XpD1aBoD2SFklRR2aksAICBDjBFjHDOzygjJW8/KmM/JRb6O0Z8iv4CJywlj7uqIUu1rmj78JXeDv9vr2xrzn+I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.zohomail.com with SMTPS id 16259998020061014.9659385115333; Sun, 11 Jul 2021 03:36:42 -0700 (PDT) Received: by mail-wm1-f53.google.com with SMTP id w13so9235078wmc.3 for ; Sun, 11 Jul 2021 03:36:41 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (static-189-95-145-212.ipcom.comunitel.net. [212.145.95.189]) by smtp.gmail.com with ESMTPSA id i2sm16896993wmq.43.2021.07.11.03.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 03:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qQHrIVyJXHGkbXKhjJkgDmeXIckABcf9Z2uGW8Bcsrk=; b=YnWfC6kmGSLD14yMHKdJVN71izMjnT7G8HrVPcZ6dKQm5tnKfo5aBeuWVnKGsRavVk DSvKhaLSOsz3czG2DaTmqtcXe18jtUYMaYlIPyG5eLOMyVu16DBz8zK2jPwtDYDu3RTE D3v3vE5iJCEpt0PKpTtJhhxNTG+4XxS5pptsPOhq5ihNskD317qVm73GIhub0UlbI8V/ ht0HjnZaIvpz9mppjRtx8iK84CuQUnJOxIi/ex61zFHCLgeFUno0EzUIuBr8FlM3M3+h IFHuWJAy8g0uH2VVBcb7KAgNlyHZ+yzygDzPubps2Sougtf649OHxdJh/TLb64l66HuV taFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=qQHrIVyJXHGkbXKhjJkgDmeXIckABcf9Z2uGW8Bcsrk=; b=FDXFAnm6THB9QQt0O1b2UpqOYOmeb9cktpLoR0hI6SLEWibqlVnvOef+vwE4fM0ldi YGkJQr4CQ0QCFtMPt9ZcBfGGv/xWzKKsqh6ix9OvpmkVhJdZQ0CFitBdXzY4EIxTchPE sHLlqUhqY9zHmr9QNWF5a4p1TtjrtWOnW+Hce59HEPvVcF/RiiLw4xc4/kxkZrgjyDhb Nxa7sSjT5DSsRzUbbEuBYV2gtOgGSo2NRtX0Tz02dlTx1VEJAAmchgbsce83cxOBMy+J 5u13kCCJ9BJNKCW48BrdFQ2qc7FFw6tv6a/xpF7PcOp3ukeDBCi54qAXhljNHl9Ti7C5 nrog== X-Gm-Message-State: AOAM532sGcnECI/IaJgYPCrC0dJiVLf97tqP0FB2tqmOFPcn6tb9TplJ eOKuAfM6c4uQZle0d3h3n2Q= X-Google-Smtp-Source: ABdhPJzP6tHeY/Njq9hho1h/0Ifv2N6B0etrXP45aD4LUN1240Qw+Zuaa4S4qheJzbg3prqtAm/Fag== X-Received: by 2002:a7b:cf03:: with SMTP id l3mr25864087wmg.110.1625999800268; Sun, 11 Jul 2021 03:36:40 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Jason Wang , Laurent Vivier , Finn Thain , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 5/5] dp8393x: don't force 32-bit register access Date: Sun, 11 Jul 2021 12:36:12 +0200 Message-Id: <20210711103612.2661521-6-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210711103612.2661521-1-f4bug@amsat.org> References: <20210711103612.2661521-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1625999802426100001 From: Mark Cave-Ayland Commit 3fe9a838ec "dp8393x: Always use 32-bit accesses" set .impl.min_acces= s_size and .impl.max_access_size to 4 to try and fix the Linux jazzsonic driver wh= ich uses 32-bit accesses. The problem with forcing the register access to 32-bit in this way is that = since the dp8393x uses 16-bit registers, a manual endian swap is required for devices= on big endian machines with 32-bit accesses. For both access sizes and machine endians the QEMU memory API can do the ri= ght thing automatically: all that is needed is to set .impl.min_access_size to 2 to d= eclare that the dp8393x implements 16-bit registers. Normally .impl.max_access_size should also be set to 2, however that doesn'= t quite work in this case since the register stride is specified using a (dynamic) = it_shift property which is applied during the MMIO access itself. The effect of this= is that for a 32-bit access the memory API performs 2 x 16-bit accesses, but the us= e of it_shift within the MMIO access itself causes the register value to be repe= ated in both the top 16-bits and bottom 16-bits. The Linux jazzsonic driver expects the = stride to be zero-extended up to access size and therefore fails to correctly detect the= dp8393x device due to the extra data in the top 16-bits. The solution here is to remove .impl.max_access_size so that the memory API= will correctly zero-extend the 16-bit registers to the access size up to and inc= luding it_shift. Since it_shift is never greater than 2 than this will always do t= he right thing for both 16-bit and 32-bit accesses regardless of the machine endian,= allowing the manual endian swap code to be removed. Signed-off-by: Mark Cave-Ayland Fixes: 3fe9a838ec ("dp8393x: Always use 32-bit accesses") Message-Id: <20210705214929.17222-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Finn Thain --- hw/net/dp8393x.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 4057a263de3..45b954e46c2 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -588,15 +588,14 @@ static uint64_t dp8393x_read(void *opaque, hwaddr add= r, unsigned int size) =20 trace_dp8393x_read(reg, reg_names[reg], val, size); =20 - return s->big_endian ? val << 16 : val; + return val; } =20 -static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data, +static void dp8393x_write(void *opaque, hwaddr addr, uint64_t val, unsigned int size) { dp8393xState *s =3D opaque; int reg =3D addr >> s->it_shift; - uint32_t val =3D s->big_endian ? data >> 16 : data; =20 trace_dp8393x_write(reg, reg_names[reg], val, size); =20 @@ -677,11 +676,16 @@ static void dp8393x_write(void *opaque, hwaddr addr, = uint64_t data, } } =20 +/* + * Since .impl.max_access_size is effectively controlled by the it_shift + * property, leave it unspecified for now to allow the memory API to + * correctly zero extend the 16-bit register values to the access size up = to and + * including it_shift. + */ static const MemoryRegionOps dp8393x_ops =3D { .read =3D dp8393x_read, .write =3D dp8393x_write, - .impl.min_access_size =3D 4, - .impl.max_access_size =3D 4, + .impl.min_access_size =3D 2, .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 --=20 2.31.1