2009-10-14 16:19:21 +08:00
|
|
|
/*
|
2013-04-17 18:56:36 +08:00
|
|
|
* PMC-Sierra 8001/8081/8088/8089 SAS/SATA based host adapters driver
|
2009-10-14 16:19:21 +08:00
|
|
|
*
|
|
|
|
* Copyright (c) 2008-2009 USI Co., Ltd.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/firmware.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-10-14 16:19:21 +08:00
|
|
|
#include "pm8001_sas.h"
|
|
|
|
#include "pm8001_ctl.h"
|
2021-04-15 18:33:45 +08:00
|
|
|
#include "pm8001_chips.h"
|
2009-10-14 16:19:21 +08:00
|
|
|
|
|
|
|
/* scsi host attributes */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_mpi_interface_rev_show - MPI interface revision number
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_mpi_interface_rev_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2013-04-17 18:56:36 +08:00
|
|
|
if (pm8001_ha->chip_id == chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2013-04-17 18:56:36 +08:00
|
|
|
pm8001_ha->main_cfg_tbl.pm8001_tbl.interface_rev);
|
|
|
|
} else {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2013-04-17 18:56:36 +08:00
|
|
|
pm8001_ha->main_cfg_tbl.pm80xx_tbl.interface_rev);
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
static
|
|
|
|
DEVICE_ATTR(interface_rev, S_IRUGO, pm8001_ctl_mpi_interface_rev_show, NULL);
|
|
|
|
|
2019-11-14 18:09:08 +08:00
|
|
|
/**
|
|
|
|
* controller_fatal_error_show - check controller is under fatal err
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2019-11-14 18:09:08 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
2021-07-09 00:57:23 +08:00
|
|
|
* A sysfs 'read-only' shost attribute.
|
2019-11-14 18:09:08 +08:00
|
|
|
*/
|
|
|
|
static ssize_t controller_fatal_error_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2019-11-14 18:09:08 +08:00
|
|
|
pm8001_ha->controller_fatal_error);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(controller_fatal_error);
|
|
|
|
|
2009-10-14 16:19:21 +08:00
|
|
|
/**
|
|
|
|
* pm8001_ctl_fw_version_show - firmware version
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-22 00:41:19 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_fw_version_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2013-04-17 18:56:36 +08:00
|
|
|
if (pm8001_ha->chip_id == chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
|
2013-04-17 18:56:36 +08:00
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 24),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 16),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 8),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev));
|
|
|
|
} else {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
|
2013-04-17 18:56:36 +08:00
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 24),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 16),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 8),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev));
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(fw_version, S_IRUGO, pm8001_ctl_fw_version_show, NULL);
|
2017-10-18 14:09:08 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_ila_version_show - ila version
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2017-10-18 14:09:08 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_ila_version_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
|
|
|
if (pm8001_ha->chip_id != chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
|
2017-10-18 14:09:08 +08:00
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 24),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 16),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 8),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(ila_version, 0444, pm8001_ctl_ila_version_show, NULL);
|
|
|
|
|
|
|
|
/**
|
2021-07-09 00:57:23 +08:00
|
|
|
* pm8001_ctl_inactive_fw_version_show - Inactive firmware version number
|
2017-10-18 14:09:08 +08:00
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2017-10-18 14:09:08 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_inactive_fw_version_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
|
|
|
if (pm8001_ha->chip_id != chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
|
2017-10-18 14:09:08 +08:00
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 24),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 16),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 8),
|
|
|
|
(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static
|
|
|
|
DEVICE_ATTR(inc_fw_ver, 0444, pm8001_ctl_inactive_fw_version_show, NULL);
|
|
|
|
|
2009-10-14 16:19:21 +08:00
|
|
|
/**
|
|
|
|
* pm8001_ctl_max_out_io_show - max outstanding io supported
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_max_out_io_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2013-04-17 18:56:36 +08:00
|
|
|
if (pm8001_ha->chip_id == chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2013-04-17 18:56:36 +08:00
|
|
|
pm8001_ha->main_cfg_tbl.pm8001_tbl.max_out_io);
|
|
|
|
} else {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2013-04-17 18:56:36 +08:00
|
|
|
pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io);
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(max_out_io, S_IRUGO, pm8001_ctl_max_out_io_show, NULL);
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_max_devices_show - max devices support
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_max_devices_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2013-04-17 18:56:36 +08:00
|
|
|
if (pm8001_ha->chip_id == chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%04d\n",
|
|
|
|
(u16)(pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl >> 16));
|
2013-04-17 18:56:36 +08:00
|
|
|
} else {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%04d\n",
|
|
|
|
(u16)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl >> 16));
|
2013-04-17 18:56:36 +08:00
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(max_devices, S_IRUGO, pm8001_ctl_max_devices_show, NULL);
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_max_sg_list_show - max sg list supported iff not 0.0 for no
|
|
|
|
* hardware limitation
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_max_sg_list_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2013-04-17 18:56:36 +08:00
|
|
|
if (pm8001_ha->chip_id == chip_8001) {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%04d\n",
|
|
|
|
pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl & 0x0000FFFF);
|
2013-04-17 18:56:36 +08:00
|
|
|
} else {
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%04d\n",
|
|
|
|
pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl & 0x0000FFFF);
|
2013-04-17 18:56:36 +08:00
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(max_sg_list, S_IRUGO, pm8001_ctl_max_sg_list_show, NULL);
|
|
|
|
|
|
|
|
#define SAS_1_0 0x1
|
|
|
|
#define SAS_1_1 0x2
|
|
|
|
#define SAS_2_0 0x4
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
show_sas_spec_support_status(unsigned int mode, char *buf)
|
|
|
|
{
|
|
|
|
ssize_t len = 0;
|
|
|
|
|
|
|
|
if (mode & SAS_1_1)
|
|
|
|
len = sprintf(buf, "%s", "SAS1.1");
|
|
|
|
if (mode & SAS_2_0)
|
|
|
|
len += sprintf(buf + len, "%s%s", len ? ", " : "", "SAS2.0");
|
|
|
|
len += sprintf(buf + len, "\n");
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_sas_spec_support_show - sas spec supported
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_sas_spec_support_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
unsigned int mode;
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
2013-04-17 18:56:36 +08:00
|
|
|
/* fe000000 means supports SAS2.1 */
|
|
|
|
if (pm8001_ha->chip_id == chip_8001)
|
|
|
|
mode = (pm8001_ha->main_cfg_tbl.pm8001_tbl.ctrl_cap_flag &
|
|
|
|
0xfe000000)>>25;
|
|
|
|
else
|
|
|
|
/* fe000000 means supports SAS2.1 */
|
|
|
|
mode = (pm8001_ha->main_cfg_tbl.pm80xx_tbl.ctrl_cap_flag &
|
|
|
|
0xfe000000)>>25;
|
2009-10-14 16:19:21 +08:00
|
|
|
return show_sas_spec_support_status(mode, buf);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(sas_spec_support, S_IRUGO,
|
|
|
|
pm8001_ctl_sas_spec_support_show, NULL);
|
|
|
|
|
|
|
|
/**
|
2021-03-03 22:46:14 +08:00
|
|
|
* pm8001_ctl_host_sas_address_show - sas address
|
2009-10-14 16:19:21 +08:00
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* This is the controller sas address
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_host_sas_address_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "0x%016llx\n",
|
2009-10-14 16:19:21 +08:00
|
|
|
be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr));
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(host_sas_address, S_IRUGO,
|
|
|
|
pm8001_ctl_host_sas_address_show, NULL);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_logging_level_show - logging level
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-22 00:41:19 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read/write' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_logging_level_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%08xh\n", pm8001_ha->logging_level);
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
2020-07-22 00:41:19 +08:00
|
|
|
|
2009-10-14 16:19:21 +08:00
|
|
|
static ssize_t pm8001_ctl_logging_level_store(struct device *cdev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
int val = 0;
|
|
|
|
|
|
|
|
if (sscanf(buf, "%x", &val) != 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pm8001_ha->logging_level = val;
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(logging_level, S_IRUGO | S_IWUSR,
|
|
|
|
pm8001_ctl_logging_level_show, pm8001_ctl_logging_level_store);
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_aap_log_show - aap1 event log
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_aap_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
2021-04-08 20:56:32 +08:00
|
|
|
u8 *ptr = (u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr;
|
2009-10-14 16:19:21 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
char *str = buf;
|
|
|
|
int max = 2;
|
|
|
|
for (i = 0; i < max; i++) {
|
|
|
|
str += sprintf(str, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x"
|
|
|
|
"0x%08x 0x%08x\n",
|
2021-04-08 20:56:32 +08:00
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 0),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 4),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 8),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 12),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 16),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 20),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 24),
|
|
|
|
pm8001_ctl_aap1_memmap(ptr, i, 28));
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return str - buf;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(aap_log, S_IRUGO, pm8001_ctl_aap_log_show, NULL);
|
2013-09-04 15:27:00 +08:00
|
|
|
/**
|
|
|
|
* pm8001_ctl_ib_queue_log_show - Out bound Queue log
|
|
|
|
* @cdev:pointer to embedded class device
|
2020-07-22 00:41:19 +08:00
|
|
|
* @attr: device attribute (unused)
|
2013-09-04 15:27:00 +08:00
|
|
|
* @buf: the buffer returned
|
2021-07-09 00:57:23 +08:00
|
|
|
*
|
2013-09-04 15:27:00 +08:00
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_ib_queue_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
int offset;
|
|
|
|
char *str = buf;
|
|
|
|
int start = 0;
|
2020-10-05 22:50:08 +08:00
|
|
|
u32 ib_offset = pm8001_ha->ib_offset;
|
2021-09-07 01:04:03 +08:00
|
|
|
u32 queue_size = pm8001_ha->max_q_num * PM8001_MPI_QUEUE * 128;
|
2013-12-10 13:01:28 +08:00
|
|
|
#define IB_MEMMAP(c) \
|
|
|
|
(*(u32 *)((u8 *)pm8001_ha-> \
|
2020-10-05 22:50:08 +08:00
|
|
|
memoryMap.region[ib_offset].virt_ptr + \
|
2013-09-04 15:27:00 +08:00
|
|
|
pm8001_ha->evtlog_ib_offset + (c)))
|
|
|
|
|
|
|
|
for (offset = 0; offset < IB_OB_READ_TIMES; offset++) {
|
2013-12-10 13:01:28 +08:00
|
|
|
str += sprintf(str, "0x%08x\n", IB_MEMMAP(start));
|
2013-09-04 15:27:00 +08:00
|
|
|
start = start + 4;
|
|
|
|
}
|
|
|
|
pm8001_ha->evtlog_ib_offset += SYSFS_OFFSET;
|
2021-09-07 01:04:03 +08:00
|
|
|
if (((pm8001_ha->evtlog_ib_offset) % queue_size) == 0)
|
2013-09-04 15:27:00 +08:00
|
|
|
pm8001_ha->evtlog_ib_offset = 0;
|
|
|
|
|
|
|
|
return str - buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(ib_log, S_IRUGO, pm8001_ctl_ib_queue_log_show, NULL);
|
|
|
|
/**
|
|
|
|
* pm8001_ctl_ob_queue_log_show - Out bound Queue log
|
|
|
|
* @cdev:pointer to embedded class device
|
2020-07-22 00:41:19 +08:00
|
|
|
* @attr: device attribute (unused)
|
2013-09-04 15:27:00 +08:00
|
|
|
* @buf: the buffer returned
|
2021-07-09 00:57:23 +08:00
|
|
|
*
|
2013-09-04 15:27:00 +08:00
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static ssize_t pm8001_ctl_ob_queue_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
int offset;
|
|
|
|
char *str = buf;
|
|
|
|
int start = 0;
|
2020-10-05 22:50:08 +08:00
|
|
|
u32 ob_offset = pm8001_ha->ob_offset;
|
2021-09-07 01:04:03 +08:00
|
|
|
u32 queue_size = pm8001_ha->max_q_num * PM8001_MPI_QUEUE * 128;
|
2013-12-10 13:01:28 +08:00
|
|
|
#define OB_MEMMAP(c) \
|
|
|
|
(*(u32 *)((u8 *)pm8001_ha-> \
|
2020-10-05 22:50:08 +08:00
|
|
|
memoryMap.region[ob_offset].virt_ptr + \
|
2013-09-04 15:27:00 +08:00
|
|
|
pm8001_ha->evtlog_ob_offset + (c)))
|
|
|
|
|
|
|
|
for (offset = 0; offset < IB_OB_READ_TIMES; offset++) {
|
2013-12-10 13:01:28 +08:00
|
|
|
str += sprintf(str, "0x%08x\n", OB_MEMMAP(start));
|
2013-09-04 15:27:00 +08:00
|
|
|
start = start + 4;
|
|
|
|
}
|
|
|
|
pm8001_ha->evtlog_ob_offset += SYSFS_OFFSET;
|
2021-09-07 01:04:03 +08:00
|
|
|
if (((pm8001_ha->evtlog_ob_offset) % queue_size) == 0)
|
2013-09-04 15:27:00 +08:00
|
|
|
pm8001_ha->evtlog_ob_offset = 0;
|
|
|
|
|
|
|
|
return str - buf;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(ob_log, S_IRUGO, pm8001_ctl_ob_queue_log_show, NULL);
|
2013-09-18 15:24:41 +08:00
|
|
|
/**
|
|
|
|
* pm8001_ctl_bios_version_show - Bios version Display
|
|
|
|
* @cdev:pointer to embedded class device
|
2020-07-22 00:41:19 +08:00
|
|
|
* @attr: device attribute (unused)
|
2013-09-18 15:24:41 +08:00
|
|
|
* @buf:the buffer returned
|
2021-07-09 00:57:23 +08:00
|
|
|
*
|
2013-09-18 15:24:41 +08:00
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_bios_version_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
char *str = buf;
|
|
|
|
int bios_index;
|
|
|
|
DECLARE_COMPLETION_ONSTACK(completion);
|
|
|
|
struct pm8001_ioctl_payload payload;
|
|
|
|
|
|
|
|
pm8001_ha->nvmd_completion = &completion;
|
|
|
|
payload.minor_function = 7;
|
|
|
|
payload.offset = 0;
|
2020-03-16 15:49:06 +08:00
|
|
|
payload.rd_length = 4096;
|
2013-09-18 15:24:41 +08:00
|
|
|
payload.func_specific = kzalloc(4096, GFP_KERNEL);
|
2014-05-09 14:01:01 +08:00
|
|
|
if (!payload.func_specific)
|
|
|
|
return -ENOMEM;
|
2014-07-09 19:51:11 +08:00
|
|
|
if (PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload)) {
|
|
|
|
kfree(payload.func_specific);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2013-09-18 15:24:41 +08:00
|
|
|
wait_for_completion(&completion);
|
|
|
|
for (bios_index = BIOSOFFSET; bios_index < BIOS_OFFSET_LIMIT;
|
|
|
|
bios_index++)
|
|
|
|
str += sprintf(str, "%c",
|
2014-08-11 14:20:35 +08:00
|
|
|
*(payload.func_specific+bios_index));
|
2014-05-09 14:01:01 +08:00
|
|
|
kfree(payload.func_specific);
|
2013-09-18 15:24:41 +08:00
|
|
|
return str - buf;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL);
|
2019-06-24 16:22:27 +08:00
|
|
|
/**
|
|
|
|
* event_log_size_show - event log size
|
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2019-06-24 16:22:27 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs read shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t event_log_size_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2019-06-24 16:22:27 +08:00
|
|
|
pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(event_log_size);
|
2009-10-14 16:19:21 +08:00
|
|
|
/**
|
2021-03-03 22:46:14 +08:00
|
|
|
* pm8001_ctl_iop_log_show - IOP event log
|
2009-10-14 16:19:21 +08:00
|
|
|
* @cdev: pointer to embedded class device
|
2020-07-13 15:59:47 +08:00
|
|
|
* @attr: device attribute (unused)
|
2009-10-14 16:19:21 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t pm8001_ctl_iop_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
char *str = buf;
|
2019-06-24 16:22:28 +08:00
|
|
|
u32 read_size =
|
|
|
|
pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size / 1024;
|
|
|
|
static u32 start, end, count;
|
|
|
|
u32 max_read_times = 32;
|
|
|
|
u32 max_count = (read_size * 1024) / (max_read_times * 4);
|
|
|
|
u32 *temp = (u32 *)pm8001_ha->memoryMap.region[IOP].virt_ptr;
|
|
|
|
|
|
|
|
if ((count % max_count) == 0) {
|
|
|
|
start = 0;
|
|
|
|
end = max_read_times;
|
|
|
|
count = 0;
|
|
|
|
} else {
|
|
|
|
start = end;
|
|
|
|
end = end + max_read_times;
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
2019-06-24 16:22:28 +08:00
|
|
|
for (; start < end; start++)
|
|
|
|
str += sprintf(str, "%08x ", *(temp+start));
|
|
|
|
count++;
|
2009-10-14 16:19:21 +08:00
|
|
|
return str - buf;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(iop_log, S_IRUGO, pm8001_ctl_iop_log_show, NULL);
|
|
|
|
|
2013-09-04 15:27:00 +08:00
|
|
|
/**
|
2021-07-09 00:57:23 +08:00
|
|
|
* pm8001_ctl_fatal_log_show - fatal error logging
|
|
|
|
* @cdev:pointer to embedded class device
|
|
|
|
* @attr: device attribute
|
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
2013-09-04 15:27:00 +08:00
|
|
|
|
|
|
|
static ssize_t pm8001_ctl_fatal_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2013-12-10 13:01:38 +08:00
|
|
|
ssize_t count;
|
2013-09-04 15:27:00 +08:00
|
|
|
|
|
|
|
count = pm80xx_get_fatal_dump(cdev, attr, buf);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL);
|
|
|
|
|
2020-03-16 15:49:05 +08:00
|
|
|
/**
|
2021-07-09 00:57:23 +08:00
|
|
|
* non_fatal_log_show - non fatal error logging
|
|
|
|
* @cdev:pointer to embedded class device
|
|
|
|
* @attr: device attribute
|
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
2020-03-16 15:49:05 +08:00
|
|
|
static ssize_t non_fatal_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
u32 count;
|
|
|
|
|
|
|
|
count = pm80xx_get_non_fatal_dump(cdev, attr, buf);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(non_fatal_log);
|
|
|
|
|
|
|
|
static ssize_t non_fatal_count_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
2022-12-09 04:11:43 +08:00
|
|
|
return sysfs_emit(buf, "%08x\n",
|
2020-03-16 15:49:05 +08:00
|
|
|
pm8001_ha->non_fatal_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t non_fatal_count_store(struct device *cdev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
int val = 0;
|
|
|
|
|
|
|
|
if (kstrtoint(buf, 16, &val) != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pm8001_ha->non_fatal_count = val;
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RW(non_fatal_count);
|
2013-09-04 15:27:00 +08:00
|
|
|
|
|
|
|
/**
|
2021-07-09 00:57:23 +08:00
|
|
|
* pm8001_ctl_gsm_log_show - gsm dump collection
|
|
|
|
* @cdev:pointer to embedded class device
|
|
|
|
* @attr: device attribute (unused)
|
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
2013-09-04 15:27:00 +08:00
|
|
|
static ssize_t pm8001_ctl_gsm_log_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2013-12-10 13:01:38 +08:00
|
|
|
ssize_t count;
|
2013-09-04 15:27:00 +08:00
|
|
|
|
|
|
|
count = pm8001_get_gsm_dump(cdev, SYSFS_OFFSET, buf);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(gsm_log, S_IRUGO, pm8001_ctl_gsm_log_show, NULL);
|
|
|
|
|
2009-10-14 16:19:21 +08:00
|
|
|
#define FLASH_CMD_NONE 0x00
|
|
|
|
#define FLASH_CMD_UPDATE 0x01
|
|
|
|
#define FLASH_CMD_SET_NVMD 0x02
|
|
|
|
|
|
|
|
struct flash_command {
|
|
|
|
u8 command[8];
|
|
|
|
int code;
|
|
|
|
};
|
|
|
|
|
2021-04-08 20:56:33 +08:00
|
|
|
static const struct flash_command flash_command_table[] = {
|
2009-10-14 16:19:21 +08:00
|
|
|
{"set_nvmd", FLASH_CMD_SET_NVMD},
|
|
|
|
{"update", FLASH_CMD_UPDATE},
|
|
|
|
{"", FLASH_CMD_NONE} /* Last entry should be NULL. */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct error_fw {
|
|
|
|
char *reason;
|
|
|
|
int err_code;
|
|
|
|
};
|
|
|
|
|
2021-04-08 20:56:33 +08:00
|
|
|
static const struct error_fw flash_error_table[] = {
|
2009-10-14 16:19:21 +08:00
|
|
|
{"Failed to open fw image file", FAIL_OPEN_BIOS_FILE},
|
|
|
|
{"image header mismatch", FLASH_UPDATE_HDR_ERR},
|
|
|
|
{"image offset mismatch", FLASH_UPDATE_OFFSET_ERR},
|
|
|
|
{"image CRC Error", FLASH_UPDATE_CRC_ERR},
|
|
|
|
{"image length Error.", FLASH_UPDATE_LENGTH_ERR},
|
|
|
|
{"Failed to program flash chip", FLASH_UPDATE_HW_ERR},
|
|
|
|
{"Flash chip not supported.", FLASH_UPDATE_DNLD_NOT_SUPPORTED},
|
|
|
|
{"Flash update disabled.", FLASH_UPDATE_DISABLED},
|
|
|
|
{"Flash in progress", FLASH_IN_PROGRESS},
|
|
|
|
{"Image file size Error", FAIL_FILE_SIZE},
|
|
|
|
{"Input parameter error", FAIL_PARAMETERS},
|
|
|
|
{"Out of memory", FAIL_OUT_MEMORY},
|
|
|
|
{"OK", 0} /* Last entry err_code = 0. */
|
|
|
|
};
|
|
|
|
|
|
|
|
static int pm8001_set_nvmd(struct pm8001_hba_info *pm8001_ha)
|
|
|
|
{
|
|
|
|
struct pm8001_ioctl_payload *payload;
|
|
|
|
DECLARE_COMPLETION_ONSTACK(completion);
|
2014-07-30 21:12:22 +08:00
|
|
|
u8 *ioctlbuffer;
|
|
|
|
u32 ret;
|
|
|
|
u32 length = 1024 * 5 + sizeof(*payload) - 1;
|
|
|
|
|
|
|
|
if (pm8001_ha->fw_image->size > 4096) {
|
|
|
|
pm8001_ha->fw_status = FAIL_FILE_SIZE;
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
|
|
|
|
ioctlbuffer = kzalloc(length, GFP_KERNEL);
|
2014-07-30 21:12:22 +08:00
|
|
|
if (!ioctlbuffer) {
|
|
|
|
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
|
2009-10-14 16:19:21 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
|
2013-03-19 20:36:40 +08:00
|
|
|
memcpy((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data,
|
2009-10-14 16:19:21 +08:00
|
|
|
pm8001_ha->fw_image->size);
|
2020-03-16 15:49:06 +08:00
|
|
|
payload->wr_length = pm8001_ha->fw_image->size;
|
2009-10-14 16:19:21 +08:00
|
|
|
payload->id = 0;
|
2013-03-19 20:36:40 +08:00
|
|
|
payload->minor_function = 0x1;
|
2009-10-14 16:19:21 +08:00
|
|
|
pm8001_ha->nvmd_completion = &completion;
|
|
|
|
ret = PM8001_CHIP_DISP->set_nvmd_req(pm8001_ha, payload);
|
2014-07-30 21:12:22 +08:00
|
|
|
if (ret) {
|
|
|
|
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
wait_for_completion(&completion);
|
|
|
|
out:
|
|
|
|
kfree(ioctlbuffer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha)
|
|
|
|
{
|
|
|
|
struct pm8001_ioctl_payload *payload;
|
|
|
|
DECLARE_COMPLETION_ONSTACK(completion);
|
2014-07-30 21:12:22 +08:00
|
|
|
u8 *ioctlbuffer;
|
2009-10-14 16:19:21 +08:00
|
|
|
struct fw_control_info *fwControl;
|
2022-02-20 11:17:42 +08:00
|
|
|
__be32 partitionSizeTmp;
|
|
|
|
u32 partitionSize;
|
2014-07-30 21:12:22 +08:00
|
|
|
u32 loopNumber, loopcount;
|
2009-10-14 16:19:21 +08:00
|
|
|
struct pm8001_fw_image_header *image_hdr;
|
2014-07-30 21:12:22 +08:00
|
|
|
u32 sizeRead = 0;
|
|
|
|
u32 ret = 0;
|
|
|
|
u32 length = 1024 * 16 + sizeof(*payload) - 1;
|
2022-02-08 10:55:00 +08:00
|
|
|
u32 fc_len;
|
|
|
|
u8 *read_buf;
|
2009-10-14 16:19:21 +08:00
|
|
|
|
2014-07-30 21:12:22 +08:00
|
|
|
if (pm8001_ha->fw_image->size < 28) {
|
|
|
|
pm8001_ha->fw_status = FAIL_FILE_SIZE;
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
ioctlbuffer = kzalloc(length, GFP_KERNEL);
|
2014-07-30 21:12:22 +08:00
|
|
|
if (!ioctlbuffer) {
|
|
|
|
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
|
2009-10-14 16:19:21 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2014-07-30 21:12:22 +08:00
|
|
|
image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data;
|
2009-10-14 16:19:21 +08:00
|
|
|
while (sizeRead < pm8001_ha->fw_image->size) {
|
|
|
|
partitionSizeTmp =
|
2022-02-20 11:17:42 +08:00
|
|
|
*(__be32 *)((u8 *)&image_hdr->image_length + sizeRead);
|
2009-10-14 16:19:21 +08:00
|
|
|
partitionSize = be32_to_cpu(partitionSizeTmp);
|
2014-07-30 22:40:51 +08:00
|
|
|
loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN,
|
|
|
|
IOCTL_BUF_SIZE);
|
2009-10-14 16:19:21 +08:00
|
|
|
for (loopNumber = 0; loopNumber < loopcount; loopNumber++) {
|
|
|
|
payload = (struct pm8001_ioctl_payload *)ioctlbuffer;
|
2020-03-16 15:49:06 +08:00
|
|
|
payload->wr_length = 1024*16;
|
2009-10-14 16:19:21 +08:00
|
|
|
payload->id = 0;
|
|
|
|
fwControl =
|
2013-03-19 20:36:40 +08:00
|
|
|
(struct fw_control_info *)&payload->func_specific;
|
2009-10-14 16:19:21 +08:00
|
|
|
fwControl->len = IOCTL_BUF_SIZE; /* IN */
|
|
|
|
fwControl->size = partitionSize + HEADER_LEN;/* IN */
|
|
|
|
fwControl->retcode = 0;/* OUT */
|
|
|
|
fwControl->offset = loopNumber * IOCTL_BUF_SIZE;/*OUT */
|
|
|
|
|
2022-02-08 10:55:00 +08:00
|
|
|
/*
|
|
|
|
* for the last chunk of data in case file size is
|
|
|
|
* not even with 4k, load only the rest
|
|
|
|
*/
|
|
|
|
|
|
|
|
read_buf = (u8 *)pm8001_ha->fw_image->data + sizeRead;
|
|
|
|
fc_len = (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE;
|
|
|
|
|
|
|
|
if (loopcount - loopNumber == 1 && fc_len) {
|
|
|
|
fwControl->len = fc_len;
|
|
|
|
memcpy((u8 *)fwControl->buffer, read_buf, fc_len);
|
|
|
|
sizeRead += fc_len;
|
|
|
|
} else {
|
|
|
|
memcpy((u8 *)fwControl->buffer, read_buf, IOCTL_BUF_SIZE);
|
|
|
|
sizeRead += IOCTL_BUF_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pm8001_ha->nvmd_completion = &completion;
|
|
|
|
ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha, payload);
|
|
|
|
if (ret) {
|
|
|
|
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
wait_for_completion(&completion);
|
|
|
|
if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) {
|
|
|
|
pm8001_ha->fw_status = fwControl->retcode;
|
|
|
|
ret = -EFAULT;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
kfree(ioctlbuffer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
static ssize_t pm8001_store_update_fw(struct device *cdev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
char *cmd_ptr, *filename_ptr;
|
|
|
|
int res, i;
|
|
|
|
int flash_command = FLASH_CMD_NONE;
|
2014-07-30 21:12:22 +08:00
|
|
|
int ret;
|
|
|
|
|
2009-10-14 16:19:21 +08:00
|
|
|
if (!capable(CAP_SYS_ADMIN))
|
|
|
|
return -EACCES;
|
|
|
|
|
2014-07-30 21:12:22 +08:00
|
|
|
/* this test protects us from running two flash processes at once,
|
|
|
|
* so we should start with this test */
|
|
|
|
if (pm8001_ha->fw_status == FLASH_IN_PROGRESS)
|
|
|
|
return -EINPROGRESS;
|
|
|
|
pm8001_ha->fw_status = FLASH_IN_PROGRESS;
|
2009-10-14 16:19:21 +08:00
|
|
|
|
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 05:03:40 +08:00
|
|
|
cmd_ptr = kcalloc(count, 2, GFP_KERNEL);
|
2009-10-14 16:19:21 +08:00
|
|
|
if (!cmd_ptr) {
|
2014-07-30 21:12:22 +08:00
|
|
|
pm8001_ha->fw_status = FAIL_OUT_MEMORY;
|
|
|
|
return -ENOMEM;
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
filename_ptr = cmd_ptr + count;
|
|
|
|
res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr);
|
|
|
|
if (res != 2) {
|
2014-07-30 21:12:22 +08:00
|
|
|
pm8001_ha->fw_status = FAIL_PARAMETERS;
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; flash_command_table[i].code != FLASH_CMD_NONE; i++) {
|
|
|
|
if (!memcmp(flash_command_table[i].command,
|
|
|
|
cmd_ptr, strlen(cmd_ptr))) {
|
|
|
|
flash_command = flash_command_table[i].code;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flash_command == FLASH_CMD_NONE) {
|
2014-07-30 21:12:22 +08:00
|
|
|
pm8001_ha->fw_status = FAIL_PARAMETERS;
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
2014-07-30 21:12:22 +08:00
|
|
|
ret = request_firmware(&pm8001_ha->fw_image,
|
2009-10-14 16:19:21 +08:00
|
|
|
filename_ptr,
|
|
|
|
pm8001_ha->dev);
|
|
|
|
|
2014-07-30 21:12:22 +08:00
|
|
|
if (ret) {
|
2020-11-21 07:16:09 +08:00
|
|
|
pm8001_dbg(pm8001_ha, FAIL,
|
|
|
|
"Failed to load firmware image file %s, error %d\n",
|
|
|
|
filename_ptr, ret);
|
2014-07-30 21:12:22 +08:00
|
|
|
pm8001_ha->fw_status = FAIL_OPEN_BIOS_FILE;
|
|
|
|
goto out;
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
2014-07-30 21:12:22 +08:00
|
|
|
if (FLASH_CMD_UPDATE == flash_command)
|
|
|
|
ret = pm8001_update_flash(pm8001_ha);
|
|
|
|
else
|
|
|
|
ret = pm8001_set_nvmd(pm8001_ha);
|
|
|
|
|
2009-10-14 16:19:21 +08:00
|
|
|
release_firmware(pm8001_ha->fw_image);
|
|
|
|
out:
|
2014-07-30 21:12:22 +08:00
|
|
|
kfree(cmd_ptr);
|
2009-10-14 16:19:21 +08:00
|
|
|
|
2014-07-30 21:12:22 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
pm8001_ha->fw_status = FLASH_OK;
|
|
|
|
return count;
|
2009-10-14 16:19:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t pm8001_show_update_fw(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
|
|
|
|
for (i = 0; flash_error_table[i].err_code != 0; i++) {
|
|
|
|
if (flash_error_table[i].err_code == pm8001_ha->fw_status)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pm8001_ha->fw_status != FLASH_IN_PROGRESS)
|
|
|
|
pm8001_ha->fw_status = FLASH_OK;
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "status=%x %s\n",
|
|
|
|
flash_error_table[i].err_code,
|
|
|
|
flash_error_table[i].reason);
|
|
|
|
}
|
2014-05-14 09:03:48 +08:00
|
|
|
static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
|
2009-10-14 16:19:21 +08:00
|
|
|
pm8001_show_update_fw, pm8001_store_update_fw);
|
2021-04-15 18:33:45 +08:00
|
|
|
|
|
|
|
static const char *const mpiStateText[] = {
|
|
|
|
"MPI is not initialized",
|
|
|
|
"MPI is successfully initialized",
|
|
|
|
"MPI termination is in progress",
|
|
|
|
"MPI initialization failed with error in [31:16]"
|
|
|
|
};
|
|
|
|
|
2021-11-30 03:46:07 +08:00
|
|
|
/**
|
|
|
|
* ctl_mpi_state_show - controller MPI state check
|
|
|
|
* @cdev: pointer to embedded class device
|
|
|
|
* @attr: device attribute (unused)
|
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
2021-04-15 18:33:45 +08:00
|
|
|
static ssize_t ctl_mpi_state_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
unsigned int mpidw0;
|
|
|
|
|
|
|
|
mpidw0 = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 0);
|
|
|
|
return sysfs_emit(buf, "%s\n", mpiStateText[mpidw0 & 0x0003]);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(ctl_mpi_state);
|
|
|
|
|
2021-04-15 18:33:46 +08:00
|
|
|
/**
|
|
|
|
* ctl_hmi_error_show - controller MPI initialization fails
|
|
|
|
* @cdev: pointer to embedded class device
|
2021-11-30 03:46:07 +08:00
|
|
|
* @attr: device attribute (unused)
|
2021-04-15 18:33:46 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t ctl_hmi_error_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
unsigned int mpidw0;
|
|
|
|
|
|
|
|
mpidw0 = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 0);
|
|
|
|
return sysfs_emit(buf, "0x%08x\n", (mpidw0 >> 16));
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(ctl_hmi_error);
|
|
|
|
|
2021-04-15 18:33:47 +08:00
|
|
|
/**
|
|
|
|
* ctl_raae_count_show - controller raae count check
|
|
|
|
* @cdev: pointer to embedded class device
|
2021-11-30 03:46:07 +08:00
|
|
|
* @attr: device attribute (unused)
|
2021-04-15 18:33:47 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t ctl_raae_count_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
unsigned int raaecnt;
|
|
|
|
|
|
|
|
raaecnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 12);
|
|
|
|
return sysfs_emit(buf, "0x%08x\n", raaecnt);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(ctl_raae_count);
|
|
|
|
|
2021-04-15 18:33:48 +08:00
|
|
|
/**
|
|
|
|
* ctl_iop0_count_show - controller iop0 count check
|
|
|
|
* @cdev: pointer to embedded class device
|
2021-11-30 03:46:07 +08:00
|
|
|
* @attr: device attribute (unused)
|
2021-04-15 18:33:48 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t ctl_iop0_count_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
unsigned int iop0cnt;
|
|
|
|
|
|
|
|
iop0cnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 16);
|
|
|
|
return sysfs_emit(buf, "0x%08x\n", iop0cnt);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(ctl_iop0_count);
|
|
|
|
|
2021-04-15 18:33:49 +08:00
|
|
|
/**
|
|
|
|
* ctl_iop1_count_show - controller iop1 count check
|
|
|
|
* @cdev: pointer to embedded class device
|
2021-11-30 03:46:07 +08:00
|
|
|
* @attr: device attribute (unused)
|
2021-04-15 18:33:49 +08:00
|
|
|
* @buf: the buffer returned
|
|
|
|
*
|
|
|
|
* A sysfs 'read-only' shost attribute.
|
|
|
|
*/
|
|
|
|
static ssize_t ctl_iop1_count_show(struct device *cdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = class_to_shost(cdev);
|
|
|
|
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
|
|
|
|
unsigned int iop1cnt;
|
|
|
|
|
|
|
|
iop1cnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 20);
|
|
|
|
return sysfs_emit(buf, "0x%08x\n", iop1cnt);
|
|
|
|
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(ctl_iop1_count);
|
|
|
|
|
2021-10-13 07:35:47 +08:00
|
|
|
static struct attribute *pm8001_host_attrs[] = {
|
|
|
|
&dev_attr_interface_rev.attr,
|
|
|
|
&dev_attr_controller_fatal_error.attr,
|
|
|
|
&dev_attr_fw_version.attr,
|
|
|
|
&dev_attr_update_fw.attr,
|
|
|
|
&dev_attr_aap_log.attr,
|
|
|
|
&dev_attr_iop_log.attr,
|
|
|
|
&dev_attr_fatal_log.attr,
|
|
|
|
&dev_attr_non_fatal_log.attr,
|
|
|
|
&dev_attr_non_fatal_count.attr,
|
|
|
|
&dev_attr_gsm_log.attr,
|
|
|
|
&dev_attr_max_out_io.attr,
|
|
|
|
&dev_attr_max_devices.attr,
|
|
|
|
&dev_attr_max_sg_list.attr,
|
|
|
|
&dev_attr_sas_spec_support.attr,
|
|
|
|
&dev_attr_logging_level.attr,
|
|
|
|
&dev_attr_event_log_size.attr,
|
|
|
|
&dev_attr_host_sas_address.attr,
|
|
|
|
&dev_attr_bios_version.attr,
|
|
|
|
&dev_attr_ib_log.attr,
|
|
|
|
&dev_attr_ob_log.attr,
|
|
|
|
&dev_attr_ila_version.attr,
|
|
|
|
&dev_attr_inc_fw_ver.attr,
|
|
|
|
&dev_attr_ctl_mpi_state.attr,
|
|
|
|
&dev_attr_ctl_hmi_error.attr,
|
|
|
|
&dev_attr_ctl_raae_count.attr,
|
|
|
|
&dev_attr_ctl_iop0_count.attr,
|
|
|
|
&dev_attr_ctl_iop1_count.attr,
|
2009-10-14 16:19:21 +08:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2021-10-13 07:35:47 +08:00
|
|
|
static const struct attribute_group pm8001_host_attr_group = {
|
|
|
|
.attrs = pm8001_host_attrs
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct attribute_group *pm8001_host_groups[] = {
|
|
|
|
&pm8001_host_attr_group,
|
|
|
|
NULL
|
|
|
|
};
|