From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE4D9C433EF for ; Mon, 13 Dec 2021 14:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v77MDrGsq2tinX5bFkahmbgAtBTV874nGIbRJaNrjAA=; b=mm1ik28Iso1gBC rjhMhaNq8/8pAm9m6ICJUt/tz/8NcF82U6IrX3IA4z9E9W/S8lSB1erPF7yV6VgjPfc49/TftgSOa N6BWIzE/TJrv+bncsEnYkEzzMKwL0ydlZFMN+GrSXzS180Qz4ykfhPNXj4u9FCEJXGMptqt3mwfon K9IDXu359/7kmdQ4FfU3oNdyOhffYahXud0ScjKLoq0O43feB5uEH2sEEltXRtSyphw/0M6izAr79 luPuox5XAebxsXe/xD77qRjDmy0V5aht7vLcqqSMEGCUEUgNCkZkFhz/1ciclSWMc0GxfS45H8IX7 7c1b2ftKcc0JrgcQTr0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwmO8-00A4rn-6i; Mon, 13 Dec 2021 14:33:12 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwm9f-009z2J-Dw; Mon, 13 Dec 2021 14:18:16 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D45A561021; Mon, 13 Dec 2021 14:18:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5CBEC34602; Mon, 13 Dec 2021 14:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1639405094; bh=NtWdzlEjft5tnQeFaBXUVrmubHd8T7HRkrRLfS+HxKc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ef4dtFt35n0BNeZHb5cwHF2nWR84NPJ4B4Ej+DcAmvR7/HzogwktH/W/meMnZnx1/ Xg3O6A+RredIYQtKTQ5Xmko6sTk52Ckx/QDevDNiQkd9m6eeVOhNiVRfdPIU5wthcz kslBCgGFDpF4EoLzXiuVfEO/wBb1eXc3RIOJDVQs= Date: Mon, 13 Dec 2021 15:18:11 +0100 From: Greg Kroah-Hartman To: Chunfeng Yun Cc: Matthias Brugger , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Eddie Hung , Yuwen Ng , stable@vger.kernel.org Subject: Re: [PATCH 2/3] usb: mtu3: add memory barrier before set GPD's HWO Message-ID: References: <20211209031424.17842-1-chunfeng.yun@mediatek.com> <20211209031424.17842-2-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211209031424.17842-2-chunfeng.yun@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_061815_567106_06383700 X-CRM114-Status: GOOD ( 20.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > Signed-off-by: Chunfeng Yun > --- > 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