Bug 254841 - usr.sbin/mpsutil: add functionality (temperature monitoring, PCIe speed etc)
Summary: usr.sbin/mpsutil: add functionality (temperature monitoring, PCIe speed etc)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Andriy Gapon
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2021-04-06 23:54 UTC by Daniel Austin
Modified: 2021-05-21 13:48 UTC (History)
4 users (show)

See Also:


Attachments
Add functionality to mpsutil (1.55 KB, patch)
2021-04-06 23:54 UTC, Daniel Austin
no flags Details | Diff
Add functionality to mpsutil (2.32 KB, patch)
2021-04-09 22:53 UTC, Daniel Austin
no flags Details | Diff
Add functionality to mpsutil (6.80 KB, patch)
2021-04-09 22:59 UTC, Daniel Austin
no flags Details | Diff
update mpsutil.8 with set ncq (674 bytes, patch)
2021-04-14 09:53 UTC, Rodrigo Osorio
no flags Details | Diff
Replacement mps_set.c (4.08 KB, text/plain)
2021-05-07 11:59 UTC, Daniel Austin
freebsd-ports: maintainer-approval+
Details
Updated copyright (3.90 KB, text/plain)
2021-05-07 12:08 UTC, Daniel Austin
freebsd-ports: maintainer-approval+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Austin 2021-04-06 23:54:38 UTC
Created attachment 223884 [details]
Add functionality to mpsutil

The attached patch adds a little functionality to the 'mpsutil' (and therefore probably also mprutil).
In the 'show adapter' output, it now shows PCIe width and speed, IOC Speed, and (the reason I wrote this patch) the temperature of the controller.

I run LSI 9206-16e cards which are notoriously hot (literally boil water hot!) and I wanted to monitor its temperature but this was awkward before.

