Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1849222imm; Thu, 11 Oct 2018 00:24:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV61QjST9zTChiAq7EwJarCr570LPyTlgJKUUQfywLDxuI2t2u4HBDX0LKVPO4o4ztso07//x X-Received: by 2002:a63:df4f:: with SMTP id h15-v6mr392905pgj.94.1539242661216; Thu, 11 Oct 2018 00:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539242661; cv=none; d=google.com; s=arc-20160816; b=hHTvYQncSD30kywRMz7o12L7F6Gu+gGIedJIDVej9jmaIamy8OVXTuYgWvAE1sRoNN v4bBtkh/hAr+cnKND38UmgHtBy11W07Lm9n2It5fgTLExz2YEh9+9Ej1PlPZwkxfPslZ 0ZhEJ5EX9+VVcY+XxkArJrCvhaF2V/iJZDSc8+ucTTMsOHHFBWZ+lcjZWGMwVtNQ/T9g 7vHkIVnBqnpuq3PxokuzL4tBVA/+2KYh4Hq5dUoK9aVhTwuc7dnR4Me/5cCu4lqp3Uj9 KshNKlf+uxp30z6kaV7iax9XoVfdLUZT5ImdrViXU2XpSd2nxX1Vy1w77y1PNWcNT6xV 5rSA== 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; bh=blu3qBNqed1JoPOHvC9y1QXSXwQvgmiV3+YRfSTvnCs=; b=yIkpBv9VqppT5VkUN9jytg1KuwIxBd7NPyCtP8rJ4VNV9Orm0VVQdxEMJAHEA2oSF9 vTCzgt3ziP/98+whUzO5C9QOdStFytSYE9HFH3J6BRo0FHE7bC5F3oD0GiFe5pvEZ/xW Iq1kRlhRShobI9hkAgSMN9J/imYVi5MLKriH61Z8taO1BgVPA2InFnl57j0yHfR6T6vR b6Ro1kJrC+gA29HkYoY+SWxnU8XQNF83PoqiSopVpOa9wIswdIbupQjtDUxwT9BM/ko0 Uyo9IOX4Z3Bl3Qv3yzqKo77FZh7T5So3sQMeq6UmomlIYzNW+Y1tiSEhj/+0W7x2mN3c BYnw== 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 j3-v6si27828230pld.380.2018.10.11.00.24.06; Thu, 11 Oct 2018 00:24:21 -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 S1727733AbeJKOZU (ORCPT + 99 others); Thu, 11 Oct 2018 10:25:20 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:43389 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbeJKOZU (ORCPT ); Thu, 11 Oct 2018 10:25:20 -0400 Received: by mail-vs1-f68.google.com with SMTP id w85so7514678vsa.10; Wed, 10 Oct 2018 23:59:26 -0700 (PDT) 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=blu3qBNqed1JoPOHvC9y1QXSXwQvgmiV3+YRfSTvnCs=; b=nxM1QFC3AeokFQM/AHYiZixrsb2wYL5yNhgAiNKV2BcIvxhOQZQHR++JrwQ/ysf/rf HregPkWoFz1fli3a7ndQr0QhURyNW0l8J0OiTiVGCQ0TQ63JJE8YG0Y2MUnrJHS023C6 4H+qwSfeFvbZTqJiNuypIICnDfjQ3+A7DMDlVkVZRPm93qxwwcaC83Vg9bMxXXWulsqG zwmxVA123ms1Hqq8eYVD370iUE4g+sijovTBWQZQ8jnli0ciR7G8dYuMVdHB0+YfvdYW TXX8ng7kQqWHfqDgRBOxsBfHpA/+1JEQvPDO7ZQGI0jtP+ZmJ9FZhoaQUpA9p9zfNdto Y7fQ== X-Gm-Message-State: ABuFfohMzNO1J0Zw888GiL1R2sGn7sYKqTjO6kiYLvUcvdY4AfaA81yN Y+1+GjPaQgLB+1xbykL7mPvj82VACYSSrTOGSrI= X-Received: by 2002:a9f:35f1:: with SMTP id u46-v6mr168253uad.20.1539241165892; Wed, 10 Oct 2018 23:59:25 -0700 (PDT) MIME-Version: 1.0 References: <20181010134036.8296-1-geert+renesas@glider.be> <20181010134036.8296-4-geert+renesas@glider.be> <1539208063.1944.12.camel@impinj.com> In-Reply-To: <1539208063.1944.12.camel@impinj.com> From: Geert Uytterhoeven Date: Thu, 11 Oct 2018 08:59:13 +0200 Message-ID: Subject: Re: [PATCH 3/3] eeprom: at25: Split writes in two SPI transfers to optimize DMA To: Trent Piepho Cc: Geert Uytterhoeven , Srinivas Kandagatla , Greg KH , Arnd Bergmann , linux-spi , Linux Kernel Mailing List , linux-mtd@vger.kernel.org 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 Hi Trent, On Wed, Oct 10, 2018 at 11:47 PM Trent Piepho wrote: > On Wed, 2018-10-10 at 15:40 +0200, Geert Uytterhoeven wrote: > > Currently EEPROM writes are implemented using a single SPI transfer, > > which contains all of command, address, and payload data bytes. > > As some SPI controllers impose limitations on transfers with respect to > > the use of DMA, they may have to fall back to PIO. E.g. DMA may require > > the transfer length to be a multiple of 4 bytes. > > > > Optimize writes for DMA by splitting writes in two SPI transfers: > > - The first transfer contains command and address bytes, > > - The second transfer contains the actual payload data, now stored at > > the start of the (kmalloc() aligned) buffer, to improve payload > > alignment. > > Does this always optimize? A master capable of an of aligned 18 byte > DMA xfer would now have a 2 byte xfer that would probably be PIO > followed by a 16 byte DMA. > > Or writing 14 bytes to the EEPROM has changed from an aligned 16 byte > write to a 2 byte and a 14 byte, which is now worse for the 4 byte > multiple requirement master which can use any DMA anymore. That's correct. I did consider this case. However, with the small page sizes used (16, 64, or 256 bytes), I'd expect EEPROM users to consider them for their data formats, and thus it IMHO makes sense to optimize for the optimal case, which is currently not the case. Note there may be 1, 2, or 3 address bytes, so it can be a total of 2 + len or 3 + len bytes, too. > It seems like an enhancement to the DMA code to look more like a > efficient memcpy() that aligns the address, then xfers efficient > blocks, then finishes the sub-block tail would be more generally > applicable. > > Or more simply, given an aligned 18 byte xfer, the driver should do an > aligned 16 byte DMA and then two more bytes. That's another option, but that probably needs changes in several drivers, and/or the SPI core (if we want to handle it there). Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds