From: Felipe Balbi <balbi@kernel.org>
To: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
v.anuragkumar@gmail.com,
Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Subject: Re: [PATCH] usb: dwc3: gadget: Correct the logic for finding last SG entry
Date: Wed, 05 Jun 2019 11:03:42 +0300 [thread overview]
Message-ID: <87y32gcvc1.fsf@linux.intel.com> (raw)
In-Reply-To: <1559141985-17104-1-git-send-email-anurag.kumar.vulisha@xilinx.com>
[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]
Hi,
Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com> writes:
> As a process of preparing TRBs usb_gadget_map_request_by_dev() is
> called from dwc3_prepare_trbs() for mapping the request. This will
> call dma_map_sg() if req->num_sgs are greater than 0. dma_map_sg()
> will map the sg entries in sglist and return the number of mapped SGs.
> As a part of mapping, some sg entries having contigous memory may be
> merged together into a single sg (when IOMMU used). So, the number of
> mapped sg entries may not be equal to the number of orginal sg entries
> in the request (req->num_sgs).
>
> As a part of preparing the TRBs, dwc3_prepare_one_trb_sg() iterates over
> the sg entries present in the sglist and calls sg_is_last() to identify
> whether the sg entry is last and set IOC bit for the last sg entry. The
> sg_is_last() determines last sg if SG_END is set in sg->page_link. When
> IOMMU used, dma_map_sg() merges 2 or more sgs into a single sg and it
> doesn't retain the page_link properties. Because of this reason the
> sg_is_last() may not find SG_END and thus resulting in IOC bit never
> getting set.
>
> For example:
>
> Consider a request having 8 sg entries with each entry having a length of
> 4096 bytes. Assume that sg1 & sg2, sg3 & sg4, sg5 & sg6, sg7 & sg8 are
> having contigous memory regions.
>
> Before calling dma_map_sg():
> sg1-->sg2-->sg3-->sg4-->sg6-->sg7-->sg8
> dma_length: 4K 4K 4K 4K 4K 4K 4K
> SG_END: False False False False False False True
> num_sgs = 8
> num_mapped_sgs = 0
>
> The dma_map_sg() merges sg1 & sg2 memory regions into sg1->dma_address.
> Similarly sg3 & sg4 into sg2->dma_address, sg5 & sg6 into the
> sg3->dma_address and sg6 & sg8 into sg4->dma_address. Here the memory
> regions are merged but the page_link properties like SG_END are not
> retained into the merged sgs.
isn't this a bug in the scatterlist mapping code? Why doesn't it keep
SG_END?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2019-06-05 8:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 14:59 [PATCH] usb: dwc3: gadget: Correct the logic for finding last SG entry Anurag Kumar Vulisha
2019-06-05 8:03 ` Felipe Balbi [this message]
2019-06-06 15:32 ` Anurag Kumar Vulisha
2019-06-07 6:49 ` Felipe Balbi
2019-10-23 16:58 ` Jack Pham
2019-10-25 12:01 ` Anurag Kumar Vulisha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y32gcvc1.fsf@linux.intel.com \
--to=balbi@kernel.org \
--cc=anurag.kumar.vulisha@xilinx.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=v.anuragkumar@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.