Skip to contentSkip to conversation

usb: remove unnecessary packed attributes

PATCH New Lucas Stach 2 participants 5 messages Aug 30, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: remove unnecessary packed attributes

We don't actually need to pack those structs, as they are not used to do actual hardware access.

This avoids some unaligned accesses and therefore makes the EHCI stack work on ARMv7 without compiler workarounds.

---
 drivers/usb/host/ehci-hcd.c | 2 +-
 include/usb.h               | 2 +-

2 Dateien ge?ndert, 2 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-)

drivers/usb/host/ehci-hcd.c +1 -1
index 18b4bc6..2f4fa5e 100644
@@ -45,7 +45,7 @@ static struct descriptor {
 	struct usb_linux_config_descriptor config;
 	struct usb_linux_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
-}  __attribute__ ((packed)) descriptor = {
+} descriptor = {
 	{
 		0x8,		/* bDescLength */
 		0x29,		/* bDescriptorType: hub descriptor */
include/usb.h +1 -1
index ba3d169..63730ee 100644
@@ -369,7 +369,7 @@ struct usb_hub_descriptor {
 	unsigned char  PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
 	/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
 	   bitmaps that hold max 255 entries. (bit0 is ignored) */
-} __attribute__ ((packed));
+};
 
 
 struct usb_hub_device {
Signature · 1 line
1.7.11.4
#1 lore raw

PATCH 1/1 usb: remove unnecessary packed attributes

Dear Lucas Stach,

Quoted 7 lines

We don't actually need to pack those structs, as they are not used to do actual hardware access.

This avoids some unaligned accesses and therefore makes the EHCI stack work on ARMv7 without compiler workarounds.

I need to review this properly, will get back to it soon.

Until then, CCing other good fellows.

Quoted 23 lines
---
 drivers/usb/host/ehci-hcd.c | 2 +-
 include/usb.h               | 2 +-

2 Dateien ge?ndert, 2 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-)

drivers/usb/host/ehci-hcd.c +1 -1
index 18b4bc6..2f4fa5e 100644
@@ -45,7 +45,7 @@ static struct descriptor {
 	struct usb_linux_config_descriptor config;
 	struct usb_linux_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
-}  __attribute__ ((packed)) descriptor = {
+} descriptor = {
 	{
 		0x8,		/* bDescLength */
 		0x29,		/* bDescriptorType: hub descriptor */
include/usb.h +0 -0
index ba3d169..63730ee 100644

include/usb.h struct usb_hub_descriptor { · line 375

Quoted 8 lines
include/usb.h +1 -1
@@ -369,7 +369,7 @@ struct usb_hub_descriptor {
 	unsigned char  PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
 	/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
 	   bitmaps that hold max 255 entries. (bit0 is ignored) */
-} __attribute__ ((packed));
+};
 
 
 struct usb_hub_device {

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 usb: remove unnecessary packed attributes

Dear Marek Vasut,

Quoted 11 lines

Dear Lucas Stach,

Quoted 7 lines

We don't actually need to pack those structs, as they are not used to do actual hardware access.

This avoids some unaligned accesses and therefore makes the EHCI stack work on ARMv7 without compiler workarounds.

I need to review this properly, will get back to it soon.

My 7th sense is telling me, these descriptors are sent across the bus. ehci_submit_root() puts them into buffer and then ehci_submit_async() blasts them. I believe they must be packed, otherwise the format expected by devices on the bus won't match and it'll fall apart.

Quoted 37 lines

Until then, CCing other good fellows.

Quoted 35 lines

---

 drivers/usb/host/ehci-hcd.c | 2 +-
 include/usb.h               | 2 +-

2 Dateien ge?ndert, 2 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-)

drivers/usb/host/ehci-hcd.c +1 -1
index 18b4bc6..2f4fa5e 100644
@@ -45,7 +45,7 @@ static struct descriptor {
 
 	struct usb_linux_config_descriptor config;
 	struct usb_linux_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
 
-}  __attribute__ ((packed)) descriptor = {
+} descriptor = {
 
drivers/usb/host/ehci-hcd.c +0 -0
 	{
 
 		0x8,		/* bDescLength */
 		0x29,		/* bDescriptorType: hub descriptor */
include/usb.h +0 -0
index ba3d169..63730ee 100644
@@ -369,7 +369,7 @@ struct usb_hub_descriptor {
 
 	unsigned char  PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
 	/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
 
 	   bitmaps that hold max 255 entries. (bit0 is ignored) */
 
Quoted 7 lines
Quoted 4 lines
include/usb.h +1 -1
-} __attribute__ ((packed));
+};

struct usb_hub_device {

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/1 usb: remove unnecessary packed attributes

Dear Marek,

it seems you are right. Though it works for me this may be pure luck. So please disregard this patch, I'll fix this up more properly.

Thanks,
Lucas

Am Donnerstag, den 30.08.2012, 22:59 +0200 schrieb Marek Vasut:

Quoted 67 lines

Dear Marek Vasut,

Quoted 11 lines

Dear Lucas Stach,

Quoted 7 lines

We don't actually need to pack those structs, as they are not used to do actual hardware access.

This avoids some unaligned accesses and therefore makes the EHCI stack work on ARMv7 without compiler workarounds.

I need to review this properly, will get back to it soon.

My 7th sense is telling me, these descriptors are sent across the bus. ehci_submit_root() puts them into buffer and then ehci_submit_async() blasts them. I believe they must be packed, otherwise the format expected by devices on the bus won't match and it'll fall apart.

Quoted 37 lines

Until then, CCing other good fellows.

Quoted 35 lines

---

 drivers/usb/host/ehci-hcd.c | 2 +-
 include/usb.h               | 2 +-

2 Dateien ge?ndert, 2 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-)

drivers/usb/host/ehci-hcd.c +1 -1
index 18b4bc6..2f4fa5e 100644
@@ -45,7 +45,7 @@ static struct descriptor {
 
 	struct usb_linux_config_descriptor config;
 	struct usb_linux_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
 
-}  __attribute__ ((packed)) descriptor = {
+} descriptor = {
 
drivers/usb/host/ehci-hcd.c +0 -0
 	{
 
 		0x8,		/* bDescLength */
 		0x29,		/* bDescriptorType: hub descriptor */
include/usb.h +0 -0
index ba3d169..63730ee 100644
@@ -369,7 +369,7 @@ struct usb_hub_descriptor {
 
 	unsigned char  PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
 	/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
 
 	   bitmaps that hold max 255 entries. (bit0 is ignored) */
 
Quoted 7 lines
Quoted 4 lines
include/usb.h +1 -1
-} __attribute__ ((packed));
+};

struct usb_hub_device {

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#4 lore raw

PATCH 1/1 usb: remove unnecessary packed attributes

Dear Lucas Stach,

Quoted 4 lines

Dear Marek,

it seems you are right. Though it works for me this may be pure luck. So please disregard this patch, I'll fix this up more properly.

Cool thing we caught it :-)

http://www.denx.de/wiki/U-Boot/Patches btw read up here ... don't top-post ... you know the drill.

Quoted 49 lines

Thanks,
Lucas

Am Donnerstag, den 30.08.2012, 22:59 +0200 schrieb Marek Vasut:

Quoted 45 lines

Dear Marek Vasut,

Quoted 11 lines

Dear Lucas Stach,

Quoted 7 lines

We don't actually need to pack those structs, as they are not used to do actual hardware access.

This avoids some unaligned accesses and therefore makes the EHCI stack work on ARMv7 without compiler workarounds.

I need to review this properly, will get back to it soon.

My 7th sense is telling me, these descriptors are sent across the bus. ehci_submit_root() puts them into buffer and then ehci_submit_async() blasts them. I believe they must be packed, otherwise the format expected by devices on the bus won't match and it'll fall apart.

Quoted 26 lines

Until then, CCing other good fellows.

Quoted 24 lines

---

 drivers/usb/host/ehci-hcd.c | 2 +-
 include/usb.h               | 2 +-

2 Dateien ge?ndert, 2 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-)

(quoted diff) +0 -0

b/drivers/usb/host/ehci-hcd.c index 18b4bc6..2f4fa5e 100644

drivers/usb/host/ehci-hcd.c +1 -1
@@ -45,7 +45,7 @@ static struct descriptor {
 
 	struct usb_linux_config_descriptor config;
 	struct usb_linux_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
 
-}  __attribute__ ((packed)) descriptor = {
+} descriptor = {
 
drivers/usb/host/ehci-hcd.c +0 -0
 	{
 
 		0x8,		/* bDescLength */
 		0x29,		/* bDescriptorType: hub descriptor */
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/usb.h struct usb_hub_descriptor { · line 371

Quoted 8 lines
include/usb.h +0 -0
index ba3d169..63730ee 100644
@@ -369,7 +369,7 @@ struct usb_hub_descriptor {
 
 	unsigned char  PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
 	/* DeviceRemovable and PortPwrCtrlMask want to be variable-

length

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
include/usb.h +1 -1
 	   bitmaps that hold max 255 entries. (bit0 is ignored) */
 
-} __attribute__ ((packed));
+};
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

struct usb_hub_device {

Best regards,
Marek Vasut

Best regards,
Marek Vasut

Best regards,
Marek Vasut