ath10k.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* imx7: dev->coherent_dma_mask NULL warning
@ 2021-08-18  0:23 Fabio Estevam
  2021-08-18  5:11 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2021-08-18  0:23 UTC (permalink / raw)
  To: Kalle Valo; +Cc: ath10k, Ulf Hansson, Bough Chen, linux-mmc, Christoph Hellwig

Hi,

Launching the hostapd application on an imx7d based board with an
ath10k Wifi chip leads to the following warning:

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 489 at kernel/dma/mapping.c:427 dma_alloc_attrs+0xd0/0x114
 Modules linked in: ath10k_sdio ath10k_core ath
 CPU: 0 PID: 489 Comm: hostapd Not tainted 5.10.48-stable-standard #1
 Hardware name: Freescale i.MX7 Dual (Device Tree)
 [<c0111378>] (unwind_backtrace) from [<c010bc04>] (show_stack+0x10/0x14)
 [<c010bc04>] (show_stack) from [<c0e26094>] (dump_stack+0xdc/0x104)
 [<c0e26094>] (dump_stack) from [<c0125574>] (__warn+0xd8/0x114)
 [<c0125574>] (__warn) from [<c0e20ecc>] (warn_slowpath_fmt+0x60/0xbc)
 [<c0e20ecc>] (warn_slowpath_fmt) from [<c01b9eac>] (dma_alloc_attrs+0xd0/0x114)
 [<c01b9eac>] (dma_alloc_attrs) from [<bf01373c>]
(ath10k_add_interface+0x2f0/0x1094 [ath10k_core])
 [<bf01373c>] (ath10k_add_interface [ath10k_core]) from [<c0d94470>]
(drv_add_interface+0x88/0x2fc)
 [<c0d94470>] (drv_add_interface) from [<c0db6c58>]
(ieee80211_do_open+0x4c8/0xc70)
 [<c0db6c58>] (ieee80211_do_open) from [<c0b12b7c>] (__dev_open+0xf0/0x170)
 [<c0b12b7c>] (__dev_open) from [<c0b12f40>] (__dev_change_flags+0x164/0x1d0)
 [<c0b12f40>] (__dev_change_flags) from [<c0b12fc4>]
(dev_change_flags+0x18/0x48)
 [<c0b12fc4>] (dev_change_flags) from [<c0bcf968>] (devinet_ioctl+0x6d4/0x868)
 [<c0bcf968>] (devinet_ioctl) from [<c0bd2684>] (inet_ioctl+0x210/0x3b0)
 [<c0bd2684>] (inet_ioctl) from [<c0ae44d4>] (sock_ioctl+0x56c/0x718)
 [<c0ae44d4>] (sock_ioctl) from [<c02ccfb8>] (sys_ioctl+0xf0/0xbf0)
 [<c02ccfb8>] (sys_ioctl) from [<c0100080>] (ret_fast_syscall+0x0/0x28)
 Exception stack(0xc3293fa8 to 0xc3293ff0)
 3fa0:                   bea0190c 00000000 00000008 00008914 bea0190c 00001003
 3fc0: bea0190c 00000000 00000008 00000036 00eeef10 00eeedb8 00000000 000186a0
 3fe0: 0051dbcc bea018fc 004ba26d b6c49fb8
 irq event stamp: 145521
 hardirqs last  enabled at (145531): [<c01949f4>] console_unlock+0x434/0x654
 hardirqs last disabled at (145540): [<c01949ec>] console_unlock+0x42c/0x654
 softirqs last  enabled at (145472): [<c0101604>] __do_softirq+0x324/0x5c4
 softirqs last disabled at (145415): [<c012e1bc>] irq_exit+0x17c/0x1dc
 ---[ end trace 37715f05492d4493 ]---

which comes from:

void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
....
WARN_ON_ONCE(!dev->coherent_dma_mask);

Where should the coherent_dma_mask be set to avoid this problem?

Thanks,

Fabio Estevam

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: imx7: dev->coherent_dma_mask NULL warning
  2021-08-18  0:23 imx7: dev->coherent_dma_mask NULL warning Fabio Estevam
@ 2021-08-18  5:11 ` Christoph Hellwig
  2021-08-18  9:31   ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2021-08-18  5:11 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Kalle Valo, ath10k, Ulf Hansson, Bough Chen, linux-mmc,
	Christoph Hellwig

On Tue, Aug 17, 2021 at 09:23:26PM -0300, Fabio Estevam wrote:
> 
> void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
> ....
> WARN_ON_ONCE(!dev->coherent_dma_mask);
> 
> Where should the coherent_dma_mask be set to avoid this problem?

Looking at the ath10k code ar->dev is set by ath10k_core_create, which
has multiple callers.

For ath10k_pci_probe it is a pci_dev, whoch should always have a
dma_mask.
For ath10k_ahb_probe is is a device tree probed platform_device,
which should have a dma mask.
For ath10k_sdio_probe it is a sdio_func, which from my understanding is
a virtual device can't do DMA itself.
For ath10k_snoc_probe it is a platform device wit an explicit
dma_set_mask_and_coherent and above so the dma_mask is set.
For ath10k_usb_probe it is an usb device which can't do USB

So unless I misred the driver you're using the SDIO or USB variant,
and those are not allowed to just call dma_* functions on their
respective devices.

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: imx7: dev->coherent_dma_mask NULL warning
  2021-08-18  5:11 ` Christoph Hellwig
