From nobody Tue Feb 10 00:59:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.47 as permitted sender) client-ip=209.85.221.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1626037321; cv=none; d=zohomail.com; s=zohoarc; b=hApNEuL9ohnZyIKiZFwU7XuNpXKY+icQ37dfZmI2FZ5koHLUtnd6ETX2ZH+lAKnrhGJB+mFXG3fxTxJi2znShToq6rSiYQTq9ub2C7frTUksfzYu38hOugzPiRH/HndC5JdoY1ASMzRgd5mpfJ6AC+dGA7P2Maqj6iZ36xTjPBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626037321; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NUim6++IcBw63PEyeXm1vZaOJYvHSUOphgJ+u9sIrvs=; b=XNseDf6E6qn/puUH9108lCh9lx2zBAnnhZXc1ubbgzByCpBCwzgi+L8WCBpNoBy7IoDTJIZVqIB5W8wqbBg+itmLa9YLw/v1cinSIbjUCRJAQrs2KglBl0lH79LOXId+2aTmbwjVgkFvodLxEkEQgfwX9kRKk8nONO27vBVJXJ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.zohomail.com with SMTPS id 1626037321419402.4007101477482; Sun, 11 Jul 2021 14:02:01 -0700 (PDT) Received: by mail-wr1-f47.google.com with SMTP id f17so22096996wrt.6 for ; Sun, 11 Jul 2021 14:02:00 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (abayonne-654-1-142-116.w86-222.abo.wanadoo.fr. [86.222.93.116]) by smtp.gmail.com with ESMTPSA id u16sm14600468wrw.36.2021.07.11.14.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 14:01:59 -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=NUim6++IcBw63PEyeXm1vZaOJYvHSUOphgJ+u9sIrvs=; b=AN10hoUhbQ+nGxO47AmEXXBSUIpnRIZY1wlL827imYlJeGihHvX4d7IGfXi3do4K11 tM2BNDHk+a8lS/xunRgt8I3ZRjIzwdsjuu55R+0vqyY18IouDdLueM9TOQkZhNAbcTi1 d3fNqPbn9S4gcAngYE2qcRiIbgAlgxNtqVMWp3HrucTtLkHjEanLdJh2eRUK7/eAEykR GA2KvoAvc6yzrHVHCJj7kryxVbrGBs+oABISWWdxTxj9xKqFV96TUCqy5SooxfRr8Rbp GdWLs76Do/vZQxEILEla7OqocmFbl/QHCz5CBxwjx5CNqor8ss1GJhID6vvqUvZlwqpK EDfQ== 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=NUim6++IcBw63PEyeXm1vZaOJYvHSUOphgJ+u9sIrvs=; b=qUPXioOOUMq/ZXsGVB/DuV7nF6p9skI0C8eOU1awnvZ0hFPFX6SvvovHMUIFP2EXkY oGDWGkKV4HVoBfKMx9XrSAKpBTJGfdbdUfqOnwkHBX5+0lvcuhncOkxvInq9ct/wTQ0f F0ShZR+jwAjhRQvnVS2qXn84UdNm14sdTiHm+W+Aeh9a/HZ8D9ldE8EuR29xSInFPEYd ZGluPO+9+pqnRNNl8jxNn6HwNjBuna6IYt7/gVvPNDLPDRefDC5WAvVURXOtf6vDsCJR 9AspbWIRGATqYl0s5EigjK5njTRlHsuZm50TttbLie4irO5C54wZp6e1G+IGTp/IuCc3 qqCw== X-Gm-Message-State: AOAM530BXpkw3/HbBnnUSDo4uP1OkeJiplxM8s0ttjA+am5sWG4D4zZH +P68PCr4vXjhvpC1DqcMg64= X-Google-Smtp-Source: ABdhPJyCUeTW2kiS82n5wDJg+ycjZfLVp+rJQLSWDWZF7PWTqtR6m0HjNfy1wu73WpHM6I/0mOn/pQ== X-Received: by 2002:a5d:48c6:: with SMTP id p6mr54785837wrs.45.1626037319630; Sun, 11 Jul 2021 14:01:59 -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: =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Fredrik Noring , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Finn Thain Subject: [PULL 19/19] dp8393x: don't force 32-bit register access Date: Sun, 11 Jul 2021 23:00:16 +0200 Message-Id: <20210711210016.2710100-20-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210711210016.2710100-1-f4bug@amsat.org> References: <20210711210016.2710100-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: 1626037323111100001 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 Tested-by: Mark Cave-Ayland --- 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