linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Noralf Trønnes" <noralf@tronnes.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] staging: fbtft: do not override DMA coherent mask
Date: Tue, 3 Jan 2017 18:18:01 +0100	[thread overview]
Message-ID: <74ef3c4d-6223-e2c6-5d72-bab4b4735093@tronnes.org> (raw)
In-Reply-To: <1483451934.9552.205.camel@linux.intel.com>


Den 03.01.2017 14:58, skrev Andy Shevchenko:
> On Tue, 2017-01-03 at 12:51 +0200, Andy Shevchenko wrote:
>> On Mon, 2017-01-02 at 19:14 +0100, Noralf Trønnes wrote:
>>> Den 02.01.2017 12:35, skrev Andy Shevchenko:
>>>> Usually it's not consumer's business to override resources passed
>>>> from
>>>> provider, in particularly DMA coherent mask.
>>>> --- a/drivers/staging/fbtft/fbtft-core.c
>>>> +++ b/drivers/staging/fbtft/fbtft-core.c
>>>> @@ -841,7 +841,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct
>>>> fbtft_display *display,
>>>>    	if (txbuflen > 0) {
>>>>    #ifdef CONFIG_HAS_DMA
>>>>    		if (dma) {
>>>> -			dev->coherent_dma_mask = ~0;
>>> Can we make this conditional like in of_dma_configure():
>>>
>>>            if (!dev->coherent_dma_mask)
>>>                   dev->coherent_dma_mask = DMA_BIT_MASK(32);
>>>
>>> If not, I guess the mask has to be set before adding the spi device
>>> in
>>> fbtft_device.c to keep it from breaking.
>> Good point. I will check this.
> So, I was too fast.
>
> Clearly an SPI slave device does not and *should not* know about DMA
> capabilities of SPI *host* controller. It's completely out of slave's
> business.
>
> The masks and other DMA properties only makes sense for the device which
> *actually does DMA*, and apparently SPI slaves do not suit that category
> (there are might be real SPI slaves with private DMA engines, though
> it's another story).
>
> Thus, the patch from my point of view should be kept in the same form.
>
> Regarding to the kbuild bot warning, would you like me to resend it
> fixed? Whatever the decision, I will wait for more comments and
> hopefully your tags.
>
> P.S. I dunno how it did work before, since DMA mask of slave device
> basically has no effect. Perhaps first argument to allocator should be
> NULL. That's only amendment I can see to this particular patch.
>

I have looked at this more closely and it seems that
spi_message.is_dma_mapped is deprecated. And if the spi master driver
can do dma, then the spi core will dma map the buffer (spi_map_buf()
even does vmalloc'ed buffers), and this is what happens for most dma
capable master drivers it seems. Since kmalloc allocates buffers that
is always dma mappable, we can always use kmalloc() instead of
dmam_alloc_coherent() for the transfer buffer.

In addition cleaning up these would prevent any later confusion:

drivers/staging/fbtft/fbtft.h:

  struct fbtft_par {
          struct {
                  void *buf;
-                dma_addr_t dma;
                  size_t len;
          } txbuf;


drivers/staging/fbtft/fbtft-core.c:

-#include <linux/dma-mapping.h>

-#ifdef CONFIG_HAS_DMA
-static bool dma = true;
-module_param(dma, bool, 0);
-MODULE_PARM_DESC(dma, "Use DMA buffer");
-#endif

         if (par->txbuf.buf)
-               sprintf(text1, ", %zu KiB %sbuffer memory",
-                       par->txbuf.len >> 10, par->txbuf.dma ? "DMA " : "");
+               sprintf(text1, ", %zu KiB buffer memory", par->txbuf.len 
 >> 10);


drivers/staging/fbtft/fbtft-io.c:

  int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len)
-       if (par->txbuf.dma && buf == par->txbuf.buf) {
-               t.tx_dma = par->txbuf.dma;
-               m.is_dma_mapped = 1;
-       }

  reply	other threads:[~2017-01-03 17:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-02 11:35 [PATCH v2 0/6] fbtft: make it work with DMA enabled SPI Andy Shevchenko
2017-01-02 11:35 ` [PATCH v2 1/6] staging: fbtft: convert fbtft_reset() to be non-atomic Andy Shevchenko
2017-01-03 17:22   ` Noralf Trønnes
2017-01-02 11:35 ` [PATCH v2 2/6] staging: fbtft: do not override DMA coherent mask Andy Shevchenko
2017-01-02 18:14   ` Noralf Trønnes
2017-01-03 10:51     ` Andy Shevchenko
2017-01-03 13:58       ` Andy Shevchenko
2017-01-03 17:18         ` Noralf Trønnes [this message]
2017-01-02 11:35 ` [PATCH v2 3/6] staging: fbtft: fallback to usual allocation when DMA fails Andy Shevchenko
2017-01-03 16:12   ` Andy Shevchenko
2017-01-03 17:23     ` Noralf Trønnes
2017-01-02 11:35 ` [PATCH v2 4/6] staging: fbtft: propagate error code from kstrto*() Andy Shevchenko
2017-01-02 18:19   ` kbuild test robot
2017-01-02 11:35 ` [PATCH v2 5/6] staging: fbtft: fb_ssd1306: Support smaller screen sizes Andy Shevchenko
2017-01-03 17:27   ` Noralf Trønnes
2017-01-02 11:35 ` [PATCH v2 6/6] staging: fbtft: fb_ssd1306: Refactor write_vmem() Andy Shevchenko
2017-01-02 11:37 ` [PATCH v2 0/6] fbtft: make it work with DMA enabled SPI Andy Shevchenko
2017-01-03 15:27   ` Greg Kroah-Hartman
2017-01-03 15:49     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74ef3c4d-6223-e2c6-5d72-bab4b4735093@tronnes.org \
    --to=noralf@tronnes.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).