@ 2021-08-18  9:31   ` Fabio Estevam
  2021-08-18 13:28     ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2021-08-18  9:31 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Kalle Valo, ath10k, Ulf Hansson, Bough Chen, linux-mmc

Hi Christoph,

On Wed, Aug 18, 2021 at 2:11 AM Christoph Hellwig <hch@lst.de> wrote:
>
> On Tue, Aug 17, 2021 at 09:23:26PM -0300, Fabio Estevam wrote:
> >
> > void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
> > ....
> > WARN_ON_ONCE(!dev->coherent_dma_mask);
> >
> > Where should the coherent_dma_mask be set to avoid this problem?
>
> Looking at the ath10k code ar->dev is set by ath10k_core_create, which
> has multiple callers.
>
> For ath10k_pci_probe it is a pci_dev, whoch should always have a
> dma_mask.
> For ath10k_ahb_probe is is a device tree probed platform_device,
> which should have a dma mask.
> For ath10k_sdio_probe it is a sdio_func, which from my understanding is
> a virtual device can't do DMA itself.
> For ath10k_snoc_probe it is a platform device wit an explicit
> dma_set_mask_and_coherent and above so the dma_mask is set.
> For ath10k_usb_probe it is an usb device which can't do USB
>
> So unless I misred the driver you're using the SDIO or USB variant,
> and those are not allowed to just call dma_* functions on their
> respective devices.

Correct, on i.MX7 the ath10k Wifi chip connects via SDIO.

Is there a way to avoid the WARN_ON_ONCE(!dev->coherent_dma_mask)
to happen in this case?

Thanks

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: imx7: dev->coherent_dma_mask NULL warning
  2021-08-18  9:31   ` Fabio Estevam
@ 2021-08-18 13:28     ` Christoph Hellwig
  2021-08-18 13:37       ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2021-08-18 13:28 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Christoph Hellwig, Kalle Valo, ath10k, Ulf Hansson, Bough Chen,
	linux-mmc

On Wed, Aug 18, 2021 at 06:31:19AM -0300, Fabio Estevam wrote:
> Correct, on i.MX7 the ath10k Wifi chip connects via SDIO.
> 
> Is there a way to avoid the WARN_ON_ONCE(!dev->coherent_dma_mask)
> to happen in this case?

The way to avoid it is by stoppind to use dma_alloc_attrs/coherent
on a device that is not DMA capable.

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: imx7: dev->coherent_dma_mask NULL warning
  2021-08-18 13:28     ` Christoph Hellwig
@ 2021-08-18 13:37       ` Fabio Estevam
  2021-08-18 14:47         ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2021-08-18 13:37 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Kalle Valo, ath10k, Ulf Hansson, Bough Chen, linux-mmc

Hi Christoph,

On Wed, Aug 18, 2021 at 10:28 AM Christoph Hellwig <hch@lst.de> wrote:
>
> On Wed, Aug 18, 2021 at 06:31:19AM -0300, Fabio Estevam wrote:
> > Correct, on i.MX7 the ath10k Wifi chip connects via SDIO.
> >
> > Is there a way to avoid the WARN_ON_ONCE(!dev->coherent_dma_mask)
> > to happen in this case?
>
> The way to avoid it is by stoppind to use dma_alloc_attrs/coherent
> on a device that is not DMA capable.

Understood, thanks.

Maybe something like this (untested)?
https://pastebin.com/xTZqtRqD

Kalle,

From an ath10k driver perspective: would you have any suggestions as
to how to stop calling
dma_alloc_coherent() for the SDIO and USB cases?

Thanks

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: imx7: dev->coherent_dma_mask NULL warning
  2021-08-18 13:37       ` Fabio Estevam
@ 2021-08-18 14:47         ` Fabio Estevam
  0 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2021-08-18 14:47 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Kalle Valo, ath10k, Ulf Hansson, Bough Chen, linux-mmc

On Wed, Aug 18, 2021 at 10:37 AM Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Christoph,
>
> On Wed, Aug 18, 2021 at 10:28 AM Christoph Hellwig <hch@lst.de> wrote:
> >
> > On Wed, Aug 18, 2021 at 06:31:19AM -0300, Fabio Estevam wrote:
> > > Correct, on i.MX7 the ath10k Wifi chip connects via SDIO.
> > >
> > > Is there a way to avoid the WARN_ON_ONCE(!dev->coherent_dma_mask)
> > > to happen in this case?
> >
> > The way to avoid it is by stoppind to use dma_alloc_attrs/coherent
> > on a device that is not DMA capable.
>
> Understood, thanks.
>
> Maybe something like this (untested)?
> https://pastebin.com/xTZqtRqD

Tested it on the board and this seems to work fine. I will submit a
proper patch.

Thanks

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-18 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18  0:23 imx7: dev->coherent_dma_mask NULL warning Fabio Estevam
2021-08-18  5:11 ` Christoph Hellwig
2021-08-18  9:31   ` Fabio Estevam
2021-08-18 13:28     ` Christoph Hellwig
2021-08-18 13:37       ` Fabio Estevam
2021-08-18 14:47         ` Fabio Estevam

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).