RE: [PATCH 3/3] usb: chipidea: use hrtimer for otg fsm timers

2015-02-28 Thread Peter Chen

 
 @@ -579,8 +579,15 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
* a_idle to a_wait_vrise when power up
*/
   if ((ci-fsm.id) || (ci-id_event) ||
 - (ci-fsm.power_up))
 + (ci-fsm.power_up)) {
   ci_otg_queue_work(ci);
 + } else {
 + /* Enable data pulse irq */
 + hw_write(ci, OP_PORTSC,
 PORTSC_W1C_BITS |
 +
   PORTSC_PP, 0);
 + hw_write_otgsc(ci, OTGSC_DPIS,
 OTGSC_DPIS);
 + hw_write_otgsc(ci, OTGSC_DPIE,
 OTGSC_DPIE);
 + }
   
Can we enable data pulse enable at initialization routine?
  
   This irq should be enabled only for A-device when there is no
   session (host role, no vbus, so in A_IDLE state), and disable it after 
   receive
 its irq(SRP).
  
 
  But from the code, I don't know the state is at A_IDLE, mind to change?
 
 
 It's already under condition of A_IDLE as below:
 
 if (ci-fsm.otg-state == OTG_STATE_A_IDLE) {
   ... ...
   if () {
   ... ...
   } else {
   /* Enable data pulse irq */
   ...
   }
 }
 
 That's a change to avoid to do it in timer out(VFALL) handler, so put it here
 (after otg fsm transit to A_IDLE and will no further state transitions).
 

Oh, I have no seen it in patch file. Send your v2, then, I can have a test.

Peter
--
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 v5 3/4] usb: storage: adjust module reference for scsi host

2015-02-28 Thread Akinobu Mita
While accessing a unusual usb storage (ums-alauda, ums-cypress, ...),
the module reference count is not incremented.  Because these drivers
allocate scsi hosts with usb_stor_host_template defined in usb-storage
module.  So these drivers always can be unloaded.

This fixes it by passing correct module reference to usb_stor_probe1() so
that .module field in struct Scsi_Host can be adjusted.

Signed-off-by: Akinobu Mita akinobu.m...@gmail.com
Acked-by: Alan Stern st...@rowland.harvard.edu
Cc: Matthew Dharm mdharm-...@one-eyed-alien.net
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Christoph Hellwig h...@lst.de
Cc: James E.J. Bottomley jbottom...@parallels.com
Cc: linux-usb@vger.kernel.org
Cc: usb-stor...@lists.one-eyed-alien.net
Cc: linux-s...@vger.kernel.org
---
No change from v3

 drivers/usb/storage/usb.c | 8 +---
 drivers/usb/storage/usb.h | 7 +--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d468d02..3bb2558 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -911,10 +911,11 @@ static unsigned int usb_stor_sg_tablesize(struct 
usb_interface *intf)
 }
 
 /* First part of general USB mass-storage probing */
-int usb_stor_probe1(struct us_data **pus,
+int __usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
-   struct us_unusual_dev *unusual_dev)
+   struct us_unusual_dev *unusual_dev,
+   struct module *owner)
 {
struct Scsi_Host *host;
struct us_data *us;
@@ -937,6 +938,7 @@ int usb_stor_probe1(struct us_data **pus,
 */
host-max_cmd_len = 16;
host-sg_tablesize = usb_stor_sg_tablesize(intf);
+   host-module = owner;
*pus = us = host_to_us(host);
mutex_init((us-dev_mutex));
us_set_lock_class(us-dev_mutex, intf);
@@ -969,7 +971,7 @@ BadDevice:
release_everything(us);
return result;
 }
-EXPORT_SYMBOL_GPL(usb_stor_probe1);
+EXPORT_SYMBOL_GPL(__usb_stor_probe1);
 
 /* Second part of general USB mass-storage probing */
 int usb_stor_probe2(struct us_data *us)
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 307e339..0cb74ba 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -194,10 +194,13 @@ extern int usb_stor_reset_resume(struct usb_interface 
*iface);
 extern int usb_stor_pre_reset(struct usb_interface *iface);
 extern int usb_stor_post_reset(struct usb_interface *iface);
 
-extern int usb_stor_probe1(struct us_data **pus,
+extern int __usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
-   struct us_unusual_dev *unusual_dev);
+   struct us_unusual_dev *unusual_dev,
+   struct module *owner);
+#define usb_stor_probe1(pus, intf, id, unusual_dev) \
+   __usb_stor_probe1(pus, intf, id, unusual_dev, THIS_MODULE)
 extern int usb_stor_probe2(struct us_data *us);
 extern void usb_stor_disconnect(struct usb_interface *intf);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/4] scsi: add ability to adjust module reference for scsi host

2015-02-28 Thread Akinobu Mita
While accessing a scsi_device, the use count of the underlying LLDD module
is incremented.  The module reference is retrieved through .module field of
struct scsi_host_template.

This mapping between scsi_device and underlying LLDD module works well
except ufs, unusual usb storage drivers, and sub drivers for esp_scsi.
These drivers consist with core driver and actual LLDDs, and
scsi_host_template is defined in the core driver.  So the actual LLDDs can
be unloaded even if the scsi_device is being accessed.

This adds .module field in struct Scsi_Host and let the module reference
be retrieved though it instead of struct scsi_host_template.  This allows
the actual LLDDs adjust module reference.

