All of lore.kernel.org
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Josh Coombs <josh.coombs@gmail.com>,
	linux ARM <linux-arm-kernel@lists.infradead.org>,
	wlanfae@realtek.com, florian.c.schilhabel@googlemail.com,
	gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [Patch v1 1/1] RTL8712 alignment bug in 3.6.5 on ARM
Date: Sun, 18 Nov 2012 18:10:00 -0600	[thread overview]
Message-ID: <50A978D8.1060309@lwfinger.net> (raw)
In-Reply-To: <20121118205515.GK11717@lunn.ch>

On 11/18/2012 02:55 PM, Andrew Lunn wrote:

> This is not sufficient. In fact it makes no difference at all. The
> problem is not with the structure, but with the allocation of memory
> used to contain the structure.
>
>          pstapriv->pallocated_stainfo_buf = _malloc(sizeof(struct sta_info) *
>                                                     NUM_STA + 4);
>          if (pstapriv->pallocated_stainfo_buf == NULL)
>                  return _FAIL;
>          pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
>                  ((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
>
> kmalloc() guarantees that its alignment is correct for any type of
> structure. Thus all this code above is redundant in Linux, but maybe
> needed in some other OS. Worse still, this code actually breaks the
> alignment. kmalloc() gave out something which was 64 bit aligned. But
> by adding 4 and then masking off the lower 2 bits, it destroys the 64
> bit alignment and makes it only 32bit aligned.
>
> Removing the _malloc() wrapper, fixing the GFP_ATOMIC, and leaving the
> allocater to worry about alignment will be one of the steps to getting
> out of staging.

As you surmised, the original driver was meant for several Windows systems as 
well as Linux.

This driver will not make it out of staging until it supports the mac80211 
stack. Work to accomplish this has started by modifying the rtl8192se code to 
work with the USB interface. I will make certain that the alignment issues are 
fixed there.

Thanks for the lesson,

Larry



WARNING: multiple messages have this Message-ID (diff)
From: Larry.Finger@lwfinger.net (Larry Finger)
To: linux-arm-kernel@lists.infradead.org
Subject: [Patch v1 1/1] RTL8712 alignment bug in 3.6.5 on ARM
Date: Sun, 18 Nov 2012 18:10:00 -0600	[thread overview]
Message-ID: <50A978D8.1060309@lwfinger.net> (raw)
In-Reply-To: <20121118205515.GK11717@lunn.ch>

On 11/18/2012 02:55 PM, Andrew Lunn wrote:

> This is not sufficient. In fact it makes no difference at all. The
> problem is not with the structure, but with the allocation of memory
> used to contain the structure.
>
>          pstapriv->pallocated_stainfo_buf = _malloc(sizeof(struct sta_info) *
>                                                     NUM_STA + 4);
>          if (pstapriv->pallocated_stainfo_buf == NULL)
>                  return _FAIL;
>          pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
>                  ((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
>
> kmalloc() guarantees that its alignment is correct for any type of
> structure. Thus all this code above is redundant in Linux, but maybe
> needed in some other OS. Worse still, this code actually breaks the
> alignment. kmalloc() gave out something which was 64 bit aligned. But
> by adding 4 and then masking off the lower 2 bits, it destroys the 64
> bit alignment and makes it only 32bit aligned.
>
> Removing the _malloc() wrapper, fixing the GFP_ATOMIC, and leaving the
> allocater to worry about alignment will be one of the steps to getting
> out of staging.

As you surmised, the original driver was meant for several Windows systems as 
well as Linux.

This driver will not make it out of staging until it supports the mac80211 
stack. Work to accomplish this has started by modifying the rtl8192se code to 
work with the USB interface. I will make certain that the alignment issues are 
fixed there.

Thanks for the lesson,

Larry

  reply	other threads:[~2012-11-19  0:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-18 17:06 [Patch v1 1/1] RTL8712 alignment bug in 3.6.5 on ARM Josh Coombs
2012-11-18 17:06 ` Josh Coombs
2012-11-18 17:47 ` Russell King - ARM Linux
2012-11-18 17:47   ` Russell King - ARM Linux
2012-11-18 18:03   ` Josh Coombs
2012-11-18 18:03     ` Josh Coombs
2012-11-18 18:20     ` Andrew Lunn
2012-11-18 18:20       ` Andrew Lunn
2012-11-18 20:10       ` Josh Coombs
2012-11-18 20:10         ` Josh Coombs
2012-11-19  3:37       ` Josh Coombs
2012-11-19  3:37         ` Josh Coombs
2012-11-18 18:11 ` Andrew Lunn
2012-11-18 18:11   ` Andrew Lunn
2012-11-18 20:18   ` Larry Finger
2012-11-18 20:18     ` Larry Finger
2012-11-18 20:55     ` Andrew Lunn
2012-11-18 20:55       ` Andrew Lunn
2012-11-19  0:10       ` Larry Finger [this message]
2012-11-19  0:10         ` Larry Finger

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=50A978D8.1060309@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=andrew@lunn.ch \
    --cc=devel@driverdev.osuosl.org \
    --cc=florian.c.schilhabel@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=josh.coombs@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wlanfae@realtek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.