Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Hannes Reinecke <hare@suse.de>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org, Arun Easi <aeasi@marvell.com>,
	Himanshu Madhani <himanshu.madhani@oracle.com>,
	Nilesh Javali <njavali@marvell.com>,
	Quinn Tran <qutran@marvell.com>, Martin Wilck <mwilck@suse.com>,
	Daniel Wagner <dwagner@suse.de>,
	Roman Bolshakov <r.bolshakov@yadro.com>
Subject: Re: [PATCH v6 15/15] qla2xxx: Fix endianness annotations in source files
Date: Fri, 15 May 2020 12:22:55 -0700	[thread overview]
Message-ID: <fdc5993d-ffb8-cd7f-06a3-20e16a1017d0@acm.org> (raw)
In-Reply-To: <77c33a4e-c67c-1978-8b72-ceca58d4309d@suse.de>

On 2020-05-14 23:50, Hannes Reinecke wrote:
> On 5/14/20 11:35 PM, Bart Van Assche wrote:
>> diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c
>> b/drivers/scsi/qla2xxx/qla_tmpl.c
>> index f05a4fa2b9d7..b91ec1c3a3ae 100644
>> --- a/drivers/scsi/qla2xxx/qla_tmpl.c
>> +++ b/drivers/scsi/qla2xxx/qla_tmpl.c
>> @@ -922,9 +922,9 @@ qla27xx_firmware_info(struct scsi_qla_host *vha,
>>       tmp->firmware_version[0] = vha->hw->fw_major_version;
>>       tmp->firmware_version[1] = vha->hw->fw_minor_version;
>>       tmp->firmware_version[2] = vha->hw->fw_subminor_version;
>> -    tmp->firmware_version[3] = cpu_to_le32(
>> +    tmp->firmware_version[3] = (__force u32)cpu_to_le32(
>>           vha->hw->fw_attributes_h << 16 | vha->hw->fw_attributes);
>> -    tmp->firmware_version[4] = cpu_to_le32(
>> +    tmp->firmware_version[4] = (__force u32)cpu_to_le32(
>>         vha->hw->fw_attributes_ext[1] << 16 |
>> vha->hw->fw_attributes_ext[0]);
>>   }
>>  
> Why do you need (__force u32) here?
> It should be a 32bit array, and cpu_to_le32() trivially returns 32bits.
> What's there to force?

The hw->fw_{major,minor,subminor}_version and also the
hw->fw_attributes_ext variables have been annotated as CPU endian. I
inserted the (__force u32) casts because that suppresses the endianness
warnings without affecting the generated code on little endian or big
endian systems. Thinking further about this, storing CPU endian values
in a firmware data structure is most likely wrong. How about modifying
patch 15/15 as follows?

 drivers/scsi/qla2xxx/qla_tmpl.c | 10 +++++-----
 drivers/scsi/qla2xxx/qla_tmpl.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index b91ec1c3a3ae..8dc82cfd38b2 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -919,12 +919,12 @@ static void
 qla27xx_firmware_info(struct scsi_qla_host *vha,
     struct qla27xx_fwdt_template *tmp)
 {
-	tmp->firmware_version[0] = vha->hw->fw_major_version;
-	tmp->firmware_version[1] = vha->hw->fw_minor_version;
-	tmp->firmware_version[2] = vha->hw->fw_subminor_version;
-	tmp->firmware_version[3] = (__force u32)cpu_to_le32(
+	tmp->firmware_version[0] = cpu_to_le32(vha->hw->fw_major_version);
+	tmp->firmware_version[1] = cpu_to_le32(vha->hw->fw_minor_version);
+	tmp->firmware_version[2] = cpu_to_le32(vha->hw->fw_subminor_version);
+	tmp->firmware_version[3] = cpu_to_le32(
 		vha->hw->fw_attributes_h << 16 | vha->hw->fw_attributes);
-	tmp->firmware_version[4] = (__force u32)cpu_to_le32(
+	tmp->firmware_version[4] = cpu_to_le32(
 	  vha->hw->fw_attributes_ext[1] << 16 | vha->hw->fw_attributes_ext[0]);
 }

diff --git a/drivers/scsi/qla2xxx/qla_tmpl.h b/drivers/scsi/qla2xxx/qla_tmpl.h
index bba8dc90acfb..89280b3477aa 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.h
+++ b/drivers/scsi/qla2xxx/qla_tmpl.h
@@ -27,7 +27,7 @@ struct __packed qla27xx_fwdt_template {
 	uint32_t saved_state[16];

 	uint32_t reserved_3[8];
-	uint32_t firmware_version[5];
+	__le32 firmware_version[5];
 };

 #define TEMPLATE_TYPE_FWDUMP		99

Thanks,

Bart.

  reply	other threads:[~2020-05-15 19:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 21:35 [PATCH v6 00/15] Fix qla2xxx endianness annotations Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 01/15] qla2xxx: Fix spelling of a variable name Bart Van Assche
2020-05-15 23:05   ` Roman Bolshakov
2020-05-14 21:35 ` [PATCH v6 02/15] qla2xxx: Suppress two recently introduced compiler warnings Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 03/15] qla2xxx: Simplify the functions for dumping firmware Bart Van Assche
2020-05-15  6:38   ` Hannes Reinecke
2020-05-15  7:57   ` Daniel Wagner
2020-05-14 21:35 ` [PATCH v6 04/15] qla2xxx: Sort BUILD_BUG_ON() statements alphabetically Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 05/15] qla2xxx: Add more BUILD_BUG_ON() statements Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 06/15] qla2xxx: Make a gap in struct qla2xxx_offld_chain explicit Bart Van Assche
2020-05-15 15:44   ` Himanshu Madhani
2020-05-14 21:35 ` [PATCH v6 07/15] qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 08/15] qla2xxx: Change two hardcoded constants into offsetof() / sizeof() expressions Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 09/15] qla2xxx: Use register names instead of register offsets Bart Van Assche
2020-05-15  8:25   ` Daniel Wagner
2020-05-15 15:54   ` Himanshu Madhani
2020-05-14 21:35 ` [PATCH v6 10/15] qla2xxx: Fix the code that reads from mailbox registers Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 11/15] qla2xxx: Change {RD,WRT}_REG_*() function names from upper case into lower case Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 12/15] qla2xxx: Cast explicitly to uint16_t / uint32_t Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 13/15] qla2xxx: Use make_handle() instead of open-coding it Bart Van Assche
2020-05-15  6:39   ` Hannes Reinecke
2020-05-15  8:28   ` Daniel Wagner
2020-05-15 15:58   ` Himanshu Madhani
2020-05-15 22:55   ` Roman Bolshakov
2020-05-14 21:35 ` [PATCH v6 14/15] qla2xxx: Fix endianness annotations in header files Bart Van Assche
2020-05-14 21:35 ` [PATCH v6 15/15] qla2xxx: Fix endianness annotations in source files Bart Van Assche
2020-05-15  6:50   ` Hannes Reinecke
2020-05-15 19:22     ` Bart Van Assche [this message]
2020-05-18  6:18       ` Hannes Reinecke
2020-05-15  9:44   ` Daniel Wagner
2020-05-18 21:13     ` Bart Van Assche
2020-05-19 15:27       ` Daniel Wagner
2020-05-19 16:17         ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fdc5993d-ffb8-cd7f-06a3-20e16a1017d0@acm.org \
    --to=bvanassche@acm.org \
    --cc=aeasi@marvell.com \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=himanshu.madhani@oracle.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --cc=njavali@marvell.com \
    --cc=qutran@marvell.com \
    --cc=r.bolshakov@yadro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox