Re: [PATCH 1/2] mpt2sas: Refcount sas_device objects and fix unsafe list usage
On Thursday 07/16 at 20:27 +0530, Sreekanth Reddy wrote: > On Sun, Jul 12, 2015 at 9:54 AM, Calvin Owens wrote: > > These objects can be referenced concurrently throughout the driver, we > > need a way to make sure threads can't delete them out from under each > > other. This patch adds the refcount, and refactors the code to use it. > > > > Additionally, we cannot iterate over the sas_device_list without > > holding the lock, or we risk corrupting random memory if items are > > added or deleted as we iterate. This patch refactors _scsih_probe_sas() > > to use the sas_device_list in a safe way. > > > > Cc: Christoph Hellwig > > Cc: Bart Van Assche > > Signed-off-by: Calvin Owens > > --- > > drivers/scsi/mpt2sas/mpt2sas_base.h | 22 +- > > drivers/scsi/mpt2sas/mpt2sas_scsih.c | 434 > > --- > > drivers/scsi/mpt2sas/mpt2sas_transport.c | 12 +- > > 3 files changed, 315 insertions(+), 153 deletions(-) > > > > diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h > > b/drivers/scsi/mpt2sas/mpt2sas_base.h > > index caff8d1..78f41ac 100644 > > --- a/drivers/scsi/mpt2sas/mpt2sas_base.h > > +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h > > @@ -238,6 +238,7 @@ > > * @flags: MPT_TARGET_FLAGS_XXX flags > > * @deleted: target flaged for deletion > > * @tm_busy: target is busy with TM request. > > + * @sdev: The sas_device associated with this target > > */ > > struct MPT2SAS_TARGET { > > struct scsi_target *starget; > > @@ -248,6 +249,7 @@ struct MPT2SAS_TARGET { > > u32 flags; > > u8 deleted; > > u8 tm_busy; > > + struct _sas_device *sdev; > > }; > > > > > > @@ -376,8 +378,24 @@ struct _sas_device { > > u8 phy; > > u8 responding; > > u8 pfa_led_on; > > + struct kref refcount; > > }; > > > > +static inline void sas_device_get(struct _sas_device *s) > > +{ > > + kref_get(&s->refcount); > > +} > > + > > +static inline void sas_device_free(struct kref *r) > > +{ > > + kfree(container_of(r, struct _sas_device, refcount)); > > +} > > + > > +static inline void sas_device_put(struct _sas_device *s) > > +{ > > + kref_put(&s->refcount, sas_device_free); > > +} > > + > > /** > > * struct _raid_device - raid volume link list > > * @list: sas device list > > @@ -1095,7 +1113,9 @@ struct _sas_node > > *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER * > > u16 handle); > > struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct > > MPT2SAS_ADAPTER > > *ioc, u64 sas_address); > > -struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address( > > +struct _sas_device *mpt2sas_get_sdev_by_addr( > > +struct MPT2SAS_ADAPTER *ioc, u64 sas_address); > > +struct _sas_device *__mpt2sas_get_sdev_by_addr( > > struct MPT2SAS_ADAPTER *ioc, u64 sas_address); > > > > void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc); > > diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > b/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > index 3f26147..fad80ce 100644 > > --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > @@ -526,8 +526,43 @@ _scsih_determine_boot_device(struct MPT2SAS_ADAPTER > > *ioc, > > } > > } > > > > +struct _sas_device * > > +__mpt2sas_get_sdev_from_target(struct MPT2SAS_TARGET *tgt_priv) > > +{ > > + struct _sas_device *ret; > > + > > + ret = tgt_priv->sdev; > > + if (ret) > > + sas_device_get(ret); > > + > > + return ret; > > +} > > + > > +struct _sas_device * > > +__mpt2sas_get_sdev_by_addr(struct MPT2SAS_ADAPTER *ioc, > > +u64 sas_address) > > +{ > > + struct _sas_device *sas_device; > > + > > + assert_spin_locked(&ioc->sas_device_lock); > > + > > + list_for_each_entry(sas_device, &ioc->sas_device_list, list) > > + if (sas_device->sas_address == sas_address) > > + goto found_device; > > + > > + list_for_each_entry(sas_device, &ioc->sas_device_init_list, list) > > + if (sas_device->sas_address == sas_address) > > + goto found_device; > > + > > + return NULL; > > + > > +found_device: > > + sas_device_get(sas_device); > > + return sas_device; > > +} > > + > > /** > > - * mpt2sas_scsih_sas_device_find_by_sas_address - sas device search > > + * mpt2sas_get_sdev_by_addr - sas device search > > * @ioc: per adapter object > > * @sas_address: sas address > > * Context: Calling function should acquire ioc->sas_device_lock > > @@ -536,24 +571,44 @@ _scsih_determine_boot_device(struct MPT2SAS_ADAPTER > > *ioc, > > * object. > > */ > > struct _sas_device * > > -mpt2sas_scsih_sas_device_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc, > > +mpt2sas_get_sdev_by_addr(struct MPT2SAS_ADAPTER *ioc, > > u64 sas_address) > > { > > struct _sas_device *sas_device; > > + unsigned long flags; > > + >
Re: [PATCH 1/2] mpt2sas: Refcount sas_device objects and fix unsafe list usage
On Monday 07/13 at 11:05 -0400, Joe Lawrence wrote: > On 07/12/2015 12:24 AM, Calvin Owens wrote: > > These objects can be referenced concurrently throughout the driver, we > > need a way to make sure threads can't delete them out from under each > > other. This patch adds the refcount, and refactors the code to use it. > > > > Additionally, we cannot iterate over the sas_device_list without > > holding the lock, or we risk corrupting random memory if items are > > added or deleted as we iterate. This patch refactors _scsih_probe_sas() > > to use the sas_device_list in a safe way. > > > > Cc: Christoph Hellwig > > Cc: Bart Van Assche > > Signed-off-by: Calvin Owens > > --- > > drivers/scsi/mpt2sas/mpt2sas_base.h | 22 +- > > drivers/scsi/mpt2sas/mpt2sas_scsih.c | 434 > > --- > > drivers/scsi/mpt2sas/mpt2sas_transport.c | 12 +- > > 3 files changed, 315 insertions(+), 153 deletions(-) > > [ ... snip ... ] > > > @@ -2078,7 +2150,7 @@ _scsih_slave_configure(struct scsi_device *sdev) > > } > > > > spin_lock_irqsave(&ioc->sas_device_lock, flags); > > - sas_device = mpt2sas_scsih_sas_device_find_by_sas_address(ioc, > > + sas_device = __mpt2sas_get_sdev_by_addr(ioc, > >sas_device_priv_data->sas_target->sas_address); > > if (!sas_device) { > > spin_unlock_irqrestore(&ioc->sas_device_lock, flags); > > @@ -2116,13 +2188,14 @@ _scsih_slave_configure(struct scsi_device *sdev) > > if (!ssp_target) > > _scsih_display_sata_capabilities(ioc, handle, sdev); > > > > - > > _scsih_change_queue_depth(sdev, qdepth); > > > > if (ssp_target) { > > sas_read_port_mode_page(sdev); > > _scsih_enable_tlr(ioc, sdev); > > } > > + > > + sas_device_put(sas_device); > > return 0; > > } > > Hi Calvin, > > Any reason why this sas_device_put is placed outside the sas_device > lock? Most other instances in this patch were called just before unlocking. Thanks for looking at this. I guess I thought that something below where we drop the sas_device_lock referenced it, but it looks like nothing does. I'll move it up in v3. I don't think it's strictly necessary that the put() happen under the lock: the only way this could be the final put() is if both ->hostdata and the sas_device_list had dropped their references, and in that case it would be impossible to have a concurrent get(), since those are the only two ways to lookup/get a sas_device. But absent any reason not to, let's make it more consistent. I'm really glad you pointed this out, because I realized I flubbed this in _scsih_target_alloc() and forgot to eliminate the sas_device_put() from before the ->hostdata lookup was added. I'll fix this in v3. > BTW I attempted testing, but needed to port to mpt3 and ended up with a > driver that didn't boot :( Hopefully I can retry later this week, or > find an older mpt2 box lying around. More testing would be fantastic if that's possible :) Thanks very much, Calvin > -- Joe -- 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 1/2] mpt2sas: Refcount sas_device objects and fix unsafe list usage
On Sunday 07/12 at 23:52 -0700, Christoph Hellwig wrote: > On Sat, Jul 11, 2015 at 09:24:55PM -0700, Calvin Owens wrote: > > These objects can be referenced concurrently throughout the driver, we > > need a way to make sure threads can't delete them out from under each > > other. This patch adds the refcount, and refactors the code to use it. > > > > Additionally, we cannot iterate over the sas_device_list without > > holding the lock, or we risk corrupting random memory if items are > > added or deleted as we iterate. This patch refactors _scsih_probe_sas() > > to use the sas_device_list in a safe way. > > > > Cc: Christoph Hellwig > > Cc: Bart Van Assche > > Signed-off-by: Calvin Owens > > --- > > drivers/scsi/mpt2sas/mpt2sas_base.h | 22 +- > > drivers/scsi/mpt2sas/mpt2sas_scsih.c | 434 > > --- > > drivers/scsi/mpt2sas/mpt2sas_transport.c | 12 +- > > 3 files changed, 315 insertions(+), 153 deletions(-) > > > > diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h > > b/drivers/scsi/mpt2sas/mpt2sas_base.h > > index caff8d1..78f41ac 100644 > > --- a/drivers/scsi/mpt2sas/mpt2sas_base.h > > +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h > > @@ -238,6 +238,7 @@ > > * @flags: MPT_TARGET_FLAGS_XXX flags > > * @deleted: target flaged for deletion > > * @tm_busy: target is busy with TM request. > > + * @sdev: The sas_device associated with this target > > */ > > struct MPT2SAS_TARGET { > > struct scsi_target *starget; > > @@ -248,6 +249,7 @@ struct MPT2SAS_TARGET { > > u32 flags; > > u8 deleted; > > u8 tm_busy; > > + struct _sas_device *sdev; > > }; > > > > > > @@ -376,8 +378,24 @@ struct _sas_device { > > u8 phy; > > u8 responding; > > u8 pfa_led_on; > > + struct kref refcount; > > }; > > > > +static inline void sas_device_get(struct _sas_device *s) > > +{ > > + kref_get(&s->refcount); > > +} > > + > > +static inline void sas_device_free(struct kref *r) > > +{ > > + kfree(container_of(r, struct _sas_device, refcount)); > > +} > > + > > +static inline void sas_device_put(struct _sas_device *s) > > +{ > > + kref_put(&s->refcount, sas_device_free); > > +} > > + > > /** > > * struct _raid_device - raid volume link list > > * @list: sas device list > > @@ -1095,7 +1113,9 @@ struct _sas_node > > *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER * > > u16 handle); > > struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct > > MPT2SAS_ADAPTER > > *ioc, u64 sas_address); > > -struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address( > > +struct _sas_device *mpt2sas_get_sdev_by_addr( > > +struct MPT2SAS_ADAPTER *ioc, u64 sas_address); > > +struct _sas_device *__mpt2sas_get_sdev_by_addr( > > struct MPT2SAS_ADAPTER *ioc, u64 sas_address); > > > > void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc); > > diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > b/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > index 3f26147..fad80ce 100644 > > --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c > > @@ -526,8 +526,43 @@ _scsih_determine_boot_device(struct MPT2SAS_ADAPTER > > *ioc, > > } > > } > > > > +struct _sas_device * > > +__mpt2sas_get_sdev_from_target(struct MPT2SAS_TARGET *tgt_priv) > > +{ > > + struct _sas_device *ret; > > + > > Does this need a: > > assert_spin_locked(&ioc->sas_device_lock); > > ? Yeah: I'll add that. Thanks very much, Calvin > Otherwise this looks sensible to me. -- 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] target/iscsi: fix digest computation for chained SGs
On 7/21/2015 3:12 AM, Spencer Baugh wrote: From: Alexei Potashnik Current implementation assumes that all the buffers of an IO are linked with a single SG list. Which makes it fail if SG chaining is used. Signed-off-by: Alexei Potashnik --- drivers/target/iscsi/iscsi_target.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 4e68b62..a4cf58c 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1209,7 +1209,6 @@ static u32 iscsit_do_crypto_hash_sg( u8 *pad_bytes) { u32 data_crc; - u32 i; struct scatterlist *sg; unsigned int page_off; @@ -1218,15 +1217,15 @@ static u32 iscsit_do_crypto_hash_sg( sg = cmd->first_data_sg; page_off = cmd->first_data_sg_off; - i = 0; while (data_length) { - u32 cur_len = min_t(u32, data_length, (sg[i].length - page_off)); + u32 cur_len = min_t(u32, data_length, (sg->length - page_off)); - crypto_hash_update(hash, &sg[i], cur_len); + crypto_hash_update(hash, sg, cur_len); data_length -= cur_len; page_off = 0; - i++; + /* iscsit_map_iovec has already checked for invalid sg pointers */ + sg = sg_next(sg); } if (padding) { How were you able to get a chained SG list in the target code? In any event, looks good, Reviewed-by: Sagi Grimberg -- 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 1/2] target: remove unused lun_flags field from se_lun
Looks good, but what's up with your From lines: On Mon, Jul 20, 2015 at 04:29:49PM -0700, Spencer Baugh wrote: > From: Spencer Baugh > > From: Chris Zankel plus another address for you in the actual email From line. Who did actually write this patch? -- 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 2/2] target: remove initiatorname field in se_acl_lun
Looks good too, but same From: issue as the last patch. -- 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: fix memory leak with scsi-mq
Thanks Tony, this looks good to me. In the long run I'll see how we can hide these implementation details in the lib/scatterlist.c code instead of burdening it on the users. Reviewed-by: Christoph Hellwig -- 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 1/2] target: remove unused lun_flags field from se_lun
Christoph Hellwig writes: > Looks good, > > but what's up with your From lines: > > On Mon, Jul 20, 2015 at 04:29:49PM -0700, Spencer Baugh wrote: >> From: Spencer Baugh >> >> From: Chris Zankel > > plus another address for you in the actual email From line. Who > did actually write this patch? Sorry, ignore the first From: line; the correct one is From: Chris Zankel for both patches -- 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 V4 00/10] [SCSI] aacraid: Patchset for aacraid driver version 41010
From: Rajinikanth Pandurangan This patchset includes the following changes (bug fixes and new feature support) specific to aacraid driver. V4: Updated code with pci_enable_msix_range instead of exact. V3: Increased msleep() time from 1 to 20. Created new patch for pci_enable_msix() replacement. Changed subject/description of patch 03. Reviewed by: Tomas Henzl , Mahesh Rajashekhara , Johannes Thumshirn , James Bottomley Rajinikanth Pandurangan (10): [SCSI] aacraid: Fix for logical device name and UID not exposed to the OS [SCSI] aacraid: Add Power Management support [SCSI] aacraid: Change interrupt mode to MSI for series-6 controller [SCSI] aacraid: Enable 64-bit write to controller register [SCSI] aacraid: Tune response path if IsFastPath bit set [SCSI] aacraid: Reset irq affinity hints before releasing irq [SCSI] aacraid: Unblock IOCTLs to controller once system resumed from suspend [SCSI] aacraid: Send commit-config to controller firmware [SCSI] aacraid: Update driver version [SCSI] aacraid: Replace pci_enable_msix() with pci_enable_msix_range() drivers/scsi/aacraid/aachba.c | 263 +--- drivers/scsi/aacraid/aacraid.h | 18 ++- drivers/scsi/aacraid/comminit.c | 147 +++--- drivers/scsi/aacraid/commsup.c | 113 - drivers/scsi/aacraid/linit.c| 159 +++- drivers/scsi/aacraid/rx.c | 1 + drivers/scsi/aacraid/sa.c | 1 + drivers/scsi/aacraid/src.c | 64 +++--- 8 files changed, 483 insertions(+), 283 deletions(-) -- 1.9.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
[PATCH V4 02/10] [SCSI] aacraid: Add Power Management support
From: Rajinikanth Pandurangan Description: * .suspend() and .resume() routines implemented in the driver * aac_release_resources() initiates firmware shutdown * aac_acquire_resources re-initializes the host interface Changes from V2: Increased msleep(1) to msleep(20) Reverted pci_enable_msix_exact() to pci_enable_msix() as this change has moved into a separate patch. Reviewed by: Tomas Henzl , Mahesh Rajashekhara , Johannes Thumshirn , James Bottomley Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/aacraid.h | 5 ++ drivers/scsi/aacraid/comminit.c | 154 drivers/scsi/aacraid/linit.c| 147 ++ drivers/scsi/aacraid/rx.c | 1 + drivers/scsi/aacraid/sa.c | 1 + drivers/scsi/aacraid/src.c | 2 + 6 files changed, 232 insertions(+), 78 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 40fe65c..62b0999 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -547,6 +547,7 @@ struct adapter_ops int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4); int (*adapter_check_health)(struct aac_dev *dev); int (*adapter_restart)(struct aac_dev *dev, int bled); + void (*adapter_start)(struct aac_dev *dev); /* Transport operations */ int (*adapter_ioremap)(struct aac_dev * dev, u32 size); irq_handler_t adapter_intr; @@ -1247,6 +1248,9 @@ struct aac_dev #define aac_adapter_restart(dev,bled) \ (dev)->a_ops.adapter_restart(dev,bled) +#define aac_adapter_start(dev) \ + ((dev)->a_ops.adapter_start(dev)) + #define aac_adapter_ioremap(dev, size) \ (dev)->a_ops.adapter_ioremap(dev, size) @@ -2127,6 +2131,7 @@ int aac_sa_init(struct aac_dev *dev); int aac_src_init(struct aac_dev *dev); int aac_srcv_init(struct aac_dev *dev); int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw_fib, int wait, struct fib * fibptr, unsigned long *nonotify); +void aac_define_int_mode(struct aac_dev *dev); unsigned int aac_response_normal(struct aac_queue * q); unsigned int aac_command_normal(struct aac_queue * q); unsigned int aac_intr_normal(struct aac_dev *dev, u32 Index, diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 45db84a..45a0a04 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -43,8 +43,6 @@ #include "aacraid.h" -static void aac_define_int_mode(struct aac_dev *dev); - struct aac_common aac_config = { .irq_mod = 1 }; @@ -338,6 +336,82 @@ static int aac_comm_init(struct aac_dev * dev) return 0; } +void aac_define_int_mode(struct aac_dev *dev) +{ + int i, msi_count; + + msi_count = i = 0; + /* max. vectors from GET_COMM_PREFERRED_SETTINGS */ + if (dev->max_msix == 0 || + dev->pdev->device == PMC_DEVICE_S6 || + dev->sync_mode) { + dev->max_msix = 1; + dev->vector_cap = + dev->scsi_host_ptr->can_queue + + AAC_NUM_MGT_FIB; + return; + } + + /* Don't bother allocating more MSI-X vectors than cpus */ + msi_count = min(dev->max_msix, + (unsigned int)num_online_cpus()); + + dev->max_msix = msi_count; + + if (msi_count > AAC_MAX_MSIX) + msi_count = AAC_MAX_MSIX; + + for (i = 0; i < msi_count; i++) + dev->msixentry[i].entry = i; + + if (msi_count > 1 && + pci_find_capability(dev->pdev, PCI_CAP_ID_MSIX)) { + i = pci_enable_msix(dev->pdev, + dev->msixentry, + msi_count); +/* Check how many MSIX vectors are allocated */ + if (i >= 0) { + dev->msi_enabled = 1; + if (i) { + msi_count = i; + if (pci_enable_msix(dev->pdev, + dev->msixentry, + msi_count)) { + dev->msi_enabled = 0; + printk(KERN_ERR "%s%d: MSIX not supported!! Will try MSI 0x%x.\n", + dev->name, dev->id, i); + } + } + } else { + dev->msi_enabled = 0; + printk(KERN_ERR "%s%d: MSIX not supported!! Will try MSI 0x%x.\n", + dev->name, dev->id, i); + } + } + + if (!dev->msi_enabled) { + msi_count = 1; + i = pci_enable_msi(dev->pdev); + +
[PATCH V4 01/10] [SCSI] aacraid: Fix for logical device name and UID not exposed to the OS
From: Rajinikanth Pandurangan Description: Driver sends the right size of the response buffer. Changes from V2: None V2: Reviewed-by: Johannes Thumshirn Reviewed-by: Tomas Henzl Reviewed-by: Mahesh Rajashekhara Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/aachba.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 9b3dd6e..fe59b00 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -570,7 +570,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) status = aac_fib_send(ContainerCommand, cmd_fibcontext, - sizeof (struct aac_get_name), + sizeof(struct aac_get_name_resp), FsaNormal, 0, 1, (fib_callback)get_container_name_callback, @@ -1052,7 +1052,7 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd) status = aac_fib_send(ContainerCommand, cmd_fibcontext, - sizeof (struct aac_get_serial), + sizeof(struct aac_get_serial_resp), FsaNormal, 0, 1, (fib_callback) get_container_serial_callback, -- 1.9.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
[PATCH V4 06/10] [SCSI] aacraid: Reset irq affinity hints before releasing irq
From: Rajinikanth Pandurangan Description: Reset irq affinity hints before releasing IRQ Removed duplicate code of IRQ acquire/release Changes from V2: None Reviewed by: Mahesh Rajashekhara , Johannes Thumshirn Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/aacraid.h | 2 + drivers/scsi/aacraid/commsup.c | 113 ++--- drivers/scsi/aacraid/src.c | 48 ++--- 3 files changed, 88 insertions(+), 75 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index e54f597..7b95227 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2110,6 +2110,8 @@ static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor) #define AAC_OWNER_ERROR_HANDLER0x103 #define AAC_OWNER_FIRMWARE 0x106 +int aac_acquire_irq(struct aac_dev *dev); +void aac_free_irq(struct aac_dev *dev); const char *aac_driverinfo(struct Scsi_Host *); struct fib *aac_fib_alloc(struct aac_dev *dev); int aac_fib_setup(struct aac_dev *dev); diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 4da5749..a1f90fe 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1270,13 +1270,12 @@ retry_next: static int _aac_reset_adapter(struct aac_dev *aac, int forced) { int index, quirks; - int retval, i; + int retval; struct Scsi_Host *host; struct scsi_device *dev; struct scsi_cmnd *command; struct scsi_cmnd *command_list; int jafo = 0; - int cpu; /* * Assumptions: @@ -1339,35 +1338,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced) aac->comm_phys = 0; kfree(aac->queues); aac->queues = NULL; - cpu = cpumask_first(cpu_online_mask); - if (aac->pdev->device == PMC_DEVICE_S6 || - aac->pdev->device == PMC_DEVICE_S7 || - aac->pdev->device == PMC_DEVICE_S8 || - aac->pdev->device == PMC_DEVICE_S9) { - if (aac->max_msix > 1) { - for (i = 0; i < aac->max_msix; i++) { - if (irq_set_affinity_hint( - aac->msixentry[i].vector, - NULL)) { - printk(KERN_ERR "%s%d: Failed to reset IRQ affinity for cpu %d\n", - aac->name, - aac->id, - cpu); - } - cpu = cpumask_next(cpu, - cpu_online_mask); - free_irq(aac->msixentry[i].vector, -&(aac->aac_msix[i])); - } - pci_disable_msix(aac->pdev); - } else { - free_irq(aac->pdev->irq, &(aac->aac_msix[0])); - } - } else { - free_irq(aac->pdev->irq, aac); - } - if (aac->msi) - pci_disable_msi(aac->pdev); + aac_free_irq(aac); kfree(aac->fsa_dev); aac->fsa_dev = NULL; quirks = aac_get_driver_ident(index)->quirks; @@ -1978,3 +1949,83 @@ int aac_command_thread(void *data) dev->aif_thread = 0; return 0; } + +int aac_acquire_irq(struct aac_dev *dev) +{ + int i; + int j; + int ret = 0; + int cpu; + + cpu = cpumask_first(cpu_online_mask); + if (!dev->sync_mode && dev->msi_enabled && dev->max_msix > 1) { + for (i = 0; i < dev->max_msix; i++) { + dev->aac_msix[i].vector_no = i; + dev->aac_msix[i].dev = dev; + if (request_irq(dev->msixentry[i].vector, + dev->a_ops.adapter_intr, + 0, "aacraid", &(dev->aac_msix[i]))) { + printk(KERN_ERR "%s%d: Failed to register IRQ for vector %d.\n", + dev->name, dev->id, i); + for (j = 0 ; j < i ; j++) + free_irq(dev->msixentry[j].vector, +&(dev->aac_msix[j])); + pci_disable_msix(dev->pdev); + ret = -1; + } + if (irq_set_affinity_hint(dev->msixentry[i].vector, + get_cpu_mask(cpu))) { + printk(KERN_ERR "%s%d: Failed to set IRQ affinity for cpu %d\n", + dev->name, dev->id, cpu); + } + cpu = cpumask_next(cp
[PATCH V4 05/10] [SCSI] aacraid: Tune response path if IsFastPath bit set
From: Rajinikanth Pandurangan Description: If 'IsFastPath' bit is set, then response path assumes no error and skips error check. Changes from V2: None Reviewed By: Tomas Henzl , Mahesh Rajashekhara , Johannes Thumshirn Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/aachba.c | 259 ++ 1 file changed, 137 insertions(+), 122 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index fe59b00..864e9f6 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -2977,11 +2977,16 @@ static void aac_srb_callback(void *context, struct fib * fibptr) return; BUG_ON(fibptr == NULL); - dev = fibptr->dev; - srbreply = (struct aac_srb_reply *) fib_data(fibptr); + scsi_dma_unmap(scsicmd); + /* expose physical device if expose_physicald flag is on */ + if (scsicmd->cmnd[0] == INQUIRY && !(scsicmd->cmnd[1] & 0x01) + && expose_physicals > 0) + aac_expose_phy_device(scsicmd); + + srbreply = (struct aac_srb_reply *) fib_data(fibptr); scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */ if (fibptr->flags & FIB_CONTEXT_FLAG_FASTRESP) { @@ -2994,147 +2999,157 @@ static void aac_srb_callback(void *context, struct fib * fibptr) */ scsi_set_resid(scsicmd, scsi_bufflen(scsicmd) - le32_to_cpu(srbreply->data_xfer_length)); - } - - scsi_dma_unmap(scsicmd); - - /* expose physical device if expose_physicald flag is on */ - if (scsicmd->cmnd[0] == INQUIRY && !(scsicmd->cmnd[1] & 0x01) - && expose_physicals > 0) - aac_expose_phy_device(scsicmd); + /* +* First check the fib status +*/ - /* -* First check the fib status -*/ + if (le32_to_cpu(srbreply->status) != ST_OK) { + int len; - if (le32_to_cpu(srbreply->status) != ST_OK){ - int len; - printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status)); - len = min_t(u32, le32_to_cpu(srbreply->sense_data_size), - SCSI_SENSE_BUFFERSIZE); - scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; - memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); - } + printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status)); + len = min_t(u32, le32_to_cpu(srbreply->sense_data_size), + SCSI_SENSE_BUFFERSIZE); + scsicmd->result = DID_ERROR << 16 + | COMMAND_COMPLETE << 8 + | SAM_STAT_CHECK_CONDITION; + memcpy(scsicmd->sense_buffer, + srbreply->sense_data, len); + } - /* -* Next check the srb status -*/ - switch( (le32_to_cpu(srbreply->srb_status))&0x3f){ - case SRB_STATUS_ERROR_RECOVERY: - case SRB_STATUS_PENDING: - case SRB_STATUS_SUCCESS: - scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; - break; - case SRB_STATUS_DATA_OVERRUN: - switch(scsicmd->cmnd[0]){ - case READ_6: - case WRITE_6: - case READ_10: - case WRITE_10: - case READ_12: - case WRITE_12: - case READ_16: - case WRITE_16: - if (le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow) { - printk(KERN_WARNING"aacraid: SCSI CMD underflow\n"); - } else { - printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n"); + /* +* Next check the srb status +*/ + switch ((le32_to_cpu(srbreply->srb_status))&0x3f) { + case SRB_STATUS_ERROR_RECOVERY: + case SRB_STATUS_PENDING: + case SRB_STATUS_SUCCESS: + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; + break; + case SRB_STATUS_DATA_OVERRUN: + switch (scsicmd->cmnd[0]) { + case READ_6: + case WRITE_6: + case READ_10: + case WRITE_10: + case READ_12: + case WRITE_12: + case READ_16: + case WRITE_16: + if (le32_to_cpu(srbr
[PATCH V4 04/10] [SCSI] aacraid: Enable 64-bit write to controller register
From: Rajinikanth Pandurangan Description: If writeq() not supported, then do atomic two 32bit write Changes from V2: None Reviewed by: Tomas Henzl , Mahesh Rajashekhara , Johannes Thumshirn Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/aacraid.h | 9 + drivers/scsi/aacraid/comminit.c | 1 + drivers/scsi/aacraid/src.c | 12 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 62b0999..e54f597 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -844,6 +844,10 @@ struct src_registers { &((AEP)->regs.src.bar0->CSR)) #define src_writel(AEP, CSR, value)writel(value, \ &((AEP)->regs.src.bar0->CSR)) +#if defined(writeq) +#definesrc_writeq(AEP, CSR, value) writeq(value, \ + &((AEP)->regs.src.bar0->CSR)) +#endif #define SRC_ODR_SHIFT 12 #define SRC_IDR_SHIFT 9 @@ -1163,6 +1167,11 @@ struct aac_dev struct fsa_dev_info *fsa_dev; struct task_struct *thread; int cardtype; + /* +*This lock will protect the two 32-bit +*writes to the Inbound Queue +*/ + spinlock_t iq_lock; /* * The following is the device specific extension. diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 45a0a04..b4b6088 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -424,6 +424,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) dev->management_fib_count = 0; spin_lock_init(&dev->manage_lock); spin_lock_init(&dev->sync_lock); + spin_lock_init(&dev->iq_lock); dev->max_fib_size = sizeof(struct hw_fib); dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size - sizeof(struct aac_fibhdr) diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index eb07b3d..1409a0b 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -447,6 +447,10 @@ static int aac_src_deliver_message(struct fib *fib) u32 fibsize; dma_addr_t address; struct aac_fib_xporthdr *pFibX; +#if !defined(writeq) + unsigned long flags; +#endif + u16 hdr_size = le16_to_cpu(fib->hw_fib_va->header.Size); atomic_inc(&q->numpending); @@ -511,10 +515,14 @@ static int aac_src_deliver_message(struct fib *fib) return -EINVAL; address |= fibsize; } - +#if defined(writeq) + src_writeq(dev, MUnit.IQ_L, (u64)address); +#else + spin_lock_irqsave(&fib->dev->iq_lock, flags); src_writel(dev, MUnit.IQ_H, upper_32_bits(address) & 0x); src_writel(dev, MUnit.IQ_L, address & 0x); - + spin_unlock_irqrestore(&fib->dev->iq_lock, flags); +#endif return 0; } -- 1.9.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
[PATCH V4 03/10] [SCSI] aacraid: Change interrupt mode to MSI for series-6 controller
From: Rajinikanth Pandurangan Description: This change always sets MSI interrupt mode for series-6 controller. Note: For series 6 family, MSIx is not supported. Changes from V2: Only Subject & description change. Reviewed by: Tomas Henzl , Mahesh Rajashekhara , Johannes Thumshirn Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/src.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index b147341..eb07b3d 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -742,7 +742,7 @@ int aac_src_init(struct aac_dev *dev) if (dev->comm_interface != AAC_COMM_MESSAGE_TYPE1) goto error_iounmap; - dev->msi = aac_msi && !pci_enable_msi(dev->pdev); + dev->msi = !pci_enable_msi(dev->pdev); dev->aac_msix[0].vector_no = 0; dev->aac_msix[0].dev = dev; -- 1.9.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
[PATCH V4 07/10] [SCSI] aacraid: Unblock IOCTLs to controller once system resumed from suspend
From: Rajinikanth Pandurangan Description: Driver blocks ioctls once it received shutdown/suspend request during suspend/hybernation. This patch unblocks ioctls on resume path. Changes from V2: None Reviewed by: Mahesh Rajashekhara , Johannes Thumshirn Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/linit.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 37375cf..3b6e5c6 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1448,6 +1448,11 @@ static int aac_resume(struct pci_dev *pdev) pci_set_master(pdev); if (aac_acquire_resources(aac)) goto fail_device; + /* + * reset this flag to unblock ioctl() as it was set at + * aac_send_shutdown() to block ioctls from upperlayer + */ + aac->adapter_shutdown = 0; scsi_unblock_requests(shost); return 0; -- 1.9.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
[PATCH V4 09/10] [SCSI] aacraid: Update driver version
From: Rajinikanth Pandurangan Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/linit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 7b95227..73c3384 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -62,7 +62,7 @@ enum { #definePMC_GLOBAL_INT_BIT0 0x0001 #ifndef AAC_DRIVER_BUILD -# define AAC_DRIVER_BUILD 40709 +# define AAC_DRIVER_BUILD 41010 # define AAC_DRIVER_BRANCH "-ms" #endif #define MAXIMUM_NUM_CONTAINERS 32 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 35dd849..3fabfa1 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -56,7 +56,7 @@ #include "aacraid.h" -#define AAC_DRIVER_VERSION "1.2-1" +#define AAC_DRIVER_VERSION "1.2-2" #ifndef AAC_DRIVER_BRANCH #define AAC_DRIVER_BRANCH "" #endif -- 1.9.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
[PATCH V4 08/10] [SCSI] aacraid: Send commit-config to controller firmware
From: Rajinikanth Pandurangan Description: Controller BIOS/UEFI driver used to send this request. But for IBM-Power system there is no BIOS/UEFI driver. So this change is required for IBM, otherwise controller will be read-only mode. Changes from V2: None Reviewed by: Mahesh Rajashekhara , Johannes Thumshirn Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/linit.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 3b6e5c6..35dd849 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1270,8 +1270,11 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_channel = aac->maximum_num_channels; else shost->max_channel = 0; - +#if defined(__powerpc__) || defined(__PPC__) || defined(__ppc__) + aac_get_config_status(aac, 1); +#else aac_get_config_status(aac, 0); +#endif aac_get_containers(aac); list_add(&aac->entry, insert); -- 1.9.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
[PATCH V4 10/10] [SCSI] aacraid: Replace pci_enable_msix() with pci_enable_msix_range()
From: Rajinikanth Pandurangan Description: As pci_enable_msix() deprecated, replaced with pci_enable_msix_range() V3 Reviewed/commented by: Tomas Henzl Changes from V3: Uses pci_enable_msix_range() instead of pci_enable_msix_exact() based on review comment. Signed-off-by: Rajinikanth Pandurangan --- drivers/scsi/aacraid/comminit.c | 20 ++-- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index b4b6088..3ba6e97 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -338,7 +338,7 @@ static int aac_comm_init(struct aac_dev * dev) void aac_define_int_mode(struct aac_dev *dev) { - int i, msi_count; + int i, msi_count, min_msix; msi_count = i = 0; /* max. vectors from GET_COMM_PREFERRED_SETTINGS */ @@ -366,22 +366,14 @@ void aac_define_int_mode(struct aac_dev *dev) if (msi_count > 1 && pci_find_capability(dev->pdev, PCI_CAP_ID_MSIX)) { - i = pci_enable_msix(dev->pdev, + min_msix = 8; + i = pci_enable_msix_range(dev->pdev, dev->msixentry, + min_msix, msi_count); -/* Check how many MSIX vectors are allocated */ - if (i >= 0) { + if (i > 0) { dev->msi_enabled = 1; - if (i) { - msi_count = i; - if (pci_enable_msix(dev->pdev, - dev->msixentry, - msi_count)) { - dev->msi_enabled = 0; - printk(KERN_ERR "%s%d: MSIX not supported!! Will try MSI 0x%x.\n", - dev->name, dev->id, i); - } - } + msi_count = i; } else { dev->msi_enabled = 0; printk(KERN_ERR "%s%d: MSIX not supported!! Will try MSI 0x%x.\n", -- 1.9.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
[PATCH] target: add support for START_STOP_UNIT SCSI opcode
From: Brian Bunker AIX servers using VIOS servers that virtualize FC cards will have a problem booting without support for START_STOP_UNIT. Signed-off-by: Brian Bunker Signed-off-by: Spencer Baugh --- drivers/target/target_core_sbc.c | 33 + 1 file changed, 33 insertions(+) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index e318ddb..996e584 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -154,6 +154,35 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) return 0; } +static sense_reason_t +sbc_emulate_startstop(struct se_cmd *cmd) +{ + unsigned char *cdb = cmd->t_task_cdb; + + /* From SBC-3: +* Immediate bit should be set since there is nothing to complete +* POWER CONDITION MODIFIER 0h +*/ + if (!(cdb[1] & 1) || (cdb[2] | cdb[3])) + return TCM_INVALID_CDB_FIELD; + + /* From SBC-3: +* POWER CONDITION 0h START_VALID - process START and LOEJ +*/ + if (cdb[4] >> 4 & 0xf) + return TCM_INVALID_CDB_FIELD; + + /* From SBC-3: +* LOEJ 0h - nothing to load or unload +* START 1h - we are ready +*/ + if (!(cdb[4] & 1) || ((cdb[4] & 2) | (cdb[4] & 4))) + return TCM_INVALID_CDB_FIELD; + + target_complete_cmd(cmd, SAM_STAT_GOOD); + return 0; +} + sector_t sbc_get_write_same_sectors(struct se_cmd *cmd) { u32 num_blocks; @@ -1069,6 +1098,10 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) size = 0; cmd->execute_cmd = sbc_emulate_noop; break; + case START_STOP: + size = 0; + cmd->execute_cmd = sbc_emulate_startstop; + break; default: ret = spc_parse_cdb(cmd, &size); if (ret) -- 2.4.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
[PATCH] target/iscsi: Fix double free of a TUR followed by a solicited NOPOUT
From: Alexei Potashnik Make sure all non-READ SCSI commands get targ_xfer_tag initialized to 0x, not just WRITEs. Double-free of a TUR cmd object occurs under the following scenario: 1. TUR received (targ_xfer_tag is uninitialized and left at 0) 2. TUR status sent 3. First unsolicited NOPIN is sent to initiator (gets targ_xfer_tag of 0) 4. NOPOUT for NOPIN (with TTT=0) arrives - its ExpStatSN acks TUR status, TUR is queued for removal - LIO tries to find NOPIN with TTT=0, but finds the same TUR instead, TUR is queued for removal for the 2nd time Signed-off-by: Alexei Potashnik Signed-off-by: Spencer Baugh --- drivers/target/iscsi/iscsi_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index a4cf58c..ebb1ece 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -970,7 +970,7 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; if (hdr->flags & ISCSI_FLAG_CMD_READ) { cmd->targ_xfer_tag = session_get_next_ttt(conn->sess); - } else if (hdr->flags & ISCSI_FLAG_CMD_WRITE) + } else cmd->targ_xfer_tag = 0x; cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); cmd->exp_stat_sn= be32_to_cpu(hdr->exp_statsn); -- 2.4.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
[PATCH] qla2xxx: Return the fabric command state for non-task management requests
From: Dilip Kumar Uppugandla Invoking get_cmd_state for qla2xxx always returns 0. Instead change it to return the actual fabric state from qla_tgt_cmd. This will help with debugging. Signed-off-by: Dilip Kumar Uppugandla Signed-off-by: Spencer Baugh --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index d9a8c60..e859586 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -420,6 +420,12 @@ static void tcm_qla2xxx_set_default_node_attrs(struct se_node_acl *nacl) static int tcm_qla2xxx_get_cmd_state(struct se_cmd *se_cmd) { + if (!(se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) { + struct qla_tgt_cmd *cmd = container_of(se_cmd, + struct qla_tgt_cmd, se_cmd); + return cmd->state; + } + return 0; } -- 2.4.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
[PATCH] target: fix crash in cmd tracing when cmd didn't match a LUN
From: Alexei Potashnik If command didn't match a LUN and we're sending check condition, the target_cmd_complete ftrace point will crash because it assumes that cmd->t_task_cdb has been set. The fix will temporarily set t_task_cdb to the se_cmd buffer and copy first 6 bytes of cdb in there as soon as possible. At a later point t_task_cdb is reset to the correct buffer, but until then traces and printks don't cause a crash. Signed-off-by: Alexei Potashnik Signed-off-by: Spencer Baugh --- drivers/target/target_core_device.c| 7 +++ drivers/target/target_core_transport.c | 7 --- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index c4a8db6..b74dfb2 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -63,6 +63,13 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 unpacked_lun) struct se_node_acl *nacl = se_sess->se_node_acl; struct se_dev_entry *deve; + /* Temporarily set t_task_cdb to the se_cmd buffer and save a portion +* of cdb in there (fabrics must provide at least 6 bytes). t_task_cdb +* will be correctly replaced in target_setup_cmd_from_cdb. Until then +* tracing and printks can access t_task_cdb without causing a crash. */ + se_cmd->t_task_cdb = se_cmd->__t_task_cdb; + memcpy(se_cmd->t_task_cdb, cdb, 6); + rcu_read_lock(); deve = target_nacl_find_deve(nacl, unpacked_lun); if (deve) { diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ce8574b..8dd15c7 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1210,15 +1210,16 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned char *cdb) * setup the pointer from __t_task_cdb to t_task_cdb. */ if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) { - cmd->t_task_cdb = kzalloc(scsi_command_size(cdb), - GFP_KERNEL); - if (!cmd->t_task_cdb) { + unsigned char *ptr = kzalloc(scsi_command_size(cdb), +GFP_KERNEL); + if (!ptr) { pr_err("Unable to allocate cmd->t_task_cdb" " %u > sizeof(cmd->__t_task_cdb): %lu ops\n", scsi_command_size(cdb), (unsigned long)sizeof(cmd->__t_task_cdb)); return TCM_OUT_OF_RESOURCES; } + cmd->t_task_cdb = ptr; } else cmd->t_task_cdb = &cmd->__t_task_cdb[0]; /* -- 2.4.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] target: fix crash in cmd tracing when cmd didn't match a LUN
Please disregard, depends on another patch. Will send again later. Sorry for the noise. -- 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] qla2xxx: Return the fabric command state for non-task management requests
On 7/21/15, 3:07 PM, "Spencer Baugh" wrote: >From: Dilip Kumar Uppugandla > >Invoking get_cmd_state for qla2xxx always returns 0. Instead change it >to return the actual fabric state from qla_tgt_cmd. This will help with >debugging. > >Signed-off-by: Dilip Kumar Uppugandla >Signed-off-by: Spencer Baugh >--- > drivers/scsi/qla2xxx/tcm_qla2xxx.c | 6 ++ > 1 file changed, 6 insertions(+) > >diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c >b/drivers/scsi/qla2xxx/tcm_qla2xxx.c >index d9a8c60..e859586 100644 >--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c >+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c >@@ -420,6 +420,12 @@ static void >tcm_qla2xxx_set_default_node_attrs(struct se_node_acl *nacl) > > static int tcm_qla2xxx_get_cmd_state(struct se_cmd *se_cmd) > { >+ if (!(se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) { >+ struct qla_tgt_cmd *cmd = container_of(se_cmd, >+ struct qla_tgt_cmd, se_cmd); >+ return cmd->state; >+ } >+ > return 0; > } > >-- >2.4.3 > >-- >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/ Looks Good. Acked-by: Himanshu Madhani > <>
Re: [PATCH] target/iscsi: fix digest computation for chained SGs
On Tue, Jul 21, 2015 at 1:57 AM, Sagi Grimberg wrote: > How were you able to get a chained SG list in the target code? Local hack. So this bug can't be hit in current mainline code, but patch improves the code and removes a hidden booby-trap, so I think it makes sense to apply. -- 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