dwc3 usb2 as host not working

2018-07-05 Thread Ricardo Ribalda Delgado
Hi

I have started playing around with a board based on the DragonBoard
820c and I cannot manage to get the USB2 working as host.

If I connect a mouse, before I start the board I can see how the
system powers up the port (vbus) and enumerates the device, just to
kill it a couple of seconds later.

If I try to connect anything to the port after the board has been
started, I get absolutely no message on dmesg about the event, also no
irqs on the hcd, only on the gpios related to the cable detection. Any
ideas of what  can be wrong/how to proceed?


Thanks

[6.153511] dwc3 read:0xc144 0x120c93b
[6.157267] dwc3 read:0xc148 0x27012412
[6.161088] dwc3 read:0xc14c 0x4108084
[6.164818] dwc3 read:0xc150 0x47822004
[6.168640] dwc3 read:0xc154 0x4202088
[6.172369] dwc3 read:0xc158 0x7870020
[6.176204] dwc3 read:0xc15c 0x0
[6.179923] dwc3 read:0xc600 0x47a
[6.183463] dwc3 read:0xc120 0x5533270a
[6.186476] dwc3 write:0xc128 0x40e0f
[6.190446] phy phy-7412000.phy.4: qusb2_phy_init(): Initializing QUSB2 phy
[6.194349] qusb2: setbits: offset 0xb4 val 0x23
[6.200865] qusb2: conf: offset 0x80 val 0xf8
[6.205697] qusb2: conf: offset 0x84 val 0xb3
[6.209948] qusb2: conf: offset 0x88 val 0x83
[6.214287] qusb2: conf: offset 0x8c val 0xc0
[6.218628] qusb2: conf: offset 0x8 val 0x30
[6.222968] qusb2: conf: offset 0xc val 0x79
[6.227308] qusb2: conf: offset 0x10 val 0x21
[6.231562] qusb2: conf: offset 0x9c val 0x14
[6.235815] qusb2: conf: offset 0x1c val 0x9f
[6.240155] qusb2: conf: offset 0x18 val 0x0
[6.244504] qusb2: setbits: offset 0x84 val 0xb0
[6.248840] qusb2: clrbits: offset 0xb4 val 0x1
[6.253613] qusb2: pll_test: offset 0x4 val 0x80
[6.257792] dwc3 read:0xc2c0 0x10c0002
[6.262519] dwc3 write:0xc2c0 0x10e0002
[6.266076] dwc3 read:0xc200 0x2500
[6.269811] Disabling power management
[6.273280] dwc3 write:0xc200 0x2400
[6.277099] dwc3 read:0xc110 0x102000
[6.280833] dwc3 write:0xc110 0x102000
[6.284396] phy phy-7412000.phy.4: qusb2_phy_poweron(): Powering-on QUSB2 phy
[6.288078] regulator:
/usr/src/kernel/drivers/regulator/qcom_smd-regulator.c:60 id 24 type
1634690156
[6.295531] dwc3 write:0xc400 0xff05b000
[6.304448] dwc3 write:0xc404 0x0
[6.308526] dwc3 write:0xc408 0x1000
[6.311735] dwc3 write:0xc40c 0x0
[6.315382] dwc3 read:0xc11c 0xc0002
[6.318584] dwc3 write:0xc11c 0xc0002
[6.322241] dwc3 read:0xc110 0x102000
[6.325797] dwc3 write:0xc110 0x101000
[6.329990] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[6.333134] xhci-hcd xhci-hcd.0.auto: new USB bus registered,
assigned bus number 1
[6.338585] xhci-hcd xhci-hcd.0.auto: xHCI capability registers at
0d408000:
[6.346119] xhci-hcd xhci-hcd.0.auto: CAPLENGTH AND HCIVERSION 0x120:
[6.350898] extcon gpio: ID 0x0 VBUS 0x1 (0x8000ba02e2a0)
[6.350900] extcon: extcon_set_state_sync \xc3\xaed:2 state:1
[6.366517] xhci-hcd xhci-hcd.0.auto: CAPLENGTH: 0x20
[6.371548] xhci-hcd xhci-hcd.0.auto: HCIVERSION: 0x100
[6.376761] xhci-hcd xhci-hcd.0.auto: HCSPARAMS 1: 0x1000140
[6.381793] xhci-hcd xhci-hcd.0.auto:   Max device slots: 64
[6.387693] xhci-hcd xhci-hcd.0.auto:   Max interrupters: 1
[6.393335] xhci-hcd xhci-hcd.0.auto:   Max ports: 1
[6.398631] xhci-hcd xhci-hcd.0.auto: HCSPARAMS 2: 0xcf1
[6.403838] xhci-hcd xhci-hcd.0.auto:   Isoc scheduling threshold: 1
[6.409482] xhci-hcd xhci-hcd.0.auto:   Maximum allowed segments in
event ring: 15
[6.415821] xhci-hcd xhci-hcd.0.auto: HCSPARAMS 3 0x7ff000a:
[6.423206] xhci-hcd xhci-hcd.0.auto:   Worst case U1 device exit latency: 10
[6.429014] xhci-hcd xhci-hcd.0.auto:   Worst case U2 device exit
latency: 2047
[6.436046] xhci-hcd xhci-hcd.0.auto: HCC PARAMS 0x220f665:
[6.443162] xhci-hcd xhci-hcd.0.auto:   HC generates 64 bit addresses
[6.448717] xhci-hcd xhci-hcd.0.auto:   HC hasn't Contiguous Frame
ID Capability
[6.455319] xhci-hcd xhci-hcd.0.auto:   HC can generate Stopped -
Short Package event
[6.462781] xhci-hcd xhci-hcd.0.auto:   FIXME: more HCCPARAMS debugging
[6.470506] xhci-hcd xhci-hcd.0.auto: RTSOFF 0x440:
[6.476929] xhci-hcd xhci-hcd.0.auto: xHCI operational registers at
0d408020:
[6.481793] xhci-hcd xhci-hcd.0.auto: USBCMD 0x0:
[6.489776] xhci-hcd xhci-hcd.0.auto:   HC is being stopped
[6.494465] xhci-hcd xhci-hcd.0.auto:   HC has finished hard reset
[6.499846] xhci-hcd xhci-hcd.0.auto:   Event Interrupts disabled
[6.506096] xhci-hcd xhci-hcd.0.auto:   Host System Error Interrupts disabled
[6.512261] xhci-hcd xhci-hcd.0.auto:   HC has finished light reset
[6.519378] xhci-hcd xhci-hcd.0.auto: USBSTS 0x11:
[6.525453] xhci-hcd xhci-hcd.0.auto:   Event ring is empty
[6.530315] xhci-hcd xhci-hcd.0.auto:   No Host System Error
[6.535783] xhci-hcd xhci-hcd.0.auto:   HC is halted
[6.541689] xhci-hcd 

Re: Serdev: USB device and sysdev probing ala i2c

2018-05-24 Thread Ricardo Ribalda Delgado
Hi Rob
On Thu, May 24, 2018 at 6:49 PM Rob Herring <r...@kernel.org> wrote:

> On Thu, May 24, 2018 at 7:18 AM, Ricardo Ribalda Delgado
> <ricardo.riba...@gmail.com> wrote:
> > Hi Johan,
> >
> > On Thu, May 24, 2018 at 2:07 PM Johan Hovold <jo...@kernel.org> wrote:
> >
> >> Hi Ricardo,
> >
> >> On Wed, May 23, 2018 at 11:17:20AM +0200, Ricardo Ribalda Delgado
wrote:
> >> > Hi
> >> >
> >> > I have a flash controller connected to the main computer via a usb to
> >> > serial. My plan is to expose it to the system as a video4linux
> > subdevice.
> >> >
> >> > With the inclusion of serdev I was expecting that it would be as
easy as
> >> > adding a i2c device, but seems that there are some functionality that
> > it is
> >> > still not implemented:
> >> >
> >> > 1) Serdev for usb serial devices.
> >
> >> Right, I didn't want to enable serdev for USB serial before we have
> >> determined how to handle hotplugging (e.g. in serdev core or by making
> >> sure every serdev driver can handle devices going away at any time) in
> >> order to avoid having things crash left and right.
> >
> >> I have out-of-tree code for USB serial that I use for testing purposes,
> >> so it's mostly a matter of finding the time to think this through.
> >
> > Could you share those patches? I would love to test them.
> > In my setup the system does not support hotplugg and/or power saving.
> >
> >
> >> > 2) Instatiating via sysfs. Something like
> >> > echo hci_nokia > /sys/bus/serio/devices/serio0/new_device
> >> > (inspired in: echo eeprom 0x50 >
/sys/bus/i2c/devices/i2c-3/new_device)
> >
> >> Serdev currently only supports device tree and ACPI. Using out-of-tree
> >> code, you could load a device tree fragment during runtime to describe
> >> your serial bus (or you just amend the device tree).
> >
> >> Using device tree overlays would have the benefit of being able to
> >> describe associated resources (e.g. reset gpios) which a simple
> >> compatible string (or equivalent) would not.
> >
> >> But there are examples where a simple compatible string would do, for
> >> example an existing CEC device presenting itself as a generic USB CDC
> >> device (hopefully with a dedicated VID/PID so that no user-space
> >> configuration is needed at all).
> >
> > What about platform devices? Can it be instatiated like that?

> Platform devices generally mean memory mapped devices. How would that
> work thru serial? I guess you could have some serial to mmio bridge
> exposed thru regmap.


Actually I was thinking about a module that is autoloaded based on a acpi
string and then creates the serial devices with something like:

static struct serio_board_info ledctrl = {
.modalias = "serio_ledctrl",
};

serio_adap = serio_get_adapter(0);
if (!serio_adap){
printk(KERN_ERR "Could not find serio bus.");
return -EIO;
}
serio_client=serio_new_device(serio_adap, ledctrl);

Yes, there would be one driver per board, and that does not scale on the
kernel tree, but for out of tree is really helpful (and maybe also for
notebooks that already have their own platform driver on the tree)

> The fundamental problem here is you need a parent device node to apply
> a DT overlay to and a USB device hotplugged has no DT device node. The
> system you are running on may not even have a DT (like a PC). If you
> have an overlay of the downstream devices, they have to be a child of
> something for the overlay to apply to. We could just create virtual
> device nodes for the purposes of applying overlays to. Another option
> would be allowing multiple DTs. Then you aren't even using overlays
> (what's the point of an overlay when a system has no real DT to begin
> with). That also would mean they are completely independent from any
> real DT or other instances (you may want to plug in multiple of the
> same device).

In my usecase the DT is way too overkilled. The previously mentioned
echo tty > /sys/bus/serio/devices/serio0/unregister
echo hci_nokia > /sys/bus/serio/devices/serio0/new_device

would be the most convenient way to use/experiment with serio.


I am not taking into consideration hot pluggable devices. I am thinking
about a use case where the usb2serial is soldered in the board.


> Rob



-- 
Ricardo Ribalda
--
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: Serdev: USB device and sysdev probing ala i2c

2018-05-24 Thread Ricardo Ribalda Delgado
Hi Johan,

On Thu, May 24, 2018 at 2:07 PM Johan Hovold <jo...@kernel.org> wrote:

> Hi Ricardo,

> On Wed, May 23, 2018 at 11:17:20AM +0200, Ricardo Ribalda Delgado wrote:
> > Hi
> >
> > I have a flash controller connected to the main computer via a usb to
> > serial. My plan is to expose it to the system as a video4linux
subdevice.
> >
> > With the inclusion of serdev I was expecting that it would be as easy as
> > adding a i2c device, but seems that there are some functionality that
it is
> > still not implemented:
> >
> > 1) Serdev for usb serial devices.

> Right, I didn't want to enable serdev for USB serial before we have
> determined how to handle hotplugging (e.g. in serdev core or by making
> sure every serdev driver can handle devices going away at any time) in
> order to avoid having things crash left and right.

> I have out-of-tree code for USB serial that I use for testing purposes,
> so it's mostly a matter of finding the time to think this through.

Could you share those patches? I would love to test them.
In my setup the system does not support hotplugg and/or power saving.


> > 2) Instatiating via sysfs. Something like
> > echo hci_nokia > /sys/bus/serio/devices/serio0/new_device
> > (inspired in: echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-3/new_device)

> Serdev currently only supports device tree and ACPI. Using out-of-tree
> code, you could load a device tree fragment during runtime to describe
> your serial bus (or you just amend the device tree).

> Using device tree overlays would have the benefit of being able to
> describe associated resources (e.g. reset gpios) which a simple
> compatible string (or equivalent) would not.

> But there are examples where a simple compatible string would do, for
> example an existing CEC device presenting itself as a generic USB CDC
> device (hopefully with a dedicated VID/PID so that no user-space
> configuration is needed at all).

What about platform devices? Can it be instatiated like that?


> > 3) Support for probing: Like hwmon for i2c

> What would you probe for (since there is no generic protocol for serial
> devices)?


Just write to the device and expect something in return. I know it can be
dangerous in most cases, but hey, this is how the modems are detected in
userspace and works fine :).


> > -Are these two things in the drawing board?
> > -if not, would it be something worth considering/reviewing for
> > upstream?

> So the first two points have been given some thought and is something
> we'd want to have eventually, while the third point has mostly been
> rejected (I think).

I did not expect the last point to be enabled by default, but it could be
useful for some platforms if you know that your serial devices are tolerant
to some "noise"


Thanks!


> Johan



-- 
Ricardo Ribalda
--
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: net2280 and UAS not working

2015-07-06 Thread Ricardo Ribalda Delgado
Hello Paul


Thanks for your info, I will not be able to test anything until next week.


Regards!
--
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 v1 01/10] usb: gadget: net2280: fix ep_cfg for defect7374

2015-05-13 Thread Ricardo Ribalda Delgado
Tested-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com

On Tue, May 12, 2015 at 8:37 PM, Mian Yousaf Kaukab
yousaf.kau...@intel.com wrote:
 ep_cfg.IN_EP_ENABLE is only valid in advance mode.

 Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
 ---
  drivers/usb/gadget/udc/net2280.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/usb/gadget/udc/net2280.c 
 b/drivers/usb/gadget/udc/net2280.c
 index 9871b90..62bc157 100644
 --- a/drivers/usb/gadget/udc/net2280.c
 +++ b/drivers/usb/gadget/udc/net2280.c
 @@ -1860,8 +1860,8 @@ static void defect7374_enable_data_eps_zero(struct 
 net2280 *dev)
 tmp = ((0  ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
 (2  OUT_ENDPOINT_TYPE) | (2  IN_ENDPOINT_TYPE) |
 ((dev-enhanced_mode) ?
 -BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
 -   BIT(IN_ENDPOINT_ENABLE));
 +BIT(OUT_ENDPOINT_ENABLE) | BIT(IN_ENDPOINT_ENABLE) :
 +BIT(ENDPOINT_ENABLE)));

 for (i = 1; i  5; i++)
 writel(tmp, dev-ep[i].cfg-ep_cfg);
 --
 2.3.3




-- 
Ricardo Ribalda
--
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: usb: gadget: g_multi does not work with net2280

2015-04-21 Thread Ricardo Ribalda Delgado
Can you try with the latest kernel from linux-next?

There are some patches from Mian Yousaf Kaukab
yousaf.kau...@intel.com, that might be related to your problem

Regards

ps: Make sure your mail client works in text mode or you wont be able
to send mails to the mailing list.

On Tue, Apr 21, 2015 at 2:39 AM, Praveen Murali pmur...@logicube.com wrote:
 Hi Ricardo,

   I am trying to get the g_multi gadget driver to work on a PLX 3380 chip
 (using net2280 driver). For some reason, when I connect my device to a
 Windows PC, although it shows up the RNDIS and mass storage endpoints, it
 does not seem to be able to activate either of them. I am using linux.inf
 from Documentation/usb to configure the RNDIS interface on my Windows PC.
 However, it works fine on a Linux PC.

 Following are some experiments I have tried with limited success

 1.   When I remove all interfaces, other than RNDIS ones from the
 g_multi driver and comment out the special handling for net2280 interrupt
 transfer endpoints in epautoconf.c-usb_ep_autoconfig_ss(), the RNDIS
 interface gets activated properly; at this stage I can assign IP addresses’s
 and communicate.

 2.   When I remove all interfaces, other than the mass storage one from
 the g_multi driver, the mass storage device shows up properly on Windows
 host.

 3.   If I comment out the special handling for net2280 interrupt
 transfer endpoints in epautoconf.c-usb_ep_autoconfig_ss() but keep all
 interfaces in g_multi, even though the interfaces show up on Windows host,
 they cannot be activated (trying to install the linux.inf results in a
 “cannot start device code 10” error).



 I started with a 3.16.7-ckt4 kernel and ported the USB338x driver from PLX
 website; that did not work. So, I now I am testing with the 4.0 release. At
 this point, it looks like an either/or for me. Is there something I am
 missing here? Let me know if you need any logs for this.



 Thanks,

 Praveen



-- 
Ricardo Ribalda
--
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: net2280 driver and gadgetfs?

2015-02-02 Thread Ricardo Ribalda Delgado
Hello Carolyn

I have tried using g_mass_storage and g_network, but I cannot see why
it should not work with gadgetfs.

What is exactly the issue? It does not build? it does not behave as expected?

I am putting the linux-usb mailing list on cc

Regards!


On Sat, Jan 31, 2015 at 12:06 AM, Smith, Carolyn J
carolyn.j.sm...@tektronix.com wrote:
 Hello Ricardo,



 I am working on a board with the PLX3380 chip on it. Thank you very much for
 your work on integrating support for this chip into the Linux net2280
 driver.



 Have you used the driver successfully with the gadgetfs filesystem at all?
 Or do you know of anyone who has? I'm not having any luck getting the
 gadgetfs example at www.linux-usb.org/gadget/usb.c working properly with it.



 Thank you for any help or suggestions you can provide,

 Carolyn Smith

 Tektronix, Inc.







-- 
Ricardo Ribalda
--
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: net2280 on iMX6

2015-01-23 Thread Ricardo Ribalda Delgado
Hello Tod

If you cc the linux-usb mailing list, there will be more chances to
get a proper answer :)

From the error message it seems that the device did not have an irq,
which is needed by the driver. Take a loop to lspci -vvv to see if it
is true.

Unfortunately I have not access to that board to test it.

Regards and good luck :) !



On Fri, Jan 23, 2015 at 5:32 PM, Tord Andersson
tord.o.anders...@gmail.com wrote:
 Hi Ricardo,

 I am trying to get a PLX3380 PCIe/USB3 adapter up and running on a Nitrogen
 Max board using a backported net2280 driver from the latest kernel to
 Boundary's 3.10.17 kernel.

 I get the following message which indicate that I have not configured my
 interrupts as I should. I get it both when using msi and disabling msi:

 ---

 PCI: enabling device :01:00.0 ( - 0002)

 net2280 :01:00.0: usb_reset_338x: Defect 7374 FsmValue 0xf000

 net2280 :01:00.0: usb_reinit_338x: Defect 7374 FsmValue f000

 net2280 :01:00.0: No IRQ.  Check PCI setup!

 (NULL device *): gadget not registered.

 net2280 :01:00.0: unbind

 ---

 Do you know if anyone has been able to test this driver/HW combo with an
 iMX6 target or other ARM target?
 It works OK on a PC running the latest kernel, so the hardware should be OK
 :)
 Other PCIe cards such as WLAN cards works OK in Nitrogen Max.

 Best regards,

 Tord

 --
 __

 mail: tord.o.anders...@gmail.com
 pgp: F934 1A9B 5E2D 0563 49FE B8EB 0F53 851B E1FA 3E8B



-- 
Ricardo Ribalda
--
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: hard lockup with USB3380

2015-01-19 Thread Ricardo Ribalda Delgado
Hello Paul

Check an old topic on the list net2280: tracing, where Jorge
Ramirez-Ortiz and Felipe Balbi are working on tracing the chip

Regards!

On Sun, Jan 18, 2015 at 4:49 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 I think I figured out the problem: my 3380 was running in legacy adapter mode.
 I am now capable of connecting both g_mass_storage and g_ether without any 
 kernel panics after ensuring the 3380 is in enhanced adapter mode.

 My only concern is the speed from my Mac to Linux:
 - g_ether: scp transfer 42Mb/s
 - g_mass_storage: dd bs=64k 116Mb/s (backed by SSD storage)
 For comparison, a direct gigabit connection allows between 90 and 95Mb/s 
 using scp between the machines.
 Local writes on the linux side using dd is around 480Mb/s (on the same SSD 
 storage).

 Any ideas on how to achieve a higher performance?

 Regards,
 Paul.

 On 25 Nov 2014, at 16:30, Paul Jones p.jo...@teclyn.com wrote:

 Ricardo,

 Unfortunately your latest change gives similar results, cycling errors in 
 the log:
 [  201.287706] [ cut here ]
 [  201.288328] WARNING: CPU: 3 PID: 1500 at 
 drivers/usb/gadget/udc/net2280.c:816 start_dma+0x153/0x160 [net2280]()
 [  201.288991] Modules linked in: g_mass_storage usb_f_mass_storage 
 libcomposite configfs net2280 udc_core snd_hda_codec_hdmi joydev hid_generic 
 usbhid hid i915 intel_rapl x86_pkg_temp_thermal intel_powerclamp 
 snd_hda_codec_realtek coretemp kvm_intel snd_hda_codec_generic kvm 
 snd_hda_intel eeepc_wmi asus_wmi snd_hda_controller rfcomm snd_seq_midi bnep 
 snd_seq_midi_event bluetooth sparse_keymap snd_hda_codec crct10dif_pclmul 
 snd_rawmidi snd_hwdep crc32_pclmul snd_pcm ghash_clmulni_intel aesni_intel 
 aes_x86_64 drm_kms_helper lrw gf128mul glue_helper ablk_helper cryptd 
 snd_seq mei_me mei serio_raw drm lpc_ich video mac_hid tpm_infineon wmi 
 snd_seq_device snd_timer snd parport_pc i2c_algo_bit soundcore ppdev lp 
 parport e1000e psmouse r8169 ahci libahci mii ptp pps_core
 [  201.292574] CPU: 3 PID: 1500 Comm: file-storage Tainted: GW  
 3.17.0-rc5+ #2
 [  201.293277] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
 [  201.293976]  0009 8803f1d8fd28 81746707 
 
 [  201.294689]  8803f1d8fd60 8106c93d 8803efc26478 
 8800ce317100
 [  201.295398]  c90005b9c1a0 8800ce317168 8803efc26320 
 8803f1d8fd70
 [  201.296109] Call Trace:
 [  201.296815]  [81746707] dump_stack+0x45/0x56
 [  201.297524]  [8106c93d] warn_slowpath_common+0x7d/0xa0
 [  201.298218]  [8106ca1a] warn_slowpath_null+0x1a/0x20
 [  201.298891]  [a0428103] start_dma+0x153/0x160 [net2280]
 [  201.299554]  [a0429b1b] net2280_queue+0x2db/0x480 [net2280]
 [  201.300209]  [a04724f1] start_transfer.isra.32+0x71/0xe0 
 [usb_f_mass_storage]
 [  201.300851]  [a047259e] start_out_transfer+0x3e/0x80 
 [usb_f_mass_storage]
 [  201.301474]  [a0473967] fsg_main_thread+0x207/0x17f0 
 [usb_f_mass_storage]
 [  201.302069]  [81749eda] ? __schedule+0x37a/0x830
 [  201.302607]  [a0473760] ? handle_exception+0x460/0x460 
 [usb_f_mass_storage]
 [  201.303200]  [8108a3e2] kthread+0xd2/0xf0
 [  201.303776]  [8108a310] ? kthread_create_on_node+0x180/0x180
 [  201.304328]  [8174ecbc] ret_from_fork+0x7c/0xb0
 [  201.304973]  [8108a310] ? kthread_create_on_node+0x180/0x180
 [  201.305486] ---[ end trace a7f3e86a1a37203b ]—
 Followed by:
 [  263.311338] net2280 :01:00.0: The dmastat return = 5002!!
 [  263.409818] g_mass_storage gadget: super-speed config #1: Linux 
 File-Backed Storage

 as long as you have ideas, I’ll be more than happy to try them :)

 Paul.

 On 25 Nov 2014, at 15:59, Ricardo Ribalda Delgado 
 ricardo.riba...@gmail.com wrote:

 One last try :)

 Instead of:

 if (likely(t  BIT(FIFO_EMPTY))) {

 have this:

 if ( t  BIT(NAK_OUT_PACKETS)){
  count = readl(ep-dma-dmacount);
  count = DMA_BYTE_COUNT_MASK;
  break;
 }

 if (likely(t  BIT(FIFO_EMPTY))) {



 On Tue, Nov 25, 2014 at 3:54 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 it no longer locks up but if I try to write to the drive, I get cycles of:
 [ 2334.127653] [ cut here ]
 [ 2334.128318] WARNING: CPU: 0 PID: 2140 at 
 drivers/usb/gadget/udc/net2280.c:816 start_dma+0x153/0x160 [net2280]()
 [ 2334.129105] Modules linked in: g_mass_storage usb_f_mass_storage 
 libcomposite configfs net2280 udc_core snd_hda_codec_hdmi i915 rfcomm bnep 
 bluetooth snd_hda_codec_realtek snd_hda_codec_generic intel_rapl 
 x86_pkg_temp_thermal snd_hda_intel intel_powerclamp coretemp 
 snd_hda_controller kvm_intel snd_hda_codec kvm drm_kms_helper snd_hwdep 
 snd_pcm drm snd_seq_midi joydev snd_seq_midi_event snd_rawmidi hid_generic 
 snd_seq eeepc_wmi asus_wmi sparse_keymap crct10dif_pclmul usbhid 
 crc32_pclmul ghash_clmulni_intel aesni_intel snd_seq_device snd_timer 
 aes_x86_64 hid

[PATCH] usb/gadget/net2280: Dont use 0 as NULL pointer

2015-01-13 Thread Ricardo Ribalda Delgado
Fix sparse warning

Fixes: cb442ee1592d2681 (usb: gadget: udc: net2280: Re-enable dynamic debug 
messages)
Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index d2fabdc..6411ed8 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2287,7 +2287,7 @@ static void handle_ep_small(struct net2280_ep *ep)
ep-irqs++;
 
ep_vdbg(ep-dev, %s ack ep_stat %08x, req %p\n,
-   ep-ep.name, t, req ? req-req : 0);
+   ep-ep.name, t, req ? req-req : NULL);
 
if (!ep-is_in || (ep-dev-quirks  PLX_2280))
writel(t  ~BIT(NAK_OUT_PACKETS), ep-regs-ep_stat);
-- 
2.1.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


Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition

2014-12-23 Thread Ricardo Ribalda Delgado
Hello Felipe

I was waiting for more comments for the other patches and I forgot to
resend this patch.

I am on holidays and without access to a computer with the right
tools, nevertheless , since the changes are only on the commit message
I have modified the patch with vi.

I have been very careful, but I cannot try to apply it. If it does not
work, please feel free to modify it yourself (if you want) or wait
until I am back


Thanks!!!

On Tue, Dec 23, 2014 at 7:44 PM, Felipe Balbi ba...@ti.com wrote:
 On Fri, Nov 28, 2014 at 11:16:16PM +0300, Sergei Shtylyov wrote:
 On 11/28/2014 06:21 PM, Ricardo Ribalda Delgado wrote:

 Thanks for reviewing. I will fix it and resend it on the next version
 of the patchset to avoid spamming the ML

 I guess it is ok to add your Reviewed-by

Yes, if you like.

 Thanks!

Not at all. :-)

 [...]

 On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:

 restart_dma is not used before it is declaration. Therefore we can

 s/it is/its/.

Also s/declaration/definition/.

 remove this definition.

 You're removing the declaration, not definition.

 do I get a new version of this patch ?

 --
 balbi



-- 
Ricardo Ribalda
--
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


Real USB3 mass storage speed

2014-12-02 Thread Ricardo Ribalda Delgado
Hello

As you know I am trying to improve the net2280 driver to a point where
it is usable for my company (qtec.com). We develop smart cameras based
on linux, and we want to provide also a mass storage interface to the
camera.

