All of lore.kernel.org
 help / color / mirror / Atom feed
* Is adding offset to dma address is valid operation?
@ 2018-03-26  9:55 Harsh Jain
       [not found] ` <8be08248-174e-19c2-357d-7d31c60a90f7-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Harsh Jain @ 2018-03-26  9:55 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Hi,

Can we add  offset to dma address received from IOMMU in scatter/Gather list before sending it to H/W.

Address to HW = sg_dma_address(sg) + offset, where 0 < offset < sg_dma_len(sg).

I need this operation to make sure our H/W does not receives entry of size greater than 2K.

Regards

Harsh Jain

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is adding offset to dma address is valid operation?
       [not found] ` <8be08248-174e-19c2-357d-7d31c60a90f7-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
@ 2018-03-26 11:45   ` Robin Murphy
       [not found]     ` <5ea7def7-2daa-b4b1-17e7-47524746a61a-5wv7dgnIgG8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2018-03-26 11:45 UTC (permalink / raw)
  To: Harsh Jain, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Hi Harsh,

On 26/03/18 10:55, Harsh Jain wrote:
> Hi,
> 
> Can we add  offset to dma address received from IOMMU in scatter/Gather list before sending it to H/W.
> 
> Address to HW = sg_dma_address(sg) + offset, where 0 < offset < sg_dma_len(sg).

