* dma_map_single returns 0 on ARM
@ 2014-10-24 16:40 Zoltan Kiss
2014-10-25 14:11 ` Stefano Stabellini
0 siblings, 1 reply; 8+ messages in thread
From: Zoltan Kiss @ 2014-10-24 16:40 UTC (permalink / raw)
To: xen-devel
Hi,
I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it
fails when it wants to map the buffers to the device:
phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
RX_BUF_SIZE, DMA_FROM_DEVICE);
This returns 0, while running on bare metal it works. Does anyone has an
advice where should I look?
Regards,
Zoltan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-24 16:40 dma_map_single returns 0 on ARM Zoltan Kiss
@ 2014-10-25 14:11 ` Stefano Stabellini
2014-10-26 20:39 ` Julien Grall
2014-10-27 15:30 ` Zoltan Kiss
0 siblings, 2 replies; 8+ messages in thread
From: Stefano Stabellini @ 2014-10-25 14:11 UTC (permalink / raw)
To: Zoltan Kiss; +Cc: xen-devel
On Fri, 24 Oct 2014, Zoltan Kiss wrote:
> Hi,
>
> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it fails
> when it wants to map the buffers to the device:
>
> phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
> RX_BUF_SIZE, DMA_FROM_DEVICE);
>
> This returns 0, while running on bare metal it works. Does anyone has an
> advice where should I look?
dma_map_single should just be a wrapper around dma_ops->map_page that in
dom0 is implemented by xen_swiotlb_map_page.
>From looking at the code the issue appears to be that dma_capable
returns false for your device.
In any case even if dma_map_single returned a valid address, keep in
mind that at the moment if the device is not dma coherent Linux needs
to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
buffers correctly. But the failure in that case is a memory corruption
after the dma request is completed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-25 14:11 ` Stefano Stabellini
@ 2014-10-26 20:39 ` Julien Grall
2014-10-27 4:42 ` manish jaggi
2014-10-27 15:30 ` Zoltan Kiss
1 sibling, 1 reply; 8+ messages in thread
From: Julien Grall @ 2014-10-26 20:39 UTC (permalink / raw)
To: Stefano Stabellini, Zoltan Kiss; +Cc: xen-devel
Hi all,
On 25/10/2014 15:11, Stefano Stabellini wrote:
> On Fri, 24 Oct 2014, Zoltan Kiss wrote:
>> Hi,
>>
>> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it fails
>> when it wants to map the buffers to the device:
>>
>> phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
>> RX_BUF_SIZE, DMA_FROM_DEVICE);
>>
>> This returns 0, while running on bare metal it works. Does anyone has an
>> advice where should I look?
>
> dma_map_single should just be a wrapper around dma_ops->map_page that in
> dom0 is implemented by xen_swiotlb_map_page.
> From looking at the code the issue appears to be that dma_capable
> returns false for your device.
>
> In any case even if dma_map_single returned a valid address, keep in
> mind that at the moment if the device is not dma coherent Linux needs
> to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
> buffers correctly. But the failure in that case is a memory corruption
> after the dma request is completed.
There is no memory corruption if CONFIG_ARM_LPAE is not enabled. It will
make crash DOM0 because of a BUG_ON in the swiotlb code (checking
truncation between DMA and physical address). This would happen on
platform where there is ram bank above 4G and when a guest is booting.
This option is only necessary for 3.17. Using 3.16 will throw lots of
warning because netback is mapping multiple time the same grant. Linux
3.15 and backwards will be "safe".
Regards,
--
Julien Grall
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-26 20:39 ` Julien Grall
@ 2014-10-27 4:42 ` manish jaggi
2014-10-27 15:45 ` Stefano Stabellini
0 siblings, 1 reply; 8+ messages in thread
From: manish jaggi @ 2014-10-27 4:42 UTC (permalink / raw)
To: Julien Grall; +Cc: Zoltan Kiss, xen-devel, Stefano Stabellini
On 27 October 2014 02:09, Julien Grall <julien.grall@linaro.org> wrote:
> Hi all,
>
> On 25/10/2014 15:11, Stefano Stabellini wrote:
>>
>> On Fri, 24 Oct 2014, Zoltan Kiss wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it
>>> fails
>>> when it wants to map the buffers to the device:
>>>
>>> phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
>>> RX_BUF_SIZE, DMA_FROM_DEVICE);
>>>
>>> This returns 0, while running on bare metal it works. Does anyone has an
>>> advice where should I look?
>>
>>
>> dma_map_single should just be a wrapper around dma_ops->map_page that in
>> dom0 is implemented by xen_swiotlb_map_page.
>> From looking at the code the issue appears to be that dma_capable
>> returns false for your device.
>>
>> In any case even if dma_map_single returned a valid address, keep in
>> mind that at the moment if the device is not dma coherent Linux needs
>> to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
>> buffers correctly. But the failure in that case is a memory corruption
>> after the dma request is completed.
>
>
> There is no memory corruption if CONFIG_ARM_LPAE is not enabled. It will
> make crash DOM0 because of a BUG_ON in the swiotlb code (checking truncation
> between DMA and physical address). This would happen on platform where there
> is ram bank above 4G and when a guest is booting.
>
One basic question, if a system has SMMU (IOMMU) enabled, would xen
still use SWIOTLB for dom0?
> This option is only necessary for 3.17. Using 3.16 will throw lots of
> warning because netback is mapping multiple time the same grant. Linux 3.15
> and backwards will be "safe".
>
> Regards,
>
> --
> Julien Grall
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-27 4:42 ` manish jaggi
@ 2014-10-27 15:45 ` Stefano Stabellini
0 siblings, 0 replies; 8+ messages in thread
From: Stefano Stabellini @ 2014-10-27 15:45 UTC (permalink / raw)
To: manish jaggi; +Cc: Zoltan Kiss, Julien Grall, xen-devel, Stefano Stabellini
On Mon, 27 Oct 2014, manish jaggi wrote:
> On 27 October 2014 02:09, Julien Grall <julien.grall@linaro.org> wrote:
> > Hi all,
> >
> > On 25/10/2014 15:11, Stefano Stabellini wrote:
> >>
> >> On Fri, 24 Oct 2014, Zoltan Kiss wrote:
> >>>
> >>> Hi,
> >>>
> >>> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it
> >>> fails
> >>> when it wants to map the buffers to the device:
> >>>
> >>> phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
> >>> RX_BUF_SIZE, DMA_FROM_DEVICE);
> >>>
> >>> This returns 0, while running on bare metal it works. Does anyone has an
> >>> advice where should I look?
> >>
> >>
> >> dma_map_single should just be a wrapper around dma_ops->map_page that in
> >> dom0 is implemented by xen_swiotlb_map_page.
> >> From looking at the code the issue appears to be that dma_capable
> >> returns false for your device.
> >>
> >> In any case even if dma_map_single returned a valid address, keep in
> >> mind that at the moment if the device is not dma coherent Linux needs
> >> to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
> >> buffers correctly. But the failure in that case is a memory corruption
> >> after the dma request is completed.
> >
> >
> > There is no memory corruption if CONFIG_ARM_LPAE is not enabled. It will
> > make crash DOM0 because of a BUG_ON in the swiotlb code (checking truncation
> > between DMA and physical address). This would happen on platform where there
> > is ram bank above 4G and when a guest is booting.
> >
> One basic question, if a system has SMMU (IOMMU) enabled, would xen
> still use SWIOTLB for dom0?
At the moment yes. Eventually we'll be able to detect that a particular
device is protected by an SMMU and as a consequence we'll just call the
regular dma_ops calls for it.
> > This option is only necessary for 3.17. Using 3.16 will throw lots of
> > warning because netback is mapping multiple time the same grant. Linux 3.15
> > and backwards will be "safe".
> >
> > Regards,
> >
> > --
> > Julien Grall
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > http://lists.xen.org/xen-devel
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-25 14:11 ` Stefano Stabellini
2014-10-26 20:39 ` Julien Grall
@ 2014-10-27 15:30 ` Zoltan Kiss
2014-10-27 15:44 ` Stefano Stabellini
1 sibling, 1 reply; 8+ messages in thread
From: Zoltan Kiss @ 2014-10-27 15:30 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel
On 25/10/14 15:11, Stefano Stabellini wrote:
> On Fri, 24 Oct 2014, Zoltan Kiss wrote:
>> Hi,
>>
>> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it fails
>> when it wants to map the buffers to the device:
>>
>> phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
>> RX_BUF_SIZE, DMA_FROM_DEVICE);
>>
>> This returns 0, while running on bare metal it works. Does anyone has an
>> advice where should I look?
>
> dma_map_single should just be a wrapper around dma_ops->map_page that in
> dom0 is implemented by xen_swiotlb_map_page.
> From looking at the code the issue appears to be that dma_capable
> returns false for your device.
>
> In any case even if dma_map_single returned a valid address, keep in
> mind that at the moment if the device is not dma coherent Linux needs
> to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
> buffers correctly. But the failure in that case is a memory corruption
> after the dma request is completed.
>
Thanks for the advices. I've managed to figure out that dma_map_single
fails because dev->dma_mask was a NULL pointer. I've set it during probe
with this:
dma_coerce_mask_and_coherent(&ndev->dev, DMA_BIT_MASK(32));
And the mappings seems to be set up properly (a bit below 512M), but the
returned buffers are filled up with 0xAA, which I guess is probably some
default value. Turning on and off CONFIG_ARM_LPAE did not helped.
I'll keep looking why is that, if you have an idea let me know.
Zoli
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-27 15:30 ` Zoltan Kiss
@ 2014-10-27 15:44 ` Stefano Stabellini
2014-10-27 15:58 ` Zoltan Kiss
0 siblings, 1 reply; 8+ messages in thread
From: Stefano Stabellini @ 2014-10-27 15:44 UTC (permalink / raw)
To: Zoltan Kiss; +Cc: xen-devel, Stefano Stabellini
On Mon, 27 Oct 2014, Zoltan Kiss wrote:
> On 25/10/14 15:11, Stefano Stabellini wrote:
> > On Fri, 24 Oct 2014, Zoltan Kiss wrote:
> > > Hi,
> > >
> > > I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it
> > > fails
> > > when it wants to map the buffers to the device:
> > >
> > > phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
> > > RX_BUF_SIZE, DMA_FROM_DEVICE);
> > >
> > > This returns 0, while running on bare metal it works. Does anyone has an
> > > advice where should I look?
> >
> > dma_map_single should just be a wrapper around dma_ops->map_page that in
> > dom0 is implemented by xen_swiotlb_map_page.
> > From looking at the code the issue appears to be that dma_capable
> > returns false for your device.
> >
> > In any case even if dma_map_single returned a valid address, keep in
> > mind that at the moment if the device is not dma coherent Linux needs
> > to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
> > buffers correctly. But the failure in that case is a memory corruption
> > after the dma request is completed.
> >
>
> Thanks for the advices. I've managed to figure out that dma_map_single fails
> because dev->dma_mask was a NULL pointer. I've set it during probe with this:
>
> dma_coerce_mask_and_coherent(&ndev->dev, DMA_BIT_MASK(32));
>
> And the mappings seems to be set up properly (a bit below 512M), but the
> returned buffers are filled up with 0xAA, which I guess is probably some
> default value. Turning on and off CONFIG_ARM_LPAE did not helped.
> I'll keep looking why is that, if you have an idea let me know.
Are you trying to do regular DMA in dom0 or are you running other guests?
If you are just doing DMA in dom0, then I don't have any suggestions:
that should work.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dma_map_single returns 0 on ARM
2014-10-27 15:44 ` Stefano Stabellini
@ 2014-10-27 15:58 ` Zoltan Kiss
0 siblings, 0 replies; 8+ messages in thread
From: Zoltan Kiss @ 2014-10-27 15:58 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel
On 27/10/14 15:44, Stefano Stabellini wrote:
> On Mon, 27 Oct 2014, Zoltan Kiss wrote:
>> On 25/10/14 15:11, Stefano Stabellini wrote:
>>> On Fri, 24 Oct 2014, Zoltan Kiss wrote:
>>>> Hi,
>>>>
>>>> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it
>>>> fails
>>>> when it wants to map the buffers to the device:
>>>>
>>>> phys = dma_map_single(&ndev->dev, priv->rx_buf[i],
>>>> RX_BUF_SIZE, DMA_FROM_DEVICE);
>>>>
>>>> This returns 0, while running on bare metal it works. Does anyone has an
>>>> advice where should I look?
>>>
>>> dma_map_single should just be a wrapper around dma_ops->map_page that in
>>> dom0 is implemented by xen_swiotlb_map_page.
>>> From looking at the code the issue appears to be that dma_capable
>>> returns false for your device.
>>>
>>> In any case even if dma_map_single returned a valid address, keep in
>>> mind that at the moment if the device is not dma coherent Linux needs
>>> to be compiled with CONFIG_ARM_LPAE to be able to cache flush the
>>> buffers correctly. But the failure in that case is a memory corruption
>>> after the dma request is completed.
>>>
>>
>> Thanks for the advices. I've managed to figure out that dma_map_single fails
>> because dev->dma_mask was a NULL pointer. I've set it during probe with this:
>>
>> dma_coerce_mask_and_coherent(&ndev->dev, DMA_BIT_MASK(32));
>>
>> And the mappings seems to be set up properly (a bit below 512M), but the
>> returned buffers are filled up with 0xAA, which I guess is probably some
>> default value. Turning on and off CONFIG_ARM_LPAE did not helped.
>> I'll keep looking why is that, if you have an idea let me know.
>
> Are you trying to do regular DMA in dom0 or are you running other guests?
> If you are just doing DMA in dom0, then I don't have any suggestions:
> that should work.
I have only Dom0 running. And one important thing I forgot to mention:
due to other restrictions I'm using a 3.14 kernel right now!
Zoli
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-10-27 15:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-24 16:40 dma_map_single returns 0 on ARM Zoltan Kiss
2014-10-25 14:11 ` Stefano Stabellini
2014-10-26 20:39 ` Julien Grall
2014-10-27 4:42 ` manish jaggi
2014-10-27 15:45 ` Stefano Stabellini
2014-10-27 15:30 ` Zoltan Kiss
2014-10-27 15:44 ` Stefano Stabellini
2014-10-27 15:58 ` Zoltan Kiss
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.