Right now, the maximum speed I have been able to achieve is around 80
MiB per second. This is with the governor in performance mode and
disabling idle states on the cpu.

I wonder if any of you have meassured the maximum speed achievable via
usb gadget mass storage via usb 3.0?

And what about the fastest usb 3.0 ssd hard drive (no usb gadget)?

If I want to get closer to the maximum speed should I just forget
about mass storage and use something else? What?

Thanks!

PS: With a Delock CFast reader I am able to achieve 84 MiB.
-- 
Ricardo Ribalda
--
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: Real USB3 mass storage speed

2014-12-02 Thread Ricardo Ribalda Delgado
Hello

 If I want to get closer to the maximum speed should I just forget
 about mass storage and use something else? What?


 You might want to look into UAS (USB Attached SCSI).
 There is USB Gadget Target Fabric Module in Kconfig.
 There is a gadget-cli tool to control it from userspace.

 You can ask Sebastian for more information:

Google could only find
https://github.com/evinrude/controller-gadget-kmod/blob/master/cli/gadget-cli.c
.

But I guess it is not the right tool isn't it?


Thanks!



-- 
Ricardo Ribalda
--
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 16/17] net2280: Move ASSERT_OUT_NAKING into out_flush

2014-11-28 Thread Ricardo Ribalda Delgado
ASSERT_OUT_NAKING was only called by out_flush and was hidden behind a
ifdef.

This patch moves the inline function into out_flush and remove the
ifdef. The user can decide to print the debug message or not via dynamic
printk

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 10 --
 drivers/usb/gadget/udc/net2280.h | 17 -
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index a978e6e..b1c253e 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -575,9 +575,15 @@ static void out_flush(struct net2280_ep *ep)
u32 __iomem *statp;
u32 tmp;
 
-   ASSERT_OUT_NAKING(ep);
-
statp = ep-regs-ep_stat;
+
+   tmp = readl(statp);
+   if (tmp  BIT(NAK_OUT_PACKETS)) {
+   ep_dbg(ep-dev, %s %s %08x !NAK\n,
+   ep-ep.name, __func__, tmp);
+   writel(BIT(SET_NAK_OUT_PACKETS), ep-regs-ep_rsp);
+   }
+
writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
BIT(DATA_PACKET_RECEIVED_INTERRUPT),
statp);
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index b31deb0..a307dce 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -356,23 +356,6 @@ static inline void start_out_naking(struct net2280_ep *ep)
readl(ep-regs-ep_rsp);
 }
 
-#ifdef DEBUG
-static inline void assert_out_naking(struct net2280_ep *ep, const char *where)
-{
-   u32 tmp = readl(ep-regs-ep_stat);
-
-   if ((tmp  BIT(NAK_OUT_PACKETS)) == 0) {
-   ep_dbg(ep-dev, %s %s %08x !NAK\n,
-   ep-ep.name, where, tmp);
-   writel(BIT(SET_NAK_OUT_PACKETS),
-   ep-regs-ep_rsp);
-   }
-}
-#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep, __func__)
-#else
-#define ASSERT_OUT_NAKING(ep) do {} while (0)
-#endif
-
 static inline void stop_out_naking(struct net2280_ep *ep)
 {
u32 tmp;
-- 
2.1.3

--
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 17/17] net2280: Re-enable dynamic debug messages

2014-11-28 Thread Ricardo Ribalda Delgado
Some debug messages were not build due to unconditional #if 0.

These messages are very useful for debugging and the user can enable
them on demand via dynamic debug.

If they are not enabled the performance is not affected.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index b1c253e..d2fabdc 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -927,10 +927,8 @@ net2280_queue(struct usb_ep *_ep, struct usb_request 
*_req, gfp_t gfp_flags)
return ret;
}
 
-#if 0
ep_vdbg(dev, %s queue req %p, len %d buf %p\n,
_ep-name, _req, _req-length, _req-buf);
-#endif
 
spin_lock_irqsave(dev-lock, flags);
 
@@ -2287,10 +2285,10 @@ static void handle_ep_small(struct net2280_ep *ep)
/* ack all, and handle what we care about */
t = readl(ep-regs-ep_stat);
ep-irqs++;
-#if 0
+
ep_vdbg(ep-dev, %s ack ep_stat %08x, req %p\n,
ep-ep.name, t, req ? req-req : 0);
-#endif
+
if (!ep-is_in || (ep-dev-quirks  PLX_2280))
writel(t  ~BIT(NAK_OUT_PACKETS), ep-regs-ep_stat);
else
-- 
2.1.3

--
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 12/17] net2280: Improve patching of defect 7374

2014-11-28 Thread Ricardo Ribalda Delgado
Once the defect 7374 is patched, there is no reason the keep reading the
idx scratch register.

