Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753895AbYKRPlo (ORCPT ); Tue, 18 Nov 2008 10:41:44 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752537AbYKRPle (ORCPT ); Tue, 18 Nov 2008 10:41:34 -0500 Received: from nwd2mail11.analog.com ([137.71.25.57]:3307 "EHLO nwd2mail11.analog.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752283AbYKRPld (ORCPT ); Tue, 18 Nov 2008 10:41:33 -0500 X-IronPort-AV: E=Sophos;i="4.33,625,1220241600"; d="txt'?bz2'66?scan'66,208,49,66";a="62716303" X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C94994.0F6E6B37" Subject: RE: [PATCH] USB/ISP1760: Fix for unaligned exceptions Date: Tue, 18 Nov 2008 15:41:01 -0000 Message-ID: <8A42379416420646B9BFAC9682273B6D06966B66@limkexm3.ad.analog.com> In-Reply-To: <49229E64.2010907@linutronix.de> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [PATCH] USB/ISP1760: Fix for unaligned exceptions Thread-Index: AclJbH74FEUviKv6R+GY+E+cQMHOdgAIr7ng References: <1227000131-19145-1-git-send-email-cooloney@kernel.org> <49229E64.2010907@linutronix.de> From: "Hennerich, Michael" To: "Sebastian Andrzej Siewior" , "Bryan Wu" Cc: , , "Michael Hennerich" X-OriginalArrivalTime: 18 Nov 2008 15:41:03.0993 (UTC) FILETIME=[10A3D690:01C94994] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 12334 Lines: 295 This is a multi-part message in MIME format. ------_=_NextPart_001_01C94994.0F6E6B37 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sebastian, >The link [1] you sent me reports an unaligned access which occurred here. >So I thing the access to *src should be either a get_unaligned helper or a >byte read loop like I did it in the read path. It's not just that single spot. I've seen unaligned pointers with count > 3 coming from various drivers. Here just two examples: 1) The generic Bluetooth USB driver: CONFIG_BT_HCIUSB =20 Bluez-utils: hcitool scan: priv_write_copy: src =3D 00efaa09, dst =3D 203c1200, len =3D 13 Full trace attached. 2) RTL8150 based USB Ethernet adapter: CONFIG_USB_RTL8150 dhcpcd: priv_read_copy: src =3D 00ea4812, dst =3D 203d8000, len =3D 64 This trace was taken with the unaligned workaround for lengths < 4. I wonder if it's only us (NOMMU) seeing these odd aligned buffers? -Michael >-----Original Message----- >From: Sebastian Andrzej Siewior [mailto:bigeasy@linutronix.de] >Sent: Tuesday, November 18, 2008 11:52 AM >To: Bryan Wu >Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; Michael >Hennerich >Subject: Re: [PATCH] USB/ISP1760: Fix for unaligned exceptions > >Bryan Wu wrote: >> From: Michael Hennerich >> Signed-off-by: Michael Hennerich >> Signed-off-by: Bryan Wu >> --- >> drivers/usb/host/isp1760-hcd.c | 67 ++++++++++++++++++++++++++++------ >----- >> 1 files changed, 48 insertions(+), 19 deletions(-) >> >> diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760- >hcd.c >> index 8017f1c..00bece2 100644 >> --- a/drivers/usb/host/isp1760-hcd.c >> +++ b/drivers/usb/host/isp1760-hcd.c >> @@ -136,12 +136,21 @@ static void priv_read_copy(struct isp1760_hcd >*priv, u32 *src, >> return; >> } >> >> - while (len >=3D 4) { >> - *src =3D __raw_readl(dst); >> - len -=3D 4; >> - src++; >> - dst++; >> - } >> + if (unlikely((u32)src & 0x3)) { >> + while (len >=3D 4) { >> + put_unaligned(__raw_readl(dst), src); >> + len -=3D 4; >> + src++; >> + dst++; >> + } >> + } else { >> + while (len >=3D 4) { >> + *src =3D __raw_readl(dst); >> + len -=3D 4; >> + src++; >> + dst++; >> + } >> + } >> >> if (!len) >> return; >> @@ -159,25 +168,45 @@ static void priv_read_copy(struct isp1760_hcd >*priv, u32 *src, >> len--; >> buff8++; >> } >> + >> } >> >> static void priv_write_copy(const struct isp1760_hcd *priv, const u32 >*src, >> __u32 __iomem *dst, u32 len) >> { >> - while (len >=3D 4) { >> - __raw_writel(*src, dst); >> - len -=3D 4; >> - src++; >> - dst++; >> - } >> >> - if (!len) >> - return; >> - /* in case we have 3, 2 or 1 by left. The buffer is allocated and the >> - * extra bytes should not be read by the HW >> - */ >> - >> - __raw_writel(*src, dst); >The link [1] you sent me reports an unaligned access which occurred here. >So I thing the access to *src should be either a get_unaligned helper or a >byte read loop like I did it in the read path. >The r8a66597 is doing the same thing (as you suggest) for one SH machine. >However, I'm not convinced to fix it that way: The buffer should be >properly aligned by the driver. Unless there is HW which requires >unaligned data, I would prefer just to fix this unaligned access. >According to the thread in [1] a similar patch fixed it for the user until >he dropped into another bug. > >> + if (unlikely((u32)src & 0x3)) { >> + while (len >=3D 4) { >> + __raw_writel(get_unaligned(src), dst); >> + len -=3D 4; >> + src++; >> + dst++; >> + } >> + >> + if (!len) >> + return; >> + /* in case we have 3, 2 or 1 by left. The buffer is allocated >and the >> + * extra bytes should not be read by the HW >> + */ >> + >> + __raw_writel(get_unaligned(src), dst); >> + >> + } else{ >> + while (len >=3D 4) { >> + __raw_writel(*src, dst); >> + len -=3D 4; >> + src++; >> + dst++; >> + } >> + >> + if (!len) >> + return; >> + /* in case we have 3, 2 or 1 by left. The buffer is allocated >and the >> + * extra bytes should not be read by the HW >> + */ >> + >> + __raw_writel(*src, dst); >> + } >> } >> >> /* memory management of the 60kb on the chip from 0x1000 to 0xffff */ > >[1] >http://blackfin.uclinux.org/gf/project/uclinux- >dist/forum/?action=3DForumBrowse&_forum_action=3DMessageReply&message_id= =3D64 889 > >Sebastian ------_=_NextPart_001_01C94994.0F6E6B37 Content-Type: application/octet-stream; name="dumps.tar.bz2" Content-Transfer-Encoding: base64 Content-Description: dumps.tar.bz2 Content-Disposition: attachment; filename="dumps.tar.bz2" QlpoOTFBWSZTWU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TvdWCXDOzZnw7n4bS0bKGAVGjaDnsFsCzgpz0MmgQm8okSHJZqG9pjSV UyFmkl9oUrxMpn2VLSqaRgwpFgq11jAwkwa03+FoZQ8m8kkQwbGhV1r1JSmzB9YxCz+vSGpUUeRg yrINZraGy0ntXNHc2iaS8yoXlKkkiHcWWaJcpJcp/UMWzBkp2GcTTTZbGXjS1lutktWOELJShSgp oYdzuUds7p4pVTSNu9yT2OTLMTB97nLNWMLDReHVQs7VT76knOZRVYTxYRIkLuHY7XrbyObp9ztk yf0g8vAV+PTvYSYDn3dJZ2Bk3l4xZh3+wuopRUPpIiVFSDGohIpsmanc9JGWESJDwkPN9izhgspz znW6rWU/4r9yTg6SSRCganESRNnpbqqGNPY9RI6rmgOUm7sD3hCUIif9KkCbDGJ+KXZO0f/d47Xp EaQd7k5rxl53ZimUmyi7vV3WSGzsbF2ajFTl76rMzQ30b8oXWhwoxayWno1jBeThX0Q3awJDcJvF PCSSIXaMzDWM8ZhJ8zqbFM9LLA5SSRDnPZPNaKMV27J1XLrOxO36DZ2KTFkhCacm+OMbrRqxRblZ y0cdjSxssjrmF43OTM5TXa6ThomDf8G1xdkfufmPBPdraf49r4Tm7dodB6lmAPCR6yXT/Zm//vL2 97zkRId9WNFSZrEtJMCrROjdYIT+sAxOxgyjAVH5KLTVUDBdjDdJRUkUQ3GK8b1UiaFVXnQT/xdy RThQkEOrB44= ------_=_NextPart_001_01C94994.0F6E6B37-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/