qla2xxx patches for kernel v5.6
Subsystems (2)
v2 cover qla2xxx patches for kernel v5.6
Hi Martin,
Please consider these six small qla2xxx patches for kernel v5.6.
Thanks,
Bart.
Changes compared to v1:
- Dropped patch "Fix point-to-point mode for qla25xx and older"
- Added three new patches.
Bart Van Assche (6):
qla2xxx: Check locking assumptions at runtime in qla2x00_abort_srb()
qla2xxx: Simplify the code for aborting SCSI commands
qla2xxx: Suppress endianness complaints in
qla2x00_configure_local_loop()
qla2xxx: Fix sparse warnings triggered by the PCI state checking code
qla2xxx: Convert MAKE_HANDLE() from a define into an inline function
qla2xxx: Fix the endianness annotations for the port attribute
max_frame_size member
drivers/scsi/qla2xxx/qla_def.h | 14 +++++++------- drivers/scsi/qla2xxx/qla_gs.c | 14 ++++++-------- drivers/scsi/qla2xxx/qla_init.c | 11 +++++------ drivers/scsi/qla2xxx/qla_isr.c | 5 ----- drivers/scsi/qla2xxx/qla_mbx.c | 5 ++--- drivers/scsi/qla2xxx/qla_mr.c | 5 ++--- drivers/scsi/qla2xxx/qla_os.c | 29 ++++++++++++++++------------- 7 files changed, 38 insertions(+), 45 deletions(-)
PATCH v2 1/6 qla2xxx: Check locking assumptions at runtime in qla2x00_abort_srb()
Document the locking assumptions this function relies on and also verify these locking assumptions at runtime.
--- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_os.c +2 -0
@@ -1700,6 +1700,8 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,bool ret_cmd;uint32_t ratov_j; +lockdep_assert_held (qp->qp_lock_ptr); +if (qla2x00_chip_is_down (vha)) { sp->done (sp, res);return ;
Re: [PATCH v2 1/6] qla2xxx: Check locking assumptions at runtime in qla2x00_abort_srb()
Quoted 9 lines · Bart Van Assche
Document the locking assumptions this function relies on and also verify these locking assumptions at runtime.
Acked-by Himanshu Madhani <[email protected]>Reviewed-by Martin Wilck <[email protected]>Reviewed-by Roman Bolshakov <[email protected]>Cc Quinn Tran <[email protected]>Cc Daniel Wagner <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
PATCH v2 2/6 qla2xxx: Simplify the code for aborting SCSI commands
In reply to Bart Van AsscheSince the SCSI core does not reuse the tag of the SCSI command that is being aborted by .eh_abort() before .eh_abort() has finished it is not necessary to check from inside that callback whether or not the SCSI command has already completed. Instead, rely on the firmware to return an error code when attempting to abort a command that has already completed. Additionally, rely on the firmware to return an error code when attempting to abort an already aborted command.
In qla2x00_abort_srb(), use blk_mq_request_started() instead of sp->completed and sp->aborted.
This patch eliminates several race conditions triggered by the removed member variables.
--- drivers/scsi/qla2xxx/qla_def.h | 3 --- drivers/scsi/qla2xxx/qla_isr.c | 5 ----- drivers/scsi/qla2xxx/qla_os.c | 27 ++++++++++++++------------- 3 files changed, 14 insertions(+), 21 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -3
@@ -597,9 +597,6 @@ typedef struct srb {struct fc_port *fcport;struct scsi_qla_host *vha; unsigned int start_timer:1; - unsigned int abort:1; - unsigned int aborted:1; - unsigned int completed:1;uint32_t handle;uint16_t flags;
drivers/scsi/qla2xxx/qla_isr.c +0 -5
@@ -2504,11 +2504,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)return ; } -if (sp->abort) - sp->aborted =1 ; -else - sp->completed =1 ; -if (sp->cmd_type !=TYPE_SRB ) { req->outstanding_cmds[handle] =NULL ; ql_dbg(ql_dbg_io, vha, 0x3015,
drivers/scsi/qla2xxx/qla_os.c +14 -13
@@ -1253,17 +1253,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)return SUCCESS ;spin_lock_irqsave (qpair->qp_lock_ptr, flags); -if (sp->completed) { -spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); -return SUCCESS ; - } - -if (sp->abort || sp->aborted) { -spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); -return FAILED ; - } - - sp->abort =1 ; sp->comp = ∁spin_unlock_irqrestore (qpair->qp_lock_ptr, flags);
@@ -1688,6 +1677,10 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)return QLA_SUCCESS ; } +/* +* The caller must ensure that no completion interrupts will happen +* while this function is in progress. +*/ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, unsigned long *flags) __releases(qp->qp_lock_ptr)
@@ -1696,6 +1689,7 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,DECLARE_COMPLETION_ONSTACK (comp);scsi_qla_host_t *vha = qp->vha;struct qla_hw_data *ha = vha->hw; +struct scsi_cmnd *cmd =GET_CMD_SP (sp);int rval;bool ret_cmd;uint32_t ratov_j;
@@ -1717,7 +1711,6 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, } sp->comp = ∁ - sp->abort =1 ;spin_unlock_irqrestore (qp->qp_lock_ptr, *flags); rval = ha->isp_ops->abort_command (sp);
@@ -1741,13 +1734,17 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, }spin_lock_irqsave (qp->qp_lock_ptr, *flags); -if (ret_cmd && (!sp->completed || !sp->aborted)) +if (ret_cmd &&blk_mq_request_started (cmd->request)) sp->done (sp, res); }else { sp->done (sp, res); } } +/* +* The caller must ensure that no completion interrupts will happen +* while this function is in progress. +*/ static void __qla2x00_abort_all_cmds (struct qla_qpair *qp,int res) {
@@ -1794,6 +1791,10 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)spin_unlock_irqrestore (qp->qp_lock_ptr, flags); } +/* +* The caller must ensure that no completion interrupts will happen +* while this function is in progress. +*/ void qla2x00_abort_all_cmds (scsi_qla_host_t *vha,int res) {
Re: [PATCH v2 2/6] qla2xxx: Simplify the code for aborting SCSI commands
Quoted 8 lines · Bart Van Assche
Since the SCSI core does not reuse the tag of the SCSI command that is being aborted by .eh_abort() before .eh_abort() has finished it is not necessary to check from inside that callback whether or not the SCSI command has already completed. Instead, rely on the firmware to return an error code when attempting to abort a command that has already completed. Additionally, rely on the firmware to return an error code when attempting to abort an already aborted command.
Quoted 5 lines
In
qla2x00_abort_srb(), useblk_mq_request_started()instead ofsp->completedandsp->aborted.This patch eliminates several race conditions triggered by the removed member variables.
I can only guess here what the races are but I agree removing the logic here and relying on the SCSI layer to handle it correctly makes sense.
Quoted 6 lines
Acked-by Himanshu Madhani <[email protected]>Reviewed-by Roman Bolshakov <[email protected]>Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Quoted 4 lines
+/*
+ * The caller must ensure that no completion interrupts will happen
+ * while this function is in progress.
+ */
So could we add something like WARN_ON(irqs_disabled())?
Re: [PATCH v2 2/6] qla2xxx: Simplify the code for aborting SCSI commands
Quoted 12 lines · Daniel Wagner
Quoted 11 lines · Bart Van Assche
Since the SCSI core does not reuse the tag of the SCSI command that is being aborted by .eh_abort() before .eh_abort() has finished it is not necessary to check from inside that callback whether or not the SCSI command has already completed. Instead, rely on the firmware to return an error code when attempting to abort a command that has already completed. Additionally, rely on the firmware to return an error code when attempting to abort an already aborted command.
In
qla2x00_abort_srb(), useblk_mq_request_started()instead ofsp->completedandsp->aborted.
Quoted 6 lines
Quoted 2 lines
This patch eliminates several race conditions triggered by the removed member variables.
I can only guess here what the races are but I agree removing the logic here and relying on the SCSI layer to handle it correctly makes sense.
I will make the patch description more clear when I repost this patch.
Quoted 6 lines
Quoted 4 lines
+/*
+ * The caller must ensure that no completion interrupts will happen
+ * while this function is in progress.
+ */So could we add something like WARN_ON(irqs_disabled())?
qla2x00_abort_all_cmds() is typically called after the kernel driver discovered that the firmware stopped processing commands. If the firmware has stopped processing commands it is safe to call this function without disabling interrupts. Even if the caller would disable interrupts, that would only disable interrupts on the local CPU but not on other CPUs. Additionally, disabling interrupts is not a proper solution because if a completion interrupt arrives after a command has been aborted that will cause trouble if the command handle has already been associated with another command.
Bart.
Re: [PATCH v2 2/6] qla2xxx: Simplify the code for aborting SCSI commands
Hi Bart,
Quoted 7 lines · Bart Van Assche
Quoted 6 lines
Quoted 4 lines
+/*
+ * The caller must ensure that no completion interrupts will happen
+ * while this function is in progress.
+ */So could we add something like WARN_ON(irqs_disabled())?
Quoted 9 lines
qla2x00_abort_all_cmds()is typically called after the kernel driver discovered that the firmware stopped processing commands. If the firmware has stopped processing commands it is safe to call this function without disabling interrupts. Even if the caller would disable interrupts, that would only disable interrupts on the local CPU but not on other CPUs. Additionally, disabling interrupts is not a proper solution because if a completion interrupt arrives after a command has been aborted that will cause trouble if the command handle has already been associated with another command.
Thanks for the explenation. I understood the comment as 'interrupts' have to be disabled when calling this function.
Thanks,
Daniel
PATCH v2 3/6 qla2xxx: Suppress endianness complaints in qla2x00_configure_local_loop()
In reply to Bart Van AsscheInstead of changing endianness in-place, write the data in CPU endian format in another buffer and copy that buffer back. This patch does not change any functionality but silences some sparse endianness warnings.
--- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/qla_init.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +1 -1
@@ -414,7 +414,7 @@ struct els_logo_payload {struct els_plogi_payload {uint8_t opcode;uint8_t rsvd[3 ]; -uint8_t data[112 ]; +__be32 data[112 /4 ]; };struct ct_arg {
drivers/scsi/qla2xxx/qla_init.c +5 -6
@@ -5060,7 +5060,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)if (N2N_TOPO (ha)) {if (test_and_clear_bit (N2N_LOGIN_NEEDED , &vha->dpc_flags)) {/* borrowing */ -u32 *bp, i, sz; +u32 *bp, sz;memset (ha->init_cb,0 , ha->init_cb_size); sz = min_t(int, sizeof(struct els_plogi_payload),
@@ -5068,13 +5068,12 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) rval =qla24xx_get_port_login_templ (vha, ha->init_cb_dma, (void *)ha->init_cb, sz);if (rval ==QLA_SUCCESS ) { +__be32 *q = &ha->plogi_els_payld.data[0 ]; + bp = (uint32_t *)ha->init_cb; -for (i =0 ; i < sz/4 ; i++, bp++) - *bp =cpu_to_be32 (*bp); +cpu_to_be32_array (q, bp, sz /4 ); -memcpy (&ha->plogi_els_payld.data, - (void *)ha->init_cb, -sizeof (ha->plogi_els_payld.data)); +memcpy (bp, q,sizeof (ha->plogi_els_payld.data)); }else {ql_dbg (ql_dbg_init, vha,0x00d1 ,"PLOGI ELS param read fail.\n" );
Re: [PATCH v2 3/6] qla2xxx: Suppress endianness complaints in qla2x00_configure_local_loop()
Quoted 9 lines · Bart Van Assche
Instead of changing endianness in-place, write the data in CPU endian format in another buffer and copy that buffer back. This patch does not change any functionality but silences some sparse endianness warnings.
Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
PATCH v2 4/6 qla2xxx: Fix sparse warnings triggered by the PCI state checking code
In reply to Bart Van AsscheThis patch fixes the following sparse warnings:
drivers/scsi/qla2xxx/qla_mbx.c:120:21: warning: restricted pci_channel_state_t degrades to integer drivers/scsi/qla2xxx/qla_mbx.c:120:37: warning: restricted pci_channel_state_t degrades to integer
From include/linux/pci.h:
enum pci_channel_state {
/* I/O channel is in normal state */
pci_channel_io_normal = (__force pci_channel_state_t) 1,
/* I/O to channel is blocked */
pci_channel_io_frozen = (__force pci_channel_state_t) 2,
/* PCI card is dead */
pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
};--- drivers/scsi/qla2xxx/qla_mbx.c | 5 ++--- drivers/scsi/qla2xxx/qla_mr.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_mbx.c +2 -3
@@ -117,10 +117,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)ql_dbg (ql_dbg_mbx, vha,0x1000 ,"Entered %s.\n" , __func__); -if (ha->pdev->error_state > pci_channel_io_frozen) { +if (ha->pdev->error_state == pci_channel_io_perm_failure) {ql_log (ql_log_warn, vha,0x1001 , -"error_state is greater than pci_channel_io_frozen, " -"exiting.\n" ); +"PCI channel failed permanently, exiting.\n" );return QLA_FUNCTION_TIMEOUT ; }
drivers/scsi/qla2xxx/qla_mr.c +2 -3
@@ -53,10 +53,9 @@ qlafx00_mailbox_command(scsi_qla_host_t *vha, struct mbx_cmd_32 *mcp)struct qla_hw_data *ha = vha->hw;scsi_qla_host_t *base_vha =pci_get_drvdata (ha->pdev); -if (ha->pdev->error_state > pci_channel_io_frozen) { +if (ha->pdev->error_state == pci_channel_io_perm_failure) {ql_log (ql_log_warn, vha,0x115c , -"error_state is greater than pci_channel_io_frozen, " -"exiting.\n" ); +"PCI channel failed permanently, exiting.\n" );return QLA_FUNCTION_TIMEOUT ; }
Re: [PATCH v2 4/6] qla2xxx: Fix sparse warnings triggered by the PCI state checking code
Quoted 18 lines · Bart Van Assche
This patch fixes the following sparse warnings:
drivers/scsi/qla2xxx/qla_mbx.c:120:21: warning: restrictedpci_channel_state_tdegrades to integerdrivers/scsi/qla2xxx/qla_mbx.c:120:37: warning: restrictedpci_channel_state_tdegrades to integerFrom
include/linux/pci.h:enum pci_channel_state { /* I/O channel is in normal state */ pci_channel_io_normal = (__force pci_channel_state_t) 1, /* I/O to channel is blocked */ pci_channel_io_frozen = (__force pci_channel_state_t) 2, /* PCI card is dead */ pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, };
Quoted 5 lines
Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Re: [PATCH v2 4/6] qla2xxx: Fix sparse warnings triggered by the PCI state checking code
In reply to Bart Van AsscheQuoted 23 lines · Bart Van Assche
This patch fixes the following sparse warnings:
drivers/scsi/qla2xxx/qla_mbx.c:120:21: warning: restrictedpci_channel_state_tdegrades to integerdrivers/scsi/qla2xxx/qla_mbx.c:120:37: warning: restrictedpci_channel_state_tdegrades to integerFrom
include/linux/pci.h:enum pci_channel_state { /* I/O channel is in normal state */ pci_channel_io_normal = (__force pci_channel_state_t) 1, /* I/O to channel is blocked */ pci_channel_io_frozen = (__force pci_channel_state_t) 2, /* PCI card is dead */ pci_channel_io_perm_failure = (__force pci_channel_state_t) 3, };Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Quoted 5 lines
--- drivers/scsi/qla2xxx/qla_mbx.c | 5 ++--- drivers/scsi/qla2xxx/qla_mr.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
Hi Bart,
Best regards,
Roman
PATCH v2 5/6 qla2xxx: Convert MAKE_HANDLE() from a define into an inline function
In reply to Bart Van AsscheThis patch allows sparse to verify the endianness of the arguments passed to MAKE_HANDLE().
--- drivers/scsi/qla2xxx/qla_def.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_def.h +4 -1
@@ -119,7 +119,10 @@ typedef struct {#define LSD (x) ((uint32_t)((uint64_t)(x)))#define MSD (x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16)) -#define MAKE_HANDLE (x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y))) +static inline uint32_t MAKE_HANDLE (uint16_t x,uint16_t y) +{ +return ((uint32_t )x <<16 ) | y; +}/* * I/O register
Re: [PATCH v2 5/6] qla2xxx: Convert MAKE_HANDLE() from a define into an inline function
Quoted 17 lines · Bart Van Assche
This patch allows sparse to verify the endianness of the arguments passed to
MAKE_HANDLE().Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/qla2xxx/qla_def.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_def.h +0
-0
drivers/scsi/qla2xxx/qla_def.h typedef struct { · line 125
Quoted 8 lines
drivers/scsi/qla2xxx/qla_def.h +4
-1@@ -119,7 +119,10 @@ typedef struct {#define LSD (x) ((uint32_t)((uint64_t)(x)))#define MSD (x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16)) -#define MAKE_HANDLE (x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y))) +static inline uint32_t MAKE_HANDLE (uint16_t x,uint16_t y) +{ +return ((uint32_t )x <<16 ) | y; +}
s/MAKE_HANDLE/make_handle/ ?
Re: [PATCH v2 5/6] qla2xxx: Convert MAKE_HANDLE() from a define into an inline function
Quoted 1 line · Daniel Wagner
s/MAKE_HANDLE/make_handle/ ?
That will make the function name conformant with the coding style. I will look into this.
Bart.
PATCH v2 6/6 qla2xxx: Fix the endianness annotations for the port attribute max_frame_size member
In reply to Bart Van AsscheMake sure that sparse doesn't complain about the statements that load or store the port attribute max_frame_size member. The port attribute data structures represent FC protocol data and hence use big endian format. This patch only changes the meaning of two ql_dbg() statements.
--- drivers/scsi/qla2xxx/qla_def.h | 4 ++-- drivers/scsi/qla2xxx/qla_gs.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +2 -2
@@ -2741,7 +2741,7 @@ struct ct_fdmiv2_port_attr {uint8_t fc4_types[32 ];uint32_t sup_speed;uint32_t cur_speed; -uint32_t max_frame_size; +__be32 max_frame_size;uint8_t os_dev_name[32 ];uint8_t host_name[256 ];uint8_t node_name[WWN_SIZE ];
@@ -2772,7 +2772,7 @@ struct ct_fdmi_port_attr {uint8_t fc4_types[32 ];uint32_t sup_speed;uint32_t cur_speed; -uint32_t max_frame_size; +__be32 max_frame_size;uint8_t os_dev_name[32 ];uint8_t host_name[256 ]; } a;
drivers/scsi/qla2xxx/qla_gs.c +6 -8
@@ -1848,14 +1848,13 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha) eiter = entries + size; eiter->type =cpu_to_be16 (FDMI_PORT_MAX_FRAME_SIZE ); eiter->len =cpu_to_be16 (4 +4 ); - eiter->a.max_frame_size =IS_FWI2_CAPABLE (ha) ? + eiter->a.max_frame_size =cpu_to_be32 (IS_FWI2_CAPABLE (ha) ?le16_to_cpu (icb24->frame_payload_size) : -le16_to_cpu (ha->init_cb->frame_payload_size); - eiter->a.max_frame_size =cpu_to_be32 (eiter->a.max_frame_size); +le16_to_cpu (ha->init_cb->frame_payload_size)); size +=4 +4 ;ql_dbg (ql_dbg_disc, vha,0x203c , -"Max_Frame_Size=%x.\n" , eiter->a.max_frame_size); +"Max_Frame_Size=%x.\n" ,be32_to_cpu (eiter->a.max_frame_size));/* OS device name. */ eiter = entries + size;
@@ -2419,14 +2418,13 @@ qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha) eiter = entries + size; eiter->type =cpu_to_be16 (FDMI_PORT_MAX_FRAME_SIZE ); eiter->len =cpu_to_be16 (4 +4 ); - eiter->a.max_frame_size =IS_FWI2_CAPABLE (ha) ? + eiter->a.max_frame_size =cpu_to_be32 (IS_FWI2_CAPABLE (ha) ?le16_to_cpu (icb24->frame_payload_size) : -le16_to_cpu (ha->init_cb->frame_payload_size); - eiter->a.max_frame_size =cpu_to_be32 (eiter->a.max_frame_size); +le16_to_cpu (ha->init_cb->frame_payload_size)); size +=4 +4 ;ql_dbg (ql_dbg_disc, vha,0x20bc , -"Max_Frame_Size = %x.\n" , eiter->a.max_frame_size); +"Max_Frame_Size = %x.\n" ,be32_to_cpu (eiter->a.max_frame_size));/* OS device name. */ eiter = entries + size;
Re: [PATCH v2 6/6] qla2xxx: Fix the endianness annotations for the port attribute max_frame_size member
Quoted 10 lines · Bart Van Assche
Make sure that sparse doesn't complain about the statements that load or store the port attribute
max_frame_sizemember. The port attribute data structures represent FC protocol data and hence use big endian format. This patch only changes the meaning of twoql_dbg()statements.Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Re: [PATCH v2 6/6] qla2xxx: Fix the endianness annotations for the port attribute max_frame_size member
In reply to Bart Van AsscheQuoted 67 lines · Bart Van Assche
Make sure that sparse doesn't complain about the statements that load or store the port attribute
max_frame_sizemember. The port attribute data structures represent FC protocol data and hence use big endian format. This patch only changes the meaning of twoql_dbg()statements.Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/qla2xxx/qla_def.h | 4 ++-- drivers/scsi/qla2xxx/qla_gs.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-)drivers/scsi/qla2xxx/qla_def.h +2
-2@@ -2741,7 +2741,7 @@ struct ct_fdmiv2_port_attr {uint8_t fc4_types[32 ];uint32_t sup_speed;uint32_t cur_speed; -uint32_t max_frame_size; +__be32 max_frame_size;uint8_t os_dev_name[32 ];uint8_t host_name[256 ];uint8_t node_name[WWN_SIZE ];@@ -2772,7 +2772,7 @@ struct ct_fdmi_port_attr {uint8_t fc4_types[32 ];uint32_t sup_speed;uint32_t cur_speed; -uint32_t max_frame_size; +__be32 max_frame_size;uint8_t os_dev_name[32 ];uint8_t host_name[256 ]; } a;drivers/scsi/qla2xxx/qla_gs.c +4
-6@@ -1848,14 +1848,13 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha) eiter = entries + size; eiter->type =cpu_to_be16 (FDMI_PORT_MAX_FRAME_SIZE ); eiter->len =cpu_to_be16 (4 +4 ); - eiter->a.max_frame_size =IS_FWI2_CAPABLE (ha) ? + eiter->a.max_frame_size =cpu_to_be32 (IS_FWI2_CAPABLE (ha) ?le16_to_cpu (icb24->frame_payload_size) : -le16_to_cpu (ha->init_cb->frame_payload_size); - eiter->a.max_frame_size =cpu_to_be32 (eiter->a.max_frame_size); +le16_to_cpu (ha->init_cb->frame_payload_size)); size +=4 +4 ;ql_dbg (ql_dbg_disc, vha,0x203c , -"Max_Frame_Size=%x.\n" , eiter->a.max_frame_size); +"Max_Frame_Size=%x.\n" ,be32_to_cpu (eiter->a.max_frame_size));/* OS device name. */ eiter = entries + size;@@ -2419,14 +2418,13 @@ qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha) eiter = entries + size; eiter->type =cpu_to_be16 (FDMI_PORT_MAX_FRAME_SIZE ); eiter->len =cpu_to_be16 (4 +4 ); - eiter->a.max_frame_size =IS_FWI2_CAPABLE (ha) ? + eiter->a.max_frame_size = cpu_to_be32(IS_FWI2_CAPABLE(ha) ? le16_to_cpu(icb24->frame_payload_size) : -le16_to_cpu (ha->init_cb->frame_payload_size);
drivers/scsi/qla2xxx/qla_gs.c qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha) · line 2430
Quoted 10 lines
drivers/scsi/qla2xxx/qla_gs.c +2
-2- eiter->a.max_frame_size =cpu_to_be32 (eiter->a.max_frame_size); + le16_to_cpu(ha->init_cb->frame_payload_size)); size +=4 +4 ;ql_dbg (ql_dbg_disc, vha,0x20bc , -"Max_Frame_Size = %x.\n" , eiter->a.max_frame_size); +"Max_Frame_Size = %x.\n" ,be32_to_cpu (eiter->a.max_frame_size));/* OS device name. */ eiter = entries + size;
Hi Bart,
I'm not an expert of FDMI feature but it seems to introduce an inconsistency with regards to structure definition. IMO, All multi-byte binary fields and bitmasks in RPA request should be made __be32 rather than only one. Probably that should go into one patch series where all fields in the structure are fixed patch-by-patch or one patch that fixes all fields at once (the latter is harder to review though).
According to Table 402 – Port Attribute Values in FC-GS-7 and RPA request attributes in the structure above, that includes:
Supported Speed
Current Port Speed
Maximum Frame Size
Port Type
Supported Classes of Service
Port State
Number of Discovered Ports
Port Identifier
But the patch itself looks good,
Regards,
Roman
Re: [PATCH v2 6/6] qla2xxx: Fix the endianness annotations for the port attribute max_frame_size member
Quoted 6 lines · Roman Bolshakov
I'm not an expert of FDMI feature but it seems to introduce an inconsistency with regards to structure definition. IMO, All multi-byte binary fields and bitmasks in RPA request should be made
__be32rather than only one. Probably that should go into one patch series where all fields in the structure are fixed patch-by-patch or one patch that fixes all fields at once (the latter is harder to review though).
Hi Roman,
I agree with what you wrote. I have a (huge) patch pending that fixes all endianness issues in the qla2xxx driver. I plan to post that patch after agreement has been achieved about this patch series.
Thanks,
Bart.
Bart,
Quoted 1 line
Please consider these six small qla2xxx patches for kernel v5.6.
I applied patch #1. #2-#6 need a repost and some reviews.
Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering