Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3383309imm; Mon, 6 Aug 2018 03:56:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc6Vfc71U9BxxsaS61p9eBWIZHahGRrbO8+/O0/M5ua1Dh3jYozXic711vtge5wZkmZlktn X-Received: by 2002:a63:da04:: with SMTP id c4-v6mr13471592pgh.398.1533553001022; Mon, 06 Aug 2018 03:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533553000; cv=none; d=google.com; s=arc-20160816; b=Mcsca/zRA69oBZyXdjNC/0zIBfVpzUs98btUUCcT3FHHuo8D+1jxUdkMffKweWNshH WkFFkQJupxjTSNGB1DFRHqWYkhPqczFoHGcwmuC/W/Hqu2yaaFOkIu2xMgJzY0Jxa7j2 hNcEtkipRMjVSHhyyFaSg7MDuFIvXPtHGruLC+3VwXfMF5tPyKSAr5XOr5RNbfnLyPdW tM0kaomjVm2qPCvfUQG4mEaWJ/HbwDhDpACA3AepI0WVsmlpueL4vhZgJKv0bdRrW30W qpFJCS1uGLKQ/uAGgKnIYPQglwJSpbm8MCDHbTp7CMqvS0b3wJ1/VpOjeKIthTg2mBmI xNMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=BnPhWi2t6IZiIvorvL7rgXu2xs4UO5F/TwYlyJOd+Go=; b=qSF7N8fP6o4kuTV7rXmUaJteGTLHU+nG4/JB22o87tXl/HwAKiRc/6Ke8rIhprhZH3 aBvqCLVOW8BYDwwZj3RvIKOSlhwdXriMb0xtM92dYxhOB2UiK1nMF45TkgnOCeqcz1ld xYjE3pggDa3a2ak9Hf/d/qCPLq8iOvWmbJ/x84ep58JLz6WC03Z4ALKq3H0KO5RQKUhF tjVuap/JFLTr//3sha12vdZChcz4o8JVKYbk98Gj258+MScZR9RDxmbjVgkc9uUt4HB1 LApK2hWv08aNnAkRBOnHsP9DSl1K+6unVdFCdvVon0/KGa1I/ppsgm75iqHDUf/Jyxay tVOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCiB3pjG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si12951640pge.589.2018.08.06.03.56.26; Mon, 06 Aug 2018 03:56:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCiB3pjG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730039AbeHFM5T (ORCPT + 99 others); Mon, 6 Aug 2018 08:57:19 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:39505 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729604AbeHFM5T (ORCPT ); Mon, 6 Aug 2018 08:57:19 -0400 Received: by mail-it0-f67.google.com with SMTP id g141-v6so17448314ita.4 for ; Mon, 06 Aug 2018 03:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BnPhWi2t6IZiIvorvL7rgXu2xs4UO5F/TwYlyJOd+Go=; b=BCiB3pjG2eyVsYaG6bDy3L94VAK7mB0zNS81z3NVJhkt3lyUiW1OZ26QyaB85rF4Zs m7G6dDuLa5WBUi4jE3CL5rv4iSN+6TgfgrvhFDBeFjDD64DUbwSXprfxAJgedYpfEyhM 1lPUGLMrMcgv3IF8H4ldjKXOutc5IPu5GUYlk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BnPhWi2t6IZiIvorvL7rgXu2xs4UO5F/TwYlyJOd+Go=; b=eNhv1yyUTRmIpAd4o7Etm2Mtvdh98mDEByf2UPzIqs7wWik5d4dI2o88rnsIsGNfGN /YJ/+2TaIxXuI0PC9ZEyOGBDtzFm6U7KCwaA85Jy36Bp+sgNiZpQZB9AtTTJ/nGyLtNY yvjK6oNOZPdW/7gpRnPHb+zT0gC9X1hOke54I6rpAMdITkBJxr6RYh1wNFIq9phar4br Owu2ICDh1nnD1QUxj45Z9VQVhYXUvxg0dhaM5IlutLX3lOsZQKMEtrEQvH0JjMTVsc3M X6ui3GFcAcd/8ULgt3udpnaLRosKmnRPwnQYS5d5TBZfeBYdLfLM3OrWDL/zhq0zTjP6 of8Q== X-Gm-Message-State: AOUpUlHcyZGfdGmRA/UJeJ2SI+F7IihtR9GG1g58xMoNbysGc3zgCnBu WXfX+44lJjbD3SYF42zgl2lbkt/NfYpvNuyLgYVrAA== X-Received: by 2002:a24:148c:: with SMTP id 134-v6mr14549061itg.50.1533552529804; Mon, 06 Aug 2018 03:48:49 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Mon, 6 Aug 2018 03:48:49 -0700 (PDT) In-Reply-To: References: <9acdacdb-3bd5-b71a-3003-e48132ee1371@redhat.com> <11f9185a-7f71-83df-3a57-0a0ae9c1f934@arm.com> From: Ard Biesheuvel Date: Mon, 6 Aug 2018 12:48:49 +0200 Message-ID: Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 To: Mikulas Patocka Cc: Florian Weimer , Andrew Pinski , Richard Earnshaw , Ramana Radhakrishnan , Thomas Petazzoni , GNU C Library , Catalin Marinas , Will Deacon , Russell King , LKML , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6 August 2018 at 12:42, Mikulas Patocka wrote: > > > On Mon, 6 Aug 2018, Ard Biesheuvel wrote: > >> On 6 August 2018 at 12:31, Mikulas Patocka wrote: >> > >> > >> > On Mon, 6 Aug 2018, Ard Biesheuvel wrote: >> > >> >> On 6 August 2018 at 10:02, Mikulas Patocka wrote: >> >> > >> >> > >> >> > On Sun, 5 Aug 2018, Florian Weimer wrote: >> >> > >> >> >> On 08/04/2018 01:04 PM, Mikulas Patocka wrote: >> >> >> > There's plenty of memcpy's in the graphics stack. No one will be rewriting >> >> >> > all the graphics drivers because of tiny market share that ARM has in >> >> >> > desktop computers. So if you refuse to fix things and blame everyone else, >> >> >> > you can as well announce that you don't want to have PCIe graphics on ARM >> >> >> > at all. >> >> >> >> >> >> The POWER toolchain maintainers said pretty much the same thing not too >> >> >> long ago. I wonder how many architectures need to fail until the >> >> >> graphics stack is finally fixed. >> >> >> >> >> >> Thanks, >> >> >> Florian >> >> > >> >> > If you say that your architecture doesn't support unaligned accesses at >> >> > all, there's no problem - the compiler won't generate them and the libc >> >> > won't contain them. >> >> > >> >> > But if you say that your architecture supports unaligned accesses except >> >> > for the framebuffer, then you have a problem - the compiler can't know >> >> > which pointers point to the framebuffer and libc can't know either - you >> >> > caused this problem by your architectural decision. >> >> > >> >> > You can use 'volatile' to suppress memory optimizations, but it's >> >> > impossible to go through the whole Linux graphics stack and add volatile >> >> > to every pointer that may point to videoram. Even if you succeesed, new >> >> > videoram accesses without volatile will appear after a year of >> >> > development. >> >> > >> >> > See for example the macros READ_ONCE and WRITE_ONCE in Linux kernel - they >> >> > should be used when there's concurrent access to the particular variable, >> >> > but mainstream architectures don't require them, so many kernel developers >> >> > are omitting them in their code. >> >> > >> >> > If you are building a supercomputer with a particular GPU, you can force >> >> > the GPU vendor to provide POWER-compliant drivers. If you are building a >> >> > workstation where the user can plug any GPU, forcing developers will go >> >> > nowhere. You have to emulate the unaligned accesses and make sure that the >> >> > next versions of your architecture support them in hardware. >> >> > >> >> >> >> I have the feeling this discussion is going off the rails again. >> >> >> >> The original report is about corruption when doing overlapping writes. >> >> Matt Sealey said you cannot have PCI outbound windows with memory >> >> semantics on ARM, and so you should be using device mappings (which do >> >> not tolerate unaligned accesses) >> >> >> >> In this context, 'device mapping' does not mean 'any non-DRAM region', >> >> but it refers to a particular type of MMU mapping attribute defined by >> >> the ARM architecture. >> >> >> >> I think we can all agree that memcpy() should be usable on any region >> >> of memory that has true memory semantics, even if it is backed by VRAM >> >> on a graphics card. >> >> >> >> The question is if PCIe can provide such regions on ARM. >> > >> > I think there are three possible solutions: >> > >> > 1. provide an alternative memcpy implementation that doesn't do unaligned >> > accesses and recompile the graphics software with -mstrict-align >> > >> > 2. map the PCI BAR as device memory and emulate the unaligned instructions >> > >> > 3. find some hardware workaround that could insert delays between the PCIe >> > accesses (but the hardware engineers need to cooperate on this instead of >> > asserting that they refuse tu support it) >> > >> >> Are we talking about a quirk for the Armada 8040 or about PCIe on ARM >> in general? > > I don't know - there are not any other easily available PCIe ARM boards > except for Armada 8040. > ... indeed, and sadly, the ones that are available all have this horrible Synopsys DesignWare PCIe IP that does not implement a true root complex at all, but is simply repurposed endpoint IP with some tweaks so it vaguely resembles a root complex. But this is exactly why I am asking: I use a AMD Seattle Overdrive as my main Linux development system, and it runs the gnome-shell stack flawlessly (using the nouveau driver), as well as a UEFI framebuffer using efifb. So my suspicion is that this is either a Synopsys IP issue or an interconnect issue, and has nothing to do with the impedance mismatch between AMBA and PCIe.