[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <VI1PR04MB4960288477F1DA7AB56D4ECC92330@VI1PR04MB4960.eurprd04.prod.outlook.com>
Date: Wed, 30 Sep 2020 07:30:21 +0000
From: Sherry Sun <sherry.sun@....com>
To: Christoph Hellwig <hch@...radead.org>
CC: "sudeep.dutt@...el.com" <sudeep.dutt@...el.com>,
"ashutosh.dixit@...el.com" <ashutosh.dixit@...el.com>,
"arnd@...db.de" <arnd@...db.de>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"kishon@...com" <kishon@...com>,
"lorenzo.pieralisi@....com" <lorenzo.pieralisi@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
dl-linux-imx <linux-imx@....com>
Subject: RE: [PATCH V2 3/4] misc: vop: simply return the saved dma address
instead of virt_to_phys
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
Powered by blists - more mailing lists