Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp7166340ybn; Mon, 30 Sep 2019 09:35:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNTc8+pvd4tf5bwW9G6CmfhnB8swnMGSFSqCU2fg0dl5ZyMKcftLzBpMcCcTWuc42cY71i X-Received: by 2002:aa7:cd5a:: with SMTP id v26mr20482331edw.256.1569861305318; Mon, 30 Sep 2019 09:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569861305; cv=none; d=google.com; s=arc-20160816; b=smou20yLUshJS3pdTIhnIqj/b7XwxN2qfnsRU/Q5A7GX7CvBGSljXujIx7xOmnJ/DD BnCgXAT7L/bCCJQCgVrLNOLYdkenzc3T7u4pvHzhudiCin3wJblnQEIX63sdhygLj2Oh YYUTgGmfwCAuSHg5hd+ciJCdVTg/htqVXriSMvd69WzxGzkNYOXDq8cJFdGEA1xfjJOu CdGkiGzeN4sH5ggwZGx36ubVi5yHupV3uVQ5HHU2K5ALkznxykKEyoJfbUHnzWXcb3bo 026DxNE9Cfb0zKrN5WnbWOBn3XcvHPB28VU6TXcMgWv8/zCTX5Jv4E8HhVOdrgHXzJvQ 9K6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=X342zlUizHRvyrES5Pcuxcu7FqW9SI8435jSZaU4FUM=; b=hN8KWgaWYo5v6yo7YYmA5UCdp4qz9j0ESocFZqzO1vN5r6sZ1xTBckaNsCpZ8iVaNe qI21D4dgnfsUVk0iCS+ReCdHpwxrolacSL+xQwAq7YcF2ai6fu5ROA//nSyQ/3x4qlAI nqrTRlKghkdWthbMN5GVQMLD9KeQ3Nj9ynPJ0D74uSSXMPkMJiIZIhVGnVwVgtR9x3lx Rj3dfj2aMrcsY1DOMizwJe9xaNkRG8mOpt6AYgOX8T/INuTLPNuo/z8xcjswvV9FP+wE PMX5mrBhM3/6XKrMqu+l31/dqQ+/DWe8cZDbOHuBrpnzkOB3KJT5jY2OKZYWtJvNaMKu gaWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="Sj/iKyao"; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u27si7566811ejb.172.2019.09.30.09.34.40; Mon, 30 Sep 2019 09:35:05 -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; dkim=pass header.i=@broadcom.com header.s=google header.b="Sj/iKyao"; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732197AbfI3Qdr (ORCPT + 99 others); Mon, 30 Sep 2019 12:33:47 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45941 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731976AbfI3Qdq (ORCPT ); Mon, 30 Sep 2019 12:33:46 -0400 Received: by mail-lj1-f194.google.com with SMTP id q64so10154608ljb.12 for ; Mon, 30 Sep 2019 09:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X342zlUizHRvyrES5Pcuxcu7FqW9SI8435jSZaU4FUM=; b=Sj/iKyaonBeAKT/qexlrU1VcHkXhgVA1m/q+Mo3IH33PIj7FTe8dgUPhIfckAOEEJD X3agXJR14Qk2KjTT5kojgLMM2ZXbrFmkGk2mA4BELlyzxwkVss1gCi2Ph/Nj718EgBk5 oF9GM7glPghqrDajeUzP264BZ9CihyvJiUNts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X342zlUizHRvyrES5Pcuxcu7FqW9SI8435jSZaU4FUM=; b=jcagcRdZqsc8SUCDnCLyPrulPMFY3/Ny4I1dvGhUhDXmIXQS8HpQLDgunaVEWXiABO CrpiDABxiY8p/Uo7UoN5c307an4WPJ7zKo/FvFKMpNXZxFlmB+Z0lJggaHZ56zSqtS3y L/IU1J+d2CiX/NLkw88ih1fx0Rp6rz6cQ3GNXaLAuruQW38mfabA4EIN3edzNa7iVXZD eLboiPXjBIe80VUAxb2MoYRwBJORCWLmNfGSlGVYVhuMO7uj220Oc4L/zGfJHn1UxiTL jTch9LJnG09FkimYIfe5m6fjrw78lhUtCYFWP7jO3QeXRQ/AtZWaJ01gUhAK0VQ4obfN 8XRg== X-Gm-Message-State: APjAAAVcnNNAPWHQwnR8Rfd6J7zyq38qVS4tQYiW6yOTOP0UO+B8ySZM RvT1qU77gkPhvlN2ULrHpP4O120rBysrw8zybELUJw== X-Received: by 2002:a2e:9853:: with SMTP id e19mr1416618ljj.57.1569861224396; Mon, 30 Sep 2019 09:33:44 -0700 (PDT) MIME-Version: 1.0 References: <20190906194719.15761-1-kdasu.kdev@gmail.com> <20190906194719.15761-2-kdasu.kdev@gmail.com> <20190930182458.761e8077@collabora.com> In-Reply-To: <20190930182458.761e8077@collabora.com> From: Kamal Dasu Date: Mon, 30 Sep 2019 12:33:06 -0400 Message-ID: Subject: Re: [PATCH 2/2] mtd: rawnand: use bounce buffer when vmalloced data buf detected To: Boris Brezillon Cc: Kamal Dasu , Brian Norris , Miquel Raynal , Richard Weinberger , David Woodhouse , Marek Vasut , Vignesh Raghavendra , Boris Brezillon , Frieder Schrempf , MTD Maling List , bcm-kernel-feedback-list@broadcom.com, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 30, 2019 at 12:25 PM Boris Brezillon wrote: > > On Mon, 30 Sep 2019 12:01:28 -0400 > Kamal Dasu wrote: > > > Does anyone have any comments on this patch ?. > > > > Kamal > > > > On Fri, Sep 6, 2019 at 3:49 PM Kamal Dasu wrote: > > > > > > For controller drivers that use DMA and set NAND_USE_BOUNCE_BUFFER > > > option use data buffers that are not vmalloced, aligned and have > > > valid virtual address to be able to do DMA transfers. This change > > > adds additional check and makes use of data buffer allocated > > > in nand_base driver when it is passed a vmalloced data buffer for > > > DMA transfers. > > > > > > Signed-off-by: Kamal Dasu > > > --- > > > drivers/mtd/nand/raw/nand_base.c | 14 ++++++++------ > > > 1 file changed, 8 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > > > index 91f046d4d452..46f6965a896a 100644 > > > --- a/drivers/mtd/nand/raw/nand_base.c > > > +++ b/drivers/mtd/nand/raw/nand_base.c > > > @@ -45,6 +45,12 @@ > > > > > > #include "internals.h" > > > > > > +static int nand_need_bounce_buf(const void *buf, struct nand_chip *chip) > > > +{ > > > + return !virt_addr_valid(buf) || is_vmalloc_addr(buf) || > > I thought virt_addr_valid() was implying !is_vmalloc_addr(), are you > sure you need that test, and can you tell me on which arch(es) this is > needed. > This has been observed on MIPS4K and MIPS5K architectures. There is a check on the controller driver to use pio in such cases. > > > + !IS_ALIGNED((unsigned long)buf, chip->buf_align); > > > +} > > > + > > > /* Define default oob placement schemes for large and small page devices */ > > > static int nand_ooblayout_ecc_sp(struct mtd_info *mtd, int section, > > > struct mtd_oob_region *oobregion) > > > @@ -3183,9 +3189,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, > > > if (!aligned) > > > use_bufpoi = 1; > > > else if (chip->options & NAND_USE_BOUNCE_BUFFER) > > > - use_bufpoi = !virt_addr_valid(buf) || > > > - !IS_ALIGNED((unsigned long)buf, > > > - chip->buf_align); > > > + use_bufpoi = nand_need_bounce_buf(buf, chip); > > > else > > > use_bufpoi = 0; > > > > > > @@ -4009,9 +4013,7 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to, > > > if (part_pagewr) > > > use_bufpoi = 1; > > > else if (chip->options & NAND_USE_BOUNCE_BUFFER) > > > - use_bufpoi = !virt_addr_valid(buf) || > > > - !IS_ALIGNED((unsigned long)buf, > > > - chip->buf_align); > > > + use_bufpoi = nand_need_bounce_buf(buf, chip); > > > else > > > use_bufpoi = 0; > > > > > > -- > > > 2.17.1 > > > >