Re: [PATCH for-next 2/4] RDMA/hns: Add IOMMU enable support in hip08

Leon Romanovsky
2017-10-12T14:54:20Z

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

On Thu, Oct 12, 2017 at 08:31:31PM +0800, Wei Hu (Xavier) wrote:
>
>
> On 2017/10/1 0:10, Leon Romanovsky wrote:
> > On Sat, Sep 30, 2017 at 05:28:59PM +0800, Wei Hu (Xavier) wrote:
> > > If the IOMMU is enabled, the length of sg obtained from
> > > __iommu_map_sg_attrs is not 4kB. When the IOVA is set with the sg
> > > dma address, the IOVA will not be page continuous. and the VA
> > > returned from dma_alloc_coherent is a vmalloc address. However,
> > > the VA obtained by the page_address is a discontinuous VA. Under
> > > these circumstances, the IOVA should be calculated based on the
> > > sg length, and record the VA returned from dma_alloc_coherent
> > > in the struct of hem.
> > >
> > > Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> > > Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
> > > Signed-off-by: Lijun Ou <oulijun@huawei.com>
> > > ---
> > Doug,
> >
> > I didn't invest time in reviewing it, but having "is_vmalloc_addr" in
> > driver code to deal with dma_alloc_coherent is most probably wrong.
> >
> > Thanks
> Hi, Leon & Doug
> We refered the function named __ttm_dma_alloc_page in the kernel code as
> below:
> And there are similar methods in bch_bio_map and mem_to_page functions
> in current 4.14-rcx.

Let's put aside TTM, I don't know the rationale behind their implementation,
but both mem_to_page and bch_bio_map are don't operate on DMA addresses
and don't belong to HW driver code.

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]