From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
Eddie Hung <eddie.hung@mediatek.com>,
Yuwen Ng <yuwen.ng@mediatek.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/3] usb: mtu3: add memory barrier before set GPD's HWO
Date: Mon, 13 Dec 2021 15:18:11 +0100 [thread overview]
Message-ID: <YbdWI5PD3e6uFz8U@kroah.com> (raw)
In-Reply-To: <20211209031424.17842-2-chunfeng.yun@mediatek.com>
On Thu, Dec 09, 2021 at 11:14:23AM +0800, Chunfeng Yun wrote:
> There is a seldom issue that the controller access invalid address
> and trigger devapc or emimpu violation. That is due to memory access
> is out of order and cause gpd data is not correct.
> Make sure GPD is fully written before giving it to HW by setting its
> HWO.
>
> Fixes: 48e0d3735aa5 ("usb: mtu3: supports new QMU format")
> Cc: stable@vger.kernel.org
> Reported-by: Eddie Hung <eddie.hung@mediatek.com>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> drivers/usb/mtu3/mtu3_qmu.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c
> index 3f414f91b589..34bb5ac67efe 100644
> --- a/drivers/usb/mtu3/mtu3_qmu.c
> +++ b/drivers/usb/mtu3/mtu3_qmu.c
> @@ -273,6 +273,8 @@ static int mtu3_prepare_tx_gpd(struct mtu3_ep *mep, struct mtu3_request *mreq)
> gpd->dw3_info |= cpu_to_le32(GPD_EXT_FLAG_ZLP);
> }
>
> + /* make sure GPD is fully written before giving it to HW */
> + mb();
So this means you are using mmio for this structure? If so, shouldn't
you be using normal io memory read/write calls as well and not just
"raw" pointers like this:
> gpd->dw0_info |= cpu_to_le32(GPD_FLAGS_IOC | GPD_FLAGS_HWO);
Are you sure this is ok?
Sprinkling around mb() calls is almost never the correct solution.
If you need to ensure that a write succeeds, shouldn't you do a read
from it afterward? Many busses require this, doesn't yours?
>
> mreq->gpd = gpd;
> @@ -306,6 +308,8 @@ static int mtu3_prepare_rx_gpd(struct mtu3_ep *mep, struct mtu3_request *mreq)
> gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma));
> ext_addr |= GPD_EXT_NGP(mtu, upper_32_bits(enq_dma));
> gpd->dw3_info = cpu_to_le32(ext_addr);
> + /* make sure GPD is fully written before giving it to HW */
> + mb();
Again, mb(); does not ensure that memory-mapped i/o actually hits the
HW. Or if it does on your platform, how?
mb() is a compiler barrier, not a memory write to a bus barrier. Please
read Documentation/memory-barriers.txt for more details.
thanks,
greg k-h
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-12-13 14:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 3:14 [PATCH 1/3] usb: mtu3: fix interval value for intr and isoc Chunfeng Yun
2021-12-09 3:14 ` [PATCH 2/3] usb: mtu3: add memory barrier before set GPD's HWO Chunfeng Yun
2021-12-13 14:18 ` Greg Kroah-Hartman [this message]
2021-12-16 8:32 ` Chunfeng Yun
2021-12-09 3:14 ` [PATCH 3/3] usb: mtu3: fix list_head check warning Chunfeng Yun
2021-12-09 9:10 ` Sergey Shtylyov
2021-12-10 1:19 ` Chunfeng Yun
2021-12-13 14:19 ` Greg Kroah-Hartman
2021-12-16 8:43 ` Chunfeng Yun
2021-12-13 14:20 ` [PATCH 1/3] usb: mtu3: fix interval value for intr and isoc Greg Kroah-Hartman
2021-12-16 8:45 ` Chunfeng Yun
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=YbdWI5PD3e6uFz8U@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=chunfeng.yun@mediatek.com \
--cc=eddie.hung@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=stable@vger.kernel.org \
--cc=yuwen.ng@mediatek.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;
as well as URLs for NNTP newsgroup(s).