This solves boot issue on Oracle Cloud Infrastructure (OCI) as mentioned:
Subject: VirtIO SCSI device recognized by boot loader but not kernel
Date: 2021-01-13 16:37:45
https://marc.info/?l=openbsd-misc&m=161055611306914
Index: sys/scsi/scsiconf.c
===================================================================
RCS file: /cvs/src/sys/scsi/scsiconf.c,v
retrieving revision 1.238
diff -u -p -r1.238 scsiconf.c
--- sys/scsi/scsiconf.c 24 Oct 2021 16:57:30 -0000 1.238
+++ sys/scsi/scsiconf.c 24 Feb 2022 01:52:01 -0000
@@ -75,7 +75,7 @@ int scsibussubprint(void *, const char *
int scsibusbioctl(struct device *, u_long, caddr_t);
#endif /* NBIO > 0 */
-void scsi_get_target_luns(struct scsi_link *, struct scsi_lun_array *);
+void scsi_get_target_luns(struct scsibus_softc *, int, struct scsi_lun_array
*);
void scsi_add_link(struct scsi_link *);
void scsi_remove_link(struct scsi_link *);
void scsi_print_link(struct scsi_link *);
@@ -412,6 +412,40 @@ scsi_activate_link(struct scsi_link *lin
return rv;
}
+struct scsi_link *
+scsi_alloc_link(struct scsibus_softc *sb, int target, int lun)
+{
+ struct scsi_link *link;
+
+ link = malloc(sizeof(*link), M_DEVBUF, M_NOWAIT);
+ if (link == NULL) {
+ SC_DEBUG(link, SDEV_DB2, ("Bad LUN. can't allocate "
+ "scsi_link.\n"));
+ return NULL;
+ }
+
+ link->state = 0;
+ link->target = target;
+ link->lun = lun;
+ link->openings = sb->sb_openings;
+ link->node_wwn = link->port_wwn = 0;
+ link->flags = sb->sb_flags;
+ link->quirks = sb->sb_quirks;
+ link->interpret_sense = scsi_interpret_sense;
+ link->device_softc = NULL;
+ link->bus = sb;
+ memset(&link->inqdata, 0, sizeof(link->inqdata));
+ link->id = NULL;
+ TAILQ_INIT(&link->queue);
+ link->running = 0;
+ link->pending = 0;
+ link->pool = sb->sb_pool;
+
+ SC_DEBUG(link, SDEV_DB2, ("scsi_link created.\n"));
+
+ return link;
+}
+
int
scsi_probe(struct scsibus_softc *sb, int target, int lun)
{
@@ -441,18 +475,13 @@ int
scsi_probe_target(struct scsibus_softc *sb, int target)
{
struct scsi_lun_array lunarray;
- struct scsi_link *link0;
int i, r, rv = 0;
if (target < 0 || target == sb->sb_adapter_target)
return EINVAL;
/* Probe all possible luns on target. */
- scsi_probe_link(sb, target, 0, 0);
- link0 = scsi_get_link(sb, target, 0);
- if (link0 == NULL)
- return EINVAL;
- scsi_get_target_luns(link0, &lunarray);
+ scsi_get_target_luns(sb, target, &lunarray);
for (i = 0; i < lunarray.count; i++) {
r = scsi_probe_link(sb, target, lunarray.luns[i],
lunarray.dumbscan);
@@ -495,31 +524,9 @@ scsi_probe_link(struct scsibus_softc *sb
if (scsi_get_link(sb, target, lun) != NULL)
return 0;
- link = malloc(sizeof(*link), M_DEVBUF, M_NOWAIT);
- if (link == NULL) {
- SC_DEBUG(link, SDEV_DB2, ("Bad LUN. can't allocate "
- "scsi_link.\n"));
+ link = scsi_alloc_link(sb, target, lun);
+ if (link == NULL)
return EINVAL;
- }
-
- link->state = 0;
- link->target = target;
- link->lun = lun;
- link->openings = sb->sb_openings;
- link->node_wwn = link->port_wwn = 0;
- link->flags = sb->sb_flags;
- link->quirks = sb->sb_quirks;
- link->interpret_sense = scsi_interpret_sense;
- link->device_softc = NULL;
- link->bus = sb;
- memset(&link->inqdata, 0, sizeof(link->inqdata));
- link->id = NULL;
- TAILQ_INIT(&link->queue);
- link->running = 0;
- link->pending = 0;
- link->pool = sb->sb_pool;
-
- SC_DEBUG(link, SDEV_DB2, ("scsi_link created.\n"));
/* Ask the adapter if this will be a valid device. */
if (sb->sb_adapter->dev_probe != NULL &&
@@ -878,13 +885,19 @@ scsi_remove_link(struct scsi_link *link)
}
void
-scsi_get_target_luns(struct scsi_link *link0, struct scsi_lun_array *lunarray)
+scsi_get_target_luns(struct scsibus_softc *sb, int target, struct
scsi_lun_array *lunarray)
{
- struct scsi_report_luns_data *report;
+ struct scsi_report_luns_data *report = NULL;
+ struct scsi_link *link0;
int i, nluns, rv = 0;
+ link0 = scsi_alloc_link(sb, target, 0);
+ if (link0 == NULL) {
+ lunarray->count = 0;
+ goto dumbscan;
+ }
+
/* Initialize dumbscan result. Just in case. */
- report = NULL;
for (i = 0; i < link0->bus->sb_luns; i++)
lunarray->luns[i] = i;
lunarray->count = link0->bus->sb_luns;
@@ -928,6 +941,8 @@ scsi_get_target_luns(struct scsi_link *l
}
dumbscan:
+ if (link0 != NULL)
+ free(link0, M_DEVBUF, sizeof(*link0));
if (report != NULL)
dma_free(report, sizeof(*report));
}