Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3373560imm; Mon, 6 Aug 2018 03:43:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfP6Ci+wGzZzQST0LVb6cJrLySwjs/9zXAtjlh6FsJIS/DuFQdm3CjkxOzmufu4eEBmPaW/ X-Received: by 2002:a62:34c4:: with SMTP id b187-v6mr16368554pfa.15.1533552209084; Mon, 06 Aug 2018 03:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533552209; cv=none; d=google.com; s=arc-20160816; b=dXzHj42B0hBEO9+S5xahjJincE1sGX7YV02wadBrDy67/aClAwWD6mvE0Ef9O8IxGT JFMIo2RfdnbF8/vyvqrlakEwzGf3nY8lgVFGHN3U2oCcTZPhrbhZH1iDXW+ZWK4jTyFZ APJb9TmWErS+s9I/LfAZfAns7ZoSRJvCDTA472zn8mwMUNBFlKld/+/hyGk6ajM1dz8r AMGxMGZRb8k7412GKb6eT/eTxv9K7oYIe8dCY64HVZSUhq5wSUwxtkm32VAjfRL+Awdu ftKDPRt3F60tTj76jn8vJCCaspoP85sbNjBZr4gNyapx4rMY7oo5c+9peoT2ORTg1gPg RQNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=DLYQISqaRqhYFD4PPq7ebOlahz4vqHwryJaN4/GViVA=; b=ypMRUUdl13t0tzBoVA0tf0G3u1PpxcdVMaAJ3N2NUGt59+y5W+p4JUDhhAS3bobkAQ h2lwH3cFyqdmCzulZlq6xRd681iKkSWNH7C2hbqDbARtMRaJIK05tVwbksc5psUrq4Wk G1QMmb563xQxSAJiqqshZgO61sEAw+ActQtFO819wNwBSxP4WoLDHzGLWuYCpdhIKNUv poiBH0O9Wkel4hAOOUREV15caHx7lTGVKjFhVrHlEFgqwz5XUvVwaBcmuKkeDeB3QgIh t19pI8B7+jfTgcQwRdyNjSYbQXiYyY2sVv7/QnA1fcfpyOscwiuBCzhoxnt/8PcZ+LQr eg8g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13-v6si10345191pgv.389.2018.08.06.03.43.14; Mon, 06 Aug 2018 03:43:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729638AbeHFMua (ORCPT + 99 others); Mon, 6 Aug 2018 08:50:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50194 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726969AbeHFMua (ORCPT ); Mon, 6 Aug 2018 08:50:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 358B07C6A9; Mon, 6 Aug 2018 10:42:02 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFA962166BA0; Mon, 6 Aug 2018 10:42:01 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w76Ag1Ox006051; Mon, 6 Aug 2018 06:42:01 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w76Ag1Dv006035; Mon, 6 Aug 2018 06:42:01 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 6 Aug 2018 06:42:01 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Ard Biesheuvel cc: Florian Weimer , Andrew Pinski , Richard Earnshaw , Ramana Radhakrishnan , Thomas Petazzoni , GNU C Library , Catalin Marinas , Will Deacon , Russell King , LKML , linux-arm-kernel Subject: Re: framebuffer corruption due to overlapping stp instructions on arm64 In-Reply-To: Message-ID: References: <9acdacdb-3bd5-b71a-3003-e48132ee1371@redhat.com> <11f9185a-7f71-83df-3a57-0a0ae9c1f934@arm.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 06 Aug 2018 10:42:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 06 Aug 2018 10:42:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > If the latter, I still haven't seen an explanation why the particulars > of AMBA justify overlapped writes being dropped at will by the > interconnect. Mikulas