Re: [PATCH v13 1/9] scsi: sr: support runtime pm

2013-01-17 Thread Aaron Lu
On Wed, Jan 16, 2013 at 11:31:31AM -0500, Alan Stern wrote:
> On Wed, 16 Jan 2013, James Bottomley wrote:
> 
> > On Tue, 2013-01-15 at 17:20 +0800, Aaron Lu wrote:
> > > This patch adds runtime pm support for sr.
> > > 
> > > It did this by increasing the runtime usage_count of the device when:
> > > - its block device is opened;
> > > - the events checking is to run.
> > > 
> > > And decreasing the runtime usage_count of the device when:
> > > - its block device is closed;
> > > - After the events checking is done.
> > > 
> > > The idea is discussed in this mail thread:
> > > http://thread.gmane.org/gmane.linux.acpi.devel/55243/focus=52703
> > > 
> > > Signed-off-by: Aaron Lu 
> > 
> > I'd like an ack from Alan Stern as well, please, but with that, you can
> > add my acked-by.
> 
> Aaron, have you checked whether this patch works okay when you play a
> track on an audio-only CD on the computer?  The block interface looks 
> okay but I'm not sure about the cdrom_device interface.

Just verified it works OK with the whole patchset applied using 2 audio
CDs.

After the ODD has been put into zero power state, insert an audio cd.
ODD will be resumed, gvfs will automatically mount the disc, and a
dialog titled "Audio Disc" asks me what to do. Press OK, the rhythmbox
application will get started. Press the Play button of rhythmbox, songs
will start to play, and runtime_usage is 2. Eject the disc, the ODD will
be put to zero power state some time later.

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


[Announce] sg3_utils-1.35 available

2013-01-17 Thread Douglas Gilbert

sg3_utils is a package of command line utilities for sending
SCSI and some ATA commands to devices. This package targets
the linux kernel (lk) 3, 2.6 and lk 2.4 series. It also has
ports to FreeBSD, Tru64, Solaris, and Windows (cygwin and mingw).

This version adds sg_compare_and_write (contributed by
Shahar Salzman). Also Hannes Reinecke has done more work on
'sg_inq --export' to support udev. This version tracks various
changes made by www.t10.org since October 2012.

For an overview of sg3_utils and downloads see this page:
http://sg.danny.cz/sg/sg3_utils.html
The sg_ses utility (for enclosure devices) is discussed at:
http://sg.danny.cz/sg/sg_ses.html
The SG_IO ioctl is discussed at:
http://sg.danny.cz/sg/sg_io.html
A full changelog can be found at:
http://sg.danny.cz/sg/p/sg3_utils.ChangeLog

A release announcement will be sent to freecode.com .

Changelog for sg3_utils-1.35 [20130117] [svn: r476]
  - sg_compare_and_write: new utility
  - sg_inq+sg_vpd: block device characteristics VPD page:
add product_type, WABEREQ, WACEREQ and VBULS fields
  - sg_inq: more --export option changes for udev
  - sg_vpd: add more rdac vendor specific vpd pages
  - sg_verify: add --ebytchk option for sbc3r34 changes
  - sg_stpg: --offline option: fix 'Invalid state 0xe'
  - sg_ses: Door Lock element changed to Door element and
abbreviation changed from 'dl' to 'do' (ses3r05)
  - archive/rescan-scsi-bus.sh: upgrade to version 1.53hr
- move rescan-scsi-bus.sh to scripts directory
  - sync to sbc3r34
  - sg_lib: sg_ll_verify10+16 expand BYTCHK to 2 bit field
  - sg_pt_win32, sg_scan(win32): changes for cygwin 1.7.17
  - clean up man page summary lines

Changelog for sg3_utils-1.34 [20121013] [svn: r461]
...

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


LSF/MM Summit CFP

2013-01-17 Thread Martin K. Petersen

The annual Linux Storage, Filesystem and Memory Management Summit for
2013 will be held on April 18th and 19th following the Linux Foundation
Collaboration Summit at Parc 55 Hotel in San Francisco, CA:

https://events.linuxfoundation.org/events/collaboration-summit
https://events.linuxfoundation.org/events/lsfmm-summit

We'd therefore like to issue a call for agenda proposals that are
suitable for cross-track discussion as well as more technical subjects
for discussion in the breakout sessions.

1) Suggestions for agenda topics should be sent before February 8th
2013 to:

lsf...@lists.linux-foundation.org

and optionally cc the Linux list which would be most interested in it:

ATA: linux-...@vger.kernel.org
SCSI: linux-scsi@vger.kernel.org
FS: linux-fsde...@vger.kernel.org
MM: linux...@kvack.org

Please remember to tag your subject with [LSF/MM TOPIC] to make it
easier to track. Agenda topics and attendees will be selected by the
program committee, but the final agenda will be formed by consensus of
the attendees on the day.

We'll try to cap attendance at around 25-30 per track to facilitate
discussions although the final numbers will depend on the room sizes at
the venue.

2) Requests to attend the summit should be sent to:

lsf...@lists.linux-foundation.org

Please summarize what expertise you will bring to the meeting, and what
you'd like to discuss.  please also tag your email with [ATTEND] so
there's less chance of it getting lost in the large mail pile.

Presentations are allowed to guide discussion, but are strongly
discouraged. There will be no recording or audio bridge. However,
written minutes will be published as in previous years:

2012:
http://lwn.net/Articles/490114/
http://lwn.net/Articles/490501/

2011:
http://lwn.net/Articles/436871/
http://lwn.net/Articles/437066/

2010:
http://lwn.net/Articles/399148/
http://lwn.net/Articles/399313/
http://lwn.net/Articles/400589/

2009:
http://lwn.net/Articles/327601/
http://lwn.net/Articles/327740/
http://lwn.net/Articles/328347/

Prior years:
http://www.usenix.org/events/lsf08/tech/lsf08sums.pdf
http://www.usenix.org/publications/login/2007-06/openpdfs...

3) If you have feedback on last year's meeting that we can use to
improve this year's, please also send that to:

lsf...@lists.linux-foundation.org

Thank you on behalf of the program committee:

Storage:
Martin K. Petersen
Jens Axboe
James Bottomley

Filesystems:
Ric Wheeler
Christoph Hellwig
Jaegeuk Kim
Jeffrey Layton
Tao Ma
Chris Mason
Trond Myklebust
Eric Sandeen
Theodore Ts'o
Sage Weil

MM:
Rik van Riel
Mel Gorman
Ying Han

-- 
Martin K. Petersen  Oracle Linux Engineering
--
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 6/8] ipr: Implement block iopoll

