USB: ehci-pci: Add support for Intel Quark X1000 USB
Subsystems (2)
PATCH v3 1/1 USB: ehci-pci: Add support for Intel Quark X1000 USB
From: "Alvin (Weike) Chen" <[email protected]>
Hi,
Intel Quark X1000 consists of one USB host controller which can be PCI enumerated. And the exsiting EHCI-PCI framework supports it with the default packet buffer in/out threshold. We reconfigure the in/out threshold as maximal as possible to maximize the performance.
Bryan O'Donoghue (1):
USB: ehci-pci: USB host controller support for Intel Quark X1000
drivers/usb/host/ehci-pci.c | 40 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v3 1/1 USB: ehci-pci: USB host controller support for Intel Quark X1000
From: Bryan O'Donoghue <[email protected]>
The EHCI packet buffer in/out threshold is programmable for Intel Quark X1000 USB host controller, and the default value is 0x20 dwords. The in/out threshold can be programmed to 0x80 dwords (512 Bytes) to maximize the perfomrance, but only when isochronous/interrupt transactions are not initiated by the USB host controller. This patch is to reconfigure the packet buffer in/out threshold as maximal as possible to maximize the performance, and 0x7F dwords (508 Bytes) should be used because the USB host controller initiates isochronous/interrupt transactions.
---
changelog v3:
*Update the description to explain why set in/out threshold
as maximal as possible.
*Improve the threshold value micros more readable.
*Remove 'usb_set_qrk_bulk_thresh'.
*Set threshold value by 'ehci_writel' instead of 'usb_set_qrk_bulk_thresh'. *Change the function name from 'usb_is_intel_quark_x1000'
to 'is_intel_quark_x1000'.
drivers/usb/host/ehci-pci.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/usb/host/ehci-pci.c +40 -0
@@ -35,11 +35,35 @@ static const char hcd_name[] = "ehci-pci";#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70/*-------------------------------------------------------------------------*/ +#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 +static inline bool is_intel_quark_x1000 (struct pci_dev *pdev) +{ +return pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC ; +} + +/* +* The offset of in/out threshold register is 0x84. +* And it is the register of 'hostpc' +* in memory-mapped EHCI controller. +*/ +#define intel_quark_x1000_insnreg01 hostpc + +/* The maximal ehci packet buffer size is 512 bytes */ +#define INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE 512 + +/* The threshold value set the register is in DWORD */ +#define INTEL_QUARK_X1000_EHCI_THRESHOLD (size) ((size)/4u) +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT 16 +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT 0 +/* called after powerup, by probe or system-pm "wakeup" */ static int ehci_pci_reinit (struct ehci_hcd *ehci,struct pci_dev *pdev) {int retval; +u32 val; +u32 thr;/* we expect static quirk code to handle the "extended capabilities" * (currently just BIOS handoff) allowed starting with EHCI 0.96
@@ -50,6 +74,22 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)if (!retval)ehci_dbg (ehci,"MWI active\n" ); +/* Reset the threshold limit */ +if (is_intel_quark_x1000 (pdev)) { +/* +* In order to support the isochronous/interrupt +* transactions, 508 bytes should be used as +* max threshold values to maximize the +* performance +*/ + thr =INTEL_QUARK_X1000_EHCI_THRESHOLD ( +INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE -4 + ); + val = thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT | + thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT ; +ehci_writel (ehci, val, ehci->regs->intel_quark_x1000_insnreg01); + } +return 0 ; }
Signature · 1 line
1.7.9.5
Re: [PATCH v3] USB: ehci-pci: USB host controller support for Intel Quark X1000
Hello.
Quoted 31 lines · Alvin
From: Bryan O'Donoghue <[email protected]>
The EHCI packet buffer in/out threshold is programmable for Intel Quark X1000 USB host controller, and the default value is
0x20dwords. The in/out threshold can be programmed to0x80dwords (512 Bytes) to maximize the perfomrance, but only when isochronous/interrupt transactions are not initiated by the USB host controller. This patch is to reconfigure the packet buffer in/out threshold as maximal as possible to maximize the performance, and0x7Fdwords (508 Bytes) should be used because the USB host controller initiates isochronous/interrupt transactions.Signed-off-by Bryan O'Donoghue <[email protected]>Signed-off-by Alvin (Weike) Chen <[email protected]>---
changelog v3:
*Update the description to explain why set in/out threshold
as maximal as possible.
*Improve the threshold value micros more readable.
*Remove 'usb_set_qrk_bulk_thresh'.
*Set threshold value by 'ehci_writel' instead of 'usb_set_qrk_bulk_thresh'. *Change the function name from 'usb_is_intel_quark_x1000'
to 'is_intel_quark_x1000'.drivers/usb/host/ehci-pci.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)drivers/usb/host/ehci-pci.c +0
-0
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 43
Quoted 9 lines
drivers/usb/host/ehci-pci.c +6
-0@@ -35,11 +35,35 @@ static const char hcd_name[] = "ehci-pci";#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70/*-------------------------------------------------------------------------*/ +#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 +static inline bool is_intel_quark_x1000 (struct pci_dev *pdev) +{ +return pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC ; +}
Why not just put this check inline into ehci_pci_reinit()?
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 49
Quoted 6 lines
drivers/usb/host/ehci-pci.c +6
-0+ +/* +* The offset of in/out threshold register is 0x84. +* And it is the register of 'hostpc' +* in memory-mapped EHCI controller. +*/
The preferred multi-line kernel style is this:
/*
* bla
* bla
*/
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 52
Quoted 3 lines
drivers/usb/host/ehci-pci.c +3
-0+#define intel_quark_x1000_insnreg01 hostpc + +/* The maximal ehci packet buffer size is 512 bytes */
s/ehci/EHCI/
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 60
Quoted 8 lines
drivers/usb/host/ehci-pci.c +7
-0+#define INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE 512 + +/* The threshold value set the register is in DWORD */ +#define INTEL_QUARK_X1000_EHCI_THRESHOLD (size) ((size)/4u) +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT 16 +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT 0 +
Too many empty lines...
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 66
Quoted 6 lines
drivers/usb/host/ehci-pci.c +2
-0/* called after powerup, by probe or system-pm "wakeup" */ static int ehci_pci_reinit (struct ehci_hcd *ehci,struct pci_dev *pdev) {int retval; +u32 val; +u32 thr;
Why not declare these where they are used?
Quoted 5 lines
drivers/usb/host/ehci-pci.c +0
-0/* we expect static quirk code to handle the "extended capabilities" * (currently just BIOS handoff) allowed starting with EHCI 0.96 @@ -50,6 +74,22 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)if (!retval)
drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 84
Quoted 10 lines
drivers/usb/host/ehci-pci.c +8
-0ehci_dbg (ehci,"MWI active\n" ); +/* Reset the threshold limit */ +if (is_intel_quark_x1000 (pdev)) { +/* +* In order to support the isochronous/interrupt +* transactions, 508 bytes should be used as +* max threshold values to maximize the +* performance +*/
Same comment about the comment style...
drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 89
Quoted 5 lines
drivers/usb/host/ehci-pci.c +5
-0+ thr =INTEL_QUARK_X1000_EHCI_THRESHOLD ( +INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE -4 + ); + val = thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT | + thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT ;
Please surround << with spaces for consistency.
drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 94
Quoted 5 lines
drivers/usb/host/ehci-pci.c +3
-0+ehci_writel (ehci, val, ehci->regs->intel_quark_x1000_insnreg01); + } +return 0 ; }
WBR, Sergei
RE: [PATCH v3] USB: ehci-pci: USB host controller support for Intel Quark X1000
Quoted 9 lines
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 43
Quoted 7 lines
/*-------------------------------------------------------------------- -----*/
drivers/usb/host/ehci-pci.c +5
-0+#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 +static inline bool is_intel_quark_x1000 (struct pci_dev *pdev) { +return pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC ; +}Why not just put this check inline into
ehci_pci_reinit()?
Alan Stern said it is not a problem, I think so also since it just a inline subroutine.
Quoted 10 lines
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 49
Quoted 7 lines
drivers/usb/host/ehci-pci.c +6
-0+ +/* +* The offset of in/out threshold register is 0x84. +* And it is the register of 'hostpc' +* in memory-mapped EHCI controller. +*/ The preferred multi-line kernel style is this:
Quoted 4 lines
/*
* bla
* bla
*/
I will improve it.
Quoted 17 lines
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 52
Quoted 3 lines
drivers/usb/host/ehci-pci.c +3
-0+#define intel_quark_x1000_insnreg01 hostpc + +/* The maximal ehci packet buffer size is 512 bytes */ s/ehci/EHCI/
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 59
Quoted 8 lines
drivers/usb/host/ehci-pci.c +7
-0+#define INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE 512 + +/* The threshold value set the register is in DWORD */ +#define INTEL_QUARK_X1000_EHCI_THRESHOLD (size) ((size)/4u) +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT 16 +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT 0 +Too many empty lines...
Quoted 8 lines
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 66
Quoted 6 lines
/* called after powerup, by probe or system-pm "wakeup" */ static int
ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev){
int retval;drivers/usb/host/ehci-pci.c +2
-0+u32 val; +u32 thr;Why not declare these where they are used?
All will be removed as Alan Stern's suggestion.
Quoted 11 lines
drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 84
Quoted 8 lines
drivers/usb/host/ehci-pci.c +8
-0+/* Reset the threshold limit */ +if (is_intel_quark_x1000 (pdev)) { +/* +* In order to support the isochronous/interrupt +* transactions, 508 bytes should be used as +* max threshold values to maximize the +* performance +*/ Same comment about the comment style...
Quoted 7 lines
drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 89
Quoted 5 lines
drivers/usb/host/ehci-pci.c +5
-0+ thr =INTEL_QUARK_X1000_EHCI_THRESHOLD ( +INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE -4 + ); + val = thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT | + thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT ;Please surround << with spaces for consistency.
The above code will be removed as Alan Stern's suggestion.
Quoted 1 line
Alan Stern
maintainerRe: [PATCH v3] USB: ehci-pci: USB host controller support for Intel Quark X1000
In reply to Chen, AlvinQuoted 11 lines · Alvin
From: Bryan O'Donoghue <[email protected]>
The EHCI packet buffer in/out threshold is programmable for Intel Quark X1000 USB host controller, and the default value is
0x20dwords. The in/out threshold can be programmed to0x80dwords (512 Bytes) to maximize the perfomrance, but only when isochronous/interrupt transactions are not initiated by the USB host controller. This patch is to reconfigure the packet buffer in/out threshold as maximal as possible to maximize the performance, and0x7Fdwords (508 Bytes) should be used because the USB host controller initiates isochronous/interrupt transactions.
Quoted 2 lines
Signed-off-by Bryan O'Donoghue <[email protected]>Signed-off-by Alvin (Weike) Chen <[email protected]>
This is getting a lot better.
Quoted 5 lines
drivers/usb/host/ehci-pci.c +0
-0
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 43
Quoted 9 lines
drivers/usb/host/ehci-pci.c +6
-0@@ -35,11 +35,35 @@ static const char hcd_name[] = "ehci-pci";#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70/*-------------------------------------------------------------------------*/ +#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 +static inline bool is_intel_quark_x1000 (struct pci_dev *pdev) +{ +return pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC ; +}
Whether to put this test directly into ehci_pci_reset() or leave it as a separate subroutine is up to you. I don't care either way.
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 49
Quoted 6 lines
drivers/usb/host/ehci-pci.c +6
-0+ +/* +* The offset of in/out threshold register is 0x84. +* And it is the register of 'hostpc' +* in memory-mapped EHCI controller. +*/
0x84 is the same as offset of the hostpc register in the Intel Moorestown controller. hostpc is not present in general EHCI controllers.
Quoted 27 lines
drivers/usb/host/ehci-pci.c +16
-0+#define intel_quark_x1000_insnreg01 hostpc + +/* The maximal ehci packet buffer size is 512 bytes */ +#define INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE 512 + +/* The threshold value set the register is in DWORD */ +#define INTEL_QUARK_X1000_EHCI_THRESHOLD (size) ((size)/4u) +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT 16 +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT 0 +/* called after powerup, by probe or system-pm "wakeup" */ static int ehci_pci_reinit (struct ehci_hcd *ehci,struct pci_dev *pdev) {int retval; +u32 val; +u32 thr;/* we expect static quirk code to handle the "extended capabilities" * (currently just BIOS handoff) allowed starting with EHCI 0.96 @@ -50,6 +74,22 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)if (!retval)ehci_dbg (ehci,"MWI active\n" ); +/* Reset the threshold limit */ +if (is_intel_quark_x1000 (pdev)) { +/* +* In order to support the isochronous/interrupt
drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 90
Quoted 10 lines
drivers/usb/host/ehci-pci.c +10
-0+* transactions, 508 bytes should be used as +* max threshold values to maximize the +* performance +*/ + thr =INTEL_QUARK_X1000_EHCI_THRESHOLD ( +INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE -4 + ); + val = thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT | + thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT ; +ehci_writel (ehci, val, ehci->regs->intel_quark_x1000_insnreg01);
I saw what other people told you about the original patch version, and I disagree with them. It is not necessary to include a detailed calculation like this, it only makes the code harder to read. It will be better to have a single #define with a comment explaining it, like this:
/* Maximum usable threshold value is 0x7f dwords for both IN and OUT */
#define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD 0x007f007f
Then here, just use INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD instead of val. The comment can simply say:
/* * For the Intel QUARK X1000, raise the I/O threshold to the * maximum usable value in order to improve performance. */
Alan Stern
RE: [PATCH v3] USB: ehci-pci: USB host controller support for Intel Quark X1000
Quoted 11 lines
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 43
Quoted 8 lines
/*-------------------------------------------------------------------- -----*/
drivers/usb/host/ehci-pci.c +5
-0+#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 +static inline bool is_intel_quark_x1000 (struct pci_dev *pdev) { +return pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC ; +}Whether to put this test directly into
ehci_pci_reset()or leave it as a separate subroutine is up to you. I don't care either way.
I will just keep it.
Quoted 10 lines
drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci"; · line 49
Quoted 6 lines
drivers/usb/host/ehci-pci.c +6
-0+ +/* +* The offset of in/out threshold register is 0x84. +* And it is the register of 'hostpc' +* in memory-mapped EHCI controller. +*/
0x84is the same as offset of the hostpc register in the Intel Moorestown controller. hostpc is not present in general EHCI controllers.
OK, I will improve the comments.
Quoted 47 lines
Quoted 12 lines
drivers/usb/host/ehci-pci.c +10
-0+#define intel_quark_x1000_insnreg01 hostpc + +/* The maximal ehci packet buffer size is 512 bytes */ +#define INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE 512 + +/* The threshold value set the register is in DWORD */ +#define INTEL_QUARK_X1000_EHCI_THRESHOLD (size) ((size)/4u) +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT 16 +#define INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT 0 + /* called after powerup, by probe or system-pm "wakeup" */ staticint
ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev){drivers/usb/host/ehci-pci.c static const char hcd_name[] = "ehci-pci";
Quoted 7 lines
drivers/usb/host/ehci-pci.c +2
-1int retval; +u32 val; +u32 thr;/* we expect static quirk code to handle the "extended capabilities" * (currently just BIOS handoff) allowed starting with EHCI 0.96 @@ -50,6 +74,22 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct
pci_dev*pdev)Quoted 7 lines
drivers/usb/host/ehci-pci.c +4
-0if (!retval)ehci_dbg (ehci,"MWI active\n" ); +/* Reset the threshold limit */ +if (is_intel_quark_x1000 (pdev)) { +/* +* In order to support the isochronous/interrupt drivers/usb/host/ehci-pci.c static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) · line 90
Quoted 10 lines
drivers/usb/host/ehci-pci.c +10
-0+* transactions, 508 bytes should be used as +* max threshold values to maximize the +* performance +*/ + thr =INTEL_QUARK_X1000_EHCI_THRESHOLD ( +INTEL_QUARK_X1000_EHCI_MAX_PACKET_BUFFER_SIZE -4 + ); + val = thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_OUT_SHIFT | + thr<<INTEL_QUARK_X1000_EHCI_THRESHOLD_IN_SHIFT ; +ehci_writel (ehci, val, ehci->regs->intel_quark_x1000_insnreg01);I saw what other people told you about the original patch version, and I disagree with them. It is not necessary to include a detailed calculation like this, it only makes the code harder to read. It will be better to have a single #define with a comment explaining it, like
this:/* Maximum usable threshold value is
0x7fdwords for both IN and OUT */
#defineINTEL_QUARK_X1000_EHCI_MAX_THRESHOLD0x007f007f
Quoted 8 lines
Then here, just use
INTEL_QUARK_X1000_EHCI_MAX_THRESHOLDinstead of val. The comment can simply say:/* * For the Intel QUARK X1000, raise the I/O threshold to the * maximum usable value in order to improve performance. */
I think so also. It is not necessary to make so complicated. I will adopt your suggestions, it is more simple and clearly.
Quoted 1 line
Alan Stern