Re: gadget framework data alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Gadiyar, Anand a écrit :
> Alan Stern wrote:
>> On Tue, 15 Dec 2009, Matthieu CASTET wrote:
>>
>>
> 
> For g_ether, the buffers are allocated using kmalloc(), but the
> networking code seems to move the data in the buffer out by 2
> bytes, and passes this unaligned address down to the gadget driver.
Yes it does that to avoid unaligned access in network stack.

> 
> The MUSB controller in the beagleboard could handle these unaligned
> DMA address, but looks like newer MUSB controllers don't seem to
> like this.
There is other controllers that can't handle this. For example s3c-hsotg
[1] and a controller that we are using (not present in upstream).

What we should decide is where the modification should be done : in
controller driver or function ?

Fixing it in function driver seems better because the function driver
has knowledge of the data in the buffer. Also even if the data are on a
32bit aligned addresses, this is not enough, we want to be aligned on a
cache boundary.

Matthieu

PS : Also note that wifi stack does similar stuff on rx side [2].

[1]
/**
 * using_dma - return the DMA status of the driver.
 * @hsotg: The driver state.
 *
 * Return true if we're using DMA.
 *
 * Currently, we have the DMA support code worked into everywhere
 * that needs it, but the AMBA DMA implementation in the hardware can
 * only DMA from 32bit aligned addresses. This means that gadgets such
 * as the CDC Ethernet cannot work as they often pass packets which are
 * not 32bit aligned.
 *
 * Unfortunately the choice to use DMA or not is global to the controller
 * and seems to be only settable when the controller is being put through
 * a core reset. This means we either need to fix the gadgets to take
 * account of DMA alignment, or add bounce buffers (yuerk).
 *
 * Until this issue is sorted out, we always return 'false'.


[2]
#if defined(CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT) ||
!defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
        /*
         * 'align' will only take the values 0 or 2 here
         * since all frames are required to be aligned
         * to 2-byte boundaries when being passed to
         * mac80211. That also explains the __skb_push()
         * below.
         */
        align = ((unsigned long)(skb->data + sizeof(struct ethhdr))) & 3;
        if (align) {
            if (WARN_ON(skb_headroom(skb) < 3)) {
                dev_kfree_skb(skb);
                skb = NULL;
            } else {
                u8 *data = skb->data;
                size_t len = skb_headlen(skb);
                skb->data -= align;
                memmove(skb->data, data, len);
                skb_set_tail_pointer(skb, len);
            }
        }
#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux