diff options
author | Dan McDonald <danmcd@joyent.com> | 2022-02-21 15:10:45 -0500 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2022-02-21 15:10:45 -0500 |
commit | ebcd0fe2a47d2edd394ec05fe4e51389205135f7 (patch) | |
tree | 106db6a17d697d1a0349888ed47813747d221981 | |
parent | 6c5a782db588047b641eaac2971cdd95add02bdf (diff) | |
parent | 74e98f497ae878ae481ccba1f91fd8dc26fa6627 (diff) | |
download | illumos-joyent-ebcd0fe2a47d2edd394ec05fe4e51389205135f7.tar.gz |
[illumos-gate merge]
commit 74e98f497ae878ae481ccba1f91fd8dc26fa6627
14484 Update Intel microcode to 20220207
commit 501bc5c03a221e7e601a0cfa80ab0972bcf20330
14471 vioblk could raise dynamic lun expansion sysevents
Conflicts:
manifest
52 files changed, 221 insertions, 71 deletions
@@ -2360,8 +2360,6 @@ h platform/i86pc/ucode/GenuineIntel/000606A6-80=platform/i86pc/ucode/GenuineInte f platform/i86pc/ucode/GenuineIntel/000706A1-01 0444 root sys f platform/i86pc/ucode/GenuineIntel/000706A8-01 0444 root sys f platform/i86pc/ucode/GenuineIntel/000706E5-80 0444 root sys -f platform/i86pc/ucode/GenuineIntel/00080664-01 0444 root sys -h platform/i86pc/ucode/GenuineIntel/00080665-01=platform/i86pc/ucode/GenuineIntel/00080664-01 f platform/i86pc/ucode/GenuineIntel/000806A1-10 0444 root sys f platform/i86pc/ucode/GenuineIntel/000806C1-80 0444 root sys f platform/i86pc/ucode/GenuineIntel/000806C2-02 0444 root sys diff --git a/usr/src/data/ucode/Makefile.links b/usr/src/data/ucode/Makefile.links index 39be3efa48..7c7233d9ca 100644 --- a/usr/src/data/ucode/Makefile.links +++ b/usr/src/data/ucode/Makefile.links @@ -153,7 +153,6 @@ INTEL_LINKS = \ 000606A6-02 \ 000606A6-04 \ 000606A6-80 \ - 00080665-01 \ 000806C2-40 \ 000806C2-80 \ 000806D1-40 \ @@ -601,9 +600,6 @@ $(ROOTINTELDIR)/000606A6-04: $(ROOTINTELDIR)/000606A6-01 $(ROOTINTELDIR)/000606A6-80: $(ROOTINTELDIR)/000606A6-01 $(RM) $@; $(LN) $^ $@ -$(ROOTINTELDIR)/00080665-01: $(ROOTINTELDIR)/00080664-01 - $(RM) $@; $(LN) $^ $@ - $(ROOTINTELDIR)/000806C2-40: $(ROOTINTELDIR)/000806C2-02 $(RM) $@; $(LN) $^ $@ diff --git a/usr/src/data/ucode/README.ucode b/usr/src/data/ucode/README.ucode index c2f0b03d81..b7785b5f99 100644 --- a/usr/src/data/ucode/README.ucode +++ b/usr/src/data/ucode/README.ucode @@ -38,4 +38,4 @@ of updating the manifest as necessary. Be careful about new files. AMD: Updated in March 2012 as part of illumos#2546. Exact revision unknown. -Intel: Linux 20210608 release +Intel: Linux 20220207 release diff --git a/usr/src/data/ucode/intel/000306F2-01 b/usr/src/data/ucode/intel/000306F2-01 Binary files differindex 04a67cf050..41a9d903b9 100644 --- a/usr/src/data/ucode/intel/000306F2-01 +++ b/usr/src/data/ucode/intel/000306F2-01 diff --git a/usr/src/data/ucode/intel/000306F4-80 b/usr/src/data/ucode/intel/000306F4-80 Binary files differindex fa7f56f52b..5f87dd2fab 100644 --- a/usr/src/data/ucode/intel/000306F4-80 +++ b/usr/src/data/ucode/intel/000306F4-80 diff --git a/usr/src/data/ucode/intel/000406E3-40 b/usr/src/data/ucode/intel/000406E3-40 Binary files differindex d9426ae970..13b343ad2a 100644 --- a/usr/src/data/ucode/intel/000406E3-40 +++ b/usr/src/data/ucode/intel/000406E3-40 diff --git a/usr/src/data/ucode/intel/000406F1-01 b/usr/src/data/ucode/intel/000406F1-01 Binary files differindex 1c6e7933a5..7ed66eabe2 100644 --- a/usr/src/data/ucode/intel/000406F1-01 +++ b/usr/src/data/ucode/intel/000406F1-01 diff --git a/usr/src/data/ucode/intel/00050653-01 b/usr/src/data/ucode/intel/00050653-01 Binary files differindex c76fac3ab0..9ec944d6cd 100644 --- a/usr/src/data/ucode/intel/00050653-01 +++ b/usr/src/data/ucode/intel/00050653-01 diff --git a/usr/src/data/ucode/intel/00050654-01 b/usr/src/data/ucode/intel/00050654-01 Binary files differindex cca28e70a8..894e5e172b 100644 --- a/usr/src/data/ucode/intel/00050654-01 +++ b/usr/src/data/ucode/intel/00050654-01 diff --git a/usr/src/data/ucode/intel/00050656-01 b/usr/src/data/ucode/intel/00050656-01 Binary files differindex 96169ce3fe..64aabb0e21 100644 --- a/usr/src/data/ucode/intel/00050656-01 +++ b/usr/src/data/ucode/intel/00050656-01 diff --git a/usr/src/data/ucode/intel/00050657-01 b/usr/src/data/ucode/intel/00050657-01 Binary files differindex f7779ee1dd..2749da188e 100644 --- a/usr/src/data/ucode/intel/00050657-01 +++ b/usr/src/data/ucode/intel/00050657-01 diff --git a/usr/src/data/ucode/intel/0005065B-01 b/usr/src/data/ucode/intel/0005065B-01 Binary files differindex 96deb26c6e..8363e7cf7f 100644 --- a/usr/src/data/ucode/intel/0005065B-01 +++ b/usr/src/data/ucode/intel/0005065B-01 diff --git a/usr/src/data/ucode/intel/00050663-10 b/usr/src/data/ucode/intel/00050663-10 Binary files differindex 2a9d8eaf7c..b4d965ff61 100644 --- a/usr/src/data/ucode/intel/00050663-10 +++ b/usr/src/data/ucode/intel/00050663-10 diff --git a/usr/src/data/ucode/intel/00050664-10 b/usr/src/data/ucode/intel/00050664-10 Binary files differindex 9bb6fbea80..4d66e5532d 100644 --- a/usr/src/data/ucode/intel/00050664-10 +++ b/usr/src/data/ucode/intel/00050664-10 diff --git a/usr/src/data/ucode/intel/00050665-10 b/usr/src/data/ucode/intel/00050665-10 Binary files differindex 12badd3891..65c6585674 100644 --- a/usr/src/data/ucode/intel/00050665-10 +++ b/usr/src/data/ucode/intel/00050665-10 diff --git a/usr/src/data/ucode/intel/000506C9-01 b/usr/src/data/ucode/intel/000506C9-01 Binary files differindex 34e1525d17..3d1aa34e93 100644 --- a/usr/src/data/ucode/intel/000506C9-01 +++ b/usr/src/data/ucode/intel/000506C9-01 diff --git a/usr/src/data/ucode/intel/000506CA-01 b/usr/src/data/ucode/intel/000506CA-01 Binary files differindex 44ca47239a..ca6f520ea5 100644 --- a/usr/src/data/ucode/intel/000506CA-01 +++ b/usr/src/data/ucode/intel/000506CA-01 diff --git a/usr/src/data/ucode/intel/000506E3-02 b/usr/src/data/ucode/intel/000506E3-02 Binary files differindex b44e31abae..761fa6660e 100644 --- a/usr/src/data/ucode/intel/000506E3-02 +++ b/usr/src/data/ucode/intel/000506E3-02 diff --git a/usr/src/data/ucode/intel/000506F1-01 b/usr/src/data/ucode/intel/000506F1-01 Binary files differindex f0f4c78068..943afa9f0d 100644 --- a/usr/src/data/ucode/intel/000506F1-01 +++ b/usr/src/data/ucode/intel/000506F1-01 diff --git a/usr/src/data/ucode/intel/000606A6-01 b/usr/src/data/ucode/intel/000606A6-01 Binary files differindex e19f676689..7a126f970f 100644 --- a/usr/src/data/ucode/intel/000606A6-01 +++ b/usr/src/data/ucode/intel/000606A6-01 diff --git a/usr/src/data/ucode/intel/000706A1-01 b/usr/src/data/ucode/intel/000706A1-01 Binary files differindex ee8a144fad..51866a1d01 100644 --- a/usr/src/data/ucode/intel/000706A1-01 +++ b/usr/src/data/ucode/intel/000706A1-01 diff --git a/usr/src/data/ucode/intel/000706A8-01 b/usr/src/data/ucode/intel/000706A8-01 Binary files differindex 9099bd3108..ddd7034a4a 100644 --- a/usr/src/data/ucode/intel/000706A8-01 +++ b/usr/src/data/ucode/intel/000706A8-01 diff --git a/usr/src/data/ucode/intel/000706E5-80 b/usr/src/data/ucode/intel/000706E5-80 Binary files differindex 0f8b5772f8..c005889fce 100644 --- a/usr/src/data/ucode/intel/000706E5-80 +++ b/usr/src/data/ucode/intel/000706E5-80 diff --git a/usr/src/data/ucode/intel/00080664-01 b/usr/src/data/ucode/intel/00080664-01 Binary files differdeleted file mode 100644 index 2d3c357f8c..0000000000 --- a/usr/src/data/ucode/intel/00080664-01 +++ /dev/null diff --git a/usr/src/data/ucode/intel/000806A1-10 b/usr/src/data/ucode/intel/000806A1-10 Binary files differindex 45b544affe..2c0c71b9ce 100644 --- a/usr/src/data/ucode/intel/000806A1-10 +++ b/usr/src/data/ucode/intel/000806A1-10 diff --git a/usr/src/data/ucode/intel/000806C1-80 b/usr/src/data/ucode/intel/000806C1-80 Binary files differindex e01ba0c1e9..906c56c3db 100644 --- a/usr/src/data/ucode/intel/000806C1-80 +++ b/usr/src/data/ucode/intel/000806C1-80 diff --git a/usr/src/data/ucode/intel/000806C2-02 b/usr/src/data/ucode/intel/000806C2-02 Binary files differindex 12da9fe36f..21f3c4ded7 100644 --- a/usr/src/data/ucode/intel/000806C2-02 +++ b/usr/src/data/ucode/intel/000806C2-02 diff --git a/usr/src/data/ucode/intel/000806D1-02 b/usr/src/data/ucode/intel/000806D1-02 Binary files differindex 5ac418b395..55cc03ab0f 100644 --- a/usr/src/data/ucode/intel/000806D1-02 +++ b/usr/src/data/ucode/intel/000806D1-02 diff --git a/usr/src/data/ucode/intel/000806E9-10 b/usr/src/data/ucode/intel/000806E9-10 Binary files differindex 11fcf69c93..42f0b936d7 100644 --- a/usr/src/data/ucode/intel/000806E9-10 +++ b/usr/src/data/ucode/intel/000806E9-10 diff --git a/usr/src/data/ucode/intel/000806E9-40 b/usr/src/data/ucode/intel/000806E9-40 Binary files differindex e08e7da081..8bce192d28 100644 --- a/usr/src/data/ucode/intel/000806E9-40 +++ b/usr/src/data/ucode/intel/000806E9-40 diff --git a/usr/src/data/ucode/intel/000806EA-40 b/usr/src/data/ucode/intel/000806EA-40 Binary files differindex d9b7508844..ef6d4f138e 100644 --- a/usr/src/data/ucode/intel/000806EA-40 +++ b/usr/src/data/ucode/intel/000806EA-40 diff --git a/usr/src/data/ucode/intel/000806EB-10 b/usr/src/data/ucode/intel/000806EB-10 Binary files differindex 6fb591d3bc..53d5ef011a 100644 --- a/usr/src/data/ucode/intel/000806EB-10 +++ b/usr/src/data/ucode/intel/000806EB-10 diff --git a/usr/src/data/ucode/intel/000806EC-04 b/usr/src/data/ucode/intel/000806EC-04 Binary files differindex 00980231fe..2d65ba226b 100644 --- a/usr/src/data/ucode/intel/000806EC-04 +++ b/usr/src/data/ucode/intel/000806EC-04 diff --git a/usr/src/data/ucode/intel/00090661-01 b/usr/src/data/ucode/intel/00090661-01 Binary files differindex 8140fcc082..06548466d3 100644 --- a/usr/src/data/ucode/intel/00090661-01 +++ b/usr/src/data/ucode/intel/00090661-01 diff --git a/usr/src/data/ucode/intel/000906C0-01 b/usr/src/data/ucode/intel/000906C0-01 Binary files differindex 2cf44b1bef..7bc9cce441 100644 --- a/usr/src/data/ucode/intel/000906C0-01 +++ b/usr/src/data/ucode/intel/000906C0-01 diff --git a/usr/src/data/ucode/intel/000906E9-02 b/usr/src/data/ucode/intel/000906E9-02 Binary files differindex 23327ecf8f..10af087b2e 100644 --- a/usr/src/data/ucode/intel/000906E9-02 +++ b/usr/src/data/ucode/intel/000906E9-02 diff --git a/usr/src/data/ucode/intel/000906EA-02 b/usr/src/data/ucode/intel/000906EA-02 Binary files differindex 13855bb023..bab21517f7 100644 --- a/usr/src/data/ucode/intel/000906EA-02 +++ b/usr/src/data/ucode/intel/000906EA-02 diff --git a/usr/src/data/ucode/intel/000906EB-02 b/usr/src/data/ucode/intel/000906EB-02 Binary files differindex c49cdc673c..0482e4b141 100644 --- a/usr/src/data/ucode/intel/000906EB-02 +++ b/usr/src/data/ucode/intel/000906EB-02 diff --git a/usr/src/data/ucode/intel/000906EC-02 b/usr/src/data/ucode/intel/000906EC-02 Binary files differindex f9b5c5ae9f..ea21168781 100644 --- a/usr/src/data/ucode/intel/000906EC-02 +++ b/usr/src/data/ucode/intel/000906EC-02 diff --git a/usr/src/data/ucode/intel/000906ED-02 b/usr/src/data/ucode/intel/000906ED-02 Binary files differindex 9b5a312dfc..ca07dec538 100644 --- a/usr/src/data/ucode/intel/000906ED-02 +++ b/usr/src/data/ucode/intel/000906ED-02 diff --git a/usr/src/data/ucode/intel/000A0652-20 b/usr/src/data/ucode/intel/000A0652-20 Binary files differindex eed05a9868..cceb88c302 100644 --- a/usr/src/data/ucode/intel/000A0652-20 +++ b/usr/src/data/ucode/intel/000A0652-20 diff --git a/usr/src/data/ucode/intel/000A0653-02 b/usr/src/data/ucode/intel/000A0653-02 Binary files differindex 9bf967dfcd..f2b8b4dff5 100644 --- a/usr/src/data/ucode/intel/000A0653-02 +++ b/usr/src/data/ucode/intel/000A0653-02 diff --git a/usr/src/data/ucode/intel/000A0655-02 b/usr/src/data/ucode/intel/000A0655-02 Binary files differindex b8ede54fe6..ddc0e87246 100644 --- a/usr/src/data/ucode/intel/000A0655-02 +++ b/usr/src/data/ucode/intel/000A0655-02 diff --git a/usr/src/data/ucode/intel/000A0660-80 b/usr/src/data/ucode/intel/000A0660-80 Binary files differindex 601bce5354..0f003e98b2 100644 --- a/usr/src/data/ucode/intel/000A0660-80 +++ b/usr/src/data/ucode/intel/000A0660-80 diff --git a/usr/src/data/ucode/intel/000A0661-80 b/usr/src/data/ucode/intel/000A0661-80 Binary files differindex c38c1510f6..ab16cc4e0c 100644 --- a/usr/src/data/ucode/intel/000A0661-80 +++ b/usr/src/data/ucode/intel/000A0661-80 diff --git a/usr/src/data/ucode/intel/000A0671-02 b/usr/src/data/ucode/intel/000A0671-02 Binary files differindex b8e29c36c7..9970cf58dd 100644 --- a/usr/src/data/ucode/intel/000A0671-02 +++ b/usr/src/data/ucode/intel/000A0671-02 diff --git a/usr/src/data/ucode/intel/THIRDPARTYLICENSE b/usr/src/data/ucode/intel/THIRDPARTYLICENSE index 8fbad3dd21..cb763c91a3 100644 --- a/usr/src/data/ucode/intel/THIRDPARTYLICENSE +++ b/usr/src/data/ucode/intel/THIRDPARTYLICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2020 Intel Corporation.
+Copyright (c) 2018-2021 Intel Corporation.
All rights reserved.
Redistribution.
diff --git a/usr/src/pkg/manifests/system-microcode-intel.p5m b/usr/src/pkg/manifests/system-microcode-intel.p5m index 9590f18276..2c7be17346 100644 --- a/usr/src/pkg/manifests/system-microcode-intel.p5m +++ b/usr/src/pkg/manifests/system-microcode-intel.p5m @@ -24,8 +24,8 @@ # Copyright 2012 Nexenta Systems, Inc. All rights reserved. # Copyright 2014 Gary Mills # Copyright 2019 Peter Tribble. -# Copyright 2020 Joyent, Inc. # Copyright 2021 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2022 Joyent, Inc. # # @@ -35,7 +35,7 @@ # <include global_zone_only_component> set name=pkg.fmri \ - value=pkg:/system/microcode/intel@20210608,$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH) + value=pkg:/system/microcode/intel@20220207,$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH) set name=pkg.summary value="Microcode for Intel CPUs" set name=pkg.description value="Microcode for Intel CPUs" set name=info.classification value=org.opensolaris.category.2008:System/Core @@ -550,9 +550,6 @@ file path=platform/i86pc/ucode/GenuineIntel/000706A8-01 group=sys mode=0444 \ reboot-needed=true file path=platform/i86pc/ucode/GenuineIntel/000706E5-80 group=sys mode=0444 \ reboot-needed=true -file path=platform/i86pc/ucode/GenuineIntel/00080664-01 group=sys mode=0444 \ - reboot-needed=true -hardlink path=platform/i86pc/ucode/GenuineIntel/00080665-01 target=00080664-01 file path=platform/i86pc/ucode/GenuineIntel/000806A1-10 group=sys mode=0444 \ reboot-needed=true file path=platform/i86pc/ucode/GenuineIntel/000806C1-80 group=sys mode=0444 \ diff --git a/usr/src/uts/common/io/vioblk/vioblk.c b/usr/src/uts/common/io/vioblk/vioblk.c index 0cccb84bce..f6649bdd12 100644 --- a/usr/src/uts/common/io/vioblk/vioblk.c +++ b/usr/src/uts/common/io/vioblk/vioblk.c @@ -25,6 +25,7 @@ * Copyright 2020 Joyent Inc. * Copyright 2019 Western Digital Corporation. * Copyright 2020 Oxide Computer Company + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -94,9 +95,10 @@ #include "vioblk.h" static void vioblk_get_id(vioblk_t *); -uint_t vioblk_int_handler(caddr_t, caddr_t); +static uint_t vioblk_int_handler(caddr_t, caddr_t); static uint_t vioblk_poll(vioblk_t *); static int vioblk_quiesce(dev_info_t *); +static int vioblk_read_capacity(vioblk_t *); static int vioblk_attach(dev_info_t *, ddi_attach_cmd_t); static int vioblk_detach(dev_info_t *, ddi_detach_cmd_t); @@ -737,8 +739,8 @@ vioblk_poll(vioblk_t *vib) return (count); } -uint_t -vioblk_int_handler(caddr_t arg0, caddr_t arg1) +static uint_t +vioblk_int_handler(caddr_t arg0, caddr_t arg1 __unused) { vioblk_t *vib = (vioblk_t *)arg0; uint_t count; @@ -755,6 +757,33 @@ vioblk_int_handler(caddr_t arg0, caddr_t arg1) return (DDI_INTR_CLAIMED); } +static uint_t +vioblk_cfgchange(caddr_t arg0, caddr_t arg1 __unused) +{ + vioblk_t *vib = (vioblk_t *)arg0; + + dev_err(vib->vib_dip, CE_NOTE, "!Configuration changed"); + + mutex_enter(&vib->vib_mutex); + + /* + * The configuration space of the device has changed in some way. + * At present, we only re-read the device capacity and trigger + * blkdev to check the device state. + */ + + if (vioblk_read_capacity(vib) == DDI_FAILURE) { + mutex_exit(&vib->vib_mutex); + return (DDI_INTR_CLAIMED); + } + + mutex_exit(&vib->vib_mutex); + + bd_state_change(vib->vib_bd_h); + + return (DDI_INTR_CLAIMED); +} + static void vioblk_free_reqs(vioblk_t *vib) { @@ -823,6 +852,50 @@ fail: } static int +vioblk_read_capacity(vioblk_t *vib) +{ + virtio_t *vio = vib->vib_virtio; + + /* The capacity is always available */ + if ((vib->vib_nblks = virtio_dev_get64(vio, + VIRTIO_BLK_CONFIG_CAPACITY)) == UINT64_MAX) { + dev_err(vib->vib_dip, CE_WARN, "invalid capacity"); + return (DDI_FAILURE); + } + + /* + * Determine the optimal logical block size recommended by the device. + * This size is advisory; the protocol always deals in 512 byte blocks. + */ + vib->vib_blk_size = DEV_BSIZE; + if (virtio_feature_present(vio, VIRTIO_BLK_F_BLK_SIZE)) { + uint32_t v = virtio_dev_get32(vio, VIRTIO_BLK_CONFIG_BLK_SIZE); + + if (v != 0 && v != PCI_EINVAL32) + vib->vib_blk_size = v; + } + + /* + * Device capacity is always in 512-byte units, convert to + * native blocks. + */ + vib->vib_nblks = (vib->vib_nblks * DEV_BSIZE) / vib->vib_blk_size; + + /* + * The device may also provide an advisory physical block size. + */ + vib->vib_pblk_size = vib->vib_blk_size; + if (virtio_feature_present(vio, VIRTIO_BLK_F_TOPOLOGY)) { + uint8_t v = virtio_dev_get8(vio, VIRTIO_BLK_CONFIG_TOPO_PBEXP); + + if (v != PCI_EINVAL8) + vib->vib_pblk_size <<= v; + } + + return (DDI_SUCCESS); +} + +static int vioblk_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) { int instance = ddi_get_instance(dip); @@ -906,6 +979,8 @@ vioblk_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) goto fail; } + virtio_register_cfgchange_handler(vio, vioblk_cfgchange, vib); + if (virtio_init_complete(vio, 0) != DDI_SUCCESS) { dev_err(dip, CE_WARN, "failed to complete Virtio init"); goto fail; @@ -944,42 +1019,9 @@ vioblk_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) kstat_install(vib->vib_kstat); vib->vib_readonly = virtio_feature_present(vio, VIRTIO_BLK_F_RO); - if ((vib->vib_nblks = virtio_dev_get64(vio, - VIRTIO_BLK_CONFIG_CAPACITY)) == UINT64_MAX) { - dev_err(dip, CE_WARN, "invalid capacity"); - goto fail; - } - - /* - * Determine the optimal logical block size recommended by the device. - * This size is advisory; the protocol always deals in 512 byte blocks. - */ - vib->vib_blk_size = DEV_BSIZE; - if (virtio_feature_present(vio, VIRTIO_BLK_F_BLK_SIZE)) { - uint32_t v = virtio_dev_get32(vio, VIRTIO_BLK_CONFIG_BLK_SIZE); - - if (v != 0 && v != PCI_EINVAL32) { - vib->vib_blk_size = v; - } - } - - /* - * Device capacity is always in 512-byte units, convert to - * native blocks. - */ - vib->vib_nblks = (vib->vib_nblks * DEV_BSIZE) / vib->vib_blk_size; - /* - * The device may also provide an advisory physical block size. - */ - vib->vib_pblk_size = vib->vib_blk_size; - if (virtio_feature_present(vio, VIRTIO_BLK_F_TOPOLOGY)) { - uint8_t v = virtio_dev_get8(vio, VIRTIO_BLK_CONFIG_TOPO_PBEXP); - - if (v != PCI_EINVAL8) { - vib->vib_pblk_size <<= v; - } - } + if (vioblk_read_capacity(vib) == DDI_FAILURE) + goto fail; /* * The maximum size for a cookie in a request. diff --git a/usr/src/uts/common/io/virtio/virtio.h b/usr/src/uts/common/io/virtio/virtio.h index 420f9ccfed..48e15b28f2 100644 --- a/usr/src/uts/common/io/virtio/virtio.h +++ b/usr/src/uts/common/io/virtio/virtio.h @@ -11,6 +11,7 @@ /* * Copyright 2019 Joyent, Inc. + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. */ #ifndef _VIRTIO_H @@ -81,6 +82,18 @@ * is usually either negotiated with the device, or determined structurally * based on the shape of the buffers required for device operation. * + * FRAMEWORK INITIALISATION: CONFIGURATION SPACE CHANGE HANDLER + * + * During the initialisation phase, the client driver may register a handler + * function for receiving device configuration space change events. Once + * initialisation has been completed, this cannot be changed without destroying + * the framework object and beginning again from scratch. + * + * When a configuration space change interrupt is received, the provided + * handler will be called with two arguments: first, the provided user data + * argument; and second, a pointer to the "virtio_t" object for this instance. + * The handler is called in an interrupt context. + * * FRAMEWORK INITIALISATION: FINISHING * * Once queue configuration has been completed, the client driver calls @@ -281,6 +294,9 @@ int virtio_init_complete(virtio_t *, int); int virtio_quiesce(virtio_t *); void virtio_shutdown(virtio_t *); +void virtio_register_cfgchange_handler(virtio_t *, ddi_intr_handler_t *, + void *); + void *virtio_intr_pri(virtio_t *); void virtio_device_reset(virtio_t *); diff --git a/usr/src/uts/common/io/virtio/virtio_impl.h b/usr/src/uts/common/io/virtio/virtio_impl.h index af786583f4..ef5f43397a 100644 --- a/usr/src/uts/common/io/virtio/virtio_impl.h +++ b/usr/src/uts/common/io/virtio/virtio_impl.h @@ -11,6 +11,7 @@ /* * Copyright 2019 Joyent, Inc. + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. */ #ifndef _VIRTIO_IMPL_H @@ -98,6 +99,11 @@ struct virtio { int vio_interrupt_type; int vio_interrupt_cap; uint_t vio_interrupt_priority; + + ddi_intr_handler_t *vio_cfgchange_handler; + void *vio_cfgchange_handlerarg; + boolean_t vio_cfgchange_handler_added; + uint_t vio_cfgchange_handler_index; }; struct virtio_queue { diff --git a/usr/src/uts/common/io/virtio/virtio_main.c b/usr/src/uts/common/io/virtio/virtio_main.c index 04b22709e8..28dce6dc92 100644 --- a/usr/src/uts/common/io/virtio/virtio_main.c +++ b/usr/src/uts/common/io/virtio/virtio_main.c @@ -11,6 +11,7 @@ /* * Copyright 2019 Joyent, Inc. + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -322,6 +323,26 @@ virtio_init(dev_info_t *dip, uint64_t driver_features, boolean_t allow_indirect) } /* + * Some virtio devices can change their device configuration state at any + * time. This function may be called by the driver during the initialisation + * phase - before calling virtio_init_complete() - in order to register a + * handler function which will be called when the device configuration space + * is updated. + */ +void +virtio_register_cfgchange_handler(virtio_t *vio, ddi_intr_handler_t *func, + void *funcarg) +{ + VERIFY(!(vio->vio_initlevel & VIRTIO_INITLEVEL_INT_ADDED)); + VERIFY(!vio->vio_cfgchange_handler_added); + + mutex_enter(&vio->vio_mutex); + vio->vio_cfgchange_handler = func; + vio->vio_cfgchange_handlerarg = funcarg; + mutex_exit(&vio->vio_mutex); +} + +/* * This function must be called by the driver once it has completed early setup * calls. The value of "allowed_interrupt_types" is a mask of interrupt types * (DDI_INTR_TYPE_MSIX, etc) that we'll try to use when installing handlers, or @@ -333,7 +354,8 @@ virtio_init_complete(virtio_t *vio, int allowed_interrupt_types) VERIFY(!(vio->vio_initlevel & VIRTIO_INITLEVEL_PROVIDER)); vio->vio_initlevel |= VIRTIO_INITLEVEL_PROVIDER; - if (!list_is_empty(&vio->vio_queues)) { + if (!list_is_empty(&vio->vio_queues) || + vio->vio_cfgchange_handler != NULL) { /* * Set up interrupts for the queues that have been registered. */ @@ -1343,32 +1365,45 @@ virtio_shared_isr(caddr_t arg0, caddr_t arg1) * this field resets it to zero. */ isr = virtio_get8(vio, VIRTIO_LEGACY_ISR_STATUS); - if ((isr & VIRTIO_ISR_CHECK_QUEUES) == 0) { - goto done; - } - for (virtio_queue_t *viq = list_head(&vio->vio_queues); viq != NULL; - viq = list_next(&vio->vio_queues, viq)) { - if (viq->viq_func != NULL) { - mutex_exit(&vio->vio_mutex); - if (viq->viq_func(viq->viq_funcarg, arg0) == - DDI_INTR_CLAIMED) { - r = DDI_INTR_CLAIMED; - } - mutex_enter(&vio->vio_mutex); + if ((isr & VIRTIO_ISR_CHECK_QUEUES) != 0) { + r = DDI_INTR_CLAIMED; - if (vio->vio_initlevel & VIRTIO_INITLEVEL_SHUTDOWN) { - /* - * The device was shut down while in a queue - * handler routine. - */ - goto done; + for (virtio_queue_t *viq = list_head(&vio->vio_queues); + viq != NULL; viq = list_next(&vio->vio_queues, viq)) { + if (viq->viq_func != NULL) { + mutex_exit(&vio->vio_mutex); + (void) viq->viq_func(viq->viq_funcarg, arg0); + mutex_enter(&vio->vio_mutex); + + if (vio->vio_initlevel & + VIRTIO_INITLEVEL_SHUTDOWN) { + /* + * The device was shut down while in a + * queue handler routine. + */ + break; + } } } } -done: mutex_exit(&vio->vio_mutex); + + /* + * vio_cfgchange_{handler,handlerarg} cannot change while interrupts + * are configured so it is safe to access them outside of the lock. + */ + + if ((isr & VIRTIO_ISR_CHECK_CONFIG) != 0) { + r = DDI_INTR_CLAIMED; + if (vio->vio_cfgchange_handler != NULL) { + (void) vio->vio_cfgchange_handler( + (caddr_t)vio->vio_cfgchange_handlerarg, + (caddr_t)vio); + } + } + return (r); } @@ -1392,6 +1427,13 @@ virtio_interrupts_setup(virtio_t *vio, int allow_types) } } + /* + * If there is a configuration change handler, one extra interrupt + * is needed for that. + */ + if (vio->vio_cfgchange_handler != NULL) + count++; + if (ddi_intr_get_supported_types(dip, &types) != DDI_SUCCESS) { dev_err(dip, CE_WARN, "could not get supported interrupts"); mutex_exit(&vio->vio_mutex); @@ -1493,6 +1535,22 @@ add_handlers: VERIFY3S(vio->vio_ninterrupts, ==, count); uint_t n = 0; + + /* Bind the configuration vector interrupt */ + if (vio->vio_cfgchange_handler != NULL) { + if (ddi_intr_add_handler(vio->vio_interrupts[n], + vio->vio_cfgchange_handler, + (caddr_t)vio->vio_cfgchange_handlerarg, + (caddr_t)vio) != DDI_SUCCESS) { + dev_err(dip, CE_WARN, + "adding configuration change interrupt failed"); + goto fail; + } + vio->vio_cfgchange_handler_added = B_TRUE; + vio->vio_cfgchange_handler_index = n; + n++; + } + for (virtio_queue_t *viq = list_head(&vio->vio_queues); viq != NULL; viq = list_next(&vio->vio_queues, viq)) { if (viq->viq_func == NULL) { @@ -1546,6 +1604,21 @@ virtio_interrupts_teardown(virtio_t *vio) } } } else { + /* + * Remove the configuration vector interrupt handler. + */ + if (vio->vio_cfgchange_handler_added) { + int r; + + if ((r = ddi_intr_remove_handler( + vio->vio_interrupts[0])) != DDI_SUCCESS) { + dev_err(vio->vio_dip, CE_WARN, + "removing configuration change interrupt " + "handler failed (%d)", r); + } + vio->vio_cfgchange_handler_added = B_FALSE; + } + for (virtio_queue_t *viq = list_head(&vio->vio_queues); viq != NULL; viq = list_next(&vio->vio_queues, viq)) { int r; @@ -1606,6 +1679,11 @@ virtio_interrupts_unwind(virtio_t *vio) virtio_put16(vio, VIRTIO_LEGACY_MSIX_QUEUE, VIRTIO_LEGACY_MSI_NO_VECTOR); } + + if (vio->vio_cfgchange_handler_added) { + virtio_put16(vio, VIRTIO_LEGACY_MSIX_CONFIG, + VIRTIO_LEGACY_MSI_NO_VECTOR); + } } if (vio->vio_interrupt_cap & DDI_INTR_FLAG_BLOCK) { @@ -1703,6 +1781,23 @@ virtio_interrupts_enable(virtio_t *vio) return (DDI_FAILURE); } } + + if (vio->vio_cfgchange_handler_added) { + virtio_put16(vio, VIRTIO_LEGACY_MSIX_CONFIG, + vio->vio_cfgchange_handler_index); + + /* Verify the value was accepted. */ + if (virtio_get16(vio, VIRTIO_LEGACY_MSIX_CONFIG) != + vio->vio_cfgchange_handler_index) { + dev_err(vio->vio_dip, CE_WARN, + "failed to configure MSI-X vector for " + "configuration"); + + virtio_interrupts_unwind(vio); + mutex_exit(&vio->vio_mutex); + return (DDI_FAILURE); + } + } } vio->vio_initlevel |= VIRTIO_INITLEVEL_INT_ENABLED; |