lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14063C7AD467DE4B82DEDB5C278E8663FFFC0C0E@fmsmsx107.amr.corp.intel.com>
Date:   Mon, 30 Mar 2020 13:46:10 +0000
From:   "Ruhl, Michael J" <michael.j.ruhl@...el.com>
To:     Marek Szyprowski <m.szyprowski@...sung.com>,
        "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
        "linux-samsung-soc@...r.kernel.org" 
        <linux-samsung-soc@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
        David Airlie <airlied@...ux.ie>,
        Shane Francis <bigbeeshane@...il.com>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Alex Deucher <alexander.deucher@....com>
Subject: RE: [PATCH v2] drm/prime: fix extracting of the DMA addresses from
 a scatterlist

>-----Original Message-----
>From: dri-devel <dri-devel-bounces@...ts.freedesktop.org> On Behalf Of
>Marek Szyprowski
>Sent: Sunday, March 29, 2020 5:56 AM
>To: Ruhl, Michael J <michael.j.ruhl@...el.com>; dri-
>devel@...ts.freedesktop.org; linux-samsung-soc@...r.kernel.org; linux-
>kernel@...r.kernel.org
>Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>; David Airlie
><airlied@...ux.ie>; Shane Francis <bigbeeshane@...il.com>;
>stable@...r.kernel.org; Thomas Zimmermann <tzimmermann@...e.de>;
>Alex Deucher <alexander.deucher@....com>
>Subject: Re: [PATCH v2] drm/prime: fix extracting of the DMA addresses from
>a scatterlist
>
>Hi Michael,
>

<snip>

>> Is there an example of what the scatterlist would look like in this case?
>
>DMA framework or IOMMU is allowed to join consecutive chunks while
>mapping if such operation is supported by the hw. Here is the example:
>
>Lets assume that we have a scatterlist with 4 4KiB pages of the physical
>addresses: 0x12000000, 0x13011000, 0x13012000, 0x11011000. The total
>size of the buffer is 16KiB. After mapping this scatterlist to a device
>behind an IOMMU it may end up as a contiguous buffer in the DMA (IOVA)
>address space. at 0xf0010000. The scatterlist will look like this:
>
>sg[0].page = 0x12000000
>sg[0].len = 4096
>sg[0].dma_addr = 0xf0010000
>sg[0].dma_len = 16384
>sg[1].page = 0x13011000
>sg[1].len = 4096
>sg[1].dma_addr = 0
>sg[1].dma_len = 0
>sg[2].page = 0x13012000
>sg[2].len = 4096
>sg[2].dma_addr = 0
>sg[2].dma_len = 0
>sg[3].page = 0x11011000
>sg[3].len = 4096
>sg[3].dma_addr = 0
>sg[3].dma_len = 0
>
>(I've intentionally wrote page as physical address to make it easier to
>understand, in real SGs it is stored a struct page pointer).
>
>> Does each SG entry always have the page and dma info? or could you have
>> entries that have page information only, and entries that have dma info
>only?
>When SG is not mapped yet it contains only the ->pages and ->len
>entries. I'm not aware of the SGs with the DMA information only, but in
>theory it might be possible to have such.
>> If the same entry has different size info (page_len = PAGE_SIZE,
>> dma_len = 4 * PAGE_SIZE?), are we guaranteed that the arrays (page and
>addrs) have
>> been sized correctly?
>
>There are always no more DMA related entries than the phys pages. If
>there is 1:1 mapping between physical memory and DMA (IOVA) space, then
>each SG entry will have len == dma_len, and dma_addr will be describing
>the same as page entry. DMA mapping framework is allowed only to join
>entries while mapping to DMA (IOVA).
>
>> Just trying to get my head wrapped around this.
>
>Sure, I hope my explanation helps a bit.

That is a great example!  Thank you very much for the explanation.

I was somehow seeing it as the dma side getting split and extended (rather
than consolidated) into more possible entries.  This clarifies the issue for me.

Thanks!

Mike

>Best regards
>--
>Marek Szyprowski, PhD
>Samsung R&D Institute Poland
>
>_______________________________________________
>dri-devel mailing list
>dri-devel@...ts.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