lkml.org 
[lkml]   [2020]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH V2 3/4] misc: vop: simply return the saved dma address instead of virt_to_phys
Date
Hi Christoph,

> On Tue, Sep 29, 2020 at 01:10:12PM +0000, Sherry Sun wrote:
> > > > if (!offset) {
> > > > - *pa = virt_to_phys(vpdev->hw_ops->get_dp(vpdev));
> > > > + if (vpdev->hw_ops->get_dp_dma)
> > > > + *pa = vpdev->hw_ops->get_dp_dma(vpdev);
> > > > + else {
> > > > + dev_err(vop_dev(vdev), "can't get device page
> > > physical address\n");
> > > > + return -EINVAL;
> > > > + }
> > >
> > > I don't think we need the NULL check here. Wouldn't it also make
> > > sense to return the virtual and DMA address from ->get_dp instead of
> > > adding another method?
> >
> > Do you mean that we should only change the original ->get_dp callback
> > to return virtual and DMA address at the same time, instead of adding the -
> >get_dp_dma callback?
>
> That was my intention when writing it, yes. But it seems like most other
> callers don't care. Maybe move the invocation of dma_mmap_coherent into
> a new ->mmap helper, that way it seems like the calling code doesn't need to
> know about the dma_addr_t at all.
>
> That being said the layering in the code keeps puzzling me. As far as I can tell
> only a single instance of struct vop_driver even exists, so we might be able to
> kill all the indirections entirely.

There may be some misunderstandings here.
For ->get_dp_dma callback, it is used to get the device page dma address,
which is allocated by MIC layer instead of vop layer.
For Intel mic, it still use kzalloc and dma_map_single apis, although we
recommended and we did use dma_alloc_coherent to get consistent device
page memory on our i.MX platform, but we didn't change the original implementation
method of Intel mic till now, as our main goal is to change the vop code to make it
more generic.

Which is means that the device page may use different allocate methods for
different platform, and now it is transparent to the vop layer.
So I think here use ->get_dp_dma callback to get device page dma address
is the most simple and convenient way.

We change to use dma_alloc_coherent in patch 1 to allocate vrings memory, as it is
the main job that the vop layer is responsible for.
So I still suggest to use ->get_dp or ->get_dp_dma callback for device page here, what do you think?

Regards
Sherry

\
 
 \ /
  Last update: 2020-09-30 09:30    [W:0.051 / U:4.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site