From patchwork Sat Aug 27 14:46:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 1103802 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7REkm3F032219 for ; Sat, 27 Aug 2011 14:46:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751924Ab1H0Oqp (ORCPT ); Sat, 27 Aug 2011 10:46:45 -0400 Received: from mail-pz0-f42.google.com ([209.85.210.42]:65151 "EHLO mail-pz0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194Ab1H0Oqp (ORCPT ); Sat, 27 Aug 2011 10:46:45 -0400 Received: by pzk37 with SMTP id 37so5849458pzk.1 for ; Sat, 27 Aug 2011 07:46:44 -0700 (PDT) Received: by 10.142.208.21 with SMTP id f21mr1319045wfg.324.1314456404666; Sat, 27 Aug 2011 07:46:44 -0700 (PDT) Received: from localhost ([183.37.202.102]) by mx.google.com with ESMTPS id a7sm7435745pbr.2.2011.08.27.07.46.38 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 27 Aug 2011 07:46:43 -0700 (PDT) From: ming.lei@canonical.com To: greg@kroah.com, stern@rowland.harvard.edu Cc: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.canonical.com, linux-omap@vger.kernel.org, Ming Lei Subject: [PATCH] usb: ehci: fix update qtd->token in qh_append_tds Date: Sat, 27 Aug 2011 22:46:25 +0800 Message-Id: <1314456385-16378-1-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 27 Aug 2011 14:46:48 +0000 (UTC) From: Ming Lei This patch fixs one performance bug on ARM Cortex A9 dual core platform, which has been reported on quite a few ARM machines(OMAP4, Tegra 2, snowball...), see details from link of https://bugs.launchpad.net/bugs/709245. In fact, one mb() on ARM is enough to flush L2 cache, but 'dummy->hw_token = token;' after mb() is added just for obeying correct mb() usage. The patch has been tested ok on OMAP4 panda A1 board, the performance of 'dd' over usb mass storage can be increased from 4~5MB/sec to 14~16MB/sec after applying this patch. Signed-off-by: Ming Lei --- drivers/usb/host/ehci-q.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 0917e3a..65b5021 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -1082,6 +1082,20 @@ static struct ehci_qh *qh_append_tds ( wmb (); dummy->hw_token = token; + /* The mb() below is added to make sure that + * 'token' can be writen into qtd, so that ehci + * HC can see the up-to-date qtd descriptor. On + * some archs(at least on ARM Cortex A9 dual core), + * writing into coherenet memory doesn't mean the + * value written can reach physical memory + * immediately, and the value may be buffered + * inside L2 cache. 'dummy->hw_token = token;' + * after mb() is added for obeying correct mb() + * usage. + * */ + mb(); + token = dummy->hw_token; + urb->hcpriv = qh_get (qh); } }