sg_dma_address() should already account for sg->offset (i.e. the start 
of the buffer within the page. If there's a DMA API implementation 
failing to respect that then that's a bug.

> I need this operation to make sure our H/W does not receives entry of size greater than 2K.

If however it's just that you want to fragment a single SG entry into 
multiple commaneds/descriptors/etc. internally to your driver, then I 
can't see that being an issue as long as you don't visibly modify the 
scatterlist itself. If there's a genuine length and/or alignment 
limitation in the hardware, though, it would be better to set up 
dev->dma_parms appropriately to describe them, such that the subsystem 
responsible for generating the scatterlist respects the appropriate 
constraints in the first place (and if it doesn't, then that's another 
bug to fix).

Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is adding offset to dma address is valid operation?
       [not found]     ` <5ea7def7-2daa-b4b1-17e7-47524746a61a-5wv7dgnIgG8@public.gmane.org>
@ 2018-03-26 11:59       ` Harsh Jain
  2018-03-26 12:31       ` Harsh Jain
  1 sibling, 0 replies; 5+ messages in thread
From: Harsh Jain @ 2018-03-26 11:59 UTC (permalink / raw)
  To: Robin Murphy, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA


On 26-03-2018 17:15, Robin Murphy wrote:
> Hi Harsh,
>
> On 26/03/18 10:55, Harsh Jain wrote:
>> Hi,
>>
>> Can we add  offset to dma address received from IOMMU in scatter/Gather list before sending it to H/W.
>>
>> Address to HW = sg_dma_address(sg) + offset, where 0 < offset < sg_dma_len(sg).
>
> sg_dma_address() should already account for sg->offset (i.e. the start of the buffer within the page. If there's a DMA API implementation failing to respect that then that's a bug.
Thanks.
Here "offset" means size of last dma entry I had mapped to H/W structure. eg if dma length is 9K offset will be 0, 2K, 4K,6K,8K.
>
>> I need this operation to make sure our H/W does not receives entry of size greater than 2K.
>
> If however it's just that you want to fragment a single SG entry into multiple commaneds/descriptors/etc. internally to your driver, then I can't see that being an issue as long as you don't visibly modify the scatterlist itself. If there's a genuine length and/or alignment limitation in the hardware, though, it would be better to set up dev->dma_parms appropriately to describe them, such that the subsystem responsible for generating the scatterlist respects the appropriate constraints in the first place (and if it doesn't, then that's another bug to fix).
>
Yes, I wants to fragment single entry into multiple such that it is less than 2K. eg. if sg->length  == 5k , I will split into 3 entries
addr1 = sg_dma_address(sg),     len =2K
addr2 = sg_dma_address(sg) + 2K,     len = 2K
addr3 = sg_dma_address(sg) +4K,     len = 1K


> Robin.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is adding offset to dma address is valid operation?
       [not found]     ` <5ea7def7-2daa-b4b1-17e7-47524746a61a-5wv7dgnIgG8@public.gmane.org>
  2018-03-26 11:59       ` Harsh Jain
@ 2018-03-26 12:31       ` Harsh Jain
       [not found]         ` <6986f4c8-a3c0-2483-6eae-cfb56eaee10a-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Harsh Jain @ 2018-03-26 12:31 UTC (permalink / raw)
  To: Robin Murphy, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA



On 26-03-2018 17:15, Robin Murphy wrote:
> Hi Harsh,
>
> On 26/03/18 10:55, Harsh Jain wrote:
>> Hi,
>>
>> Can we add  offset to dma address received from IOMMU in scatter/Gather list before sending it to H/W.
>>
>> Address to HW = sg_dma_address(sg) + offset, where 0 < offset < sg_dma_len(sg).
>
> sg_dma_address() should already account for sg->offset (i.e. the start of the buffer within the page. If there's a DMA API implementation failing to respect that then that's a bug.
>
>> I need this operation to make sure our H/W does not receives entry of size greater than 2K.
>
> If however it's just that you want to fragment a single SG entry into multiple commaneds/descriptors/etc. internally to your driver, then I can't see that being an issue as long as you don't visibly modify the scatterlist itself. If there's a genuine length and/or alignment limitation in the hardware, though, it would be better to set up dev->dma_parms appropriately to describe them, such that the subsystem responsible for generating the scatterlist respects the appropriate constraints in the first place (and if it doesn't, then that's another bug to fix).
Can dma_parms  handle 2K size limit ? Because dma_map_sg() returns <= passed nents. But in my case nents will increase.

>
> Robin.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is adding offset to dma address is valid operation?
       [not found]         ` <6986f4c8-a3c0-2483-6eae-cfb56eaee10a-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
@ 2018-03-26 13:31           ` Robin Murphy
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Murphy @ 2018-03-26 13:31 UTC (permalink / raw)
  To: Harsh Jain, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On 26/03/18 13:31, Harsh Jain wrote:
> 
> 
> On 26-03-2018 17:15, Robin Murphy wrote:
>> Hi Harsh,
>> 
>> On 26/03/18 10:55, Harsh Jain wrote:
>>> Hi,
>>> 
>>> Can we add  offset to dma address received from IOMMU in
>>> scatter/Gather list before sending it to H/W.
>>> 
>>> Address to HW = sg_dma_address(sg) + offset, where 0 < offset <
>>> sg_dma_len(sg).
>> 
>> sg_dma_address() should already account for sg->offset (i.e. the
>> start of the buffer within the page. If there's a DMA API
>> implementation failing to respect that then that's a bug.
>> 
>>> I need this operation to make sure our H/W does not receives
>>> entry of size greater than 2K.
>> 
>> If however it's just that you want to fragment a single SG entry
>> into multiple commaneds/descriptors/etc. internally to your driver,
>> then I can't see that being an issue as long as you don't visibly
>> modify the scatterlist itself. If there's a genuine length and/or
>> alignment limitation in the hardware, though, it would be better to
>> set up dev->dma_parms appropriately to describe them, such that the
>> subsystem responsible for generating the scatterlist respects the
>> appropriate constraints in the first place (and if it doesn't, then
>> that's another bug to fix).
> Can dma_parms  handle 2K size limit ? Because dma_map_sg() returns <=
> passed nents. But in my case nents will increase.

The point is that dma_map_sg() should still never increase nents, 
because the guy *creating* the scatterlist is also expected to respect 
dma_parms where it exists, such that nents would be appropriate to start 
with. That said, it does look like there are some places (e.g. the block 
layer) which may not cope properly with limits less than PAGE_SIZE, so I 
guess the reliability of dma_parms might depend on how much you want to 
go spelunking in core code :/

Robin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-26 13:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26  9:55 Is adding offset to dma address is valid operation? Harsh Jain
     [not found] ` <8be08248-174e-19c2-357d-7d31c60a90f7-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2018-03-26 11:45   ` Robin Murphy
     [not found]     ` <5ea7def7-2daa-b4b1-17e7-47524746a61a-5wv7dgnIgG8@public.gmane.org>
2018-03-26 11:59       ` Harsh Jain
2018-03-26 12:31       ` Harsh Jain
     [not found]         ` <6986f4c8-a3c0-2483-6eae-cfb56eaee10a-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2018-03-26 13:31           ` Robin Murphy

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.