From: Robert Jarzmik <robert.jarzmik@free.fr>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Vinod Koul <vinod.koul@intel.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: virt-dma: fix completion list manipulation
Date: Tue, 03 Mar 2015 11:27:03 +0100 [thread overview]
Message-ID: <877fuy1img.fsf@free.fr> (raw)
In-Reply-To: <54F5615E.3070106@metafoo.de> (Lars-Peter Clausen's message of "Tue, 03 Mar 2015 08:23:10 +0100")
Lars-Peter Clausen <lars@metafoo.de> writes:
>>> That will break all drivers which handle this currently correctly and remove the
>>> descriptor from any list before calling vchan_cookie_complete.
>> Ah, well well I don't agree.
>>
>> First, let's split the drivers which remove the descriptors and these which
>> don't :
>>
>> These which remove the descriptor:
>> dma-jz4740.c
>> fsl-edma.c
>>
>> These which don't remove the descriptor:
>> amba-pl08x.c
>> edma.c
>> img-mdc-dma.c
>> k3dma.c
>> moxart-dma.c
>> omap-dma.c
>> qcom_bam_dma.c
>> s3c24xx-dma.c
>> sa11x0-dma.c
>> sun6i-dma.c
>
> All of those remove the descriptor from the list when they start the transfer.
Ah, I didn't see that.
Isn't the descriptor lost if a terminate_all(), relying on
vchan_get_all_descriptors() and vchan_dma_desc_free_list() is used ?
>>
>> That settles the correctness I think, the correct behavior is to not remove the
>> descriptor and let it be done by vchan_cookie_complete().
>>
>> Now for the remaining 2 drivers, we'll have :
>> - list_del(&vd->node) => vd becomes a singleton
>> - list_move_tail(&vd->node, &...desc_completed)
>> => list_del(&vd->node) : nothing changes, it's a nop
>> => list_add_tail(&vd->node, &...desc_completed)
>>
>> And the behavior remains correct after the patch, only one "list_del()" is done
>> twice for nothing. Where do you see any breakage ?
>
> Calling list_del() on a list item that is not on a list causes undefined
> behavior, which can result in memory corruption, segfaults, etc...
Ah yes, you must be thinking about the "poisoning" after the __list_del() call,
I forgot about that.
Do you think amending all these drivers and changing their list_del() into
list_del_init() would at least prevent the "undefined behavior" ?
I still think that their use of virt-dma is incorrect, ie. that at one point in
time a virtual descriptor has to be on exactly one list of virt-dma (excepting
transient critical sections).
Cheers.
--
Robert
next prev parent reply other threads:[~2015-03-03 10:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 21:19 [PATCH] dmaengine: virt-dma: fix completion list manipulation Robert Jarzmik
2015-03-02 21:29 ` Lars-Peter Clausen
2015-03-02 22:03 ` Robert Jarzmik
2015-03-03 7:23 ` Lars-Peter Clausen
2015-03-03 10:27 ` Robert Jarzmik [this message]
2015-03-03 11:21 ` Lars-Peter Clausen
2015-03-03 11:55 ` Robert Jarzmik
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=877fuy1img.fsf@free.fr \
--to=robert.jarzmik@free.fr \
--cc=dmaengine@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=vinod.koul@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox