From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Bryan Wu <cooloney@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Hennerich <michael.hennerich@analog.com>
Subject: Re: [PATCH] USB/ISP1760: Fix for unaligned exceptions
Date: Tue, 18 Nov 2008 11:52:20 +0100 [thread overview]
Message-ID: <49229E64.2010907@linutronix.de> (raw)
In-Reply-To: <1227000131-19145-1-git-send-email-cooloney@kernel.org>
Bryan Wu wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Bryan Wu <cooloney@kernel.org>
> ---
> 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 >= 4) {
> - *src = __raw_readl(dst);
> - len -= 4;
> - src++;
> - dst++;
> - }
> + if (unlikely((u32)src & 0x3)) {
> + while (len >= 4) {
> + put_unaligned(__raw_readl(dst), src);
> + len -= 4;
> + src++;
> + dst++;
> + }
> + } else {
> + while (len >= 4) {
> + *src = __raw_readl(dst);
> + len -= 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 >= 4) {
> - __raw_writel(*src, dst);
> - len -= 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 >= 4) {
> + __raw_writel(get_unaligned(src), dst);
> + len -= 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 >= 4) {
> + __raw_writel(*src, dst);
> + len -= 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=ForumBrowse&_forum_action=MessageReply&message_id=64889
Sebastian
next prev parent reply other threads:[~2008-11-18 10:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-18 9:22 [PATCH] USB/ISP1760: Fix for unaligned exceptions Bryan Wu
2008-11-18 10:52 ` Sebastian Andrzej Siewior [this message]
2008-11-18 15:41 ` Hennerich, Michael
2008-11-19 9:18 ` Sebastian Andrzej Siewior
2008-11-19 10:30 ` Hennerich, Michael
2008-11-19 10:55 ` Sebastian Andrzej Siewior
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=49229E64.2010907@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=cooloney@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michael.hennerich@analog.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