From patchwork Mon Jul 7 16:03:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 4496181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 267CABEEAA for ; Mon, 7 Jul 2014 16:05:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A254201EF for ; Mon, 7 Jul 2014 16:05:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59AEB201CD for ; Mon, 7 Jul 2014 16:05:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4BO9-0002jI-Q8; Mon, 07 Jul 2014 16:03:33 +0000 Received: from dns-bn1lp0143.outbound.protection.outlook.com ([207.46.163.143] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4BO7-0002ca-5N for linux-arm-kernel@lists.infradead.org; Mon, 07 Jul 2014 16:03:32 +0000 Received: from DM2PR02CA009.namprd02.prod.outlook.com (10.141.52.147) by CY1PR0201MB0921.namprd02.prod.outlook.com (25.160.164.153) with Microsoft SMTP Server (TLS) id 15.0.974.11; Mon, 7 Jul 2014 16:03:08 +0000 Received: from BN1BFFO11FD005.protection.gbl (2a01:111:f400:7c10::1:190) by DM2PR02CA009.outlook.office365.com (2a01:111:e400:2414::19) with Microsoft SMTP Server (TLS) id 15.0.980.8 via Frontend Transport; Mon, 7 Jul 2014 16:03:07 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BN1BFFO11FD005.mail.protection.outlook.com (10.58.144.68) with Microsoft SMTP Server id 15.0.980.11 via Frontend Transport; Mon, 7 Jul 2014 16:03:07 +0000 X-WSS-ID: 0N8CN94-08-2PN-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 29B6ABD8686; Mon, 7 Jul 2014 11:03:03 -0500 (CDT) Received: from SATLEXDAG02.amd.com (10.181.40.5) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.2.328.9; Mon, 7 Jul 2014 11:03:49 -0500 Received: from tlendack-t1.amdoffice.net (10.180.168.240) by SATLEXDAG02.amd.com (10.181.40.5) with Microsoft SMTP Server id 14.2.328.9; Mon, 7 Jul 2014 12:03:03 -0400 Subject: [PATCH] arm64/dma: Flush the coherent mapping in __dma_alloc_noncoherent To: , , From: Tom Lendacky Date: Mon, 7 Jul 2014 11:03:03 -0500 Message-ID: <20140707160303.30884.66565.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.15 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(428002)(189002)(199002)(87936001)(79102001)(19580405001)(103116003)(50986999)(229853001)(105586002)(74502001)(68736004)(95666004)(85852003)(97736001)(102836001)(107886001)(46102001)(107046002)(86362001)(50466002)(80022001)(54356999)(77982001)(74662001)(4396001)(84676001)(20776003)(23676002)(83506001)(44976005)(83322001)(19580395003)(101416001)(92726001)(106466001)(92566001)(2201001)(21056001)(81542001)(83072002)(33646001)(99396002)(81342001)(85306003)(31966008)(64706001)(77096002)(47776003)(53416004)(76482001)(71626003); DIR:OUT; SFP:; SCL:1; SRVR:CY1PR0201MB0921; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 02652BD10A Received-SPF: None (: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=Thomas.Lendacky@amd.com; X-OriginatorOrg: amd4.onmicrosoft.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140707_090331_393640_AF987071 X-CRM114-Status: GOOD ( 11.48 ) X-Spam-Score: -0.8 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In 3.15 (-rc3) the default arm64 DMA operations changed from coherent to non-coherent operations. This change broke some devices. The associated devices were specifying AXI domain and cache coherency signals equal to write-back, no-allocate. Given that the non-coherent operations resulted in un-cached operations, the device should have succeeded even with those cache coherency signals (the DMA should not have found anything in cache and went to memory). But this was not the case. Not until the coherent mapping range was flushed did the device work properly. In __dma_alloc_noncoherent the allocated memory is flushed but the coherent mapping is not. If a device is performing DMA with non-allocating caching hints (will look in cache, but if not found will go to memory and not allocate a cache entry) this could result in unpredictable results. So flush the coherent mapping as well. Signed-off-by: Tom Lendacky --- arch/arm64/mm/dma-mapping.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 4164c5a..56bdd89 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -120,6 +120,9 @@ static void *__dma_alloc_noncoherent(struct device *dev, size_t size, if (!coherent_ptr) goto no_map; + /* remove any dirty cache lines on the mapping */ + __dma_flush_range(coherent_ptr, coherent_ptr + size); + return coherent_ptr; no_map: