Skip to content

Commit

Permalink
[SCSI] qla2xxx: Integrate generic card temperature with mezz card tem…
Browse files Browse the repository at this point in the history
…perature.

Give priority to I2C thermal.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Joe Carnuccio authored and James Bottomley committed Feb 22, 2013
1 parent 6c3943c commit fe52f6e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 40 deletions.
33 changes: 20 additions & 13 deletions drivers/scsi/qla2xxx/qla_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,22 +1272,29 @@ qla2x00_thermal_temp_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
int rval = QLA_FUNCTION_FAILED;
uint16_t temp, frac;
uint16_t temp = 0;

if (!vha->hw->flags.thermal_supported)
return snprintf(buf, PAGE_SIZE, "\n");
if (!vha->hw->thermal_support) {
ql_log(ql_log_warn, vha, 0x70db,
"Thermal not supported by this card.\n");
goto done;
}

temp = frac = 0;
if (qla2x00_reset_active(vha))
ql_log(ql_log_warn, vha, 0x707b,
"ISP reset active.\n");
else if (!vha->hw->flags.eeh_busy)
rval = qla2x00_get_thermal_temp(vha, &temp, &frac);
if (rval != QLA_SUCCESS)
return snprintf(buf, PAGE_SIZE, "\n");
if (qla2x00_reset_active(vha)) {
ql_log(ql_log_warn, vha, 0x70dc, "ISP reset active.\n");
goto done;
}

if (vha->hw->flags.eeh_busy) {
ql_log(ql_log_warn, vha, 0x70dd, "PCI EEH busy.\n");
goto done;
}

if (qla2x00_get_thermal_temp(vha, &temp) == QLA_SUCCESS)
return snprintf(buf, PAGE_SIZE, "%d\n", temp);

return snprintf(buf, PAGE_SIZE, "%d.%02d\n", temp, frac);
done:
return snprintf(buf, PAGE_SIZE, "\n");
}

static ssize_t
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/qla2xxx/qla_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* | Level | Last Value Used | Holes |
* ----------------------------------------------------------------------
* | Module Init and Probe | 0x0126 | 0x4b,0xba,0xfa |
* | Mailbox commands | 0x1158 | 0x111a-0x111b |
* | Mailbox commands | 0x115b | 0x111a-0x111b |
* | | | 0x112c-0x112e |
* | | | 0x113a |
* | Device Discovery | 0x2087 | 0x2020-0x2022, |
Expand Down
5 changes: 4 additions & 1 deletion drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ typedef struct {
#define MBX_0 BIT_0

#define RNID_TYPE_SET_VERSION 0x9
#define RNID_TYPE_ASIC_TEMP 0xC

/*
* Firmware state codes from get firmware state mailbox command
Expand Down Expand Up @@ -2628,7 +2629,6 @@ struct qla_hw_data {
uint32_t nic_core_hung:1;

uint32_t quiesce_owner:1;
uint32_t thermal_supported:1;
uint32_t nic_core_reset_hdlr_active:1;
uint32_t nic_core_reset_owner:1;
uint32_t isp82xx_no_md_cap:1;
Expand Down Expand Up @@ -3076,6 +3076,9 @@ struct qla_hw_data {
int cfg_lun_q_depth;

struct qlt_hw_data tgt;
uint16_t thermal_support;
#define THERMAL_SUPPORT_I2C BIT_0
#define THERMAL_SUPPORT_ISP BIT_1
};

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/qla2xxx/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *);
extern void qla2x00_try_to_stop_firmware(scsi_qla_host_t *);

extern int qla2x00_get_thermal_temp(scsi_qla_host_t *, uint16_t *, uint16_t *);
extern int qla2x00_get_thermal_temp(scsi_qla_host_t *, uint16_t *);

extern void qla84xx_put_chip(struct scsi_qla_host *);

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/qla2xxx/qla_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
vha->flags.reset_active = 0;
ha->flags.pci_channel_io_perm_failure = 0;
ha->flags.eeh_busy = 0;
ha->flags.thermal_supported = 1;
ha->thermal_support = THERMAL_SUPPORT_I2C|THERMAL_SUPPORT_ISP;
atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
atomic_set(&vha->loop_state, LOOP_DOWN);
vha->device_flags = DFLG_NO_CABLE;
Expand Down
82 changes: 59 additions & 23 deletions drivers/scsi/qla2xxx/qla_mbx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3924,6 +3924,39 @@ qla2x00_set_driver_version(scsi_qla_host_t *vha, char *version)
return rval;
}

static int
qla2x00_read_asic_temperature(scsi_qla_host_t *vha, uint16_t *temp)
{
int rval;
mbx_cmd_t mc;
mbx_cmd_t *mcp = &mc;

if (!IS_FWI2_CAPABLE(vha->hw))
return QLA_FUNCTION_FAILED;

ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1159,
"Entered %s.\n", __func__);

mcp->mb[0] = MBC_GET_RNID_PARAMS;
mcp->mb[1] = RNID_TYPE_ASIC_TEMP << 8;
mcp->out_mb = MBX_1|MBX_0;
mcp->in_mb = MBX_1|MBX_0;
mcp->tov = MBX_TOV_SECONDS;
mcp->flags = 0;
rval = qla2x00_mailbox_command(vha, mcp);
*temp = mcp->mb[1];

if (rval != QLA_SUCCESS) {
ql_dbg(ql_dbg_mbx, vha, 0x115a,
"Failed=%x mb[0]=%x,%x.\n", rval, mcp->mb[0], mcp->mb[1]);
} else {
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x115b,
"Done %s.\n", __func__);
}

return rval;
}

int
qla2x00_read_sfp(scsi_qla_host_t *vha, dma_addr_t sfp_dma, uint8_t *sfp,
uint16_t dev, uint16_t off, uint16_t len, uint16_t opt)
Expand Down Expand Up @@ -4526,42 +4559,45 @@ qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority,
}

int
qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp, uint16_t *frac)
qla2x00_get_thermal_temp(scsi_qla_host_t *vha, uint16_t *temp)
{
int rval;
uint8_t byte;
int rval = QLA_FUNCTION_FAILED;
struct qla_hw_data *ha = vha->hw;
uint8_t byte;

ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10ca,
"Entered %s.\n", __func__);

/* Integer part */
rval = qla2x00_read_sfp(vha, 0, &byte, 0x98, 0x01, 1,
BIT_13|BIT_12|BIT_0);
if (rval != QLA_SUCCESS) {
ql_dbg(ql_dbg_mbx, vha, 0x10c9, "Failed=%x.\n", rval);
ha->flags.thermal_supported = 0;
goto fail;
if (ha->thermal_support & THERMAL_SUPPORT_I2C) {
rval = qla2x00_read_sfp(vha, 0, &byte,
0x98, 0x1, 1, BIT_13|BIT_12|BIT_0);
*temp = byte;
if (rval == QLA_SUCCESS)
goto done;

ql_log(ql_log_warn, vha, 0x10c9,
"Thermal not supported by I2C.\n");
ha->thermal_support &= ~THERMAL_SUPPORT_I2C;
}
*temp = byte;

/* Fraction part */
rval = qla2x00_read_sfp(vha, 0, &byte, 0x98, 0x10, 1,
BIT_13|BIT_12|BIT_0);
if (rval != QLA_SUCCESS) {
ql_dbg(ql_dbg_mbx, vha, 0x1019, "Failed=%x.\n", rval);
ha->flags.thermal_supported = 0;
goto fail;
if (ha->thermal_support & THERMAL_SUPPORT_ISP) {
rval = qla2x00_read_asic_temperature(vha, temp);
if (rval == QLA_SUCCESS)
goto done;

ql_log(ql_log_warn, vha, 0x1019,
"Thermal not supported by ISP.\n");
ha->thermal_support &= ~THERMAL_SUPPORT_ISP;
}
*frac = (byte >> 6) * 25;

ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1018,
"Done %s.\n", __func__);
return rval;
fail:
ql_log(ql_log_warn, vha, 0x1150,
"Thermal not supported by this card "
"(ignoring further requests).\n");
return rval;

done:
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1018,
"Done %s.\n", __func__);
return rval;
}

Expand Down

0 comments on commit fe52f6e

Please sign in to comment.