Cache the content of the scratch idx register on device flag.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 153 +--
 drivers/usb/gadget/udc/net2280.h |   3 +-
 2 files changed, 68 insertions(+), 88 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index ade4693..d4255f9 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1765,76 +1765,73 @@ static void defect7374_disable_data_eps(struct net2280 
*dev)
 static void defect7374_enable_data_eps_zero(struct net2280 *dev)
 {
u32 tmp = 0, tmp_reg;
-   u32 fsmvalue, scratch;
+   u32 scratch;
int i;
unsigned char ep_sel;
 
scratch = get_idx_reg(dev-regs, SCRATCH);
-   fsmvalue = scratch  (0xf  DEFECT7374_FSM_FIELD);
+
+   WARN_ON((scratch  (0xf  DEFECT7374_FSM_FIELD))
+   == DEFECT7374_FSM_SS_CONTROL_READ);
+
scratch = ~(0xf  DEFECT7374_FSM_FIELD);
 
-   /*See if firmware needs to set up for workaround*/
-   if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
-   ep_warn(dev, Operate Defect 7374 workaround soft this time);
-   ep_warn(dev, It will operate on cold-reboot and SS connect);
-
-   /*GPEPs:*/
-   tmp = ((0  ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
-  (2  OUT_ENDPOINT_TYPE) | (2  IN_ENDPOINT_TYPE) |
-  ((dev-enhanced_mode) ?
-  BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
-  BIT(IN_ENDPOINT_ENABLE));
-
-   for (i = 1; i  5; i++)
-   writel(tmp, dev-ep[i].cfg-ep_cfg);
-
-   /* CSRIN, PCIIN, STATIN, RCIN*/
-   tmp = ((0  ENDPOINT_NUMBER) | BIT(ENDPOINT_ENABLE));
-   writel(tmp, dev-dep[1].dep_cfg);
-   writel(tmp, dev-dep[3].dep_cfg);
-   writel(tmp, dev-dep[4].dep_cfg);
-   writel(tmp, dev-dep[5].dep_cfg);
-
-   /*Implemented for development and debug.
-* Can be refined/tuned later.*/
-   for (ep_sel = 0; ep_sel = 21; ep_sel++) {
-   /* Select an endpoint for subsequent operations: */
-   tmp_reg = readl(dev-plregs-pl_ep_ctrl);
-   writel(((tmp_reg  ~0x1f) | ep_sel),
-  dev-plregs-pl_ep_ctrl);
-
-   if (ep_sel == 1) {
-   tmp =
-   (readl(dev-plregs-pl_ep_ctrl) |
-BIT(CLEAR_ACK_ERROR_CODE) | 0);
-   writel(tmp, dev-plregs-pl_ep_ctrl);
-   continue;
-   }
+   ep_warn(dev, Operate Defect 7374 workaround soft this time);
+   ep_warn(dev, It will operate on cold-reboot and SS connect);
 
-   if (ep_sel == 0 || (ep_sel  9  ep_sel  14) ||
-   ep_sel == 18  || ep_sel == 20)
-   continue;
+   /*GPEPs:*/
+   tmp = ((0  ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
+   (2  OUT_ENDPOINT_TYPE) | (2  IN_ENDPOINT_TYPE) |
+   ((dev-enhanced_mode) ?
+BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
+   BIT(IN_ENDPOINT_ENABLE));
 
-   tmp = (readl(dev-plregs-pl_ep_cfg_4) |
-BIT(NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
-   writel(tmp, dev-plregs-pl_ep_cfg_4);
+   for (i = 1; i  5; i++)
+   writel(tmp, dev-ep[i].cfg-ep_cfg);
 
-   tmp = readl(dev-plregs-pl_ep_ctrl) 
-   ~BIT(EP_INITIALIZED);
-   writel(tmp, dev-plregs-pl_ep_ctrl);
+   /* CSRIN, PCIIN, STATIN, RCIN*/
+   tmp = ((0  ENDPOINT_NUMBER) | BIT(ENDPOINT_ENABLE));
+   writel(tmp, dev-dep[1].dep_cfg);
+   writel(tmp, dev-dep[3].dep_cfg);
+   writel(tmp, dev-dep[4].dep_cfg);
+   writel(tmp, dev-dep[5].dep_cfg);
 
+   /*Implemented for development and debug.
+* Can be refined/tuned later.*/
+   for (ep_sel = 0; ep_sel = 21; ep_sel++) {
+   /* Select an endpoint for subsequent operations: */
+   tmp_reg = readl(dev-plregs-pl_ep_ctrl);
+   writel(((tmp_reg  ~0x1f) | ep_sel),
+   dev-plregs-pl_ep_ctrl);
+
+   if (ep_sel == 1) {
+   tmp =
+   (readl(dev-plregs-pl_ep_ctrl) |
+BIT(CLEAR_ACK_ERROR_CODE) | 0);
+   writel(tmp, dev-plregs-pl_ep_ctrl);
+   continue

[PATCH 13/17] net2280: Remove function resume_dma

2014-11-28 Thread Ricardo Ribalda Delgado
Function resume_dma is not used, remove it.

The reason the compiler did not catch this dead code is the inline
modifier.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index d4255f9..cc76181 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -831,11 +831,6 @@ static void start_dma(struct net2280_ep *ep, struct 
net2280_request *req)
start_queue(ep, tmp, req-td_dma);
 }
 
-static inline void resume_dma(struct net2280_ep *ep)
-{
-   writel(readl(ep-dma-dmactl) | BIT(DMA_ENABLE), ep-dma-dmactl);
-}
-
 static inline void
 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid)
 {
-- 
2.1.3

--
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 15/17] net2280: Simplify scan_dma_completions

2014-11-28 Thread Ricardo Ribalda Delgado
After fix superspeed dma_done was applied we can simplify the code by
removing the duplicated dma_done and letting the function check if there
are more completed dma transactions.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index cc76181..a978e6e 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1051,9 +1051,8 @@ static void scan_dma_completions(struct net2280_ep *ep)
dma_done(ep, req, tmp, 0);
break;
} else if (!ep-is_in 
-   (req-req.length % ep-ep.maxpacket) != 0) {
-   if (ep-dev-quirks  PLX_SUPERSPEED)
-   return dma_done(ep, req, tmp, 0);
+  (req-req.length % ep-ep.maxpacket) 
+  !(ep-dev-quirks  PLX_SUPERSPEED)) {
 
tmp = readl(ep-regs-ep_stat);
/* AVOID TROUBLE HERE by not issuing short reads from
-- 
2.1.3

--
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 14/17] net2280: Declare allow_status_338x as inline

2014-11-28 Thread Ricardo Ribalda Delgado
The function is very simple, does not declare any variable and it is
called in the irq path.

The counterpart for net228x is already declared as inline.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index c7c7981..b31deb0 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -125,7 +125,7 @@ static inline void allow_status(struct net2280_ep *ep)
ep-stopped = 1;
 }
 
-static void allow_status_338x(struct net2280_ep *ep)
+static inline void allow_status_338x(struct net2280_ep *ep)
 {
/*
 * Control Status Phase Handshake was set by the chip when the setup
-- 
2.1.3

--
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 07/17] net2280: Code cleanout remove ep_stdrsp function

2014-11-28 Thread Ricardo Ribalda Delgado
ep_stdrsp was only called by handle_stat0_irqs_superspeed and with
always the same flags.

Remove the function and replace the call by the code inside the
function, since it is very simple once the dead code is removed.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 49 +++-
 1 file changed, 8 insertions(+), 41 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index e8c36db..653a8a2 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2668,46 +2668,6 @@ static void ep_stall(struct net2280_ep *ep, int stall)
}
 }
 
-static void ep_stdrsp(struct net2280_ep *ep, int value, int wedged)
-{
-   /* set/clear, then synch memory views with the device */
-   if (value) {
-   ep-stopped = 1;
-   if (ep-num == 0)
-   ep-dev-protocol_stall = 1;
-   else {
-   if (ep-dma)
-   ep_stop_dma(ep);
-   ep_stall(ep, true);
-   }
-
-   if (wedged)
-   ep-wedged = 1;
-   } else {
-   ep-stopped = 0;
-   ep-wedged = 0;
-
-   ep_stall(ep, false);
-
-   /* Flush the queue */
-   if (!list_empty(ep-queue)) {
-   struct net2280_request *req =
-   list_entry(ep-queue.next, struct net2280_request,
-  queue);
-   if (ep-dma)
-   resume_dma(ep);
-   else {
-   if (ep-is_in)
-   write_fifo(ep, req-req);
-   else {
-   if (read_fifo(ep, req))
-   done(ep, req, 0);
-   }
-   }
-   }
-   }
-}
-
 static void handle_stat0_irqs_superspeed(struct net2280 *dev,
struct net2280_ep *ep, struct usb_ctrlrequest r)
 {
@@ -2864,7 +2824,14 @@ static void handle_stat0_irqs_superspeed(struct net2280 
*dev,
e = get_ep_by_addr(dev, w_index);
if (!e || (w_value != USB_ENDPOINT_HALT))
goto do_stall3;
-   ep_stdrsp(e, true, false);
+   ep-stopped = 1;
+   if (ep-num == 0)
+   ep-dev-protocol_stall = 1;
+   else {
+   if (ep-dma)
+   ep_stop_dma(ep);
+   ep_stall(ep, true);
+   }
allow_status_338x(ep);
break;
 
-- 
2.1.3

--
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 11/17] net2280: Clean function net2280_queue

2014-11-28 Thread Ricardo Ribalda Delgado
Do not duplicate the code for the else branch of the condition.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 46b66b3..ade4693 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -937,24 +937,12 @@ net2280_queue(struct usb_ep *_ep, struct usb_request 
*_req, gfp_t gfp_flags)
_req-actual = 0;
 
/* kickstart this i/o queue? */
-   if (list_empty(ep-queue)  !ep-stopped) {
-   /* DMA request while EP halted */
-   if (ep-dma 
-   (readl(ep-regs-ep_rsp)  BIT(CLEAR_ENDPOINT_HALT)) 
-   (dev-quirks  PLX_SUPERSPEED)) {
-   int valid = 1;
-   if (ep-is_in) {
-   int expect;
-   expect = likely(req-req.zero ||
-   ((req-req.length %
- ep-ep.maxpacket) != 0));
-   if (expect != ep-in_fifo_validate)
-   valid = 0;
-   }
-   queue_dma(ep, req, valid);
-   }
+   if  (list_empty(ep-queue)  !ep-stopped 
+   !((dev-quirks  PLX_SUPERSPEED)  ep-dma 
+ (readl(ep-regs-ep_rsp)  BIT(CLEAR_ENDPOINT_HALT {
+
/* use DMA if the endpoint supports it, else pio */
-   else if (ep-dma)
+   if (ep-dma)
start_dma(ep, req);
else {
/* maybe there's no control data, just status ack */
-- 
2.1.3

--
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 10/17] net2280: Merge abort_dma for 228x and 338x

2014-11-28 Thread Ricardo Ribalda Delgado
We can use the same function for both families of chips and also remove
the ep_stop_dma() function.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 23 ++-
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 5ba5132..46b66b3 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -836,12 +836,6 @@ static inline void resume_dma(struct net2280_ep *ep)
writel(readl(ep-dma-dmactl) | BIT(DMA_ENABLE), ep-dma-dmactl);
 }
 
-static inline void ep_stop_dma(struct net2280_ep *ep)
-{
-   writel(readl(ep-dma-dmactl)  ~BIT(DMA_ENABLE), ep-dma-dmactl);
-   spin_stop_dma(ep-dma);
-}
-
 static inline void
 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid)
 {
@@ -1115,7 +1109,7 @@ static void restart_dma(struct net2280_ep *ep)
start_dma(ep, req);
 }
 
-static void abort_dma_228x(struct net2280_ep *ep)
+static void abort_dma(struct net2280_ep *ep)
 {
/* abort the current transfer */
if (likely(!list_empty(ep-queue))) {
@@ -1127,19 +1121,6 @@ static void abort_dma_228x(struct net2280_ep *ep)
scan_dma_completions(ep);
 }
 
-static void abort_dma_338x(struct net2280_ep *ep)
-{
-   writel(BIT(DMA_ABORT), ep-dma-dmastat);
-   spin_stop_dma(ep-dma);
-}
-
-static void abort_dma(struct net2280_ep *ep)
-{
-   if (ep-dev-quirks  PLX_LEGACY)
-   return abort_dma_228x(ep);
-   return abort_dma_338x(ep);
-}
-
 /* dequeue ALL requests */
 static void nuke(struct net2280_ep *ep)
 {
@@ -2813,7 +2794,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 
*dev,
ep-dev-protocol_stall = 1;
else {
if (ep-dma)
-   ep_stop_dma(ep);
+   abort_dma(ep);
set_halt(ep);
}
allow_status_338x(ep);
-- 
2.1.3

--
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 08/17] net2280: Remove field is_halt

2014-11-28 Thread Ricardo Ribalda Delgado
Field is_halt is never used by any function.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 6 +-
 drivers/usb/gadget/udc/net2280.h | 1 -
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 653a8a2..48e8d82 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2643,7 +2643,6 @@ static void ep_stall(struct net2280_ep *ep, int stall)
   /* BIT(SET_NAK_PACKETS) | */
   BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
   ep-regs-ep_rsp);
-   ep-is_halt = 1;
} else {
if (dev-gadget.speed == USB_SPEED_SUPER) {
/*
@@ -2663,7 +2662,6 @@ static void ep_stall(struct net2280_ep *ep, int stall)
writel(val,
   /* | BIT(CLEAR_NAK_PACKETS),*/
   ep-regs-ep_rsp);
-   ep-is_halt = 0;
val = readl(ep-regs-ep_rsp);
}
 }
@@ -2924,9 +2922,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 
stat)
}
ep-stopped = 0;
dev-protocol_stall = 0;
-   if (dev-quirks  PLX_SUPERSPEED)
-   ep-is_halt = 0;
-   else{
+   if (!(dev-quirks  PLX_SUPERSPEED)) {
if (ep-dev-quirks  PLX_2280)
tmp = BIT(FIFO_OVERFLOW) |
BIT(FIFO_UNDERFLOW);
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index 4c53b83..a16494a 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -100,7 +100,6 @@ struct net2280_ep {
dma_addr_t  td_dma; /* of dummy */
struct net2280  *dev;
unsigned long   irqs;
-   unsigned is_halt:1;
 
/* analogous to a host-side qh */
struct list_headqueue;
-- 
2.1.3

--
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 09/17] net2280: Remove function ep_stall

2014-11-28 Thread Ricardo Ribalda Delgado
irqs_superspeed calls ep_stall instead of set/clear_halt, due to a
workaround for SS seqnum. Create a function with the workaround and
call set/clear_halt instead.

This way we can compare the code of super/normal speed and it is easier
to follow the code.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 44 ++--
 1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 48e8d82..5ba5132 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2632,38 +2632,19 @@ restore_data_eps:
return;
 }
 
-static void ep_stall(struct net2280_ep *ep, int stall)
+static void ep_clear_seqnum(struct net2280_ep *ep)
 {
struct net2280 *dev = ep-dev;
u32 val;
static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
 
-   if (stall) {
-   writel(BIT(SET_ENDPOINT_HALT) |
-  /* BIT(SET_NAK_PACKETS) | */
-  BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
-  ep-regs-ep_rsp);
-   } else {
-   if (dev-gadget.speed == USB_SPEED_SUPER) {
-   /*
-* Workaround for SS SeqNum not cleared via
-* Endpoint Halt (Clear) bit. select endpoint
-*/
-   val = readl(dev-plregs-pl_ep_ctrl);
-   val = (val  ~0x1f) | ep_pl[ep-num];
-   writel(val, dev-plregs-pl_ep_ctrl);
+   val = readl(dev-plregs-pl_ep_ctrl)  ~0x1f;
+   val |= ep_pl[ep-num];
+   writel(val, dev-plregs-pl_ep_ctrl);
+   val |= BIT(SEQUENCE_NUMBER_RESET);
+   writel(val, dev-plregs-pl_ep_ctrl);
 
-   val |= BIT(SEQUENCE_NUMBER_RESET);
-   writel(val, dev-plregs-pl_ep_ctrl);
-   }
-   val = readl(ep-regs-ep_rsp);
-   val |= BIT(CLEAR_ENDPOINT_HALT) |
-   BIT(CLEAR_ENDPOINT_TOGGLE);
-   writel(val,
-  /* | BIT(CLEAR_NAK_PACKETS),*/
-  ep-regs-ep_rsp);
-   val = readl(ep-regs-ep_rsp);
-   }
+   return;
 }
 
 static void handle_stat0_irqs_superspeed(struct net2280 *dev,
@@ -2764,7 +2745,12 @@ static void handle_stat0_irqs_superspeed(struct net2280 
*dev,
if (w_value != USB_ENDPOINT_HALT)
goto do_stall3;
ep_vdbg(dev, %s clear halt\n, e-ep.name);
-   ep_stall(e, false);
+   /*
+* Workaround for SS SeqNum not cleared via
+* Endpoint Halt (Clear) bit. select endpoint
+*/
+   ep_clear_seqnum(e);
+   clear_halt(e);
if (!list_empty(e-queue)  e-td_dma)
restart_dma(e);
allow_status(ep);
@@ -2828,7 +2814,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 
*dev,
else {
if (ep-dma)
ep_stop_dma(ep);
-   ep_stall(ep, true);
+   set_halt(ep);
}
allow_status_338x(ep);
break;
@@ -2857,7 +2843,7 @@ do_stall3:
r.bRequestType, r.bRequest, tmp);
dev-protocol_stall = 1;
/* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
-   ep_stall(ep, true);
+   set_halt(ep);
}
 
 next_endpoints3:
-- 
2.1.3

--
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 06/17] net2280: Remove restart_dma inline function definition

2014-11-28 Thread Ricardo Ribalda Delgado
restart_dma is not used before it is declaration. Therefore we can
remove this definition.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 0340462..e8c36db 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1043,8 +1043,6 @@ dma_done(struct net2280_ep *ep,   struct net2280_request 
*req, u32 dmacount,
done(ep, req, status);
 }
 
-static void restart_dma(struct net2280_ep *ep);
-
 static void scan_dma_completions(struct net2280_ep *ep)
 {
/* only look at descriptors that were naturally retired,
-- 
2.1.3

--
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 05/17] net2280: Remove dma_started field

2014-11-28 Thread Ricardo Ribalda Delgado
Remove dma_started field from net2280_ep structure, since it is not used
by any function.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 4 
 drivers/usb/gadget/udc/net2280.h | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 230b8d4..0340462 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -834,16 +834,12 @@ static void start_dma(struct net2280_ep *ep, struct 
net2280_request *req)
 static inline void resume_dma(struct net2280_ep *ep)
 {
writel(readl(ep-dma-dmactl) | BIT(DMA_ENABLE), ep-dma-dmactl);
-
-   ep-dma_started = true;
 }
 
 static inline void ep_stop_dma(struct net2280_ep *ep)
 {
writel(readl(ep-dma-dmactl)  ~BIT(DMA_ENABLE), ep-dma-dmactl);
spin_stop_dma(ep-dma);
-
-   ep-dma_started = false;
 }
 
 static inline void
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index 03f1524..4c53b83 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -100,7 +100,7 @@ struct net2280_ep {
dma_addr_t  td_dma; /* of dummy */
struct net2280  *dev;
unsigned long   irqs;
-   unsigned is_halt:1, dma_started:1;
+   unsigned is_halt:1;
 
/* analogous to a host-side qh */
struct list_headqueue;
-- 
2.1.3

--
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 04/17] net2280: Remove use_dma module parameter

2014-11-28 Thread Ricardo Ribalda Delgado
use_dma parameter was designed to enable the dma on the chip. It was
enabled by default.

It comes from the time when the dma was not reliable. Now it has been
working ok in production.

This patch removes this parameter.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 33 +
 1 file changed, 5 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index fc5c0a2..230b8d4 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -80,18 +80,6 @@ static const char *const ep_name[] = {
ep-e, ep-f, ep-g, ep-h,
 };
 
-/* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO)
- *
- * The net2280 DMA engines are not tightly integrated with their FIFOs;
- * not all cases are (yet) handled well in this driver or the silicon.
- * Some gadget drivers work better with the dma support here than others.
- * These two parameters let you use PIO or more aggressive DMA.
- */
-static bool use_dma = true;
-
-/* modprobe net2280 use_dma=n etc */
-module_param(use_dma, bool, 0444);
-
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
  * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
  * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable
@@ -455,7 +443,7 @@ static int net2280_disable(struct usb_ep *_ep)
/* synch memory views with the device */
(void)readl(ep-cfg-ep_cfg);
 
-   if (use_dma  !ep-dma  ep-num = 1  ep-num = 4)
+   if (!ep-dma  ep-num = 1  ep-num = 4)
ep-dma = ep-dev-dma[ep-num - 1];
 
spin_unlock_irqrestore(ep-dev-lock, flags);
@@ -1508,12 +1496,11 @@ static ssize_t registers_show(struct device *_dev,
 
/* Main Control Registers */
t = scnprintf(next, size, %s version  DRIVER_VERSION
-   , chiprev %04x, dma %s\n\n
+   , chiprev %04x\n\n
devinit %03x fifoctl %08x gadget '%s'\n
pci irqenb0 %02x irqenb1 %08x 
irqstat0 %04x irqstat1 %08x\n,
driver_name, dev-chiprev,
-   use_dma ? enabled : disabled,
readl(dev-regs-devinit),
readl(dev-regs-fifoctl),
s,
@@ -1995,10 +1982,6 @@ static void usb_reset(struct net2280 *dev)
 static void usb_reinit_228x(struct net2280 *dev)
 {
u32 tmp;
-   int init_dma;
-
-   /* use_dma changes are ignored till next device re-init */
-   init_dma = use_dma;
 
/* basic endpoint init */
for (tmp = 0; tmp  7; tmp++) {
@@ -2010,8 +1993,7 @@ static void usb_reinit_228x(struct net2280 *dev)
 
if (tmp  0  tmp = 4) {
ep-fifo_size = 1024;
-   if (init_dma)
-   ep-dma = dev-dma[tmp - 1];
+   ep-dma = dev-dma[tmp - 1];
} else
ep-fifo_size = 64;
ep-regs = dev-epregs[tmp];
@@ -2035,7 +2017,6 @@ static void usb_reinit_228x(struct net2280 *dev)
 
 static void usb_reinit_338x(struct net2280 *dev)
 {
-   int init_dma;
int i;
u32 tmp, val;
u32 fsmvalue;
@@ -2043,9 +2024,6 @@ static void usb_reinit_338x(struct net2280 *dev)
static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
0x00, 0xC0, 0x00, 0xC0 };
 
-   /* use_dma changes are ignored till next device re-init */
-   init_dma = use_dma;
-
/* basic endpoint init */
for (i = 0; i  dev-n_ep; i++) {
struct net2280_ep *ep = dev-ep[i];
@@ -2054,7 +2032,7 @@ static void usb_reinit_338x(struct net2280 *dev)
ep-dev = dev;
ep-num = i;
 
-   if (i  0  i = 4  init_dma)
+   if (i  0  i = 4)
ep-dma = dev-dma[i - 1];
 
if (dev-enhanced_mode) {
@@ -3606,8 +3584,7 @@ static int net2280_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
ep_info(dev, %s\n, driver_desc);
ep_info(dev, irq %d, pci mem %p, chip rev %04x\n,
pdev-irq, base, dev-chiprev);
-   ep_info(dev, version:  DRIVER_VERSION ; dma %s %s\n,
-   use_dma ? enabled : disabled,
+   ep_info(dev, version:  DRIVER_VERSION ; %s\n,
dev-enhanced_mode ? enhanced mode : legacy mode);
retval = device_create_file(pdev-dev, dev_attr_registers);
if (retval)
-- 
2.1.3

--
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 01/17] net2280: Remove obsolete module param use_dma_chaining

2014-11-28 Thread Ricardo Ribalda Delgado
use_dma_chaining module parameter was designed to avoid creating one irq
per package on a group of packages (with the help of the driver's flag
no_interrupt).

Unfortunately, when this parameter is enabled, the driver fails to work
on both net2280 and 3380 chips.

This patch removes this parameter, which was disabled by default.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 147 ---
 1 file changed, 13 insertions(+), 134 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index d6411e0..08c16ee 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -12,11 +12,7 @@
  * the Mass Storage, Serial, and Ethernet/RNDIS gadget drivers
  * as well as Gadget Zero and Gadgetfs.
  *
- * DMA is enabled by default.  Drivers using transfer queues might use
- * DMA chaining to remove IRQ latencies between transfers.  (Except when
- * short OUT transfers happen.)  Drivers can use the req-no_interrupt
- * hint to completely eliminate some IRQs, if a later IRQ is guaranteed
- * and DMA chaining is enabled.
+ * DMA is enabled by default.
  *
  * MSI is enabled by default.  The legacy IRQ is used if MSI couldn't
  * be enabled.
@@ -85,7 +81,6 @@ static const char *const ep_name[] = {
 };
 
 /* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO)
- * use_dma_chaining -- dma descriptor queueing gives even more irq reduction
  *
  * The net2280 DMA engines are not tightly integrated with their FIFOs;
  * not all cases are (yet) handled well in this driver or the silicon.
@@ -93,12 +88,10 @@ static const char *const ep_name[] = {
  * These two parameters let you use PIO or more aggressive DMA.
  */
 static bool use_dma = true;
-static bool use_dma_chaining;
 static bool use_msi = true;
 
 /* modprobe net2280 use_dma=n etc */
 module_param(use_dma, bool, 0444);
-module_param(use_dma_chaining, bool, 0444);
 module_param(use_msi, bool, 0444);
 
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
@@ -202,15 +195,6 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
/* set speed-dependent max packet; may kick in high bandwidth */
set_max_speed(ep, max);
 
-   /* FIFO lines can't go to different packets.  PIO is ok, so
-* use it instead of troublesome (non-bulk) multi-packet DMA.
-*/
-   if (ep-dma  (max % 4) != 0  use_dma_chaining) {
-   ep_dbg(ep-dev, %s, no dma for maxpacket %d\n,
-   ep-ep.name, ep-ep.maxpacket);
-   ep-dma = NULL;
-   }
-
/* set type, direction, address; reset fifo counters */
writel(BIT(FIFO_FLUSH), ep-regs-ep_stat);
tmp = (desc-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK);
@@ -747,8 +731,7 @@ static void fill_dma_desc(struct net2280_ep *ep,
req-valid = valid;
if (valid)
dmacount |= BIT(VALID_BIT);
-   if (likely(!req-req.no_interrupt || !use_dma_chaining))
-   dmacount |= BIT(DMA_DONE_INTERRUPT_ENABLE);
+   dmacount |= BIT(DMA_DONE_INTERRUPT_ENABLE);
 
/* td-dmadesc = previously set by caller */
td-dmaaddr = cpu_to_le32 (req-req.dma);
@@ -862,8 +845,7 @@ static void start_dma(struct net2280_ep *ep, struct 
net2280_request *req)
req-td-dmadesc = cpu_to_le32 (ep-td_dma);
fill_dma_desc(ep, req, 1);
 
-   if (!use_dma_chaining)
-   req-td-dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
+   req-td-dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
 
start_queue(ep, tmp, req-td_dma);
 }
@@ -1150,64 +1132,12 @@ static void scan_dma_completions(struct net2280_ep *ep)
 static void restart_dma(struct net2280_ep *ep)
 {
struct net2280_request  *req;
-   u32 dmactl = dmactl_default;
 
if (ep-stopped)
return;
req = list_entry(ep-queue.next, struct net2280_request, queue);
 
-   if (!use_dma_chaining) {
-   start_dma(ep, req);
-   return;
-   }
-
-   /* the 2280 will be processing the queue unless queue hiccups after
-* the previous transfer:
-*  IN:   wanted automagic zlp, head doesn't (or vice versa)
-*DMA_FIFO_VALIDATE doesn't init from dma descriptors.
-*  OUT:  was usb-short, we must restart.
-*/
-   if (ep-is_in  !req-valid) {
-   struct net2280_request  *entry, *prev = NULL;
-   int reqmode, done = 0;
-
-   ep_dbg(ep-dev, %s dma hiccup td %p\n, ep-ep.name, req-td);
-   ep-in_fifo_validate = likely(req-req.zero ||
-   (req-req.length % ep-ep.maxpacket) != 0);
-   if (ep-in_fifo_validate)
-   dmactl |= BIT(DMA_FIFO_VALIDATE);
-   list_for_each_entry(entry, ep-queue, queue) {
-   __le32  dmacount

[PATCH 03/17] net2280: Remove module parameter use_msi

2014-11-28 Thread Ricardo Ribalda Delgado
Parameter use_msi was used to enable msi irq on usb338x chips, it was
enabled by default.

There is no reason to prefer non-msi irq on usb338x, and it falls back
to non msi on error.

Therefore remove this option.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 27b94c6..fc5c0a2 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -88,11 +88,9 @@ static const char *const ep_name[] = {
  * These two parameters let you use PIO or more aggressive DMA.
  */
 static bool use_dma = true;
-static bool use_msi = true;
 
 /* modprobe net2280 use_dma=n etc */
 module_param(use_dma, bool, 0444);
-module_param(use_msi, bool, 0444);
 
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
  * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
@@ -3426,7 +3424,7 @@ static void net2280_remove(struct pci_dev *pdev)
}
if (dev-got_irq)
free_irq(pdev-irq, dev);
-   if (use_msi  dev-quirks  PLX_SUPERSPEED)
+   if (dev-quirks  PLX_SUPERSPEED)
pci_disable_msi(pdev);
if (dev-regs)
iounmap(dev-regs);
@@ -3549,7 +3547,7 @@ static int net2280_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
goto done;
}
 
-   if (use_msi  (dev-quirks  PLX_SUPERSPEED))
+   if (dev-quirks  PLX_SUPERSPEED)
if (pci_enable_msi(pdev))
ep_err(dev, Failed to enable MSI mode\n);
 
-- 
2.1.3

--
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 02/17] net2280: remove full_speed module parameter

2014-11-28 Thread Ricardo Ribalda Delgado
This patch removes the full_speed parameter used force full-speed
operation.

It was designed exclusively for testing purposes, and there is no
reason to maintain this in a production kernel.

Reverts: 2f0760774711c957c395b31131b848043af98edf
Suggested-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 08c16ee..27b94c6 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -113,11 +113,6 @@ static bool enable_suspend;
 /* modprobe net2280 enable_suspend=1 etc */
 module_param(enable_suspend, bool, 0444);
 
-/* force full-speed operation */
-static bool full_speed;
-module_param(full_speed, bool, 0444);
-MODULE_PARM_DESC(full_speed, force full-speed mode -- for testing only!);
-
 #defineDIR_STRING(bAddress) (((bAddress)  USB_DIR_IN) ? in : out)
 
 static char *type_string(u8 bmAttributes)
@@ -2291,11 +2286,7 @@ static int net2280_start(struct usb_gadget *_gadget,
if (retval)
goto err_func;
 
-   /* Enable force-full-speed testing mode, if desired */
-   if (full_speed  (dev-quirks  PLX_LEGACY))
-   writel(BIT(FORCE_FULL_SPEED_MODE), dev-usb-xcvrdiag);
-
-   /* ... then enable host detection and ep0; and we're ready
+   /* enable host detection and ep0; and we're ready
 * for set_configuration as well as eventual disconnect.
 */
net2280_led_active(dev, 1);
@@ -2353,10 +2344,6 @@ static int net2280_stop(struct usb_gadget *_gadget)
 
net2280_led_active(dev, 0);
 
-   /* Disable full-speed test mode */
-   if (dev-quirks  PLX_LEGACY)
-   writel(0, dev-usb-xcvrdiag);
-
device_remove_file(dev-pdev-dev, dev_attr_function);
device_remove_file(dev-pdev-dev, dev_attr_queues);
 
@@ -3655,9 +3642,6 @@ static void net2280_shutdown(struct pci_dev *pdev)
/* disable the pullup so the host will think we're gone */
writel(0, dev-usb-usbctl);
 
-   /* Disable full-speed test mode */
-   if (dev-quirks  PLX_LEGACY)
-   writel(0, dev-usb-xcvrdiag);
 }
 
 
-- 
2.1.3

--
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 00/17] net2280: Code cleanout, improve debug and remove broken param

2014-11-28 Thread Ricardo Ribalda Delgado
This set of patches removes broken parameter use_dma_chaining, and the
unneeded full_speed,use_dma and use_msi.

Then does some code cleanout by removing duplicated and dead code.

Finally it removes the unconditional removed debug messages, since
they can be enabled by the user via dynamic printk.

Due to the fact that I am implementing the scather gatter on the top of
this tree I would like to get this merged/reviewed before continuing.

Ricardo Ribalda Delgado (17):
  net2280: Remove obsolete module param use_dma_chaining
  net2280: remove full_speed module parameter
  net2280: Remove module parameter use_msi
  net2280: Remove use_dma module parameter
  net2280: Remove dma_started field
  net2280: Remove restart_dma inline function definition
  net2280: Code cleanout remove ep_stdrsp function
  net2280: Remove field is_halt
  net2280: Remove function ep_stall
  net2280: Merge abort_dma for 228x and 338x
  net2280: Clean function net2280_queue
  net2280: Improve patching of defect 7374
  net2280: Remove function resume_dma
  net2280: Declare allow_status_338x as inline
  net2280: Simplify scan_dma_completions
  net2280: Move ASSERT_OUT_NAKING into out_flush
  net2280: Re-enable dynamic debug messages

 drivers/usb/gadget/udc/net2280.c | 525 ++-
 drivers/usb/gadget/udc/net2280.h |  23 +-
 2 files changed, 129 insertions(+), 419 deletions(-)

-- 
2.1.3

--
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 06/17] net2280: Remove restart_dma inline function definition

2014-11-28 Thread Ricardo Ribalda Delgado
Hello

Thanks for reviewing. I will fix it and resend it on the next version
of the patchset to avoid spamming the ML

I guess it is ok to add your Reviewed-by

Thanks!


On Fri, Nov 28, 2014 at 3:46 PM, Sergei Shtylyov
sergei.shtyl...@cogentembedded.com wrote:
 Hello.

 On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:

 restart_dma is not used before it is declaration. Therefore we can


s/it is/its/.

 remove this definition.


You're removing the declaration, not definition.

 Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
 ---
   drivers/usb/gadget/udc/net2280.c | 2 --
   1 file changed, 2 deletions(-)


 diff --git a/drivers/usb/gadget/udc/net2280.c
 b/drivers/usb/gadget/udc/net2280.c
 index 0340462..e8c36db 100644
 --- a/drivers/usb/gadget/udc/net2280.c
 +++ b/drivers/usb/gadget/udc/net2280.c
 @@ -1043,8 +1043,6 @@ dma_done(struct net2280_ep *ep,   struct
 net2280_request *req, u32 dmacount,
 done(ep, req, status);
   }

 -static void restart_dma(struct net2280_ep *ep);
 -
   static void scan_dma_completions(struct net2280_ep *ep)
   {
 /* only look at descriptors that were naturally retired,


 WBR, Sergei




-- 
Ricardo Ribalda
--
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: hard lockup with USB3380

2014-11-25 Thread Ricardo Ribalda Delgado
Could you print

count, req-valid and le32_to_cpu(req-td-dmacount) just before udelay(1)

Thanks!

On Tue, Nov 25, 2014 at 12:05 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 I added a ep_warn before and after the loop and right after connecting my Mac 
 it passes through that loop many times.
 Even without writing to the device I then get the lockup message while inside 
 the loop (ep-dev = ep-b).

 Paul.

 On 25 Nov 2014, at 02:06, Ricardo Ribalda Delgado ricardo.riba...@gmail.com 
 wrote:

 Hello

 Could you check if the code is stalled at this loop ?
 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/udc/net2280.c#n2594

 Regards!

 On Thu, Nov 13, 2014 at 3:37 PM, Paul Jones p.jo...@teclyn.com wrote:
 Hi,

 using the latest kernel from 
 https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/ with a USB3380 
 I get a kernel lockup after setting up an emulated drive and start using it.

 In order to reproduce:
dd if=/dev/zero of=somefile bs=64k count=102400
modprobe net2280
modprobe g_mass_storage file=somefile
 I then connect the cable to my Mac, quick format the drive (this works), 
 mount the drive (works as well) and then do write a large file:
dd if=/dev/zero of=mountpoint/file bs=64k count=10240
 I then almost immediately get:
 [  115.886330] [ cut here ]
 [  115.886335] WARNING: CPU: 3 PID: 0 at kernel/watchdog.c:267 
 watchdog_overflow_callback+0x9c/0xd0()
 [  115.886336] Watchdog detected hard LOCKUP on cpu 3
 [  115.886336] Modules linked in: g_mass_storage net2280 usb_f_mass_storage 
 libcomposite udc_core configfs snd_hda_codec_hdmi i915 
 snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel 
 snd_hda_controller snd_hda_codec intel_rapl x86_pkg_temp_thermal 
 intel_powerclamp coretemp kvm_intel kvm snd_hwdep snd_pcm joydev 
 snd_seq_midi hid_generic crct10dif_pclmul snd_seq_midi_event crc32_pclmul 
 snd_rawmidi ghash_clmulni_intel eeepc_wmi asus_wmi sparse_keymap 
 aesni_intel drm_kms_helper snd_seq drm usbhid hid snd_seq_device aes_x86_64 
 lrw gf128mul glue_helper snd_timer ablk_helper cryptd snd mei_me mei 
 serio_raw soundcore lpc_ich i2c_algo_bit wmi video mac_hid tpm_infineon 
 rfcomm bnep bluetooth parport_pc ppdev lp parport e1000e psmouse r8169 ptp 
 ahci libahci pps_core mii
 [  115.886361] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.17.0-rc5+ #2
 [  115.886362] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
 [  115.886363]  0009 88041fb86c10 81746707 
 88041fb86c58
 [  115.886364]  88041fb86c48 8106c93d 8804097fc000 
 
 [  115.886365]  88041fb86d70  88041fb86ef8 
 88041fb86ca8
 [  115.886367] Call Trace:
 [  115.886368]  NMI  [81746707] dump_stack+0x45/0x56
 [  115.886373]  [8106c93d] warn_slowpath_common+0x7d/0xa0
 [  115.886374]  [8106c9ac] warn_slowpath_fmt+0x4c/0x50
 [  115.886376]  [8111a23c] watchdog_overflow_callback+0x9c/0xd0
 [  115.886379]  [811579ed] __perf_event_overflow+0x8d/0x230
 [  115.886381]  [81029db8] ? x86_perf_event_set_period+0xe8/0x150
 [  115.886383]  [81158454] perf_event_overflow+0x14/0x20
 [  115.886385]  [8103136d] intel_pmu_handle_irq+0x1ed/0x3e0
 [  115.886386]  [81028abb] perf_event_nmi_handler+0x2b/0x50
 [  115.886388]  [81016fd8] nmi_handle+0x88/0x120
 [  115.886389]  [810175de] default_do_nmi+0xde/0x140
 [  115.886390]  [810176c8] do_nmi+0x88/0xc0
 [  115.886392]  [81751171] end_repeat_nmi+0x1e/0x2e
 [  115.886394]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886395]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886396]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886397]  EOE  IRQ  [813808dc] 
 __const_udelay+0x2c/0x30
 [  115.886400]  [a054be3a] net2280_irq+0x76a/0x15a8 [net2280]
 [  115.886402]  [8148df1c] ? add_interrupt_randomness+0x3c/0x1f0
 [  115.886405]  [810c090e] handle_irq_event_percpu+0x3e/0x1a0
 [  115.886407]  [810c0aad] handle_irq_event+0x3d/0x60
 [  115.886408]  [810c3657] handle_edge_irq+0x77/0x130
 [  115.886410]  [810154ee] handle_irq+0x1e/0x30
 [  115.886411]  [81751b6f] do_IRQ+0x4f/0xf0
 [  115.886412]  [8174f9ed] common_interrupt+0x6d/0x6d
 [  115.886413]  EOI  [815f4490] ? cpuidle_enter_state+0x70/0x170
 [  115.886416]  [815f4647] cpuidle_enter+0x17/0x20
 [  115.886417]  [810aad9d] cpu_startup_entry+0x31d/0x340
 [  115.886419]  [810dde88] ? 
 clockevents_config_and_register+0x28/0x30
 [  115.886421]  [81045237] start_secondary+0x1a7/0x250
 [  115.886422] ---[ end trace e31adb6e2f340f5d ]—

 Output from lspci:
 00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM 
 Controller (rev 06)
 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core 
 Processor PCI Express

Re: hard lockup with USB3380

2014-11-25 Thread Ricardo Ribalda Delgado
hmm it seems that the code is waiting for a dma to complete. Please print

ep-dma-dmactl
ep-dma-dmastat
ep-dma-dmacount
ep-dma-dmadesc
req-td_dma
ep-regs-ep_stat



Thanks

On Tue, Nov 25, 2014 at 1:58 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 count = 0, req-valid = 1,  le32_to_cpu(req-td-dmacount) =  2952791040

 Paul.

 On 25 Nov 2014, at 13:09, Ricardo Ribalda Delgado ricardo.riba...@gmail.com 
 wrote:

 Could you print

 count, req-valid and le32_to_cpu(req-td-dmacount) just before udelay(1)

 Thanks!

 On Tue, Nov 25, 2014 at 12:05 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 I added a ep_warn before and after the loop and right after connecting my 
 Mac it passes through that loop many times.
 Even without writing to the device I then get the lockup message while 
 inside the loop (ep-dev = ep-b).

 Paul.

 On 25 Nov 2014, at 02:06, Ricardo Ribalda Delgado 
 ricardo.riba...@gmail.com wrote:

 Hello

 Could you check if the code is stalled at this loop ?
 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/udc/net2280.c#n2594

 Regards!

 On Thu, Nov 13, 2014 at 3:37 PM, Paul Jones p.jo...@teclyn.com wrote:
 Hi,

 using the latest kernel from 
 https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/ with a 
 USB3380 I get a kernel lockup after setting up an emulated drive and 
 start using it.

 In order to reproduce:
   dd if=/dev/zero of=somefile bs=64k count=102400
   modprobe net2280
   modprobe g_mass_storage file=somefile
 I then connect the cable to my Mac, quick format the drive (this works), 
 mount the drive (works as well) and then do write a large file:
   dd if=/dev/zero of=mountpoint/file bs=64k count=10240
 I then almost immediately get:
 [  115.886330] [ cut here ]
 [  115.886335] WARNING: CPU: 3 PID: 0 at kernel/watchdog.c:267 
 watchdog_overflow_callback+0x9c/0xd0()
 [  115.886336] Watchdog detected hard LOCKUP on cpu 3
 [  115.886336] Modules linked in: g_mass_storage net2280 
 usb_f_mass_storage libcomposite udc_core configfs snd_hda_codec_hdmi i915 
 snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel 
 snd_hda_controller snd_hda_codec intel_rapl x86_pkg_temp_thermal 
 intel_powerclamp coretemp kvm_intel kvm snd_hwdep snd_pcm joydev 
 snd_seq_midi hid_generic crct10dif_pclmul snd_seq_midi_event crc32_pclmul 
 snd_rawmidi ghash_clmulni_intel eeepc_wmi asus_wmi sparse_keymap 
 aesni_intel drm_kms_helper snd_seq drm usbhid hid snd_seq_device 
 aes_x86_64 lrw gf128mul glue_helper snd_timer ablk_helper cryptd snd 
 mei_me mei serio_raw soundcore lpc_ich i2c_algo_bit wmi video mac_hid 
 tpm_infineon rfcomm bnep bluetooth parport_pc ppdev lp parport e1000e 
 psmouse r8169 ptp ahci libahci pps_core mii
 [  115.886361] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.17.0-rc5+ #2
 [  115.886362] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
 [  115.886363]  0009 88041fb86c10 81746707 
 88041fb86c58
 [  115.886364]  88041fb86c48 8106c93d 8804097fc000 
 
 [  115.886365]  88041fb86d70  88041fb86ef8 
 88041fb86ca8
 [  115.886367] Call Trace:
 [  115.886368]  NMI  [81746707] dump_stack+0x45/0x56
 [  115.886373]  [8106c93d] warn_slowpath_common+0x7d/0xa0
 [  115.886374]  [8106c9ac] warn_slowpath_fmt+0x4c/0x50
 [  115.886376]  [8111a23c] watchdog_overflow_callback+0x9c/0xd0
 [  115.886379]  [811579ed] __perf_event_overflow+0x8d/0x230
 [  115.886381]  [81029db8] ? 
 x86_perf_event_set_period+0xe8/0x150
 [  115.886383]  [81158454] perf_event_overflow+0x14/0x20
 [  115.886385]  [8103136d] intel_pmu_handle_irq+0x1ed/0x3e0
 [  115.886386]  [81028abb] perf_event_nmi_handler+0x2b/0x50
 [  115.886388]  [81016fd8] nmi_handle+0x88/0x120
 [  115.886389]  [810175de] default_do_nmi+0xde/0x140
 [  115.886390]  [810176c8] do_nmi+0x88/0xc0
 [  115.886392]  [81751171] end_repeat_nmi+0x1e/0x2e
 [  115.886394]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886395]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886396]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886397]  EOE  IRQ  [813808dc] 
 __const_udelay+0x2c/0x30
 [  115.886400]  [a054be3a] net2280_irq+0x76a/0x15a8 [net2280]
 [  115.886402]  [8148df1c] ? add_interrupt_randomness+0x3c/0x1f0
 [  115.886405]  [810c090e] handle_irq_event_percpu+0x3e/0x1a0
 [  115.886407]  [810c0aad] handle_irq_event+0x3d/0x60
 [  115.886408]  [810c3657] handle_edge_irq+0x77/0x130
 [  115.886410]  [810154ee] handle_irq+0x1e/0x30
 [  115.886411]  [81751b6f] do_IRQ+0x4f/0xf0
 [  115.886412]  [8174f9ed] common_interrupt+0x6d/0x6d
 [  115.886413]  EOI  [815f4490] ? 
 cpuidle_enter_state+0x70/0x170
 [  115.886416]  [815f4647] cpuidle_enter+0x17/0x20
 [  115.886417]  [810aad9d

Re: hard lockup with USB3380

2014-11-25 Thread Ricardo Ribalda Delgado
Could you try
if (likely(t  (BIT(FIFO_EMPTY) | BIT(NAK_OUT_PACKETS{

instead of

if (likely(t  BIT(FIFO_EMPTY)))


And tell if it works better

On Tue, Nov 25, 2014 at 2:58 PM, Paul Jones p.jo...@teclyn.com wrote:
 dmactl=37158946, dmastat=50331648, dmacount=805306368, dmadesc=778727536, 
 epstat=16528, td_dma=ce40c050

 Paul.

 On 25 Nov 2014, at 14:08, Ricardo Ribalda Delgado ricardo.riba...@gmail.com 
 wrote:

 hmm it seems that the code is waiting for a dma to complete. Please print

 ep-dma-dmactl
 ep-dma-dmastat
 ep-dma-dmacount
 ep-dma-dmadesc
 req-td_dma
 ep-regs-ep_stat



 Thanks

 On Tue, Nov 25, 2014 at 1:58 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 count = 0, req-valid = 1,  le32_to_cpu(req-td-dmacount) =  2952791040

 Paul.

 On 25 Nov 2014, at 13:09, Ricardo Ribalda Delgado 
 ricardo.riba...@gmail.com wrote:

 Could you print

 count, req-valid and le32_to_cpu(req-td-dmacount) just before udelay(1)

 Thanks!

 On Tue, Nov 25, 2014 at 12:05 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 I added a ep_warn before and after the loop and right after connecting my 
 Mac it passes through that loop many times.
 Even without writing to the device I then get the lockup message while 
 inside the loop (ep-dev = ep-b).

 Paul.

 On 25 Nov 2014, at 02:06, Ricardo Ribalda Delgado 
 ricardo.riba...@gmail.com wrote:

 Hello

 Could you check if the code is stalled at this loop ?
 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/udc/net2280.c#n2594

 Regards!

 On Thu, Nov 13, 2014 at 3:37 PM, Paul Jones p.jo...@teclyn.com wrote:
 Hi,

 using the latest kernel from 
 https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/ with a 
 USB3380 I get a kernel lockup after setting up an emulated drive and 
 start using it.

 In order to reproduce:
  dd if=/dev/zero of=somefile bs=64k count=102400
  modprobe net2280
  modprobe g_mass_storage file=somefile
 I then connect the cable to my Mac, quick format the drive (this 
 works), mount the drive (works as well) and then do write a large file:
  dd if=/dev/zero of=mountpoint/file bs=64k count=10240
 I then almost immediately get:
 [  115.886330] [ cut here ]
 [  115.886335] WARNING: CPU: 3 PID: 0 at kernel/watchdog.c:267 
 watchdog_overflow_callback+0x9c/0xd0()
 [  115.886336] Watchdog detected hard LOCKUP on cpu 3
 [  115.886336] Modules linked in: g_mass_storage net2280 
 usb_f_mass_storage libcomposite udc_core configfs snd_hda_codec_hdmi 
 i915 snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel 
 snd_hda_controller snd_hda_codec intel_rapl x86_pkg_temp_thermal 
 intel_powerclamp coretemp kvm_intel kvm snd_hwdep snd_pcm joydev 
 snd_seq_midi hid_generic crct10dif_pclmul snd_seq_midi_event 
 crc32_pclmul snd_rawmidi ghash_clmulni_intel eeepc_wmi asus_wmi 
 sparse_keymap aesni_intel drm_kms_helper snd_seq drm usbhid hid 
 snd_seq_device aes_x86_64 lrw gf128mul glue_helper snd_timer 
 ablk_helper cryptd snd mei_me mei serio_raw soundcore lpc_ich 
 i2c_algo_bit wmi video mac_hid tpm_infineon rfcomm bnep bluetooth 
 parport_pc ppdev lp parport e1000e psmouse r8169 ptp ahci libahci 
 pps_core mii
 [  115.886361] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.17.0-rc5+ #2
 [  115.886362] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
 [  115.886363]  0009 88041fb86c10 81746707 
 88041fb86c58
 [  115.886364]  88041fb86c48 8106c93d 8804097fc000 
 
 [  115.886365]  88041fb86d70  88041fb86ef8 
 88041fb86ca8
 [  115.886367] Call Trace:
 [  115.886368]  NMI  [81746707] dump_stack+0x45/0x56
 [  115.886373]  [8106c93d] warn_slowpath_common+0x7d/0xa0
 [  115.886374]  [8106c9ac] warn_slowpath_fmt+0x4c/0x50
 [  115.886376]  [8111a23c] 
 watchdog_overflow_callback+0x9c/0xd0
 [  115.886379]  [811579ed] __perf_event_overflow+0x8d/0x230
 [  115.886381]  [81029db8] ? 
 x86_perf_event_set_period+0xe8/0x150
 [  115.886383]  [81158454] perf_event_overflow+0x14/0x20
 [  115.886385]  [8103136d] intel_pmu_handle_irq+0x1ed/0x3e0
 [  115.886386]  [81028abb] perf_event_nmi_handler+0x2b/0x50
 [  115.886388]  [81016fd8] nmi_handle+0x88/0x120
 [  115.886389]  [810175de] default_do_nmi+0xde/0x140
 [  115.886390]  [810176c8] do_nmi+0x88/0xc0
 [  115.886392]  [81751171] end_repeat_nmi+0x1e/0x2e
 [  115.886394]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886395]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886396]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886397]  EOE  IRQ  [813808dc] 
 __const_udelay+0x2c/0x30
 [  115.886400]  [a054be3a] net2280_irq+0x76a/0x15a8 [net2280]
 [  115.886402]  [8148df1c] ? 
 add_interrupt_randomness+0x3c/0x1f0
 [  115.886405]  [810c090e] handle_irq_event_percpu+0x3e/0x1a0
 [  115.886407]  [810c0aad

Re: hard lockup with USB3380

2014-11-25 Thread Ricardo Ribalda Delgado
One last try :)

Instead of:

if (likely(t  BIT(FIFO_EMPTY))) {

have this:

if ( t  BIT(NAK_OUT_PACKETS)){
   count = readl(ep-dma-dmacount);
   count = DMA_BYTE_COUNT_MASK;
   break;
}

if (likely(t  BIT(FIFO_EMPTY))) {



On Tue, Nov 25, 2014 at 3:54 PM, Paul Jones p.jo...@teclyn.com wrote:
 Ricardo,

 it no longer locks up but if I try to write to the drive, I get cycles of:
 [ 2334.127653] [ cut here ]
 [ 2334.128318] WARNING: CPU: 0 PID: 2140 at 
 drivers/usb/gadget/udc/net2280.c:816 start_dma+0x153/0x160 [net2280]()
 [ 2334.129105] Modules linked in: g_mass_storage usb_f_mass_storage 
 libcomposite configfs net2280 udc_core snd_hda_codec_hdmi i915 rfcomm bnep 
 bluetooth snd_hda_codec_realtek snd_hda_codec_generic intel_rapl 
 x86_pkg_temp_thermal snd_hda_intel intel_powerclamp coretemp 
 snd_hda_controller kvm_intel snd_hda_codec kvm drm_kms_helper snd_hwdep 
 snd_pcm drm snd_seq_midi joydev snd_seq_midi_event snd_rawmidi hid_generic 
 snd_seq eeepc_wmi asus_wmi sparse_keymap crct10dif_pclmul usbhid crc32_pclmul 
 ghash_clmulni_intel aesni_intel snd_seq_device snd_timer aes_x86_64 hid lrw 
 gf128mul glue_helper snd ablk_helper mei_me mei cryptd serio_raw lpc_ich 
 i2c_algo_bit wmi soundcore video tpm_infineon mac_hid parport_pc ppdev lp 
 parport e1000e psmouse r8169 ahci ptp libahci mii pps_core
 [ 2334.132731] CPU: 0 PID: 2140 Comm: file-storage Tainted: GW  
 3.17.0-rc5+ #2
 [ 2334.133438] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
 [ 2334.134146]  0009 8804087a3d28 81746707 
 
 [ 2334.134863]  8804087a3d60 8106c93d 88002e693478 
 8803efd14480
 [ 2334.135583]  c900018fc1a0 8803efd144e8 88002e693320 
 8804087a3d70
 [ 2334.136299] Call Trace:
 [ 2334.137023]  [81746707] dump_stack+0x45/0x56
 [ 2334.137734]  [8106c93d] warn_slowpath_common+0x7d/0xa0
 [ 2334.138433]  [8106ca1a] warn_slowpath_null+0x1a/0x20
 [ 2334.139109]  [a0372103] start_dma+0x153/0x160 [net2280]
 [ 2334.139795]  [a0373b1b] net2280_queue+0x2db/0x480 [net2280]
 [ 2334.140449]  [a03b94f1] start_transfer.isra.32+0x71/0xe0 
 [usb_f_mass_storage]
 [ 2334.141128]  [a03b959e] start_out_transfer+0x3e/0x80 
 [usb_f_mass_storage]
 [ 2334.141772]  [a03ba967] fsg_main_thread+0x207/0x17f0 
 [usb_f_mass_storage]
 [ 2334.142374]  [81749eda] ? __schedule+0x37a/0x830
 [ 2334.142950]  [a03ba760] ? handle_exception+0x460/0x460 
 [usb_f_mass_storage]
 [ 2334.143534]  [8108a3e2] kthread+0xd2/0xf0
 [ 2334.144054]  [8108a310] ? kthread_create_on_node+0x180/0x180
 [ 2334.144595]  [8174ecbc] ret_from_fork+0x7c/0xb0
 [ 2334.145155]  [8108a310] ? kthread_create_on_node+0x180/0x180
 [ 2334.145699] ---[ end trace 4ded8927b95f4eec ]---
 followed by:
 [ 2396.154501] net2280 :01:00.0: The dmastat return = 5002!!
 [ 2396.253653] g_mass_storage gadget: super-speed config #1: Linux 
 File-Backed Storage

 Unplugging  and re-plugging the USB cable does allow me to remount the volume.

 Paul.
 On 25 Nov 2014, at 15:24, Ricardo Ribalda Delgado ricardo.riba...@gmail.com 
 wrote:

 Could you try
 if (likely(t  (BIT(FIFO_EMPTY) | BIT(NAK_OUT_PACKETS{

 instead of

 if (likely(t  BIT(FIFO_EMPTY)))


 And tell if it works better




-- 
Ricardo Ribalda
--
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: net2280: is use_dma_chaining obsolete?

2014-11-25 Thread Ricardo Ribalda Delgado
Hello Felipe

On Tue, Nov 25, 2014 at 3:54 PM, Felipe Balbi ba...@ti.com wrote:
 Hi,

 On Tue, Nov 25, 2014 at 02:44:16AM +0100, Ricardo Ribalda Delgado wrote:
  might be better if you can fix the code, instead. We have a better
  scatter-gather support in the framework itself.

 As I understand it, the code was designed to reduce the number of irqs
 when you expect to send X consecutive packages. In that scenario you
 only want an irq at the end. ie, u_ether supports it. It was not
 designed for sg.

 The problem is that the driver only allocates one sg descriptor per
 endpoint, without the possibility of chaining the request I dont see

 right, but what I'm is that we don't want the UDC manually allocating SG
 lists and moving req-buf to that sg, we want the gadget driver to pass
 a properly formatted sg to the UDC. Currently, only UASP implementation
 on top of target framework is doing that. Eventually, we should have
 more functions passing sgs to the UDC.

i understand. What I want to do is remove the use_dma_chaining and
then add support for sg.



 how can this can work. And it does not work on my hw.

 If you could confirm what I am saying about the dma_chaining by
 testing it on net2280 then I think we should remote the module
 parameter, because it will only confuse the user and also ofuscates a
 lot the code.

 Unfortunately I don't have net2280 and I keep forgetting if Alan has
 net2280 or net2272.

It doesnt really matter. Any will do for the test

@Alan, could you please give it a try with is use_dma_chaining obsolete=1


  UDC needs to set gadget-sg_supported and a pointer to the sg should be
  passed in by the gadget driver through usb_request-sg.

 I could try to implement pure sg on net2282.c , but I will only be
 able to test it on usb338x hardware. If you could test it later I can
 give it a try.

 Regards!

 --
 Ricardo Ribalda

 --
 balbi



-- 
Ricardo Ribalda
--
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: net2280: is use_dma_chaining obsolete?

2014-11-25 Thread Ricardo Ribalda Delgado
On Tue, Nov 25, 2014 at 4:32 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Tue, 25 Nov 2014, Ricardo Ribalda Delgado wrote:

 Hello Felipe

 On Tue, Nov 25, 2014 at 3:54 PM, Felipe Balbi ba...@ti.com wrote:
  Hi,
 
  On Tue, Nov 25, 2014 at 02:44:16AM +0100, Ricardo Ribalda Delgado wrote:
   might be better if you can fix the code, instead. We have a better
   scatter-gather support in the framework itself.
 
  As I understand it, the code was designed to reduce the number of irqs
  when you expect to send X consecutive packages. In that scenario you
  only want an irq at the end. ie, u_ether supports it. It was not
  designed for sg.
 
  The problem is that the driver only allocates one sg descriptor per
  endpoint, without the possibility of chaining the request I dont see
 
  right, but what I'm is that we don't want the UDC manually allocating SG
  lists and moving req-buf to that sg, we want the gadget driver to pass
  a properly formatted sg to the UDC. Currently, only UASP implementation
  on top of target framework is doing that. Eventually, we should have
  more functions passing sgs to the UDC.

 i understand. What I want to do is remove the use_dma_chaining and
 then add support for sg.


 
  how can this can work. And it does not work on my hw.
 
  If you could confirm what I am saying about the dma_chaining by
  testing it on net2280 then I think we should remote the module
  parameter, because it will only confuse the user and also ofuscates a
  lot the code.
 
  Unfortunately I don't have net2280 and I keep forgetting if Alan has
  net2280 or net2272.

 It doesnt really matter. Any will do for the test

 @Alan, could you please give it a try with is use_dma_chaining obsolete=1

 Give what a try?  What exactly would you like me to do?

Hello Alan

Could you test if the parameter dma_chaining works on your board with
the current kernel?

#on the target
modprobe net2280 use_dma_chaining=1 #(it it is already loaded, rmmod)
dd if=/dev/zero of=/tmp/mem bs=256M count=1
modprobe g_mass_storage file=/tmp/mem

#on the host
#Check if /dev/sdX has apperared
dd if=/dev/sdX of=/dev/null


Thanks!




 Alan Stern




-- 
Ricardo Ribalda
--
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: net2280: is use_dma_chaining obsolete?

2014-11-25 Thread Ricardo Ribalda Delgado
Hello

On Tue, Nov 25, 2014 at 6:05 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Tue, 25 Nov 2014, Ricardo Ribalda Delgado wrote:

 Hello Alan

 Could you test if the parameter dma_chaining works on your board with
 the current kernel?

 #on the target
 modprobe net2280 use_dma_chaining=1 #(it it is already loaded, rmmod)
 dd if=/dev/zero of=/tmp/mem bs=256M count=1
 modprobe g_mass_storage file=/tmp/mem

 #on the host
 #Check if /dev/sdX has apperared
 dd if=/dev/sdX of=/dev/null

 It doesn't even come close to working.  The system grinds to a halt
 when the UDC fails to send the third bulk-out packet.  The first two
 packets get sent okay.

Exactly the same that I am experiencing. I am preparing a patch that
removes the option, does some dma cleanout and then add support for
sg.

I might ask you to test it in the future :)

Thanks for your help!


 Alan Stern




-- 
Ricardo Ribalda
--
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: net2280: is use_dma_chaining obsolete?

2014-11-25 Thread Ricardo Ribalda Delgado
Now that I open the pandora box

Is there any reason to have use_dma, use_msi, enable_suspend and
full_speed as parameters? I might as well remove them.

Regards!

On Tue, Nov 25, 2014 at 6:10 PM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 Hello

 On Tue, Nov 25, 2014 at 6:05 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Tue, 25 Nov 2014, Ricardo Ribalda Delgado wrote:

 Hello Alan

 Could you test if the parameter dma_chaining works on your board with
 the current kernel?

 #on the target
 modprobe net2280 use_dma_chaining=1 #(it it is already loaded, rmmod)
 dd if=/dev/zero of=/tmp/mem bs=256M count=1
 modprobe g_mass_storage file=/tmp/mem

 #on the host
 #Check if /dev/sdX has apperared
 dd if=/dev/sdX of=/dev/null

 It doesn't even come close to working.  The system grinds to a halt
 when the UDC fails to send the third bulk-out packet.  The first two
 packets get sent okay.

 Exactly the same that I am experiencing. I am preparing a patch that
 removes the option, does some dma cleanout and then add support for
 sg.

 I might ask you to test it in the future :)

 Thanks for your help!


 Alan Stern




 --
 Ricardo Ribalda



-- 
Ricardo Ribalda
--
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: net2280: is use_dma_chaining obsolete?

2014-11-25 Thread Ricardo Ribalda Delgado
hello Sebastian

On Tue, Nov 25, 2014 at 6:18 PM, Sebastian Andrzej Siewior
bige...@linutronix.de wrote:
 On 11/25/2014 06:10 PM, Ricardo Ribalda Delgado wrote:
 Exactly the same that I am experiencing. I am preparing a patch that
 removes the option, does some dma cleanout and then add support for
 sg.

 why not look at reg-no_interrupt?

It was also looking at reg-no_interrupt. The logic was:

if (!use_dma_chaining)
  ignore reg-no_interrupt
else
  check reg-no_interrupt

The issue is that the implementation under use_dma_chaining does not work.

Thanks!


 Sebastian



-- 
Ricardo Ribalda
--
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


net2280: is use_dma_chaining obsolete?

2014-11-24 Thread Ricardo Ribalda Delgado
Hello

I cannot make work the parameter use_dma_chaining with g_mass_storage
and a usb3380 device. The initial enumeration works, but after a
couple of frames the enumeration is restarted. If I compare usbmon
with and without the parameter I can see that the device fails to
reply to the host.

 While going through the code I realized that there is only on scathe
gather descriptor per endpoint and I wonder how can you make work a
dma_chain with only one descriptor!.

 I think the driver is expecting a special pattern of execution or
maybe (probably) I am not understanding the code right.

  Can somebody confirm that this parameter works on a net2280, and if
not, can I remove the obsolete code, so no other person loses some
hours and gray hair :) ?

  Thanks!

-- 
Ricardo Ribalda
--
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: hard lockup with USB3380

2014-11-24 Thread Ricardo Ribalda Delgado
Hello

Could you check if the code is stalled at this loop ?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/udc/net2280.c#n2594

Regards!

On Thu, Nov 13, 2014 at 3:37 PM, Paul Jones p.jo...@teclyn.com wrote:
 Hi,

 using the latest kernel from 
 https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/ with a USB3380 I 
 get a kernel lockup after setting up an emulated drive and start using it.

 In order to reproduce:
 dd if=/dev/zero of=somefile bs=64k count=102400
 modprobe net2280
 modprobe g_mass_storage file=somefile
 I then connect the cable to my Mac, quick format the drive (this works), 
 mount the drive (works as well) and then do write a large file:
 dd if=/dev/zero of=mountpoint/file bs=64k count=10240
 I then almost immediately get:
 [  115.886330] [ cut here ]
 [  115.886335] WARNING: CPU: 3 PID: 0 at kernel/watchdog.c:267 
 watchdog_overflow_callback+0x9c/0xd0()
 [  115.886336] Watchdog detected hard LOCKUP on cpu 3
 [  115.886336] Modules linked in: g_mass_storage net2280 usb_f_mass_storage 
 libcomposite udc_core configfs snd_hda_codec_hdmi i915 snd_hda_codec_realtek 
 snd_hda_codec_generic snd_hda_intel snd_hda_controller snd_hda_codec 
 intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm 
 snd_hwdep snd_pcm joydev snd_seq_midi hid_generic crct10dif_pclmul 
 snd_seq_midi_event crc32_pclmul snd_rawmidi ghash_clmulni_intel eeepc_wmi 
 asus_wmi sparse_keymap aesni_intel drm_kms_helper snd_seq drm usbhid hid 
 snd_seq_device aes_x86_64 lrw gf128mul glue_helper snd_timer ablk_helper 
 cryptd snd mei_me mei serio_raw soundcore lpc_ich i2c_algo_bit wmi video 
 mac_hid tpm_infineon rfcomm bnep bluetooth parport_pc ppdev lp parport e1000e 
 psmouse r8169 ptp ahci libahci pps_core mii
 [  115.886361] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 3.17.0-rc5+ #2
 [  115.886362] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
 [  115.886363]  0009 88041fb86c10 81746707 
 88041fb86c58
 [  115.886364]  88041fb86c48 8106c93d 8804097fc000 
 
 [  115.886365]  88041fb86d70  88041fb86ef8 
 88041fb86ca8
 [  115.886367] Call Trace:
 [  115.886368]  NMI  [81746707] dump_stack+0x45/0x56
 [  115.886373]  [8106c93d] warn_slowpath_common+0x7d/0xa0
 [  115.886374]  [8106c9ac] warn_slowpath_fmt+0x4c/0x50
 [  115.886376]  [8111a23c] watchdog_overflow_callback+0x9c/0xd0
 [  115.886379]  [811579ed] __perf_event_overflow+0x8d/0x230
 [  115.886381]  [81029db8] ? x86_perf_event_set_period+0xe8/0x150
 [  115.886383]  [81158454] perf_event_overflow+0x14/0x20
 [  115.886385]  [8103136d] intel_pmu_handle_irq+0x1ed/0x3e0
 [  115.886386]  [81028abb] perf_event_nmi_handler+0x2b/0x50
 [  115.886388]  [81016fd8] nmi_handle+0x88/0x120
 [  115.886389]  [810175de] default_do_nmi+0xde/0x140
 [  115.886390]  [810176c8] do_nmi+0x88/0xc0
 [  115.886392]  [81751171] end_repeat_nmi+0x1e/0x2e
 [  115.886394]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886395]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886396]  [8138099a] ? delay_tsc+0x3a/0x80
 [  115.886397]  EOE  IRQ  [813808dc] __const_udelay+0x2c/0x30
 [  115.886400]  [a054be3a] net2280_irq+0x76a/0x15a8 [net2280]
 [  115.886402]  [8148df1c] ? add_interrupt_randomness+0x3c/0x1f0
 [  115.886405]  [810c090e] handle_irq_event_percpu+0x3e/0x1a0
 [  115.886407]  [810c0aad] handle_irq_event+0x3d/0x60
 [  115.886408]  [810c3657] handle_edge_irq+0x77/0x130
 [  115.886410]  [810154ee] handle_irq+0x1e/0x30
 [  115.886411]  [81751b6f] do_IRQ+0x4f/0xf0
 [  115.886412]  [8174f9ed] common_interrupt+0x6d/0x6d
 [  115.886413]  EOI  [815f4490] ? cpuidle_enter_state+0x70/0x170
 [  115.886416]  [815f4647] cpuidle_enter+0x17/0x20
 [  115.886417]  [810aad9d] cpu_startup_entry+0x31d/0x340
 [  115.886419]  [810dde88] ? 
 clockevents_config_and_register+0x28/0x30
 [  115.886421]  [81045237] start_secondary+0x1a7/0x250
 [  115.886422] ---[ end trace e31adb6e2f340f5d ]—

 Output from lspci:
 00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller 
 (rev 06)
 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor 
 PCI Express x16 Controller (rev 06)
 00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen 
 Core Processor Integrated Graphics Controller (rev 06)
 00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core 
 Processor HD Audio Controller (rev 06)
 00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family 
 USB xHCI (rev 05)
 00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series 
 Chipset Family MEI Controller #1 (rev 04)
 00:16.3 Serial 

Re: net2280: is use_dma_chaining obsolete?

2014-11-24 Thread Ricardo Ribalda Delgado
Hello Felipe



 might be better if you can fix the code, instead. We have a better
 scatter-gather support in the framework itself.

As I understand it, the code was designed to reduce the number of irqs
when you expect to send X consecutive packages. In that scenario you
only want an irq at the end. ie, u_ether supports it. It was not
designed for sg.

The problem is that the driver only allocates one sg descriptor per
endpoint, without the possibility of chaining the request I dont see
how can this can work. And it does not work on my hw.

If you could confirm what I am saying about the dma_chaining by
testing it on net2280 then I think we should remote the module
parameter, because it will only confuse the user and also ofuscates a
lot the code.


 UDC needs to set gadget-sg_supported and a pointer to the sg should be
 passed in by the gadget driver through usb_request-sg.

I could try to implement pure sg on net2282.c , but I will only be
able to test it on usb338x hardware. If you could test it later I can
give it a try.

Regards!

-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-09-01 Thread Ricardo Ribalda Delgado
Hello

The promised dmesg output. Still some xhci_drop_endpoint called with...

Thanks!

Sep  1 10:52:00 neopili kernel: [  193.123108] usb 2-2: new SuperSpeed
USB device number 2 using xhci_hcd
Sep  1 10:52:00 neopili kernel: [  193.142204] usb 2-2: New USB device
found, idVendor=0525, idProduct=a4a5
Sep  1 10:52:00 neopili kernel: [  193.142211] usb 2-2: New USB device
strings: Mfr=3, Product=4, SerialNumber=0
Sep  1 10:52:00 neopili kernel: [  193.142215] usb 2-2: Product: Mass
Storage Gadget
Sep  1 10:52:00 neopili kernel: [  193.142218] usb 2-2: Manufacturer:
Linux 3.16.0-qtec-standard+ with net2280
Sep  1 10:52:00 neopili systemd-udevd[221]: unknown key
'SYSFS{manufacturer}' in /etc/udev/rules.d/52-digilent-usb.rules:35
Sep  1 10:52:00 neopili systemd-udevd[221]: invalid rule
'/etc/udev/rules.d/52-digilent-usb.rules:35'
Sep  1 10:52:00 neopili systemd-udevd[221]: unknown key 'BUS' in
/lib/udev/rules.d/60-libgnuradio-fcd3.7.3.rules:2
Sep  1 10:52:00 neopili systemd-udevd[221]: invalid rule
'/lib/udev/rules.d/60-libgnuradio-fcd3.7.3.rules:2'
Sep  1 10:52:00 neopili systemd-udevd[1720]: failed to execute
'/lib/udev/mtp-probe' 'mtp-probe
/sys/devices/pci:00/:00:1c.6/:0e:00.0/usb2/2-2 2 2': No
such file or directory
Sep  1 10:52:00 neopili kernel: [  193.289553] usb-storage 2-2:1.0:
USB Mass Storage device detected
Sep  1 10:52:00 neopili kernel: [  193.289745] usb-storage 2-2:1.0:
Quirks match for vid 0525 pid a4a5: 1
Sep  1 10:52:00 neopili kernel: [  193.289820] scsi host6: usb-storage 2-2:1.0
Sep  1 10:52:00 neopili kernel: [  193.289991] usbcore: registered new
interface driver usb-storage
Sep  1 10:52:00 neopili kernel: [  193.312632] usbcore: registered new
interface driver uas
Sep  1 10:52:01 neopili kernel: [  194.288067] scsi 6:0:0:0:
Direct-Access LinuxFile-Stor Gadget 0316 PQ: 0 ANSI: 2
Sep  1 10:52:01 neopili kernel: [  194.288957] sd 6:0:0:0: Attached
scsi generic sg2 type 0
Sep  1 10:52:01 neopili kernel: [  194.290003] sd 6:0:0:0: [sdb] 32768
512-byte logical blocks: (16.7 MB/16.0 MiB)
Sep  1 10:52:01 neopili kernel: [  194.403012] usb 2-2: reset
SuperSpeed USB device number 2 using xhci_hcd
Sep  1 10:52:01 neopili kernel: [  194.419901] xhci_hcd :0e:00.0:
xHCI xhci_drop_endpoint called with disabled ep 8805e68915c8
Sep  1 10:52:01 neopili kernel: [  194.419907] xhci_hcd :0e:00.0:
xHCI xhci_drop_endpoint called with disabled ep 8805e6891580
Sep  1 10:52:31 neopili kernel: [  224.908382] usb 2-2: reset
SuperSpeed USB device number 2 using xhci_hcd
Sep  1 10:52:31 neopili kernel: [  224.925090] xhci_hcd :0e:00.0:
xHCI xhci_drop_endpoint called with disabled ep 8805e68915c8
Sep  1 10:52:31 neopili kernel: [  224.925100] xhci_hcd :0e:00.0:
xHCI xhci_drop_endpoint called with disabled ep 8805e6891580
Sep  1 10:52:31 neopili kernel: [  224.926327] sd 6:0:0:0: [sdb] Write
Protect is off
Sep  1 10:52:31 neopili kernel: [  224.926336] sd 6:0:0:0: [sdb] Mode
Sense: 00 00 00 00

On Fri, Aug 29, 2014 at 5:20 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 08/28/2014 06:09 PM, Ricardo Ribalda Delgado wrote:
 Sure, but the hw leaves my desk until next monday in 30 minutes.

 So unless you send the patch right now you will have to wait for
 results until next Monday

 Thanks!


 Great, anytime you can test it is appreciated.
 Added the patch to the bug:
 https://bugzilla.kernel.org/show_bug.cgi?id=75521

 Patch looks like this:

 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
 index c020b09..7aee5a3 100644
 --- a/drivers/usb/host/xhci.c
 +++ b/drivers/usb/host/xhci.c
 @@ -3544,6 +3544,10 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, 
 struct usb_device *udev)
 for (i = 1; i  31; ++i) {
 struct xhci_virt_ep *ep = virt_dev-eps[i];

 +   /* reset device sets ep states to disabled, also halted ones 
 */
 +   ep-ep_state = ~(EP_HALTED || SET_DEQ_PENDING);
 +   ep-stopped_td = NULL;
 +
 if (ep-ep_state  EP_HAS_STREAMS) {
 xhci_warn(xhci, WARN: endpoint 0x%02x has streams on 
 device reset, freeing streams.\n,
 xhci_get_endpoint_address(i));


 -Mathias




-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-09-01 Thread Ricardo Ribalda Delgado
After some time of use (one hour or so) my system started to behave
weird. I did check  dmesg and I was receiving the following line
again and again:

usb-storage: Error in queuecommand_lck: us-sfb= 8805bd61ccc0

I did disconnect the usb device and the whole computer crashed :S



On Mon, Sep 1, 2014 at 11:02 AM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 Hello

 The promised dmesg output. Still some xhci_drop_endpoint called with...

 Thanks!

 Sep  1 10:52:00 neopili kernel: [  193.123108] usb 2-2: new SuperSpeed
 USB device number 2 using xhci_hcd
 Sep  1 10:52:00 neopili kernel: [  193.142204] usb 2-2: New USB device
 found, idVendor=0525, idProduct=a4a5
 Sep  1 10:52:00 neopili kernel: [  193.142211] usb 2-2: New USB device
 strings: Mfr=3, Product=4, SerialNumber=0
 Sep  1 10:52:00 neopili kernel: [  193.142215] usb 2-2: Product: Mass
 Storage Gadget
 Sep  1 10:52:00 neopili kernel: [  193.142218] usb 2-2: Manufacturer:
 Linux 3.16.0-qtec-standard+ with net2280
 Sep  1 10:52:00 neopili systemd-udevd[221]: unknown key
 'SYSFS{manufacturer}' in /etc/udev/rules.d/52-digilent-usb.rules:35
 Sep  1 10:52:00 neopili systemd-udevd[221]: invalid rule
 '/etc/udev/rules.d/52-digilent-usb.rules:35'
 Sep  1 10:52:00 neopili systemd-udevd[221]: unknown key 'BUS' in
 /lib/udev/rules.d/60-libgnuradio-fcd3.7.3.rules:2
 Sep  1 10:52:00 neopili systemd-udevd[221]: invalid rule
 '/lib/udev/rules.d/60-libgnuradio-fcd3.7.3.rules:2'
 Sep  1 10:52:00 neopili systemd-udevd[1720]: failed to execute
 '/lib/udev/mtp-probe' 'mtp-probe
 /sys/devices/pci:00/:00:1c.6/:0e:00.0/usb2/2-2 2 2': No
 such file or directory
 Sep  1 10:52:00 neopili kernel: [  193.289553] usb-storage 2-2:1.0:
 USB Mass Storage device detected
 Sep  1 10:52:00 neopili kernel: [  193.289745] usb-storage 2-2:1.0:
 Quirks match for vid 0525 pid a4a5: 1
 Sep  1 10:52:00 neopili kernel: [  193.289820] scsi host6: usb-storage 2-2:1.0
 Sep  1 10:52:00 neopili kernel: [  193.289991] usbcore: registered new
 interface driver usb-storage
 Sep  1 10:52:00 neopili kernel: [  193.312632] usbcore: registered new
 interface driver uas
 Sep  1 10:52:01 neopili kernel: [  194.288067] scsi 6:0:0:0:
 Direct-Access LinuxFile-Stor Gadget 0316 PQ: 0 ANSI: 2
 Sep  1 10:52:01 neopili kernel: [  194.288957] sd 6:0:0:0: Attached
 scsi generic sg2 type 0
 Sep  1 10:52:01 neopili kernel: [  194.290003] sd 6:0:0:0: [sdb] 32768
 512-byte logical blocks: (16.7 MB/16.0 MiB)
 Sep  1 10:52:01 neopili kernel: [  194.403012] usb 2-2: reset
 SuperSpeed USB device number 2 using xhci_hcd
 Sep  1 10:52:01 neopili kernel: [  194.419901] xhci_hcd :0e:00.0:
 xHCI xhci_drop_endpoint called with disabled ep 8805e68915c8
 Sep  1 10:52:01 neopili kernel: [  194.419907] xhci_hcd :0e:00.0:
 xHCI xhci_drop_endpoint called with disabled ep 8805e6891580
 Sep  1 10:52:31 neopili kernel: [  224.908382] usb 2-2: reset
 SuperSpeed USB device number 2 using xhci_hcd
 Sep  1 10:52:31 neopili kernel: [  224.925090] xhci_hcd :0e:00.0:
 xHCI xhci_drop_endpoint called with disabled ep 8805e68915c8
 Sep  1 10:52:31 neopili kernel: [  224.925100] xhci_hcd :0e:00.0:
 xHCI xhci_drop_endpoint called with disabled ep 8805e6891580
 Sep  1 10:52:31 neopili kernel: [  224.926327] sd 6:0:0:0: [sdb] Write
 Protect is off
 Sep  1 10:52:31 neopili kernel: [  224.926336] sd 6:0:0:0: [sdb] Mode
 Sense: 00 00 00 00

 On Fri, Aug 29, 2014 at 5:20 PM, Mathias Nyman mathias.ny...@intel.com 
 wrote:
 On 08/28/2014 06:09 PM, Ricardo Ribalda Delgado wrote:
 Sure, but the hw leaves my desk until next monday in 30 minutes.

 So unless you send the patch right now you will have to wait for
 results until next Monday

 Thanks!


 Great, anytime you can test it is appreciated.
 Added the patch to the bug:
 https://bugzilla.kernel.org/show_bug.cgi?id=75521

 Patch looks like this:

 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
 index c020b09..7aee5a3 100644
 --- a/drivers/usb/host/xhci.c
 +++ b/drivers/usb/host/xhci.c
 @@ -3544,6 +3544,10 @@ int xhci_discover_or_reset_device(struct usb_hcd 
 *hcd, struct usb_device *udev)
 for (i = 1; i  31; ++i) {
 struct xhci_virt_ep *ep = virt_dev-eps[i];

 +   /* reset device sets ep states to disabled, also halted ones 
 */
 +   ep-ep_state = ~(EP_HALTED || SET_DEQ_PENDING);
 +   ep-stopped_td = NULL;
 +
 if (ep-ep_state  EP_HAS_STREAMS) {
 xhci_warn(xhci, WARN: endpoint 0x%02x has streams 
 on device reset, freeing streams.\n,
 xhci_get_endpoint_address(i));


 -Mathias




 --
 Ricardo Ribalda



-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-09-01 Thread Ricardo Ribalda Delgado
Well, it is hard to say. rc2 without the patch showed more warnings,
but never crashed badly (queuecommand_lck).

The sample size is not big enough. maybe rc2 also has the
queuecommand_lck bug, but I havent hit it.

On Mon, Sep 1, 2014 at 12:37 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 09/01/2014 12:36 PM, Ricardo Ribalda Delgado wrote:
 After some time of use (one hour or so) my system started to behave
 weird. I did check  dmesg and I was receiving the following line
 again and again:

 usb-storage: Error in queuecommand_lck: us-sfb= 8805bd61ccc0

 I did disconnect the usb device and the whole computer crashed :S


 Ok, thanks.

 Would you say things work better after the patch?

 I still think the patch solves part of the issue, i.e. how we handle halted 
 endpoints
 in reset, but I don't know the reason why the endpoints stall in the first 
 place

 -Mathias





-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-09-01 Thread Ricardo Ribalda Delgado
Do you have a NEC/Renesas uPD720200 USB 3.0 Host?

If so, try with an usb gadget acting as a mass storage. That hits the
bug in my machine.

Regarsd!

On Mon, Sep 1, 2014 at 1:12 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 09/01/2014 01:26 PM, Ricardo Ribalda Delgado wrote:
 Well, it is hard to say. rc2 without the patch showed more warnings,
 but never crashed badly (queuecommand_lck).

 The sample size is not big enough. maybe rc2 also has the
 queuecommand_lck bug, but I havent hit it.


 Ok, I won't submit it as I now know what really is going on.

 I asked for once of the devices that can trigger this bug,
 https://bugzilla.kernel.org/show_bug.cgi?id=75521

 I'll know more when I can get my hands on it

 -Mathias



-- 
Ricardo Ribalda
--
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 v2] usb: gadget: net2280: Fix invalid handling of Reset irq

2014-09-01 Thread Ricardo Ribalda Delgado
Hello Felipe

I think that you have forgotten about this patch :). It is needed by
usb3380 in usb3.0 mode. Otherwise the device keeps reseting.

Thanks!

On Tue, Aug 26, 2014 at 6:00 PM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 Without this patch, some hosts keep restarting indefinitely the target.

 Fixes: ae8e530 (usb: gadget: net2280: Code Cleanup)
 Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
 ---

 v2: Request by Felipe Balbi

 Use Fixes: on commit message

  drivers/usb/gadget/udc/net2280.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/usb/gadget/udc/net2280.c 
 b/drivers/usb/gadget/udc/net2280.c
 index f4eac11..2e95715 100644
 --- a/drivers/usb/gadget/udc/net2280.c
 +++ b/drivers/usb/gadget/udc/net2280.c
 @@ -3320,7 +3320,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 
 stat)
 if (stat  tmp) {
 writel(tmp, dev-regs-irqstat1);
 if stat  BIT(ROOT_PORT_RESET_INTERRUPT)) 
 -   (readl(dev-usb-usbstat)  mask)) ||
 +   ((readl(dev-usb-usbstat)  mask) == 0)) ||
 ((readl(dev-usb-usbctl) 
 BIT(VBUS_PIN)) == 0)) 
 (dev-gadget.speed != USB_SPEED_UNKNOWN)) {
 --
 2.1.0




-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-09-01 Thread Ricardo Ribalda Delgado
I could offer you a net3380 usb gadget device (mini pcie or pcie) but
the uPD720200 is my notebook, so I cannot afford an extra one for you
:)

On Mon, Sep 1, 2014 at 2:25 PM, Mathias Nyman
mathias.ny...@linux.intel.com wrote:
 On 09/01/2014 02:19 PM, Ricardo Ribalda Delgado wrote:
 Do you have a NEC/Renesas uPD720200 USB 3.0 Host?

 If so, try with an usb gadget acting as a mass storage. That hits the
 bug in my machine.


 Thanks for the tip, but currently I only got Intel hosts.

 btw I earlier meant to say that I _don't_ know what's going on yet.

 -Mathias





-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-08-28 Thread Ricardo Ribalda Delgado
Hello

On Thu, Aug 28, 2014 at 12:41 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 08/27/2014 07:10 PM, Ricardo Ribalda Delgado wrote:
 Perhaps we could apply both patches to current tree and backport mine
 to older kernels?


 The already applied patch fixes many other issues than just this one.
 backporting it to stable  3.13 turned out to not be that difficult, stable 
 maintainers
 said they can do it themselves.

then I agree, there is absolutely no need for my patch :).

I have a broken gadget driver that was very good at triggering the
bug, I will try it out with your patch.


Thanks!


 Stable kernels prefer patches that are already upstream, as 
 Documentation/stable_kernel_rules.txt states:
 - It or an equivalent fix must already exist in Linus' tree (upstream).

 There is no need for the other patch anymore, not upstream nor to stable

 -Mathias




-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-08-28 Thread Ricardo Ribalda Delgado
Hello Mathias

This is the dmesg output after your patch. No WARN(), no crash :), but
still some weird messages:

[  146.511623] usb 2-2: new SuperSpeed USB device number 2 using xhci_hcd
[  146.531652] usb 2-2: New USB device found, idVendor=0525, idProduct=a4a5
[  146.531661] usb 2-2: New USB device strings: Mfr=3, Product=4, SerialNumber=0
[  146.531666] usb 2-2: Product: Mass Storage Gadget
[  146.531670] usb 2-2: Manufacturer: Linux 3.16.0-qtec-standard+ with net2280
[  147.772743] usb-storage 2-2:1.0: USB Mass Storage device detected
[  147.773018] usb-storage 2-2:1.0: Quirks match for vid 0525 pid a4a5: 1
[  147.773185] scsi host6: usb-storage 2-2:1.0
[  147.773361] usbcore: registered new interface driver usb-storage
[  147.788950] usbcore: registered new interface driver uas
[  148.772699] scsi 6:0:0:0: Direct-Access LinuxFile-Stor
Gadget 0316 PQ: 0 ANSI: 2
[  148.773192] sd 6:0:0:0: Attached scsi generic sg2 type 0
[  148.774860] sd 6:0:0:0: [sdb] 32768 512-byte logical blocks: (16.7
MB/16.0 MiB)
[  148.888294] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  148.905202] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  148.905207] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  148.906324] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  148.912639] sd 6:0:0:0: [sdb] Test WP failed, assume Write Enabled
[  149.014972] sd 6:0:0:0: [sdb] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[  149.128640] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  149.145953] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  149.145963] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  149.147525] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  149.268626] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  149.285563] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  149.285573] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  149.286904] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  149.404621] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  149.421397] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  149.421404] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  149.422855] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  149.431667]  sdb: unknown partition table
[  149.544713] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  149.561649] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  149.561658] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  149.563021] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  149.680733] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  149.697766] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  149.697774] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  149.699025] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  149.706700] sd 6:0:0:0: [sdb] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[  149.706712] sd 6:0:0:0: [sdb] Attached SCSI disk
[  149.820933] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
[  149.837887] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc88
[  149.837895] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
with disabled ep 880036f3cc40
[  149.839242] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
[  155.752101] usb 3-1.5.6: reset high-speed USB device number 10 using ehci-pci
[  155.866642] cdc_acm 3-1.5.6:1.1: This device cannot do calls on its
own. It is not a modem.
[  155.866756] cdc_acm 3-1.5.6:1.1: ttyACM0: USB ACM device
[  155.867613] usb 3-1.5.6: usbfs: process 1521 (pool) did not claim
interface 0 before use
[  160.471327] pool[1680]: segfault at fc0e61c0 ip
7f570f036200 sp 7f570639f0d0 error 5 in
libc-2.19.so[7f570efee000+19f000]

