[PATCH 0/6] target: Update UA handling
Hi Nic, lio-target is very minimalistic when it comes to generate UAs; primarily they are generated for persistent reservations, but generic changes tend to be ignored. This patchset updates the UA handling and generates UA for internal state changes (REPORTED LUNS DATA CHANGED, INQUIRY DATA CHANGED, and LUN RESET OCCURRED). Funnily enough this triggers some issues with the SCSI stack; I'll be sending out patches for that, too. Hannes Reinecke (6): target_core_alua: Correct UA handling when switching states target: Remove 'ua_nacl' pointer from se_ua structure target: use 'se_dev_entry' when allocating UAs target: Send UA on ALUA target port group change target: Send UA upon LUN RESET tmr completion target: Send UA when changing LUN inventory drivers/target/target_core_alua.c | 56 +- drivers/target/target_core_device.c| 26 +++- drivers/target/target_core_pr.c| 31 +++ drivers/target/target_core_transport.c | 29 ++ drivers/target/target_core_ua.c| 24 ++- drivers/target/target_core_ua.h| 5 ++- include/target/target_core_base.h | 1 - 7 files changed, 121 insertions(+), 51 deletions(-) -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/6] target: Send UA when changing LUN inventory
When changind the LUN inventory via core_enable_device_list_for_node() or core_disable_device_list_for_node() a REPORTED LUNS DATA HAS CHANGED UA should be send. Signed-off-by: Hannes Reinecke --- drivers/target/target_core_device.c | 26 +- drivers/target/target_core_ua.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 650613e..ac191a9 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -305,7 +305,7 @@ int core_enable_device_list_for_node( struct se_node_acl *nacl, struct se_portal_group *tpg) { - struct se_dev_entry *orig, *new; + struct se_dev_entry *orig, *new, *tmp; new = kzalloc(sizeof(*new), GFP_KERNEL); if (!new) { @@ -360,6 +360,15 @@ int core_enable_device_list_for_node( kref_put(&orig->pr_kref, target_pr_kref_release); wait_for_completion(&orig->pr_comp); + rcu_read_lock(); + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) { + if (tmp == new) + continue; + core_scsi3_ua_allocate(tmp, 0x3F, + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); + } + rcu_read_unlock(); + kfree_rcu(orig, rcu_head); return 0; } @@ -373,6 +382,14 @@ int core_enable_device_list_for_node( list_add_tail(&new->lun_link, &lun->lun_deve_list); spin_unlock_bh(&lun->lun_deve_lock); + rcu_read_lock(); + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) { + if (tmp == new) + continue; + core_scsi3_ua_allocate(tmp, 0x3F, + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); + } + rcu_read_unlock(); return 0; } @@ -385,6 +402,7 @@ void core_disable_device_list_for_node( struct se_node_acl *nacl, struct se_portal_group *tpg) { + struct se_dev_entry *tmp; /* * rcu_dereference_raw protected by se_lun->lun_group symlink * reference to se_device->dev_group. @@ -428,6 +446,12 @@ void core_disable_device_list_for_node( kfree_rcu(orig, rcu_head); core_scsi3_free_pr_reg_from_nacl(dev, nacl); + + rcu_read_lock(); + hlist_for_each_entry_rcu(tmp, &nacl->lun_entry_hlist, link) + core_scsi3_ua_allocate(tmp, 0x3F, + ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED); + rcu_read_unlock(); } /* core_clear_lun_from_tpg(): diff --git a/drivers/target/target_core_ua.h b/drivers/target/target_core_ua.h index 948ae1e..45e3b6d 100644 --- a/drivers/target/target_core_ua.h +++ b/drivers/target/target_core_ua.h @@ -26,6 +26,7 @@ #define ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS 0x09 #define ASCQ_3FH_INQUIRY_DATA_HAS_CHANGED 0x03 +#define ASCQ_3FH_REPORTED_LUNS_DATA_HAS_CHANGED0x0E extern struct kmem_cache *se_ua_cache; -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/6] target_core_alua: Correct UA handling when switching states
When switching target port group ALUA states we need to send one UA when setting the ALUA state to 'transitioning', and another one once the final state has been set. Signed-off-by: Hannes Reinecke --- drivers/target/target_core_alua.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 2318e6e..228a3c7 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -941,16 +941,11 @@ static int core_alua_update_tpg_primary_metadata( return rc; } -static void core_alua_do_transition_tg_pt_work(struct work_struct *work) +static void core_alua_queue_state_change_ua(struct t10_alua_tg_pt_gp *tg_pt_gp) { - struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(work, - struct t10_alua_tg_pt_gp, tg_pt_gp_transition_work.work); - struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; struct se_dev_entry *se_deve; struct se_lun *lun; struct se_lun_acl *lacl; - bool explicit = (tg_pt_gp->tg_pt_gp_alua_access_status == -ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG); spin_lock(&tg_pt_gp->tg_pt_gp_lock); list_for_each_entry(lun, &tg_pt_gp->tg_pt_gp_lun_list, @@ -1002,6 +997,16 @@ static void core_alua_do_transition_tg_pt_work(struct work_struct *work) percpu_ref_put(&lun->lun_ref); } spin_unlock(&tg_pt_gp->tg_pt_gp_lock); +} + +static void core_alua_do_transition_tg_pt_work(struct work_struct *work) +{ + struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(work, + struct t10_alua_tg_pt_gp, tg_pt_gp_transition_work.work); + struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; + bool explicit = (tg_pt_gp->tg_pt_gp_alua_access_status == +ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG); + /* * Update the ALUA metadata buf that has been allocated in * core_alua_do_port_transition(), this metadata will be written @@ -1031,6 +1036,9 @@ static void core_alua_do_transition_tg_pt_work(struct work_struct *work) tg_pt_gp->tg_pt_gp_id, core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_previous_state), core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_pending_state)); + + core_alua_queue_state_change_ua(tg_pt_gp); + spin_lock(&dev->t10_alua.tg_pt_gps_lock); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); spin_unlock(&dev->t10_alua.tg_pt_gps_lock); @@ -1083,6 +1091,8 @@ static int core_alua_do_transition_tg_pt( ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG : ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA; + core_alua_queue_state_change_ua(tg_pt_gp); + /* * Check for the optional ALUA primary state transition delay */ -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] target: Send UA upon LUN RESET tmr completion
SAM mandates that an BUS DEVICE RESET FUNCTION OCCURRED UA needs to be send after a LUN RESET tmr has completed. Signed-off-by: Hannes Reinecke --- drivers/target/target_core_transport.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index a0e0d3a..bb60c0c4 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3064,6 +3064,17 @@ static void target_tmr_work(struct work_struct *work) ret = core_tmr_lun_reset(dev, tmr, NULL, NULL); tmr->response = (!ret) ? TMR_FUNCTION_COMPLETE : TMR_FUNCTION_REJECTED; + if (tmr->response == TMR_FUNCTION_COMPLETE) { + struct se_dev_entry *deve; + + rcu_read_lock(); + deve = target_nacl_find_deve(cmd->se_sess->se_node_acl, +cmd->orig_fe_lun); + if (deve) + core_scsi3_ua_allocate(deve, 0x29, + ASCQ_29H_BUS_DEVICE_RESET_FUNCTION_OCCURRED); + rcu_read_unlock(); + } break; case TMR_TARGET_WARM_RESET: tmr->response = TMR_FUNCTION_REJECTED; -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/6] target: use 'se_dev_entry' when allocating UAs
We need to use 'se_dev_entry' as argument when allocating UAs, otherwise we'll never see any UAs for an implicit ALUA state transition triggered from userspace. Signed-off-by: Hannes Reinecke --- drivers/target/target_core_alua.c | 27 ++- drivers/target/target_core_pr.c| 31 +-- drivers/target/target_core_transport.c | 18 -- drivers/target/target_core_ua.c| 23 +++ drivers/target/target_core_ua.h| 2 +- 5 files changed, 59 insertions(+), 42 deletions(-) diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 228a3c7..aa2e4b1 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -972,23 +972,32 @@ static void core_alua_queue_state_change_ua(struct t10_alua_tg_pt_gp *tg_pt_gp) list_for_each_entry(se_deve, &lun->lun_deve_list, lun_link) { lacl = rcu_dereference_check(se_deve->se_lun_acl, lockdep_is_held(&lun->lun_deve_lock)); + /* -* se_deve->se_lun_acl pointer may be NULL for a -* entry created without explicit Node+MappedLUN ACLs +* spc4r37 p.242: +* After an explicit target port asymmetric access +* state change, a device server shall establish a +* unit attention condition with the additional sense +* code set to ASYMMETRIC ACCESS STATE CHANGED for +* the initiator port associated with every I_T nexus +* other than the I_T nexus on which the SET TARGET +* PORT GROUPS command was received. */ - if (!lacl) - continue; - if ((tg_pt_gp->tg_pt_gp_alua_access_status == ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG) && - (tg_pt_gp->tg_pt_gp_alua_nacl != NULL) && - (tg_pt_gp->tg_pt_gp_alua_nacl == lacl->se_lun_nacl) && (tg_pt_gp->tg_pt_gp_alua_lun != NULL) && (tg_pt_gp->tg_pt_gp_alua_lun == lun)) continue; - core_scsi3_ua_allocate(lacl->se_lun_nacl, - se_deve->mapped_lun, 0x2A, + /* +* se_deve->se_lun_acl pointer may be NULL for a +* entry created without explicit Node+MappedLUN ACLs +*/ + if (lacl && (tg_pt_gp->tg_pt_gp_alua_nacl != NULL) && + (tg_pt_gp->tg_pt_gp_alua_nacl == lacl->se_lun_nacl)) + continue; + + core_scsi3_ua_allocate(se_deve, 0x2A, ASCQ_2AH_ASYMMETRIC_ACCESS_STATE_CHANGED); } spin_unlock_bh(&lun->lun_deve_lock); diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 436e30b..bb28a97 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -125,6 +125,25 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg(struct se_device *, struct se_node_acl *, struct se_session *); static void core_scsi3_put_pr_reg(struct t10_pr_registration *); +static void core_scsi3_pr_ua_allocate(struct se_node_acl *nacl, + u32 unpacked_lun, u8 asc, u8 ascq) +{ + struct se_dev_entry *deve; + + if (!nacl) + return; + + rcu_read_lock(); + deve = target_nacl_find_deve(nacl, unpacked_lun); + if (!deve) { + rcu_read_unlock(); + return; + } + + core_scsi3_ua_allocate(deve, asc, ascq); + rcu_read_unlock(); +} + static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd) { struct se_session *se_sess = cmd->se_sess; @@ -2197,7 +2216,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, &pr_tmpl->registration_list, pr_reg_list) { - core_scsi3_ua_allocate( + core_scsi3_pr_ua_allocate( pr_reg_p->pr_reg_nacl, pr_reg_p->pr_res_mapped_lun, 0x2A, @@ -2624,7 +2643,7 @@ core_scsi3_emulate_pro_release(struct se_cmd *cmd, int type, int scope, if (pr_reg_p == pr_reg) continue; - core_scsi3_ua_allocate(pr_reg_p->pr_reg_nacl, + core_scsi3_p
[PATCH 4/6] target: Send UA on ALUA target port group change
When the ALUA target port group changes an INQUIRY DATA CHANGE UA needs to be sent. Signed-off-by: Hannes Reinecke --- drivers/target/target_core_alua.c | 7 +++ drivers/target/target_core_ua.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index aa2e4b1..edaf1b9 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -1880,12 +1880,19 @@ static void core_alua_put_tg_pt_gp_from_name( static void __target_attach_tg_pt_gp(struct se_lun *lun, struct t10_alua_tg_pt_gp *tg_pt_gp) { + struct se_dev_entry *se_deve; + assert_spin_locked(&lun->lun_tg_pt_gp_lock); spin_lock(&tg_pt_gp->tg_pt_gp_lock); lun->lun_tg_pt_gp = tg_pt_gp; list_add_tail(&lun->lun_tg_pt_gp_link, &tg_pt_gp->tg_pt_gp_lun_list); tg_pt_gp->tg_pt_gp_members++; + spin_lock_bh(&lun->lun_deve_lock); + list_for_each_entry(se_deve, &lun->lun_deve_list, lun_link) + core_scsi3_ua_allocate(se_deve, 0x3f, + ASCQ_3FH_INQUIRY_DATA_HAS_CHANGED); + spin_unlock_bh(&lun->lun_deve_lock); spin_unlock(&tg_pt_gp->tg_pt_gp_lock); } diff --git a/drivers/target/target_core_ua.h b/drivers/target/target_core_ua.h index a9c4693..948ae1e 100644 --- a/drivers/target/target_core_ua.h +++ b/drivers/target/target_core_ua.h @@ -25,6 +25,8 @@ #define ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS 0x09 +#define ASCQ_3FH_INQUIRY_DATA_HAS_CHANGED 0x03 + extern struct kmem_cache *se_ua_cache; extern sense_reason_t target_scsi3_ua_check(struct se_cmd *); -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/6] target: Remove 'ua_nacl' pointer from se_ua structure
Unused. Signed-off-by: Hannes Reinecke --- drivers/target/target_core_ua.c | 1 - include/target/target_core_base.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c index e53d4ee..e506224 100644 --- a/drivers/target/target_core_ua.c +++ b/drivers/target/target_core_ua.c @@ -107,7 +107,6 @@ int core_scsi3_ua_allocate( } INIT_LIST_HEAD(&ua->ua_nacl_list); - ua->ua_nacl = nacl; ua->ua_asc = asc; ua->ua_ascq = ascq; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index d30271e..4055cbd 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -549,7 +549,6 @@ struct se_cmd { struct se_ua { u8 ua_asc; u8 ua_ascq; - struct se_node_acl *ua_nacl; struct list_headua_nacl_list; }; -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Patch V2 4/9] [SCSI] aacraid: Enable 64-bit write to controller register
On Wed, Jun 10, 2015 at 06:42:26PM -0700, rajinikanth.panduran...@pmcs.com wrote: > From: Rajinikanth Pandurangan > > Description: > If writeq() not supported, then do atomic two 32bit write > > 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) > +#define src_writeq(AEP, CSR, value) writeq(value, \ > + &((AEP)->regs.src.bar0->CSR)) > +#endif > > #define SRC_ODR_SHIFT12 > #define SRC_IDR_SHIFT9 > @@ -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 e0a76d5..e4ff47e 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; > } Why not make src_writeq() a wrapper over either writeq() or spin_lock_irqsave(); src_writel() x2; spin_unlock_irqrestore(), depending on the presence of writeq? > > -- > 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 -- Johannes Thumshirn Storage jthumsh...@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- 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] scsi: retry MODE SENSE on unit attention
The 'sd' driver is calling scsi_mode_sense() to figure out internal details. But scsi_mode_sense() never checks for any pending unit attentions, so we're getting annoying error messages like: MODE SENSE: unimplemented page/subpage: 0x00/0x00 and a possible wrong decision for device cache handling. Signed-off-by: Hannes Reinecke --- drivers/scsi/scsi_lib.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 2428d96..d7915c8 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2423,7 +2423,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, unsigned char cmd[12]; int use_10_for_ms; int header_length; - int result; + int result, retry_count = retries; struct scsi_sense_hdr my_sshdr; memset(data, 0, sizeof(*data)); @@ -2502,6 +2502,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, data->block_descriptor_length = buffer[3]; } data->header_length = header_length; + } else if ((status_byte(result) == CHECK_CONDITION) && + scsi_sense_valid(sshdr) && + sshdr->sense_key == UNIT_ATTENTION && retry_count) { + retry_count--; + goto retry; } return result; -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] scsi: Add ALUA state change UA handling
Log the ALUA state change unit attention correctly with the message log and emit an event to allow user-space tools to react to it. Signed-off-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 4 drivers/scsi/scsi_lib.c| 4 include/scsi/scsi_device.h | 1 + 3 files changed, 9 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index c95a4e9..ad32bc0 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -421,6 +421,10 @@ static void scsi_report_sense(struct scsi_device *sdev, evt_type = SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED; sdev_printk(KERN_WARNING, sdev, "Mode parameters changed"); + } else if (sshdr->asc == 0x2a && sshdr->ascq == 0x06) { + evt_type = SDEV_EVT_ALUA_STATE_CHANGE_REPORTED; + sdev_printk(KERN_WARNING, sdev, + "ALUA state has changed"); } else if (sshdr->asc == 0x2a && sshdr->ascq == 0x09) { evt_type = SDEV_EVT_CAPACITY_CHANGE_REPORTED; sdev_printk(KERN_WARNING, sdev, diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b1a2631..2428d96 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2698,6 +2698,9 @@ static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt) case SDEV_EVT_CAPACITY_CHANGE_REPORTED: envp[idx++] = "SDEV_UA=CAPACITY_DATA_HAS_CHANGED"; break; + case SDEV_EVT_ALUA_STATE_CHANGE_REPORTED: + envp[idx++] = "SDEV_UA=ALUA_STATE_HAS_CHANGED"; + break; case SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED: envp[idx++] = "SDEV_UA=THIN_PROVISIONING_SOFT_THRESHOLD_REACHED"; break; @@ -2807,6 +2810,7 @@ struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type, case SDEV_EVT_MEDIA_CHANGE: case SDEV_EVT_INQUIRY_CHANGE_REPORTED: case SDEV_EVT_CAPACITY_CHANGE_REPORTED: + case SDEV_EVT_ALUA_STATE_CHANGE_REPORTED: case SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED: case SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED: case SDEV_EVT_LUN_CHANGE_REPORTED: diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index a4c9336..5d7553f 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -53,6 +53,7 @@ enum scsi_device_state { enum scsi_device_event { SDEV_EVT_MEDIA_CHANGE = 1,/* media has changed */ SDEV_EVT_INQUIRY_CHANGE_REPORTED, /* 3F 03 UA reported */ + SDEV_EVT_ALUA_STATE_CHANGE_REPORTED,/* 2A 06 UA reported */ SDEV_EVT_CAPACITY_CHANGE_REPORTED, /* 2A 09 UA reported */ SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED, /* 38 07 UA reported */ SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED,/* 2A 01 UA reported */ -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
On Fri, Mar 21, 2014 at 2:08 PM, Arvind Kumar wrote: > The driver is missing calls to pci_dma_mapping_error() after > performing the DMA mapping, which caused DMA-API warning to > show up in dmesg's output. Though that happens only when > DMA_API_DEBUG option is enabled. This change fixes the issue > and makes pvscsi_map_buffers() function more robust. > > Signed-off-by: Arvind Kumar > Cc: Josh Boyer This patch has been sent and pinged for 3 months now. It's gotten no comments at all. Should we send it to Linus so it actually gets picked up? josh > --- > drivers/scsi/vmw_pvscsi.c | 45 > +++-- > drivers/scsi/vmw_pvscsi.h |2 +- > 2 files changed, 40 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c > index c88e146..9478a00 100644 > --- a/drivers/scsi/vmw_pvscsi.c > +++ b/drivers/scsi/vmw_pvscsi.c > @@ -349,9 +349,9 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, > * Map all data buffers for a command into PCI space and > * setup the scatter/gather list if needed. > */ > -static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, > - struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, > - struct PVSCSIRingReqDesc *e) > +static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, > + struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, > + struct PVSCSIRingReqDesc *e) > { > unsigned count; > unsigned bufflen = scsi_bufflen(cmd); > @@ -360,18 +360,30 @@ static void pvscsi_map_buffers(struct pvscsi_adapter > *adapter, > e->dataLen = bufflen; > e->dataAddr = 0; > if (bufflen == 0) > - return; > + return 0; > > sg = scsi_sglist(cmd); > count = scsi_sg_count(cmd); > if (count != 0) { > int segs = scsi_dma_map(cmd); > - if (segs > 1) { > + > + if (segs == -ENOMEM) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map cmd sglist for > DMA.\n"); > + return -1; > + } else if (segs > 1) { > pvscsi_create_sg(ctx, sg, segs); > > e->flags |= PVSCSI_FLAG_CMD_WITH_SG_LIST; > ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, > SGL_SIZE, > PCI_DMA_TODEVICE); > + if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map ctx > sglist for DMA.\n"); > + scsi_dma_unmap(cmd); > + ctx->sglPA = 0; > + return -1; > + } > e->dataAddr = ctx->sglPA; > } else > e->dataAddr = sg_dma_address(sg); > @@ -382,8 +394,15 @@ static void pvscsi_map_buffers(struct pvscsi_adapter > *adapter, > */ > ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, > cmd->sc_data_direction); > + if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map direct data > buffer for DMA.\n"); > + return -1; > + } > e->dataAddr = ctx->dataPA; > } > + > + return 0; > } > > static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, > @@ -712,6 +731,12 @@ static int pvscsi_queue_ring(struct pvscsi_adapter > *adapter, > ctx->sensePA = pci_map_single(adapter->dev, cmd->sense_buffer, > SCSI_SENSE_BUFFERSIZE, > PCI_DMA_FROMDEVICE); > + if (pci_dma_mapping_error(adapter->dev, ctx->sensePA)) { > + scmd_printk(KERN_ERR, cmd, > + "vmw_pvscsi: Failed to map sense buffer > for DMA.\n"); > + ctx->sensePA = 0; > + return -1; > + } > e->senseAddr = ctx->sensePA; > e->senseLen = SCSI_SENSE_BUFFERSIZE; > } else { > @@ -737,7 +762,15 @@ static int pvscsi_queue_ring(struct pvscsi_adapter > *adapter, > else > e->flags = 0; > > - pvscsi_map_buffers(adapter, ctx, cmd, e); > + if (pvscsi_map_buffers(adapter, ctx, cmd, e) != 0) { > + if (cmd->sense_buffer) { > + pci_unmap_single(adapter->dev, ctx->sensePA, > +SCSI
Re: [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
On Thu, 2015-06-11 at 08:32 -0400, Josh Boyer wrote: > On Fri, Mar 21, 2014 at 2:08 PM, Arvind Kumar wrote: > > The driver is missing calls to pci_dma_mapping_error() after > > performing the DMA mapping, which caused DMA-API warning to > > show up in dmesg's output. Though that happens only when > > DMA_API_DEBUG option is enabled. This change fixes the issue > > and makes pvscsi_map_buffers() function more robust. > > > > Signed-off-by: Arvind Kumar > > Cc: Josh Boyer > > This patch has been sent and pinged for 3 months now. It's gotten no > comments at all. Should we send it to Linus so it actually gets > picked up? It's waiting for someone to review it. If you're interested in it, have you reviewed it? In which case just add your reviewed by and we're ready to go. 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] megaraid_sas : Pass driver version to firmware inside IOC init frame
On 06/10/2015 12:22 PM, sumit.sax...@avagotech.com wrote: Here should be an explanation why is this needed. The driver knows the fw version and can adapt to it. When sending the version to firmware fails, the driver just logs it and is able to continue. Why is the information needed for the fw ? I fear that after several iterations we will have a table of corresponding driver/fw versions that driver will send down to fw make it work... Tomas > Signed-off-by: Sumit Saxena > --- > drivers/scsi/megaraid/megaraid_sas.h| 10 +++--- > drivers/scsi/megaraid/megaraid_sas_base.c | 18 ++ > drivers/scsi/megaraid/megaraid_sas_fusion.c |7 +++ > 3 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/megaraid/megaraid_sas.h > b/drivers/scsi/megaraid/megaraid_sas.h > index 20c3754..5bd4d30 100644 > --- a/drivers/scsi/megaraid/megaraid_sas.h > +++ b/drivers/scsi/megaraid/megaraid_sas.h > @@ -1038,6 +1038,7 @@ struct megasas_ctrl_info { > #define MEGASAS_MAX_LD_IDS (MEGASAS_MAX_LD_CHANNELS * \ > MEGASAS_MAX_DEV_PER_CHANNEL) > > +#define MEGASAS_MAX_NAME32 > #define MEGASAS_MAX_SECTORS(2*1024) > #define MEGASAS_MAX_SECTORS_IEEE (2*128) > #define MEGASAS_DBG_LVL 1 > @@ -1264,17 +1265,18 @@ struct megasas_init_frame { > __le32 pad_0; /*0Ch */ > > __le16 flags; /*10h */ > - __le16 reserved_3; /*12h */ > + __le16 reserved_2; /*12h */ > __le32 data_xfer_len; /*14h */ > > __le32 queue_info_new_phys_addr_lo; /*18h */ > __le32 queue_info_new_phys_addr_hi; /*1Ch */ > __le32 queue_info_old_phys_addr_lo; /*20h */ > __le32 queue_info_old_phys_addr_hi; /*24h */ > - __le32 reserved_4[2]; /*28h */ > + __le32 driver_ver_lo; /*28h */ > + __le32 driver_ver_hi; /*2Ch */ > __le32 system_info_lo; /*30h */ > __le32 system_info_hi; /*34h */ > - __le32 reserved_5[2]; /*38h */ > + __le32 reserved_3[2]; /*38h */ > > } __attribute__ ((packed)); > > @@ -1665,6 +1667,8 @@ struct megasas_instance { > dma_addr_t producer_h; > __le32 *consumer; > dma_addr_t consumer_h; > + __le32 *verbuf; > + dma_addr_t verbuf_h; > struct MR_DRV_SYSTEM_INFO *system_info_buf; > dma_addr_t system_info_h; > struct MR_LD_VF_AFFILIATION *vf_affiliation; > diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c > b/drivers/scsi/megaraid/megaraid_sas_base.c > index a022c39..6bfb3eb 100644 > --- a/drivers/scsi/megaraid/megaraid_sas_base.c > +++ b/drivers/scsi/megaraid/megaraid_sas_base.c > @@ -4252,6 +4252,14 @@ megasas_issue_init_mfi(struct megasas_instance > *instance) > > init_frame->cmd = MFI_CMD_INIT; > init_frame->cmd_status = MFI_STAT_INVALID_STATUS; > + > + if (instance->verbuf) { > + snprintf((char *)instance->verbuf, strlen(MEGASAS_VERSION) + 2, > "%s\n", > + MEGASAS_VERSION); > + init_frame->driver_ver_lo = cpu_to_le32(instance->verbuf_h); > + init_frame->driver_ver_hi = 0; > + } > + > init_frame->queue_info_new_phys_addr_lo = > cpu_to_le32(lower_32_bits(initq_info_h)); > init_frame->queue_info_new_phys_addr_hi = > @@ -5257,6 +5265,12 @@ static int megasas_probe_one(struct pci_dev *pdev, > break; > } > > + instance->verbuf = pci_alloc_consistent(pdev, > + MEGASAS_MAX_NAME * sizeof(u32), > + &instance->verbuf_h); > + if (!instance->verbuf) > + dev_info(&instance->pdev->dev, "Can't allocate version > buffer\n"); > + > instance->system_info_buf = pci_zalloc_consistent(pdev, > sizeof(struct MR_DRV_SYSTEM_INFO), > &instance->system_info_h); > @@ -5838,6 +5852,10 @@ static void megasas_detach_one(struct pci_dev *pdev) > pci_free_consistent(pdev, sizeof(struct MR_DRV_SYSTEM_INFO), > instance->system_info_buf, > instance->system_info_h); > > + if (instance->verbuf) > + pci_free_consistent(pdev, MEGASAS_MAX_NAME * sizeof(u32), > + instance->verbuf, instance->verbuf_h); > + > scsi_host_put(host); > > pci_disable_device(pdev); > diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c > b/drivers/scsi/megaraid/megaraid_sas_fusion.c > index 0637f42..359d605 100644 > --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c > +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c > @@ -671,6 +671,13 @@ megasas_ioc_init_fusion(struct megasas_instance > *instance) > /* Convert capability to LE32 */ > cpu_to_le32s(
Re: [PATCH 0/2] target: 64-bit LUN support
On 06/10/15 22:56, Hannes Reinecke wrote: Actually, I've been thinking about this. Currently I'm not sure if we should fully embrace this route; after all, 'scsilun_to_int' is meant to be a conversion from the (abstract) LUN number into our internal representation. And as it's internal we're free to use whatever we like. Where we need to fix up things is in reporting; whenever we display LUN numbers to userspace (printk or sysfs-wise) we probably should use the appropriate format. I'll see if I can whip up a printk format for this. Never liked the '%llu' format for LUNs anyway. Hello Hannes, Making how LUNs are displayed dependent on the LUN addressing method sounds like a good idea to me. One step further would be to ensure that the format in which LUNs are entered through configfs matches the format used to display LUNs. This may require to add an additional configuration parameter in configfs for the LUN addressing format. E.g. for users who connect an AIX initiator system to LIO it would be much more convenient to use LUN numbers like 1, 2, 3 instead of the raw LUN numbers 256, 512, 768. Thanks, Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] scsi: Add ALUA state change UA handling
On Thu, 2015-06-11 at 13:07 +0200, Hannes Reinecke wrote: > Log the ALUA state change unit attention correctly with > the message log and emit an event to allow user-space > tools to react to it. > > Signed-off-by: Hannes Reinecke > --- > drivers/scsi/scsi_error.c | 4 > drivers/scsi/scsi_lib.c| 4 > include/scsi/scsi_device.h | 1 + > 3 files changed, 9 insertions(+) > > diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c > index c95a4e9..ad32bc0 100644 > --- a/drivers/scsi/scsi_error.c > +++ b/drivers/scsi/scsi_error.c > @@ -421,6 +421,10 @@ static void scsi_report_sense(struct scsi_device *sdev, > evt_type = SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED; > sdev_printk(KERN_WARNING, sdev, > "Mode parameters changed"); > + } else if (sshdr->asc == 0x2a && sshdr->ascq == 0x06) { > + evt_type = SDEV_EVT_ALUA_STATE_CHANGE_REPORTED; > + sdev_printk(KERN_WARNING, sdev, > + "ALUA state has changed"); Would you mind changing this to "Asymmetic access state changed", since that is the actual text in the T10 spec? > } else if (sshdr->asc == 0x2a && sshdr->ascq == 0x09) { > evt_type = SDEV_EVT_CAPACITY_CHANGE_REPORTED; > sdev_printk(KERN_WARNING, sdev, > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index b1a2631..2428d96 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -2698,6 +2698,9 @@ static void scsi_evt_emit(struct scsi_device *sdev, > struct scsi_event *evt) > case SDEV_EVT_CAPACITY_CHANGE_REPORTED: > envp[idx++] = "SDEV_UA=CAPACITY_DATA_HAS_CHANGED"; > break; > + case SDEV_EVT_ALUA_STATE_CHANGE_REPORTED: > + envp[idx++] = "SDEV_UA=ALUA_STATE_HAS_CHANGED"; And could you change this to "ASYMMETRIC_ACCESS_STATE_HAS_CHANGED"? > + break; > case SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED: > envp[idx++] = "SDEV_UA=THIN_PROVISIONING_SOFT_THRESHOLD_REACHED"; > break; > @@ -2807,6 +2810,7 @@ struct scsi_event *sdev_evt_alloc(enum > scsi_device_event evt_type, > case SDEV_EVT_MEDIA_CHANGE: > case SDEV_EVT_INQUIRY_CHANGE_REPORTED: > case SDEV_EVT_CAPACITY_CHANGE_REPORTED: > + case SDEV_EVT_ALUA_STATE_CHANGE_REPORTED: > case SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED: > case SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED: > case SDEV_EVT_LUN_CHANGE_REPORTED: > diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h > index a4c9336..5d7553f 100644 > --- a/include/scsi/scsi_device.h > +++ b/include/scsi/scsi_device.h > @@ -53,6 +53,7 @@ enum scsi_device_state { > enum scsi_device_event { > SDEV_EVT_MEDIA_CHANGE = 1,/* media has changed */ > SDEV_EVT_INQUIRY_CHANGE_REPORTED, /* 3F 03 UA reported */ > + SDEV_EVT_ALUA_STATE_CHANGE_REPORTED,/* 2A 06 UA reported */ > SDEV_EVT_CAPACITY_CHANGE_REPORTED, /* 2A 09 UA reported */ > SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED, /* 38 07 UA reported */ > SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED,/* 2A 01 UA reported */ Seems like a good idea. As I mentioned yesterday, I have a patch set that rescans the device when the ALUA state transitions to an ACTIVE state, if the capacity could not be obtained when the device was previously probed. This could be made more generalized, too. But I don't have the HW to test it, and I'm waiting for the vendor to get back to me. Reviewed-by: Ewan D. Milne -- 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: retry MODE SENSE on unit attention
On Thu, 2015-06-11 at 13:01 +0200, Hannes Reinecke wrote: > The 'sd' driver is calling scsi_mode_sense() to figure out > internal details. But scsi_mode_sense() never checks for > any pending unit attentions, so we're getting annoying error > messages like: > > MODE SENSE: unimplemented page/subpage: 0x00/0x00 > > and a possible wrong decision for device cache handling. > > Signed-off-by: Hannes Reinecke > --- > drivers/scsi/scsi_lib.c | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index 2428d96..d7915c8 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -2423,7 +2423,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int > modepage, > unsigned char cmd[12]; > int use_10_for_ms; > int header_length; > - int result; > + int result, retry_count = retries; > struct scsi_sense_hdr my_sshdr; > > memset(data, 0, sizeof(*data)); > @@ -2502,6 +2502,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int > modepage, > data->block_descriptor_length = buffer[3]; > } > data->header_length = header_length; > + } else if ((status_byte(result) == CHECK_CONDITION) && > +scsi_sense_valid(sshdr) && > +sshdr->sense_key == UNIT_ATTENTION && retry_count) { > + retry_count--; > + goto retry; > } > > return result; Great, but shouldn't we be doing this more generally? What about scsi_mode_select()? (And, with the number of status changes that can get reported by UAs, we might want to think about increasing the retry count on these commands up from 3 at some point.) Reviewed-by: Ewan D. Milne -- 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 4/9] [SCSI] aacraid: Enable 64-bit write to controller register
Hello Johannes, My comments are inline. Thanks, -Raj P. -Original Message- From: Johannes Thumshirn [mailto:jthumsh...@suse.de] Sent: Thursday, June 11, 2015 3:02 AM To: Rajinikanth Pandurangan Cc: jbottom...@parallels.com; linux-scsi@vger.kernel.org; aacr...@pmc-sierra.com; Harry Yang; Mahesh Rajashekhara; Rich Bono; Achim Leubner; Murthy Bhat Subject: Re: [Patch V2 4/9] [SCSI] aacraid: Enable 64-bit write to controller register On Wed, Jun 10, 2015 at 06:42:26PM -0700, rajinikanth.panduran...@pmcs.com wrote: > From: Rajinikanth Pandurangan > > Description: > If writeq() not supported, then do atomic two 32bit write > > 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) > +#define src_writeq(AEP, CSR, value) writeq(value, \ > + &((AEP)->regs.src.bar0->CSR)) > +#endif > > #define SRC_ODR_SHIFT12 > #define SRC_IDR_SHIFT9 > @@ -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 e0a76d5..e4ff47e 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; > } Why not make src_writeq() a wrapper over either writeq() or spin_lock_irqsave(); src_writel() x2; spin_unlock_irqrestore(), depending on the presence of writeq? [RajP] Yes, agreed. Will include it in our next submission. > > -- > 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 -- Johannes Thumshirn Storage jthumsh...@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- 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: [Pv-drivers] [PATCH] VMW_PVSCSI: Fix the issue of DMA-API related warnings.
On 06/11/2015 02:32 PM, Josh Boyer wrote: > On Fri, Mar 21, 2014 at 2:08 PM, Arvind Kumar wrote: >> The driver is missing calls to pci_dma_mapping_error() after >> performing the DMA mapping, which caused DMA-API warning to >> show up in dmesg's output. Though that happens only when >> DMA_API_DEBUG option is enabled. This change fixes the issue >> and makes pvscsi_map_buffers() function more robust. >> >> Signed-off-by: Arvind Kumar >> Cc: Josh Boyer > This patch has been sent and pinged for 3 months now. It's gotten no > comments at all. Should we send it to Linus so it actually gets > picked up? > > josh Reviewed-by: Thomas Hellstrom > >> --- >> drivers/scsi/vmw_pvscsi.c | 45 >> +++-- >> drivers/scsi/vmw_pvscsi.h |2 +- >> 2 files changed, 40 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c >> index c88e146..9478a00 100644 >> --- a/drivers/scsi/vmw_pvscsi.c >> +++ b/drivers/scsi/vmw_pvscsi.c >> @@ -349,9 +349,9 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, >> * Map all data buffers for a command into PCI space and >> * setup the scatter/gather list if needed. >> */ >> -static void pvscsi_map_buffers(struct pvscsi_adapter *adapter, >> - struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, >> - struct PVSCSIRingReqDesc *e) >> +static int pvscsi_map_buffers(struct pvscsi_adapter *adapter, >> + struct pvscsi_ctx *ctx, struct scsi_cmnd *cmd, >> + struct PVSCSIRingReqDesc *e) >> { >> unsigned count; >> unsigned bufflen = scsi_bufflen(cmd); >> @@ -360,18 +360,30 @@ static void pvscsi_map_buffers(struct pvscsi_adapter >> *adapter, >> e->dataLen = bufflen; >> e->dataAddr = 0; >> if (bufflen == 0) >> - return; >> + return 0; >> >> sg = scsi_sglist(cmd); >> count = scsi_sg_count(cmd); >> if (count != 0) { >> int segs = scsi_dma_map(cmd); >> - if (segs > 1) { >> + >> + if (segs == -ENOMEM) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map cmd sglist >> for DMA.\n"); >> + return -1; >> + } else if (segs > 1) { >> pvscsi_create_sg(ctx, sg, segs); >> >> e->flags |= PVSCSI_FLAG_CMD_WITH_SG_LIST; >> ctx->sglPA = pci_map_single(adapter->dev, ctx->sgl, >> SGL_SIZE, >> PCI_DMA_TODEVICE); >> + if (pci_dma_mapping_error(adapter->dev, ctx->sglPA)) >> { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map ctx >> sglist for DMA.\n"); >> + scsi_dma_unmap(cmd); >> + ctx->sglPA = 0; >> + return -1; >> + } >> e->dataAddr = ctx->sglPA; >> } else >> e->dataAddr = sg_dma_address(sg); >> @@ -382,8 +394,15 @@ static void pvscsi_map_buffers(struct pvscsi_adapter >> *adapter, >> */ >> ctx->dataPA = pci_map_single(adapter->dev, sg, bufflen, >> cmd->sc_data_direction); >> + if (pci_dma_mapping_error(adapter->dev, ctx->dataPA)) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map direct data >> buffer for DMA.\n"); >> + return -1; >> + } >> e->dataAddr = ctx->dataPA; >> } >> + >> + return 0; >> } >> >> static void pvscsi_unmap_buffers(const struct pvscsi_adapter *adapter, >> @@ -712,6 +731,12 @@ static int pvscsi_queue_ring(struct pvscsi_adapter >> *adapter, >> ctx->sensePA = pci_map_single(adapter->dev, >> cmd->sense_buffer, >> SCSI_SENSE_BUFFERSIZE, >> PCI_DMA_FROMDEVICE); >> + if (pci_dma_mapping_error(adapter->dev, ctx->sensePA)) { >> + scmd_printk(KERN_ERR, cmd, >> + "vmw_pvscsi: Failed to map sense buffer >> for DMA.\n"); >> + ctx->sensePA = 0; >> + return -1; >> + } >> e->senseAddr = ctx->sensePA; >> e->senseLen = SCSI_SENSE_BUFFERSIZE; >> } else { >> @@ -737,7 +762,15 @@ static int pvscsi_queue_ring(struct pvscsi_adapter >> *adapter, >> else >> e->flags = 0; >> >> - pvscsi_map_buffers(adapter, ctx, cmd, e); >> + if (pvscsi_m
Re: [PATCH v6] cxlflash: Base support for IBM CXL Flash Adapter
On 06/09/2015 05:15 PM, Matthew R. Ochs wrote: > SCSI device driver to support filesystem access on the IBM CXL Flash adapter. > > Supported-by: Stephen Bates > Reviewed-by: Michael Neuling > Signed-off-by: Matthew R. Ochs > Signed-off-by: Manoj N. Kumar Reviewed-by: Brian King Hi James, This driver is dependent on a bunch of core cxl support going in the powerpc tree. Are you OK with this going through the powerpc tree so they can both go in a single pull request to Linus? Are there any additional discussion points or issues you think need to be resolved before that happens, or should Michael look at queuing this up for -next? Thanks, Brian -- Brian King Power Linux I/O IBM Linux Technology Center -- 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] bfa: fix leak of bfad_im_port_index on module unload
Resources allocated within bfad_im_port_index idr are not deallocated on module unload. The patch adds idr_destroy() in exit function. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/scsi/bfa/bfad_im.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 7223b0006740..8367c11d554b 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -851,6 +851,8 @@ bfad_im_module_exit(void) if (bfad_im_scsi_vport_transport_template) fc_release_transport(bfad_im_scsi_vport_transport_template); + + idr_destroy(&bfad_im_port_index); } void -- 1.9.1 -- 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 2/4] ipr: Byte swapping for device_id attribute in sysfs
From: Wen Xiong On LE system, users see the wrong device_id attribute. This patch does necessary byte swapping for device_id attribute and works on both of LE and BE systems. Signed-off-by: Wen Xiong Signed-off-by: Brian King --- drivers/scsi/ipr.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff -puN drivers/scsi/ipr.c~ipr_device_id_swap drivers/scsi/ipr.c --- linux/drivers/scsi/ipr.c~ipr_device_id_swap 2015-06-11 20:18:26.578563454 -0500 +++ linux-bjking1/drivers/scsi/ipr.c2015-06-11 20:33:52.946558852 -0500 @@ -4449,7 +4449,7 @@ static ssize_t ipr_show_device_id(struct spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); res = (struct ipr_resource_entry *)sdev->hostdata; if (res && ioa_cfg->sis64) - len = snprintf(buf, PAGE_SIZE, "0x%llx\n", res->dev_id); + len = snprintf(buf, PAGE_SIZE, "0x%llx\n", be64_to_cpu(res->dev_id)); else if (res) len = snprintf(buf, PAGE_SIZE, "0x%llx\n", res->lun_wwn); _ -- 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 4/4] ipr: Driver version 2.6.2
Bump driver version. Signed-off-by: Brian King --- drivers/scsi/ipr.h |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN drivers/scsi/ipr.h~ipr_version_2_6_2 drivers/scsi/ipr.h --- linux/drivers/scsi/ipr.h~ipr_version_2_6_2 2015-06-11 20:11:35.110136508 -0500 +++ linux-bjking1/drivers/scsi/ipr.h2015-06-11 20:11:45.055050007 -0500 @@ -39,8 +39,8 @@ /* * Literals */ -#define IPR_DRIVER_VERSION "2.6.1" -#define IPR_DRIVER_DATE "(March 12, 2015)" +#define IPR_DRIVER_VERSION "2.6.2" +#define IPR_DRIVER_DATE "(June 11, 2015)" /* * 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 3/4] ipr: Endian / sparse fixes
Some misc fixes for endianness checking with sparse so sparse with endian checking now runs clean. Fixes a minor bug in the process which was uncovered by sparse which would result in unnecessary error recovery for check conditions. Signed-off-by: Brian King --- drivers/scsi/ipr.c | 13 +++-- drivers/scsi/ipr.h | 13 ++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff -puN drivers/scsi/ipr.h~ipr_endian_fixes drivers/scsi/ipr.h --- linux/drivers/scsi/ipr.h~ipr_endian_fixes 2015-06-11 20:18:29.102541573 -0500 +++ linux-bjking1/drivers/scsi/ipr.h2015-06-11 20:18:29.112541485 -0500 @@ -1007,13 +1007,13 @@ struct ipr_hostrcb_type_24_error { struct ipr_hostrcb_type_07_error { u8 failure_reason[64]; struct ipr_vpd vpd; - u32 data[222]; + __be32 data[222]; }__attribute__((packed, aligned (4))); struct ipr_hostrcb_type_17_error { u8 failure_reason[64]; struct ipr_ext_vpd vpd; - u32 data[476]; + __be32 data[476]; }__attribute__((packed, aligned (4))); struct ipr_hostrcb_config_element { @@ -1291,18 +1291,17 @@ struct ipr_resource_entry { (((res)->bus << 24) | ((res)->target << 8) | (res)->lun) u8 ata_class; - - u8 flags; - __be16 res_flags; - u8 type; + u16 flags; + u16 res_flags; + u8 qmodel; struct ipr_std_inq_data std_inq_data; __be32 res_handle; __be64 dev_id; - __be64 lun_wwn; + u64 lun_wwn; struct scsi_lun dev_lun; u8 res_path[8]; diff -puN drivers/scsi/ipr.c~ipr_endian_fixes drivers/scsi/ipr.c --- linux/drivers/scsi/ipr.c~ipr_endian_fixes 2015-06-11 20:18:29.107541529 -0500 +++ linux-bjking1/drivers/scsi/ipr.c2015-06-11 20:18:29.121541408 -0500 @@ -1159,7 +1159,8 @@ static void ipr_init_res_entry(struct ip if (ioa_cfg->sis64) { proto = cfgtew->u.cfgte64->proto; - res->res_flags = cfgtew->u.cfgte64->res_flags; + res->flags = be16_to_cpu(cfgtew->u.cfgte64->flags); + res->res_flags = be16_to_cpu(cfgtew->u.cfgte64->res_flags); res->qmodel = IPR_QUEUEING_MODEL64(res); res->type = cfgtew->u.cfgte64->res_type; @@ -1307,8 +1308,8 @@ static void ipr_update_res_entry(struct int new_path = 0; if (res->ioa_cfg->sis64) { - res->flags = cfgtew->u.cfgte64->flags; - res->res_flags = cfgtew->u.cfgte64->res_flags; + res->flags = be16_to_cpu(cfgtew->u.cfgte64->flags); + res->res_flags = be16_to_cpu(cfgtew->u.cfgte64->res_flags); res->type = cfgtew->u.cfgte64->res_type; memcpy(&res->std_inq_data, &cfgtew->u.cfgte64->std_inq_data, @@ -1894,7 +1895,7 @@ static void ipr_log_array_error(struct i * Return value: * none **/ -static void ipr_log_hex_data(struct ipr_ioa_cfg *ioa_cfg, u32 *data, int len) +static void ipr_log_hex_data(struct ipr_ioa_cfg *ioa_cfg, __be32 *data, int len) { int i; @@ -2264,7 +2265,7 @@ static void ipr_log_fabric_error(struct ((unsigned long)fabric + be16_to_cpu(fabric->length)); } - ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len); + ipr_log_hex_data(ioa_cfg, (__be32 *)fabric, add_len); } /** @@ -2358,7 +2359,7 @@ static void ipr_log_sis64_fabric_error(s ((unsigned long)fabric + be16_to_cpu(fabric->length)); } - ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len); + ipr_log_hex_data(ioa_cfg, (__be32 *)fabric, add_len); } /** _ -- 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 1/4] ipr: Fix locking for unit attention handling
Make sure we have the host lock held when calling scsi_report_bus_reset. Fixes a crash seen as the __devices list in the scsi host was changing as we were iterating through it. Cc: Signed-off-by: Brian King --- drivers/scsi/ipr.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff -puN drivers/scsi/ipr.c~ipr_erp_start_locking drivers/scsi/ipr.c --- linux/drivers/scsi/ipr.c~ipr_erp_start_locking 2015-06-11 20:18:13.806674185 -0500 +++ linux-bjking1/drivers/scsi/ipr.c2015-06-11 20:18:13.814674115 -0500 @@ -6263,21 +6263,23 @@ static void ipr_scsi_done(struct ipr_cmn struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd; u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc); - unsigned long hrrq_flags; + unsigned long lock_flags; scsi_set_resid(scsi_cmd, be32_to_cpu(ipr_cmd->s.ioasa.hdr.residual_data_len)); if (likely(IPR_IOASC_SENSE_KEY(ioasc) == 0)) { scsi_dma_unmap(scsi_cmd); - spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags); + spin_lock_irqsave(ipr_cmd->hrrq->lock, lock_flags); list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q); scsi_cmd->scsi_done(scsi_cmd); - spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags); + spin_unlock_irqrestore(ipr_cmd->hrrq->lock, lock_flags); } else { - spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags); + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + spin_lock(&ipr_cmd->hrrq->_lock); ipr_erp_start(ioa_cfg, ipr_cmd); - spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags); + spin_unlock(&ipr_cmd->hrrq->_lock); + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); } } _ -- 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: retry MODE SENSE on unit attention
On 06/11/2015 05:07 PM, Ewan Milne wrote: > On Thu, 2015-06-11 at 13:01 +0200, Hannes Reinecke wrote: >> The 'sd' driver is calling scsi_mode_sense() to figure out >> internal details. But scsi_mode_sense() never checks for >> any pending unit attentions, so we're getting annoying error >> messages like: >> >> MODE SENSE: unimplemented page/subpage: 0x00/0x00 >> >> and a possible wrong decision for device cache handling. >> >> Signed-off-by: Hannes Reinecke >> --- >> drivers/scsi/scsi_lib.c | 7 ++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >> index 2428d96..d7915c8 100644 >> --- a/drivers/scsi/scsi_lib.c >> +++ b/drivers/scsi/scsi_lib.c >> @@ -2423,7 +2423,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int >> modepage, >> unsigned char cmd[12]; >> int use_10_for_ms; >> int header_length; >> -int result; >> +int result, retry_count = retries; >> struct scsi_sense_hdr my_sshdr; >> >> memset(data, 0, sizeof(*data)); >> @@ -2502,6 +2502,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, >> int modepage, >> data->block_descriptor_length = buffer[3]; >> } >> data->header_length = header_length; >> +} else if ((status_byte(result) == CHECK_CONDITION) && >> + scsi_sense_valid(sshdr) && >> + sshdr->sense_key == UNIT_ATTENTION && retry_count) { >> +retry_count--; >> +goto retry; >> } >> >> return result; > > Great, but shouldn't we be doing this more generally? What about > scsi_mode_select()? > I haven't seen any issues with scsi_mode_select() as of now, so I didn't do anything about this :-) > (And, with the number of status changes that can get reported by > UAs, we might want to think about increasing the retry count on > these commands up from 3 at some point.) > Hmm. _Actually_, we're not getting _more_ UAs (neither the number nor the situation at which UAs are being send has changed). It's just that we're trying to _use_ UAs so these things pop up. But yeah, raising the number or retries to eg 5 is probably a good idea. > Reviewed-by: Ewan D. Milne > Cheers, Hannes -- Dr. Hannes ReineckezSeries & Storage h...@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- 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] mvsas: always iounmap resources
On 05/22/2015 11:15 AM, Johannes Thumshirn wrote: > In case pci_resource_start() or pci_resource_len() reutrn 0, mvsas_ioremap > returns without doing an iounmap() of mvi->regs_ex. > > Found by the cocinelle tool. > > Signed-off-by: Johannes Thumshirn > --- > drivers/scsi/mvsas/mv_init.c | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c > index 53030b0..04a3205 100644 > --- a/drivers/scsi/mvsas/mv_init.c > +++ b/drivers/scsi/mvsas/mv_init.c > @@ -339,8 +339,11 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int > bar_ex) > > res_start = pci_resource_start(pdev, bar); > res_len = pci_resource_len(pdev, bar); > - if (!res_start || !res_len) > + if (!res_start || !res_len) { > + iounmap(mvi->regs_ex); > + mvi->regs_ex = NULL; > goto err_out; > + } > > res_flag = pci_resource_flags(pdev, bar); > if (res_flag & IORESOURCE_CACHEABLE) > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckezSeries & Storage h...@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- 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] megaraid_sas : Pass driver version to firmware inside IOC init frame
>-Original Message- >From: Tomas Henzl [mailto:the...@redhat.com] >Sent: Thursday, June 11, 2015 7:26 PM >To: sumit.sax...@avagotech.com; linux-scsi@vger.kernel.org >Cc: martin.peter...@oracle.com; h...@infradead.org; >jbottom...@parallels.com; kashyap.de...@avagotech.com >Subject: Re: [PATCH] megaraid_sas : Pass driver version to firmware inside >IOC init frame > >On 06/10/2015 12:22 PM, sumit.sax...@avagotech.com wrote: > >Here should be an explanation why is this needed. > >The driver knows the fw version and can adapt to it. >When sending the version to firmware fails, the driver just logs it and is able to >continue. >Why is the information needed for the fw ? Intent here is to have driver version string in firmware logs and it can help to align driver and firmware logs during debugging. One of Avago's customer has requested driver version to be displayed in firmware logs. This code has been part of inhouse driver for long time but was missed to be submitted to upstream. Since this is helpful for debugging not a fatal in functional area so if memory allocation for version buffer fails still driver continues. > >I fear that after several iterations we will have a table of corresponding >driver/fw versions that driver will send down to fw make it work... > >Tomas > > >> Signed-off-by: Sumit Saxena >> --- >> drivers/scsi/megaraid/megaraid_sas.h| 10 +++--- >> drivers/scsi/megaraid/megaraid_sas_base.c | 18 ++ >> drivers/scsi/megaraid/megaraid_sas_fusion.c |7 +++ >> 3 files changed, 32 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/scsi/megaraid/megaraid_sas.h >> b/drivers/scsi/megaraid/megaraid_sas.h >> index 20c3754..5bd4d30 100644 >> --- a/drivers/scsi/megaraid/megaraid_sas.h >> +++ b/drivers/scsi/megaraid/megaraid_sas.h >> @@ -1038,6 +1038,7 @@ struct megasas_ctrl_info { >> #define MEGASAS_MAX_LD_IDS > (MEGASAS_MAX_LD_CHANNELS * \ >> > MEGASAS_MAX_DEV_PER_CHANNEL) >> >> +#define MEGASAS_MAX_NAME32 >> #define MEGASAS_MAX_SECTORS(2*1024) >> #define MEGASAS_MAX_SECTORS_IEEE(2*128) >> #define MEGASAS_DBG_LVL 1 >> @@ -1264,17 +1265,18 @@ struct megasas_init_frame { >> __le32 pad_0; /*0Ch */ >> >> __le16 flags; /*10h */ >> -__le16 reserved_3; /*12h */ >> +__le16 reserved_2; /*12h */ >> __le32 data_xfer_len; /*14h */ >> >> __le32 queue_info_new_phys_addr_lo; /*18h */ >> __le32 queue_info_new_phys_addr_hi; /*1Ch */ >> __le32 queue_info_old_phys_addr_lo; /*20h */ >> __le32 queue_info_old_phys_addr_hi; /*24h */ >> -__le32 reserved_4[2]; /*28h */ >> +__le32 driver_ver_lo; /*28h */ >> +__le32 driver_ver_hi; /*2Ch */ >> __le32 system_info_lo; /*30h */ >> __le32 system_info_hi; /*34h */ >> -__le32 reserved_5[2]; /*38h */ >> +__le32 reserved_3[2]; /*38h */ >> >> } __attribute__ ((packed)); >> >> @@ -1665,6 +1667,8 @@ struct megasas_instance { >> dma_addr_t producer_h; >> __le32 *consumer; >> dma_addr_t consumer_h; >> +__le32 *verbuf; >> +dma_addr_t verbuf_h; >> struct MR_DRV_SYSTEM_INFO *system_info_buf; >> dma_addr_t system_info_h; >> struct MR_LD_VF_AFFILIATION *vf_affiliation; diff --git >> a/drivers/scsi/megaraid/megaraid_sas_base.c >> b/drivers/scsi/megaraid/megaraid_sas_base.c >> index a022c39..6bfb3eb 100644 >> --- a/drivers/scsi/megaraid/megaraid_sas_base.c >> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c >> @@ -4252,6 +4252,14 @@ megasas_issue_init_mfi(struct megasas_instance >> *instance) >> >> init_frame->cmd = MFI_CMD_INIT; >> init_frame->cmd_status = MFI_STAT_INVALID_STATUS; >> + >> +if (instance->verbuf) { >> +snprintf((char *)instance->verbuf, >strlen(MEGASAS_VERSION) + 2, "%s\n", >> +MEGASAS_VERSION); >> +init_frame->driver_ver_lo = cpu_to_le32(instance- >>verbuf_h); >> +init_frame->driver_ver_hi = 0; >> +} >> + >> init_frame->queue_info_new_phys_addr_lo = >> cpu_to_le32(lower_32_bits(initq_info_h)); >> init_frame->queue_info_new_phys_addr_hi = @@ -5257,6 +5265,12 >@@ >> static int megasas_probe_one(struct pci_dev *pdev, >> break; >> } >> >> +instance->verbuf = pci_alloc_consistent(pdev, >> +MEGASAS_MAX_NAME * >sizeof(u32), >> +&instance->verbuf_h); >> +if (!instance->verbuf) >> +dev_info(&instance->pdev->dev, "Can't allocate version >buffer\n"); >> + >> instance->system_info_buf = pci_zalloc_consistent(pdev, >> sizeof(struct >MR_DRV_SYSTEM_INFO), >> &instance->system_info_h); >> @@ -5838,6 +5852,10 @@ static void megasas_detach_one(struct pc