public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [QUESTION]: Why did we clear the lowest bit of SCSI command's status in scsi_status_is_good
@ 2022-11-28  3:58 Wenchao Hao
  2022-11-28 12:52 ` James Bottomley
  0 siblings, 1 reply; 9+ messages in thread
From: Wenchao Hao @ 2022-11-28  3:58 UTC (permalink / raw)
  To: Martin K. Petersen, James E.J. Bottomley, Mike Christie,
	James Bottomley
  Cc: linux-scsi, linfeilong, yanaijie, xuhujie, lijinlin3

static inline bool scsi_status_is_good(int status)                                                                                                                                                             
{
        if (status < 0)
                return false;

        if (host_byte(status) == DID_NO_CONNECT)
                return false;

        /*  
         * FIXME: bit0 is listed as reserved in SCSI-2, but is
         * significant in SCSI-3.  For now, we follow the SCSI-2
         * behaviour and ignore reserved bits.
         */
        status &= 0xfe;
        return ((status == SAM_STAT_GOOD) ||
                (status == SAM_STAT_CONDITION_MET) ||
                /* Next two "intermediate" statuses are obsolete in SAM-4 */
                (status == SAM_STAT_INTERMEDIATE) ||
                (status == SAM_STAT_INTERMEDIATE_CONDITION_MET) ||
                /* FIXME: this is obsolete in SAM-3 */
                (status == SAM_STAT_COMMAND_TERMINATED));
}
We have function defined in include/scsi/scsi.h as above, which is used to check
if the status in result is good.

But the function cleared the lowest bit of SCSI command's status, which would
translate an undefined status to good in some condition, for example the status
is 0x1.

This code seems introduced in this patch:
https://lore.kernel.org/all/1052403312.2097.35.camel@mulgrave/

Is anyone who knows why did we clear the lowest bit? 

We found some firmware or drivers would return status which did not defined in
SAM. Now SCSI middle level do not have an uniform behavior for these undefined
status. I want to change the logic to return error for all status which did not
defined in SAM or define a method in host template to let drivers to judge
what to do in this condition.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-02 16:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-28  3:58 [QUESTION]: Why did we clear the lowest bit of SCSI command's status in scsi_status_is_good Wenchao Hao
2022-11-28 12:52 ` James Bottomley
2022-11-28 14:41   ` Wenchao Hao
2022-11-28 15:21     ` James Bottomley
2022-11-28 17:38       ` Wenchao Hao
2022-11-28 18:12         ` James Bottomley
2022-12-02 13:58           ` Wenchao Hao
2022-12-02 14:17             ` James Bottomley
2022-12-02 16:26               ` Wenchao Hao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox