From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] smsc95xx: align buffers to cache line size
Date: Sun, 8 Jul 2012 20:59:32 +0200 [thread overview]
Message-ID: <201207082059.32988.marek.vasut@gmail.com> (raw)
In-Reply-To: <1341755583-30090-1-git-send-email-ilya.yanok@cogentembedded.com>
Dear Ilya Yanok,
> Align buffers passed to the USB code to cache line size so
> they can be DMAed safely.
>
> Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
> ---
> Depens on Marek's patch [1] for DEFINE_CACHE_ALIGN_BUFFER.
Isn't it your patch anyway? You should get the credit for that series, you know
...
btw. this will fail with cache line < 32 .
>
> [1] http://patchwork.ozlabs.org/patch/169619/
>
> drivers/usb/eth/smsc95xx.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
> index c7aebea..c62a8c1 100644
> --- a/drivers/usb/eth/smsc95xx.c
> +++ b/drivers/usb/eth/smsc95xx.c
> @@ -153,13 +153,15 @@ static int curr_eth_dev; /* index for name of next
> device detected */ static int smsc95xx_write_reg(struct ueth_data *dev,
> u32 index, u32 data) {
> int len;
> + ALLOC_CACHE_ALIGN_BUFFER(u32, tmpbuf, 1);
>
> cpu_to_le32s(&data);
> + tmpbuf[0] = data;
>
> len = usb_control_msg(dev->pusb_dev, usb_sndctrlpipe(dev->pusb_dev, 0),
> USB_VENDOR_REQUEST_WRITE_REGISTER,
> USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> - 00, index, &data, sizeof(data), USB_CTRL_SET_TIMEOUT);
> + 00, index, tmpbuf, sizeof(data), USB_CTRL_SET_TIMEOUT);
> if (len != sizeof(data)) {
> debug("smsc95xx_write_reg failed: index=%d, data=%d, len=%d",
> index, data, len);
> @@ -171,11 +173,13 @@ static int smsc95xx_write_reg(struct ueth_data *dev,
> u32 index, u32 data) static int smsc95xx_read_reg(struct ueth_data *dev,
> u32 index, u32 *data) {
> int len;
> + ALLOC_CACHE_ALIGN_BUFFER(u32, tmpbuf, 1);
>
> len = usb_control_msg(dev->pusb_dev, usb_rcvctrlpipe(dev->pusb_dev, 0),
> USB_VENDOR_REQUEST_READ_REGISTER,
> USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> - 00, index, data, sizeof(data), USB_CTRL_GET_TIMEOUT);
> + 00, index, tmpbuf, sizeof(data), USB_CTRL_GET_TIMEOUT);
> + *data = tmpbuf[0];
> if (len != sizeof(data)) {
> debug("smsc95xx_read_reg failed: index=%d, len=%d",
> index, len);
> @@ -664,7 +668,8 @@ static int smsc95xx_send(struct eth_device *eth, void*
> packet, int length) int actual_len;
> u32 tx_cmd_a;
> u32 tx_cmd_b;
> - unsigned char msg[PKTSIZE + sizeof(tx_cmd_a) + sizeof(tx_cmd_b)];
> + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, msg,
> + PKTSIZE + sizeof(tx_cmd_a) + sizeof(tx_cmd_b));
>
> debug("** %s(), len %d, buf %#x\n", __func__, length, (int)msg);
> if (length > PKTSIZE)
> @@ -695,7 +700,7 @@ static int smsc95xx_send(struct eth_device *eth, void*
> packet, int length) static int smsc95xx_recv(struct eth_device *eth)
> {
> struct ueth_data *dev = (struct ueth_data *)eth->priv;
> - static unsigned char recv_buf[AX_RX_URB_SIZE];
> + DEFINE_CACHE_ALIGN_BUFFER(unsigned char, recv_buf, AX_RX_URB_SIZE);
> unsigned char *buf_ptr;
> int err;
> int actual_len;
Best regards,
Marek Vasut
next prev parent reply other threads:[~2012-07-08 18:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-08 13:53 [U-Boot] [PATCH] smsc95xx: align buffers to cache line size Ilya Yanok
2012-07-08 18:59 ` Marek Vasut [this message]
2012-07-08 19:35 ` Ilya Yanok
2012-07-08 21:31 ` Marek Vasut
2012-07-08 22:32 ` Ilya Yanok
2012-07-09 0:45 ` Marek Vasut
2012-07-09 18:33 ` Ilya Yanok
2012-07-10 2:17 ` Marek Vasut
2012-07-10 8:48 ` Ilya Yanok
2012-07-10 9:34 ` Marek Vasut
2012-07-10 11:25 ` Ilya Yanok
2012-07-10 15:53 ` Marek Vasut
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=201207082059.32988.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/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