Re: [PATCH 0/3] Insert ATA transport objects in SCSI syfs topology.

2012-09-28 Thread Aaron Lu
On Thu, Sep 27, 2012 at 12:04:01PM -0700, Gwendal Grignou wrote:
 This set of patches improve ATA transport classes integration with SCSI
 objects.
 
 Before [2.6.x]
 
 Ata and scsi transport class where separated:
 `--:09:00.0
 |  `--ata1
 |  |  `--port_port
 |  |  `--link1
 |  |  |  `--dev1.0
 |  |  |  `--dev1.1
 |  `--ata2
 |  ...
 |  `--host0
 |  |  `--scsi_host
 |  |  |  `--host0
 |  |  `--target0:0:0
 |  |  |  `--0:0:0:0
 |  |  |  |  `--block
 |  |  |  |  |  `--sda
 |  |  |  |  |  |  `--sda1
 
 In 3.2, Lin - in commit 9a6d6a2ddabbd32c07f6a38b659e5f3db319fa5a - addressed
 the issue of linking the ata port with the scsi host object by placing the
 scsi_host object under ata port objects.
 
 However to be more consistent with other transport, this patch does the 
 opposite:
 
 For instance, with SAS transport, We have
 `--:0b:00.0
 |  `--host6
 |  |  `--phy-6:0
 |  |  `--phy-6:1
 ...
 |  |  `--port-6:0
 |  |  |  `--end_device-6:0
 |  |  |  |  `--sas_device
 |  |  |  |  |  `--end_device-6:0
 |  |  |  |  `--sas_end_device
 |  |  |  |  |  `--end_device-6:0
 |  |  |  |  `--target6:0:0
 |  |  |  |  |  `--6:0:0:0
 |  |  |  |  |  |  `--block
 |  |  |  |  |  |  |  `--sdb
 ...
 |  |  `--port-6:1
 |  |  |  `--end_device-6:1
 ...
 phy and port have to be separated, sas_port are created dynamically.
 
 For ata, all objects are created at initialization time, so the layout is:
 `--:09:00.0
 |  `--host0
 |  |  `--port1
 |  |  |  `--link1
 |  |  |  |  `--dev1.0
 |  |  |  |  |  `--target0:0:0
 |  |  |  |  |  |  `--0:0:0:0
 |  |  |  |  |  |  |  `--block
 |  |  |  |  |  |  |  |  `--sda
 
 If we have a port multiplier, more links are created.
 `--:09:00.0
 ...
 |  `--host4
 |  |  `--port5
 |  |  |  `--link5
 |  |  |  |  `--dev5.0
 [device for the port multiplier]
 |  |  |  `--link5.0
 |  |  |  |  `--dev5.0.0
 |  |  |  |  |  `--target4:0:0
 |  |  |  |  |  |  `--4:0:0:0
 |  |  |  |  |  |  |  `--block
 |  |  |  |  |  |  |  |  `--sdc
 [disk in port 0 of the port multiplier]
 ...
 |  |  |  `--link5.2
 |  |  |  |  `--dev5.2.0
 |  |  |  |  |  `--target4:2:0
 |  |  |  |  |  |  `--4:2:0:0
 |  |  |  |  |  |  |  `--block
 |  |  |  |  |  |  |  |  `--sde
 [disk in port 2 of the port multiplier]
 
 In consequence, the path of a scsi device becomes:
 .../:00:1f.2/host0/ata1/link1/dev1.0/target0:0:0/0:0:0:0
 
Should be port1 :-)

 dev1.0 indicates the master device [0] in ata port 1.
 ata1 being under host0, we know the reliationships between the scsi_host id 
 and
 ata port id.
 
 or when a port multiplier is present: for instance the device in port 4 of the
 port multiplier:
 .../:00:06.0/:09:00.0/host5/ata6/link6.4/dev6.4.0/target5:4:0/5:4:0:0

Same here.

Thanks,
Aaron

 
 Gwendal Grignou (3):
   Revert ata: make ata port as parent device of scsi host
   scsi: Allow devices to have arbitrary parent
   libata: Change transport topology layout
 
  drivers/ata/libata-core.c  |   13 ++---
  drivers/ata/libata-scsi.c  |4 ++--
  drivers/ata/libata-transport.c |2 +-
  drivers/firewire/sbp2.c|3 ++-
  drivers/message/i2o/i2o_scsi.c |4 ++--
  drivers/scsi/scsi_scan.c   |9 +
  include/scsi/scsi_device.h |2 +-
  7 files changed, 19 insertions(+), 18 deletions(-)
 
 -- 
 1.7.7.3
 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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/3] libata: Change transport topology layout

2012-09-28 Thread Aaron Lu
On Thu, Sep 27, 2012 at 12:04:04PM -0700, Gwendal Grignou wrote:
 Integrate ata objects [port, link, device] with scsi objects.
 
 
 The path of a scsi device is:
 .../:00:1f.2/host0/ata1/link1/dev1.0/target0:0:0/0:0:0:0

After test, I noticed that this will break the current ata acpi binding
code, but can be fixed with the following changes:

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 30eb7177..459c5b4 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -978,7 +978,7 @@ void ata_acpi_on_disable(struct ata_device *dev)
 
 static int compat_pci_ata(struct ata_port *ap)
 {
-   struct device *dev = ap-tdev.parent;
+   struct device *dev = ap-host-dev;
struct pci_dev *pdev;
 
if (!is_pci_dev(dev))
@@ -998,7 +998,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, 
acpi_handle *handle)
if (ap-flags  ATA_FLAG_ACPI_SATA)
return -ENODEV;
 
-   *handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap-tdev.parent),
+   *handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap-host-dev),
ap-port_no);
 
if (!*handle)
@@ -1061,7 +1061,12 @@ static struct ata_port *dev_to_ata_port(struct device 
*dev)
 
 static int ata_acpi_find_device(struct device *dev, acpi_handle *handle)
 {
-   struct ata_port *ap = dev_to_ata_port(dev);
+   struct ata_port *ap;
+
+   if (scsi_is_host_device(dev))
+   ap = ata_shost_to_port(dev_to_shost(dev));
+   else
+   ap = dev_to_ata_port(dev);
 
if (!ap)
return -ENODEV;


And to make zero power ODD function, the following changes to enable
runtime pm with no callbacks for the ata_link/ata_device transport
devices are necessary.

diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index c04d393..ce91bd2 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -421,6 +421,10 @@ int ata_tlink_add(struct ata_link *link)
goto tlink_err;
}
 
+   pm_runtime_no_callbacks(dev);
+   pm_runtime_set_active(dev);
+   pm_runtime_enable(dev);
+
transport_add_device(dev);
transport_configure_device(dev);
 
@@ -649,6 +653,10 @@ static int ata_tdev_add(struct ata_device *ata_dev)
return error;
}
 
+   pm_runtime_no_callbacks(dev);
+   pm_runtime_set_active(dev);
+   pm_runtime_enable(dev);
+
transport_add_device(dev);
transport_configure_device(dev);
return 0;

There is no other problems I can see.
Should I prepare a patch to addess the 2 issues?

Thanks,
Aaron

 
 or when a port multiplier is present: for instance the device in port 4 of the
 port multiplier:
 .../:00:06.0/:09:00.0/host5/ata6/link6.4/dev6.4.0/target5:4:0/5:4:0:0
 
 
 Change-Id: I202e089208e8746ccdaf2053d43da831a0c0976d
 
 Signed-off-by: Gwendal Grignou gwen...@google.com
 ---
  drivers/ata/libata-core.c  |   13 ++---
  drivers/ata/libata-scsi.c  |4 ++--
  drivers/ata/libata-transport.c |2 +-
  3 files changed, 9 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
 index 611050d..c83590b 100644
 --- a/drivers/ata/libata-core.c
 +++ b/drivers/ata/libata-core.c
 @@ -6063,19 +6063,18 @@ int ata_host_register(struct ata_host *host, struct 
 scsi_host_template *sht)
   for (i = 0; i  host-n_ports; i++)
   host-ports[i]-print_id = atomic_inc_return(ata_print_id);
  
 + rc = ata_scsi_add_hosts(host, sht);
 + if (rc)
 + return rc;
  
   /* Create associated sysfs transport objects  */
   for (i = 0; i  host-n_ports; i++) {
 - rc = ata_tport_add(host-dev,host-ports[i]);
 - if (rc) {
 + struct ata_port *ap = host-ports[i];
 + rc = ata_tport_add(ap-scsi_host-shost_gendev, ap);
 + if (rc)
   goto err_tadd;
 - }
   }
  
 - rc = ata_scsi_add_hosts(host, sht);
 - if (rc)
 - goto err_tadd;
 -
   /* set cable, sata_spd_limit and report */
   for (i = 0; i  host-n_ports; i++) {
   struct ata_port *ap = host-ports[i];
 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
 index bfda61f..9023bb1 100644
 --- a/drivers/ata/libata-scsi.c
 +++ b/drivers/ata/libata-scsi.c
 @@ -3649,8 +3649,8 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
   else
   channel = link-pmp;
  
 - sdev = __scsi_add_device(ap-scsi_host-shost_gendev,
 -  channel, id, 0, NULL);
 + sdev = __scsi_add_device(dev-tdev, channel, id, 0,
 +  NULL);
   if (!IS_ERR(sdev)) {
   dev-sdev = sdev;
   scsi_device_put(sdev);
 diff 

Re: [usb-storage] Re: usb3 fails to write when using usb3 hub in usb3 port

2012-09-28 Thread Adrian Sandu

 Adrian,

 I think that the suggestion about checking the power supply, the cabling,
 the grounding screws, and anything of like nature that has been omitted
 from this list is a very good idea. If successful it would eliminate
 the problem for you, as well as resolving the mystery. Unresolved
 mysteries are unpleasant for the user, and at least equally unpleasant
 for a developer.

 I have seen hardware do really weird things, myself. As a trivial example,
 once a local computer shop gave me a motherboard which had been returned
 because of booting problems. I was told that it had been brought in twice
 by the customer. No problem had been detected in the shop; they had
 replaced it to make a customer happy. I brought the board home. It was a
 hot summer day. I put it on the floor, hooked up a spare power supply, and
 it booted. No problem. I left it sitting there overnight. The next
 morning, I tried it again. Dead. But in the evening it came to life again.
 Guessing, I looked at the solder joints under the power connector on the
 board. One of them looked suspicious. So I fired up the soldering iron and
 put a dab of fresh solder on it. After that, the board was in use for
 years and never had the booting problem again. The reason that the problem
 was not detected was that it was the middle of the summer in Alabama, and
 when the computer was brought to the shop it was put in a car for the
 trip. The board got warm enough for the solder in that joint to expand
 enough for startup, while en route to the shop.

 Thus, I definitely do encourage you to check for hardware or cabling
 problems before deciding to buy additional equipment as a workaround.


 Good luck,

 Theodore Kilgore


 On Thu, 27 Sep 2012, Adrian Sandu wrote:

  They're the same chipset.  There's minor differences in the PCI
  capabilities, but not much else.  It could be something electrically
  wrong with the AsRock system, I suppose.  That's possible if you see
  the errors popping up erratically.
 
  Any chance you can exchange the AsRock system?

 Nope... I have it for more than 1 year and I kinda' need it even if
 the usb3 won't work... at least I can use the 2 ports to dirrectly
 connect 2 drives...nothing else is wrong and I wouldn't of known if I
 wouldn't of got these hubs...

 My only solution if no more debugging can be done is to get a nas a
 put the drives in it...

 Maybe it's the drives fault somehow ? maybe we should mail wd ?
 manhattan's fault ? via ? :) There must be someone/someway/somehow
 that can analyze it in someway and say what is wrong ..

 Still weird..I'll try on another laptop tomorrow or so ( a dell
 inspiron with an usb3 port .. dunno what usb3 root chipset it has )

The only thing I can do is buy other usb3 cables :| It's weird to
think that 5 drives ( 2 bought last week or so from 2 different stores
( 1 wd and 1 seagate ), the other 3 are 2 WDs and 1 verbatim bought
from different shops each (I am a backup nazzi) ) are all having
problems !
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH scsi] Short the path length of scsi_cmd_to_driver()

2012-09-28 Thread Li Zhong
On Thu, 2012-09-27 at 13:43 -0400, Martin K. Petersen wrote:
  Li == Li Zhong zh...@linux.vnet.ibm.com writes:
 
  @@ -845,8 +844,11 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
  unsigned char *cmnd,
  
  scsi_eh_restore_cmnd(scmd, ses);
  
 -if (sdrv  sdrv-eh_action)
 -rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
 +if (scmd-request-cmd_type == REQ_TYPE_FS) {
 +struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
 +if (sdrv-eh_action)
 +rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
 +}
  
  return rtn;
  }
 
 My only concern is whether our device lifetime rules guarantee that the
 ULD is always attached when we service an error handling command?

Thank you, Martin, for the review. 

I don't know much about scsi, it might take me some more time to have an
answer to the above question. 

For now, if I understand correctly, maybe we could only do the
not-consistent behaviours bug fix?  Or could we provide two versions of
scsi_cmd_to_driver(), one with NULL checking for scsi_send_eh_cmnd(),
one without the checking for scsi_finish_command()? 

Thanks, Zhong

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


Re: [PATCH scsi] Short the path length of scsi_cmd_to_driver()

2012-09-28 Thread James Bottomley
On Thu, 2012-09-27 at 13:43 -0400, Martin K. Petersen wrote:
  Li == Li Zhong zh...@linux.vnet.ibm.com writes:
 
  @@ -845,8 +844,11 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
  unsigned char *cmnd,
  
  scsi_eh_restore_cmnd(scmd, ses);
  
 -if (sdrv  sdrv-eh_action)
 -rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
 +if (scmd-request-cmd_type == REQ_TYPE_FS) {
 +struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
 +if (sdrv-eh_action)
 +rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
 +}
  
  return rtn;
  }
 
 My only concern is whether our device lifetime rules guarantee that the
 ULD is always attached when we service an error handling command?

Yes, they are.  We can only get REQ_TYPE_FS through a filesystem, which
must be mounted on a block device, which is provided by the ULD.  You
can't unmount with outstanding I/O (which people complain about when it
goes into error handling, I'll admit), so the ULD has to stay bound.

James



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


Re: [PATCH scsi] Add NULL checking of return value from scsi_cmd_to_driver()

2012-09-28 Thread James Bottomley
On Thu, 2012-09-27 at 13:41 -0400, Martin K. Petersen wrote:
  James == James Bottomley james.bottom...@hansenpartnership.com 
  writes:
 
  I'm fine with having the eh action be triggered for FS requests only,
  if that's what you're asking?
 
 James Sort of ... I was thinking do it for all non REQ_TYPE_BLOCK_PC
 James commands (which includes flush and other strange types), but if
 James you think it should only be for REQ_TYPE_FS, that's fine too.
 
 I'm ok either way.

OK, let's mirror the code in scsi.c then, so != REQ_TYPE_BLOCK_PC.

James


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


Re: [PATCH v7 2/6] scsi: sr: support runtime pm

2012-09-28 Thread Aaron Lu
On 09/27/2012 06:46 PM, Oliver Neukum wrote:
 On Tuesday 25 September 2012 16:01:35 Aaron Lu wrote:
 On Mon, Sep 24, 2012 at 11:40:18PM +0200, Rafael J. Wysocki wrote:
 On Monday, September 24, 2012, Aaron Lu wrote:
 On Mon, Sep 24, 2012 at 02:55:31PM +0200, Rafael J. Wysocki wrote:
 
 I just checked the spec again and tested, when the ODD has power, it
 will also send out notifications on pressing the eject button/inserting
 a disc. So we should be able to capture such a event.
 
 In this case there's no need to poll for disk change unless the button has
 been pressed.

The SATA spec says the device attention pin shall assert when:
- For tray type ODD, its front panel button is released;
- For slot type ODD, media is inserted.

I've a slot type ODD which has a eject button. The notification will be
sent when a disc is inserted, but not when the eject button is pressed,
and this doesn't violate the spec.

But if we disable the poll for disc changes, we will lose an event when
the disc is ejected by the eject button(the device attention pin shall
not trigger this time). I suppose this is a problem?

I think the device attention scheme is not designed to do this job,
while SATA asynchronous notification is.

 
 I'm thinking of enabling this GPE in sr_suspend once we decided that it
 is ready to be powered off, so the time frame between sr_suspend and
 when the power is actually removed in libata should be taken care of by
 the GPE. If GPE fires, the notification function will request a runtime
 resume of the device. Does this sound OK?
 
 This sounds terribly, needlessly complicated. Just enable it when
 you detect the presence of a disk drive that supports it.
 
 Furthermore we have a device which can detect that a button has
 been pressed. It is fundamentally wrong to poll for medium change in
 such devices. You know that it hasn't been changed.

That may depend on the ODD's capability. For the slot type ODD I
mentioned above, we will not know when the disc is gone.

Thanks,
Aaron

 We should notify the upper layers that we can do medium change
 detection on our own.
 
   Regards
   Oliver
 

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


Re: [usb-storage] Re: usb3 fails to write when using usb3 hub in usb3 port

2012-09-28 Thread Adrian Sandu
The only solution I see is to buy something else, like an Asus
EB1501P-B057E .. I need something small and fast enough .. :| Maybe
any other recommendations ? ( other root chipset / atom cpu .. small
powered .. etc. )
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [bug report] [SCSI] mvumi: GFP_KERNEL under spin lock

2012-09-28 Thread Dan Carpenter
Whatever happened with this?  You could just change the GFP_KERNEL
to GFP_ATOMIC.

regards,
dan carpenter

On Tue, Aug 14, 2012 at 05:59:27PM +0300, Dan Carpenter wrote:
 Hello Jianyun Li,
 
 The patch f0c568a478f0: [SCSI] mvumi: Add Marvell UMI driver from 
 May 11, 2011, leads to the following warning:
 drivers/scsi/mvumi.c:121 mvumi_alloc_mem_resource()
error: scheduling with locks held: 'spin_lock:host_lock'
 
 The problem is that we do a couple GPF_KERNEL allocations in
 mvumi_alloc_mem_resource() and this static analysis program sees a path
 where that function is called with spin_locks held.
 
 mvumi_isr_handler() - takes a spin lock
 - mvumi_handshake()
- mvumi_init_data()
   - mvumi_alloc_mem_resource() - GFP_KERNEL
 
 The IRQ handler does print a warning before calling mvumi_handshake()
 so it seems like this path doesn't get exercised very much.
 
 regards,
 dan carpenter
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [bug report] [SCSI] mvumi: GFP_KERNEL under spin lock

2012-09-28 Thread Dan Carpenter
On Fri, Sep 28, 2012 at 02:30:22PM +0300, Dan Carpenter wrote:
 Whatever happened with this?  You could just change the GFP_KERNEL
 to GFP_ATOMIC.
 

Ah, that email address is dead is what happened.  I'll send a patch
that changes this to GFP_ATOMIC.

regards,
dan carpenter

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


Re: [SCSI PATCH] sd: max-retries becomes configurable

2012-09-28 Thread Dan Williams
On Wed, Sep 26, 2012 at 7:20 PM, Martin K. Petersen
martin.peter...@oracle.com wrote:
 James == James Bottomley james.bottom...@hansenpartnership.com 
 writes:

 James On Mon, 2012-09-24 at 17:00 -0400, Jeff Garzik wrote:

 drivers/scsi/sd.c | 4  drivers/scsi/sd.h | 2 +- 2 files changed,
 5 insertions(+), 1 deletion(-)

 James I'm not opposed in principle to doing this (except that it should
 James be a sysfs parameter like all our other controls),

 Now that we're in that department. I never got any feedback on the
 following patch.

 Hannes told me in person that he felt the eh_timeout belonged in
 scsi_device and not in the request queue. Whereas I favored making it a
 block layer tunable despite currently only being used by SCSI. Any
 opinions?


I think request_queue since tuning these parameters would be useful
for libata/libsas usage and libata is still on track to move out from
under scsi ;-).

Hm, how to extend this for the ata eh case?  I had a global hack to
make libata give up quicker [1], but I it would be better to have it
be per queue.  What about another tunable to limit how deep into the
recovery escalation to go?  For pure scsi it short circuits escalation
and for ata it limits tries ata_eh_reset(), and then the value of
eh_timeout_secs in the non-default case overrides those in
ata_eh_reset_timeouts..

--
Dan

[1]: libata: reset once http://marc.info/?l=linux-idem=134189240724489w=2
...Dave found this does not work as advertised for libsas since we
don't end up applying force parameters to sas-ata links.  My test case
apparently fell out of eh early for another reason.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] Updates for the be2iscsi driver.

2012-09-28 Thread John Soni Jose
 Patches to update the be2iscsi driver. These patches were generated
 against the scsi tree misc heads.

Jayamohan Kallickal (1):
  be2iscsi: Fix the kernel panic in blkiopoll disable mode

John Soni Jose (15):
  be2iscsi: Display Completion Event string instead of opcode
  be2iscsi: Fix memory leak in control path of driver
  be2iscsi: Fix max supported EQ count to 8.
  be2iscsi: Display driver name and version in device attribute
  be2iscsi: Issue an FLR when driver is loaded.
  be2iscsi: Fix return value
  be2iscsi: Fix support for Skyhawk Adapters
  be2iscsi: Fix max EQ supported by the driver.
  be2iscsi: Fix CQ create MBX CMD for Skyhawk.
  be2iscsi: Fix WRB support for Skyhawk adapters.
  be2iscsi: Fix context update for session in Skyhawk.
  be2iscsi: Fix Task Completion Event handling for Skyhawk
  be2iscsi: Fix issue of displaying adapter family.
  be2iscsi: Fix the copyright information
  be2iscsi: Bump the driver version

Minh Tran (1):
  be2iscsi: Fix the issue with soft reset.

 drivers/scsi/be2iscsi/be.h   |9 +-
 drivers/scsi/be2iscsi/be_cmds.c  |   42 ++-
 drivers/scsi/be2iscsi/be_cmds.h  |   83 +++-
 drivers/scsi/be2iscsi/be_iscsi.c |   10 +-
 drivers/scsi/be2iscsi/be_iscsi.h |2 +-
 drivers/scsi/be2iscsi/be_main.c  |  974 +-
 drivers/scsi/be2iscsi/be_main.h  |  143 +-
 drivers/scsi/be2iscsi/be_mgmt.c  |  195 -
 drivers/scsi/be2iscsi/be_mgmt.h  |   16 +-
 9 files changed, 1106 insertions(+), 368 deletions(-)

-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Fix the issue with soft reset.

2012-09-28 Thread John Soni Jose
From: Minh Tran minhduc.t...@emulex.com

 Fixed soft_reset problem which driver modified
 all 32bit before a write on second pass.

Signed-off-by: Minh Tran minhduc.t...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_cmds.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 07d2cb1..05f70bb 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -56,7 +56,7 @@ int beiscsi_pci_soft_reset(struct beiscsi_hba *phba)
writel(pconline0, (void *)pci_online0_offset);
writel(pconline1, (void *)pci_online1_offset);
 
-   sreset = BE2_SET_RESET;
+   sreset |= BE2_SET_RESET;
writel(sreset, (void *)pci_reset_offset);
 
i = 0;
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Display Completion Event string instead of opcode

2012-09-28 Thread John Soni Jose
 Display the event string along with the opcode and CID on which
 the event has occured.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_cmds.h |2 -
 drivers/scsi/be2iscsi/be_main.c |   88 ---
 2 files changed, 64 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 2c8f98d..897086b 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -992,8 +992,6 @@ struct be_cmd_get_all_if_id_req {
 #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
 * sequence number by driver  */
 
-/* Returns byte size of given field with a structure. */
-
 /* Returns the number of items in the field array. */
 #define BE_NUMBER_OF_FIELD(_type_, _field_)\
(FIELD_SIZEOF(_type_, _field_)/sizeof_type_ *)0)-_field_[0])))\
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ff73f95..b52c5c0 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -158,6 +158,45 @@ struct device_attribute *beiscsi_attrs[] = {
NULL,
 };
 
+static char const *cqe_desc[] = {
+   RESERVED_DESC,
+   SOL_CMD_COMPLETE,
+   SOL_CMD_KILLED_DATA_DIGEST_ERR,
+   CXN_KILLED_PDU_SIZE_EXCEEDS_DSL,
+   CXN_KILLED_BURST_LEN_MISMATCH,
+   CXN_KILLED_AHS_RCVD,
+   CXN_KILLED_HDR_DIGEST_ERR,
+   CXN_KILLED_UNKNOWN_HDR,
+   CXN_KILLED_STALE_ITT_TTT_RCVD,
+   CXN_KILLED_INVALID_ITT_TTT_RCVD,
+   CXN_KILLED_RST_RCVD,
+   CXN_KILLED_TIMED_OUT,
+   CXN_KILLED_RST_SENT,
+   CXN_KILLED_FIN_RCVD,
+   CXN_KILLED_BAD_UNSOL_PDU_RCVD,
+   CXN_KILLED_BAD_WRB_INDEX_ERROR,
+   CXN_KILLED_OVER_RUN_RESIDUAL,
+   CXN_KILLED_UNDER_RUN_RESIDUAL,
+   CMD_KILLED_INVALID_STATSN_RCVD,
+   CMD_KILLED_INVALID_R2T_RCVD,
+   CMD_CXN_KILLED_LUN_INVALID,
+   CMD_CXN_KILLED_ICD_INVALID,
+   CMD_CXN_KILLED_ITT_INVALID,
+   CMD_CXN_KILLED_SEQ_OUTOFORDER,
+   CMD_CXN_KILLED_INVALID_DATASN_RCVD,
+   CXN_INVALIDATE_NOTIFY,
+   CXN_INVALIDATE_INDEX_NOTIFY,
+   CMD_INVALIDATED_NOTIFY,
+   UNSOL_HDR_NOTIFY,
+   UNSOL_DATA_NOTIFY,
+   UNSOL_DATA_DIGEST_ERROR_NOTIFY,
+   DRIVERMSG_NOTIFY,
+   CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN,
+   SOL_CMD_KILLED_DIF_ERR,
+   CXN_KILLED_SYN_RCVD,
+   CXN_KILLED_IMM_DATA_RCVD
+};
+
 static int beiscsi_slave_configure(struct scsi_device *sdev)
 {
blk_queue_max_segment_size(sdev-request_queue, 65536);
@@ -1914,6 +1953,13 @@ static void  beiscsi_process_mcc_isr(struct beiscsi_hba 
*phba)
 
 }
 
+/**
+ * beiscsi_process_cq()- Process the Completion Queue
+ * @pbe_eq: Event Q on which the Completion has come
+ *
+ * return
+ * Number of Completion Entries processed.
+ **/
 static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
 {
struct be_queue_info *cq;
@@ -1958,7 +2004,8 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj 
*pbe_eq)
case DRIVERMSG_NOTIFY:
beiscsi_log(phba, KERN_INFO,
BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
-   BM_%d : Received DRIVERMSG_NOTIFY\n);
+   BM_%d : Received %s[%d] on CID : %d\n,
+   cqe_desc[code], code, cid);
 
dmsg = (struct dmsg_cqe *)sol;
hwi_complete_drvr_msgs(beiscsi_conn, phba, sol);
@@ -1966,7 +2013,8 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj 
*pbe_eq)
case UNSOL_HDR_NOTIFY:
beiscsi_log(phba, KERN_INFO,
BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
-   BM_%d : Received UNSOL_HDR_ NOTIFY\n);
+   BM_%d : Received %s[%d] on CID : %d\n,
+   cqe_desc[code], code, cid);
 
hwi_process_default_pdu_ring(beiscsi_conn, phba,
 (struct i_t_dpdu_cqe *)sol);
@@ -1974,7 +2022,8 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj 
*pbe_eq)
case UNSOL_DATA_NOTIFY:
beiscsi_log(phba, KERN_INFO,
BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
-   BM_%d : Received UNSOL_DATA_NOTIFY\n);
+   BM_%d : Received %s[%d] on CID : %d\n,
+   cqe_desc[code], code, cid);
 
hwi_process_default_pdu_ring(beiscsi_conn, phba,
 (struct i_t_dpdu_cqe *)sol);
@@ -1984,8 +2033,8 @@ static unsigned int beiscsi_process_cq(struct 

[PATCH 03/17] be2iscsi: Fix memory leak in control path of driver

2012-09-28 Thread John Soni Jose
 In contorl path of the driver the task was mapped using
 pci_map_single which was not unmapped when the completion
 for the task had come.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |   38 --
 drivers/scsi/be2iscsi/be_main.h |2 ++
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index b52c5c0..54eb7ad 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2242,10 +2242,14 @@ hwi_write_sgl(struct iscsi_wrb *pwrb, struct 
scatterlist *sg,
AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1);
 }
 
+/**
+ * hwi_write_buffer()- Populate the WRB with task info
+ * @pwrb: ptr to the WRB entry
+ * @task: iscsi task which is to be executed
+ **/
 static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task)
 {
struct iscsi_sge *psgl;
-   unsigned long long addr;
struct beiscsi_io_task *io_task = task-dd_data;
struct beiscsi_conn *beiscsi_conn = io_task-conn;
struct beiscsi_hba *phba = beiscsi_conn-phba;
@@ -2259,24 +2263,27 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, 
struct iscsi_task *task)
if (task-data) {
if (task-data_count) {
AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1);
-   addr = (u64) pci_map_single(phba-pcidev,
-   task-data,
-   task-data_count, 1);
+   io_task-mtask_addr = pci_map_single(phba-pcidev,
+task-data,
+task-data_count,
+PCI_DMA_TODEVICE);
+
+   io_task-mtask_data_count = task-data_count;
} else {
AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0);
-   addr = 0;
+   io_task-mtask_addr = 0;
}
AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb,
-   ((u32)(addr  0x)));
+ lower_32_bits(io_task-mtask_addr));
AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb,
-   ((u32)(addr  32)));
+ upper_32_bits(io_task-mtask_addr));
AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb,
task-data_count);
 
AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 1);
} else {
AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0);
-   addr = 0;
+   io_task-mtask_addr = 0;
}
 
psgl = (struct iscsi_sge *)io_task-psgl_handle-pfrag;
@@ -2299,9 +2306,9 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, 
struct iscsi_task *task)
psgl++;
if (task-data) {
AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
-   ((u32)(addr  0x)));
+ lower_32_bits(io_task-mtask_addr));
AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
-   ((u32)(addr  32)));
+ upper_32_bits(io_task-mtask_addr));
}
AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106);
}
@@ -3893,6 +3900,11 @@ static void beiscsi_clean_port(struct beiscsi_hba *phba)
kfree(phba-ep_array);
 }
 
+/**
+ * beiscsi_cleanup_task()- Free driver resources of the task
+ * @task: ptr to the iscsi task
+ *
+ **/
 static void beiscsi_cleanup_task(struct iscsi_task *task)
 {
struct beiscsi_io_task *io_task = task-dd_data;
@@ -3940,6 +3952,12 @@ static void beiscsi_cleanup_task(struct iscsi_task *task)
spin_unlock(phba-mgmt_sgl_lock);
io_task-psgl_handle = NULL;
}
+   if (io_task-mtask_addr) {
+   pci_unmap_single(phba-pcidev,
+io_task-mtask_addr,
+io_task-mtask_data_count,
+PCI_DMA_TODEVICE);
+   }
}
}
 }
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index b891226..f4e8d19 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -410,6 +410,8 @@ struct 

[PATCH 04/17] be2iscsi: Fix max supported EQ count to 8.

2012-09-28 Thread John Soni Jose
 The maximum EQ that can be created for a function is 8. Check the
 CPU online count and create only 8 EQ if CPU_Count = 8

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |   23 ++-
 drivers/scsi/be2iscsi/be_main.h |1 +
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 54eb7ad..6bab4e7 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2890,7 +2890,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
}
return 0;
 create_eq_error:
-   for (i = 0; i  (phba-num_cpus + 1); i++) {
+   for (i = 0; i  (phba-num_cpus + eq_for_mcc); i++) {
eq = phwi_context-be_eq[i].q;
mem = eq-dma_mem;
if (mem-va)
@@ -3315,15 +3315,20 @@ err:
return -ENOMEM;
 }
 
-static int find_num_cpus(void)
+/**
+ * find_num_cpus()- Get the CPU online count
+ * @phba: ptr to priv structure
+ *
+ * CPU count is used for creating EQ.
+ **/
+static void find_num_cpus(struct beiscsi_hba *phba)
 {
int  num_cpus = 0;
 
num_cpus = num_online_cpus();
-   if (num_cpus = MAX_CPUS)
-   num_cpus = MAX_CPUS - 1;
 
-   return num_cpus;
+   phba-num_cpus = (num_cpus = BEISCSI_MAX_NUM_CPU) ?
+(BEISCSI_MAX_NUM_CPU - 1) : num_cpus;
 }
 
 static int hwi_init_port(struct beiscsi_hba *phba)
@@ -4541,7 +4546,7 @@ static int __devinit beiscsi_dev_probe(struct pci_dev 
*pcidev,
struct hwi_controller *phwi_ctrlr;
struct hwi_context_memory *phwi_context;
struct be_eq_obj *pbe_eq;
-   int ret, num_cpus, i;
+   int ret, i;
u8 *real_offset = 0;
u32 value = 0;
 
@@ -4577,10 +4582,10 @@ static int __devinit beiscsi_dev_probe(struct pci_dev 
*pcidev,
}
 
if (enable_msix)
-   num_cpus = find_num_cpus();
+   find_num_cpus(phba);
else
-   num_cpus = 1;
-   phba-num_cpus = num_cpus;
+   phba-num_cpus = 1;
+
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
BM_%d : num_cpus = %d\n,
phba-num_cpus);
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index f4e8d19..e24d550 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -61,6 +61,7 @@
 #define BE2_DEFPDU_DATA_SZ 8192
 
 #define MAX_CPUS   31
+#define BEISCSI_MAX_NUM_CPU8
 #define BEISCSI_SGLIST_ELEMENTS30
 
 #define BEISCSI_CMD_PER_LUN128 /* scsi_host-cmd_per_lun */
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Display driver name and version in device attribute

2012-09-28 Thread John Soni Jose
Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |2 ++
 drivers/scsi/be2iscsi/be_mgmt.c |   16 
 drivers/scsi/be2iscsi/be_mgmt.h |3 +++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 6bab4e7..82c69aa 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -153,8 +153,10 @@ BEISCSI_RW_ATTR(log_enable, 0x00,
\t\t\t\tIO Path Events : 0x10\n
\t\t\t\tConfiguration Path : 0x20\n);
 
+DEVICE_ATTR(beiscsi_drvr_ver, S_IRUGO, beiscsi_drvr_ver_disp, NULL);
 struct device_attribute *beiscsi_attrs[] = {
dev_attr_beiscsi_log_enable,
+   dev_attr_beiscsi_drvr_ver,
NULL,
 };
 
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index aab5dd3..1ec1db3 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1136,3 +1136,19 @@ int mgmt_set_vlan(struct beiscsi_hba *phba,
free_mcc_tag(phba-ctrl, tag);
return 0;
 }
+
+/**
+ * beiscsi_drvr_ver_disp()- Display the driver Name and Version
+ * @dev: ptr to device not used.
+ * @attr: device attribute, not used.
+ * @buf: contains formatted text driver name and version
+ *
+ * return
+ * size of the formatted string
+ **/
+ssize_t
+beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   return snprintf(buf, PAGE_SIZE, BE_NAME \n);
+}
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index c50cef6..291c684 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -301,4 +301,7 @@ int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba,
 unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba);
 
 int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
+
+ssize_t beiscsi_drvr_ver_disp(struct device *dev,
+  struct device_attribute *attr, char *buf);
 #endif
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Issue an FLR when driver is loaded.

2012-09-28 Thread John Soni Jose
 Issue Function Level Reset everytime driver is loaded.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |   39 ---
 1 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 82c69aa..0fb36b4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -47,8 +47,6 @@
 static unsigned int be_iopoll_budget = 10;
 static unsigned int be_max_phys_size = 64;
 static unsigned int enable_msix = 1;
-static unsigned int gcrashmode = 0;
-static unsigned int num_hba = 0;
 
 MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table);
 MODULE_DESCRIPTION(DRV_DESC   BUILD_STR);
@@ -4605,31 +4603,18 @@ static int __devinit beiscsi_dev_probe(struct pci_dev 
*pcidev,
goto hba_free;
}
 
-   if (!num_hba) {
-   real_offset = (u8 *)phba-csr_va + MPU_EP_SEMAPHORE;
-   value = readl((void *)real_offset);
-   if (value  0x0001) {
-   gcrashmode++;
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   BM_%d : Loading Driver in crashdump 
mode\n);
-   ret = beiscsi_cmd_reset_function(phba);
-   if (ret) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   BM_%d : Reset Failed. Aborting 
Crashdump\n);
-   goto hba_free;
-   }
-   ret = be_chk_reset_complete(phba);
-   if (ret) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
-   BM_%d : Failed to get out of 
reset.
-   Aborting Crashdump\n);
-   goto hba_free;
-   }
-   } else {
-   value |= 0x0001;
-   writel(value, (void *)real_offset);
-   num_hba++;
-   }
+   ret = beiscsi_cmd_reset_function(phba);
+   if (ret) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   BM_%d : Reset Failed. Aborting Crashdump\n);
+   goto hba_free;
+   }
+   ret = be_chk_reset_complete(phba);
+   if (ret) {
+   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
+   BM_%d : Failed to get out of reset.
+   Aborting Crashdump\n);
+   goto hba_free;
}
 
spin_lock_init(phba-io_sgl_lock);
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Fix the kernel panic in blkiopoll disable mode

2012-09-28 Thread John Soni Jose
From: Jayamohan Kallickal jayamohan.kallic...@emulex.com

 Fix kernel panic issue while running IO in blk_iopoll disable mode.
 Creating UNBOUND WQ for each EQ in the driver.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be.h  |5 +
 drivers/scsi/be2iscsi/be_main.c |  159 +-
 drivers/scsi/be2iscsi/be_main.h |5 -
 3 files changed, 109 insertions(+), 60 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index a50b6a9..be67c90 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -84,9 +84,14 @@ static inline void queue_tail_inc(struct be_queue_info *q)
 /*ISCSI */
 
 struct be_eq_obj {
+   char wq_name[32];
+   bool todo_mcc_cq;
+   bool todo_cq;
struct be_queue_info q;
struct beiscsi_hba *phba;
struct be_queue_info *cq;
+   struct workqueue_struct *wq; /* Work Q */
+   struct work_struct work_cqs; /* Work Item */
struct blk_iopoll   iopoll;
 };
 
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 0fb36b4..0ce96a0 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -769,7 +769,7 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id)
 resource_id) / 32] 
 EQE_RESID_MASK)  16) == mcc-id) {
spin_lock_irqsave(phba-isr_lock, flags);
-   phba-todo_mcc_cq = 1;
+   pbe_eq-todo_mcc_cq = true;
spin_unlock_irqrestore(phba-isr_lock, flags);
}
AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
@@ -777,8 +777,8 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id)
eqe = queue_tail_node(eq);
num_eq_processed++;
}
-   if (phba-todo_mcc_cq)
-   queue_work(phba-wq, phba-work_cqs);
+   if (pbe_eq-todo_mcc_cq)
+   queue_work(pbe_eq-wq, pbe_eq-work_cqs);
if (num_eq_processed)
hwi_ring_eq_db(phba, eq-id, 1, num_eq_processed, 1, 1);
 
@@ -818,29 +818,26 @@ static irqreturn_t be_isr_msix(int irq, void *dev_id)
eqe = queue_tail_node(eq);
num_eq_processed++;
}
-   if (num_eq_processed)
-   hwi_ring_eq_db(phba, eq-id, 1, num_eq_processed, 0, 1);
-
-   return IRQ_HANDLED;
} else {
while (eqe-dw[offsetof(struct amap_eq_entry, valid) / 32]
 EQE_VALID_MASK) {
spin_lock_irqsave(phba-isr_lock, flags);
-   phba-todo_cq = 1;
+   pbe_eq-todo_cq = true;
spin_unlock_irqrestore(phba-isr_lock, flags);
AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
queue_tail_inc(eq);
eqe = queue_tail_node(eq);
num_eq_processed++;
}
-   if (phba-todo_cq)
-   queue_work(phba-wq, phba-work_cqs);
-
-   if (num_eq_processed)
-   hwi_ring_eq_db(phba, eq-id, 1, num_eq_processed, 1, 1);
 
-   return IRQ_HANDLED;
+   if (pbe_eq-todo_cq)
+   queue_work(pbe_eq-wq, pbe_eq-work_cqs);
}
+
+   if (num_eq_processed)
+   hwi_ring_eq_db(phba, eq-id, 1, num_eq_processed, 0, 1);
+
+   return IRQ_HANDLED;
 }
 
 /**
@@ -888,7 +885,7 @@ static irqreturn_t be_isr(int irq, void *dev_id)
 resource_id) / 32] 
 EQE_RESID_MASK)  16) == mcc-id) {
spin_lock_irqsave(phba-isr_lock, flags);
-   phba-todo_mcc_cq = 1;
+   pbe_eq-todo_mcc_cq = true;
spin_unlock_irqrestore(phba-isr_lock, flags);
num_mcceq_processed++;
} else {
@@ -901,8 +898,8 @@ static irqreturn_t be_isr(int irq, void *dev_id)
eqe = queue_tail_node(eq);
}
if (num_ioeq_processed || num_mcceq_processed) {
-   if (phba-todo_mcc_cq)
-   queue_work(phba-wq, phba-work_cqs);
+   if (pbe_eq-todo_mcc_cq)
+   queue_work(pbe_eq-wq, pbe_eq-work_cqs);
 
if ((num_mcceq_processed)  (!num_ioeq_processed))
hwi_ring_eq_db(phba, eq-id, 0,
@@ -925,11 +922,11 @@ static irqreturn_t be_isr(int irq, void *dev_id)
 resource_id) / 32] 
 EQE_RESID_MASK)  16) != cq-id) {
  

[PATCH 09/17] be2iscsi: Fix support for Skyhawk Adapters

2012-09-28 Thread John Soni Jose
 Fix support for Skyhawk adapter by populating the pci_id_table

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be.h  |2 +-
 drivers/scsi/be2iscsi/be_main.c |3 +++
 drivers/scsi/be2iscsi/be_main.h |4 
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index be67c90..7d9267b 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -28,7 +28,7 @@
 /* BladeEngine Generation numbers */
 #define BE_GEN2 2
 #define BE_GEN3 3
-
+#define BE_GEN44
 struct be_dma_mem {
void *va;
dma_addr_t dma;
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index c7f9929..c97f010 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -521,6 +521,7 @@ static DEFINE_PCI_DEVICE_TABLE(beiscsi_pci_id_table) = {
{ PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) },
{ PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) },
{ PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID3) },
+   { PCI_DEVICE(ELX_VENDOR_ID, OC_SKH_ID1) },
{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table);
@@ -4591,6 +4592,8 @@ static int __devinit beiscsi_dev_probe(struct pci_dev 
*pcidev,
case OC_DEVICE_ID3:
phba-generation = BE_GEN3;
break;
+   case OC_SKH_ID1:
+   phba-generation = BE_GEN4;
default:
phba-generation = 0;
}
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 687ac28..71443fd 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -42,6 +42,7 @@
 #define DRV_DESC   BE_NAME   Driver
 
 #define BE_VENDOR_ID   0x19A2
+#define ELX_VENDOR_ID  0x10DF
 /* DEVICE ID's for BE2 */
 #define BE_DEVICE_ID1  0x212
 #define OC_DEVICE_ID1  0x702
@@ -51,6 +52,9 @@
 #define BE_DEVICE_ID2  0x222
 #define OC_DEVICE_ID3  0x712
 
+/* DEVICE ID for SKH */
+#define OC_SKH_ID1 0x722
+
 #define BE2_IO_DEPTH   1024
 #define BE2_MAX_SESSIONS   256
 #define BE2_CMDS_PER_CXN   128
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Fix max EQ supported by the driver.

2012-09-28 Thread John Soni Jose
 Fix the max EQ created when driver is loaded. The max
 EQ for BE3 adapter will be 8 and for Skyhawk it will be 64.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |   15 +--
 drivers/scsi/be2iscsi/be_main.h |   13 -
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index c97f010..ebb102f 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3325,8 +3325,19 @@ static void find_num_cpus(struct beiscsi_hba *phba)
 
num_cpus = num_online_cpus();
 
-   phba-num_cpus = (num_cpus = BEISCSI_MAX_NUM_CPU) ?
-(BEISCSI_MAX_NUM_CPU - 1) : num_cpus;
+   switch (phba-generation) {
+   case BE_GEN2:
+   case BE_GEN3:
+   phba-num_cpus = (num_cpus  BEISCSI_MAX_NUM_CPUS) ?
+ BEISCSI_MAX_NUM_CPUS : num_cpus;
+   break;
+   case BE_GEN4:
+   phba-num_cpus = (num_cpus  OC_SKH_MAX_NUM_CPUS) ?
+ OC_SKH_MAX_NUM_CPUS : num_cpus;
+   break;
+   default:
+   phba-num_cpus = 1;
+   }
 }
 
 static int hwi_init_port(struct beiscsi_hba *phba)
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 71443fd..4a9dd37 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -64,8 +64,11 @@
 #define BE2_DEFPDU_HDR_SZ  64
 #define BE2_DEFPDU_DATA_SZ 8192
 
-#define MAX_CPUS   31
-#define BEISCSI_MAX_NUM_CPU8
+#define MAX_CPUS   64
+#define BEISCSI_MAX_NUM_CPUS   7
+#define OC_SKH_MAX_NUM_CPUS63
+
+
 #define BEISCSI_SGLIST_ELEMENTS30
 
 #define BEISCSI_CMD_PER_LUN128 /* scsi_host-cmd_per_lun */
@@ -279,8 +282,8 @@ struct beiscsi_hba {
unsigned short asic_revision;
unsigned int num_cpus;
unsigned int nxt_cqid;
-   struct msix_entry msix_entries[MAX_CPUS + 1];
-   char *msi_name[MAX_CPUS + 1];
+   struct msix_entry msix_entries[MAX_CPUS];
+   char *msi_name[MAX_CPUS];
bool msix_enabled;
struct be_mem_descriptor *init_mem;
 
@@ -839,7 +842,7 @@ struct hwi_context_memory {
u16 max_eqd;/* in usecs */
u16 cur_eqd;/* in usecs */
struct be_eq_obj be_eq[MAX_CPUS];
-   struct be_queue_info be_cq[MAX_CPUS];
+   struct be_queue_info be_cq[MAX_CPUS - 1];
 
struct be_queue_info be_def_hdrq;
struct be_queue_info be_def_dataq;
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Fix CQ create MBX CMD for Skyhawk.

2012-09-28 Thread John Soni Jose
 Fix the CQ creation for Skyhawk by creating version V2 of the MBOX Cmd.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_cmds.c |   38 +++---
 drivers/scsi/be2iscsi/be_cmds.h |   26 --
 drivers/scsi/be2iscsi/be_main.h |1 +
 3 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 05f70bb..1257038 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -649,18 +649,34 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
OPCODE_COMMON_CQ_CREATE, sizeof(*req));
 
req-num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem-va, q_mem-size));
+   if (chip_skyhawk(ctrl-pdev)) {
+   req-hdr.version = MBX_CMD_VER2;
+   req-page_size = 1;
+   AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm,
+ ctxt, coalesce_wm);
+   AMAP_SET_BITS(struct amap_cq_context_v2, nodelay,
+ ctxt, no_delay);
+   AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt,
+ __ilog2_u32(cq-len / 256));
+   AMAP_SET_BITS(struct amap_cq_context_v2, valid, ctxt, 1);
+   AMAP_SET_BITS(struct amap_cq_context_v2, eventable, ctxt, 1);
+   AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq-id);
+   AMAP_SET_BITS(struct amap_cq_context_v2, armed, ctxt, 1);
+   } else {
+   AMAP_SET_BITS(struct amap_cq_context, coalescwm,
+ ctxt, coalesce_wm);
+   AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay);
+   AMAP_SET_BITS(struct amap_cq_context, count, ctxt,
+ __ilog2_u32(cq-len / 256));
+   AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1);
+   AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts);
+   AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
+   AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq-id);
+   AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
+   AMAP_SET_BITS(struct amap_cq_context, func, ctxt,
+ PCI_FUNC(ctrl-pdev-devfn));
+   }
 
-   AMAP_SET_BITS(struct amap_cq_context, coalescwm, ctxt, coalesce_wm);
-   AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay);
-   AMAP_SET_BITS(struct amap_cq_context, count, ctxt,
- __ilog2_u32(cq-len / 256));
-   AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1);
-   AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts);
-   AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
-   AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq-id);
-   AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
-   AMAP_SET_BITS(struct amap_cq_context, func, ctxt,
- PCI_FUNC(ctrl-pdev-devfn));
be_dws_cpu_to_le(ctxt, sizeof(req-context));
 
be_cmd_page_addrs_prepare(req-pages, ARRAY_SIZE(req-pages), q_mem);
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 897086b..c560e9d 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -58,6 +58,9 @@ struct be_mcc_wrb {
 #define CQE_STATUS_EXTD_MASK 0x
 #define CQE_STATUS_EXTD_SHIFT 16   /* bits 0 - 15 */
 
+/* MBOX Command VER */
+#define MBX_CMD_VER2   0x02
+
 struct be_mcc_compl {
u32 status; /* dword 0 */
u32 tag0;   /* dword 1 */
@@ -183,7 +186,8 @@ struct be_cmd_req_hdr {
u8 domain;  /* dword 0 */
u32 timeout;/* dword 1 */
u32 request_length; /* dword 2 */
-   u32 rsvd0;  /* dword 3 */
+   u8 version; /* dword 3 */
+   u8 rsvd0[3];/* dword 3 */
 };
 
 struct be_cmd_resp_hdr {
@@ -483,10 +487,28 @@ struct amap_cq_context {
u8 rsvd5[32];   /* dword 3 */
 } __packed;
 
+struct amap_cq_context_v2 {
+   u8 rsvd0[12];   /* dword 0 */
+   u8 coalescwm[2];/* dword 0 */
+   u8 nodelay; /* dword 0 */
+   u8 rsvd1[12];   /* dword 0 */
+   u8 count[2];/* dword 0 */
+   u8 valid;   /* dword 0 */
+   u8 rsvd2;   /* dword 0 */
+   u8 eventable;   /* dword 0 */
+   u8 eqid[16];/* dword 1 */
+   u8 rsvd3[15];   /* dword 1 */
+   u8 armed;   /* dword 1 */
+   u8 cqecount[16];/* dword 2 */
+   u8 rsvd4[16];   /* dword 2 */
+   u8 rsvd5[32];   /* dword 3 */
+};
+
 struct be_cmd_req_cq_create {
struct be_cmd_req_hdr hdr;
u16 num_pages;
-   u16 rsvd0;
+   u8 page_size;
+   u8 rsvd0;
u8 

[PATCH 12/17] be2iscsi: Fix WRB support for Skyhawk adapters.

2012-09-28 Thread John Soni Jose
 Fix the latest WRB support for Skyhawk adapter by using V2 version.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |  265 +--
 drivers/scsi/be2iscsi/be_main.h |   51 -
 2 files changed, 277 insertions(+), 39 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ebb102f..87ee112 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2153,6 +2153,101 @@ static int be_iopoll(struct blk_iopoll *iop, int budget)
 }
 
 static void
+hwi_write_sgl_v2(struct iscsi_wrb *pwrb, struct scatterlist *sg,
+ unsigned int num_sg, struct beiscsi_io_task *io_task)
+{
+   struct iscsi_sge *psgl;
+   unsigned int sg_len, index;
+   unsigned int sge_len = 0;
+   unsigned long long addr;
+   struct scatterlist *l_sg;
+   unsigned int offset;
+
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_lo, pwrb,
+ io_task-bhs_pa.u.a32.address_lo);
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_hi, pwrb,
+ io_task-bhs_pa.u.a32.address_hi);
+
+   l_sg = sg;
+   for (index = 0; (index  num_sg)  (index  2); index++,
+   sg = sg_next(sg)) {
+   if (index == 0) {
+   sg_len = sg_dma_len(sg);
+   addr = (u64) sg_dma_address(sg);
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
+ sge0_addr_lo, pwrb,
+ lower_32_bits(addr));
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
+ sge0_addr_hi, pwrb,
+ upper_32_bits(addr));
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
+ sge0_len, pwrb,
+ sg_len);
+   sge_len = sg_len;
+   } else {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_r2t_offset,
+ pwrb, sge_len);
+   sg_len = sg_dma_len(sg);
+   addr = (u64) sg_dma_address(sg);
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
+ sge1_addr_lo, pwrb,
+ lower_32_bits(addr));
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
+ sge1_addr_hi, pwrb,
+ upper_32_bits(addr));
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
+ sge1_len, pwrb,
+ sg_len);
+   }
+   }
+   psgl = (struct iscsi_sge *)io_task-psgl_handle-pfrag;
+   memset(psgl, 0, sizeof(*psgl) * BE2_SGE);
+
+   AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task-bhs_len - 2);
+
+   AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
+ io_task-bhs_pa.u.a32.address_hi);
+   AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
+ io_task-bhs_pa.u.a32.address_lo);
+
+   if (num_sg == 1) {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb,
+ 1);
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb,
+ 0);
+   } else if (num_sg == 2) {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb,
+ 0);
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb,
+ 1);
+   } else {
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb,
+ 0);
+   AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb,
+ 0);
+   }
+
+   sg = l_sg;
+   psgl++;
+   psgl++;
+   offset = 0;
+   for (index = 0; index  num_sg; index++, sg = sg_next(sg), psgl++) {
+   sg_len = sg_dma_len(sg);
+   addr = (u64) sg_dma_address(sg);
+   AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
+ lower_32_bits(addr));
+   AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
+ upper_32_bits(addr));
+   AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, sg_len);
+   AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, offset);
+   AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0);
+   offset += sg_len;
+   }
+   psgl--;
+   AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1);
+}
+
+static void
 hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg,
 

[PATCH 13/17] be2iscsi: Fix context update for session in Skyhawk.

2012-09-28 Thread John Soni Jose
 Fix the context update of a session in Skyhawk using the V2 version.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_iscsi.c |8 ++
 drivers/scsi/be2iscsi/be_main.c  |   69 ++-
 drivers/scsi/be2iscsi/be_main.h  |   50 +-
 drivers/scsi/be2iscsi/be_mgmt.c  |  139 ++
 drivers/scsi/be2iscsi/be_mgmt.h  |8 ++
 5 files changed, 212 insertions(+), 62 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index aedb0d9..32b9639 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -937,6 +937,14 @@ static void  beiscsi_set_params_for_offld(struct 
beiscsi_conn *beiscsi_conn,
  session-initial_r2t_en);
AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params,
  session-imm_data_en);
+   AMAP_SET_BITS(struct amap_beiscsi_offload_params,
+ data_seq_inorder, params,
+ session-dataseq_inorder_en);
+   AMAP_SET_BITS(struct amap_beiscsi_offload_params,
+ pdu_seq_inorder, params,
+ session-pdu_inorder_en);
+   AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_r2t, params,
+ session-max_r2t);
AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params,
  (conn-exp_statsn - 1));
 }
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 87ee112..8324e2b 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -4086,8 +4086,6 @@ beiscsi_offload_connection(struct beiscsi_conn 
*beiscsi_conn,
   struct beiscsi_offload_params *params)
 {
struct wrb_handle *pwrb_handle;
-   struct iscsi_target_context_update_wrb *pwrb = NULL;
-   struct be_mem_descriptor *mem_descr;
struct beiscsi_hba *phba = beiscsi_conn-phba;
struct iscsi_task *task = beiscsi_conn-task;
struct iscsi_session *session = task-conn-session;
@@ -4104,67 +4102,16 @@ beiscsi_offload_connection(struct beiscsi_conn 
*beiscsi_conn,
 
pwrb_handle = alloc_wrb_handle(phba, (beiscsi_conn-beiscsi_conn_cid -
   phba-fw_config.iscsi_cid_start));
-   pwrb = (struct iscsi_target_context_update_wrb *)pwrb_handle-pwrb;
-   memset(pwrb, 0, sizeof(*pwrb));
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
- max_burst_length, pwrb, params-dw[offsetof
- (struct amap_beiscsi_offload_params,
- max_burst_length) / 32]);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
- max_send_data_segment_length, pwrb,
- params-dw[offsetof(struct amap_beiscsi_offload_params,
- max_send_data_segment_length) / 32]);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
- first_burst_length,
- pwrb,
- params-dw[offsetof(struct amap_beiscsi_offload_params,
- first_burst_length) / 32]);
-
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb,
- (params-dw[offsetof(struct amap_beiscsi_offload_params,
- erl) / 32]  OFFLD_PARAMS_ERL));
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb,
- (params-dw[offsetof(struct amap_beiscsi_offload_params,
- dde) / 32]  OFFLD_PARAMS_DDE)  2);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb,
- (params-dw[offsetof(struct amap_beiscsi_offload_params,
- hde) / 32]  OFFLD_PARAMS_HDE)  3);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb,
- (params-dw[offsetof(struct amap_beiscsi_offload_params,
- ir2t) / 32]  OFFLD_PARAMS_IR2T)  4);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb,
- (params-dw[offsetof(struct amap_beiscsi_offload_params,
-  imd) / 32]  OFFLD_PARAMS_IMD)  5);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn,
- pwrb,
- (params-dw[offsetof(struct amap_beiscsi_offload_params,
- exp_statsn) / 32] + 1));
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb,
- 0x7);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx,
- pwrb, pwrb_handle-wrb_index);
-   AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb,
- pwrb, pwrb_handle-nxt_wrb_index);
-   

[PATCH 14/17] be2iscsi: Fix Task Completion Event handling for Skyhawk

2012-09-28 Thread John Soni Jose
 Fix the Completion events returned by the FW for Skyhawk.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_cmds.h |   53 
 drivers/scsi/be2iscsi/be_main.c |  267 ---
 drivers/scsi/be2iscsi/be_main.h |   14 ++
 3 files changed, 230 insertions(+), 104 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index c560e9d..135c096 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -826,6 +826,59 @@ struct amap_sol_cqe_ring {
u8 valid;   /* dword 3 */
 } __packed;
 
+struct amap_sol_cqe_v2 {
+   u8 hw_sts[8];   /* dword 0 */
+   u8 i_sts[8];/* dword 0 */
+   u8 wrb_index[16];   /* dword 0 */
+   u8 i_exp_cmd_sn[32];/* dword 1 */
+   u8 code[6]; /* dword 2 */
+   u8 cmd_cmpl;/* dword 2 */
+   u8 rsvd0;   /* dword 2 */
+   u8 i_cmd_wnd[8];/* dword 2 */
+   u8 cid[13]; /* dword 2 */
+   u8 u;   /* dword 2 */
+   u8 o;   /* dword 2 */
+   u8 s;   /* dword 2 */
+   u8 i_res_cnt[31];   /* dword 3 */
+   u8 valid;   /* dword 3 */
+} __packed;
+
+struct common_sol_cqe {
+   u32 exp_cmdsn;
+   u32 res_cnt;
+   u16 wrb_index;
+   u16 cid;
+   u8 hw_sts;
+   u8 cmd_wnd;
+   u8 res_flag; /* the s feild of structure */
+   u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
+   u8 i_flags; /* for skh or the u and o feilds */
+   u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
+};
+
+/*** iSCSI ack/driver message completions ***/
+struct amap_it_dmsg_cqe {
+   u8 ack_num[32]; /* DWORD 0 */
+   u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
+   u8 code[6]; /* DWORD 2 */
+   u8 cid[10]; /* DWORD 2 */
+   u8 wrb_idx[8];  /* DWORD 2 */
+   u8 rsvd0[8];/* DWORD 2*/
+   u8 rsvd1[31];   /* DWORD 3*/
+   u8 valid;   /* DWORD 3 */
+} __packed;
+
+struct amap_it_dmsg_cqe_v2 {
+   u8 ack_num[32]; /* DWORD 0 */
+   u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
+   u8 code[6]; /* DWORD 2 */
+   u8 rsvd0[10];   /* DWORD 2 */
+   u8 wrb_idx[16]; /* DWORD 2 */
+   u8 rsvd1[16];   /* DWORD 3 */
+   u8 cid[13]; /* DWORD 3 */
+   u8 rsvd2[2];/* DWORD 3 */
+   u8 valid;   /* DWORD 3 */
+} __packed;
 
 
 /**
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 8324e2b..f39cd6b 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1248,7 +1248,8 @@ free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct 
sgl_handle *psgl_handle)
 
 static void
 be_complete_io(struct beiscsi_conn *beiscsi_conn,
-  struct iscsi_task *task, struct sol_cqe *psol)
+   struct iscsi_task *task,
+   struct common_sol_cqe *csol_cqe)
 {
struct beiscsi_io_task *io_task = task-dd_data;
struct be_status_bhs *sts_bhs =
@@ -1258,20 +1259,14 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
u32 resid = 0, exp_cmdsn, max_cmdsn;
u8 rsp, status, flags;
 
-   exp_cmdsn = (psol-
-   dw[offsetof(struct amap_sol_cqe, i_exp_cmd_sn) / 32]
-SOL_EXP_CMD_SN_MASK);
-   max_cmdsn = ((psol-
-   dw[offsetof(struct amap_sol_cqe, i_exp_cmd_sn) / 32]
-SOL_EXP_CMD_SN_MASK) +
-   ((psol-dw[offsetof(struct amap_sol_cqe, i_cmd_wnd)
-   / 32]  SOL_CMD_WND_MASK)  24) - 1);
-   rsp = ((psol-dw[offsetof(struct amap_sol_cqe, i_resp) / 32]
-SOL_RESP_MASK)  16);
-   status = ((psol-dw[offsetof(struct amap_sol_cqe, i_sts) / 32]
-SOL_STS_MASK)  8);
-   flags = ((psol-dw[offsetof(struct amap_sol_cqe, i_flags) / 32]
-SOL_FLAGS_MASK)  24) | 0x80;
+   exp_cmdsn = csol_cqe-exp_cmdsn;
+   max_cmdsn = (csol_cqe-exp_cmdsn +
+csol_cqe-cmd_wnd - 1);
+   rsp = csol_cqe-i_resp;
+   status = csol_cqe-i_sts;
+   flags = csol_cqe-i_flags;
+   resid = csol_cqe-res_cnt;
+
if (!task-sc) {
if (io_task-scsi_cmnd)
scsi_dma_unmap(io_task-scsi_cmnd);
@@ -1286,9 +1281,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 
/* bidi not initially supported */
if (flags  (ISCSI_FLAG_CMD_UNDERFLOW | ISCSI_FLAG_CMD_OVERFLOW)) {
-   resid = (psol-dw[offsetof(struct amap_sol_cqe, i_res_cnt) /
-   32]  SOL_RES_CNT_MASK);
-
if (!status  (flags  ISCSI_FLAG_CMD_OVERFLOW))
task-sc-result = DID_ERROR  16;
 
@@ -1310,13 +1302,8 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
 

[PATCH 15/17] be2iscsi: Fix issue of displaying adapter family.

2012-09-28 Thread John Soni Jose
 Fix the issue of displaying adapter family by creating new
 sys attribute.

Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.c |2 ++
 drivers/scsi/be2iscsi/be_mgmt.c |   38 ++
 drivers/scsi/be2iscsi/be_mgmt.h |3 +++
 3 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index f39cd6b..6da7e18 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -152,9 +152,11 @@ BEISCSI_RW_ATTR(log_enable, 0x00,
\t\t\t\tConfiguration Path : 0x20\n);
 
 DEVICE_ATTR(beiscsi_drvr_ver, S_IRUGO, beiscsi_drvr_ver_disp, NULL);
+DEVICE_ATTR(beiscsi_adapter_family, S_IRUGO, beiscsi_adap_family_disp, NULL);
 struct device_attribute *beiscsi_attrs[] = {
dev_attr_beiscsi_log_enable,
dev_attr_beiscsi_drvr_ver,
+   dev_attr_beiscsi_adapter_family,
NULL,
 };
 
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index b96a159..02c6344 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1153,6 +1153,44 @@ beiscsi_drvr_ver_disp(struct device *dev, struct 
device_attribute *attr,
return snprintf(buf, PAGE_SIZE, BE_NAME \n);
 }
 
+/**
+ * beiscsi_adap_family_disp()- Display adapter family.
+ * @dev: ptr to device to get priv structure
+ * @attr: device attribute, not used.
+ * @buf: contains formatted text driver name and version
+ *
+ * return
+ * size of the formatted string
+ **/
+ssize_t
+beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   uint16_t dev_id = 0;
+   struct Scsi_Host *shost = class_to_shost(dev);
+   struct beiscsi_hba *phba = iscsi_host_priv(shost);
+
+   dev_id = phba-pcidev-device;
+   switch (dev_id) {
+   case BE_DEVICE_ID1:
+   case OC_DEVICE_ID1:
+   case OC_DEVICE_ID2:
+   return snprintf(buf, PAGE_SIZE, BE2 Adapter Family\n);
+   break;
+   case BE_DEVICE_ID2:
+   case OC_DEVICE_ID3:
+   return snprintf(buf, PAGE_SIZE, BE3 Adapter Family\n);
+   break;
+   case OC_SKH_ID1:
+   return snprintf(buf, PAGE_SIZE, Skyhawk Adapter Family\n);
+   break;
+   default:
+   return snprintf(buf, PAGE_SIZE, Unkown Adapter Type\n);
+   break;
+   }
+}
+
+
 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
 struct wrb_handle *pwrb_handle,
 struct be_mem_descriptor *mem_descr)
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index 4ec6127..e2c222a 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -305,6 +305,9 @@ int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t 
vlan_tag);
 ssize_t beiscsi_drvr_ver_disp(struct device *dev,
   struct device_attribute *attr, char *buf);
 
+ssize_t beiscsi_adap_family_disp(struct device *dev,
+ struct device_attribute *attr, char *buf);
+
 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
 struct wrb_handle *pwrb_handle,
 struct be_mem_descriptor *mem_descr);
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Fix the copyright information

2012-09-28 Thread John Soni Jose
Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be.h   |2 +-
 drivers/scsi/be2iscsi/be_cmds.c  |2 +-
 drivers/scsi/be2iscsi/be_cmds.h  |2 +-
 drivers/scsi/be2iscsi/be_iscsi.c |2 +-
 drivers/scsi/be2iscsi/be_iscsi.h |2 +-
 drivers/scsi/be2iscsi/be_main.c  |2 +-
 drivers/scsi/be2iscsi/be_main.h  |2 +-
 drivers/scsi/be2iscsi/be_mgmt.c  |2 +-
 drivers/scsi/be2iscsi/be_mgmt.h  |2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 7d9267b..5d3a51a 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 1257038..c52b964 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 135c096..37f2bb5 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 32b9639..08f3683 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index 8b826fc..38eab72 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 6da7e18..920b016 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 53c052e..741f215 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 02c6344..6f56ce8 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index e2c222a..88a8ed2 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2005 - 2011 Emulex
+ * Copyright (C) 2005 - 2012 Emulex
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
-- 
1.7.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi 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] be2iscsi: Bump the driver version

2012-09-28 Thread John Soni Jose
Signed-off-by: John Soni Jose sony.joh...@emulex.com
Signed-off-by: Jayamohan Kallickal jayamohan.kallic...@emulex.com
---
 drivers/scsi/be2iscsi/be_main.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 741f215..b3d009f 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 
 #include be.h
 #define DRV_NAME   be2iscsi
-#define BUILD_STR  4.4.58.0
+#define BUILD_STR  10.0.250.0
 #define BE_NAMEEmulex OneConnect \
Open-iSCSI Driver version BUILD_STR
 #define DRV_DESC   BE_NAME   Driver
-- 
1.7.2

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


Re: [PATCH v7 2/6] scsi: sr: support runtime pm

2012-09-28 Thread Aaron Lu
[Adding more people and list back in]

On 09/29/2012 05:46 AM, Rafael J. Wysocki wrote:
 On Friday, September 28, 2012, Aaron Lu wrote:
 On 09/28/2012 07:15 AM, Rafael J. Wysocki wrote:
 On Thursday, September 27, 2012, Aaron Lu wrote:
 On 09/27/2012 05:37 AM, Rafael J. Wysocki wrote:

 Say the user has pressed the eject button.  What does need to happen so 
 that
 the tray is physically ejected?

 The tray is ejected by the ODD itself, host does not have to do anything.

 There is a command(PREVENT_MEDIUM_REMOVAL) to lock the door so that when
 user presses the eject button, the tray will not be ejected. This command
 is usually sent when we have a disc inside and a user space program
 opened the underlying block device(e.g. /dev/sr0) to read/write data.

 And host can also eject the tray by sending a START_STOP_UNIT command
 with param LoEj set to 1 and we have a function called sr_tray_move to
 do just this. And this is also what I've used to eject the tray after
 user wakes up the ODD, as when user presses the eject button when the
 ODD is in zero power state, it can't eject the tray as usual, so host
 software will need to do this, that's the reason I need to know such
 information:
 When ODD is resumed, is it because user wakes it up?

 But START_STOP_UNIT eventually causes ata_scsi_start_stop_xlat() to be

 You are following ata case, while the ODD is an atapi device :-)
 The translation function is atapi_xlat, but that doesn't affect the idea
 here.

 executed, so I wonder if we really need to go up through the SCSI stack
 to send that command to the drive from there?  It should be possible
 to issue STANDBY/READ VERIFY to the device directly from libata if
 an eject event is signaled through a GPE.

 Yes, this is possible.
 Though it doesn't feel very cool, since I have no idea if the ODD is a
 tray type or slot type in ATA layer and I'll blindly send this command
 to it then, not a problem maybe.
 
 It would be good to verify if that works for slot devices, if possible.

The ACPI GPE event is triggered when user inserts a disc into a slot
type ODD, and if I send an eject command to it, the disc will be
ejected, which is wrong.

I need to know the loading mechanism(tray type or slot type) of the ODD
to decide if I should send this command.

 
 And what do you think of moving the acpi notification code to sr?
 http://marc.info/?l=linux-pmm=134873904332704w=4
 
 I don't think this is a good idea, quite frankly.  sr seems to be a too
 generic place for that.

Does this mean sr can only have code that is useful to all devices it
manages? i.e. If a piece of code enables a feature for a special kind of
ODD(like the sata based ZPODD), it shouldn't be done in sr?

 
 Ideally, the whole ZPODD handling should not be visible to the SCSI layer,

I can see 2 problems:
- Don't know its loading machanism so we have the problem above;
- Need to send command to find out if ODD is zero power ready somewhere
  in ata layer, this implies the device is doing IO after it is runtime
  suspended in scsi layer.

 perhaps except the no_polling flag disabling the polling that may be
 useful for other purposes in principle.

I hope so, let's hear what other people has to say.

 
 I'm not sure if it's possible at this point, but if not we need to know
 very precisely why not.

There is nothing in theory stopping us from doing this in ata layer.
For the loading mechanism, we can always send an ATAPI command to figure
it out.

So gentlemen, I need your opinions on where this ZPODD code should live
before I can continue this work, thanks.

-Aaron

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


[PATCH v2 scsi] Short the path length of scsi_cmd_to_driver()

2012-09-28 Thread Li Zhong
As suggested by James: this patch tries to short the path length of
scsi_cmd_to_driver(). As only REQ_TYPE_BLOCK_PC commands can be
submitted without a driver, so we could avoid the related NULL
checking, as long as we make sure we don't use it for REQ_TYPE_BLOCK_PC
type commands. Plus, this fixes a bug where you get different behaviors
from REQ_TYPE_BLOCK_PC commands when a driver is and isn't attached.

v2: mirror code != REQ_TYPE_BLOCK_PC in scsi.c, rather than == REQ_TYPE_FS

Signed-off-by: Li Zhong zh...@linux.vnet.ibm.com
---
 drivers/scsi/scsi_error.c |8 +---
 include/scsi/scsi_cmnd.h  |   12 ++--
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index de2337f..c1b05a8 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -789,7 +789,6 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
 int cmnd_size, int timeout, unsigned sense_bytes)
 {
struct scsi_device *sdev = scmd-device;
-   struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
struct Scsi_Host *shost = sdev-host;
DECLARE_COMPLETION_ONSTACK(done);
unsigned long timeleft;
@@ -845,8 +844,11 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, 
unsigned char *cmnd,
 
scsi_eh_restore_cmnd(scmd, ses);
 
-   if (sdrv  sdrv-eh_action)
-   rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
+   if (scmd-request-cmd_type != REQ_TYPE_BLOCK_PC) {
+   struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
+   if (sdrv-eh_action)
+   rtn = sdrv-eh_action(scmd, cmnd, cmnd_size, rtn);
+   }
 
return rtn;
 }
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index ac06cc5..de5f5d8 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -132,18 +132,10 @@ struct scsi_cmnd {
unsigned char tag;  /* SCSI-II queued command tag */
 };
 
+/* make sure not to use it with REQ_TYPE_BLOCK_PC commands */
 static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 {
-   struct scsi_driver **sdp;
-
-   if (!cmd-request-rq_disk)
-   return NULL;
-
-   sdp = (struct scsi_driver **)cmd-request-rq_disk-private_data;
-   if (!sdp)
-   return NULL;
-
-   return *sdp;
+   return *(struct scsi_driver **)cmd-request-rq_disk-private_data;
 }
 
 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
-- 
1.7.7.6



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