Thanks!

On Thu, Aug 28, 2014 at 12:50 PM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 Hello

 On Thu, Aug 28, 2014 at 12:41 PM, Mathias Nyman mathias.ny...@intel.com 
 wrote:
 On 08/27/2014 07:10 PM, Ricardo Ribalda Delgado wrote:
 Perhaps we could apply both patches to current tree and backport mine
 to older kernels?


 The already applied patch fixes many other issues than just this one.
 backporting it to stable  3.13 turned out to not be that difficult, stable 
 maintainers
 said they can do it themselves.

 then I agree, there is absolutely no need for my patch :).

 I have

Re: [PATCH] xhci-ring: Fix Null pointer dereference

2014-08-28 Thread Ricardo Ribalda Delgado
Sure, but the hw leaves my desk until next monday in 30 minutes.

So unless you send the patch right now you will have to wait for
results until next Monday

Thanks!



On Thu, Aug 28, 2014 at 5:20 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 08/28/2014 03:36 PM, Ricardo Ribalda Delgado wrote:
 Hello Mathias

 This is the dmesg output after your patch. No WARN(), no crash :), but
 still some weird messages:

 [  146.511623] usb 2-2: new SuperSpeed USB device number 2 using xhci_hcd
 [  146.531652] usb 2-2: New USB device found, idVendor=0525, idProduct=a4a5
 [  146.531661] usb 2-2: New USB device strings: Mfr=3, Product=4, 
 SerialNumber=0
 [  146.531666] usb 2-2: Product: Mass Storage Gadget
 [  146.531670] usb 2-2: Manufacturer: Linux 3.16.0-qtec-standard+ with 
 net2280
 [  147.772743] usb-storage 2-2:1.0: USB Mass Storage device detected
 [  147.773018] usb-storage 2-2:1.0: Quirks match for vid 0525 pid a4a5: 1
 [  147.773185] scsi host6: usb-storage 2-2:1.0
 [  147.773361] usbcore: registered new interface driver usb-storage
 [  147.788950] usbcore: registered new interface driver uas
 [  148.772699] scsi 6:0:0:0: Direct-Access LinuxFile-Stor
 Gadget 0316 PQ: 0 ANSI: 2
 [  148.773192] sd 6:0:0:0: Attached scsi generic sg2 type 0
 [  148.774860] sd 6:0:0:0: [sdb] 32768 512-byte logical blocks: (16.7
 MB/16.0 MiB)
 [  148.888294] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  148.905202] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  148.905207] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  148.906324] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  148.912639] sd 6:0:0:0: [sdb] Test WP failed, assume Write Enabled
 [  149.014972] sd 6:0:0:0: [sdb] Write cache: enabled, read cache:
 enabled, doesn't support DPO or FUA
 [  149.128640] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  149.145953] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  149.145963] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  149.147525] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  149.268626] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  149.285563] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  149.285573] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  149.286904] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  149.404621] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  149.421397] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  149.421404] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  149.422855] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  149.431667]  sdb: unknown partition table
 [  149.544713] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  149.561649] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  149.561658] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  149.563021] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  149.680733] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  149.697766] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  149.697774] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  149.699025] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  149.706700] sd 6:0:0:0: [sdb] Write cache: enabled, read cache:
 enabled, doesn't support DPO or FUA
 [  149.706712] sd 6:0:0:0: [sdb] Attached SCSI disk
 [  149.820933] usb 2-2: reset SuperSpeed USB device number 2 using xhci_hcd
 [  149.837887] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc88
 [  149.837895] xhci_hcd :0e:00.0: xHCI xhci_drop_endpoint called
 with disabled ep 880036f3cc40
 [  149.839242] xhci_hcd :0e:00.0: Error: Failed finding new dequeue state
 [  155.752101] usb 3-1.5.6: reset high-speed USB device number 10 using 
 ehci-pci
 [  155.866642] cdc_acm 3-1.5.6:1.1: This device cannot do calls on its
 own. It is not a modem.
 [  155.866756] cdc_acm 3-1.5.6:1.1: ttyACM0: USB ACM device
 [  155.867613] usb 3-1.5.6: usbfs: process 1521 (pool) did not claim
 interface 0 before use
 [  160.471327] pool[1680]: segfault at fc0e61c0 ip
 7f570f036200 sp 7f570639f0d0 error 5 in
 libc-2.19.so[7f570efee000+19f000]

 Thanks!


 Thanks, I see you already found bug 75521
 https://bugzilla.kernel.org/show_bug.cgi?id=75521

 I think this is the same cause.
 Currently I suspect that one halted endpoint is not handled before

