Re: JMicron based usb 3.0 to sata enclosure, hangs, numerous errors
Upgraded to 4.15.3 and now UAS works, strange... Anyhow now the enclosure is connected via an USB 3.0 HUB (self powered in my case) and it seems to be stable Devs, apparently there is some problem operating this chipset with Intel USB controller directly I have googled a little bit aroud and actually found someone complaining of a possible similar issue also on Windows: http://goughlui.com/2015/11/01/review-orico-usb-3-0-5-bay-raid-hdd-enclosure-9558ru3-part-2/ Note that the USB controller I have is identical to the Chris one: 00:14.0 USB controller [0c03]: Intel Corporation Device [8086:22b5] (rev 36) (prog-if 30 [XHCI]) Subsystem: Intel Corporation Device [8086:7270] Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+ Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- SERR- Kernel driver in use: xhci_hcd 2018-02-14 8:36 GMT+01:00 Menion : > That is very strange > My device has same vid:pid of your one, but it goes blacklisted... > I am running kernel 4.15.1, I will try to upgrade > What kind of enclosure is yours? Mine is an Orico 9553RU3 5 bay > enclosure with RAID > Bye > > 2018-02-13 23:41 GMT+01:00 Chris Murphy : >> On Mon, Feb 12, 2018 at 12:57 AM, Menion wrote: >> >>> >>> I wanted to test my enclosure with an hub, but I have just realized >>> that now the JMS567 is UAS blacklisted by default in kernel >>> 4.15.x. >>> Can you check if it still works removing the dedicated hub external >>> power supply? >> >> >> I've upgraded to 4.15.3, and it does not appear to be blacklisted for uas >> driver. >> >> kernel: usbcore: registered new interface driver usb-storage >> kernel: scsi host2: uas >> kernel: usbcore: registered new interface driver uas >> >> >> >> Full kernel messages upon insertion directly to the computer's USB port >> (hub not involved at all): >> https://paste.fedoraproject.org/paste/bPPAl~ngYjktfC--i7NqJA/raw >> >> >> >> -- >> Chris Murphy -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: JMicron based usb 3.0 to sata enclosure, hangs, numerous errors
weird, not, it is little bit more stable, bu then it eventually hit the problem again: [ 2696.410684] sd 2:0:0:2: [sdc] tag#13 uas_eh_abort_handler 0 uas-tag 14 inflight: CMD OUT [ 2696.410708] sd 2:0:0:2: [sdc] tag#13 CDB: Write(10) 2a 00 19 ed 69 80 00 00 20 00 [ 2696.410948] sd 2:0:0:2: [sdc] tag#12 uas_eh_abort_handler 0 uas-tag 13 inflight: CMD OUT [ 2696.410967] sd 2:0:0:2: [sdc] tag#12 CDB: Write(10) 2a 00 19 ed 69 40 00 00 20 00 [ 2696.415259] sd 2:0:0:2: [sdc] tag#11 uas_eh_abort_handler 0 uas-tag 12 inflight: CMD OUT [ 2696.415282] sd 2:0:0:2: [sdc] tag#11 CDB: Write(10) 2a 00 19 ed 69 00 00 00 20 00 [ 2696.418759] sd 2:0:0:2: [sdc] tag#10 uas_eh_abort_handler 0 uas-tag 11 inflight: CMD OUT [ 2696.418782] sd 2:0:0:2: [sdc] tag#10 CDB: Write(10) 2a 00 19 ed 68 20 00 00 60 00 [ 2696.422170] sd 2:0:0:2: [sdc] tag#9 uas_eh_abort_handler 0 uas-tag 10 inflight: CMD OUT [ 2696.422183] sd 2:0:0:2: [sdc] tag#9 CDB: Write(10) 2a 00 19 ed 67 80 00 00 40 00 [ 2696.425660] sd 2:0:0:2: [sdc] tag#8 uas_eh_abort_handler 0 uas-tag 9 inflight: CMD OUT [ 2696.425672] sd 2:0:0:2: [sdc] tag#8 CDB: Write(10) 2a 00 19 ed 66 e0 00 00 80 00 [ 2696.429160] sd 2:0:0:2: [sdc] tag#7 uas_eh_abort_handler 0 uas-tag 8 inflight: CMD OUT [ 2696.429171] sd 2:0:0:2: [sdc] tag#7 CDB: Write(10) 2a 00 19 ed 66 40 00 00 60 00 [ 2696.432661] sd 2:0:0:2: [sdc] tag#6 uas_eh_abort_handler 0 uas-tag 7 inflight: CMD OUT [ 2696.432675] sd 2:0:0:2: [sdc] tag#6 CDB: Write(10) 2a 00 19 ed 5c 20 00 00 20 00 [ 2696.436263] sd 2:0:0:2: [sdc] tag#5 uas_eh_abort_handler 0 uas-tag 6 inflight: CMD OUT [ 2696.436281] sd 2:0:0:2: [sdc] tag#5 CDB: Write(10) 2a 00 19 ed 5b a0 00 00 20 00 [ 2696.439746] sd 2:0:0:2: [sdc] tag#4 uas_eh_abort_handler 0 uas-tag 5 inflight: CMD OUT [ 2696.439764] sd 2:0:0:2: [sdc] tag#4 CDB: Write(10) 2a 00 19 ed 5b 40 00 00 40 00 [ 2696.443236] sd 2:0:0:2: [sdc] tag#3 uas_eh_abort_handler 0 uas-tag 4 inflight: CMD OUT [ 2696.443253] sd 2:0:0:2: [sdc] tag#3 CDB: Write(10) 2a 00 19 ed 59 e0 00 00 20 00 [ 2696.446657] sd 2:0:0:2: [sdc] tag#2 uas_eh_abort_handler 0 uas-tag 3 inflight: CMD OUT [ 2696.44] sd 2:0:0:2: [sdc] tag#2 CDB: Write(10) 2a 00 19 ed 59 00 00 00 20 00 [ 2696.450164] sd 2:0:0:2: [sdc] tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD OUT [ 2696.450172] sd 2:0:0:2: [sdc] tag#1 CDB: Write(10) 2a 00 19 ed 58 80 00 00 60 00 [ 2696.453703] sd 2:0:0:1: [sdb] tag#26 uas_eh_abort_handler 0 uas-tag 27 inflight: CMD OUT [ 2696.453712] sd 2:0:0:1: [sdb] tag#26 CDB: Write(10) 2a 00 00 4d a9 80 00 00 20 00 [ 2696.457284] sd 2:0:0:1: [sdb] tag#25 uas_eh_abort_handler 0 uas-tag 26 inflight: CMD OUT [ 2696.457293] sd 2:0:0:1: [sdb] tag#25 CDB: Write(10) 2a 00 00 4d a9 40 00 00 20 00 [ 2696.461226] sd 2:0:0:1: [sdb] tag#24 uas_eh_abort_handler 0 uas-tag 25 inflight: CMD OUT [ 2696.461249] sd 2:0:0:1: [sdb] tag#24 CDB: Write(10) 2a 00 00 4d a9 00 00 00 20 00 [ 2696.464934] sd 2:0:0:1: [sdb] tag#23 uas_eh_abort_handler 0 uas-tag 24 inflight: CMD OUT [ 2696.464958] sd 2:0:0:1: [sdb] tag#23 CDB: Write(10) 2a 00 00 4d a8 20 00 00 60 00 [ 2696.468555] sd 2:0:0:1: [sdb] tag#22 uas_eh_abort_handler 0 uas-tag 23 inflight: CMD OUT [ 2696.468569] sd 2:0:0:1: [sdb] tag#22 CDB: Write(10) 2a 00 00 4d a7 80 00 00 40 00 [ 2696.471942] sd 2:0:0:1: [sdb] tag#0 uas_eh_abort_handler 0 uas-tag 22 inflight: CMD OUT [ 2696.471955] sd 2:0:0:1: [sdb] tag#0 CDB: Write(10) 2a 00 00 4d a6 e0 00 00 80 00 [ 2696.475759] sd 2:0:0:1: [sdb] tag#21 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD OUT [ 2696.475773] sd 2:0:0:1: [sdb] tag#21 CDB: Write(10) 2a 00 00 4d a6 40 00 00 60 00 [ 2696.479231] sd 2:0:0:1: [sdb] tag#20 uas_eh_abort_handler 0 uas-tag 21 inflight: CMD OUT [ 2696.479248] sd 2:0:0:1: [sdb] tag#20 CDB: Write(10) 2a 00 00 4d 9c 20 00 00 20 00 [ 2696.482706] sd 2:0:0:1: [sdb] tag#19 uas_eh_abort_handler 0 uas-tag 20 inflight: CMD OUT [ 2696.482722] sd 2:0:0:1: [sdb] tag#19 CDB: Write(10) 2a 00 00 4d 9b a0 00 00 20 00 [ 2696.486396] sd 2:0:0:1: [sdb] tag#18 uas_eh_abort_handler 0 uas-tag 19 inflight: CMD OUT [ 2696.486410] sd 2:0:0:1: [sdb] tag#18 CDB: Write(10) 2a 00 00 4d 9b 40 00 00 40 00 [ 2696.490218] sd 2:0:0:1: [sdb] tag#17 uas_eh_abort_handler 0 uas-tag 18 inflight: CMD OUT [ 2696.490236] sd 2:0:0:1: [sdb] tag#17 CDB: Write(10) 2a 00 00 4d 99 e0 00 00 20 00 [ 2696.494186] sd 2:0:0:1: [sdb] tag#16 uas_eh_abort_handler 0 uas-tag 17 inflight: CMD OUT [ 2696.494215] sd 2:0:0:1: [sdb] tag#16 CDB: Write(10) 2a 00 00 4d 99 00 00 00 20 00 [ 2696.498156] sd 2:0:0:1: [sdb] tag#15 uas_eh_abort_handler 0 uas-tag 16 inflight: CMD OUT [ 2696.498178] sd 2:0:0:1: [sdb] tag#15 CDB: Write(10) 2a 00 00 4d 98 80 00 00 60 00 [ 2696.501622] sd 2:0:0:1: [sdb] tag#14 uas_eh_abort_handler 0 uas-tag 15 inflight: CMD OUT [ 2696.501630] sd 2:0:0:1: [sdb] tag#14 CDB: Write(10) 2a 00 00 4d 97 00 00 00 20 00 [ 2696.505850] scsi host2: uas_eh_device_reset_handler start [ 2696.587283] usb 2-1.4: reset SuperSpeed USB device number 4 using xhci_hcd [ 2696.611371] scsi ho
Re: High CPU load produced by USB (DW2)
On 8 February 2018 at 14:53, Minas Harutyunyan wrote: > On 2/8/2018 5:07 PM, Mirza Krak wrote: >> On 8 February 2018 at 12:02, Minas Harutyunyan >> wrote: >>> Hi Mirza, >>> >>> On 2/7/2018 1:49 PM, Mirza Krak wrote: >> >> < snip > >> >>> >>> Could you please provide additional info: >>> 1. Does your core support descriptor DMA mode? (bits 31 and 30 of GHWCFG4). >>> 2. Version of core (GSNPSID)? >> >> It does seem to support descriptor DMA mode, and content of both >> GHWCFG4 and GSNPSID are posted below. >> >> root@esp5-d1:~# dmesg | grep -E "GHWCFG4|GSNPSID" >> [1.109298] dwc2 ff54.usb: GSNPSID @0xF0940040 : 0x4F54310A >> [1.109344] dwc2 ff54.usb: GHWCFG4 @0xF0940050 : 0xC8004030 >> [1.489016] dwc2 ff58.usb: GSNPSID @0xF09C0040 : 0x4F54310A >> [1.489063] dwc2 ff58.usb: GHWCFG4 @0xF09C0050 : 0xDBF04030 >> >> Full register dump at boot (no devices connected) can be found at [1]. >> >>> 3. Do you connect any HS HUB between dwc core port and keyboard? Is it >>> available connection scenarios when Split traffic generated? >> >> There is actually an HS HUB (FE1_QFP48) between dwc core and keyboard, >> I was not aware of it but it is mounted on the board. >> >> >> [1]. >> https://urldefense.proofpoint.com/v2/url?u=https-3A__gist.github.com_mirzak_a62454670f3b908a9783f9db8b0d&d=DwIFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=6z9Al9FrHR_ZqbbtSAsD16pvOL2S3XHxQnSzq8kusyI&m=FuRmhDEOJlbUvuyApaxG_YmB514C3IOGSzs6Mq_fzC0&s=ELF0UP4IluOiL35JlnFjiltWZx-BcTIsTaPjaWb0RFk&e= >> > Actually your core supported DDMA mode, moreover core allow SW to > dynamically switch between BDMA and DDMA after core reset. > If dwc2 core work in DDMA mode then core can track (u)frames internally > and unmasking SOF's not required, but Host in DDMA doesn't support Split > transfers. This is why, in your case (FS/LS keyboard connected to HS > HUB), core switched to BDMA and unmasking SOF interrupt to track (u)frames. Thank you for your valuable respons. It is indeed as you mentioned the combination of HS and FS/LS devices that trigger the high CPU load. Running HS only devices does not produce any noticeable load. But I am confused by one thing, I have two different boards with the same SoC and same version of the DWC2 IP. Both boards have an internal USB hub for the external connectors, though it seems that they have different types of HUB' s. And I only have problems with one of them. The second board does not have a problem mixing HS and FS/LS devices. Is it possible that the USB HUB has some kind of "offloading" for the Split transfers? Tinkerboard USB hub (works well when mixing HS and FS/LS devices) $ lsusb -t /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M |__ Port 1: Dev 2, If 0, Class=Audio, Driver=, 480M |__ Port 1: Dev 2, If 1, Class=Audio, Driver=, 480M |__ Port 1: Dev 2, If 2, Class=Audio, Driver=, 480M |__ Port 1: Dev 2, If 3, Class=Audio, Driver=, 480M |__ Port 1: Dev 2, If 4, Class=Audio, Driver=, 480M |__ Port 1: Dev 2, If 5, Class=Audio, Driver=, 480M |__ Port 1: Dev 2, If 255, Class=Human Interface Device, Driver=usbhid, 480M /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M |__ Port 3: Dev 4, If 0, Class=Audio, Driver=, 12M |__ Port 3: Dev 4, If 1, Class=Audio, Driver=, 12M |__ Port 4: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M $ lsusb -d 05e3:0610 -v Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass9 Hub bDeviceSubClass 0 bDeviceProtocol 2 TT per port bMaxPacketSize064 idVendor 0x05e3 Genesys Logic, Inc. idProduct 0x0610 4-port hub bcdDevice 32.98 iManufacturer 0 iProduct1 USB2.0 Hub iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 41 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 bInterfaceProtocol 1 Single TT iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes3 Transfer TypeInterrupt Synch Type
[PATCH] staging: typec: handle vendor defined part and modify drp toggling flow
From: ShuFanLee Handle vendor defined behavior in tcpci_init and tcpci_irq. More operations can be extended in tcpci_vendor_data if needed. According to TCPCI specification, 4.4.5.2 ROLE_CONTROL, TCPC shall not start DRP toggling until subsequently the TCPM writes to the COMMAND register to start DRP toggling. DRP toggling flow is chagned as following: - Write DRP = 0 & Rd/Rd - Write DRP = 1 - Set LOOK4CONNECTION command Signed-off-by: ShuFanLee --- drivers/staging/typec/tcpci.c | 98 --- drivers/staging/typec/tcpci.h | 15 +++ 2 files changed, 97 insertions(+), 16 deletions(-) diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 9bd4412..b3a97b3 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -30,6 +30,7 @@ struct tcpci { bool controls_vbus; struct tcpc_dev tcpc; + struct tcpci_vendor_data *vdata; }; static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc) @@ -37,16 +38,29 @@ static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc) return container_of(tcpc, struct tcpci, tcpc); } -static int tcpci_read16(struct tcpci *tcpci, unsigned int reg, - u16 *val) +int tcpci_read16(struct tcpci *tcpci, unsigned int reg, u16 *val) { return regmap_raw_read(tcpci->regmap, reg, val, sizeof(u16)); } +EXPORT_SYMBOL_GPL(tcpci_read16); -static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) +int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) { return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16)); } +EXPORT_SYMBOL_GPL(tcpci_write16); + +int tcpci_read8(struct tcpci *tcpci, unsigned int reg, u8 *val) +{ + return regmap_raw_read(tcpci->regmap, reg, val, sizeof(u8)); +} +EXPORT_SYMBOL_GPL(tcpci_read8); + +int tcpci_write8(struct tcpci *tcpci, unsigned int reg, u8 val) +{ + return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u8)); +} +EXPORT_SYMBOL_GPL(tcpci_write8); static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) { @@ -98,8 +112,10 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, enum typec_cc_status cc) { + int ret; struct tcpci *tcpci = tcpc_to_tcpci(tcpc); - unsigned int reg = TCPC_ROLE_CTRL_DRP; + unsigned int reg = (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT) | + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT); switch (cc) { default: @@ -116,8 +132,19 @@ static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, TCPC_ROLE_CTRL_RP_VAL_SHIFT); break; } - - return regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + usleep_range(500, 1000); + reg |= TCPC_ROLE_CTRL_DRP; + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + ret = regmap_write(tcpci->regmap, TCPC_COMMAND, + TCPC_CMD_LOOK4CONNECTION); + if (ret < 0) + return ret; + return 0; } static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink) @@ -323,6 +350,15 @@ static int tcpci_init(struct tcpc_dev *tcpc) if (time_after(jiffies, timeout)) return -ETIMEDOUT; + /* Handle vendor init */ + if (tcpci->vdata) { + if (tcpci->vdata->init) { + ret = (*tcpci->vdata->init)(tcpci, tcpci->vdata); + if (ret < 0) + return ret; + } + } + /* Clear all events */ ret = tcpci_write16(tcpci, TCPC_ALERT, 0x); if (ret < 0) @@ -351,6 +387,13 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id) tcpci_read16(tcpci, TCPC_ALERT, &status); + /* Handle vendor defined interrupt */ + if (tcpci->vdata) { + if (tcpci->vdata->irq_handler) + (*tcpci->vdata->irq_handler)(tcpci, tcpci->vdata, +&status); + } + /* * Clear alert status for everything except RX_STATUS, which shouldn't * be cleared until we have successfully retrieved message. @@ -417,7 +460,7 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id) .reg_bits = 8, .val_bits = 8, - .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */ + .max_register = 0xFF, /* 0x80 .. 0xFF are vendor defined */ }; static const struct tcpc_config tcpci_tcpc_config = { @@ -435,22 +478,22 @@ static int tcpci_parse_config(struct tcpci *tcpci) return 0; } -static int tcpci_probe(struct i2c_client
Re: [PATCH] staging: typec: handle vendor defined part and modify drp toggling flow
On Wed, Feb 14, 2018 at 05:24:04PM +0800, ShuFanLee wrote: > From: ShuFanLee > > Handle vendor defined behavior in tcpci_init and tcpci_irq. > More operations can be extended in tcpci_vendor_data if needed. > According to TCPCI specification, 4.4.5.2 ROLE_CONTROL, > TCPC shall not start DRP toggling until subsequently the TCPM > writes to the COMMAND register to start DRP toggling. > DRP toggling flow is chagned as following: > - Write DRP = 0 & Rd/Rd > - Write DRP = 1 > - Set LOOK4CONNECTION command > > Signed-off-by: ShuFanLee > --- > drivers/staging/typec/tcpci.c | 98 > --- > drivers/staging/typec/tcpci.h | 15 +++ > 2 files changed, 97 insertions(+), 16 deletions(-) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index 9bd4412..b3a97b3 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -30,6 +30,7 @@ struct tcpci { > bool controls_vbus; > > struct tcpc_dev tcpc; > + struct tcpci_vendor_data *vdata; > }; > > static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc) > @@ -37,16 +38,29 @@ static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev > *tcpc) > return container_of(tcpc, struct tcpci, tcpc); > } > > -static int tcpci_read16(struct tcpci *tcpci, unsigned int reg, > - u16 *val) > +int tcpci_read16(struct tcpci *tcpci, unsigned int reg, u16 *val) > { > return regmap_raw_read(tcpci->regmap, reg, val, sizeof(u16)); > } > +EXPORT_SYMBOL_GPL(tcpci_read16); > > -static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) > +int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val) > { > return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16)); > } > +EXPORT_SYMBOL_GPL(tcpci_write16); > + > +int tcpci_read8(struct tcpci *tcpci, unsigned int reg, u8 *val) > +{ > + return regmap_raw_read(tcpci->regmap, reg, val, sizeof(u8)); > +} > +EXPORT_SYMBOL_GPL(tcpci_read8); > + > +int tcpci_write8(struct tcpci *tcpci, unsigned int reg, u8 val) > +{ > + return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u8)); > +} > +EXPORT_SYMBOL_GPL(tcpci_write8); I don't think there is any need to export those wrappers. You can always expect the glue driver to supply the regmap as member of that struct tcpci_vendor_data. See below.. > static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) > { > @@ -98,8 +112,10 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum > typec_cc_status cc) > static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, > enum typec_cc_status cc) > { > + int ret; > struct tcpci *tcpci = tcpc_to_tcpci(tcpc); > - unsigned int reg = TCPC_ROLE_CTRL_DRP; > + unsigned int reg = (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT) | > +(TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT); > > switch (cc) { > default: > @@ -116,8 +132,19 @@ static int tcpci_start_drp_toggling(struct tcpc_dev > *tcpc, > TCPC_ROLE_CTRL_RP_VAL_SHIFT); > break; > } > - > - return regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); > + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); > + if (ret < 0) > + return ret; > + usleep_range(500, 1000); > + reg |= TCPC_ROLE_CTRL_DRP; > + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); > + if (ret < 0) > + return ret; > + ret = regmap_write(tcpci->regmap, TCPC_COMMAND, > +TCPC_CMD_LOOK4CONNECTION); > + if (ret < 0) > + return ret; > + return 0; > } > > static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink) > @@ -323,6 +350,15 @@ static int tcpci_init(struct tcpc_dev *tcpc) > if (time_after(jiffies, timeout)) > return -ETIMEDOUT; > > + /* Handle vendor init */ > + if (tcpci->vdata) { > + if (tcpci->vdata->init) { > + ret = (*tcpci->vdata->init)(tcpci, tcpci->vdata); ret = tcpci->vdata->init(... > + if (ret < 0) > + return ret; > + } > + } > + > /* Clear all events */ > ret = tcpci_write16(tcpci, TCPC_ALERT, 0x); > if (ret < 0) > @@ -351,6 +387,13 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id) > > tcpci_read16(tcpci, TCPC_ALERT, &status); > > + /* Handle vendor defined interrupt */ > + if (tcpci->vdata) { > + if (tcpci->vdata->irq_handler) > + (*tcpci->vdata->irq_handler)(tcpci, tcpci->vdata, > + &status); Ditto. > + } > + > /* >* Clear alert status for everything except RX_STATUS, which shouldn't >* be cleared until we have successfully retrieved message. > @@ -417,7 +460,7 @@ static irqre
Re: High CPU load produced by USB (DW2)
On 2/14/2018 12:57 PM, Mirza Krak wrote: > On 8 February 2018 at 14:53, Minas Harutyunyan > wrote: >> On 2/8/2018 5:07 PM, Mirza Krak wrote: >>> On 8 February 2018 at 12:02, Minas Harutyunyan >>> wrote: Hi Mirza, On 2/7/2018 1:49 PM, Mirza Krak wrote: >>> >>> < snip > >>> Could you please provide additional info: 1. Does your core support descriptor DMA mode? (bits 31 and 30 of GHWCFG4). 2. Version of core (GSNPSID)? >>> >>> It does seem to support descriptor DMA mode, and content of both >>> GHWCFG4 and GSNPSID are posted below. >>> >>> root@esp5-d1:~# dmesg | grep -E "GHWCFG4|GSNPSID" >>> [1.109298] dwc2 ff54.usb: GSNPSID @0xF0940040 : 0x4F54310A >>> [1.109344] dwc2 ff54.usb: GHWCFG4 @0xF0940050 : 0xC8004030 >>> [1.489016] dwc2 ff58.usb: GSNPSID @0xF09C0040 : 0x4F54310A >>> [1.489063] dwc2 ff58.usb: GHWCFG4 @0xF09C0050 : 0xDBF04030 >>> >>> Full register dump at boot (no devices connected) can be found at [1]. >>> 3. Do you connect any HS HUB between dwc core port and keyboard? Is it available connection scenarios when Split traffic generated? >>> >>> There is actually an HS HUB (FE1_QFP48) between dwc core and keyboard, >>> I was not aware of it but it is mounted on the board. >>> >>> >>> [1]. >>> https://urldefense.proofpoint.com/v2/url?u=https-3A__gist.github.com_mirzak_a62454670f3b908a9783f9db8b0d&d=DwIFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=6z9Al9FrHR_ZqbbtSAsD16pvOL2S3XHxQnSzq8kusyI&m=FuRmhDEOJlbUvuyApaxG_YmB514C3IOGSzs6Mq_fzC0&s=ELF0UP4IluOiL35JlnFjiltWZx-BcTIsTaPjaWb0RFk&e= >>> >> Actually your core supported DDMA mode, moreover core allow SW to >> dynamically switch between BDMA and DDMA after core reset. >> If dwc2 core work in DDMA mode then core can track (u)frames internally >> and unmasking SOF's not required, but Host in DDMA doesn't support Split >> transfers. This is why, in your case (FS/LS keyboard connected to HS >> HUB), core switched to BDMA and unmasking SOF interrupt to track (u)frames. > > Thank you for your valuable respons. > > It is indeed as you mentioned the combination of HS and FS/LS devices > that trigger the high CPU load. Running HS only devices does not > produce any noticeable load. > > But I am confused by one thing, I have two different boards with the > same SoC and same version of the DWC2 IP. Both boards have an internal > USB hub for the external connectors, though it seems that they have > different types of HUB' s. And I only have problems with one of them. > The second board does not have a problem mixing HS and FS/LS devices. > Is it possible that the USB HUB has some kind of "offloading" for the > Split transfers? > > Tinkerboard USB hub (works well when mixing HS and FS/LS devices) > > > $ lsusb -t > /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M > |__ Port 1: Dev 2, If 0, Class=Audio, Driver=, 480M > |__ Port 1: Dev 2, If 1, Class=Audio, Driver=, 480M > |__ Port 1: Dev 2, If 2, Class=Audio, Driver=, 480M > |__ Port 1: Dev 2, If 3, Class=Audio, Driver=, 480M > |__ Port 1: Dev 2, If 4, Class=Audio, Driver=, 480M > |__ Port 1: Dev 2, If 5, Class=Audio, Driver=, 480M > |__ Port 1: Dev 2, If 255, Class=Human Interface Device, Driver=usbhid, > 480M > /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M > /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M > |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M > |__ Port 3: Dev 4, If 0, Class=Audio, Driver=, 12M > |__ Port 3: Dev 4, If 1, Class=Audio, Driver=, 12M > |__ Port 4: Dev 3, If 0, Class=Human Interface Device, > Driver=usbhid, 12M > > $ lsusb -d 05e3:0610 -v > > Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub > Device Descriptor: >bLength18 >bDescriptorType 1 >bcdUSB 2.00 >bDeviceClass9 Hub >bDeviceSubClass 0 >bDeviceProtocol 2 TT per port >bMaxPacketSize064 >idVendor 0x05e3 Genesys Logic, Inc. >idProduct 0x0610 4-port hub >bcdDevice 32.98 >iManufacturer 0 >iProduct1 USB2.0 Hub >iSerial 0 >bNumConfigurations 1 >Configuration Descriptor: > bLength 9 > bDescriptorType 2 > wTotalLength 41 > bNumInterfaces 1 > bConfigurationValue 1 > iConfiguration 0 > bmAttributes 0xe0 >Self Powered >Remote Wakeup > MaxPower 100mA > Interface Descriptor: >bLength 9 >bDescriptorType 4 >bInterfaceNumber0 >bAlternateSetting 0 >bNumEndpoints 1 >bInterfaceClass 9 Hub >bInterfaceSubClass 0 >bInterfaceProtocol 1 Single TT
[PATCH v2] staging: typec: handle vendor defined part and modify drp toggling flow
From: ShuFanLee Handle vendor defined behavior in tcpci_init, tcpci_set_vconn and export tcpci_irq. More operations can be extended in tcpci_data if needed. According to TCPCI specification, 4.4.5.2 ROLE_CONTROL, TCPC shall not start DRP toggling until subsequently the TCPM writes to the COMMAND register to start DRP toggling. DRP toggling flow is chagned as following: - Write DRP = 0 & Rd/Rd - Write DRP = 1 - Set LOOK4CONNECTION command Signed-off-by: ShuFanLee --- drivers/staging/typec/tcpci.c | 111 ++ drivers/staging/typec/tcpci.h | 13 + 2 files changed, 103 insertions(+), 21 deletions(-) diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 9bd4412..461fbd48 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -21,7 +21,6 @@ struct tcpci { struct device *dev; - struct i2c_client *client; struct tcpm_port *port; @@ -30,6 +29,7 @@ struct tcpci { bool controls_vbus; struct tcpc_dev tcpc; + struct tcpci_data *data; }; static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc) @@ -98,8 +98,10 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, enum typec_cc_status cc) { + int ret; struct tcpci *tcpci = tcpc_to_tcpci(tcpc); - unsigned int reg = TCPC_ROLE_CTRL_DRP; + unsigned int reg = (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT) | + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT); switch (cc) { default: @@ -116,8 +118,19 @@ static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, TCPC_ROLE_CTRL_RP_VAL_SHIFT); break; } - - return regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + usleep_range(500, 1000); + reg |= TCPC_ROLE_CTRL_DRP; + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + ret = regmap_write(tcpci->regmap, TCPC_COMMAND, + TCPC_CMD_LOOK4CONNECTION); + if (ret < 0) + return ret; + return 0; } static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink) @@ -178,6 +191,16 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable) struct tcpci *tcpci = tcpc_to_tcpci(tcpc); int ret; + /* Handle vendor set vconn */ + if (tcpci->data) { + if (tcpci->data->set_vconn) { + ret = tcpci->data->set_vconn(tcpci, tcpci->data, +enable); + if (ret < 0) + return ret; + } + } + ret = regmap_write(tcpci->regmap, TCPC_POWER_CTRL, enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0); if (ret < 0) @@ -323,6 +346,15 @@ static int tcpci_init(struct tcpc_dev *tcpc) if (time_after(jiffies, timeout)) return -ETIMEDOUT; + /* Handle vendor init */ + if (tcpci->data) { + if (tcpci->data->init) { + ret = tcpci->data->init(tcpci, tcpci->data); + if (ret < 0) + return ret; + } + } + /* Clear all events */ ret = tcpci_write16(tcpci, TCPC_ALERT, 0x); if (ret < 0) @@ -344,9 +376,16 @@ static int tcpci_init(struct tcpc_dev *tcpc) return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg); } -static irqreturn_t tcpci_irq(int irq, void *dev_id) +static irqreturn_t _tcpci_irq(int irq, void *dev_id) { struct tcpci *tcpci = dev_id; + + tcpci_irq(tcpci); + return IRQ_HANDLED; +} + +int tcpci_irq(struct tcpci *tcpci) +{ u16 status; tcpci_read16(tcpci, TCPC_ALERT, &status); @@ -412,6 +451,7 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id) return IRQ_HANDLED; } +EXPORT_SYMBOL_GPL(tcpci_irq); static const struct regmap_config tcpci_regmap_config = { .reg_bits = 8, @@ -435,22 +475,18 @@ static int tcpci_parse_config(struct tcpci *tcpci) return 0; } -static int tcpci_probe(struct i2c_client *client, - const struct i2c_device_id *i2c_id) +struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) { struct tcpci *tcpci; int err; - tcpci = devm_kzalloc(&client->dev, sizeof(*tcpci), GFP_KERNEL); + tcpci = devm_kzalloc(dev, sizeof(*tcpci), GFP_KERNEL); if (!tcpci) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - tcpci->client = client; - tcpci->dev = &client->dev; - i2c_
Re: [PATCH v2] staging: typec: handle vendor defined part and modify drp toggling flow
On Wed, Feb 14, 2018 at 08:45:34PM +0800, ShuFanLee wrote: > From: ShuFanLee > > Handle vendor defined behavior in tcpci_init, tcpci_set_vconn and export > tcpci_irq. > More operations can be extended in tcpci_data if needed. > According to TCPCI specification, 4.4.5.2 ROLE_CONTROL, > TCPC shall not start DRP toggling until subsequently the TCPM > writes to the COMMAND register to start DRP toggling. > DRP toggling flow is chagned as following: > - Write DRP = 0 & Rd/Rd > - Write DRP = 1 > - Set LOOK4CONNECTION command > > Signed-off-by: ShuFanLee > --- > drivers/staging/typec/tcpci.c | 111 > ++ > drivers/staging/typec/tcpci.h | 13 + > 2 files changed, 103 insertions(+), 21 deletions(-) What changed from v1? And I have to ask, are there no ' ' characters in your name? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [BUG] SD card reader disappears after suspend
Thanks for the patches. However no luck yet, the usb device still doesn't reinitialize. Logs: https://gist.github.com/90ccb390c5777b9e2d5dc595f44d50da Can I somehow check if it is at all possible to bring back this particular device after hub power loss? For instance would you expect reloading all USB modules to bring back the device? I tried that and it didn't help: #!/bin/bash echo "Unload modules..." echo 1 > /sys/bus/pci/devices/\:00\:14.0/remove rmmod xhci_pci rmmod xhci_hcd rmmod usbhid rmmod bcm5974 rmmod btusb rmmod uas rmmod usb_storage rmmod usbcore rmmod usb_common echo "wait" sleep 2 echo "Reload modules..." modprobe usb_common modprobe usbcore modprobe usb_storage modprobe uas modprobe btusb modprobe bcm5974 modprobe usbhid modprobe xhci_hcd modprobe xhci_pci echo 1 > /sys/bus/pci/rescan 2018-02-13 17:07 GMT+01:00 Mathias Nyman : > On 12.02.2018 16:03, Mathias Nyman wrote: >> >> On 10.02.2018 02:01, Samuel Sadok wrote: >>> >>> Thanks Mathias for looking into this. >>> >>> 2018-02-06 18:32 GMT+01:00 Mathias Nyman : Does reverting 37be6676 usb: hub: Fix auto-remount of safely removed or ejected USB-3 devices help? >>> >>> >>> Unfortunately not, the card reader is still missing after resume. >>> >>> Here's the dmesg and usbmon (as previously, doing one suspend-resume >>> cycle): >>> https://gist.github.com/anonymous/5aea8eddf97e1b964bffd75ed88793fd >>> >>> For this log I also increased the usbmon buffer size as suggested by >>> Alan (to about 2MB). This (seemingly) resolved the issue with the log >>> gaps. >>> >> Ok, one reason reverting didn't help is that it we still don't really >> disable and re-enable: >> >> [ 100.771564] usb usb2-port4: logical disconnect >> ... >> [ 100.771586] usb usb2-port4: Not disabling port; link state is RxDetect >> >>> The reset resume of device "usb 2-4" (the device in question) happens >>> around [100.77]. >>> In the usbmon log there is no activity at that exact time, only ~50ms >>> before and after. Can we infer from this that the issue is independent >>> from the actual device and must stem from some faulty state in the >>> kernel or USB controller? >>> >>> Btw I also added/modified some debug lines for my own understanding, >>> those are tagged with "[CUSTOM LOG]". >>> * check that root cause for failing USB3 device reset after resume is not that several xhci slots are in Default state at the same time. xHC can't handle this. In normal device enumeration usb core has a mutex protecting it, not sure it works here, maybe usb core and xhci are out of sync after xHC reset? >>> >>> >>> I find this line in particular interesting: >>> [ 100.771536] xhci_hcd :00:14.0: [CUSTOM LOG] xHCI >>> xhci_urb_enqueue called with unaddressed device, slot_id = 1 >>> This comes from xhci_check_args(). Since udev->slot_id == 1 is >>> non-zero this implies that xhci->devs[udev->slot_id] must be NULL for >>> this particular device (usb 2-4), which I guess is not good. So to me >>> this does indeed look like the usb core and xhci are out of sync. >>> >>> However I'm not familiar with the code (for instance what is slot_id >>> is for, who uses it, should it always be 0 on resume?) but based on >>> the log and what you wrote I guess this sounds like a good point: >> >> >> xhci uses slot_id to identify different usb devices connected to it. >> xHC hw gives each enabled attached usb device a slot_id. >> When usb core asks xhci host to do something to a device xhci driver knows >> which device based on udev->slot_id >> >> when xhci controller is reset, all xhci slots are disabled and freed, but >> usb core still has udev->slot_id pointers set. >> >> In normal resume case the xHC controller is not reset, but if something >> goes wrong, >> or power is cut from xHC during suspend then we recover by resetting xHC >> at resume. >> >> I'll try to write some quick testpatches that: >> - removes LPM and LTM disabling from usb_reset_and_verify_device >> - zeroes udev->slot_id when slot is disabled and freed in xhci >> - forces a disable/enable port after port reset failed a few times. >> > > A series for testing can be found at: > > git://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git > port-disable-test > > https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=port-disable-test > > Based on 4.15 > Can you try it out? > > > -Mathias > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Gentoo Linux Bug 612702 (NEC USB3 PCI cards and storage devices)
Hi. The bug-wrangler of bug 612702 asked me to forward the following information to you (attachement). [0.00] Linux version 4.15.2-gentoo (root@i7) (gcc version 6.4.0 (Gentoo 6.4.0 p1.1)) #1 SMP Thu Feb 8 16:56:47 CET 2018 [0.00] Command line: BOOT_IMAGE=/kernel-genkernel-x86_64-4.15.2-gentoo root=UUID=953f200f-a3e3-4153-bf86-e1b2c2f95374 ro quiet splash [0.00] x86/fpu: x87 FPU will use FXSAVE [0.00] e820: BIOS-provided physical RAM map: [0.00] BIOS-e820: [mem 0x-0x0009bbff] usable [0.00] BIOS-e820: [mem 0x0009bc00-0x0009] reserved [0.00] BIOS-e820: [mem 0x000e4000-0x000f] reserved [0.00] BIOS-e820: [mem 0x0010-0xdfe6] usable [0.00] BIOS-e820: [mem 0xdfe7-0xdfe87fff] ACPI data [0.00] BIOS-e820: [mem 0xdfe88000-0xdfedbfff] ACPI NVS [0.00] BIOS-e820: [mem 0xdfedc000-0xdfff] reserved [0.00] BIOS-e820: [mem 0xfee0-0xfee00fff] reserved [0.00] BIOS-e820: [mem 0xffe0-0x] reserved [0.00] BIOS-e820: [mem 0x0001-0x00021fff] usable [0.00] NX (Execute Disable) protection: active [0.00] random: fast init done [0.00] SMBIOS 2.6 present. [0.00] DMI: System manufacturer System Product Name/P7P55D, BIOS 2101 10/20/2011 [0.00] e820: update [mem 0x-0x0fff] usable ==> reserved [0.00] e820: remove [mem 0x000a-0x000f] usable [0.00] e820: last_pfn = 0x22 max_arch_pfn = 0x4 [0.00] MTRR default type: uncachable [0.00] MTRR fixed ranges enabled: [0.00] 0-9 write-back [0.00] A-B uncachable [0.00] C-C write-protect [0.00] D-D uncachable [0.00] E-E7FFF write-through [0.00] E8000-F write-protect [0.00] MTRR variable ranges enabled: [0.00] 0 base 0 mask E write-back [0.00] 1 base 2 mask FE000 write-back [0.00] 2 base 0E000 mask FE000 uncachable [0.00] 3 disabled [0.00] 4 disabled [0.00] 5 disabled [0.00] 6 disabled [0.00] 7 disabled [0.00] x86/PAT: Configuration [0-7]: WB WC UC- UC WB WP UC- WT [0.00] e820: update [mem 0xe000-0x] usable ==> reserved [0.00] e820: last_pfn = 0xdfe70 max_arch_pfn = 0x4 [0.00] found SMP MP-table at [mem 0x000ff780-0x000ff78f] mapped at [ (ptrval)] [0.00] Base memory trampoline at [(ptrval)] 95000 size 24576 [0.00] BRK [0x86955000, 0x86955fff] PGTABLE [0.00] BRK [0x86956000, 0x86956fff] PGTABLE [0.00] BRK [0x86957000, 0x86957fff] PGTABLE [0.00] BRK [0x86958000, 0x86958fff] PGTABLE [0.00] BRK [0x86959000, 0x86959fff] PGTABLE [0.00] BRK [0x8695a000, 0x8695afff] PGTABLE [0.00] BRK [0x8695b000, 0x8695bfff] PGTABLE [0.00] BRK [0x8695c000, 0x8695cfff] PGTABLE [0.00] BRK [0x8695d000, 0x8695dfff] PGTABLE [0.00] RAMDISK: [mem 0x37267000-0x3792afff] [0.00] ACPI: Early table checksum verification disabled [0.00] ACPI: RSDP 0x000FB970 24 (v02 ACPIAM) [0.00] ACPI: XSDT 0xDFE70100 6C (v01 102011 XSDT1457 20111020 MSFT 0097) [0.00] ACPI: FACP 0xDFE70290 F4 (v03 102011 FACP1457 20111020 MSFT 0097) [0.00] ACPI: DSDT 0xDFE704A0 00EF4D (v01 A1326 A1326001 0001 INTL 20060113) [0.00] ACPI: FACS 0xDFE88000 40 [0.00] ACPI: FACS 0xDFE88000 40 [0.00] ACPI: APIC 0xDFE70390 CC (v01 102011 APIC1457 20111020 MSFT 0097) [0.00] ACPI: MCFG 0xDFE70460 3C (v01 102011 OEMMCFG 20111020 MSFT 0097) [0.00] ACPI: OEMB 0xDFE88040 72 (v01 102011 OEMB1457 20111020 MSFT 0097) [0.00] ACPI: HPET 0xDFE7F3F0 38 (v01 102011 OEMHPET 20111020 MSFT 0097) [0.00] ACPI: DMAR 0xDFE880C0 90 (v01 AMIOEMDMAR 0001 MSFT 0097) [0.00] ACPI: ASPT 0xDFE7F690 34 (v06 102011 PerfTune 20111020 MSFT 0097) [0.00] ACPI: OSFR 0xDFE7F6D0 B0 (v01 102011 OEMOSFR 20111020 MSFT 0097) [0.00] ACPI: SSDT 0xDFE8AC00 000363 (v01 DpgPmm CpuPm 0012 INTL 20060113) [0.00] ACPI: Local APIC address 0xfee0 [0.00] tsc: Fast TSC calibration using PIT [0.00] Zone ranges: [0.00] DMA [mem 0x1000-0x00ff] [0.00] DMA32[mem 0x0100-0x] [0.00] Normal [mem 0x0001-0x00021fff] [0.00] Movable zone start for each
Re: [PATCH v2] staging: typec: handle vendor defined part and modify drp toggling flow
On 02/14/2018 04:45 AM, ShuFanLee wrote: From: ShuFanLee Handle vendor defined behavior in tcpci_init, tcpci_set_vconn and export tcpci_irq. More operations can be extended in tcpci_data if needed. According to TCPCI specification, 4.4.5.2 ROLE_CONTROL, TCPC shall not start DRP toggling until subsequently the TCPM writes to the COMMAND register to start DRP toggling. DRP toggling flow is chagned as following: - Write DRP = 0 & Rd/Rd - Write DRP = 1 - Set LOOK4CONNECTION command Signed-off-by: ShuFanLee --- drivers/staging/typec/tcpci.c | 111 ++ drivers/staging/typec/tcpci.h | 13 + 2 files changed, 103 insertions(+), 21 deletions(-) diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 9bd4412..461fbd48 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -21,7 +21,6 @@ struct tcpci { struct device *dev; - struct i2c_client *client; struct tcpm_port *port; @@ -30,6 +29,7 @@ struct tcpci { bool controls_vbus; struct tcpc_dev tcpc; + struct tcpci_data *data; }; static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc) @@ -98,8 +98,10 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, enum typec_cc_status cc) { + int ret; struct tcpci *tcpci = tcpc_to_tcpci(tcpc); - unsigned int reg = TCPC_ROLE_CTRL_DRP; + unsigned int reg = (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT) | + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT); switch (cc) { default: @@ -116,8 +118,19 @@ static int tcpci_start_drp_toggling(struct tcpc_dev *tcpc, TCPC_ROLE_CTRL_RP_VAL_SHIFT); break; } - - return regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + usleep_range(500, 1000); + reg |= TCPC_ROLE_CTRL_DRP; + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + ret = regmap_write(tcpci->regmap, TCPC_COMMAND, + TCPC_CMD_LOOK4CONNECTION); + if (ret < 0) + return ret; + return 0; } static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink) @@ -178,6 +191,16 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable) struct tcpci *tcpci = tcpc_to_tcpci(tcpc); int ret; + /* Handle vendor set vconn */ + if (tcpci->data) { + if (tcpci->data->set_vconn) { + ret = tcpci->data->set_vconn(tcpci, tcpci->data, +enable); + if (ret < 0) + return ret; + } + } + ret = regmap_write(tcpci->regmap, TCPC_POWER_CTRL, enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0); if (ret < 0) @@ -323,6 +346,15 @@ static int tcpci_init(struct tcpc_dev *tcpc) if (time_after(jiffies, timeout)) return -ETIMEDOUT; + /* Handle vendor init */ + if (tcpci->data) { + if (tcpci->data->init) { + ret = tcpci->data->init(tcpci, tcpci->data); + if (ret < 0) + return ret; + } + } + /* Clear all events */ ret = tcpci_write16(tcpci, TCPC_ALERT, 0x); if (ret < 0) @@ -344,9 +376,16 @@ static int tcpci_init(struct tcpc_dev *tcpc) return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg); } -static irqreturn_t tcpci_irq(int irq, void *dev_id) +static irqreturn_t _tcpci_irq(int irq, void *dev_id) { struct tcpci *tcpci = dev_id; + + tcpci_irq(tcpci); + return IRQ_HANDLED; This should probably be return tcpci_irq(tcpci); +} + +int tcpci_irq(struct tcpci *tcpci) and this should be irqreturn_t tcpci_irq(struct tcpci *tcpci) Otherwise it doesn't add value to have tcpci_irq() return anything. Alternative would be to make it void tcpci_irq(struct tcpci *tcpci) if it will always only return IRQ_HANDLED. Guenter +{ u16 status; tcpci_read16(tcpci, TCPC_ALERT, &status); @@ -412,6 +451,7 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id) return IRQ_HANDLED; } +EXPORT_SYMBOL_GPL(tcpci_irq); static const struct regmap_config tcpci_regmap_config = { .reg_bits = 8, @@ -435,22 +475,18 @@ static int tcpci_parse_config(struct tcpci *tcpci) return 0; } -static int tcpci_probe(struct i2c_client *client, - const struct i2c_device_id *i2c_id) +struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_da
Re: [PATCH v2] staging: typec: handle vendor defined part and modify drp toggling flow
On Wed, Feb 14, 2018 at 10:43:45PM +0800, 李書帆 wrote: > Hi Gerg, > > > What changed from v1? > > The diff between v1 and v2 is as following: You need to explain what changed below the --- line, as is described in Documentation/SubmittingPatches. Please fix that up, and the text for your name, when you resend version 3 of this patch. thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Gentoo Linux Bug 612702 (NEC USB3 PCI cards and storage devices)
On Wed, Feb 14, 2018 at 03:43:54PM +0100, Stefan Kalis wrote: > Hi. The bug-wrangler of bug 612702 asked me to forward the following > information to you (attachement). > Why? What exactly is the problem here? You need to give us a hint :) thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 11/14] USB: host: sl811: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Signed-off-by: Andy Shevchenko --- drivers/usb/host/sl811-hcd.c | 17 +++-- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index fa88a903fa2e..806148697ee8 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1381,7 +1381,7 @@ static void dump_irq(struct seq_file *s, char *label, u8 mask) (mask & SL11H_INTMASK_DP) ? " dp" : ""); } -static int sl811h_show(struct seq_file *s, void *unused) +static int sl811h_debug_show(struct seq_file *s, void *unused) { struct sl811*sl811 = s->private; struct sl811h_ep*ep; @@ -1491,25 +1491,14 @@ static int sl811h_show(struct seq_file *s, void *unused) return 0; } - -static int sl811h_open(struct inode *inode, struct file *file) -{ - return single_open(file, sl811h_show, inode->i_private); -} - -static const struct file_operations debug_ops = { - .open = sl811h_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(sl811h_debug); /* expect just one sl811 per system */ static void create_debug_file(struct sl811 *sl811) { sl811->debug_file = debugfs_create_file("sl811h", S_IRUGO, usb_debug_root, sl811, - &debug_ops); + &sl811h_debug_ops); } static void remove_debug_file(struct sl811 *sl811) -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 10/14] USB: host: isp116x: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Olav Kongas Signed-off-by: Andy Shevchenko --- drivers/usb/host/isp116x-hcd.c | 15 ++- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 5f9234b9cf7b..4602ed801f0a 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1168,7 +1168,7 @@ static void dump_int(struct seq_file *s, char *label, u32 mask) mask & HCINT_SF ? " sof" : "", mask & HCINT_SO ? " so" : ""); } -static int isp116x_show_dbg(struct seq_file *s, void *unused) +static int isp116x_debug_show(struct seq_file *s, void *unused) { struct isp116x *isp116x = s->private; @@ -1196,18 +1196,7 @@ static int isp116x_show_dbg(struct seq_file *s, void *unused) return 0; } - -static int isp116x_open_seq(struct inode *inode, struct file *file) -{ - return single_open(file, isp116x_show_dbg, inode->i_private); -} - -static const struct file_operations isp116x_debug_fops = { - .open = isp116x_open_seq, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(isp116x_debug); static int create_debug_file(struct isp116x *isp116x) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 01/14] USB: chipidea: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Peter Chen Signed-off-by: Andy Shevchenko --- drivers/usb/chipidea/debug.c | 65 1 file changed, 5 insertions(+), 60 deletions(-) diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index c9e1a165ed82..ce648cb3ed94 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@ -45,18 +45,7 @@ static int ci_device_show(struct seq_file *s, void *data) return 0; } - -static int ci_device_open(struct inode *inode, struct file *file) -{ - return single_open(file, ci_device_show, inode->i_private); -} - -static const struct file_operations ci_device_fops = { - .open = ci_device_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ci_device); /** * ci_port_test_show: reads port test mode @@ -156,18 +145,7 @@ static int ci_qheads_show(struct seq_file *s, void *data) return 0; } - -static int ci_qheads_open(struct inode *inode, struct file *file) -{ - return single_open(file, ci_qheads_show, inode->i_private); -} - -static const struct file_operations ci_qheads_fops = { - .open = ci_qheads_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ci_qheads); /** * ci_requests_show: DMA contents of all requests currently queued (all endpts) @@ -204,18 +182,7 @@ static int ci_requests_show(struct seq_file *s, void *data) return 0; } - -static int ci_requests_open(struct inode *inode, struct file *file) -{ - return single_open(file, ci_requests_show, inode->i_private); -} - -static const struct file_operations ci_requests_fops = { - .open = ci_requests_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ci_requests); static int ci_otg_show(struct seq_file *s, void *unused) { @@ -278,18 +245,7 @@ static int ci_otg_show(struct seq_file *s, void *unused) return 0; } - -static int ci_otg_open(struct inode *inode, struct file *file) -{ - return single_open(file, ci_otg_show, inode->i_private); -} - -static const struct file_operations ci_otg_fops = { - .open = ci_otg_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ci_otg); static int ci_role_show(struct seq_file *s, void *data) { @@ -376,18 +332,7 @@ static int ci_registers_show(struct seq_file *s, void *unused) return 0; } - -static int ci_registers_open(struct inode *inode, struct file *file) -{ - return single_open(file, ci_registers_show, inode->i_private); -} - -static const struct file_operations ci_registers_fops = { - .open = ci_registers_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ci_registers); /** * dbg_create_files: initializes the attribute interface -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 06/14] USB: gadget: pxa25x: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Signed-off-by: Andy Shevchenko --- drivers/usb/gadget/udc/pxa25x_udc.c | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index 0e3f5faa000e..d4be53559f2e 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1233,8 +1233,7 @@ static const struct usb_gadget_ops pxa25x_udc_ops = { #ifdef CONFIG_USB_GADGET_DEBUG_FS -static int -udc_seq_show(struct seq_file *m, void *_d) +static int udc_debug_show(struct seq_file *m, void *_d) { struct pxa25x_udc *dev = m->private; unsigned long flags; @@ -1335,25 +1334,12 @@ udc_seq_show(struct seq_file *m, void *_d) local_irq_restore(flags); return 0; } - -static int -udc_debugfs_open(struct inode *inode, struct file *file) -{ - return single_open(file, udc_seq_show, inode->i_private); -} - -static const struct file_operations debug_fops = { - .open = udc_debugfs_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_ATTRIBUTE(udc_debug); #define create_debug_files(dev) \ do { \ dev->debugfs_udc = debugfs_create_file(dev->gadget.name, \ - S_IRUGO, NULL, dev, &debug_fops); \ + S_IRUGO, NULL, dev, &udc_debug_fops); \ } while (0) #define remove_debug_files(dev) debugfs_remove(dev->debugfs_udc) -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 12/14] USB: host: whci: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Signed-off-by: Andy Shevchenko --- drivers/usb/host/whci/debug.c | 48 ++- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/drivers/usb/host/whci/debug.c b/drivers/usb/host/whci/debug.c index f154e5791bfd..8ddfe3f1f693 100644 --- a/drivers/usb/host/whci/debug.c +++ b/drivers/usb/host/whci/debug.c @@ -72,7 +72,7 @@ static void qset_print(struct seq_file *s, struct whc_qset *qset) } } -static int di_print(struct seq_file *s, void *p) +static int di_show(struct seq_file *s, void *p) { struct whc *whc = s->private; int d; @@ -91,8 +91,9 @@ static int di_print(struct seq_file *s, void *p) } return 0; } +DEFINE_SHOW_ATTRIBUTE(di); -static int asl_print(struct seq_file *s, void *p) +static int asl_show(struct seq_file *s, void *p) { struct whc *whc = s->private; struct whc_qset *qset; @@ -103,8 +104,9 @@ static int asl_print(struct seq_file *s, void *p) return 0; } +DEFINE_SHOW_ATTRIBUTE(asl); -static int pzl_print(struct seq_file *s, void *p) +static int pzl_show(struct seq_file *s, void *p) { struct whc *whc = s->private; struct whc_qset *qset; @@ -118,45 +120,7 @@ static int pzl_print(struct seq_file *s, void *p) } return 0; } - -static int di_open(struct inode *inode, struct file *file) -{ - return single_open(file, di_print, inode->i_private); -} - -static int asl_open(struct inode *inode, struct file *file) -{ - return single_open(file, asl_print, inode->i_private); -} - -static int pzl_open(struct inode *inode, struct file *file) -{ - return single_open(file, pzl_print, inode->i_private); -} - -static const struct file_operations di_fops = { - .open= di_open, - .read= seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; - -static const struct file_operations asl_fops = { - .open= asl_open, - .read= seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; - -static const struct file_operations pzl_fops = { - .open= pzl_open, - .read= seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_ATTRIBUTE(pzl); void whc_dbg_init(struct whc *whc) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 02/14] USB: dwc2: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: John Youn Signed-off-by: Andy Shevchenko --- drivers/usb/dwc2/debugfs.c | 84 -- 1 file changed, 6 insertions(+), 78 deletions(-) diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index f4650a88be78..5e0d7f2bd2af 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -170,19 +170,7 @@ static int state_show(struct seq_file *seq, void *v) return 0; } - -static int state_open(struct inode *inode, struct file *file) -{ - return single_open(file, state_show, inode->i_private); -} - -static const struct file_operations state_fops = { - .owner = THIS_MODULE, - .open = state_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(state); /** * fifo_show - debugfs: show the fifo information @@ -219,19 +207,7 @@ static int fifo_show(struct seq_file *seq, void *v) return 0; } - -static int fifo_open(struct inode *inode, struct file *file) -{ - return single_open(file, fifo_show, inode->i_private); -} - -static const struct file_operations fifo_fops = { - .owner = THIS_MODULE, - .open = fifo_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(fifo); static const char *decode_direction(int is_in) { @@ -303,19 +279,7 @@ static int ep_show(struct seq_file *seq, void *v) return 0; } - -static int ep_open(struct inode *inode, struct file *file) -{ - return single_open(file, ep_show, inode->i_private); -} - -static const struct file_operations ep_fops = { - .owner = THIS_MODULE, - .open = ep_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ep); /** * dwc2_hsotg_create_debug - create debugfs directory and files @@ -770,19 +734,7 @@ static int params_show(struct seq_file *seq, void *v) return 0; } - -static int params_open(struct inode *inode, struct file *file) -{ - return single_open(file, params_show, inode->i_private); -} - -static const struct file_operations params_fops = { - .owner = THIS_MODULE, - .open = params_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(params); static int hw_params_show(struct seq_file *seq, void *v) { @@ -817,19 +769,7 @@ static int hw_params_show(struct seq_file *seq, void *v) return 0; } - -static int hw_params_open(struct inode *inode, struct file *file) -{ - return single_open(file, hw_params_show, inode->i_private); -} - -static const struct file_operations hw_params_fops = { - .owner = THIS_MODULE, - .open = hw_params_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(hw_params); static int dr_mode_show(struct seq_file *seq, void *v) { @@ -840,19 +780,7 @@ static int dr_mode_show(struct seq_file *seq, void *v) seq_printf(seq, "%s\n", dr_mode); return 0; } - -static int dr_mode_open(struct inode *inode, struct file *file) -{ - return single_open(file, dr_mode_show, inode->i_private); -} - -static const struct file_operations dr_mode_fops = { - .owner = THIS_MODULE, - .open = dr_mode_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(dr_mode); int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 13/14] USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Heikki Krogerus Cc: Guenter Roeck Signed-off-by: Andy Shevchenko --- drivers/usb/typec/fusb302/fusb302.c | 17 +++-- drivers/usb/typec/tcpm.c| 17 +++-- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 9ce4756adad6..da179aaf789e 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -199,7 +199,7 @@ static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...) va_end(args); } -static int fusb302_seq_show(struct seq_file *s, void *v) +static int fusb302_debug_show(struct seq_file *s, void *v) { struct fusb302_chip *chip = (struct fusb302_chip *)s->private; int tail; @@ -216,18 +216,7 @@ static int fusb302_seq_show(struct seq_file *s, void *v) return 0; } - -static int fusb302_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, fusb302_seq_show, inode->i_private); -} - -static const struct file_operations fusb302_debug_operations = { - .open = fusb302_debug_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(fusb302_debug); static struct dentry *rootdir; @@ -242,7 +231,7 @@ static int fusb302_debugfs_init(struct fusb302_chip *chip) chip->dentry = debugfs_create_file(dev_name(chip->dev), S_IFREG | 0444, rootdir, - chip, &fusb302_debug_operations); + chip, &fusb302_debug_fops); return 0; } diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index f4d563ee7690..a163ba55b061 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -506,7 +506,7 @@ static void tcpm_log_source_caps(struct tcpm_port *port) } } -static int tcpm_seq_show(struct seq_file *s, void *v) +static int tcpm_debug_show(struct seq_file *s, void *v) { struct tcpm_port *port = (struct tcpm_port *)s->private; int tail; @@ -523,18 +523,7 @@ static int tcpm_seq_show(struct seq_file *s, void *v) return 0; } - -static int tcpm_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, tcpm_seq_show, inode->i_private); -} - -static const struct file_operations tcpm_debug_operations = { - .open = tcpm_debug_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(tcpm_debug); static struct dentry *rootdir; @@ -550,7 +539,7 @@ static int tcpm_debugfs_init(struct tcpm_port *port) port->dentry = debugfs_create_file(dev_name(port->dev), S_IFREG | 0444, rootdir, - port, &tcpm_debug_operations); + port, &tcpm_debug_fops); return 0; } -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 03/14] USB: musb: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Bin Liu Signed-off-by: Andy Shevchenko --- drivers/usb/musb/musb_debugfs.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 7cf5a1bbdaff..025b2c8630df 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c @@ -112,11 +112,7 @@ static int musb_regdump_show(struct seq_file *s, void *unused) pm_runtime_put_autosuspend(musb->controller); return 0; } - -static int musb_regdump_open(struct inode *inode, struct file *file) -{ - return single_open(file, musb_regdump_show, inode->i_private); -} +DEFINE_SHOW_ATTRIBUTE(musb_regdump); static int musb_test_mode_show(struct seq_file *s, void *unused) { @@ -161,13 +157,6 @@ static int musb_test_mode_show(struct seq_file *s, void *unused) return 0; } -static const struct file_operations musb_regdump_fops = { - .open = musb_regdump_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; - static int musb_test_mode_open(struct inode *inode, struct file *file) { return single_open(file, musb_test_mode_show, inode->i_private); -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 05/14] USB: gadget: gr: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Signed-off-by: Andy Shevchenko --- drivers/usb/gadget/udc/gr_udc.c | 17 ++--- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index b3fb1bbdb854..ca83c15d8ea4 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -179,8 +179,7 @@ static void gr_seq_ep_show(struct seq_file *seq, struct gr_ep *ep) seq_puts(seq, "\n"); } - -static int gr_seq_show(struct seq_file *seq, void *v) +static int gr_dfs_show(struct seq_file *seq, void *v) { struct gr_udc *dev = seq->private; u32 control = gr_read32(&dev->regs->control); @@ -203,19 +202,7 @@ static int gr_seq_show(struct seq_file *seq, void *v) return 0; } - -static int gr_dfs_open(struct inode *inode, struct file *file) -{ - return single_open(file, gr_seq_show, inode->i_private); -} - -static const struct file_operations gr_dfs_fops = { - .owner = THIS_MODULE, - .open = gr_dfs_open, - .read = seq_read, - .llseek = seq_lseek, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(gr_dfs); static void gr_dfs_create(struct gr_udc *dev) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 04/14] USB: gadget: bcm63xx: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Kevin Cernekee Cc: Florian Fainelli Cc: bcm-kernel-feedback-l...@broadcom.com Signed-off-by: Andy Shevchenko --- drivers/usb/gadget/udc/bcm63xx_udc.c | 33 - 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 465ccd1104de..3a8df8601074 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -2158,6 +2158,7 @@ static int bcm63xx_usbd_dbg_show(struct seq_file *s, void *p) return 0; } +DEFINE_SHOW_ATTRIBUTE(bcm63xx_usbd_dbg); /* * bcm63xx_iudma_dbg_show - Show IUDMA status and descriptors. @@ -2238,33 +2239,7 @@ static int bcm63xx_iudma_dbg_show(struct seq_file *s, void *p) return 0; } - -static int bcm63xx_usbd_dbg_open(struct inode *inode, struct file *file) -{ - return single_open(file, bcm63xx_usbd_dbg_show, inode->i_private); -} - -static int bcm63xx_iudma_dbg_open(struct inode *inode, struct file *file) -{ - return single_open(file, bcm63xx_iudma_dbg_show, inode->i_private); -} - -static const struct file_operations usbd_dbg_fops = { - .owner = THIS_MODULE, - .open = bcm63xx_usbd_dbg_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; - -static const struct file_operations iudma_dbg_fops = { - .owner = THIS_MODULE, - .open = bcm63xx_iudma_dbg_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; - +DEFINE_SHOW_ATTRIBUTE(bcm63xx_iudma_dbg); /** * bcm63xx_udc_init_debugfs - Create debugfs entries. @@ -2282,11 +2257,11 @@ static void bcm63xx_udc_init_debugfs(struct bcm63xx_udc *udc) goto err_root; usbd = debugfs_create_file("usbd", 0400, root, udc, - &usbd_dbg_fops); + &bcm63xx_usbd_dbg_fops); if (!usbd) goto err_usbd; iudma = debugfs_create_file("iudma", 0400, root, udc, - &iudma_dbg_fops); + &bcm63xx_iudma_dbg_fops); if (!iudma) goto err_iudma; -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 08/14] USB: host: fhci: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Signed-off-by: Andy Shevchenko --- drivers/usb/host/fhci-dbg.c | 26 ++ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/usb/host/fhci-dbg.c b/drivers/usb/host/fhci-dbg.c index fafa91189e45..ebf9bb219f75 100644 --- a/drivers/usb/host/fhci-dbg.c +++ b/drivers/usb/host/fhci-dbg.c @@ -55,6 +55,7 @@ static int fhci_dfs_regs_show(struct seq_file *s, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(fhci_dfs_regs); static int fhci_dfs_irq_stat_show(struct seq_file *s, void *v) { @@ -75,30 +76,7 @@ static int fhci_dfs_irq_stat_show(struct seq_file *s, void *v) return 0; } - -static int fhci_dfs_regs_open(struct inode *inode, struct file *file) -{ - return single_open(file, fhci_dfs_regs_show, inode->i_private); -} - -static int fhci_dfs_irq_stat_open(struct inode *inode, struct file *file) -{ - return single_open(file, fhci_dfs_irq_stat_show, inode->i_private); -} - -static const struct file_operations fhci_dfs_regs_fops = { - .open = fhci_dfs_regs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations fhci_dfs_irq_stat_fops = { - .open = fhci_dfs_irq_stat_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(fhci_dfs_irq_stat); void fhci_dfs_create(struct fhci_hcd *fhci) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 07/14] USB: gadget: pxa27x: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Signed-off-by: Andy Shevchenko --- drivers/usb/gadget/udc/pxa27x_udc.c | 42 +++-- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index fadcf2653c3d..a58242e901df 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -131,6 +131,7 @@ static int state_dbg_show(struct seq_file *s, void *p) return 0; } +DEFINE_SHOW_ATTRIBUTE(state_dbg); static int queues_dbg_show(struct seq_file *s, void *p) { @@ -163,6 +164,7 @@ static int queues_dbg_show(struct seq_file *s, void *p) return 0; } +DEFINE_SHOW_ATTRIBUTE(queues_dbg); static int eps_dbg_show(struct seq_file *s, void *p) { @@ -199,45 +201,7 @@ static int eps_dbg_show(struct seq_file *s, void *p) return 0; } - -static int eps_dbg_open(struct inode *inode, struct file *file) -{ - return single_open(file, eps_dbg_show, inode->i_private); -} - -static int queues_dbg_open(struct inode *inode, struct file *file) -{ - return single_open(file, queues_dbg_show, inode->i_private); -} - -static int state_dbg_open(struct inode *inode, struct file *file) -{ - return single_open(file, state_dbg_show, inode->i_private); -} - -static const struct file_operations state_dbg_fops = { - .owner = THIS_MODULE, - .open = state_dbg_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; - -static const struct file_operations queues_dbg_fops = { - .owner = THIS_MODULE, - .open = queues_dbg_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; - -static const struct file_operations eps_dbg_fops = { - .owner = THIS_MODULE, - .open = eps_dbg_open, - .llseek = seq_lseek, - .read = seq_read, - .release= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(eps_dbg); static void pxa_init_debugfs(struct pxa_udc *udc) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 14/14] uwb: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Signed-off-by: Andy Shevchenko --- drivers/uwb/uwb-debug.c | 32 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/uwb/uwb-debug.c b/drivers/uwb/uwb-debug.c index 991374b13571..f1622bae13be 100644 --- a/drivers/uwb/uwb-debug.c +++ b/drivers/uwb/uwb-debug.c @@ -206,7 +206,7 @@ static const struct file_operations command_fops = { .owner = THIS_MODULE, }; -static int reservations_print(struct seq_file *s, void *p) +static int reservations_show(struct seq_file *s, void *p) { struct uwb_rc *rc = s->private; struct uwb_rsv *rsv; @@ -240,21 +240,9 @@ static int reservations_print(struct seq_file *s, void *p) return 0; } +DEFINE_SHOW_ATTRIBUTE(reservations); -static int reservations_open(struct inode *inode, struct file *file) -{ - return single_open(file, reservations_print, inode->i_private); -} - -static const struct file_operations reservations_fops = { - .open= reservations_open, - .read= seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; - -static int drp_avail_print(struct seq_file *s, void *p) +static int drp_avail_show(struct seq_file *s, void *p) { struct uwb_rc *rc = s->private; @@ -264,19 +252,7 @@ static int drp_avail_print(struct seq_file *s, void *p) return 0; } - -static int drp_avail_open(struct inode *inode, struct file *file) -{ - return single_open(file, drp_avail_print, inode->i_private); -} - -static const struct file_operations drp_avail_fops = { - .open= drp_avail_open, - .read= seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_ATTRIBUTE(drp_avail); static void uwb_dbg_channel_changed(struct uwb_pal *pal, int channel) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 09/14] USB: host: imx21: Re-use DEFINE_SHOW_ATTRIBUTE() macro
...instead of open coding file operations followed by custom ->open() callbacks per each attribute. Signed-off-by: Andy Shevchenko --- drivers/usb/host/imx21-dbg.c | 65 1 file changed, 5 insertions(+), 60 deletions(-) diff --git a/drivers/usb/host/imx21-dbg.c b/drivers/usb/host/imx21-dbg.c index b964f9a51d87..a213ed6f07b5 100644 --- a/drivers/usb/host/imx21-dbg.c +++ b/drivers/usb/host/imx21-dbg.c @@ -245,6 +245,7 @@ static int debug_status_show(struct seq_file *s, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(debug_status); static int debug_dmem_show(struct seq_file *s, void *v) { @@ -266,6 +267,7 @@ static int debug_dmem_show(struct seq_file *s, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(debug_dmem); static int debug_etd_show(struct seq_file *s, void *v) { @@ -334,6 +336,7 @@ static int debug_etd_show(struct seq_file *s, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(debug_etd); static void debug_statistics_show_one(struct seq_file *s, const char *name, struct debug_stats *stats) @@ -368,6 +371,7 @@ static int debug_statistics_show(struct seq_file *s, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(debug_statistics); static void debug_isoc_show_one(struct seq_file *s, const char *name, int index,struct debug_isoc_trace *trace) @@ -409,66 +413,7 @@ static int debug_isoc_show(struct seq_file *s, void *v) return 0; } - -static int debug_status_open(struct inode *inode, struct file *file) -{ - return single_open(file, debug_status_show, inode->i_private); -} - -static int debug_dmem_open(struct inode *inode, struct file *file) -{ - return single_open(file, debug_dmem_show, inode->i_private); -} - -static int debug_etd_open(struct inode *inode, struct file *file) -{ - return single_open(file, debug_etd_show, inode->i_private); -} - -static int debug_statistics_open(struct inode *inode, struct file *file) -{ - return single_open(file, debug_statistics_show, inode->i_private); -} - -static int debug_isoc_open(struct inode *inode, struct file *file) -{ - return single_open(file, debug_isoc_show, inode->i_private); -} - -static const struct file_operations debug_status_fops = { - .open = debug_status_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations debug_dmem_fops = { - .open = debug_dmem_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations debug_etd_fops = { - .open = debug_etd_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations debug_statistics_fops = { - .open = debug_statistics_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations debug_isoc_fops = { - .open = debug_isoc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(debug_isoc); static void create_debug_files(struct imx21 *imx21) { -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] usb: host: xhci-plat: Fix clock resource by adding a register clock
On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory. The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint. The binding documentation is updating accordingly. Signed-off-by: Gregory CLEMENT --- Documentation/devicetree/bindings/usb/usb-xhci.txt | 5 +++- drivers/usb/host/xhci-plat.c | 33 ++ drivers/usb/host/xhci.h| 3 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index e2ea59bbca93..e4b14511f4f8 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -27,7 +27,10 @@ Required properties: - interrupts: one XHCI interrupt should be described here. Optional properties: - - clocks: reference to a clock + - clocks: reference to the clocks + - clock-names: mandatory if there is a second clock, in this case +the name must be "core" for the first clock and "reg" for the +second one - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM - usb3-lpm-capable: determines if platform is USB3 LPM capable - quirk-broken-port-ped: set if the controller has broken port disable mechanism diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 79afaac57ef6..fd0c399013a2 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev) struct resource *res; struct usb_hcd *hcd; struct clk *clk; + struct clk *reg_clk; int ret; int irq; @@ -226,17 +227,27 @@ static int xhci_plat_probe(struct platform_device *pdev) hcd->rsrc_len = resource_size(res); /* -* Not all platforms have a clk so it is not an error if the -* clock does not exists. +* Not all platforms have clks so it is not an error if the +* clock do not exist. */ + reg_clk = devm_clk_get(&pdev->dev, "reg"); + if (!IS_ERR(reg_clk)) { + ret = clk_prepare_enable(reg_clk); + if (ret) + goto put_hcd; + } else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto put_hcd; + } + clk = devm_clk_get(&pdev->dev, NULL); if (!IS_ERR(clk)) { ret = clk_prepare_enable(clk); if (ret) - goto put_hcd; + goto disable_reg_clk; } else if (PTR_ERR(clk) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; - goto put_hcd; + goto disable_reg_clk; } xhci = hcd_to_xhci(hcd); @@ -252,6 +263,7 @@ static int xhci_plat_probe(struct platform_device *pdev) device_wakeup_enable(hcd->self.controller); xhci->clk = clk; + xhci->reg_clk = reg_clk; xhci->main_hcd = hcd; xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, dev_name(&pdev->dev), hcd); @@ -321,6 +333,9 @@ static int xhci_plat_probe(struct platform_device *pdev) disable_clk: clk_disable_unprepare(clk); +disable_reg_clk: + clk_disable_unprepare(reg_clk); + put_hcd: usb_put_hcd(hcd); @@ -336,6 +351,7 @@ static int xhci_plat_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct clk *clk = xhci->clk; + struct clk *reg_clk = xhci->reg_clk; xhci->xhc_state |= XHCI_STATE_REMOVING; @@ -346,6 +362,7 @@ static int xhci_plat_remove(struct platform_device *dev) usb_put_hcd(xhci->shared_hcd); clk_disable_unprepare(clk); + clk_disable_unprepare(reg_clk); usb_put_hcd(hcd); pm_runtime_set_suspended(&dev->dev); @@ -370,8 +387,10 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) */ ret = xhci_suspend(xhci, device_may_wakeup(dev)); - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) + if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) { clk_disable_unprepare(xhci->clk); + clk_disable_unprepare(xhci->reg_clk); + } return ret; } @@ -382,8 +401,10 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) + if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) { + clk_prepare_
[PATCH 1/2] usb: host: xhci-plat: Remove useless test before clk_disable_unprepare
clk_disable_unprepare() already checks that the clock pointer is valid. No need to test it before calling it. Signed-off-by: Gregory CLEMENT --- drivers/usb/host/xhci-plat.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 6f038306c14d..79afaac57ef6 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -319,8 +319,7 @@ static int xhci_plat_probe(struct platform_device *pdev) usb_put_hcd(xhci->shared_hcd); disable_clk: - if (!IS_ERR(clk)) - clk_disable_unprepare(clk); + clk_disable_unprepare(clk); put_hcd: usb_put_hcd(hcd); @@ -346,8 +345,7 @@ static int xhci_plat_remove(struct platform_device *dev) usb_remove_hcd(hcd); usb_put_hcd(xhci->shared_hcd); - if (!IS_ERR(clk)) - clk_disable_unprepare(clk); + clk_disable_unprepare(clk); usb_put_hcd(hcd); pm_runtime_set_suspended(&dev->dev); -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] Allow xhci-plat using a second clock
Hello, The purpose of this series is to allow xhci-plat using a second clock. It is needed on the Armada 7K/8K but could be used by other SoCs. The first patch is just a fix found while I was working on this feature. Thanks, Gregory Gregory CLEMENT (2): usb: host: xhci-plat: Remove useless test before clk_disable_unprepare usb: host: xhci-plat: Fix clock resource by adding a register clock Documentation/devicetree/bindings/usb/usb-xhci.txt | 5 ++- drivers/usb/host/xhci-plat.c | 39 -- drivers/usb/host/xhci.h| 3 +- 3 files changed, 35 insertions(+), 12 deletions(-) -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] usb: xhci: tegra: Add support for managing powergates
The Tegra XHCI controller requires that the XUSBA (for superspeed) and XUSBC (for host) power-domains are enabled. Commit 8df127456f29 ("soc/tegra: pmc: Enable XUSB partitions on boot") was added to force on these power-domains if the XHCI driver is enabled while proper power-domain support is added, to ensure the device did not hang on boot. However, rather than forcing on these power-domains in the PMC driver we can use the legacy Tegra powergate APIs to turn on these power-domains during the probe of the Tegra XHCI driver. In the near future we plan to move the Tegra XHCI driver to use the generic PM domain framework for power-domains and so to prepare for this only use the legacy Tegra powergate API if there is not PM domain associated with device (ie. dev.pm_domain is NULL). Please note that in the future the superspeed and host resets will be handled by the generic PM domain provider and so these are only these are only needed in the case where there is no generic PM domain. Signed-off-by: Jon Hunter --- drivers/usb/host/xhci-tegra.c | 68 +++ 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 42aa67858b53..f69e5edfd604 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "xhci.h" @@ -931,20 +932,6 @@ static int tegra_xusb_probe(struct platform_device *pdev) if (IS_ERR(tegra->padctl)) return PTR_ERR(tegra->padctl); - tegra->host_rst = devm_reset_control_get(&pdev->dev, "xusb_host"); - if (IS_ERR(tegra->host_rst)) { - err = PTR_ERR(tegra->host_rst); - dev_err(&pdev->dev, "failed to get xusb_host reset: %d\n", err); - goto put_padctl; - } - - tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss"); - if (IS_ERR(tegra->ss_rst)) { - err = PTR_ERR(tegra->ss_rst); - dev_err(&pdev->dev, "failed to get xusb_ss reset: %d\n", err); - goto put_padctl; - } - tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host"); if (IS_ERR(tegra->host_clk)) { err = PTR_ERR(tegra->host_clk); @@ -1008,11 +995,48 @@ static int tegra_xusb_probe(struct platform_device *pdev) goto put_padctl; } + if (!pdev->dev.pm_domain) { + tegra->host_rst = devm_reset_control_get(&pdev->dev, +"xusb_host"); + if (IS_ERR(tegra->host_rst)) { + err = PTR_ERR(tegra->host_rst); + dev_err(&pdev->dev, + "failed to get xusb_host reset: %d\n", err); + goto put_padctl; + } + + tegra->ss_rst = devm_reset_control_get(&pdev->dev, "xusb_ss"); + if (IS_ERR(tegra->ss_rst)) { + err = PTR_ERR(tegra->ss_rst); + dev_err(&pdev->dev, "failed to get xusb_ss reset: %d\n", + err); + goto put_padctl; + } + + err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_XUSBA, + tegra->ss_clk, + tegra->ss_rst); + if (err) { + dev_err(&pdev->dev, + "failed to enable XUSBA domain: %d\n", err); + goto put_padctl; + } + + err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_XUSBC, + tegra->host_clk, + tegra->host_rst); + if (err) { + dev_err(&pdev->dev, + "failed to enable XUSBC domain: %d\n", err); + goto disable_xusba; + } + } + tegra->supplies = devm_kcalloc(&pdev->dev, tegra->soc->num_supplies, sizeof(*tegra->supplies), GFP_KERNEL); if (!tegra->supplies) { err = -ENOMEM; - goto put_padctl; + goto disable_xusbc; } for (i = 0; i < tegra->soc->num_supplies; i++) @@ -1022,7 +1046,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) tegra->supplies); if (err) { dev_err(&pdev->dev, "failed to get regulators: %d\n", err); - goto put_padctl; + goto disable_xusbc; } for (i = 0; i < tegra->soc->num_types; i++) @@ -1032,7 +1056,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) sizeof(*tegra->phys), GFP_KE
[PATCH 1/3] usb: xhci: tegra: Prepare for adding runtime PM support
When adding runtime PM support to the Tegra XHCI driver, it is desirable to move the function calls to enable the clocks, regulators and PHY from the tegra_xusb_probe into the runtime PM handlers. Currently, the clocks, regulators and PHY are all enabled before we call usb_create_hcd() in tegra_xusb_probe(), however, we cannot call pm_runtime_get_sync() at this point because the platform device data is not yet initialised. Fortunately, the function usb_create_hcd() can be called before we enable the clocks, regulators and PHY and so prepare for adding runtime PM support, by moving the call to usb_create_hcd() before we enable the hardware. Signed-off-by: Jon Hunter --- drivers/usb/host/xhci-tegra.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 2c076ea80522..02b0b24faa58 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1054,10 +1054,23 @@ static int tegra_xusb_probe(struct platform_device *pdev) } } + tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, + dev_name(&pdev->dev)); + if (!tegra->hcd) { + err = -ENOMEM; + goto put_padctl; + } + + /* +* This must happen after usb_create_hcd(), because usb_create_hcd() +* will overwrite the drvdata of the device with the hcd it creates. +*/ + platform_set_drvdata(pdev, tegra); + err = tegra_xusb_clk_enable(tegra); if (err) { dev_err(&pdev->dev, "failed to enable clocks: %d\n", err); - goto put_padctl; + goto put_usb2; } err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); @@ -1080,19 +1093,6 @@ static int tegra_xusb_probe(struct platform_device *pdev) goto disable_phy; } - tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, - dev_name(&pdev->dev)); - if (!tegra->hcd) { - err = -ENOMEM; - goto disable_phy; - } - - /* -* This must happen after usb_create_hcd(), because usb_create_hcd() -* will overwrite the drvdata of the device with the hcd it creates. -*/ - platform_set_drvdata(pdev, tegra); - tegra->hcd->regs = tegra->regs; tegra->hcd->rsrc_start = regs->start; tegra->hcd->rsrc_len = resource_size(regs); @@ -1100,7 +1100,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED); if (err < 0) { dev_err(&pdev->dev, "failed to add USB HCD: %d\n", err); - goto put_usb2; + goto disable_phy; } device_wakeup_enable(tegra->hcd->self.controller); @@ -1155,14 +1155,14 @@ static int tegra_xusb_probe(struct platform_device *pdev) usb_put_hcd(xhci->shared_hcd); remove_usb2: usb_remove_hcd(tegra->hcd); -put_usb2: - usb_put_hcd(tegra->hcd); disable_phy: tegra_xusb_phy_disable(tegra); disable_regulator: regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); disable_clk: tegra_xusb_clk_disable(tegra); +put_usb2: + usb_put_hcd(tegra->hcd); put_padctl: tegra_xusb_padctl_put(tegra->padctl); return err; -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] usb: xhci: tegra: Add runtime PM support
Add runtime PM support to the Tegra XHCI driver and move the function calls to enable/disable the clocks, regulators and PHY into the runtime PM callbacks. Signed-off-by: Jon Hunter --- drivers/usb/host/xhci-tegra.c | 80 ++- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 02b0b24faa58..42aa67858b53 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1067,22 +1068,12 @@ static int tegra_xusb_probe(struct platform_device *pdev) */ platform_set_drvdata(pdev, tegra); - err = tegra_xusb_clk_enable(tegra); - if (err) { - dev_err(&pdev->dev, "failed to enable clocks: %d\n", err); - goto put_usb2; - } - - err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); - if (err) { - dev_err(&pdev->dev, "failed to enable regulators: %d\n", err); - goto disable_clk; - } + pm_runtime_enable(&pdev->dev); - err = tegra_xusb_phy_enable(tegra); + err = pm_runtime_get_sync(&pdev->dev); if (err < 0) { - dev_err(&pdev->dev, "failed to enable PHYs: %d\n", err); - goto disable_regulator; + dev_err(&pdev->dev, "failed to enable device: %d\n", err); + goto disable_rpm; } tegra_xusb_ipfs_config(tegra, regs); @@ -1090,7 +1081,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) err = tegra_xusb_load_firmware(tegra); if (err < 0) { dev_err(&pdev->dev, "failed to load firmware: %d\n", err); - goto disable_phy; + goto put_rpm; } tegra->hcd->regs = tegra->regs; @@ -1100,7 +1091,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED); if (err < 0) { dev_err(&pdev->dev, "failed to add USB HCD: %d\n", err); - goto disable_phy; + goto put_rpm; } device_wakeup_enable(tegra->hcd->self.controller); @@ -1155,13 +1146,10 @@ static int tegra_xusb_probe(struct platform_device *pdev) usb_put_hcd(xhci->shared_hcd); remove_usb2: usb_remove_hcd(tegra->hcd); -disable_phy: - tegra_xusb_phy_disable(tegra); -disable_regulator: - regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); -disable_clk: - tegra_xusb_clk_disable(tegra); -put_usb2: +put_rpm: + pm_runtime_put_sync(&pdev->dev); +disable_rpm: + pm_runtime_disable(&pdev->dev); usb_put_hcd(tegra->hcd); put_padctl: tegra_xusb_padctl_put(tegra->padctl); @@ -1181,13 +1169,55 @@ static int tegra_xusb_remove(struct platform_device *pdev) dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt, tegra->fw.phys); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + + tegra_xusb_padctl_put(tegra->padctl); + + return 0; +} + +static int tegra_xusb_runtime_suspend(struct device *dev) +{ + struct tegra_xusb *tegra = dev_get_drvdata(dev); + tegra_xusb_phy_disable(tegra); regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); tegra_xusb_clk_disable(tegra); - tegra_xusb_padctl_put(tegra->padctl); + return 0; +} + +static int tegra_xusb_runtime_resume(struct device *dev) +{ + struct tegra_xusb *tegra = dev_get_drvdata(dev); + int err; + + err = tegra_xusb_clk_enable(tegra); + if (err) { + dev_err(dev, "failed to enable clocks: %d\n", err); + return err; + } + + err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); + if (err) { + dev_err(dev, "failed to enable regulators: %d\n", err); + goto disable_clk; + } + + err = tegra_xusb_phy_enable(tegra); + if (err < 0) { + dev_err(dev, "failed to enable PHYs: %d\n", err); + goto disable_regulator; + } return 0; + +disable_regulator: + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); +disable_clk: + tegra_xusb_clk_disable(tegra); + return err; } #ifdef CONFIG_PM_SLEEP @@ -1211,6 +1241,8 @@ static int tegra_xusb_resume(struct device *dev) #endif static const struct dev_pm_ops tegra_xusb_pm_ops = { + SET_RUNTIME_PM_OPS(tegra_xusb_runtime_suspend, + tegra_xusb_runtime_resume, NULL) SET_SYSTEM_SLEEP_PM_OPS(tegra_xusb_suspend, tegra_xusb_resume) }; -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http:
Re: [PATCH v1 13/14] USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro
On Wed, Feb 14, 2018 at 06:08:29PM +0200, Andy Shevchenko wrote: > ...instead of open coding file operations followed by custom ->open() > callbacks per each attribute. > > Cc: Heikki Krogerus > Cc: Guenter Roeck > Signed-off-by: Andy Shevchenko Reviewed-by: Guenter Roeck > --- > drivers/usb/typec/fusb302/fusb302.c | 17 +++-- > drivers/usb/typec/tcpm.c| 17 +++-- > 2 files changed, 6 insertions(+), 28 deletions(-) > > diff --git a/drivers/usb/typec/fusb302/fusb302.c > b/drivers/usb/typec/fusb302/fusb302.c > index 9ce4756adad6..da179aaf789e 100644 > --- a/drivers/usb/typec/fusb302/fusb302.c > +++ b/drivers/usb/typec/fusb302/fusb302.c > @@ -199,7 +199,7 @@ static void fusb302_log(struct fusb302_chip *chip, const > char *fmt, ...) > va_end(args); > } > > -static int fusb302_seq_show(struct seq_file *s, void *v) > +static int fusb302_debug_show(struct seq_file *s, void *v) > { > struct fusb302_chip *chip = (struct fusb302_chip *)s->private; > int tail; > @@ -216,18 +216,7 @@ static int fusb302_seq_show(struct seq_file *s, void *v) > > return 0; > } > - > -static int fusb302_debug_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, fusb302_seq_show, inode->i_private); > -} > - > -static const struct file_operations fusb302_debug_operations = { > - .open = fusb302_debug_open, > - .llseek = seq_lseek, > - .read = seq_read, > - .release= single_release, > -}; > +DEFINE_SHOW_ATTRIBUTE(fusb302_debug); > > static struct dentry *rootdir; > > @@ -242,7 +231,7 @@ static int fusb302_debugfs_init(struct fusb302_chip *chip) > > chip->dentry = debugfs_create_file(dev_name(chip->dev), > S_IFREG | 0444, rootdir, > -chip, &fusb302_debug_operations); > +chip, &fusb302_debug_fops); > > return 0; > } > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > index f4d563ee7690..a163ba55b061 100644 > --- a/drivers/usb/typec/tcpm.c > +++ b/drivers/usb/typec/tcpm.c > @@ -506,7 +506,7 @@ static void tcpm_log_source_caps(struct tcpm_port *port) > } > } > > -static int tcpm_seq_show(struct seq_file *s, void *v) > +static int tcpm_debug_show(struct seq_file *s, void *v) > { > struct tcpm_port *port = (struct tcpm_port *)s->private; > int tail; > @@ -523,18 +523,7 @@ static int tcpm_seq_show(struct seq_file *s, void *v) > > return 0; > } > - > -static int tcpm_debug_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, tcpm_seq_show, inode->i_private); > -} > - > -static const struct file_operations tcpm_debug_operations = { > - .open = tcpm_debug_open, > - .llseek = seq_lseek, > - .read = seq_read, > - .release= single_release, > -}; > +DEFINE_SHOW_ATTRIBUTE(tcpm_debug); > > static struct dentry *rootdir; > > @@ -550,7 +539,7 @@ static int tcpm_debugfs_init(struct tcpm_port *port) > > port->dentry = debugfs_create_file(dev_name(port->dev), > S_IFREG | 0444, rootdir, > -port, &tcpm_debug_operations); > +port, &tcpm_debug_fops); > > return 0; > } > -- > 2.15.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] ARM: dts: am43xx: Enable dual-role mode for USB1
* Roger Quadros [180122 05:17]: > +Tony > > On 22/01/18 15:11, Roger Quadros wrote: > > USB1 port is micro-AB type and can function as peripheral > > as well as host. Enable dual-role mode for USB1. Looks like I don't have this one, please resend it separately when it's safe to apply. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: gadget: f_uac2: fix bFirstInterface in composite gadget
If there are multiple functions associated with a configuration, then the UAC2 interfaces may not start at zero. Set the correct first interface number in the association descriptor so that the audio interfaces are enumerated correctly in this case. Signed-off-by: John Keeping Reviewed-by: Krzysztof Opasiak --- v2: - Add Krzysztof's reviewed-by drivers/usb/gadget/function/f_uac2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 11fe788b4308..d2dc1f00180b 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -524,6 +524,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); return ret; } + iad_desc.bFirstInterface = ret; + std_ac_if_desc.bInterfaceNumber = ret; uac2->ac_intf = ret; uac2->ac_alt = 0; -- 2.16.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: host: ehci: Use dma_pool_zalloc()
Use dma_pool_zalloc() instead of dma_pool_alloc + memset Signed-off-by: Souptick Joarder --- drivers/usb/host/ehci-mem.c | 3 +-- drivers/usb/host/ehci-sched.c | 6 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 21307d8..4c6c08b 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c @@ -73,10 +73,9 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags) if (!qh) goto done; qh->hw = (struct ehci_qh_hw *) - dma_pool_alloc(ehci->qh_pool, flags, &dma); + dma_pool_zalloc(ehci->qh_pool, flags, &dma); if (!qh->hw) goto fail; - memset(qh->hw, 0, sizeof *qh->hw); qh->qh_dma = dma; // INIT_LIST_HEAD (&qh->qh_list); INIT_LIST_HEAD (&qh->qtd_list); diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index e56db44..28e2a33 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -1287,7 +1287,7 @@ static void scan_intr(struct ehci_hcd *ehci) } else { alloc_itd: spin_unlock_irqrestore(&ehci->lock, flags); - itd = dma_pool_alloc(ehci->itd_pool, mem_flags, + itd = dma_pool_zalloc(ehci->itd_pool, mem_flags, &itd_dma); spin_lock_irqsave(&ehci->lock, flags); if (!itd) { @@ -1297,7 +1297,6 @@ static void scan_intr(struct ehci_hcd *ehci) } } - memset(itd, 0, sizeof(*itd)); itd->itd_dma = itd_dma; itd->frame = NO_FRAME; list_add(&itd->itd_list, &sched->td_list); @@ -2081,7 +2080,7 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, } else { alloc_sitd: spin_unlock_irqrestore(&ehci->lock, flags); - sitd = dma_pool_alloc(ehci->sitd_pool, mem_flags, + sitd = dma_pool_zalloc(ehci->sitd_pool, mem_flags, &sitd_dma); spin_lock_irqsave(&ehci->lock, flags); if (!sitd) { @@ -2091,7 +2090,6 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, } } - memset(sitd, 0, sizeof(*sitd)); sitd->sitd_dma = sitd_dma; sitd->frame = NO_FRAME; list_add(&sitd->sitd_list, &iso_sched->td_list); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: host: ehci: Use dma_pool_zalloc()
On Wed, 14 Feb 2018, Souptick Joarder wrote: > Use dma_pool_zalloc() instead of dma_pool_alloc + memset > > Signed-off-by: Souptick Joarder > --- Acked-by: Alan Stern > drivers/usb/host/ehci-mem.c | 3 +-- > drivers/usb/host/ehci-sched.c | 6 ++ > 2 files changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c > index 21307d8..4c6c08b 100644 > --- a/drivers/usb/host/ehci-mem.c > +++ b/drivers/usb/host/ehci-mem.c > @@ -73,10 +73,9 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd > *ehci, gfp_t flags) > if (!qh) > goto done; > qh->hw = (struct ehci_qh_hw *) > - dma_pool_alloc(ehci->qh_pool, flags, &dma); > + dma_pool_zalloc(ehci->qh_pool, flags, &dma); > if (!qh->hw) > goto fail; > - memset(qh->hw, 0, sizeof *qh->hw); > qh->qh_dma = dma; > // INIT_LIST_HEAD (&qh->qh_list); > INIT_LIST_HEAD (&qh->qtd_list); > diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c > index e56db44..28e2a33 100644 > --- a/drivers/usb/host/ehci-sched.c > +++ b/drivers/usb/host/ehci-sched.c > @@ -1287,7 +1287,7 @@ static void scan_intr(struct ehci_hcd *ehci) > } else { > alloc_itd: > spin_unlock_irqrestore(&ehci->lock, flags); > - itd = dma_pool_alloc(ehci->itd_pool, mem_flags, > + itd = dma_pool_zalloc(ehci->itd_pool, mem_flags, > &itd_dma); > spin_lock_irqsave(&ehci->lock, flags); > if (!itd) { > @@ -1297,7 +1297,6 @@ static void scan_intr(struct ehci_hcd *ehci) > } > } > > - memset(itd, 0, sizeof(*itd)); > itd->itd_dma = itd_dma; > itd->frame = NO_FRAME; > list_add(&itd->itd_list, &sched->td_list); > @@ -2081,7 +2080,7 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb > *urb, > } else { > alloc_sitd: > spin_unlock_irqrestore(&ehci->lock, flags); > - sitd = dma_pool_alloc(ehci->sitd_pool, mem_flags, > + sitd = dma_pool_zalloc(ehci->sitd_pool, mem_flags, > &sitd_dma); > spin_lock_irqsave(&ehci->lock, flags); > if (!sitd) { > @@ -2091,7 +2090,6 @@ static int itd_submit(struct ehci_hcd *ehci, struct urb > *urb, > } > } > > - memset(sitd, 0, sizeof(*sitd)); > sitd->sitd_dma = sitd_dma; > sitd->frame = NO_FRAME; > list_add(&sitd->sitd_list, &iso_sched->td_list); > -- > 1.9.1 > > > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: gadget: udc: bdc: Use dma_pool_zalloc
Use dma_pool_zalloc instead of dma_pool_alloc + memset Signed-off-by: Souptick Joarder --- drivers/usb/gadget/udc/bdc/bdc_ep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index f40d4c1..03149b9d 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -151,7 +151,7 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) if (!bd_table) goto fail; - bd_table->start_bd = dma_pool_alloc(bdc->bd_table_pool, + bd_table->start_bd = dma_pool_zalloc(bdc->bd_table_pool, GFP_ATOMIC, &dma); if (!bd_table->start_bd) { @@ -167,7 +167,6 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) (unsigned long long)bd_table->dma, prev_table); ep->bd_list.bd_table_array[index] = bd_table; - memset(bd_table->start_bd, 0, bd_p_tab * sizeof(struct bdc_bd)); if (prev_table) chain_table(prev_table, bd_table, bd_p_tab); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Regression] xhci: some hard drives cannot be seen using a JMicron JMS56x enclosure
Hi, I use two hard drives in an enclosure connected to my PC using UAS. The enclosure is a JMicron JMS56x (152d:0562); the drives are a Fujitsu MHZ2160BH G2 (2"5, 160GB) and a Western Digital EFRX-68N32N0 (3"5, 4TB). Using a USB2 port, I can see both drives as expected. I used to be able to use both drives using a USB3 port (and UAS) in Linux 4.11 and 4.12, but I am experiencing a bug starting with Linux 4.13. When I plug the USB cable, I can see the following output in dmesg: [Tue Feb 6 22:17:49 2018] usb 4-2: new SuperSpeed USB device number 10 using xhci_hcd [Tue Feb 6 22:17:49 2018] usb 4-2: New USB device found, idVendor=152d, idProduct=0562 [Tue Feb 6 22:17:49 2018] usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=5 [Tue Feb 6 22:17:49 2018] usb 4-2: Product: JMS56x Series [Tue Feb 6 22:17:49 2018] usb 4-2: Manufacturer: JMicron [Tue Feb 6 22:17:49 2018] usb 4-2: SerialNumber: RANDOM__8A4D7F833EEF [Tue Feb 6 22:17:49 2018] scsi host6: uas [Tue Feb 6 22:17:50 2018] scsi 6:0:0:0: Direct-Access FUJITSU MHZ2160BH G2 0104 PQ: 0 ANSI: 6 [Tue Feb 6 22:17:50 2018] scsi 6:0:0:1: Direct-Access WDC WD40 EFRX-68N32N0 0104 PQ: 0 ANSI: 6 [Tue Feb 6 22:17:50 2018] sd 6:0:0:0: Attached scsi generic sg2 type 0 [Tue Feb 6 22:17:50 2018] sd 6:0:0:1: Attached scsi generic sg3 type 0 [Tue Feb 6 22:17:57 2018] sd 6:0:0:0: [sdb] 312581808 512-byte logical blocks: (160 GB/149 GiB) [Tue Feb 6 22:17:57 2018] sd 6:0:0:1: [sdc] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB) [Tue Feb 6 22:17:57 2018] sd 6:0:0:0: [sdb] Write Protect is off [Tue Feb 6 22:17:57 2018] sd 6:0:0:0: [sdb] Mode Sense: 67 00 10 08 [Tue Feb 6 22:17:57 2018] sd 6:0:0:1: [sdc] Write Protect is off [Tue Feb 6 22:17:57 2018] sd 6:0:0:1: [sdc] Mode Sense: 67 00 10 08 [Tue Feb 6 22:17:57 2018] sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA [Tue Feb 6 22:17:57 2018] sd 6:0:0:1: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA [Tue Feb 6 22:17:57 2018] sdb: sdb1 [Tue Feb 6 22:17:57 2018] sd 6:0:0:0: [sdb] Attached SCSI disk [Tue Feb 6 22:18:27 2018] sd 6:0:0:1: tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: IN [Tue Feb 6 22:18:27 2018] sd 6:0:0:1: tag#1 CDB: Inquiry 12 01 00 00 40 00 [Tue Feb 6 22:18:27 2018] scsi host6: uas_eh_device_reset_handler start [Tue Feb 6 22:18:28 2018] usb 4-2: reset SuperSpeed USB device number 10 using xhci_hcd [Tue Feb 6 22:18:28 2018] usb 4-2: device firmware changed [Tue Feb 6 22:18:28 2018] scsi host6: uas_post_reset: alloc streams error -19 after reset [Tue Feb 6 22:18:28 2018] usb 4-2: USB disconnect, device number 10 [Tue Feb 6 22:20:29 2018] iwlwifi :03:00.0: Radio type=0x0-0x3-0x1 [Tue Feb 6 22:20:29 2018] iwlwifi :03:00.0: Radio type=0x0-0x3-0x1 [Tue Feb 6 22:20:29 2018] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready [Tue Feb 6 22:20:30 2018] INFO: task kworker/0:3:191 blocked for more than 120 seconds. [Tue Feb 6 22:20:30 2018] Not tainted 4.14.0-3-amd64 #1 Debian 4.14.13-1 [Tue Feb 6 22:20:30 2018] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [Tue Feb 6 22:20:30 2018] kworker/0:3 D0 191 2 0x8000 [Tue Feb 6 22:20:30 2018] Workqueue: usb_hub_wq hub_event [usbcore] [Tue Feb 6 22:20:30 2018] Call Trace: [Tue Feb 6 22:20:30 2018] ? __schedule+0x28e/0x880 [Tue Feb 6 22:20:30 2018] schedule+0x28/0x80 [Tue Feb 6 22:20:30 2018] schedule_preempt_disabled+0xa/0x10 [Tue Feb 6 22:20:30 2018] __mutex_lock.isra.1+0x1a0/0x4e0 [Tue Feb 6 22:20:30 2018] ? _dev_info+0x64/0x80 [Tue Feb 6 22:20:30 2018] ? usb_disconnect+0x57/0x260 [usbcore] [Tue Feb 6 22:20:30 2018] usb_disconnect+0x57/0x260 [usbcore] [Tue Feb 6 22:20:30 2018] hub_event+0x52b/0x15d0 [usbcore] [Tue Feb 6 22:20:30 2018] process_one_work+0x185/0x380 [Tue Feb 6 22:20:30 2018] worker_thread+0x2e/0x390 [Tue Feb 6 22:20:30 2018] ? process_one_work+0x380/0x380 [Tue Feb 6 22:20:30 2018] kthread+0x118/0x130 [Tue Feb 6 22:20:30 2018] ? kthread_create_on_node+0x70/0x70 [Tue Feb 6 22:20:30 2018] ret_from_fork+0x1f/0x30 [Tue Feb 6 22:20:30 2018] INFO: task scsi_eh_6:9856 blocked for more than 120 seconds. [Tue Feb 6 22:20:30 2018] Not tainted 4.14.0-3-amd64 #1 Debian 4.14.13-1 [Tue Feb 6 22:20:30 2018] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [Tue Feb 6 22:20:30 2018] scsi_eh_6 D0 9856 2 0x8000 [Tue Feb 6 22:20:30 2018] Call Trace: [Tue Feb 6 22:20:30 2018] ? __schedule+0x28e/0x880 [Tue Feb 6 22:20:30 2018] schedule+0x28/0x80 [Tue Feb 6 22:20:30 2018] async_synchronize_cookie_domain+0x96/0x140 [Tue Feb 6 22:20:30 2018] ? finish_wait+0x80/0x80 [Tue Feb 6 22:20:30 2018] sd_remove+0x48/0xc0 [sd_mod] [Tue Feb 6 22:20:30 2018] device_release_driver_internal+0x157/0x210 [Tue Feb 6 22:20:30 2018] bus_remove_device+0xe2/0x150 [Tue Feb 6 22:20:30 2018] device_del+0x1c9/0x3
Re: [PATCH 0/4] usb: dwc3: Add dual-role support using OTG core
Hi Felipe, On 22/01/18 15:11, Roger Quadros wrote: > Hi Felipe, > > Some platforms (e.g. TI's AM437x) don't have USB ID pin state available > over GPIO/extcon but need to rely on the DWC3 core's OTG block to > get the ID pin state instead. > > This series implements simple dual-role functionality using DWC3's OTG block. > Debugfs 'mode' override is also functional so user can switch > between "otg", "host" or "device" modes for debug. > > Although system suspend/resume isn't working yet in mainline for AM437x, > I've tested this series for system suspend/resume using a local tree. Any comments on this series? > > This series depends on [1] and [2] > > [1] https://www.mail-archive.com/linux-usb@vger.kernel.org/msg98771.html > > [2] https://www.mail-archive.com/linux-usb@vger.kernel.org/msg98848.html > > Roger Quadros (4): > usb: dwc3: prevent setting PRTCAP to OTG from debugfs > usb: dwc3: core.h: add some register definitions > usb: dwc3: add dual role support using OTG block > ARM: dts: am43xx: Enable dual-role mode for USB1 > > arch/arm/boot/dts/am437x-gp-evm.dts | 2 +- > arch/arm/boot/dts/am437x-sk-evm.dts | 2 +- > arch/arm/boot/dts/am43x-epos-evm.dts | 2 +- > drivers/usb/dwc3/core.c | 70 - > drivers/usb/dwc3/core.h | 111 > drivers/usb/dwc3/drd.c | 492 > +-- > 6 files changed, 650 insertions(+), 29 deletions(-) > -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] usb: dwc3: drd: Fix lock-up on ID change during system suspend/resume
Felipe, On 25/01/18 18:11, Roger Quadros wrote: > Hi, > > On 24/01/18 14:19, Roger Quadros wrote: >> On 23/01/18 14:41, Roger Quadros wrote: >>> Hi Manu, >>> >>> On 23/01/18 05:45, Manu Gautam wrote: Hi, On 1/22/2018 6:31 PM, Roger Quadros wrote: > Adding/removing host/gadget controller before .pm_complete() > causes a lock-up. Let's prevent any dual-role state change > between .pm_prepare() and .pm_complete() to fix this. What kind of lock-up are you seeing? Some hardware lockup or software deadlock? IMO using a freezable_wq for drd_work should address that? >>> >>> I was seeing a software deadlock. freezable_wq is a good idea. I'll try it >>> out. >> >> using freezable_wq doesn't get rid of the deadlock. >> If I use freezable_wq plus add some delay before I do a dwc3_host_init() >> in the work function then it starts to work. >> >> As dependence on delay looks fragile so I'll stick to the current >> implementation >> based on .pm_prepare/complete(). >> > > So I was able to reproduce the lock up with my series as well. On further > investigation > this is what I see. > > There are 2 different scenarios. > > 1) controller in host mode prior to system suspend and switches to device > mode during resume. > > In this case when we call dwc3_host_exit() before tasks are thawed > xhci_plat_remove() seems to lock up at the second usb_remove_hcd() call. > This issue is resolved by using system_freezable_wq for the _dwc3_set_mode() > function. > > > 2) controller in device mode prior to system suspend and switches to host > mode during resume. > > In this case we sleep indefinitely in _dwc3_set_mode due to > dwc3_set_mode()->dwc3_gadget_exit()->usb_del_gadget_udc()->udc_stop()->dwc3_gadget_stop()->wait_event_lock_irq() > > This is not resolved by moving the dwc3_set_mode() call to .pm_complete() nor > via the system_freezable_wq. > > One way I could fix this is like so. > > Felipe, could you please suggest a better way? > Maybe we need to do this in dwc3_gadget_exit() before calling > usb_del_gadget_udc() ? Once you let me know your opinion I can revise this series. Thanks. > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index b417d9a..0c903c1 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -109,6 +109,7 @@ static void __dwc3_set_mode(struct work_struct *work) > struct dwc3 *dwc = work_to_dwc(work); > unsigned long flags; > int ret; > + int epnum; > > if (!dwc->desired_dr_role) > return; > @@ -124,6 +125,17 @@ static void __dwc3_set_mode(struct work_struct *work) > dwc3_host_exit(dwc); > break; > case DWC3_GCTL_PRTCAP_DEVICE: > + spin_lock_irqsave(&dwc->lock, flags); > + for (epnum = 2; epnum < DWC3_ENDPOINTS_NUM; epnum++) { > + struct dwc3_ep *dep = dwc->eps[epnum]; > + > + if (!dep) > + continue; > + > + dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; > + } > + spin_unlock_irqrestore(&dwc->lock, flags); > + > dwc3_gadget_exit(dwc); > dwc3_event_buffers_cleanup(dwc); > break; > -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html