Signed-off-by: Akinobu Mita akinobu.m...@gmail.com
Reviewed-by: Hannes Reinecke h...@suse.de
Cc: Vinayak Holikatti vinholika...@gmail.com
Cc: Dolev Raviv dra...@codeaurora.org
Cc: Sujit Reddy Thumma sthu...@codeaurora.org
Cc: Subhash Jadavani subha...@codeaurora.org
Cc: Christoph Hellwig h...@lst.de
Cc: James E.J. Bottomley jbottom...@parallels.com
Cc: Matthew Dharm mdharm-...@one-eyed-alien.net
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Alan Stern st...@rowland.harvard.edu
Cc: David S. Miller da...@davemloft.net
Cc: Hannes Reinecke h...@suse.de
Cc: linux-usb@vger.kernel.org
Cc: usb-stor...@lists.one-eyed-alien.net
Cc: linux-s...@vger.kernel.org
---
Change from v3
- Rebased to the 4.0-rc1

 drivers/scsi/hosts.c | 1 +
 drivers/scsi/scsi.c  | 4 ++--
 include/scsi/scsi_host.h | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 8bb173e..21f1442 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -411,6 +411,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template 
*sht, int privsize)
 */
shost-max_cmd_len = 12;
shost-hostt = sht;
+   shost-module = sht-module;
shost-this_id = sht-this_id;
shost-can_queue = sht-can_queue;
shost-sg_tablesize = sht-sg_tablesize;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c9c3b57..0d89344 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -981,7 +981,7 @@ int scsi_device_get(struct scsi_device *sdev)
return -ENXIO;
/* We can fail try_module_get if we're doing SCSI operations
 * from module exit (like cache flush) */
-   __module_get(sdev-host-hostt-module);
+   __module_get(sdev-host-module);
 
return 0;
 }
@@ -997,7 +997,7 @@ EXPORT_SYMBOL(scsi_device_get);
  */
 void scsi_device_put(struct scsi_device *sdev)
 {
-   module_put(sdev-host-hostt-module);
+   module_put(sdev-host-module);
put_device(sdev-sdev_gendev);
 }
 EXPORT_SYMBOL(scsi_device_put);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index e113c75..8742bfd 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -620,6 +620,7 @@ struct Scsi_Host {
 */
unsigned short max_cmd_len;
 
+   struct module *module;
int this_id;
int can_queue;
short cmd_per_lun;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 0/4] scsi: ufs ums-* esp_scsi: fix module reference counting

2015-02-28 Thread Akinobu Mita
While accessing a scsi_device, the use count of the underlying LLDD module
is incremented.  The module reference is retrieved through .module field of
struct scsi_host_template.

This mapping between scsi_device and underlying LLDD module works well
except ufs, unusual usb storage drivers, and sub drivers for esp_scsi.
These drivers consist with core driver and actual LLDDs, and
scsi_host_template is defined in the core driver.  So the actual LLDDs can
be unloaded even if the scsi_device is being accessed.

This patch series first adds ability to adjust module reference for
scsi host by LLDDs and then fixes actual LLDDs by adjusting module
reference after scsi host allocation.

* v5:
- Discard v4 changes and restore to v3.  Because v4 shows that
  moving owner module field from scsi_host_template to Scsi_Host
  requires a lot of changes and introduces complication to existing
  drivers which don't have the module reference mismatch issue.
- Rebased to the 4.0-rc1

* v4:
- Patch series is almost rewritten as module reference field in
  struct scsi_host_template has been unused anymore.  So Acked-by: and
  Reviewed-by: tags that have been received are deleted.

* v3:
- Add fix for ESP SCSI drivers

* v2:
- Pass correct module reference to usb_stor_probe1() instead of touching
  all ums-* drivers, suggested by Alan Stern

Akinobu Mita (4):
  scsi: add ability to adjust module reference for scsi host
  scsi: ufs: adjust module reference for scsi host
  usb: storage: adjust module reference for scsi host
  scsi: esp_scsi: adjust module reference for scsi host

 drivers/scsi/am53c974.c  |  3 +--
 drivers/scsi/esp_scsi.c  | 16 +---
 drivers/scsi/esp_scsi.h  | 11 +++
 drivers/scsi/hosts.c |  1 +
 drivers/scsi/jazz_esp.c  |  3 +--
 drivers/scsi/mac_esp.c   |  3 +--
 drivers/scsi/scsi.c  |  4 ++--
 drivers/scsi/sun3x_esp.c |  3 +--
 drivers/scsi/sun_esp.c   |  3 +--
 drivers/scsi/ufs/ufshcd-pci.c|  1 +
 drivers/scsi/ufs/ufshcd-pltfrm.c |  1 +
 drivers/scsi/ufs/ufshcd.c|  1 -
 drivers/usb/storage/usb.c|  8 +---
 drivers/usb/storage/usb.h|  7 +--
 include/scsi/scsi_host.h |  1 +
 15 files changed, 41 insertions(+), 25 deletions(-)

Cc: Vinayak Holikatti vinholika...@gmail.com
Cc: Dolev Raviv dra...@codeaurora.org
Cc: Sujit Reddy Thumma sthu...@codeaurora.org
Cc: Subhash Jadavani subha...@codeaurora.org
Cc: Christoph Hellwig h...@lst.de
Cc: James E.J. Bottomley jbottom...@parallels.com
Cc: Matthew Dharm mdharm-...@one-eyed-alien.net
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Alan Stern st...@rowland.harvard.edu
Cc: David S. Miller da...@davemloft.net
Cc: Hannes Reinecke h...@suse.de
Cc: linux-usb@vger.kernel.org
Cc: usb-stor...@lists.one-eyed-alien.net
Cc: linux-s...@vger.kernel.org
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html