[PATCH] usb: gadget: net2280: Remove pci_class from PCI_TABLE

2014-08-27 Thread Ricardo Ribalda Delgado
Defining the vendor and the product id should be enough to discriminate
the device.

The reason for this patch is that there is a missmatch betweed the
modalias showed by sysfs and the modalias generated by file2alias.

One expects the programming interface in uppercase and the other
generates it in lowercase.

This means that some implementations modprobe will fail to load the
driver.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index f4eac11..542ab89 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -3770,16 +3770,12 @@ static void net2280_shutdown(struct pci_dev *pdev)
 /*-*/
 
 static const struct pci_device_id pci_ids[] = { {
-   .class =((PCI_CLASS_SERIAL_USB  8) | 0xfe),
-   .class_mask =   ~0,
.vendor =   PCI_VENDOR_ID_PLX_LEGACY,
.device =   0x2280,
.subvendor =PCI_ANY_ID,
.subdevice =PCI_ANY_ID,
.driver_data =  PLX_LEGACY | PLX_2280,
}, {
-   .class =((PCI_CLASS_SERIAL_USB  8) | 0xfe),
-   .class_mask =   ~0,
.vendor =   PCI_VENDOR_ID_PLX_LEGACY,
.device =   0x2282,
.subvendor =PCI_ANY_ID,
@@ -3787,8 +3783,6 @@ static const struct pci_device_id pci_ids[] = { {
.driver_data =  PLX_LEGACY,
},
{
-   .class =((PCI_CLASS_SERIAL_USB  8) | 0xfe),
-   .class_mask =   ~0,
.vendor =   PCI_VENDOR_ID_PLX,
.device =   0x3380,
.subvendor =PCI_ANY_ID,
@@ -3796,8 +3790,6 @@ static const struct pci_device_id pci_ids[] = { {
.driver_data =  PLX_SUPERSPEED,
 },
{
-   .class =((PCI_CLASS_SERIAL_USB  8) | 0xfe),
-   .class_mask =   ~0,
.vendor =   PCI_VENDOR_ID_PLX,
.device =   0x3382,
.subvendor =PCI_ANY_ID,
-- 
2.1.0

--
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] xhci-ring: Fix Null pointer dereference

2014-08-27 Thread Ricardo Ribalda Delgado
At least I have seen the issue on Debian 3.14 and 3.16. Is your patch
going to be backported to linux-stable? The computer crashes very very
badly

On Wed, Aug 27, 2014 at 4:25 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 08/26/2014 06:47 PM, Ricardo Ribalda Delgado wrote:
 While testing a usb gadget I managed to crash completely the host
 computer. This was due to a NULL pointer derefence.

 This patch avoids the crash although the kernel still outputs some
 warnings.

 Without this patch, kernels from (at least) 3.14 can be crashed with
 mass storage gadgets.

 Affected host:  NEC Corporation uPD720200 USB 3.0



 This should not be necessary anymore after
 commit 365038d83313951d6ace15342eb24624bbef1666
 xhci: rework cycle bit checking for new dequeue pointers

 http://marc.info/?l=linux-usbm=140844993115671w=2

 Which was just added to Greg's usb-linus branch.
 It checks that the new_deq_ptr and new_deq_seg are valid before calling
 xhci_queue_new_dequeue_state()

 -Mathias








-- 
Ricardo Ribalda
--
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


Status of g_webcam uvc-gadget

2014-08-27 Thread Ricardo Ribalda Delgado
Hello

Is somebody using/supporting g_webcam?

The only reference userland server is uvc-gadget from
http://git.ideasonboard.org/?p=uvc-gadget.git;a=summary ?

I have an industrial fpga camera that speaks v4l2, my plan is to
export it as an uvc camera via usb3380 as a debug interface.

Thanks!

-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-08-27 Thread Ricardo Ribalda Delgado
Perhaps we could apply both patches to current tree and backport mine
to older kernels?

On Wed, Aug 27, 2014 at 5:27 PM, Mathias Nyman mathias.ny...@intel.com wrote:
 On 08/27/2014 05:14 PM, Ricardo Ribalda Delgado wrote:
 At least I have seen the issue on Debian 3.14 and 3.16. Is your patch
 going to be backported to linux-stable? The computer crashes very very
 badly


 Yes, it is, but it might need some additional work as it won't apply cleanly 
 on older versions

 http://marc.info/?l=linux-usbm=140913688327011w=2

 -Mathias



-- 
Ricardo Ribalda
--
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: gadget: net2280: Remove pci_class from PCI_TABLE

2014-08-27 Thread Ricardo Ribalda Delgado
Hello Greg





On Wed, Aug 27, 2014 at 9:25 PM, Greg Kroah-Hartman
gre...@linuxfoundation.org wrote:
 On Wed, Aug 27, 2014 at 03:00:29PM +0200, Ricardo Ribalda Delgado wrote:
 Defining the vendor and the product id should be enough to discriminate
 the device.

 The reason for this patch is that there is a missmatch betweed the
 modalias showed by sysfs and the modalias generated by file2alias.

 One expects the programming interface in uppercase and the other
 generates it in lowercase.

 I don't understand, what is wrong here?  Who does it in uppercase and
 who in lower?  And does it matter?  It's just a numeric value that
 should not be used as a string compare.


In pci-sysfs: 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci-sysfs.c#n175

static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pci_dev *pci_dev = to_pci_dev(dev);

return sprintf(buf, pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n,
  pci_dev-vendor, pci_dev-device,
  pci_dev-subsystem_vendor, pci_dev-subsystem_device,
  (u8)(pci_dev-class  16), (u8)(pci_dev-class  8),
  (u8)(pci_dev-class));
}


In file2alias: 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/mod/file2alias.c

#define ADD(str, sep, cond, field)  \
do {\
strcat(str, sep);   \
if (cond)   \
sprintf(str + strlen(str),  \
sizeof(field) == 1 ? %02X :   \
sizeof(field) == 2 ? %04X :   \
sizeof(field) == 4 ? %08X : ,   \
field); \
else\
sprintf(str + strlen(str), *);\
} while(0)


ADD(alias, bc, baseclass_mask == 0xFF, baseclass);
ADD(alias, sc, subclass_mask == 0xFF, subclass);
ADD(alias, i, interface_mask == 0xFF, interface);



 This means that some implementations modprobe will fail to load the
 driver.

 What implementations fail to work?  Shouldn't we fix the root of the
 problem and not just patch up all drivers to display incorrect data?

At least the implementation of kmod in yocproject does a case sensitive match.


I have already sent a patch to fix what I consider the root of the problem

https://lkml.org/lkml/2014/8/27/242


 And I mean incorrect, as you are changing the values here from being
 very specific, to being much broader.


Not many drivers define the pci interface and there is no other driver
that has the same vendor  and product id. Therefore I see no hurt in
adding both patches, one to make the driver broader, and another to
fix pci-sysfs.


Also, the change on pci-sysfs might affect more stuff and therefore
take longer to be applied.


 thanks,

Thank you :)

 greg k-h



-- 
Ricardo Ribalda
--
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: gadget: net2280: Remove pci_class from PCI_TABLE

2014-08-27 Thread Ricardo Ribalda Delgado
Hello Greg


 Not many drivers define the pci interface and there is no other driver
 that has the same vendor  and product id. Therefore I see no hurt in
 adding both patches, one to make the driver broader, and another to
 fix pci-sysfs.

 Also, the change on pci-sysfs might affect more stuff and therefore
 take longer to be applied.

 As we have been printing the value to userspace in this way for well
 over a decade now, and nothing has changed, I say it's a userspace bug
 that you should fix instead.  Don't work around broken user programs in
 the kernel by changing something that has been stable for 10+ years.

 Ok, sorry, not 10+ years, the commit was written May of 2005, so 9
 years.

 Fix your module loading code please.

On the other thread ( https://lkml.org/lkml/2014/8/27/242 ) we have
agreed about fixing this thing on pci-sysfs.c .

Still I think that there is no good reason to add the pci interface to
the pci_table on this driver. Therefore I consider that this patch is
still valid.

What do you think. This patch is NACK?


Thanks!


 thanks,

 greg k-h



-- 
Ricardo Ribalda
--
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] xhci-ring: Fix Null pointer dereference

2014-08-26 Thread Ricardo Ribalda Delgado
-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/host/xhci-ring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 60fb52a..7767481 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -613,7 +613,8 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
Set TR Deq Ptr cmd, new deq seg = %p (0x%llx dma), 
new deq ptr = %p (0x%llx dma), new cycle = %u,
deq_state-new_deq_seg,
-   (unsigned long long)deq_state-new_deq_seg-dma,
+   (unsigned long long)(deq_state-new_deq_seg) ?
+   deq_state-new_deq_seg-dma : 0,
deq_state-new_deq_ptr,
(unsigned long 
long)xhci_trb_virt_to_dma(deq_state-new_deq_seg, deq_state-new_deq_ptr),
deq_state-new_cycle_state);
-- 
2.1.0

--
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: net2280: Fix invalid handling of Reset irq

2014-08-26 Thread Ricardo Ribalda Delgado
Without this patch, some hosts keeps restarting indefinitely the target.

Bug added on ae8e530a7e5d87592cb23996bee7fd6f1eb202ed usb: gadget:
net2280: Code Cleanup

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index f4eac11..2e95715 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -3320,7 +3320,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 
stat)
if (stat  tmp) {
writel(tmp, dev-regs-irqstat1);
if stat  BIT(ROOT_PORT_RESET_INTERRUPT)) 
-   (readl(dev-usb-usbstat)  mask)) ||
+   ((readl(dev-usb-usbstat)  mask) == 0)) ||
((readl(dev-usb-usbctl) 
BIT(VBUS_PIN)) == 0)) 
(dev-gadget.speed != USB_SPEED_UNKNOWN)) {
-- 
2.1.0

--
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: net2280: Fix invalid handling of Reset irq

2014-08-26 Thread Ricardo Ribalda Delgado
Without this patch, some hosts keep restarting indefinitely the target.

Fixes: ae8e530 (usb: gadget: net2280: Code Cleanup)
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---

v2: Request by Felipe Balbi

Use Fixes: on commit message

 drivers/usb/gadget/udc/net2280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index f4eac11..2e95715 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -3320,7 +3320,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 
stat)
if (stat  tmp) {
writel(tmp, dev-regs-irqstat1);
if stat  BIT(ROOT_PORT_RESET_INTERRUPT)) 
-   (readl(dev-usb-usbstat)  mask)) ||
+   ((readl(dev-usb-usbstat)  mask) == 0)) ||
((readl(dev-usb-usbctl) 
BIT(VBUS_PIN)) == 0)) 
(dev-gadget.speed != USB_SPEED_UNKNOWN)) {
-- 
2.1.0

--
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


BUG: xhci_hcd: Crashes system when reseting endpoint

2014-08-25 Thread Ricardo Ribalda Delgado
Hello

When I connect a usb gadget mass storage to my laptop the whole system
crashes.  It seems that the bug happens when the gadget/host
initialize a reset.

I lose all control to the computer, and the only way to recover
control is rebooting it via powerbutton.

Kernel that does not work: 3.14 3.16 (Debian)

The host is a nec/renesas 3.0 with the latest firmware

ricardo@neopili:~$ lspci -d 1033:0194 -vvv
0e:00.0 USB controller: NEC Corporation uPD720200 USB 3.0 Host
Controller (rev 04) (prog-if 30 [XHCI])
Subsystem: Lenovo Device 21cf
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast TAbort-
TAbort- MAbort- SERR- PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 18
Region 0: Memory at d410 (64-bit, non-prefetchable) [size=8K]
Capabilities: access denied
Kernel driver in use: xhci_hcd


The device is a linux 3.16 gadget (net2280) and works ok on a Windows
machine and the usb 2.0 port.

I cannot confirm 100%, but I am pretty sure that this same setup was
working with linux 3.12.


dmesg (with dyndbg enabled)
: http://pastebin.com/raw.php?i=PRUiG7ng

Might be related to: https://bugzilla.kernel.org/show_bug.cgi?id=75521


Thanks!

Aug 25 17:59:32 neopili kernel: [  366.580743] xhci_hcd :0e:00.0:
Port Status Change Event for port 4
Aug 25 17:59:32 neopili kernel: [  366.580756] xhci_hcd :0e:00.0:
resume root hub
Aug 25 17:59:32 neopili kernel: [  366.580776] xhci_hcd :0e:00.0:
handle_port_status: starting port polling.
Aug 25 17:59:32 neopili kernel: [  366.580866] xhci_hcd :0e:00.0:
get port status, actual port 0 status  = 0x2a0
Aug 25 17:59:32 neopili kernel: [  366.580877] xhci_hcd :0e:00.0:
Get port status returned 0x100
Aug 25 17:59:32 neopili kernel: [  366.580917] xhci_hcd :0e:00.0:
get port status, actual port 1 status  = 0x202a0
Aug 25 17:59:32 neopili kernel: [  366.580921] xhci_hcd :0e:00.0:
Get port status returned 0x10100
Aug 25 17:59:32 neopili kernel: [  366.580948] xhci_hcd :0e:00.0:
clear port connect change, actual port 1 status  = 0x2a0
Aug 25 17:59:32 neopili kernel: [  366.582811] xhci_hcd :0e:00.0:
Port Status Change Event for port 2
Aug 25 17:59:32 neopili kernel: [  366.582833] xhci_hcd :0e:00.0:
resume root hub
Aug 25 17:59:32 neopili kernel: [  366.582845] xhci_hcd :0e:00.0:
handle_port_status: starting port polling.
Aug 25 17:59:32 neopili kernel: [  366.583095] xhci_hcd :0e:00.0:
get port status, actual port 0 status  = 0x2a0
Aug 25 17:59:32 neopili kernel: [  366.583099] xhci_hcd :0e:00.0:
Get port status returned 0x2a0
Aug 25 17:59:32 neopili kernel: [  366.583124] xhci_hcd :0e:00.0:
get port status, actual port 1 status  = 0x21203
Aug 25 17:59:32 neopili kernel: [  366.583127] xhci_hcd :0e:00.0:
Get port status returned 0x10203
Aug 25 17:59:32 neopili kernel: [  366.583143] xhci_hcd :0e:00.0:
clear port connect change, actual port 1 status  = 0x1203
Aug 25 17:59:32 neopili kernel: [  366.655724] xhci_hcd :0e:00.0:
xhci_hub_status_data: stopping port polling.
Aug 25 17:59:32 neopili kernel: [  366.655757] xhci_hcd :0e:00.0:
xhci_hub_status_data: stopping port polling.
Aug 25 17:59:32 neopili kernel: [  366.683811] xhci_hcd :0e:00.0:
get port status, actual port 1 status  = 0x1203
Aug 25 17:59:32 neopili kernel: [  366.683820] xhci_hcd :0e:00.0:
Get port status returned 0x203
Aug 25 17:59:32 neopili kernel: [  366.683924] xhci_hcd :0e:00.0:
// Ding dong!
Aug 25 17:59:32 neopili kernel: [  366.684099] xhci_hcd :0e:00.0:
Slot 1 output ctx = 0x5c22ba000 (dma)
Aug 25 17:59:32 neopili kernel: [  366.684109] xhci_hcd :0e:00.0:
Slot 1 input ctx = 0x5be985000 (dma)
Aug 25 17:59:32 neopili kernel: [  366.684121] xhci_hcd :0e:00.0:
Set slot id 1 dcbaa entry 880620c3d008 to 0x5c22ba000
Aug 25 17:59:32 neopili kernel: [  366.684139] xhci_hcd :0e:00.0:
get port status, actual port 1 status  = 0x1203
Aug 25 17:59:32 neopili kernel: [  366.684142] xhci_hcd :0e:00.0:
Get port status returned 0x203
Aug 25 17:59:32 neopili kernel: [  366.684239] xhci_hcd :0e:00.0:
set port reset, actual port 1 status  = 0x1311
Aug 25 17:59:32 neopili kernel: [  366.684284] xhci_hcd :0e:00.0:
Port Status Change Event for port 2
Aug 25 17:59:32 neopili kernel: [  366.684294] xhci_hcd :0e:00.0:
handle_port_status: starting port polling.
Aug 25 17:59:32 neopili kernel: [  366.687737] xhci_hcd :0e:00.0:
xhci_hub_status_data: stopping port polling.
Aug 25 17:59:32 neopili kernel: [  366.739779] xhci_hcd :0e:00.0:
get port status, actual port 1 status  = 0x201203
Aug 25 17:59:32 neopili kernel: [  366.739789] xhci_hcd :0e:00.0:
Get port status returned 0x100203
Aug 25 17:59:32 neopili kernel: [  366.795756] xhci_hcd :0e:00.0:
clear port reset change, actual port 1 status  = 0x1203
Aug 25 17:59:32 neopili kernel: [  366.795851] xhci_hcd 

Re: [PATCH] net/usb/hso: Add support for Option GTM671WFS

2014-08-05 Thread Ricardo Ribalda Delgado
Hello Dan.

I have also been able to start/stop the gps via the gps control port
(ttyHS2) and get nmea data port through the gps port. (ttyHS1)

Please tell me if you need more tests

Regards!

root@qt5022:~# cat /sys/class/tty/*/hsotype
Diagnostic
GPS
GPS Control
Application
Control
Modem
root@qt5022:~# hso_connect up
Using /etc/conninfo.ini as connection file
Using /dev/ttyHS3 application port.
Initializing...
Trying internet ...
Connecting...
trying
Connected
Setting IP address to  10.198.XXX.115
Adding route
Done.
root@qt5022:~# ifconfig hso0
hso0  Link encap:UNSPEC  HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
  inet addr:10.198.XXX.115  P-t-P:10.198.XXX.115  Mask:255.255.255.255
  UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1486  Metric:1
  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:10
  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@qt5022:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=1163 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=46 time=304 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=46 time=72.5 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=46 time=60.7 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 60.790/400.296/1163.670/451.296 ms, pipe 2
root@qt5022:~# cat /dev/ttyHS1
$GPGSV,4,1,16,24271232,,,*7A
$GPGSV,4,2,16,31302928,,,*78
$GPGSV,4,3,16,26252322,,,*7B
$GPGSV,4,4,16,21201918,,,*7E
$GPGGA,,0*66
$PQXFI,,*56
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,,V,,N*53
$GPGSA,A,1,,,*1E
$GPGSV,4,1,16,04242712,,,*7F
$GPGSV,4,2,16,32313029,,,*73
$GPGSV,4,3,16,28262523,,,*71
$GPGSV,4,4,16,22212019,,,*77
$GPGGA,,0*66
$PQXFI,,*56
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,,V,,N*53
$GPGSA,A,1,,,*1E

On Mon, Aug 4, 2014 at 8:30 PM, Dan Williams d...@redhat.com wrote:
 On Mon, 2014-08-04 at 11:20 +0200, Ricardo Ribalda Delgado wrote:
 Suggested-by: Dan Williams d...@redhat.com

 Before we apply this patch though, can you grab for the following for
 me?

 cat /sys/class/tty/*/hsotype

 and lets see if the firmware actually responds.  Also, do you get an
 'hso0' network interface as reported by ifconfig or /sbin/ip?  If you
 do, then lets do some additional verification to ensure it should be
 driven by 'hso' instead of option.

 Dan

 On Mon, Aug 4, 2014 at 11:11 AM, Ricardo Ribalda Delgado
 ricardo.riba...@gmail.com wrote:
  After this patch:
 
  [ 32.985530] hso: drivers/net/usb/hso.c: Option Wireless
  [ 33.000452] hso 2-1.4:1.7: Not our interface
  [ 33.001849] usbcore: registered new interface driver hso
 
  root@qt5022:~# ls /dev/ttyHS*
  /dev/ttyHS0  /dev/ttyHS1  /dev/ttyHS2  /dev/ttyHS3  /dev/ttyHS4
  /dev/ttyHS5
 
  root@qt5022:~# lsusb -d 0af0: -vvv
 
  Bus 002 Device 003: ID 0af0:9200 Option
  Device Descriptor:
bLength18
bDescriptorType 1
bcdUSB   2.00
bDeviceClass  255 Vendor Specific Class
bDeviceSubClass   255 Vendor Specific Subclass
bDeviceProtocol   255 Vendor Specific Protocol
bMaxPacketSize064
idVendor   0x0af0 Option
idProduct  0x9200
bcdDevice0.00
iManufacturer   3 Option N.V.
iProduct2 Globetrotter HSUPA Modem
iSerial 0
bNumConfigurations  1
Configuration Descriptor:
  bLength 9
  bDescriptorType 2
  wTotalLength  200
  bNumInterfaces  8
  bConfigurationValue 1
  iConfiguration  1 Option Configuration
  bmAttributes 0xe0
Self Powered
Remote Wakeup
  MaxPower  100mA
  Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber0
bAlternateSetting   0
bNumEndpoints   2
bInterfaceClass   255 Vendor Specific Class
bInterfaceSubClass255 Vendor Specific Subclass
bInterfaceProtocol255 Vendor Specific Protocol
iInterface  0
Endpoint Descriptor:
  bLength 7
  bDescriptorType 5
  bEndpointAddress 0x81  EP 1 IN
  bmAttributes2
Transfer TypeBulk
Synch Type   None
Usage Type   Data
  wMaxPacketSize 0x0200  1x 512 bytes
  bInterval  32
Endpoint Descriptor:
  bLength 7
  bDescriptorType 5
  bEndpointAddress 0x01  EP 1 OUT
  bmAttributes2
Transfer Type

[PATCH] net/usb/hso: Add support for Option GTM671WFS

2014-08-04 Thread Ricardo Ribalda Delgado
bEndpointAddress 0x08  EP 8 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   1
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x89  EP 9 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   1
Device Qualifier (for other device speed):
  bLength10
  bDescriptorType 6
  bcdUSB   2.00
  bDeviceClass  255 Vendor Specific Class
  bDeviceSubClass   255 Vendor Specific Subclass
  bDeviceProtocol   255 Vendor Specific Protocol
  bMaxPacketSize064
  bNumConfigurations  1
Device Status: 0x0001
  Self Powered

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/net/usb/hso.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index a3a0586..eb12261 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -469,6 +469,7 @@ static const struct usb_device_id hso_ids[] = {
{USB_DEVICE(0x0af0, 0x8800)},
{USB_DEVICE(0x0af0, 0x8900)},
{USB_DEVICE(0x0af0, 0x9000)},
+   {USB_DEVICE(0x0af0, 0x9200)},   /* Option GTM671WFS */
{USB_DEVICE(0x0af0, 0xd035)},
{USB_DEVICE(0x0af0, 0xd055)},
{USB_DEVICE(0x0af0, 0xd155)},
-- 
2.0.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] serial/option: Add support for Option GTM671WFS

