Author: mav
Date: Thu Mar 26 00:42:31 2020
New Revision: 359314
URL: https://svnweb.freebsd.org/changeset/base/359314

Log:
  MFC r359146: Fix SES on device slots without phys after r349321.
  
  Broadcom 9400-8i8e HBAs report virtual SES device, where slots representing
  external connectors are reported having no phys.  Since sasdev_phys is NULL
  there and proto_hdr is a union, ses_paths_iter() misinterpreted them as ATA.
  Add explicit protocol check to properly differentiate them.

Modified:
  stable/12/sys/cam/scsi/scsi_enc_ses.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cam/scsi/scsi_enc_ses.c
==============================================================================
--- stable/12/sys/cam/scsi/scsi_enc_ses.c       Thu Mar 26 00:39:36 2020        
(r359313)
+++ stable/12/sys/cam/scsi/scsi_enc_ses.c       Thu Mar 26 00:42:31 2020        
(r359314)
@@ -956,30 +956,38 @@ ses_paths_iter(enc_softc_t *enc, enc_element_t *elm,
        if (addl->hdr == NULL)
                return;
 
-       if (addl->proto_hdr.sas != NULL &&
-           addl->proto_data.sasdev_phys != NULL) {
-               ses_path_iter_args_t args;
+       switch(ses_elm_addlstatus_proto(addl->hdr)) {
+       case SPSP_PROTO_SAS:
+               if (addl->proto_hdr.sas != NULL &&
+                   addl->proto_data.sasdev_phys != NULL) {
+                       ses_path_iter_args_t args;
 
-               args.callback     = callback;
-               args.callback_arg = callback_arg;
-               ses_devids_iter(enc, elm, ses_path_iter_devid_callback, &args);
-       } else if (addl->proto_hdr.ata != NULL) {
-               struct cam_path *path;
-               struct ccb_getdev cgd;
+                       args.callback     = callback;
+                       args.callback_arg = callback_arg;
+                       ses_devids_iter(enc, elm, ses_path_iter_devid_callback,
+                           &args);
+               }
+               break;
+       case SPSP_PROTO_ATA:
+               if (addl->proto_hdr.ata != NULL) {
+                       struct cam_path *path;
+                       struct ccb_getdev cgd;
 
-               if (xpt_create_path(&path, /*periph*/NULL,
-                   scsi_4btoul(addl->proto_hdr.ata->bus),
-                   scsi_4btoul(addl->proto_hdr.ata->target), 0)
-                    != CAM_REQ_CMP)
-                       return;
+                       if (xpt_create_path(&path, /*periph*/NULL,
+                           scsi_4btoul(addl->proto_hdr.ata->bus),
+                           scsi_4btoul(addl->proto_hdr.ata->target), 0)
+                            != CAM_REQ_CMP)
+                               return;
 
-               xpt_setup_ccb(&cgd.ccb_h, path, CAM_PRIORITY_NORMAL);
-               cgd.ccb_h.func_code = XPT_GDEV_TYPE;
-               xpt_action((union ccb *)&cgd);
-               if (cgd.ccb_h.status == CAM_REQ_CMP)
-                       callback(enc, elm, path, callback_arg);
+                       xpt_setup_ccb(&cgd.ccb_h, path, CAM_PRIORITY_NORMAL);
+                       cgd.ccb_h.func_code = XPT_GDEV_TYPE;
+                       xpt_action((union ccb *)&cgd);
+                       if (cgd.ccb_h.status == CAM_REQ_CMP)
+                               callback(enc, elm, path, callback_arg);
 
-               xpt_free_path(path);
+                       xpt_free_path(path);
+               }
+               break;
        }
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to