Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1462265imm; Sat, 4 Aug 2018 04:06:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcFYyQOufy82OwqdK/wJtOZDOZ83ZASnlM0UisD2Yr95FZz9oZA/I9/DcBFzTufGs8W8/DF X-Received: by 2002:a63:d443:: with SMTP id i3-v6mr7483854pgj.216.1533380762134; Sat, 04 Aug 2018 04:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533380762; cv=none; d=google.com; s=arc-20160816; b=k9Y8EWhHZ/eB8eCnMJHjQd9AhzHY9AWiUcBiZw2N6jhyknswMx2VAg9NRCaYIyX9o5 WdVh/HxGw8GPTes5ss8JBU0Lc1BYw8vM7MN6OADeEMzLomi29o6716bDx5TCLUHacgKz PtP81g3lMWv3dTcT4+aBrFVg9kmdyM/kJDHb5gd4qhtihFprNJW5+Ae4jRw1F4jowkn8 9rKvgPD+yclYHf6+qAk/jl0SlkSX+l/cSU6Dlch0Klnwy4naVvzXEsyJRL55eG0LqTlJ FDbVTuyHBTwqJ2uRyDe11NEwRcBmA4VMQ+v/gMW80unR+h5/thVfai22EonOcFnaiy95 GI9g== 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=iAEJ6wn8P84aL7oi9UkaddRnhdwT0p4otkOOAqT2IZg=; b=ee9sBGaf/sSkIJWAZoCp2rGhb+BR2T3I6WMRom1TjT6VtyoTsgapFSSCGjoapce/tc i4d5ZxHZzjYZtVqthgRsqhqxCljS/1dYLRI+HwMIenleuq8LmAwjEf5N0O9mpEzOsN3e KazkdGFrZx7PoBRhtYCBU1u/9j3eZya1ygl/6ndSX1RukWhURpZushiCNrDjNwdv7bt6 iJz54lcCBeYGUK27N/uI9gkzKyj+OryLYtQtnxWulJhfbd0uVJsi46tSLF7vNppCvSAF nDI7fNIyvRvwbg5wxMCbEeFAJh92JdG7osp6LiuzZzOqxl/v6yl18nFlOIiHcaPjX5EK cVNw== 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 x5-v6si6739367pgg.75.2018.08.04.04.05.47; Sat, 04 Aug 2018 04:06:02 -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 S1729655AbeHDNEh (ORCPT + 99 others); Sat, 4 Aug 2018 09:04:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726855AbeHDNEh (ORCPT ); Sat, 4 Aug 2018 09:04:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9A638197031; Sat, 4 Aug 2018 11:04:15 +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 7E41C2026D66; Sat, 4 Aug 2018 11:04:15 +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 w74B4EZ0000455; Sat, 4 Aug 2018 07:04:14 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w74B4Dsu000400; Sat, 4 Aug 2018 07:04:13 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Sat, 4 Aug 2018 07:04:13 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Andrew Pinski cc: Richard Earnshaw , ard.biesheuvel@linaro.org, Ramana Radhakrishnan , Florian Weimer , thomas.petazzoni@free-electrons.com, GNU C Library , Catalin Marinas , Will Deacon , linux@armlinux.org.uk, LKML , linux-arm-kernel@lists.infradead.org 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.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Sat, 04 Aug 2018 11:04:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Sat, 04 Aug 2018 11:04:15 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Fri, 3 Aug 2018, Andrew Pinski wrote: > On Fri, Aug 3, 2018 at 5:58 PM Mikulas Patocka wrote: > > > > > > > > On Fri, 3 Aug 2018, Richard Earnshaw (lists) wrote: > > > > > Whoa, hold on. > > > > > > Memcpy should never be used on device memory. Period. Memcpy doesn't > > > know anything about what size of access is needed for accessing a device. > > > > > > But why is the buffer in device memory rather than some other form of > > > uncached memory? > > > > > > If you change memcpy to deal with an aspect of the system hardware, > > > you'll end up hosing performance EVERYWHERE. DON'T DO IT! > > > > memcpy in glibc uses ifunc selection and it already has optimized variants > > for Falkor and Thunder-X. You can add just another variant for Armada-8040 > > that works around this bug and you won't be harming anyone but users of > > Armada-8040. > > Except it is not a bug in the ARMADA at all. It is a bug in thinking > memcpy will work on non-DRAM memory. 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. > Can you run the test program on x86 using the similar framebuffer > setup? Does doing two writes (one aligned and one unaligned but > overlapping with previous one) cause the same issue? I suspect it > does, then using memcpy for frame buffers is wrong. > > Thanks, > Andrew Overlapping unaligned writes work on x86 - they have to, because of backward compatibility. 8086, 80286 and 80386 didn't have any cache at all. 80486 and Pentium had cache, but when the CPU was reading some data from memory, the motherboard could disable cacheability for this data by a special pin. Software didn't have to do any explicit cache management - programs for 80386 that expected that there's no cache worked flawlessly on 80486 and Pentium. Pentium Pro had memory type range registers that determine cacheability of various memory regions (so that it could allocate a cache line on write without having to query the motherboard if the particular region of memory is cacheable) - but the MTRRs were set by BIOS and the software didn't have to care about them at all - an 80386 operating system that had no idea of cacheability would still work on Pentium Pro. MTRRs could also set a write-combining mode on a region of memory - but again, this is completely transparent to the software (the write combining buffers are flushed when accessing an I/O port or uncacheable memory) - so that an accelerated graphics driver written for Pentium that had no idea of write-combining would still work on Pentium Pro with write combining enabled. Mikulas