2014-08-04 Thread Ricardo Ribalda Delgado
Hello Dan


 Are you 100% sure these don't go into the 'hso' driver?  'option' is
 used for mostly older Option devices (like 5+ years old).  I tried to
 find information about this module, and the closest I could come for
 0af0:9200 was:

 http://trac.gateworks.com/wiki/3g

 which indicates they might be 'hso' instead.  Can you give that a try?

With all the hso_ids configuration I get the following error message:

[  553.501693] hso: drivers/net/usb/hso.c: Option Wireless
[  553.524898] hso 2-1.4:1.7: Not our interface

and depending on the mode I get 3, 4 or 6 ttySH interfaces

But, if we ignore this, the device can connect to the internet with
hso_connect.sh. I have already post a patch using the hso driver.

The device could also connect with option.ko... Do you think that
there could be other devices wrongly handled with option ?

Ricardo
--
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] net/usb/hso: Add support for Option GTM671WFS

2014-08-04 Thread Ricardo Ribalda Delgado
Suggested-by: Dan Williams d...@redhat.com

On Mon, Aug 4, 2014 at 11:11 AM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 After this patch:

 [ 32.985530] hso: drivers/net/usb/hso.c: Option Wireless
 [ 33.000452] hso 2-1.4:1.7: Not our interface
 [ 33.001849] usbcore: registered new interface driver hso

 root@qt5022:~# ls /dev/ttyHS*
 /dev/ttyHS0  /dev/ttyHS1  /dev/ttyHS2  /dev/ttyHS3  /dev/ttyHS4
 /dev/ttyHS5

 root@qt5022:~# lsusb -d 0af0: -vvv

 Bus 002 Device 003: ID 0af0:9200 Option
 Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   2.00
   bDeviceClass  255 Vendor Specific Class
   bDeviceSubClass   255 Vendor Specific Subclass
   bDeviceProtocol   255 Vendor Specific Protocol
   bMaxPacketSize064
   idVendor   0x0af0 Option
   idProduct  0x9200
   bcdDevice0.00
   iManufacturer   3 Option N.V.
   iProduct2 Globetrotter HSUPA Modem
   iSerial 0
   bNumConfigurations  1
   Configuration Descriptor:
 bLength 9
 bDescriptorType 2
 wTotalLength  200
 bNumInterfaces  8
 bConfigurationValue 1
 iConfiguration  1 Option Configuration
 bmAttributes 0xe0
   Self Powered
   Remote Wakeup
 MaxPower  100mA
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   0
   bNumEndpoints   2
   bInterfaceClass   255 Vendor Specific Class
   bInterfaceSubClass255 Vendor Specific Subclass
   bInterfaceProtocol255 Vendor Specific Protocol
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x81  EP 1 IN
 bmAttributes2
   Transfer TypeBulk
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0200  1x 512 bytes
 bInterval  32
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x01  EP 1 OUT
 bmAttributes2
   Transfer TypeBulk
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0200  1x 512 bytes
 bInterval  32
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber1
   bAlternateSetting   0
   bNumEndpoints   2
   bInterfaceClass   255 Vendor Specific Class
   bInterfaceSubClass255 Vendor Specific Subclass
   bInterfaceProtocol255 Vendor Specific Protocol
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x82  EP 2 IN
 bmAttributes2
   Transfer TypeBulk
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0200  1x 512 bytes
 bInterval  32
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x02  EP 2 OUT
 bmAttributes2
   Transfer TypeBulk
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0200  1x 512 bytes
 bInterval  32
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber2
   bAlternateSetting   0
   bNumEndpoints   2
   bInterfaceClass   255 Vendor Specific Class
   bInterfaceSubClass255 Vendor Specific Subclass
   bInterfaceProtocol255 Vendor Specific Protocol
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x83  EP 3 IN
 bmAttributes2
   Transfer TypeBulk
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0200  1x 512 bytes
 bInterval  32
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x03  EP 3 OUT
 bmAttributes2
   Transfer TypeBulk
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0200  1x 512 bytes
 bInterval  32
 Interface Descriptor:
   bLength 9
   bDescriptorType 4

[PATCH] serial/option: Add support for Option GTM671WFS

2014-08-01 Thread Ricardo Ribalda Delgado
bInterval  32
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x07  EP 7 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval  32
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber7
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass 8 Mass Storage
  bInterfaceSubClass  6 SCSI
  bInterfaceProtocol 80 Bulk-Only
  iInterface  0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x08  EP 8 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   1
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x89  EP 9 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   1
Device Qualifier (for other device speed):
  bLength10
  bDescriptorType 6
  bcdUSB   2.00
  bDeviceClass  255 Vendor Specific Class
  bDeviceSubClass   255 Vendor Specific Subclass
  bDeviceProtocol   255 Vendor Specific Protocol
  bMaxPacketSize064
  bNumConfigurations  1
Device Status: 0x0001
  Self Powered

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/serial/option.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index a968894..48a63b5 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -78,6 +78,7 @@ static void option_instat_callback(struct urb *urb);
 #define OPTION_PRODUCT_ETNA_MODEM_EX   0x7061
 #define OPTION_PRODUCT_ETNA_KOI_MODEM  0x7100
 #define OPTION_PRODUCT_GTM380_MODEM0x7201
+#define OPTION_PRODUCT_GLOBETROTTER_MODEM  0x9200
 
 #define HUAWEI_VENDOR_ID   0x12D1
 #define HUAWEI_PRODUCT_E1730x140C
@@ -603,6 +604,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_MODEM_EX) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GTM380_MODEM) },
+   { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_GLOBETROTTER_MODEM) },
{ USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q101) },
{ USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_Q111) },
{ USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) },
-- 
2.0.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: net2280: Fix typo on #ifdef

2014-07-04 Thread Ricardo Ribalda Delgado
Commit e56e69cc0ff4 (usb: gadget: net2280: Use pr_* function)
includes a editing mistake on one of the #ifdef.

This patch fixes it.

Reported-by: Paul Bolle pebo...@tiscali.nl
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/udc/net2280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index ce8bc86..248dccb 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1562,7 +1562,7 @@ static const struct usb_gadget_ops net2280_ops = {
 
 /*-*/
 
-#ifdef CONFIG_USB_GADGET_PDEBUG_FILES
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 
 /* FIXME move these into procfs, and use seq_file.
  * Sysfs _still_ doesn't behave for arbitrarily sized files,
-- 
2.0.0

--
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: usb: gadget: net2280: CONFIG_USB_GADGET_PDEBUG_FILES?

2014-07-04 Thread Ricardo Ribalda Delgado
My fault. Thank you very much for reporting it. I have just posted the patch


Regards

On Fri, Jul 4, 2014 at 9:37 AM, Paul Bolle pebo...@tiscali.nl wrote:
 Commit e56e69cc0ff4 (usb: gadget: net2280: Use pr_* function) is
 included in today's linux-next (ie, next-20140704).

 It contains this odd chunk:
 @@ -1566,7 +1563,7 @@ static const struct usb_gadget_ops net2280_ops = {

  
 /*-*/

 -#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 +#ifdef CONFIG_USB_GADGET_PDEBUG_FILES

  /* FIXME move these into procfs, and use seq_file.
   * Sysfs _still_ doesn't behave for arbitrarily sized files,

 (Commit b7ca96655ddd (usb: gadget: Gadget directory cleanup - group UDC
 drivers), also included in today's linux-next, moved that new check for
 CONFIG_USB_GADGET_PDEBUG_FILES to drivers/usb/gadget/udc/net2280.c.)

 Using CONFIG_USB_GADGET_PDEBUG_FILES appears to be just an editing
 mistake. Would Ricardo like to submit the trivial patch to clean it up
 or should I do that?


 Paul Bolle




-- 
Ricardo Ribalda
--
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 00/10] net2280: Support for PLX USB338x and cleanout code

2014-06-30 Thread Ricardo Ribalda Delgado
Hello Felipe

Any comment on this patchset? Shall I resend it rebased on v3.16-rc2?


Regards

On Tue, Jun 10, 2014 at 10:19 PM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 Ping...

 On Tue, May 20, 2014 at 6:30 PM, Ricardo Ribalda Delgado
 ricardo.riba...@gmail.com wrote:
 The USB 3380 is a PCI Express Gen 2 to USB 3.0 SuperSpeed Peripheral
 Controller. It shares a lot functionatily with the net228x family.

 This series of patches includes some resend of previous patches.

 Please check the changelog for every patch. This time it has been placed
 under the tear line



 Ricardo Ribalda Delgado (10):
   usb: gadget: net2280: Add support for PLX USB338X
   usb: gadget: net2280: Dont use magic numbers
   usb: gadget: net2280: Use BIT() macro
   usb: gadget: net2280: Use true/false instead of 1/0
   usb: gadget: net2280: Use module_pci_driver macro
   usb: gadget: net2280: Refactor queues_show
   usb: gadget: net2280: Pass checkpacth.pl test
   usb: gadget: net2280: Code Cleanup
   usb: gadget: net2280: Use pr_* function
   usb: gadget: net2280: Use quirks instead of pci id

  drivers/usb/gadget/Kconfig   |   10 +-
  drivers/usb/gadget/net2280.c | 2752 
 --
  drivers/usb/gadget/net2280.h |  285 +++--
  include/linux/usb/usb338x.h  |  199 +++
  4 files changed, 2235 insertions(+), 1011 deletions(-)
  create mode 100644 include/linux/usb/usb338x.h

 --
 2.0.0.rc2




 --
 Ricardo Ribalda



-- 
Ricardo Ribalda
--
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 00/10] net2280: Support for PLX USB338x and cleanout code

2014-06-10 Thread Ricardo Ribalda Delgado
Ping...

On Tue, May 20, 2014 at 6:30 PM, Ricardo Ribalda Delgado
ricardo.riba...@gmail.com wrote:
 The USB 3380 is a PCI Express Gen 2 to USB 3.0 SuperSpeed Peripheral
 Controller. It shares a lot functionatily with the net228x family.

 This series of patches includes some resend of previous patches.

 Please check the changelog for every patch. This time it has been placed
 under the tear line



 Ricardo Ribalda Delgado (10):
   usb: gadget: net2280: Add support for PLX USB338X
   usb: gadget: net2280: Dont use magic numbers
   usb: gadget: net2280: Use BIT() macro
   usb: gadget: net2280: Use true/false instead of 1/0
   usb: gadget: net2280: Use module_pci_driver macro
   usb: gadget: net2280: Refactor queues_show
   usb: gadget: net2280: Pass checkpacth.pl test
   usb: gadget: net2280: Code Cleanup
   usb: gadget: net2280: Use pr_* function
   usb: gadget: net2280: Use quirks instead of pci id

  drivers/usb/gadget/Kconfig   |   10 +-
  drivers/usb/gadget/net2280.c | 2752 
 --
  drivers/usb/gadget/net2280.h |  285 +++--
  include/linux/usb/usb338x.h  |  199 +++
  4 files changed, 2235 insertions(+), 1011 deletions(-)
  create mode 100644 include/linux/usb/usb338x.h

 --
 2.0.0.rc2




-- 
Ricardo Ribalda
--
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 3/5] usb: gadget: net2280: Pass checkpacth.pl test

2014-05-20 Thread Ricardo Ribalda Delgado
Not for grep...

But if this is an issue I have no problem going back to the original.
We can spend a whole year just talking about codestyle.



On Tue, May 20, 2014 at 10:52 AM, David Laight david.lai...@aculab.com wrote:
 From: Alan Stern
 ...
  -static struct usb_request *
  -net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
  +static struct usb_request *net2280_alloc_request(struct usb_ep *_ep,
  +   gfp_t gfp_flags)

 What's with the extreme indentation on the continuation line?  The
 style used here is for continuation lines to be indented by two stops
 relative to the first line.

 Also why move the line break?
 The Linux kernel has both styles, and the original one (with the
 function name starting in column 1) makes it much easier to search
 to the definition.

 David






-- 
Ricardo Ribalda
--
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/9] usb: gadget: net2280: Dont use magic numbers

2014-05-20 Thread Ricardo Ribalda Delgado
Hello Alan

In this case, there are only two family of devices supported by the
driver. Maybe quirks are too much.

At the end:

ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY

is not much bigger than

ep-dev-quirk_flag  PLX_NET2280_QUIRK

But if you prefer the quirk I dont mind implementing it, but please as
a follow-up patch, since there are 8 patches depending on this :)

Regards!


On Tue, May 20, 2014 at 4:21 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Mon, 19 May 2014, Ricardo Ribalda Delgado wrote:

 Instead of using magic numbers use #defines

 Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
 ---
  drivers/usb/gadget/net2280.c | 68 
 +++-
  drivers/usb/gadget/net2280.h |  1 +
  2 files changed, 36 insertions(+), 33 deletions(-)

 diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
 index 8112d91..ba1fdd8 100644
 --- a/drivers/usb/gadget/net2280.c
 +++ b/drivers/usb/gadget/net2280.c
 @@ -152,7 +152,7 @@ static inline void enable_pciirqenb(struct net2280_ep 
 *ep)
  {
   u32 tmp = readl(ep-dev-regs-pciirqenb0);

 - if (ep-dev-pdev-vendor == 0x17cc)
 + if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)

 You ought to be able to make this considerably smaller by using a
 quirk flag in ep-dev.  The flag can indicate whether or not the
 controller uses the LEGACY interface.

 Alan Stern




-- 
Ricardo Ribalda
--
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 08/10 v2.1] usb: gadget: net2280: Code Cleanup

2014-05-20 Thread Ricardo Ribalda Delgado
- Move logical continuations to end of line
- Improve spacing

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
v2: Comments by Alan Stern
-Use octal notation istead of S_I

 drivers/usb/gadget/net2280.c | 155 +--
 drivers/usb/gadget/net2280.h |   4 +-
 2 files changed, 78 insertions(+), 81 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d1d4f4f..d506c83 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -100,9 +100,9 @@ static bool use_dma_chaining;
 static bool use_msi = true;
 
 /* modprobe net2280 use_dma=n etc */
-module_param(use_dma, bool, S_IRUGO);
-module_param(use_dma_chaining, bool, S_IRUGO);
-module_param(use_msi, bool, S_IRUGO);
+module_param(use_dma, bool, 0444);
+module_param(use_dma_chaining, bool, 0444);
+module_param(use_msi, bool, 0444);
 
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
  * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
@@ -111,7 +111,7 @@ module_param(use_msi, bool, S_IRUGO);
 static ushort fifo_mode;
 
 /* modprobe net2280 fifo_mode=1 etc */
-module_param (fifo_mode, ushort, 0644);
+module_param(fifo_mode, ushort, 0644);
 
 /* enable_suspend -- When enabled, the driver will respond to
  * USB suspend requests by powering down the NET2280.  Otherwise,
@@ -121,7 +121,7 @@ module_param (fifo_mode, ushort, 0644);
 static bool enable_suspend;
 
 /* modprobe net2280 enable_suspend=1 etc */
-module_param(enable_suspend, bool, S_IRUGO);
+module_param(enable_suspend, bool, 0444);
 
 /* force full-speed operation */
 static bool full_speed;
@@ -169,8 +169,8 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
 
ep = container_of(_ep, struct net2280_ep, ep);
-   if (!_ep || !desc || ep-desc || _ep-name == ep0name
-   || desc-bDescriptorType != USB_DT_ENDPOINT)
+   if (!_ep || !desc || ep-desc || _ep-name == ep0name ||
+   desc-bDescriptorType != USB_DT_ENDPOINT)
return -EINVAL;
dev = ep-dev;
if (!dev-driver || dev-gadget.speed == USB_SPEED_UNKNOWN)
@@ -220,9 +220,9 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
tmp = (desc-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK);
if (tmp == USB_ENDPOINT_XFER_INT) {
/* erratum 0105 workaround prevents hs NYET */
-   if (dev-chiprev == 0100
-dev-gadget.speed == USB_SPEED_HIGH
-!(desc-bEndpointAddress  USB_DIR_IN))
+   if (dev-chiprev == 0100 
+   dev-gadget.speed == USB_SPEED_HIGH 
+   !(desc-bEndpointAddress  USB_DIR_IN))
writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
ep-regs-ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
@@ -402,8 +402,8 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
-   BIT(DATA_IN_TOKEN_INTERRUPT)
-   , ep-regs-ep_stat);
+   BIT(DATA_IN_TOKEN_INTERRUPT),
+   ep-regs-ep_stat);
 
/* fifo size is handled separately */
 }
@@ -425,9 +425,9 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
writel(BIT(DMA_ABORT_DONE_INTERRUPT) |
   BIT(DMA_PAUSE_DONE_INTERRUPT) |
   BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
-  BIT(DMA_TRANSACTION_DONE_INTERRUPT)
-  /* | BIT(DMA_ABORT) */
-  , ep-dma-dmastat);
+  BIT(DMA_TRANSACTION_DONE_INTERRUPT),
+  /* | BIT(DMA_ABORT), */
+  ep-dma-dmastat);
 
