Page MenuHomeFreeBSD

cam: Properly mask out the status bits to get completion code
ClosedPublic

Authored by imp on Apr 14 2023, 2:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 8, 9:31 AM
Unknown Object (File)
Sun, May 5, 12:22 PM
Unknown Object (File)
Tue, Apr 30, 8:00 PM
Unknown Object (File)
Apr 10 2024, 3:55 AM
Unknown Object (File)
Feb 15 2024, 3:08 AM
Unknown Object (File)
Jan 21 2024, 10:12 AM
Unknown Object (File)
Jan 15 2024, 8:37 PM
Unknown Object (File)
Jan 14 2024, 6:56 AM
Subscribers

Details

Summary

ccb_h.status has two parts: the actual status and some addition bits to
indicate additional information. It must be masked before comparing
against completion codes. Add new inline function cam_ccb_success to
simplify this to test whether or not the request succeeded. Most of the
code already does this, but a few places don't (the rest likely should
be converted to use cam_ccb_status and/or cam_ccb_success, but that's
for another day). This caused at least one bug in recognizing devices
behind a SATA port multiplexer.

PR: 270459
Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Apr 14 2023, 2:14 PM

The additional flags are normally used only for queued requests. So some of places here are likely not affected. But it should not harm probably any way.

This revision is now accepted and ready to land.Apr 14 2023, 2:23 PM
In D39572#900813, @mav wrote:

The additional flags are normally used only for queued requests. So some of places here are likely not affected. But it should not harm probably any way.

I agree. IMHO, it's better to have a more foolproof and simpler rule to follow than to do some things one way and other things another.
The path inq commands can't really ever fail... The few SIMs I looked at all unconditionally returned CAM_REQ_CMP anyway...
But surprisingly these were the few places that checked the status w/o masking and I thought it best just to do them all.
But I think 3 or 4 of them may have been doing it wrong (the nvme one was fixed after the tree I did these changes in,
btw). If there were a bunch more, I'd likely split things up differently.