I added the other features because they seemed useful and were already fetched in the same config page as the temperature.  (note: the temperature units come from the card itself, although i've only ever seen Celcius)

Here's an example output on a LSI 9207-8i card I used for testing the patch:

mps0 Adapter:
       Board Name: SAS9207-8i
   Board Assembly: H3-25590-00B
        Chip Name: LSISAS2308
    Chip Revision: ALL
    BIOS Revision: 7.29.00.00
Firmware Revision: 20.00.07.00
  Integrated RAID: no
 PCIe Width/Speed: x8 (5.0 GB/sec)
        IOC Speed: Full
      Temperature: 63 C

PhyNum  CtlrHandle  DevHandle  Disabled  Speed   Min    Max    Device
0                              N                 1.5    6.0    SAS Initiator
1                              N                 1.5    6.0    SAS Initiator
2                              N                 1.5    6.0    SAS Initiator
3                              N                 1.5    6.0    SAS Initiator
4       0001        0009       N         6.0     1.5    6.0    SAS Initiator
5       0002        000a       N         6.0     1.5    6.0    SAS Initiator
6       0003        000b       N         6.0     1.5    6.0    SAS Initiator
7       0004        000c       N         6.0     1.5    6.0    SAS Initiator
Comment 1 Daniel Austin 2021-04-09 22:53:43 UTC
Created attachment 223965 [details]
Add functionality to mpsutil

I've updated the patch to show whether SATA NCQ is enabled in 'show adapter' and also added a new command "set ncq [enable|disable]" which enables or disables NCQ in the NVRAM of the card.

This is particularly useful in some external JBOD enclosures.
For example, I use a QNAP TL-D1600S 16 bay and with NCQ enabled wth mps cards I receive errors from all attached drives.

Once the system is booted, you can use camcontrol tags to effectively disable NCQ which works around the problem, but the kernel still has to suffer before that point (e.g. with ZFS, just probing for pools could make my system take 5+ mins to boot)... I discovered this workaround via Google.

I had worked around it by using lsiutil in Linux to disable NCQ on the card, and with this patch users of FreeBSD / TrueNAS etc can set that setting in their chosen OS.

Note: this diff also adds a new file (mps_set.c)
Comment 2 Daniel Austin 2021-04-09 22:59:21 UTC
Created attachment 223966 [details]
Add functionality to mpsutil

wrong attachment - sorry (fixed!)
Comment 3 Andriy Gapon freebsd_committer freebsd_triage 2021-04-14 08:58:34 UTC
(In reply to Daniel Austin from comment #2)
mps_set.c looks like a new file, you should put your own copyright into it (assuming you are the author, of course).

Other than that, the change looks good to me and I can commit it unless anyone objects.
Comment 4 Yuri Pankov freebsd_committer freebsd_triage 2021-04-14 09:39:57 UTC
The patch seems to work fine for me, sadly it looks like my board does not have temp sensor (I was worried about it getting very hot too and even slapped a small fan on it):

mps0 Adapter:
       Board Name: SAS9211-8i
   Board Assembly: H3-25250-02G
        Chip Name: LSISAS2008
    Chip Revision: ALL
    BIOS Revision: 7.37.00.00
Firmware Revision: 20.00.07.00
  Integrated RAID: no
         SATA NCQ: ENABLED
 PCIe Width/Speed: x8 (5.0 GB/sec)
        IOC Speed: Full
      Temperature: Unknown/Unsupported
Comment 5 Rodrigo Osorio freebsd_committer freebsd_triage 2021-04-14 09:53:28 UTC
Created attachment 224099 [details]
update mpsutil.8 with set ncq

My two cents to update mpsutil manpage
Comment 6 Daniel Austin 2021-04-14 09:54:24 UTC
(In reply to Yuri Pankov from comment #4)
Hi Yuri,

Could you let me know the output of:

mpsutil show cfgpage 0 7
Comment 7 Yuri Pankov freebsd_committer freebsd_triage 2021-04-14 09:55:55 UTC
(In reply to Daniel Austin from comment #6)
Daniel, here you go:

Page 0x0: IO Unit 7, Read-only
0000   00 07 0a 04  |....|
0004   01 08 00 00  |....|
0008   00 00 00 00  |....|
000c   00 00 00 00  |....|
0010   01 00 00 00  |....|
0014   00 00 00 00  |....|
0018   00 01 00 00  |....|
001c   00 00 00 00  |....|
0020   00 00 00 00  |....|
0024   00 00 01 00  |....|
Comment 8 Daniel Austin 2021-04-14 10:11:08 UTC
(In reply to Yuri Pankov from comment #7)
Ah, sadly that means there are no temperature sensors on your board or controller ICs :-(

I've never seen a lsisas2008 chip overheat so long as it had airflow though, so your fan will be working fine... I managed to clock my lsisas2308 at 111C with a fan nearby... now with better more direct fans i've got it down to around 70C.
I've never seen cards run as hot as the 2308s!
Comment 9 Yuri Pankov freebsd_committer freebsd_triage 2021-04-14 10:20:00 UTC
(In reply to Daniel Austin from comment #8)
In any case, works with 2308 for me too, thanks for the patch!

mps0 Adapter:
       Board Name: SAS9205-8e
   Board Assembly: H3-25360-04G
        Chip Name: LSISAS2308
    Chip Revision: ALL
    BIOS Revision: 7.35.00.00
Firmware Revision: 18.00.00.00
  Integrated RAID: no
         SATA NCQ: ENABLED
 PCIe Width/Speed: x8 (5.0 GB/sec)
        IOC Speed: Full
      Temperature: 49 C
Comment 10 Andriy Gapon freebsd_committer freebsd_triage 2021-05-07 11:41:32 UTC
Daniel, how would you like to be attributed in a commit?
Is Daniel Austin <freebsd-ports@dan.me.uk> okay?
Comment 11 Daniel Austin 2021-05-07 11:54:07 UTC
(In reply to Andriy Gapon from comment #10)
Hi Andriy,

That's fine with me - sure.

Thanks.
Comment 12 Andriy Gapon freebsd_committer freebsd_triage 2021-05-07 11:55:17 UTC
Daniel, the new file, mps_set.c, has copyrights that appear to be copied from one of the existing source files.
I think that you should put your own copyright there unless you think that you copied a significant portion of the original file (which seems unlikely).
Comment 13 Daniel Austin 2021-05-07 11:59:04 UTC
Created attachment 224748 [details]
Replacement mps_set.c

Replacement mps_set.c fixing copyright information.
Comment 14 Andriy Gapon freebsd_committer freebsd_triage 2021-05-07 12:05:12 UTC
(In reply to Daniel Austin from comment #13)
Sorry for being pedantic, but could you please use the latest BSD license template from share/examples/etc/bsd-style-copyright ?

Since you are both the author and the copyright holder you don't need the "Written by" line, just put everything you want (name, email) on the "Copyright" line.
I could do those changes for you, but since this is a copyright matter, it's a little delicate :-)
Thank you!
Comment 15 Daniel Austin 2021-05-07 12:08:10 UTC
Created attachment 224749 [details]
Updated copyright
Comment 16 commit-hook freebsd_committer freebsd_triage 2021-05-07 12:23:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51

commit e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51
Author:     Daniel Austin <freebsd-ports@dan.me.uk>
AuthorDate: 2021-05-07 11:41:53 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-05-07 12:22:22 +0000

    mpsutil: extend show adapter information, add NCQ control

    'show adapter' now shows PCIe width and speed, IOC Speed, and the
    temperature of the controller.

    A new command, 'set ncq', is added.
    It enables or disables SATA NCQ in the NVRAM of the card.
    Its current setting is added to 'show adapter' as well.

    PR:             254841
    MFC after:      2 weeks
    Relnotes:       perhaps

 usr.sbin/mpsutil/Makefile        |   2 +-
 usr.sbin/mpsutil/mps_set.c (new) | 129 +++++++++++++++++++++++++++++++++++++++
 usr.sbin/mpsutil/mps_show.c      |  34 +++++++++++
 usr.sbin/mpsutil/mpsutil.8       |   8 ++-
 4 files changed, 171 insertions(+), 2 deletions(-)
Comment 17 commit-hook freebsd_committer freebsd_triage 2021-05-21 10:30:36 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=395bc3598b47ef270d17beae778830e134814fbe

commit 395bc3598b47ef270d17beae778830e134814fbe
Author:     Daniel Austin <freebsd-ports@dan.me.uk>
AuthorDate: 2021-05-07 11:41:53 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-05-21 10:29:17 +0000

    mpsutil: extend show adapter information, add NCQ control

    'show adapter' now shows PCIe width and speed, IOC Speed, and the
    temperature of the controller.

    A new command, 'set ncq', is added.
    It enables or disables SATA NCQ in the NVRAM of the card.
    Its current setting is added to 'show adapter' as well.

    PR:             254841
    MFC after:      2 weeks
    Relnotes:       perhaps

    (cherry picked from commit e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51)

 usr.sbin/mpsutil/Makefile        |   2 +-
 usr.sbin/mpsutil/mps_set.c (new) | 129 +++++++++++++++++++++++++++++++++++++++
 usr.sbin/mpsutil/mps_show.c      |  34 +++++++++++
 usr.sbin/mpsutil/mpsutil.8       |   8 ++-
 4 files changed, 171 insertions(+), 2 deletions(-)
Comment 18 commit-hook freebsd_committer freebsd_triage 2021-05-21 13:45:56 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4b9d54e2aeca7435698bd37a2d99416acb23c9b5

commit 4b9d54e2aeca7435698bd37a2d99416acb23c9b5
Author:     Daniel Austin <freebsd-ports@dan.me.uk>
AuthorDate: 2021-05-07 11:41:53 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-05-21 10:32:35 +0000

    mpsutil: extend show adapter information, add NCQ control

    'show adapter' now shows PCIe width and speed, IOC Speed, and the
    temperature of the controller.

    A new command, 'set ncq', is added.
    It enables or disables SATA NCQ in the NVRAM of the card.
    Its current setting is added to 'show adapter' as well.

    PR:             254841
    Relnotes:       perhaps

    (cherry picked from commit e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51)

 usr.sbin/mpsutil/Makefile        |   2 +-
 usr.sbin/mpsutil/mps_set.c (new) | 129 +++++++++++++++++++++++++++++++++++++++
 usr.sbin/mpsutil/mps_show.c      |  34 +++++++++++
 usr.sbin/mpsutil/mpsutil.8       |   8 ++-
 4 files changed, 171 insertions(+), 2 deletions(-)
Comment 19 Andriy Gapon freebsd_committer freebsd_triage 2021-05-21 13:48:01 UTC
Thank you again for the great submission.
The change is in all supported branches now.