dmastat = readl(ep-dma-dmastat);
if (dmastat == 0x5002) {
@@ -618,15 +618,15 @@ static void out_flush(struct net2280_ep *ep)
 
statp = ep-regs-ep_stat;
writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
-   BIT(DATA_PACKET_RECEIVED_INTERRUPT)
-   , statp);
+   BIT(DATA_PACKET_RECEIVED_INTERRUPT),
+   statp);
writel(BIT(FIFO_FLUSH), statp);
/* Make sure that stap is written */
mb();
tmp = readl(statp);
-   if (tmp  BIT(DATA_OUT_PING_TOKEN_INTERRUPT)
+   if (tmp  BIT(DATA_OUT_PING_TOKEN_INTERRUPT) 
/* high speed did bulk NYET; fifo isn't filling */
-ep-dev-gadget.speed == USB_SPEED_FULL) {
+   ep-dev-gadget.speed == USB_SPEED_FULL) {
unsignedusec;
 
usec = 50;  /* 64 byte bulk/interrupt */
@@ -653,8 +653,8

[PATCH 10/10] usb: gadget: net2280: Use quirks instead of pci id

2014-05-20 Thread Ricardo Ribalda Delgado
Use of quirks improve readability and will be easier to add new devices
to this driver.

Suggested-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 83 +++-
 drivers/usb/gadget/net2280.h |  6 
 2 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 9ced9ff..ce8bc86 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -147,7 +147,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
 {
u32 tmp = readl(ep-dev-regs-pciirqenb0);
 
-   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
+   if (ep-dev-quirks  PLX_LEGACY)
tmp |= BIT(ep-num);
else
tmp |= BIT(ep_bit[ep-num]);
@@ -177,7 +177,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
if ((desc-bEndpointAddress  0x0f) == EP_DONTUSE)
return -EDOM;
 
-   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX) {
+   if (dev-quirks  PLX_SUPERSPEED) {
if ((desc-bEndpointAddress  0x0f) = 0x0c)
return -EDOM;
ep-is_in = !!usb_endpoint_dir_in(desc);
@@ -187,8 +187,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp(desc)  0x1fff;
-   if (ep-num  4  max  64 
-   (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY))
+   if (ep-num  4  max  64  (dev-quirks  PLX_LEGACY))
return -ERANGE;
 
spin_lock_irqsave(dev-lock, flags);
@@ -233,7 +232,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
ep-is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
/* Enable this endpoint */
-   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY) {
+   if (dev-quirks  PLX_LEGACY) {
tmp = ENDPOINT_TYPE;
tmp |= desc-bEndpointAddress;
/* default full fifo lines */
@@ -263,7 +262,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
/* for OUT transfers, block the rx fifo until a read is posted */
if (!ep-is_in)
writel(BIT(SET_NAK_OUT_PACKETS), ep-regs-ep_rsp);
-   else if (dev-pdev-device != 0x2280) {
+   else if (!(dev-quirks  PLX_2280)) {
/* Added for 2282, Don't use nak packets on an in endpoint,
 * this was ignored on 2280
 */
@@ -279,7 +278,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
-   if (dev-pdev-device == 0x2280)
+   if (dev-quirks  PLX_2280)
tmp |= readl(ep-regs-ep_irqenb);
writel(tmp, ep-regs-ep_irqenb);
} else {/* dma, per-request */
@@ -361,7 +360,7 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
/* init to our chosen defaults, notably so that we NAK OUT
 * packets until the driver queues a read (+note erratum 0112)
 */
-   if (!ep-is_in || ep-dev-pdev-device == 0x2280) {
+   if (!ep-is_in || (ep-dev-quirks  PLX_2280)) {
tmp = BIT(SET_NAK_OUT_PACKETS_MODE) |
BIT(SET_NAK_OUT_PACKETS) |
BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
@@ -381,7 +380,7 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
writel(tmp, ep-regs-ep_rsp);
 
/* scrub most status bits, and flush any fifo state */
-   if (ep-dev-pdev-device == 0x2280)
+   if (ep-dev-quirks  PLX_2280)
tmp = BIT(FIFO_OVERFLOW) |
BIT(FIFO_UNDERFLOW);
else
@@ -468,7 +467,7 @@ static int net2280_disable(struct usb_ep *_ep)
spin_lock_irqsave(ep-dev-lock, flags);
nuke(ep);
 
-   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
+   if (ep-dev-quirks  PLX_SUPERSPEED)
ep_reset_338x(ep-dev-regs, ep);
else
ep_reset_228x(ep-dev-regs, ep);
@@ -742,7 +741,7 @@ static void fill_dma_desc(struct net2280_ep *ep,
if (ep-is_in)
dmacount |= BIT(DMA_DIRECTION);
if ((!ep-is_in  (dmacount % ep-ep.maxpacket) != 0) ||
-   ep-dev-pdev-device != 0x2280)
+   !(ep-dev-quirks  PLX_2280))
dmacount |= BIT(END_OF_CHAIN);
 
req-valid = valid;
@@ -786,14 +785,14 @@ static void start_queue(struct net2280_ep *ep, u32 
dmactl, u32 td_dma)
struct net2280_dma_regs __iomem *dma = ep-dma;
unsigned int tmp = BIT(VALID_BIT) | (ep-is_in

[PATCH 06/10] usb: gadget: net2280: Refactor queues_show

2014-05-20 Thread Ricardo Ribalda Delgado
Replace a long and ugly expresion with an already available function.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index bd851de..c3205ec 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1777,15 +1777,7 @@ static ssize_t queues_show(struct device *_dev, struct 
device_attribute *attr,
\n%s (ep%d%s-%s) max %04x %s fifo %d\n,
ep-ep.name, t  USB_ENDPOINT_NUMBER_MASK,
(t  USB_DIR_IN) ? in : out,
-   ({ char *val;
-switch (d-bmAttributes  0x03) {
-case USB_ENDPOINT_XFER_BULK:
-   val = bulk; break;
-case USB_ENDPOINT_XFER_INT:
-   val = intr; break;
-default:
-   val = iso; break;
-} val; }),
+   type_string(d-bmAttributes),
usb_endpoint_maxp (d)  0x1fff,
ep-dma ? dma : pio, ep-fifo_size
);
-- 
2.0.0.rc2

--
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 00/10] net2280: Support for PLX USB338x and cleanout code

2014-05-20 Thread Ricardo Ribalda Delgado
The USB 3380 is a PCI Express Gen 2 to USB 3.0 SuperSpeed Peripheral
Controller. It shares a lot functionatily with the net228x family.

This series of patches includes some resend of previous patches.

Please check the changelog for every patch. This time it has been placed
under the tear line



Ricardo Ribalda Delgado (10):
  usb: gadget: net2280: Add support for PLX USB338X
  usb: gadget: net2280: Dont use magic numbers
  usb: gadget: net2280: Use BIT() macro
  usb: gadget: net2280: Use true/false instead of 1/0
  usb: gadget: net2280: Use module_pci_driver macro
  usb: gadget: net2280: Refactor queues_show
  usb: gadget: net2280: Pass checkpacth.pl test
  usb: gadget: net2280: Code Cleanup
  usb: gadget: net2280: Use pr_* function
  usb: gadget: net2280: Use quirks instead of pci id

 drivers/usb/gadget/Kconfig   |   10 +-
 drivers/usb/gadget/net2280.c | 2752 --
 drivers/usb/gadget/net2280.h |  285 +++--
 include/linux/usb/usb338x.h  |  199 +++
 4 files changed, 2235 insertions(+), 1011 deletions(-)
 create mode 100644 include/linux/usb/usb338x.h

-- 
2.0.0.rc2

--
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 04/10] usb: gadget: net2280: Use true/false instead of 1/0

2014-05-20 Thread Ricardo Ribalda Delgado
For bool variables

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 5b9368d..b43725a 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -95,9 +95,9 @@ static const char *const ep_name [] = {
  * Some gadget drivers work better with the dma support here than others.
  * These two parameters let you use PIO or more aggressive DMA.
  */
-static bool use_dma = 1;
-static bool use_dma_chaining = 0;
-static bool use_msi = 1;
+static bool use_dma = true;
+static bool use_dma_chaining;
+static bool use_msi = true;
 
 /* modprobe net2280 use_dma=n etc */
 module_param (use_dma, bool, S_IRUGO);
@@ -118,7 +118,7 @@ module_param (fifo_mode, ushort, 0644);
  * USB suspend requests will be ignored.  This is acceptable for
  * self-powered devices
  */
-static bool enable_suspend = 0;
+static bool enable_suspend;
 
 /* modprobe net2280 enable_suspend=1 etc */
 module_param (enable_suspend, bool, S_IRUGO);
-- 
2.0.0.rc2

--
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 03/10] usb: gadget: net2280: Use BIT() macro

2014-05-20 Thread Ricardo Ribalda Delgado
Improves readability of the code

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 572 +--
 drivers/usb/gadget/net2280.h |  65 ++---
 2 files changed, 318 insertions(+), 319 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index ba1fdd8..5b9368d 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -144,8 +144,8 @@ static char *type_string (u8 bmAttributes)
 
 #include net2280.h
 
-#define valid_bit  cpu_to_le32 (1  VALID_BIT)
-#define dma_done_iecpu_to_le32 (1  DMA_DONE_INTERRUPT_ENABLE)
+#define valid_bit  cpu_to_le32(BIT(VALID_BIT))
+#define dma_done_iecpu_to_le32(BIT(DMA_DONE_INTERRUPT_ENABLE))
 
 /*-*/
 static inline void enable_pciirqenb(struct net2280_ep *ep)
@@ -153,9 +153,9 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
u32 tmp = readl(ep-dev-regs-pciirqenb0);
 
if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
-   tmp |= 1  ep-num;
+   tmp |= BIT(ep-num);
else
-   tmp |= 1  ep_bit[ep-num];
+   tmp |= BIT(ep_bit[ep-num]);
writel(tmp, ep-dev-regs-pciirqenb0);
 
return;
@@ -218,14 +218,14 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
 
/* set type, direction, address; reset fifo counters */
-   writel ((1  FIFO_FLUSH), ep-regs-ep_stat);
+   writel(BIT(FIFO_FLUSH), ep-regs-ep_stat);
tmp = (desc-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK);
if (tmp == USB_ENDPOINT_XFER_INT) {
/* erratum 0105 workaround prevents hs NYET */
if (dev-chiprev == 0100
 dev-gadget.speed == USB_SPEED_HIGH
 !(desc-bEndpointAddress  USB_DIR_IN))
-   writel ((1  CLEAR_NAK_OUT_PACKETS_MODE),
+   writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
ep-regs-ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
/* catch some particularly blatant driver bugs */
@@ -243,18 +243,18 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
tmp |= desc-bEndpointAddress;
/* default full fifo lines */
tmp |= (4  ENDPOINT_BYTE_COUNT);
-   tmp |= 1  ENDPOINT_ENABLE;
+   tmp |= BIT(ENDPOINT_ENABLE);
ep-is_in = (tmp  USB_DIR_IN) != 0;
} else {
/* In Legacy mode, only OUT endpoints are used */
if (dev-enhanced_mode  ep-is_in) {
tmp = IN_ENDPOINT_TYPE;
-   tmp |= (1  IN_ENDPOINT_ENABLE);
+   tmp |= BIT(IN_ENDPOINT_ENABLE);
/* Not applicable to Legacy */
-   tmp |= (1  ENDPOINT_DIRECTION);
+   tmp |= BIT(ENDPOINT_DIRECTION);
} else {
tmp = OUT_ENDPOINT_TYPE;
-   tmp |= (1  OUT_ENDPOINT_ENABLE);
+   tmp |= BIT(OUT_ENDPOINT_ENABLE);
tmp |= (ep-is_in  ENDPOINT_DIRECTION);
}
 
@@ -267,13 +267,13 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
/* for OUT transfers, block the rx fifo until a read is posted */
if (!ep-is_in)
-   writel ((1  SET_NAK_OUT_PACKETS), ep-regs-ep_rsp);
+   writel(BIT(SET_NAK_OUT_PACKETS), ep-regs-ep_rsp);
else if (dev-pdev-device != 0x2280) {
/* Added for 2282, Don't use nak packets on an in endpoint,
 * this was ignored on 2280
 */
-   writel ((1  CLEAR_NAK_OUT_PACKETS)
-   | (1  CLEAR_NAK_OUT_PACKETS_MODE), ep-regs-ep_rsp);
+   writel(BIT(CLEAR_NAK_OUT_PACKETS) |
+   BIT(CLEAR_NAK_OUT_PACKETS_MODE), ep-regs-ep_rsp);
}
 
writel(tmp, ep-cfg-ep_cfg);
@@ -282,13 +282,13 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
if (!ep-dma) { /* pio, per-packet */
enable_pciirqenb(ep);
 
-   tmp = (1  DATA_PACKET_RECEIVED_INTERRUPT_ENABLE)
-   | (1  DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
+   tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
+   BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
if (dev-pdev-device == 0x2280)
tmp |= readl (ep-regs-ep_irqenb);
writel (tmp, ep-regs-ep_irqenb);
} else {/* dma, per-request */
-   tmp = (1  (8 + ep-num)); /* completion */
+   tmp

[PATCH 02/10] usb: gadget: net2280: Dont use magic numbers

2014-05-20 Thread Ricardo Ribalda Delgado
Instead of using magic numbers use #defines

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 68 +++-
 drivers/usb/gadget/net2280.h |  1 +
 2 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 8112d91..ba1fdd8 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -152,7 +152,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
 {
u32 tmp = readl(ep-dev-regs-pciirqenb0);
 
-   if (ep-dev-pdev-vendor == 0x17cc)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
tmp |= 1  ep-num;
else
tmp |= 1  ep_bit[ep-num];
@@ -182,7 +182,7 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
if ((desc-bEndpointAddress  0x0f) == EP_DONTUSE)
return -EDOM;
 
-   if (dev-pdev-vendor == 0x10b5) {
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX) {
if ((desc-bEndpointAddress  0x0f) = 0x0c)
return -EDOM;
ep-is_in = !!usb_endpoint_dir_in(desc);
@@ -192,7 +192,8 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp (desc)  0x1fff;
-   if (ep-num  4  max  64  (dev-pdev-vendor == 0x17cc))
+   if (ep-num  4  max  64 
+   (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY))
return -ERANGE;
 
spin_lock_irqsave (dev-lock, flags);
@@ -237,7 +238,7 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
ep-is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
/* Enable this endpoint */
-   if (dev-pdev-vendor == 0x17cc) {
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY) {
tmp = ENDPOINT_TYPE;
tmp |= desc-bEndpointAddress;
/* default full fifo lines */
@@ -472,7 +473,7 @@ static int net2280_disable (struct usb_ep *_ep)
spin_lock_irqsave (ep-dev-lock, flags);
nuke (ep);
 
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
ep_reset_338x(ep-dev-regs, ep);
else
ep_reset_228x(ep-dev-regs, ep);
@@ -799,7 +800,7 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, 
u32 td_dma)
writel (readl (dma-dmastat), dma-dmastat);
 
writel (td_dma, dma-dmadesc);
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
dmactl |= (0x01  DMA_REQUEST_OUTSTANDING);
writel (dmactl, dma-dmactl);
 
@@ -995,7 +996,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request 
*_req, gfp_t gfp_flags)
/* DMA request while EP halted */
if (ep-dma 
(readl(ep-regs-ep_rsp)  (1  CLEAR_ENDPOINT_HALT)) 
-   (dev-pdev-vendor == 0x10b5)) {
+   (dev-pdev-vendor == PCI_VENDOR_ID_PLX)) {
int valid = 1;
if (ep-is_in) {
int expect;
@@ -1126,7 +1127,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
} else if (!ep-is_in
 (req-req.length % ep-ep.maxpacket) != 0) {
tmp = readl (ep-regs-ep_stat);
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
return dma_done(ep, req, tmp, 0);
 
/* AVOID TROUBLE HERE by not issuing short reads from
@@ -1234,7 +1235,7 @@ static void abort_dma_338x(struct net2280_ep *ep)
 
 static void abort_dma(struct net2280_ep *ep)
 {
-   if (ep-dev-pdev-vendor == 0x17cc)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
return abort_dma_228x(ep);
return abort_dma_338x(ep);
 }
@@ -1392,7 +1393,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, 
int wedged)
ep-wedged = 1;
} else {
clear_halt (ep);
-   if (ep-dev-pdev-vendor == 0x10b5 
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX 
!list_empty(ep-queue)  ep-td_dma)
restart_dma(ep);
ep-wedged = 0;
@@ -2104,7 +2105,7 @@ static void usb_reset_338x(struct net2280 *dev)
 
 static void usb_reset(struct net2280 *dev)
 {
-   if (dev-pdev-vendor == 0x17cc)
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
return usb_reset_228x(dev);
return usb_reset_338x(dev);
 }
@@ -2260,7 +2261,7 @@ static void usb_reinit_338x(struct

[PATCH 05/10] usb: gadget: net2280: Use module_pci_driver macro

2014-05-20 Thread Ricardo Ribalda Delgado
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index b43725a..bd851de 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -3588,6 +3588,9 @@ static int net2280_probe (struct pci_dev *pdev, const 
struct pci_device_id *id)
void__iomem *base = NULL;
int retval, i;
 
+   if (!use_dma)
+   use_dma_chaining = 0;
+
/* alloc, and start init */
dev = kzalloc (sizeof *dev, GFP_KERNEL);
if (dev == NULL){
@@ -3833,20 +3836,8 @@ static struct pci_driver net2280_pci_driver = {
/* FIXME add power management support */
 };
 
+module_pci_driver(net2280_pci_driver);
+
 MODULE_DESCRIPTION (DRIVER_DESC);
 MODULE_AUTHOR (David Brownell);
 MODULE_LICENSE (GPL);
-
-static int __init init (void)
-{
-   if (!use_dma)
-   use_dma_chaining = 0;
-   return pci_register_driver (net2280_pci_driver);
-}
-module_init (init);
-
-static void __exit cleanup (void)
-{
-   pci_unregister_driver (net2280_pci_driver);
-}
-module_exit (cleanup);
-- 
2.0.0.rc2

--
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 09/10 v2.1] usb: gadget: net2280: Use pr_* function

2014-05-20 Thread Ricardo Ribalda Delgado
Driver was using custom functions WARNING, ERROR, DEBUG, instead of
 pr_err, pr_dgb...

New ep_* macros have been created that use standard pr_* functions.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
v2: Comment by Joe Perches and Alan Stern
  -Use ep_* instead of custom DETDEV macro

 drivers/usb/gadget/net2280.c | 121 +--
 drivers/usb/gadget/net2280.h |  36 +
 2 files changed, 71 insertions(+), 86 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d506c83..9ced9ff 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -42,9 +42,6 @@
  * (at your option) any later version.
  */
 
-#undef DEBUG   /* messages on error and most fault paths */
-#undef VERBOSE /* extra debug messages (success too) */
-
 #include linux/module.h
 #include linux/pci.h
 #include linux/dma-mapping.h
@@ -210,7 +207,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 * use it instead of troublesome (non-bulk) multi-packet DMA.
 */
if (ep-dma  (max % 4) != 0  use_dma_chaining) {
-   DEBUG(ep-dev, %s, no dma for maxpacket %d\n,
+   ep_dbg(ep-dev, %s, no dma for maxpacket %d\n,
ep-ep.name, ep-ep.maxpacket);
ep-dma = NULL;
}
@@ -303,7 +300,7 @@ net2280_enable(struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
 
tmp = desc-bEndpointAddress;
-   DEBUG(dev, enabled %s (ep%d%s-%s) %s max %04x\n,
+   ep_dbg(dev, enabled %s (ep%d%s-%s) %s max %04x\n,
_ep-name, tmp  0x0f, DIR_STRING(tmp),
type_string(desc-bmAttributes),
ep-dma ? dma : pio, max);
@@ -431,7 +428,7 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
 
dmastat = readl(ep-dma-dmastat);
if (dmastat == 0x5002) {
-   WARNING(ep-dev, The dmastat return = %x!!\n,
+   ep_warn(ep-dev, The dmastat return = %x!!\n,
   dmastat);
writel(0x5a, ep-dma-dmastat);
}
@@ -476,7 +473,7 @@ static int net2280_disable(struct usb_ep *_ep)
else
ep_reset_228x(ep-dev-regs, ep);
 
-   VDEBUG(ep-dev, disabled %s %s\n,
+   ep_vdbg(ep-dev, disabled %s %s\n,
ep-dma ? dma : pio, _ep-name);
 
/* synch memory views with the device */
@@ -572,7 +569,7 @@ static void write_fifo(struct net2280_ep *ep, struct 
usb_request *req)
if (count  total)  /* min() cannot be used on a bitfield */
count = total;
 
-   VDEBUG(ep-dev, write %s fifo (IN) %d bytes%s req %p\n,
+   ep_vdbg(ep-dev, write %s fifo (IN) %d bytes%s req %p\n,
ep-ep.name, count,
(count != ep-ep.maxpacket) ?  (short) : ,
req);
@@ -684,7 +681,7 @@ static int read_fifo(struct net2280_ep *ep, struct 
net2280_request *req)
if (count  tmp) {
/* as with DMA, data overflow gets flushed */
if ((tmp % ep-ep.maxpacket) != 0) {
-   ERROR(ep-dev,
+   ep_err(ep-dev,
%s out fifo %d bytes, expected %d\n,
ep-ep.name, count, tmp);
req-req.status = -EOVERFLOW;
@@ -699,7 +696,7 @@ static int read_fifo(struct net2280_ep *ep, struct 
net2280_request *req)
 
is_short = (count == 0) || ((count % ep-ep.maxpacket) != 0);
 
-   VDEBUG(ep-dev, read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n,
+   ep_vdbg(ep-dev, read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n,
ep-ep.name, count, is_short ?  (short) : ,
cleanup ?  flush : , prevent ?  nak : ,
req, req-req.actual, req-req.length);
@@ -925,7 +922,7 @@ done(struct net2280_ep *ep, struct net2280_request *req, 
int status)
usb_gadget_unmap_request(dev-gadget, req-req, ep-is_in);
 
if (status  status != -ESHUTDOWN)
-   VDEBUG(dev, complete %s req %p stat %d len %u/%u\n,
+   ep_vdbg(dev, complete %s req %p stat %d len %u/%u\n,
ep-ep.name, req-req, status,
req-req.actual, req-req.length);
 
@@ -978,7 +975,7 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, 
gfp_t gfp_flags)
}
 
 #if 0
-   VDEBUG(dev, %s queue req %p, len %d buf %p\n,
+   ep_vdbg(dev, %s queue req %p, len %d buf %p\n,
_ep-name, _req, _req-length, _req-buf);
 #endif
 
@@ -1012,7 +1009,7 @@ net2280_queue(struct usb_ep *_ep, struct usb_request 
*_req, gfp_t gfp_flags)
if (ep-num == 0  _req-length == 0) {
allow_status(ep

[PATCH 5/5] usb: gadget: net2280: Use module_pci_driver macro

2014-05-19 Thread Ricardo Ribalda Delgado
Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index b43725a..bd851de 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -3588,6 +3588,9 @@ static int net2280_probe (struct pci_dev *pdev, const 
struct pci_device_id *id)
void__iomem *base = NULL;
int retval, i;
 
+   if (!use_dma)
+   use_dma_chaining = 0;
+
/* alloc, and start init */
dev = kzalloc (sizeof *dev, GFP_KERNEL);
if (dev == NULL){
@@ -3833,20 +3836,8 @@ static struct pci_driver net2280_pci_driver = {
/* FIXME add power management support */
 };
 
+module_pci_driver(net2280_pci_driver);
+
 MODULE_DESCRIPTION (DRIVER_DESC);
 MODULE_AUTHOR (David Brownell);
 MODULE_LICENSE (GPL);
-
-static int __init init (void)
-{
-   if (!use_dma)
-   use_dma_chaining = 0;
-   return pci_register_driver (net2280_pci_driver);
-}
-module_init (init);
-
-static void __exit cleanup (void)
-{
-   pci_unregister_driver (net2280_pci_driver);
-}
-module_exit (cleanup);
-- 
2.0.0.rc0

--
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 4/5] usb: gadget: net2280: Use true/false instead of 1/0

2014-05-19 Thread Ricardo Ribalda Delgado
For bool variables

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 5b9368d..b43725a 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -95,9 +95,9 @@ static const char *const ep_name [] = {
  * Some gadget drivers work better with the dma support here than others.
  * These two parameters let you use PIO or more aggressive DMA.
  */
-static bool use_dma = 1;
-static bool use_dma_chaining = 0;
-static bool use_msi = 1;
+static bool use_dma = true;
+static bool use_dma_chaining;
+static bool use_msi = true;
 
 /* modprobe net2280 use_dma=n etc */
 module_param (use_dma, bool, S_IRUGO);
@@ -118,7 +118,7 @@ module_param (fifo_mode, ushort, 0644);
  * USB suspend requests will be ignored.  This is acceptable for
  * self-powered devices
  */
-static bool enable_suspend = 0;
+static bool enable_suspend;
 
 /* modprobe net2280 enable_suspend=1 etc */
 module_param (enable_suspend, bool, S_IRUGO);
-- 
2.0.0.rc0

--
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/5] usb: gadget: net2280: Use BIT() macro

2014-05-19 Thread Ricardo Ribalda Delgado
Improves readability of the code

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 572 +--
 drivers/usb/gadget/net2280.h |  65 ++---
 2 files changed, 318 insertions(+), 319 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index ba1fdd8..5b9368d 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -144,8 +144,8 @@ static char *type_string (u8 bmAttributes)
 
 #include net2280.h
 
-#define valid_bit  cpu_to_le32 (1  VALID_BIT)
-#define dma_done_iecpu_to_le32 (1  DMA_DONE_INTERRUPT_ENABLE)
+#define valid_bit  cpu_to_le32(BIT(VALID_BIT))
+#define dma_done_iecpu_to_le32(BIT(DMA_DONE_INTERRUPT_ENABLE))
 
 /*-*/
 static inline void enable_pciirqenb(struct net2280_ep *ep)
@@ -153,9 +153,9 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
u32 tmp = readl(ep-dev-regs-pciirqenb0);
 
if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
-   tmp |= 1  ep-num;
+   tmp |= BIT(ep-num);
else
-   tmp |= 1  ep_bit[ep-num];
+   tmp |= BIT(ep_bit[ep-num]);
writel(tmp, ep-dev-regs-pciirqenb0);
 
return;
@@ -218,14 +218,14 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
 
/* set type, direction, address; reset fifo counters */
-   writel ((1  FIFO_FLUSH), ep-regs-ep_stat);
+   writel(BIT(FIFO_FLUSH), ep-regs-ep_stat);
tmp = (desc-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK);
if (tmp == USB_ENDPOINT_XFER_INT) {
/* erratum 0105 workaround prevents hs NYET */
if (dev-chiprev == 0100
 dev-gadget.speed == USB_SPEED_HIGH
 !(desc-bEndpointAddress  USB_DIR_IN))
-   writel ((1  CLEAR_NAK_OUT_PACKETS_MODE),
+   writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
ep-regs-ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
/* catch some particularly blatant driver bugs */
@@ -243,18 +243,18 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
tmp |= desc-bEndpointAddress;
/* default full fifo lines */
tmp |= (4  ENDPOINT_BYTE_COUNT);
-   tmp |= 1  ENDPOINT_ENABLE;
+   tmp |= BIT(ENDPOINT_ENABLE);
ep-is_in = (tmp  USB_DIR_IN) != 0;
} else {
/* In Legacy mode, only OUT endpoints are used */
if (dev-enhanced_mode  ep-is_in) {
tmp = IN_ENDPOINT_TYPE;
-   tmp |= (1  IN_ENDPOINT_ENABLE);
+   tmp |= BIT(IN_ENDPOINT_ENABLE);
/* Not applicable to Legacy */
-   tmp |= (1  ENDPOINT_DIRECTION);
+   tmp |= BIT(ENDPOINT_DIRECTION);
} else {
tmp = OUT_ENDPOINT_TYPE;
-   tmp |= (1  OUT_ENDPOINT_ENABLE);
+   tmp |= BIT(OUT_ENDPOINT_ENABLE);
tmp |= (ep-is_in  ENDPOINT_DIRECTION);
}
 
@@ -267,13 +267,13 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
/* for OUT transfers, block the rx fifo until a read is posted */
if (!ep-is_in)
-   writel ((1  SET_NAK_OUT_PACKETS), ep-regs-ep_rsp);
+   writel(BIT(SET_NAK_OUT_PACKETS), ep-regs-ep_rsp);
else if (dev-pdev-device != 0x2280) {
/* Added for 2282, Don't use nak packets on an in endpoint,
 * this was ignored on 2280
 */
-   writel ((1  CLEAR_NAK_OUT_PACKETS)
-   | (1  CLEAR_NAK_OUT_PACKETS_MODE), ep-regs-ep_rsp);
+   writel(BIT(CLEAR_NAK_OUT_PACKETS) |
+   BIT(CLEAR_NAK_OUT_PACKETS_MODE), ep-regs-ep_rsp);
}
 
writel(tmp, ep-cfg-ep_cfg);
@@ -282,13 +282,13 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
if (!ep-dma) { /* pio, per-packet */
enable_pciirqenb(ep);
 
-   tmp = (1  DATA_PACKET_RECEIVED_INTERRUPT_ENABLE)
-   | (1  DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
+   tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
+   BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
if (dev-pdev-device == 0x2280)
tmp |= readl (ep-regs-ep_irqenb);
writel (tmp, ep-regs-ep_irqenb);
} else {/* dma, per-request */
-   tmp = (1  (8 + ep-num)); /* completion */
+   tmp

[PATCH 2/5] usb: gadget: net2280: Dont use magic numbers

2014-05-19 Thread Ricardo Ribalda Delgado
Instead of using magic numbers use #defines

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 68 +++-
 drivers/usb/gadget/net2280.h |  1 +
 2 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 8112d91..ba1fdd8 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -152,7 +152,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
 {
u32 tmp = readl(ep-dev-regs-pciirqenb0);
 
-   if (ep-dev-pdev-vendor == 0x17cc)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
tmp |= 1  ep-num;
else
tmp |= 1  ep_bit[ep-num];
@@ -182,7 +182,7 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
if ((desc-bEndpointAddress  0x0f) == EP_DONTUSE)
return -EDOM;
 
-   if (dev-pdev-vendor == 0x10b5) {
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX) {
if ((desc-bEndpointAddress  0x0f) = 0x0c)
return -EDOM;
ep-is_in = !!usb_endpoint_dir_in(desc);
@@ -192,7 +192,8 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp (desc)  0x1fff;
-   if (ep-num  4  max  64  (dev-pdev-vendor == 0x17cc))
+   if (ep-num  4  max  64 
+   (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY))
return -ERANGE;
 
spin_lock_irqsave (dev-lock, flags);
@@ -237,7 +238,7 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
ep-is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
/* Enable this endpoint */
-   if (dev-pdev-vendor == 0x17cc) {
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY) {
tmp = ENDPOINT_TYPE;
tmp |= desc-bEndpointAddress;
/* default full fifo lines */
@@ -472,7 +473,7 @@ static int net2280_disable (struct usb_ep *_ep)
spin_lock_irqsave (ep-dev-lock, flags);
nuke (ep);
 
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
ep_reset_338x(ep-dev-regs, ep);
else
ep_reset_228x(ep-dev-regs, ep);
@@ -799,7 +800,7 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, 
u32 td_dma)
writel (readl (dma-dmastat), dma-dmastat);
 
writel (td_dma, dma-dmadesc);
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
dmactl |= (0x01  DMA_REQUEST_OUTSTANDING);
writel (dmactl, dma-dmactl);
 
@@ -995,7 +996,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request 
*_req, gfp_t gfp_flags)
/* DMA request while EP halted */
if (ep-dma 
(readl(ep-regs-ep_rsp)  (1  CLEAR_ENDPOINT_HALT)) 
-   (dev-pdev-vendor == 0x10b5)) {
+   (dev-pdev-vendor == PCI_VENDOR_ID_PLX)) {
int valid = 1;
if (ep-is_in) {
int expect;
@@ -1126,7 +1127,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
} else if (!ep-is_in
 (req-req.length % ep-ep.maxpacket) != 0) {
tmp = readl (ep-regs-ep_stat);
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
return dma_done(ep, req, tmp, 0);
 
/* AVOID TROUBLE HERE by not issuing short reads from
@@ -1234,7 +1235,7 @@ static void abort_dma_338x(struct net2280_ep *ep)
 
 static void abort_dma(struct net2280_ep *ep)
 {
-   if (ep-dev-pdev-vendor == 0x17cc)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
return abort_dma_228x(ep);
return abort_dma_338x(ep);
 }
@@ -1392,7 +1393,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, 
int wedged)
ep-wedged = 1;
} else {
clear_halt (ep);
-   if (ep-dev-pdev-vendor == 0x10b5 
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX 
!list_empty(ep-queue)  ep-td_dma)
restart_dma(ep);
ep-wedged = 0;
@@ -2104,7 +2105,7 @@ static void usb_reset_338x(struct net2280 *dev)
 
 static void usb_reset(struct net2280 *dev)
 {
-   if (dev-pdev-vendor == 0x17cc)
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
return usb_reset_228x(dev);
return usb_reset_338x(dev);
 }
@@ -2260,7 +2261,7 @@ static void usb_reinit_338x(struct

Re: [PATCH 3/5] usb: gadget: net2280: Use BIT() macro

2014-05-19 Thread Ricardo Ribalda Delgado
Hello David

I dont want to start a flame war here :) but  In the particular case
of hardware registers I believe it does.

This patch has been posted because on a previous patch to support the
usb3380, one of the requested changes was to use this macro. In order
to have consistent code in the file I have posted this patch.

BTW, I havent defined the bit macro, just used it :P

Cheers!


On Mon, May 19, 2014 at 12:18 PM, David Laight david.lai...@aculab.com wrote:
 From: Ricardo Ribalda Delgado
 Improves readability of the code

 Personally I don't find macros like BIT() improve the readability at all.
 What next? Maybe:

 #define ADD(a, b) ((a) + (b))

 David






-- 
Ricardo Ribalda
--
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 4/5] usb: gadget: net2280: Code Cleanup

2014-05-19 Thread Ricardo Ribalda Delgado
Move logical continuations to end of line

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 145 +--
 drivers/usb/gadget/net2280.h |   4 +-
 2 files changed, 73 insertions(+), 76 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 35527d0..e67ae96 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -169,8 +169,8 @@ static int net2280_enable(struct usb_ep *_ep,
static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
 
ep = container_of(_ep, struct net2280_ep, ep);
-   if (!_ep || !desc || ep-desc || _ep-name == ep0name
-   || desc-bDescriptorType != USB_DT_ENDPOINT)
+   if (!_ep || !desc || ep-desc || _ep-name == ep0name ||
+   desc-bDescriptorType != USB_DT_ENDPOINT)
return -EINVAL;
dev = ep-dev;
if (!dev-driver || dev-gadget.speed == USB_SPEED_UNKNOWN)
@@ -220,9 +220,9 @@ static int net2280_enable(struct usb_ep *_ep,
tmp = (desc-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK);
if (tmp == USB_ENDPOINT_XFER_INT) {
/* erratum 0105 workaround prevents hs NYET */
-   if (dev-chiprev == 0100
-dev-gadget.speed == USB_SPEED_HIGH
-!(desc-bEndpointAddress  USB_DIR_IN))
+   if (dev-chiprev == 0100 
+   dev-gadget.speed == USB_SPEED_HIGH 
+   !(desc-bEndpointAddress  USB_DIR_IN))
writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
ep-regs-ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
@@ -402,8 +402,8 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
-   BIT(DATA_IN_TOKEN_INTERRUPT)
-   , ep-regs-ep_stat);
+   BIT(DATA_IN_TOKEN_INTERRUPT),
+   ep-regs-ep_stat);
 
/* fifo size is handled separately */
 }
@@ -425,9 +425,9 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
writel(BIT(DMA_ABORT_DONE_INTERRUPT) |
   BIT(DMA_PAUSE_DONE_INTERRUPT) |
   BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
-  BIT(DMA_TRANSACTION_DONE_INTERRUPT)
-  /* | BIT(DMA_ABORT) */
-  , ep-dma-dmastat);
+  BIT(DMA_TRANSACTION_DONE_INTERRUPT),
+  /* | BIT(DMA_ABORT), */
+  ep-dma-dmastat);
 
dmastat = readl(ep-dma-dmastat);
if (dmastat == 0x5002) {
@@ -618,15 +618,15 @@ static void out_flush(struct net2280_ep *ep)
 
statp = ep-regs-ep_stat;
writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
-   BIT(DATA_PACKET_RECEIVED_INTERRUPT)
-   , statp);
+   BIT(DATA_PACKET_RECEIVED_INTERRUPT),
+   statp);
writel(BIT(FIFO_FLUSH), statp);
/* Make sure stap is written before readded back */
mb();
tmp = readl(statp);
-   if (tmp  BIT(DATA_OUT_PING_TOKEN_INTERRUPT)
+   if (tmp  BIT(DATA_OUT_PING_TOKEN_INTERRUPT) 
/* high speed did bulk NYET; fifo isn't filling */
-ep-dev-gadget.speed == USB_SPEED_FULL) {
+   ep-dev-gadget.speed == USB_SPEED_FULL) {
unsignedusec;
 
usec = 50;  /* 64 byte bulk/interrupt */
@@ -653,8 +653,8 @@ static int read_fifo(struct net2280_ep *ep, struct 
net2280_request *req)
/* erratum 0106 ... packets coming in during fifo reads might
 * be incompletely rejected.  not all cases have workarounds.
 */
-   if (ep-dev-chiprev == 0x0100
-ep-dev-gadget.speed == USB_SPEED_FULL) {
+   if (ep-dev-chiprev == 0x0100 
+   ep-dev-gadget.speed == USB_SPEED_FULL) {
udelay(1);
tmp = readl(ep-regs-ep_stat);
if ((tmp  BIT(NAK_OUT_PACKETS)))
@@ -726,8 +726,8 @@ static int read_fifo(struct net2280_ep *ep, struct 
net2280_request *req)
(void) readl(ep-regs-ep_rsp);
}
 
-   return is_short || ((req-req.actual == req-req.length)
-!req-req.zero);
+   return is_short || ((req-req.actual == req-req.length) 
+   !req-req.zero);
 }
 
 /* fill out dma descriptor to match a given request */
@@ -744,8 +744,8 @@ static void fill_dma_desc(struct net2280_ep *ep,
 */
if (ep-is_in)
dmacount |= BIT(DMA_DIRECTION);
-   if ((!ep-is_in  (dmacount % ep-ep.maxpacket) != 0

[PATCH 1/5] usb: gadget: net2280: Refactor queues_show

2014-05-19 Thread Ricardo Ribalda Delgado
Replace a long and ugly expresion with an already available function.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index bd851de..c3205ec 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1777,15 +1777,7 @@ static ssize_t queues_show(struct device *_dev, struct 
device_attribute *attr,
\n%s (ep%d%s-%s) max %04x %s fifo %d\n,
ep-ep.name, t  USB_ENDPOINT_NUMBER_MASK,
(t  USB_DIR_IN) ? in : out,
-   ({ char *val;
-switch (d-bmAttributes  0x03) {
-case USB_ENDPOINT_XFER_BULK:
-   val = bulk; break;
-case USB_ENDPOINT_XFER_INT:
-   val = intr; break;
-default:
-   val = iso; break;
-} val; }),
+   type_string(d-bmAttributes),
usb_endpoint_maxp (d)  0x1fff,
ep-dma ? dma : pio, ep-fifo_size
);
-- 
2.0.0.rc2

--
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 5/5] usb: gadget: net2280: Use pr_* function

2014-05-19 Thread Ricardo Ribalda Delgado
Driver was using custom functions WARNING, ERROR, DEBUG, instead of
 pr_err, pr_dgb...

VDEBUG has also been replaced by DEBUG because the same functionality
(or even better) can be achieved with dynamic printk.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 130 +++
 drivers/usb/gadget/net2280.h |  31 +--
 2 files changed, 71 insertions(+), 90 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index e67ae96..11800bb 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -210,7 +210,7 @@ static int net2280_enable(struct usb_ep *_ep,
 * use it instead of troublesome (non-bulk) multi-packet DMA.
 */
if (ep-dma  (max % 4) != 0  use_dma_chaining) {
-   DEBUG(ep-dev, %s, no dma for maxpacket %d\n,
+   dev_dbg(GETDEV(ep-dev), %s, no dma for maxpacket %d\n,
ep-ep.name, ep-ep.maxpacket);
ep-dma = NULL;
}
@@ -303,7 +303,7 @@ static int net2280_enable(struct usb_ep *_ep,
}
 
tmp = desc-bEndpointAddress;
-   DEBUG(dev, enabled %s (ep%d%s-%s) %s max %04x\n,
+   dev_dbg(GETDEV(dev), enabled %s (ep%d%s-%s) %s max %04x\n,
_ep-name, tmp  0x0f, DIR_STRING(tmp),
type_string(desc-bmAttributes),
ep-dma ? dma : pio, max);
@@ -431,7 +431,7 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
 
dmastat = readl(ep-dma-dmastat);
if (dmastat == 0x5002) {
-   WARNING(ep-dev, The dmastat return = %x!!\n,
+   dev_warn(GETDEV(ep-dev), The dmastat return = %x!!\n,
   dmastat);
writel(0x5a, ep-dma-dmastat);
}
@@ -476,7 +476,7 @@ static int net2280_disable(struct usb_ep *_ep)
else
ep_reset_228x(ep-dev-regs, ep);
 
-   VDEBUG(ep-dev, disabled %s %s\n,
+   dev_dbg(GETDEV(ep-dev), disabled %s %s\n,
ep-dma ? dma : pio, _ep-name);
 
/* synch memory views with the device */
@@ -572,7 +572,7 @@ static void write_fifo(struct net2280_ep *ep, struct 
usb_request *req)
if (count  total)  /* min() cannot be used on a bitfield */
count = total;
 
-   VDEBUG(ep-dev, write %s fifo (IN) %d bytes%s req %p\n,
+   dev_dbg(GETDEV(ep-dev), write %s fifo (IN) %d bytes%s req %p\n,
ep-ep.name, count,
(count != ep-ep.maxpacket) ?  (short) : ,
req);
@@ -684,7 +684,7 @@ static int read_fifo(struct net2280_ep *ep, struct 
net2280_request *req)
if (count  tmp) {
/* as with DMA, data overflow gets flushed */
if ((tmp % ep-ep.maxpacket) != 0) {
-   ERROR(ep-dev,
+   dev_err(GETDEV(ep-dev),
%s out fifo %d bytes, expected %d\n,
ep-ep.name, count, tmp);
req-req.status = -EOVERFLOW;
@@ -699,7 +699,7 @@ static int read_fifo(struct net2280_ep *ep, struct 
net2280_request *req)
 
is_short = (count == 0) || ((count % ep-ep.maxpacket) != 0);
 
-   VDEBUG(ep-dev, read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n,
+   dev_dbg(GETDEV(ep-dev), read %s fifo (OUT) %d bytes%s%s%s req %p 
%d/%d\n,
ep-ep.name, count, is_short ?  (short) : ,
cleanup ?  flush : , prevent ?  nak : ,
req, req-req.actual, req-req.length);
@@ -925,7 +925,7 @@ static void done(struct net2280_ep *ep,
usb_gadget_unmap_request(dev-gadget, req-req, ep-is_in);
 
if (status  status != -ESHUTDOWN)
-   VDEBUG(dev, complete %s req %p stat %d len %u/%u\n,
+   dev_dbg(GETDEV(dev), complete %s req %p stat %d len %u/%u\n,
ep-ep.name, req-req, status,
req-req.actual, req-req.length);
 
@@ -978,7 +978,7 @@ static int net2280_queue(struct usb_ep *_ep,
}
 
 #if 0
-   VDEBUG(dev, %s queue req %p, len %d buf %p\n,
+   dev_dbg(GETDEV(dev), %s queue req %p, len %d buf %p\n,
_ep-name, _req, _req-length, _req-buf);
 #endif
 
@@ -1012,7 +1012,8 @@ static int net2280_queue(struct usb_ep *_ep,
if (ep-num == 0  _req-length == 0) {
allow_status(ep);
done(ep, req, 0);
-   VDEBUG(dev, %s status ack\n, ep-ep.name);
+   dev_dbg(GETDEV(dev),
+   %s status ack\n, ep-ep.name);
goto done;
}
 
@@ -1130,7 +1131,7 @@ static void scan_dma_completions(struct net2280_ep *ep

[PATCH 0/5] usb: gadget: net2280: Code cleanout

2014-05-19 Thread Ricardo Ribalda Delgado

net2280 was developed before the CodeStyle was enforced. This set of patches
intend to improve the readability of the code.

This set of patches should be applied after:

[PATCH 5/5] usb: gadget: net2280: Use module_pci_driver macro

In order to avoid mail list spamming I have not resubmitted the 10 patches, only
the new ones.


Ricardo Ribalda Delgado (5):
  usb: gadget: net2280: Refactor queues_show
  usb: gadget: net2280: Use S_I macros
  usb: gadget: net2280: Pass checkpacth.pl test
  usb: gadget: net2280: Code Cleanup
  usb: gadget: net2280: Use pr_* function

 drivers/usb/gadget/net2280.c | 1329 +-
 drivers/usb/gadget/net2280.h |   97 ++-
 2 files changed, 695 insertions(+), 731 deletions(-)

-- 
2.0.0.rc2

--
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/5] usb: gadget: net2280: Use S_I macros

2014-05-19 Thread Ricardo Ribalda Delgado
Instead of octal notation, to be consistent around the file.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index c3205ec..5b2ab68 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -111,7 +111,7 @@ module_param(use_msi, bool, S_IRUGO);
 static ushort fifo_mode = 0;
 
 /* modprobe net2280 fifo_mode=1 etc */
-module_param (fifo_mode, ushort, 0644);
+module_param(fifo_mode, ushort, S_IRUGO | S_IWUSR);
 
 /* enable_suspend -- When enabled, the driver will respond to
  * USB suspend requests by powering down the NET2280.  Otherwise,
@@ -125,7 +125,7 @@ module_param (enable_suspend, bool, S_IRUGO);
 
 /* force full-speed operation */
 static bool full_speed;
-module_param(full_speed, bool, 0444);
+module_param(full_speed, bool, S_IRUGO);
 MODULE_PARM_DESC(full_speed, force full-speed mode -- for testing only!);
 
 #defineDIR_STRING(bAddress) (((bAddress)  USB_DIR_IN) ? in : out)
-- 
2.0.0.rc2

--
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 5/5] usb: gadget: net2280: Use pr_* function

2014-05-19 Thread Ricardo Ribalda Delgado
Hello Joe

I think dev_vdg cannot be controlled with DYNAMIC_DEBUG, therefore I
replaced it with dev_dbg.

But if you prefer to use dev_dbg, I will modify it to use dev_dbg


Thanks!

On Mon, May 19, 2014 at 9:16 PM, Joe Perches j...@perches.com wrote:
 On Mon, 2014-05-19 at 21:11 +0200, Ricardo Ribalda Delgado wrote:
 VDEBUG has also been replaced by DEBUG because the same   functionality
 (or even better) can be achieved with dynamic printk.

 dev_vdbg exists for that purpose.





-- 
Ricardo Ribalda
--
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/5] usb: gadget: net2280: Use S_I macros

2014-05-19 Thread Ricardo Ribalda Delgado
Hello Alan

What about using octal notation in all the file and merge the patch
with the other big patch of the series? I am trying to have some
consistency in the file :)


Thanks!

On Mon, May 19, 2014 at 9:30 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Mon, 19 May 2014, Ricardo Ribalda Delgado wrote:

 Instead of octal notation, to be consistent around the file.

 Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
 ---
  drivers/usb/gadget/net2280.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
 index c3205ec..5b2ab68 100644
 --- a/drivers/usb/gadget/net2280.c
 +++ b/drivers/usb/gadget/net2280.c
 @@ -111,7 +111,7 @@ module_param(use_msi, bool, S_IRUGO);
  static ushort fifo_mode = 0;

  /* modprobe net2280 fifo_mode=1 etc */
 -module_param (fifo_mode, ushort, 0644);
 +module_param(fifo_mode, ushort, S_IRUGO | S_IWUSR);

 I don't think this is necessary, in and of itself.  In my opinion, the
 macros are a lot harder to figure out than the octal values.

 Don't bother making this change.  It's useless churn.

 Alan Stern




-- 
Ricardo Ribalda
--
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 5/5] usb: gadget: net2280: Use pr_* function

2014-05-19 Thread Ricardo Ribalda Delgado
Hello Joe


OK, then I will use dev_vdbg. Thanks!



On Mon, May 19, 2014 at 9:42 PM, Joe Perches j...@perches.com wrote:
 On Mon, 2014-05-19 at 21:33 +0200, Ricardo Ribalda Delgado wrote:
 I think dev_vdg cannot be controlled with DYNAMIC_DEBUG, therefore I
 replaced it with dev_dbg.

 But if you prefer to use dev_dbg, I will modify it to use dev_dbg

 s/VDEBUG/dev_vdbg/

 dev_vdbg can be controlled by DYNAMIC_DEBUG.

 dev_vdbg is dev_dbg when VERBOSE_DEBUG is set.

 include/linux/device.h-#ifdef VERBOSE_DEBUG
 include/linux/device.h:#define dev_vdbg dev_dbg
 include/linux/device.h-#else
 include/linux/device.h:#define dev_vdbg(dev, format, arg...)  
   \
 include/linux/device.h-({ 
   \
 include/linux/device.h- if (0)
   \
 include/linux/device.h- dev_printk(KERN_DEBUG, dev, format, ##arg);   
   \
 include/linux/device.h- 0;
   \
 include/linux/device.h-})





-- 
Ricardo Ribalda
--
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/5] usb: gadget: net2280: Code Cleanup

2014-05-19 Thread Ricardo Ribalda Delgado
Hello Alan


I am trying to be consistent around the file. On a previous patch I
was asked to move the operators at the end. I did so, and now I am
modifying the file to look alike.



On Mon, May 19, 2014 at 9:43 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Mon, 19 May 2014, Ricardo Ribalda Delgado wrote:

 Move logical continuations to end of line

 This is almost totally unnecessary.  Some people prefer the
 operators at the end of the first line, other people prefer them at the
 start of the next line.  It's just a matter of taste and it doesn't
 matter.

 @@ -402,8 +402,8 @@ static void ep_reset_228x(struct net2280_regs __iomem 
 *regs,
   BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
   BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
   BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
 - BIT(DATA_IN_TOKEN_INTERRUPT)
 - , ep-regs-ep_stat);
 + BIT(DATA_IN_TOKEN_INTERRUPT),
 + ep-regs-ep_stat);

 This is an example of the one type of change that does make sense.
 Nobody should start lines with a ','.

 Alan Stern




-- 
Ricardo Ribalda
--
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 5/5] usb: gadget: net2280: Use pr_* function

2014-05-19 Thread Ricardo Ribalda Delgado
Hello Alan

I really think that setting/unsetting DEBUG and VERBOSE is not a good
idea, and the generic functions are there to be used.

What do you think that makes it more difficult to read? The GETDEV macro?

Cheers

On Mon, May 19, 2014 at 9:44 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Mon, 19 May 2014, Ricardo Ribalda Delgado wrote:

 Driver was using custom functions WARNING, ERROR, DEBUG, instead of
  pr_err, pr_dgb...

 What's wrong with that, and why bother to change it?

 diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
 index e67ae96..11800bb 100644
 --- a/drivers/usb/gadget/net2280.c
 +++ b/drivers/usb/gadget/net2280.c
 @@ -210,7 +210,7 @@ static int net2280_enable(struct usb_ep *_ep,
* use it instead of troublesome (non-bulk) multi-packet DMA.
*/
   if (ep-dma  (max % 4) != 0  use_dma_chaining) {
 - DEBUG(ep-dev, %s, no dma for maxpacket %d\n,
 + dev_dbg(GETDEV(ep-dev), %s, no dma for maxpacket %d\n,

 Don't you think that the new code is harder to read than the original?
 Why go to a lot of trouble just to make things worse?

 Alan Stern




-- 
Ricardo Ribalda
--
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 5/5] usb: gadget: net2280: Use pr_* function

2014-05-19 Thread Ricardo Ribalda Delgado
Good idea.

 I am going to define ep_* and use them.

btw, DEBUG cannot be used if not unset, because there is a namespace collision.

Regards!



On Mon, May 19, 2014 at 10:29 PM, Joe Perches j...@perches.com wrote:
 On Mon, 2014-05-19 at 16:17 -0400, Alan Stern wrote:
 On Mon, 19 May 2014, Ricardo Ribalda Delgado wrote:
  I really think that setting/unsetting DEBUG and VERBOSE is not a good
  idea, and the generic functions are there to be used.
 You could change the definitions of DEBUG and VDEBUG to make them use
 the generic functions.
  What do you think that makes it more difficult to read? The GETDEV macro?

 Maybe add ep_level helper macros and remove xprint

 #define ep_err(ep, fmt, ...)\
 dev_err((ep)-dev-pdev-dev, fmt, ##__VA_ARGS__)
 #define ep_warn(ep, fmt, ...)   \
 dev_warn((ep)-dev-pdev-dev, fmt, ##__VA_ARGS__)
 #define ep_info(ep, fmt, ...)   \
 dev_info((ep)-dev-pdev-dev, fmt, ##__VA_ARGS__)
 #define ep_dbg(ep, fmt, ...)\
 dev_dbg((ep)-dev-pdev-dev, fmt, ##__VA_ARGS__)
 #define ep_vdbg(ep, fmt, ...)   \
 dev_vdbg((ep)-dev-pdev-dev, fmt, ##__VA_ARGS__)

 but even that conversion isn't straightforward.





-- 
Ricardo Ribalda
--
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/9] usb: gadget: net2280: Dont use magic numbers

2014-05-19 Thread Ricardo Ribalda Delgado
Instead of using magic numbers use #defines

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 drivers/usb/gadget/net2280.c | 68 +++-
 drivers/usb/gadget/net2280.h |  1 +
 2 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 8112d91..ba1fdd8 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -152,7 +152,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
 {
u32 tmp = readl(ep-dev-regs-pciirqenb0);
 
-   if (ep-dev-pdev-vendor == 0x17cc)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
tmp |= 1  ep-num;
else
tmp |= 1  ep_bit[ep-num];
@@ -182,7 +182,7 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
if ((desc-bEndpointAddress  0x0f) == EP_DONTUSE)
return -EDOM;
 
-   if (dev-pdev-vendor == 0x10b5) {
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX) {
if ((desc-bEndpointAddress  0x0f) = 0x0c)
return -EDOM;
ep-is_in = !!usb_endpoint_dir_in(desc);
@@ -192,7 +192,8 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
 
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp (desc)  0x1fff;
-   if (ep-num  4  max  64  (dev-pdev-vendor == 0x17cc))
+   if (ep-num  4  max  64 
+   (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY))
return -ERANGE;
 
spin_lock_irqsave (dev-lock, flags);
@@ -237,7 +238,7 @@ net2280_enable (struct usb_ep *_ep, const struct 
usb_endpoint_descriptor *desc)
}
ep-is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
/* Enable this endpoint */
-   if (dev-pdev-vendor == 0x17cc) {
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY) {
tmp = ENDPOINT_TYPE;
tmp |= desc-bEndpointAddress;
/* default full fifo lines */
@@ -472,7 +473,7 @@ static int net2280_disable (struct usb_ep *_ep)
spin_lock_irqsave (ep-dev-lock, flags);
nuke (ep);
 
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
ep_reset_338x(ep-dev-regs, ep);
else
ep_reset_228x(ep-dev-regs, ep);
@@ -799,7 +800,7 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, 
u32 td_dma)
writel (readl (dma-dmastat), dma-dmastat);
 
writel (td_dma, dma-dmadesc);
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
dmactl |= (0x01  DMA_REQUEST_OUTSTANDING);
writel (dmactl, dma-dmactl);
 
@@ -995,7 +996,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request 
*_req, gfp_t gfp_flags)
/* DMA request while EP halted */
if (ep-dma 
(readl(ep-regs-ep_rsp)  (1  CLEAR_ENDPOINT_HALT)) 
-   (dev-pdev-vendor == 0x10b5)) {
+   (dev-pdev-vendor == PCI_VENDOR_ID_PLX)) {
int valid = 1;
if (ep-is_in) {
int expect;
@@ -1126,7 +1127,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
} else if (!ep-is_in
 (req-req.length % ep-ep.maxpacket) != 0) {
tmp = readl (ep-regs-ep_stat);
-   if (ep-dev-pdev-vendor == 0x10b5)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX)
return dma_done(ep, req, tmp, 0);
 
/* AVOID TROUBLE HERE by not issuing short reads from
@@ -1234,7 +1235,7 @@ static void abort_dma_338x(struct net2280_ep *ep)
 
 static void abort_dma(struct net2280_ep *ep)
 {
-   if (ep-dev-pdev-vendor == 0x17cc)
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
return abort_dma_228x(ep);
return abort_dma_338x(ep);
 }
@@ -1392,7 +1393,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, 
int wedged)
ep-wedged = 1;
} else {
clear_halt (ep);
-   if (ep-dev-pdev-vendor == 0x10b5 
+   if (ep-dev-pdev-vendor == PCI_VENDOR_ID_PLX 
!list_empty(ep-queue)  ep-td_dma)
restart_dma(ep);
ep-wedged = 0;
@@ -2104,7 +2105,7 @@ static void usb_reset_338x(struct net2280 *dev)
 
 static void usb_reset(struct net2280 *dev)
 {
-   if (dev-pdev-vendor == 0x17cc)
+   if (dev-pdev-vendor == PCI_VENDOR_ID_PLX_LEGACY)
return usb_reset_228x(dev);
return usb_reset_338x(dev);
 }
@@ -2260,7 +2261,7 @@ static void usb_reinit_338x(struct

  1   2   >