2013-01-17 Thread wenxiong
This patch implements blk iopoll in ipr driver for performance improvement.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |  221 +
 drivers/scsi/ipr.h |6 +
 2 files changed, 178 insertions(+), 49 deletions(-)

Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 16:11:20.062476228 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 16:11:50.275910225 -0600
@@ -108,6 +108,7 @@ static const struct ipr_chip_cfg_t ipr_c
.max_cmds = 100,
.cache_line_size = 0x20,
.clear_isr = 1,
+   .iopoll_weight = 0,
{
.set_interrupt_mask_reg = 0x0022C,
.clr_interrupt_mask_reg = 0x00230,
@@ -132,6 +133,7 @@ static const struct ipr_chip_cfg_t ipr_c
.max_cmds = 100,
.cache_line_size = 0x20,
.clear_isr = 1,
+   .iopoll_weight = 0,
{
.set_interrupt_mask_reg = 0x00288,
.clr_interrupt_mask_reg = 0x0028C,
@@ -156,6 +158,7 @@ static const struct ipr_chip_cfg_t ipr_c
.max_cmds = 1000,
.cache_line_size = 0x20,
.clear_isr = 0,
+   .iopoll_weight = 64,
{
.set_interrupt_mask_reg = 0x00010,
.clr_interrupt_mask_reg = 0x00018,
@@ -3560,6 +3563,95 @@ static struct device_attribute ipr_ioa_r
.store = ipr_store_reset_adapter
 };
 
+static int ipr_iopoll(struct blk_iopoll *iop, int budget);
+ /**
+ * ipr_show_iopoll_weight - Show ipr polling mode
+ * @dev:   class device struct
+ * @buf:   buffer
+ *
+ * Return value:
+ * number of bytes printed to buffer
+ **/
+static ssize_t ipr_show_iopoll_weight(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct Scsi_Host *shost = class_to_shost(dev);
+   struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
+   unsigned long lock_flags = 0;
+   int len;
+
+   spin_lock_irqsave(shost->host_lock, lock_flags);
+   len = snprintf(buf, PAGE_SIZE, "%d\n", ioa_cfg->iopoll_weight);
+   spin_unlock_irqrestore(shost->host_lock, lock_flags);
+
+   return len;
+}
+
+/**
+ * ipr_store_iopoll_weight - Change the adapter's polling mode
+ * @dev:   class device struct
+ * @buf:   buffer
+ *
+ * Return value:
+ * number of bytes printed to buffer
+ **/
+static ssize_t ipr_store_iopoll_weight(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct Scsi_Host *shost = class_to_shost(dev);
+   struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
+   unsigned long user_iopoll_weight;
+   unsigned long lock_flags = 0;
+   int i;
+
+   if (!ioa_cfg->sis64) {
+   dev_info(&ioa_cfg->pdev->dev, "blk-iopoll not supported on this 
adapter\n");
+   return -EINVAL;
+   }
+   if (kstrtoul(buf, 10, &user_iopoll_weight))
+   return -EINVAL;
+
+   if (user_iopoll_weight > 256) {
+   dev_info(&ioa_cfg->pdev->dev, "Invalid blk-iopoll weight. It 
must be less than 256\n");
+   return -EINVAL;
+   }
+
+   if (user_iopoll_weight == ioa_cfg->iopoll_weight) {
+   dev_info(&ioa_cfg->pdev->dev, "Current blk-iopoll weight has 
the same weight\n");
+   return strlen(buf);
+   }
+
+   if (blk_iopoll_enabled && ioa_cfg->iopoll_weight &&
+   ioa_cfg->sis64 && ioa_cfg->nvectors > 1) {
+   for (i = 1; i < ioa_cfg->hrrq_num; i++)
+   blk_iopoll_disable(&ioa_cfg->hrrq[i].iopoll);
+   }
+
+   spin_lock_irqsave(shost->host_lock, lock_flags);
+   ioa_cfg->iopoll_weight = user_iopoll_weight;
+   if (blk_iopoll_enabled && ioa_cfg->iopoll_weight &&
+   ioa_cfg->sis64 && ioa_cfg->nvectors > 1) {
+   for (i = 1; i < ioa_cfg->hrrq_num; i++) {
+   blk_iopoll_init(&ioa_cfg->hrrq[i].iopoll,
+   ioa_cfg->iopoll_weight, ipr_iopoll);
+   blk_iopoll_enable(&ioa_cfg->hrrq[i].iopoll);
+   }
+   }
+   spin_unlock_irqrestore(shost->host_lock, lock_flags);
+
+   return strlen(buf);
+}
+
+static struct device_attribute ipr_iopoll_weight_attr = {
+   .attr = {
+   .name = "iopoll_weight",
+   .mode = S_IRUGO | S_IWUSR,
+   },
+   .show = ipr_show_iopoll_weight,
+   .store = ipr_store_iopoll_weight
+};
+
 /**
  * ipr_alloc_ucode_buffer - Allocates a microcode download buffer
  * @buf_len:   buffer length
@@ -3928,6 

[PATCH V2 5/8] ipr: Reduce lock contention

2013-01-17 Thread wenxiong
This patch reduces lock contention while implementing distributed 
completion processing. 

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |  323 +
 drivers/scsi/ipr.h |   21 +--
 2 files changed, 240 insertions(+), 104 deletions(-)

Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 13:40:15.992165067 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 16:11:20.062476228 -0600
@@ -552,7 +552,8 @@ static void ipr_trc_hook(struct ipr_cmnd
struct ipr_trace_entry *trace_entry;
struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
 
-   trace_entry = &ioa_cfg->trace[ioa_cfg->trace_index++];
+   trace_entry = &ioa_cfg->trace[atomic_add_return
+   (1, &ioa_cfg->trace_index)%IPR_NUM_TRACE_ENTRIES];
trace_entry->time = jiffies;
trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0];
trace_entry->type = type;
@@ -563,6 +564,7 @@ static void ipr_trc_hook(struct ipr_cmnd
trace_entry->cmd_index = ipr_cmd->cmd_index & 0xff;
trace_entry->res_handle = ipr_cmd->ioarcb.res_handle;
trace_entry->u.add_data = add_data;
+   wmb();
 }
 #else
 #define ipr_trc_hook(ipr_cmd, type, add_data) do { } while (0)
@@ -697,9 +699,15 @@ static void ipr_mask_and_clear_interrupt
  u32 clr_ints)
 {
volatile u32 int_reg;
+   int i;
 
/* Stop new interrupts */
-   ioa_cfg->allow_interrupts = 0;
+   for (i = 0; i < ioa_cfg->hrrq_num; i++) {
+   spin_lock(&ioa_cfg->hrrq[i]._lock);
+   ioa_cfg->hrrq[i].allow_interrupts = 0;
+   spin_unlock(&ioa_cfg->hrrq[i]._lock);
+   }
+   wmb();
 
/* Set interrupt mask to stop all new interrupts */
if (ioa_cfg->sis64)
@@ -818,6 +826,7 @@ static void ipr_fail_all_ops(struct ipr_
 
ENTER;
for_each_hrrq(hrrq, ioa_cfg) {
+   spin_lock(&hrrq->_lock);
list_for_each_entry_safe(ipr_cmd,
temp, &hrrq->hrrq_pending_q, queue) {
list_del(&ipr_cmd->queue);
@@ -837,6 +846,7 @@ static void ipr_fail_all_ops(struct ipr_
del_timer(&ipr_cmd->timer);
ipr_cmd->done(ipr_cmd);
}
+   spin_unlock(&hrrq->_lock);
}
LEAVE;
 }
@@ -991,12 +1001,9 @@ static void ipr_send_blocking_cmd(struct
 static int ipr_get_hrrq_index(struct ipr_ioa_cfg *ioa_cfg)
 {
if (ioa_cfg->hrrq_num == 1)
-   ioa_cfg->hrrq_index = 0;
-   else {
-   if (++ioa_cfg->hrrq_index >= ioa_cfg->hrrq_num)
-   ioa_cfg->hrrq_index = 1;
-   }
-   return ioa_cfg->hrrq_index;
+   return 0;
+   else
+   return (atomic_add_return(1, &ioa_cfg->hrrq_index) % 
(ioa_cfg->hrrq_num - 1)) + 1;
 }
 
 /**
@@ -1018,7 +1025,7 @@ static void ipr_send_hcam(struct ipr_ioa
struct ipr_cmnd *ipr_cmd;
struct ipr_ioarcb *ioarcb;
 
-   if (ioa_cfg->allow_cmds) {
+   if (ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds) {
ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_pending_q);
list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_pending_q);
@@ -2564,7 +2571,7 @@ static int ipr_reset_reload(struct ipr_i
 
/* If we got hit with a host reset while we were already resetting
 the adapter for some reason, and the reset failed. */
-   if (ioa_cfg->ioa_is_dead) {
+   if (ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead) {
ipr_trace;
return FAILED;
}
@@ -3205,7 +3212,8 @@ static void ipr_worker_thread(struct wor
 restart:
do {
did_work = 0;
-   if (!ioa_cfg->allow_cmds || !ioa_cfg->allow_ml_add_del) {
+   if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds ||
+   !ioa_cfg->allow_ml_add_del) {
spin_unlock_irqrestore(ioa_cfg->host->host_lock, 
lock_flags);
return;
}
@@ -3453,7 +3461,7 @@ static ssize_t ipr_show_adapter_state(st
int len;
 
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
-   if (ioa_cfg->ioa_is_dead)
+   if (ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead)
len = snprintf(buf, PAGE_SIZE, "offline\n");
else
len = snprintf(buf, PAGE_SIZE, "online\n");
@@ -3479,14 +3487,20 @@ static ssize_t ipr_store_adapter_state(s
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags;
-   int result = count;
+   int result = count, i;
 
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
 
spin_lo

[PATCH V2 4/8] ipr: Add support for MSI-X and distributed completion

2013-01-17 Thread wenxiong
The new generation IBM SAS Controllers will support MSI-X interrupts and
Distributed Completion Processing features. This patch add these support
in ipr device driver.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |  718 -
 drivers/scsi/ipr.h |   70 +++--
 2 files changed, 595 insertions(+), 193 deletions(-)

Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 13:31:35.105915246 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 16:13:41.442476346 -0600
@@ -98,6 +98,7 @@ static unsigned int ipr_transop_timeout 
 static unsigned int ipr_debug = 0;
 static unsigned int ipr_max_devs = IPR_DEFAULT_SIS64_DEVS;
 static unsigned int ipr_dual_ioa_raid = 1;
+static unsigned int ipr_number_of_msix = 2;
 static DEFINE_SPINLOCK(ipr_driver_lock);
 
 /* This table describes the differences between DMA controller chips */
@@ -215,6 +216,8 @@ MODULE_PARM_DESC(dual_ioa_raid, "Enable 
 module_param_named(max_devs, ipr_max_devs, int, 0);
 MODULE_PARM_DESC(max_devs, "Specify the maximum number of physical devices. "
 "[Default=" __stringify(IPR_DEFAULT_SIS64_DEVS) "]");
+module_param_named(number_of_msix, ipr_number_of_msix, int, 0);
+MODULE_PARM_DESC(number_of_msix, "Specify the number of MSIX interrupts to use 
on capable adapters (1 - 5).  (default:2)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(IPR_DRIVER_VERSION);
 
@@ -595,8 +598,11 @@ static void ipr_reinit_ipr_cmnd(struct i
struct ipr_ioasa *ioasa = &ipr_cmd->s.ioasa;
struct ipr_ioasa64 *ioasa64 = &ipr_cmd->s.ioasa64;
dma_addr_t dma_addr = ipr_cmd->dma_addr;
+   int hrrq_id;
 
+   hrrq_id = ioarcb->cmd_pkt.hrrq_id;
memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt));
+   ioarcb->cmd_pkt.hrrq_id = hrrq_id;
ioarcb->data_transfer_length = 0;
ioarcb->read_data_transfer_length = 0;
ioarcb->ioadl_len = 0;
@@ -646,12 +652,16 @@ static void ipr_init_ipr_cmnd(struct ipr
  * pointer to ipr command struct
  **/
 static
-struct ipr_cmnd *__ipr_get_free_ipr_cmnd(struct ipr_ioa_cfg *ioa_cfg)
+struct ipr_cmnd *__ipr_get_free_ipr_cmnd(struct ipr_hrr_queue *hrrq)
 {
-   struct ipr_cmnd *ipr_cmd;
+   struct ipr_cmnd *ipr_cmd = NULL;
+
+   if (likely(!list_empty(&hrrq->hrrq_free_q))) {
+   ipr_cmd = list_entry(hrrq->hrrq_free_q.next,
+   struct ipr_cmnd, queue);
+   list_del(&ipr_cmd->queue);
+   }
 
-   ipr_cmd = list_entry(ioa_cfg->free_q.next, struct ipr_cmnd, queue);
-   list_del(&ipr_cmd->queue);
 
return ipr_cmd;
 }
@@ -666,7 +676,8 @@ struct ipr_cmnd *__ipr_get_free_ipr_cmnd
 static
 struct ipr_cmnd *ipr_get_free_ipr_cmnd(struct ipr_ioa_cfg *ioa_cfg)
 {
-   struct ipr_cmnd *ipr_cmd = __ipr_get_free_ipr_cmnd(ioa_cfg);
+   struct ipr_cmnd *ipr_cmd =
+   __ipr_get_free_ipr_cmnd(&ioa_cfg->hrrq[IPR_INIT_HRRQ]);
ipr_init_ipr_cmnd(ipr_cmd, ipr_lock_and_done);
return ipr_cmd;
 }
@@ -761,13 +772,12 @@ static int ipr_set_pcix_cmd_reg(struct i
  **/
 static void ipr_sata_eh_done(struct ipr_cmnd *ipr_cmd)
 {
-   struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
struct ata_queued_cmd *qc = ipr_cmd->qc;
struct ipr_sata_port *sata_port = qc->ap->private_data;
 
qc->err_mask |= AC_ERR_OTHER;
sata_port->ioasa.status |= ATA_BUSY;
-   list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
+   list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
ata_qc_complete(qc);
 }
 
@@ -783,14 +793,13 @@ static void ipr_sata_eh_done(struct ipr_
  **/
 static void ipr_scsi_eh_done(struct ipr_cmnd *ipr_cmd)
 {
-   struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd;
 
scsi_cmd->result |= (DID_ERROR << 16);
 
scsi_dma_unmap(ipr_cmd->scsi_cmd);
scsi_cmd->scsi_done(scsi_cmd);
-   list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
+   list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
 }
 
 /**
@@ -805,24 +814,30 @@ static void ipr_scsi_eh_done(struct ipr_
 static void ipr_fail_all_ops(struct ipr_ioa_cfg *ioa_cfg)
 {
struct ipr_cmnd *ipr_cmd, *temp;
+   struct ipr_hrr_queue *hrrq;
 
ENTER;
-   list_for_each_entry_safe(ipr_cmd, temp, &ioa_cfg->pending_q, queue) {
-   list_del(&ipr_cmd->queue);
+   for_each_hrrq(hrrq, ioa_cfg) {
+   list_for_each_entry_safe(ipr_cmd,
+   temp, &hrrq->hrrq_pending_q, queue) {
+   list_del(&ipr_cmd->queue);
+
+   ipr_cmd->s.ioasa.hdr.ioasc =
+   cpu_to_be32(IPR_IOASC_IOA_WAS_RESET);
+   ipr_cmd->s.ioasa.hdr.ilid =
+   cpu_to_be32(IPR_DRIVER_ILID);
 
-   ipr_cmd->s.ioasa.hdr.ioasc = 
cpu_to_be3

[PATCH V2 0/8] Add support for new IBM SAS controllers

2013-01-17 Thread wenxiong
Hi All,

The only change is the subject line with moving V2 inside of [] since last time.

Thanks for your help!
Wendy



-- 
--
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 7/8] ipr: Driver version 2.6.0

2013-01-17 Thread wenxiong
Bump driver version.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: b/drivers/scsi/ipr.h
===
--- a/drivers/scsi/ipr.h2013-01-11 16:11:50.275910225 -0600
+++ b/drivers/scsi/ipr.h2013-01-11 16:12:03.673719736 -0600
@@ -39,8 +39,8 @@
 /*
  * Literals
  */
-#define IPR_DRIVER_VERSION "2.5.4"
-#define IPR_DRIVER_DATE "(July 11, 2012)"
+#define IPR_DRIVER_VERSION "2.6.0"
+#define IPR_DRIVER_DATE "(November 16, 2012)"
 
 /*
  * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding

-- 
--
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 8/8] ipr: Fix sparse error in ipr driver

2013-01-17 Thread wenxiong
This patch fixes the following sparse error:

 CHECK   drivers/scsi/ipr.c
spinlock.h:147:9: warning: context imbalance in 'ipr_reset_reload' - unexpected 
unlock

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |   69 +
 1 file changed, 17 insertions(+), 52 deletions(-)

Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 16:13:50.803418076 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 16:14:53.092477895 -0600
@@ -2553,36 +2553,6 @@ static void ipr_oper_timeout(struct ipr_
 }
 
 /**
- * ipr_reset_reload - Reset/Reload the IOA
- * @ioa_cfg:   ioa config struct
- * @shutdown_type: shutdown type
- *
- * This function resets the adapter and re-initializes it.
- * This function assumes that all new host commands have been stopped.
- * Return value:
- * SUCCESS / FAILED
- **/
-static int ipr_reset_reload(struct ipr_ioa_cfg *ioa_cfg,
-   enum ipr_shutdown_type shutdown_type)
-{
-   if (!ioa_cfg->in_reset_reload)
-   ipr_initiate_ioa_reset(ioa_cfg, shutdown_type);
-
-   spin_unlock_irq(ioa_cfg->host->host_lock);
-   wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
-   spin_lock_irq(ioa_cfg->host->host_lock);
-
-   /* If we got hit with a host reset while we were already resetting
-the adapter for some reason, and the reset failed. */
-   if (ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead) {
-   ipr_trace;
-   return FAILED;
-   }
-
-   return SUCCESS;
-}
-
-/**
  * ipr_find_ses_entry - Find matching SES in SES table
  * @res:   resource entry struct of SES
  *
@@ -4797,22 +4767,18 @@ static int ipr_slave_alloc(struct scsi_d
return rc;
 }
 
-/**
- * ipr_eh_host_reset - Reset the host adapter
- * @scsi_cmd:  scsi command struct
- *
- * Return value:
- * SUCCESS / FAILED
- **/
-static int __ipr_eh_host_reset(struct scsi_cmnd *scsi_cmd)
+static int ipr_eh_host_reset(struct scsi_cmnd *cmd)
 {
struct ipr_ioa_cfg *ioa_cfg;
-   int rc;
+   unsigned long lock_flags = 0;
+   int rc = SUCCESS;
 
ENTER;
-   ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata;
+   ioa_cfg = (struct ipr_ioa_cfg *) cmd->device->host->hostdata;
+   spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
 
if (!ioa_cfg->in_reset_reload) {
+   ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_ABBREV);
dev_err(&ioa_cfg->pdev->dev,
"Adapter being reset as a result of error recovery.\n");
 
@@ -4820,20 +4786,19 @@ static int __ipr_eh_host_reset(struct sc
ioa_cfg->sdt_state = GET_DUMP;
}
 
-   rc = ipr_reset_reload(ioa_cfg, IPR_SHUTDOWN_ABBREV);
-
-   LEAVE;
-   return rc;
-}
-
-static int ipr_eh_host_reset(struct scsi_cmnd *cmd)
-{
-   int rc;
+   spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
+   wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
+   spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
 
-   spin_lock_irq(cmd->device->host->host_lock);
-   rc = __ipr_eh_host_reset(cmd);
-   spin_unlock_irq(cmd->device->host->host_lock);
+   /* If we got hit with a host reset while we were already resetting
+the adapter for some reason, and the reset failed. */
+   if (ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead) {
+   ipr_trace;
+   rc = FAILED;
+   }
 
+   spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
+   LEAVE;
return rc;
 }
 

-- 
--
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 3/8] ipr: Resource path error logging cleanup

2013-01-17 Thread wenxiong
From: Brian King 

The resource path as displayed by the ipr driver is the
location string identifying a location on the SAS fabric.
This patch adds the SCSI host number such that error logs
can be more easily correlated in multiple adapter configurations.

Signed-off-by: Brian King 
Signed-off-by: Wen Xiong 
---

 drivers/scsi/ipr.c |   78 -
 drivers/scsi/ipr.h |5 ++-
 2 files changed, 56 insertions(+), 27 deletions(-)

Index: b/drivers/scsi/ipr.h
===
--- a/drivers/scsi/ipr.h2013-01-11 13:30:56.053727535 -0600
+++ b/drivers/scsi/ipr.h2013-01-11 13:31:35.095911184 -0600
@@ -409,7 +409,7 @@ struct ipr_config_table_entry64 {
__be64 dev_id;
__be64 lun;
__be64 lun_wwn[2];
-#define IPR_MAX_RES_PATH_LENGTH24
+#define IPR_MAX_RES_PATH_LENGTH48
__be64 res_path;
struct ipr_std_inq_data std_inq_data;
u8 reserved2[4];
@@ -1722,7 +1722,8 @@ struct ipr_ucode_image_header {
if (ipr_is_device(hostrcb)) {   \
if ((hostrcb)->ioa_cfg->sis64) {\
printk(KERN_ERR IPR_NAME ": %s: " fmt,  \
-   
ipr_format_res_path(hostrcb->hcam.u.error64.fd_res_path, \
+   ipr_format_res_path(hostrcb->ioa_cfg,   \
+   hostrcb->hcam.u.error64.fd_res_path, \
hostrcb->rp_buffer, \
sizeof(hostrcb->rp_buffer)),\
__VA_ARGS__);   \
Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 13:31:21.703731278 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 13:31:35.105915246 -0600
@@ -1166,14 +1166,15 @@ static int ipr_is_same_device(struct ipr
 }
 
 /**
- * ipr_format_res_path - Format the resource path for printing.
+ * __ipr_format_res_path - Format the resource path for printing.
  * @res_path:  resource path
  * @buf:   buffer
+ * @len:   length of buffer provided
  *
  * Return value:
  * pointer to buffer
  **/
-static char *ipr_format_res_path(u8 *res_path, char *buffer, int len)
+static char *__ipr_format_res_path(u8 *res_path, char *buffer, int len)
 {
int i;
char *p = buffer;
@@ -1187,6 +1188,27 @@ static char *ipr_format_res_path(u8 *res
 }
 
 /**
+ * ipr_format_res_path - Format the resource path for printing.
+ * @ioa_cfg:   ioa config struct
+ * @res_path:  resource path
+ * @buf:   buffer
+ * @len:   length of buffer provided
+ *
+ * Return value:
+ * pointer to buffer
+ **/
+static char *ipr_format_res_path(struct ipr_ioa_cfg *ioa_cfg,
+u8 *res_path, char *buffer, int len)
+{
+   char *p = buffer;
+
+   *p = '\0';
+   p += snprintf(p, buffer + len - p, "%d/", ioa_cfg->host->host_no);
+   __ipr_format_res_path(res_path, p, len - (buffer - p));
+   return buffer;
+}
+
+/**
  * ipr_update_res_entry - Update the resource entry.
  * @res:   resource entry struct
  * @cfgtew:config table entry wrapper struct
@@ -1226,8 +1248,8 @@ static void ipr_update_res_entry(struct 
 
if (res->sdev && new_path)
sdev_printk(KERN_INFO, res->sdev, "Resource path: %s\n",
-   ipr_format_res_path(res->res_path, buffer,
-   sizeof(buffer)));
+   ipr_format_res_path(res->ioa_cfg,
+   res->res_path, buffer, sizeof(buffer)));
} else {
res->flags = cfgtew->u.cfgte->flags;
if (res->flags & IPR_IS_IOA_RESOURCE)
@@ -1613,8 +1635,8 @@ static void ipr_log_sis64_config_error(s
ipr_err_separator;
 
ipr_err("Device %d : %s", i + 1,
-ipr_format_res_path(dev_entry->res_path, buffer,
-sizeof(buffer)));
+   __ipr_format_res_path(dev_entry->res_path,
+ buffer, sizeof(buffer)));
ipr_log_ext_vpd(&dev_entry->vpd);
 
ipr_err("-New Device Information-\n");
@@ -1960,14 +1982,16 @@ static void ipr_log64_fabric_path(struct
 
ipr_hcam_err(hostrcb, "%s %s: Resource Path=%s\n",
 path_active_desc[i].desc, 
path_state_desc[j].desc,
-ipr_format_res_path(fabric->res_path, 
buffer,
-sizeof(buffer)));
+ipr_format_res_path(hostrcb->ioa_cfg,
+   

[PATCH V2 2/8] ipr: Handler ID memory allocation failure

2013-01-17 Thread wenxiong
From: Brian King 

Add code to handle memory allocation failures at module load time.

Reported-by: Fengguang Wu 

Signed-off-by: Brian King 
Signed-off-by: Wen Xiong 
---

 drivers/scsi/ipr.c |7 +++
 1 file changed, 7 insertions(+)

Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 13:30:56.053727535 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 13:31:21.703731278 -0600
@@ -8516,6 +8516,10 @@ static int ipr_alloc_mem(struct ipr_ioa_
 
BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL);
ioa_cfg->vset_ids = kzalloc(sizeof(unsigned long) *

BITS_TO_LONGS(ioa_cfg->max_devs_supported), GFP_KERNEL);
+
+   if (!ioa_cfg->target_ids || !ioa_cfg->array_ids
+   || !ioa_cfg->vset_ids)
+   goto out_free_res_entries;
}
 
for (i = 0; i < ioa_cfg->max_devs_supported; i++) {
@@ -8591,6 +8595,9 @@ out_free_vpd_cbs:
ioa_cfg->vpd_cbs, ioa_cfg->vpd_cbs_dma);
 out_free_res_entries:
kfree(ioa_cfg->res_entries);
+   kfree(ioa_cfg->target_ids);
+   kfree(ioa_cfg->array_ids);
+   kfree(ioa_cfg->vset_ids);
goto out;
 }
 

-- 
--
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 1/8] ipr: Add sereral new CCIN definitions for new adapters support

2013-01-17 Thread wenxiong
Add the appropriate definitions and table entries for new adapter support.

Signed-off-by: Wen Xiong 
---
 drivers/scsi/ipr.c |   10 ++
 drivers/scsi/ipr.h |5 +
 2 files changed, 15 insertions(+)

Index: b/drivers/scsi/ipr.c
===
--- a/drivers/scsi/ipr.c2013-01-11 13:29:48.162478273 -0600
+++ b/drivers/scsi/ipr.c2013-01-11 13:30:56.053727535 -0600
@@ -9277,6 +9277,8 @@ static struct pci_device_id ipr_pci_tabl
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2,
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B2, 0, 0, 0 },
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57C0, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2,
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57C3, 0, 0, 0 },
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROC_FPGA_E2,
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57C4, 0, 0, 0 },
@@ -9290,6 +9292,14 @@ static struct pci_device_id ipr_pci_tabl
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57C8, 0, 0, 0 },
{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE,
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57CE, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57D5, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57D6, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57D7, 0, 0, 0 },
+   { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CROCODILE,
+   PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57D8, 0, 0, 0 },
{ }
 };
 MODULE_DEVICE_TABLE(pci, ipr_pci_table);
Index: b/drivers/scsi/ipr.h
===
--- a/drivers/scsi/ipr.h2013-01-11 13:29:53.292478040 -0600
+++ b/drivers/scsi/ipr.h2013-01-11 13:30:56.053727535 -0600
@@ -82,6 +82,7 @@
 
 #define IPR_SUBS_DEV_ID_57B40x033B
 #define IPR_SUBS_DEV_ID_57B20x035F
+#define IPR_SUBS_DEV_ID_57C00x0352
 #define IPR_SUBS_DEV_ID_57C30x0353
 #define IPR_SUBS_DEV_ID_57C40x0354
 #define IPR_SUBS_DEV_ID_57C60x0357
@@ -94,6 +95,10 @@
 #define IPR_SUBS_DEV_ID_574D0x0356
 #define IPR_SUBS_DEV_ID_57C80x035D
 
+#define IPR_SUBS_DEV_ID_57D50x03FB
+#define IPR_SUBS_DEV_ID_57D60x03FC
+#define IPR_SUBS_DEV_ID_57D70x03FF
+#define IPR_SUBS_DEV_ID_57D80x03FE
 #define IPR_NAME   "ipr"
 
 /*

-- 
--
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 3/4] block: implement runtime pm strategy

2013-01-17 Thread Alan Stern
On Thu, 17 Jan 2013, Aaron Lu wrote:

> > > @@ -515,6 +516,27 @@ void elv_bio_merged(struct request_queue *q, struct 
> > > request *rq,
> > >   e->type->ops.elevator_bio_merged_fn(q, rq, bio);
> > >  }
> > >  
> > > +#ifdef CONFIG_PM_RUNTIME
> > > +static void blk_pm_requeue_request(struct request *rq)
> > > +{
> > > + if (!(rq->cmd_flags & REQ_PM))
> > > + rq->q->nr_pending--;
> > > +}
> > 
> > You don't check q->dev here.  That's okay, but it means that
> > q->nr_pending will be meaningless or wrong if any I/O takes place
> > before blk_pm_runtime_init is called.
> 
> Right, so I had better check q->dev here too.
> 
> > 
> > Therefore the kerneldoc for blk_pm_runtime_init should mention that it
> > must not be called after any requests have been submitted.  Also
> 
> So with the q->dev check added above, I believe this is not needed.

No, it is still needed.  With the q->dev check added, q->nr_pending 
will always be 0 before blk_pm_runtime_init is called.  But if I/O is 
taking place then the number of pending requests really isn't 0.

Either you have to make sure the q->nr_pending is always correct, even 
when runtime PM isn't being used, or else the caller has to make sure 
that no I/O takes place before blk_pm_runtime_init is called.

> 
> > mention that blk_pm_runtime_init enables runtime PM for q->dev, so the
> > caller shouldn't do it.
> 
> I may misunderstandd this in last email.
> 
> We didn't enable runtime PM for the device in blk_pm_runtime_init, just
> some auto suspend related settings.

Sorry, yes, you are right.  In fact, the caller has to make sure that 
runtime PM is enabled before calling blk_pm_runtime_init; otherwise the 
autosuspend timer might not work right.

Alan Stern

--
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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread Subhash Jadavani

On 1/17/2013 4:17 PM, Russell King - ARM Linux wrote:

On Thu, Jan 17, 2013 at 10:37:42AM +, Russell King - ARM Linux wrote:

On Thu, Jan 17, 2013 at 09:11:20AM +, James Bottomley wrote:

I'd actually prefer page = pfn_to_page(page_to_pfn(page) + 1); because
it makes the code look like the hack it is.  The preferred form for all
iterators like this should be to iterate over the pfn instead of a
pointer into the page arrays, because that will always work correctly no
matter how many weird and wonderful memory schemes we come up with.

So, why don't we update the code to do that then?

Also, couldn't the addition of the scatterlist offset to the page also
be buggy too?

So, what about this patch which addresses both additions by keeping our
iterator as a pfn as you suggest.  It also simplifies some of the code
in the loop too.

Can the original folk with the problem test this patch?


Yes, this patch also fixes the issue.  You may add: Tested-by: Subhash 
Jadavani  .


Regards,
Subhash



  arch/arm/mm/dma-mapping.c |   18 ++
  1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 6b2fb87..076c26d 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -774,25 +774,27 @@ static void dma_cache_maint_page(struct page *page, 
unsigned long offset,
size_t size, enum dma_data_direction dir,
void (*op)(const void *, size_t, int))
  {
+   unsigned long pfn;
+   size_t left = size;
+
+   pfn = page_to_pfn(page) + offset / PAGE_SIZE;
+   offset %= PAGE_SIZE;
+
/*
 * A single sg entry may refer to multiple physically contiguous
 * pages.  But we still need to process highmem pages individually.
 * If highmem is not configured then the bulk of this loop gets
 * optimized out.
 */
-   size_t left = size;
do {
size_t len = left;
void *vaddr;
  
+		page = pfn_to_page(pfn);

+
if (PageHighMem(page)) {
-   if (len + offset > PAGE_SIZE) {
-   if (offset >= PAGE_SIZE) {
-   page += offset / PAGE_SIZE;
-   offset %= PAGE_SIZE;
-   }
+   if (len + offset > PAGE_SIZE)
len = PAGE_SIZE - offset;
-   }
vaddr = kmap_high_get(page);
if (vaddr) {
vaddr += offset;
@@ -809,7 +811,7 @@ static void dma_cache_maint_page(struct page *page, 
unsigned long offset,
op(vaddr, len, dir);
}
offset = 0;
-   page++;
+   pfn++;
left -= len;
} while (left);
  }

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


--
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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread Russell King - ARM Linux
On Thu, Jan 17, 2013 at 11:19:21AM +, James Bottomley wrote:
> On Thu, 2013-01-17 at 11:04 +, Russell King - ARM Linux wrote:
> > On Thu, Jan 17, 2013 at 11:01:47AM +, James Bottomley wrote:
> > > On Thu, 2013-01-17 at 10:47 +, Russell King - ARM Linux wrote:
> > > > Also, couldn't the addition of the scatterlist offset to the page also
> > > > be buggy too?
> > > 
> > > No, fortunately, offset must be within the first page from the point of
> > > view of block generated sg lists.  As long as nothing within arm
> > > violates this, it should be a safe assumption ... although the code
> > > seems to assume otherwise.
> > 
> > Are you absolutely sure about that?  I believe I have seen cases where
> > that has been violated in the past, though it was many years ago.
> 
> >From the point of view of the block layer, absolutely: the scatterlist
> is generated from an array of bio_vecs.  Each bio_vec is a page, offset
> and length element and obeys the rule that offset must be within the
> page and offset + length cannot stray over the page.

Well, I found it when working on the mmc stuff initially, long before
it got complex.  The scatterlists were unmodified from the block layer,
and I'm positive I saw occasions where the offset in the scatter lists
were larger than PAGE_SIZE.

> >From the point of view of other arm stuff, I don't know.

I'm not talking about anything ARM specific here.
--
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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread James Bottomley
On Thu, 2013-01-17 at 11:04 +, Russell King - ARM Linux wrote:
> On Thu, Jan 17, 2013 at 11:01:47AM +, James Bottomley wrote:
> > On Thu, 2013-01-17 at 10:47 +, Russell King - ARM Linux wrote:
> > > Also, couldn't the addition of the scatterlist offset to the page also
> > > be buggy too?
> > 
> > No, fortunately, offset must be within the first page from the point of
> > view of block generated sg lists.  As long as nothing within arm
> > violates this, it should be a safe assumption ... although the code
> > seems to assume otherwise.
> 
> Are you absolutely sure about that?  I believe I have seen cases where
> that has been violated in the past, though it was many years ago.

>From the point of view of the block layer, absolutely: the scatterlist
is generated from an array of bio_vecs.  Each bio_vec is a page, offset
and length element and obeys the rule that offset must be within the
page and offset + length cannot stray over the page.

>From the point of view of other arm stuff, I don't know.

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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread Russell King - ARM Linux
On Thu, Jan 17, 2013 at 11:01:47AM +, James Bottomley wrote:
> On Thu, 2013-01-17 at 10:47 +, Russell King - ARM Linux wrote:
> > Also, couldn't the addition of the scatterlist offset to the page also
> > be buggy too?
> 
> No, fortunately, offset must be within the first page from the point of
> view of block generated sg lists.  As long as nothing within arm
> violates this, it should be a safe assumption ... although the code
> seems to assume otherwise.

Are you absolutely sure about that?  I believe I have seen cases where
that has been violated in the past, though it was many years ago.
--
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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread James Bottomley
On Thu, 2013-01-17 at 10:47 +, Russell King - ARM Linux wrote:
> On Thu, Jan 17, 2013 at 10:37:42AM +, Russell King - ARM Linux wrote:
> > On Thu, Jan 17, 2013 at 09:11:20AM +, James Bottomley wrote:
> > > I'd actually prefer page = pfn_to_page(page_to_pfn(page) + 1); because
> > > it makes the code look like the hack it is.  The preferred form for all
> > > iterators like this should be to iterate over the pfn instead of a
> > > pointer into the page arrays, because that will always work correctly no
> > > matter how many weird and wonderful memory schemes we come up with.
> > 
> > So, why don't we update the code to do that then?

We can, but it involves quite a rewrite within the arm dma-mapping code
to use pfn instead of page.  It looks like it would make the code
cleaner because there are a lot of page_to_pfn transformations in there.
However, the current patch is the simplest one for stable and I don't
actually have any arm build and test environments.

> Also, couldn't the addition of the scatterlist offset to the page also
> be buggy too?

No, fortunately, offset must be within the first page from the point of
view of block generated sg lists.  As long as nothing within arm
violates this, it should be a safe assumption ... although the code
seems to assume otherwise.

James

> So, what about this patch which addresses both additions by keeping our
> iterator as a pfn as you suggest.  It also simplifies some of the code
> in the loop too.
> 
> Can the original folk with the problem test this patch?
> 
>  arch/arm/mm/dma-mapping.c |   18 ++
>  1 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 6b2fb87..076c26d 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -774,25 +774,27 @@ static void dma_cache_maint_page(struct page *page, 
> unsigned long offset,
>   size_t size, enum dma_data_direction dir,
>   void (*op)(const void *, size_t, int))
>  {
> + unsigned long pfn;
> + size_t left = size;
> +
> + pfn = page_to_pfn(page) + offset / PAGE_SIZE;
> + offset %= PAGE_SIZE;
> +
>   /*
>* A single sg entry may refer to multiple physically contiguous
>* pages.  But we still need to process highmem pages individually.
>* If highmem is not configured then the bulk of this loop gets
>* optimized out.
>*/
> - size_t left = size;
>   do {
>   size_t len = left;
>   void *vaddr;
>  
> + page = pfn_to_page(pfn);
> +
>   if (PageHighMem(page)) {
> - if (len + offset > PAGE_SIZE) {
> - if (offset >= PAGE_SIZE) {
> - page += offset / PAGE_SIZE;
> - offset %= PAGE_SIZE;
> - }
> + if (len + offset > PAGE_SIZE)
>   len = PAGE_SIZE - offset;
> - }
>   vaddr = kmap_high_get(page);
>   if (vaddr) {
>   vaddr += offset;
> @@ -809,7 +811,7 @@ static void dma_cache_maint_page(struct page *page, 
> unsigned long offset,
>   op(vaddr, len, dir);
>   }
>   offset = 0;
> - page++;
> + pfn++;
>   left -= len;
>   } while (left);
>  }

Looks reasonable modulo all the simplification we could do if we can
assume offset < PAGE_SIZE

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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread Russell King - ARM Linux
On Thu, Jan 17, 2013 at 10:37:42AM +, Russell King - ARM Linux wrote:
> On Thu, Jan 17, 2013 at 09:11:20AM +, James Bottomley wrote:
> > I'd actually prefer page = pfn_to_page(page_to_pfn(page) + 1); because
> > it makes the code look like the hack it is.  The preferred form for all
> > iterators like this should be to iterate over the pfn instead of a
> > pointer into the page arrays, because that will always work correctly no
> > matter how many weird and wonderful memory schemes we come up with.
> 
> So, why don't we update the code to do that then?

Also, couldn't the addition of the scatterlist offset to the page also
be buggy too?

So, what about this patch which addresses both additions by keeping our
iterator as a pfn as you suggest.  It also simplifies some of the code
in the loop too.

Can the original folk with the problem test this patch?

 arch/arm/mm/dma-mapping.c |   18 ++
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 6b2fb87..076c26d 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -774,25 +774,27 @@ static void dma_cache_maint_page(struct page *page, 
unsigned long offset,
size_t size, enum dma_data_direction dir,
void (*op)(const void *, size_t, int))
 {
+   unsigned long pfn;
+   size_t left = size;
+
+   pfn = page_to_pfn(page) + offset / PAGE_SIZE;
+   offset %= PAGE_SIZE;
+
/*
 * A single sg entry may refer to multiple physically contiguous
 * pages.  But we still need to process highmem pages individually.
 * If highmem is not configured then the bulk of this loop gets
 * optimized out.
 */
-   size_t left = size;
do {
size_t len = left;
void *vaddr;
 
+   page = pfn_to_page(pfn);
+
if (PageHighMem(page)) {
-   if (len + offset > PAGE_SIZE) {
-   if (offset >= PAGE_SIZE) {
-   page += offset / PAGE_SIZE;
-   offset %= PAGE_SIZE;
-   }
+   if (len + offset > PAGE_SIZE)
len = PAGE_SIZE - offset;
-   }
vaddr = kmap_high_get(page);
if (vaddr) {
vaddr += offset;
@@ -809,7 +811,7 @@ static void dma_cache_maint_page(struct page *page, 
unsigned long offset,
op(vaddr, len, dir);
}
offset = 0;
-   page++;
+   pfn++;
left -= len;
} while (left);
 }

--
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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread Russell King - ARM Linux
On Thu, Jan 17, 2013 at 09:11:20AM +, James Bottomley wrote:
> On Wed, 2013-01-16 at 15:18 -0800, Tejun Heo wrote:
> > On Wed, Jan 16, 2013 at 10:32:35AM +, James Bottomley wrote:
> > > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> > > index 6b2fb87..ab88c5b 100644
> > > --- a/arch/arm/mm/dma-mapping.c
> > > +++ b/arch/arm/mm/dma-mapping.c
> > > @@ -809,7 +809,7 @@ static void dma_cache_maint_page(struct page *page, 
> > > unsigned long offset,
> > >   op(vaddr, len, dir);
> > >   }
> > >   offset = 0;
> > > - page++;
> > > + page = pfn_to_page(page_to_pfn(page) + 1);
> > 
> > Probably page = nth_page(page, 1) is the better form.
> 
> It's the same thing.
> 
> I'd actually prefer page = pfn_to_page(page_to_pfn(page) + 1); because
> it makes the code look like the hack it is.  The preferred form for all
> iterators like this should be to iterate over the pfn instead of a
> pointer into the page arrays, because that will always work correctly no
> matter how many weird and wonderful memory schemes we come up with.

So, why don't we update the code to do that then?
--
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


[Bug 51881] HighPoint RocketRAID 2720 fail to detect some SATA hdd

2013-01-17 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=51881





--- Comment #9 from Shane Huang   2013-01-17 09:36:23 ---
The patch in comment #4 was accepted by Jeff in his repository. Thanks.

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
--
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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread James Bottomley
On Wed, 2013-01-16 at 15:18 -0800, Tejun Heo wrote:
> On Wed, Jan 16, 2013 at 10:32:35AM +, James Bottomley wrote:
> > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> > index 6b2fb87..ab88c5b 100644
> > --- a/arch/arm/mm/dma-mapping.c
> > +++ b/arch/arm/mm/dma-mapping.c
> > @@ -809,7 +809,7 @@ static void dma_cache_maint_page(struct page *page, 
> > unsigned long offset,
> > op(vaddr, len, dir);
> > }
> > offset = 0;
> > -   page++;
> > +   page = pfn_to_page(page_to_pfn(page) + 1);
> 
> Probably page = nth_page(page, 1) is the better form.

It's the same thing.

I'd actually prefer page = pfn_to_page(page_to_pfn(page) + 1); because
it makes the code look like the hack it is.  The preferred form for all
iterators like this should be to iterate over the pfn instead of a
pointer into the page arrays, because that will always work correctly no
matter how many weird and wonderful memory schemes we come up with.

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 v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors

2013-01-17 Thread James Bottomley
On Wed, 2013-01-16 at 23:14 +, Russell King - ARM Linux wrote:
> On Wed, Jan 16, 2013 at 10:32:35AM +, James Bottomley wrote:
> > On Wed, 2013-01-16 at 12:07 +0530, Subhash Jadavani wrote:
> > 
> > > Now consider this call stack from MMC block driver (this is on the ARmv7 
> > > based board):
> > >  [   98.918174] [] (v7_dma_inv_range+0x30/0x48) from 
> > > [] (dma_cache_maint_page+0x1c4/0x24c)
> > >  [   98.927819] [] (dma_cache_maint_page+0x1c4/0x24c) from 
> > > [] (___dma_page_cpu_to_dev+0x14/0x1c)
> > >  [   98.937982] [] (___dma_page_cpu_to_dev+0x14/0x1c) from 
> > > [] (dma_map_sg+0x3c/0x114)
> > 
> > OK, so this is showing that ARM itself is making the assumption that the
> > pages are contiguous in the page offset map.
> > 
> > Fix this by doing the increment via the pfn, which will do the right
> > thing whatever the memory model.
> > 
> > Signed-off-by: James Bottomley 
> 
> Ok.  What would you like the patch summary line for this to be -
> the existing one seems to be a little wrong given the content of
> this patch...

how about

arm: fix struct page iterator in dma_cache_maint() to work with
sparsemem

?

James

> > 
> > ---
> > 
> > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> > index 6b2fb87..ab88c5b 100644
> > --- a/arch/arm/mm/dma-mapping.c
> > +++ b/arch/arm/mm/dma-mapping.c
> > @@ -809,7 +809,7 @@ static void dma_cache_maint_page(struct page *page, 
> > unsigned long offset,
> > op(vaddr, len, dir);
> > }
> > offset = 0;
> > -   page++;
> > +   page = pfn_to_page(page_to_pfn(page) + 1);
> > left -= len;
> > } while (left);
> >  }
> > 
> > 
> > 
> > ___
> > linux-arm-kernel mailing list
> > linux-arm-ker...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> --
> 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


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