Received: by 10.192.165.156 with SMTP id m28csp463076imm; Wed, 11 Apr 2018 01:58:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+0BBGLTsjG7VhCug+Vv6pqXbsBB9U4JqjqpSvARvje+QgftEQ9ym3K8a6ND30BBBsETZOI X-Received: by 2002:a17:902:9a82:: with SMTP id w2-v6mr4103518plp.6.1523437096664; Wed, 11 Apr 2018 01:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523437096; cv=none; d=google.com; s=arc-20160816; b=M3z1lx3zxjYHX5LDvSK01HGI8tYueUFqTVLjE0bP4LtLlMdR5oYjvtd0isZ95C3i9S 2r76YNldc3opZeoISZi2k0J79rskyezH7GXmjy9a6jQDL4ekPY1N0bS1n1ecxhFEv0gG huo/LbOq2sv1FT++DXQmIrQsU6Aw7q5UNRKrEwQDfolbFL43qo9YqZtg3MMbrYDrQYSY S6SPTjT6f9O7Dw4z5wDai+4qlXmyjIAK0Xs2WiohbKY8NS5uIsPSD3/DDeDGY4wHGCop bElomZ7NAu8DgU8Qetm1JUks3JM3O51WNzse4omqvFNq7K2M+PoGFupKpS3eqvreV10W IGbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=sRI/p3pT53tvBEV50UbaCRoafhF6Z6pyD2hyFRFtW3s=; b=lB1e8oanwfj85FmnX/JWk3y9egvBU2fFUmLF7sVGzZvtAUa7f9oiJnpL2PKz37TWiH bB7YDor1JK+V854huG5aXPOFVPx6uEduuntO8sKZPvyzplspCL5FRszaB5p9uaZ0V/Pp WmOvWv8ihoxV2FZAuLrn0yFoXUi06xcjSG1bevnBq6Lf0+abzFaEyc0E3r1Qr4Kh5lXU yLpROz9wkQlgDNeckt9hSlVJu/4GmOqp2j3DflsqiVNV7k8ummP6qJVab90+aRA0YU1k Zc/HXxK63lmeAR5rVpXpW5ekZm8/jS+W2dQ8Kz8lYLm84JY3WkTkicO9gAMu8cRJneyA R5RQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si638632plb.536.2018.04.11.01.57.39; Wed, 11 Apr 2018 01:58:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbeDKIwh (ORCPT + 99 others); Wed, 11 Apr 2018 04:52:37 -0400 Received: from mail.bootlin.com ([62.4.15.54]:44171 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752016AbeDKIwe (ORCPT ); Wed, 11 Apr 2018 04:52:34 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id CB155204AD; Wed, 11 Apr 2018 10:52:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 18FAE207B2; Wed, 11 Apr 2018 10:52:02 +0200 (CEST) Date: Wed, 11 Apr 2018 10:52:01 +0200 From: Boris Brezillon To: Ladislav Michl Cc: Andreas Kemnade , Discussions about the Letux Kernel , Boris Brezillon , Aaro Koskinen , Tony Lindgren , Linux Kernel Mailing List , Peter Ujfalusi , linux-omap , Roger Quadros Subject: Re: [Letux-kernel] [Bug]: mtd: onenand: omap2plus: kernel panic with OneNAND on OMAP3 (DM3730) device GTA04A5 Message-ID: <20180411105201.5f126e94@bbrezillon> In-Reply-To: <20180411082746.GA20164@lenoch> References: <5D496D5C-4E3E-47B4-9981-E8F4C348DE00@goldelico.com> <20180410205643.GA2228@lenoch> <20180411065836.7e1bfc3f@aktux> <20180411062607.GA9179@lenoch> <20180411091528.4e954c32@bbrezillon> <20180411073655.GA18273@lenoch> <20180411100806.3c09bafc@bbrezillon> <20180411082746.GA20164@lenoch> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Apr 2018 10:27:46 +0200 Ladislav Michl wrote: > On Wed, Apr 11, 2018 at 10:08:06AM +0200, Boris Brezillon wrote: > > On Wed, 11 Apr 2018 09:36:56 +0200 > > Ladislav Michl wrote: > > > > > Hi Boris, > > > > > > On Wed, Apr 11, 2018 at 09:15:28AM +0200, Boris Brezillon wrote: > [...] > > > > Not sure this approach is safe on all archs: if the cache is VIVT or > > > > VIPT, you may have several entries pointing to the same phys page, and > > > > then, when dma_map_page() does its cache maintenance operations, it's > > > > only taking one of these entries into account. > > > > > > Hmm, I used the same approach Samsung OneNAND driver does since commit > > > dcf08227e964a53a2cb39130b74842c7dcb6adde. > > > Both TI OMAP3630 and Samsung S5PC110 are using Cortex-A8 which > > > is VIPT. In that case samsung's driver code has the same problem. > > > > > > > In other parts of the MTD subsystem, we tend to not do DMA on buffers > > > > that have been vmalloc-ed. > > > > > > > > You can do something like > > > > > > > > if (virt_addr_valid(buf)) > > > > /* Use DMA */ > > > > else > > > > /* > > > > * Do not use DMA, or use a bounce buffer > > > > * allocated with kmalloc > > > > */ > > > > > > Okay, I'll use this approach then, but first I'd like to be sure above is > > > correct. Anyone? > > > > See this discussion [1]. The problem came up a few times already, so > > might find other threads describing why it's not safe. > > > > [1]https://lists.linuxfoundation.org/pipermail/iommu/2016-March/016240.html > > Question was more likely whenever there might exist more that one mapping > of the same page. I'm clearly not an expert, so I might be wrong, but I think a physical page can be both in the identity mapping and mapped in the vmalloc space. Now, is there a real risk that both ends are accessed in parallel thus making different cache entries pointing to the same phys page dirty, I'm not sure. Or maybe there are other corner case, but you'll have to ask Russell (or any other ARM expert) to get a clearer answer. > But okay, I'll disable DMA for highmem. Patch will follow. > > ladis