{"id":2222649,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2222649/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260413092240.3719260-3-daniel@thingy.jp/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.1/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260413092240.3719260-3-daniel@thingy.jp>","date":"2026-04-13T09:22:36","name":"[v4,2/6] m68k: Fix writew(), writel(), readw(), readl() endianness for classic m68k","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5117c14e91c3aea0f794a1c0247b339c70afc45d","submitter":{"id":85408,"url":"http://patchwork.ozlabs.org/api/1.1/people/85408/?format=json","name":"Daniel Palmer","email":"daniel@thingy.jp"},"delegate":{"id":14103,"url":"http://patchwork.ozlabs.org/api/1.1/users/14103/?format=json","username":"spectrum","first_name":"Angelo","last_name":"Dureghello","email":"sysamfw@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260413092240.3719260-3-daniel@thingy.jp/mbox/","series":[{"id":499674,"url":"http://patchwork.ozlabs.org/api/1.1/series/499674/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=499674","date":"2026-04-13T09:22:34","name":"Add virtio-mmio support to m68k virt machine","version":4,"mbox":"http://patchwork.ozlabs.org/series/499674/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222649/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222649/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=thingy.jp header.i=@thingy.jp header.a=rsa-sha256\n header.s=google header.b=hCzldwn8;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=thingy.jp","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=thingy.jp header.i=@thingy.jp header.b=\"hCzldwn8\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=thingy.jp","phobos.denx.de; spf=pass smtp.mailfrom=daniel@0x0f.com"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvMQk0F89z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 19:23:26 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 10A42841B9;\n\tMon, 13 Apr 2026 11:23:08 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id 82098841B9; Mon, 13 Apr 2026 11:23:07 +0200 (CEST)","from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com\n [IPv6:2607:f8b0:4864:20::1033])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 47BEC8419C\n for <u-boot@lists.denx.de>; Mon, 13 Apr 2026 11:23:05 +0200 (CEST)","by mail-pj1-x1033.google.com with SMTP id\n 98e67ed59e1d1-35d95017a68so2605063a91.3\n for <u-boot@lists.denx.de>; Mon, 13 Apr 2026 02:23:04 -0700 (PDT)","from kinako ([2400:2200:776:9b18:a191:7a74:9fd8:591b])\n by smtp.googlemail.com with ESMTPSA id\n 98e67ed59e1d1-35fb617725esm1055930a91.1.2026.04.13.02.23.00\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 13 Apr 2026 02:23:03 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=no\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=thingy.jp; s=google; t=1776072183; x=1776676983; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=me1vVhPqr1kjIlS8wW0B4mXkU2u+5wAIRtgWgiIVfTo=;\n b=hCzldwn8pyt6piEgkrfl11aEQZeaYPJczMTufYRbiot2E/fJQOneFbhjKSI3sIry9Y\n sDnhikW49IerZ1zeja2VYgjCa7EoKHAQJIAOwqvob8PVKn/o2JqtqANdnEZJi3Snoxxi\n UM4ayMquXrv5l5uYots8IZ1Ws/3B3TAsvQo4w=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776072183; x=1776676983;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=me1vVhPqr1kjIlS8wW0B4mXkU2u+5wAIRtgWgiIVfTo=;\n b=hggVwhf0hmmDaqSo0BVItWcpZ+a45VK0lY5QbNWi1E0ZNUflxTKk6XKT8qLdavFx0e\n hDO9QmDRZwcN1QElr4af3tm/PBjKXs/GzW9wI9foyPt1TtufOlG+52TVGGkNT1q8RFki\n BRHbX55EC9dK044mHigtueuNbfG6JfUys1wHJ1kOSe0AK7T5oCBdP17cbDd6doecfOzM\n lc7oJ6fN1WhZnCbUpbxUewWuJf49m6+e0pEvfF17SzYBKD1Z0QixVw7pPWPJd6WKaM/P\n ajRZzB3h3SmsUFZb7v74njEhTZugdqVS/eYkJebpz8OuZ1u9XhkFUhoVzTkFnUFN5NaU\n rFxQ==","X-Forwarded-Encrypted":"i=1;\n AFNElJ+tcMkMhbaSilRYfFHGZ+aqx6RGhsij1YjDqfKz4YmYcGoGKIMbiwelnMcMi9bCfYhHivdMchA=@lists.denx.de","X-Gm-Message-State":"AOJu0YxRqD2pznlrvp4DAyqqenbSejV7EJ2uCpl2/oD0g/f/vs5gytXe\n ahx6zzdjVf6bkayqJQdCoXVNNfwH+Y4OMyiDV8sC7XbrhW0IOCIzXUSldZVDon3S7VY=","X-Gm-Gg":"AeBDietfHf3vKO1XwMkklAVW9WOpsdfHi+YRUuNeeoVT5mqE5W7gzYMNVNT/fD2tExe\n 2WoVcWEuL//p2BpZOZlaoWsJatf3GxsmalrN/EqAwckWSXXLTIsInupC47RY8e5/MmouxYN1mZs\n ApzQ+Hn1X8DZ78L48J3v8Pw52mSPFDMwFCd8ZRWXtz8CNAgTZBWucKcb1oKwxoZcS6yJDcbssva\n a8alKelv6WAEcKae+BBUNFLv1f/hM4/vUMZMgYO1W3bm5xY1Z/1eST3JugO7LDpGp8L8vkZlv73\n 4HwFAYu6z1rrt8LTpaK24bct1m8bByLhDuQzXFeDXf7hN66JVl/PVFaoslq/rO9y/JnAKIM9Eos\n kzfB8TmDlQV0QfdeA/xj8tQrvtg9S/pE9BOTe7cv12UqPb/h6WaUQG5lhjlsb/hN3Mh0ZOR0NAI\n uQhPJp1mhDspRQ1ZOfPiT+huBe","X-Received":"by 2002:a17:90a:dfc7:b0:35b:e52a:6fe5 with SMTP id\n 98e67ed59e1d1-35e4274e358mr11940905a91.5.1776072183570;\n Mon, 13 Apr 2026 02:23:03 -0700 (PDT)","From":"Daniel Palmer <daniel@thingy.jp>","To":"visitorckw@gmail.com,\n\tangelo@kernel-space.org,\n\tbmeng.cn@gmail.com","Cc":"sjg@chromium.org, u-boot@lists.denx.de, Daniel Palmer <daniel@thingy.jp>","Subject":"[PATCH v4 2/6] m68k: Fix writew(), writel(), readw(),\n readl() endianness for classic m68k","Date":"Mon, 13 Apr 2026 18:22:36 +0900","Message-ID":"<20260413092240.3719260-3-daniel@thingy.jp>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20260413092240.3719260-1-daniel@thingy.jp>","References":"<20260413092240.3719260-1-daniel@thingy.jp>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"In Linux these are meant to read a little-endian value and swap\nto the CPU endian.\n\nIn u-boot for m68k this is currently broken and prevents\nvirtio-mmio from functioning.\n\nThis change is only for classic m68k. Coldfire has read big-endian,\nno swap for these in u-boot and Linux and existing drivers probably\ndepend on this.\n\nSigned-off-by: Daniel Palmer <daniel@thingy.jp>\nTested-by: Angelo Dureghello <angelo@kernel-space.org>\nReviewed-by: Simon Glass <sjg@chromium.org>\n---\n arch/m68k/include/asm/io.h | 31 ++++++++++++++++++++-----------\n 1 file changed, 20 insertions(+), 11 deletions(-)","diff":"diff --git a/arch/m68k/include/asm/io.h b/arch/m68k/include/asm/io.h\nindex 35ad4a1c0444..2577081d8363 100644\n--- a/arch/m68k/include/asm/io.h\n+++ b/arch/m68k/include/asm/io.h\n@@ -23,18 +23,27 @@\n #define __raw_writew(w,addr) ((*(volatile u16 *) (addr)) = (w))\n #define __raw_writel(l,addr) ((*(volatile u32 *) (addr)) = (l))\n \n-#define readb(addr)\t\tin_8((volatile u8 *)(addr))\n-#define writeb(b,addr)\t\tout_8((volatile u8 *)(addr), (b))\n-#if !defined(__BIG_ENDIAN)\n-#define readw(addr)\t\t(*(volatile u16 *) (addr))\n-#define readl(addr)\t\t(*(volatile u32 *) (addr))\n-#define writew(b,addr)\t\t((*(volatile u16 *) (addr)) = (b))\n-#define writel(b,addr)\t\t((*(volatile u32 *) (addr)) = (b))\n+#define readb(addr)\tin_8((volatile u8 *)(addr))\n+#define writeb(b, addr)\tout_8((volatile u8 *)(addr), (b))\n+#ifdef CONFIG_M680x0\n+/*\n+ * For classic m68k these work the same way as Linux:\n+ * Read a little endian value, swap to the CPU endian.\n+ */\n+#define readw(addr)\tin_le16((volatile u16 *)(addr))\n+#define readl(addr)\tin_le32((volatile u32 *)(addr))\n+#define writew(b, addr)\tout_le16((volatile u16 *)(addr), (b))\n+#define writel(b, addr)\tout_le32((volatile u32 *)(addr), (b))\n #else\n-#define readw(addr)\t\tin_be16((volatile u16 *)(addr))\n-#define readl(addr)\t\tin_be32((volatile u32 *)(addr))\n-#define writew(b,addr)\t\tout_be16((volatile u16 *)(addr),(b))\n-#define writel(b,addr)\t\tout_be32((volatile u32 *)(addr),(b))\n+/*\n+ * For coldfire these read a big endian value and use it\n+ * as-is. This means that for little endian devices on the\n+ * bus like PCI device these won't work as expected currently.\n+ */\n+#define readw(addr)\tin_be16((volatile u16 *)(addr))\n+#define readl(addr)\tin_be32((volatile u32 *)(addr))\n+#define writew(b, addr)\tout_be16((volatile u16 *)(addr), (b))\n+#define writel(b, addr)\tout_be32((volatile u32 *)(addr), (b))\n #endif\n \n /*\n","prefixes":["v4","2/6"]}