From patchwork Tue Oct 13 01:38:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 7380601 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4DC009F302 for ; Tue, 13 Oct 2015 01:39:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EA3820988 for ; Tue, 13 Oct 2015 01:39:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A26B920985 for ; Tue, 13 Oct 2015 01:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932276AbbJMBj1 (ORCPT ); Mon, 12 Oct 2015 21:39:27 -0400 Received: from mail-ob0-f182.google.com ([209.85.214.182]:36596 "EHLO mail-ob0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932248AbbJMBjZ (ORCPT ); Mon, 12 Oct 2015 21:39:25 -0400 Received: by obbrx8 with SMTP id rx8so2539658obb.3; Mon, 12 Oct 2015 18:39:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9ICgLuioUwDPAo6jkyEgdtmlfwYC0mdPkFOU3fGmzwg=; b=k557kXnX4V6WhPOEKLC5mAOSEX35bUkjl6GLLCAGD6V523YB+D/jsxH+lTj24vkeNp +W9sO64cnU/JPtQPUG8wSNMj+HjJvBFkbDxLJxI6x5g7moXrXT8rfyP6IKrzHFXsnqx7 JNu88dMMw4fKuGLYa4G78qo0rhoaI9PK32VwgPww4B6v0orCft/b7cWp9v0yAVBijxmC e9o3NoVF8TxokYFZNLDgL7caw3cj+AP9fJ+FWgOQktQOqQ61qZEFVUHlFei2Qs6khqsI fCq9S/vFYvlu7filwkRFNl+n8K56MxrURkVqXFSEOK5fgvGSV9XmsRzP8p+dwtUzMP1m Zsmg== X-Received: by 10.60.23.104 with SMTP id l8mr17437366oef.19.1444700365156; Mon, 12 Oct 2015 18:39:25 -0700 (PDT) Received: from localhost.localdomain (pool-71-97-41-79.dllstx.fios.verizon.net. [71.97.41.79]) by smtp.gmail.com with ESMTPSA id ta5sm320312obc.13.2015.10.12.18.39.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 18:39:24 -0700 (PDT) From: Franklin S Cooper Jr To: linux-kernel@vger.kernel.org, rogerq@ti.com, devicetree@vger.kernel.org, linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org, nsekhar@ti.com, computersforpeace@gmail.com, dwmw2@infradead.org, tony@atomide.com Cc: Franklin S Cooper Jr Subject: [PATCH 3/5] mtd: nand: omap2: Fix high memory dma prefetch transfer Date: Mon, 12 Oct 2015 20:38:56 -0500 Message-Id: <1444700338-27582-4-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1444700338-27582-1-git-send-email-fcooper@ti.com> References: <1444700338-27582-1-git-send-email-fcooper@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Based on DMA documentation and testing using high memory buffer when doing dma transfers can lead to various issues including kernel panics. To workaround this simply use cpu copy. The amount of high memory buffers used are very uncommon so no noticeable performance hit should be seen. Signed-off-by: Franklin S Cooper Jr --- drivers/mtd/nand/omap2.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 94d11de..537be2f 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -479,17 +479,8 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, int ret; u32 val; - if (addr >= high_memory) { - struct page *p1; - - if (((size_t)addr & PAGE_MASK) != - ((size_t)(addr + len - 1) & PAGE_MASK)) - goto out_copy; - p1 = vmalloc_to_page(addr); - if (!p1) - goto out_copy; - addr = page_address(p1) + ((size_t)addr & ~PAGE_MASK); - } + if (addr >= high_memory) + goto out_copy; sg_init_one(&sg, addr, len); n = dma_map_sg(info->dma->device->dev, &sg, 1, dir); @@ -545,6 +536,7 @@ out_copy: else is_write == 0 ? omap_read_buf8(mtd, (u_char *) addr, len) : omap_write_buf8(mtd, (u_char *) addr, len); + return 0; }