Merge tag 'drm-vc4-fixes-2016-09-14' of https://github.com/anholt/linux into drm...
[linux-2.6-block.git] / drivers / infiniband / hw / hfi1 / mad.c
index 962bb11074d919b7cacb5905382e929a18264db9..39e42c373a01c5e9afc276bb2073b214cde4515f 100644 (file)
@@ -1819,6 +1819,11 @@ static int __subn_get_opa_cable_info(struct opa_smp *smp, u32 am, u8 *data,
        u32 len = OPA_AM_CI_LEN(am) + 1;
        int ret;
 
+       if (dd->pport->port_type != PORT_TYPE_QSFP) {
+               smp->status |= IB_SMP_INVALID_FIELD;
+               return reply((struct ib_mad_hdr *)smp);
+       }
+
 #define __CI_PAGE_SIZE BIT(7) /* 128 bytes */
 #define __CI_PAGE_MASK ~(__CI_PAGE_SIZE - 1)
 #define __CI_PAGE_NUM(a) ((a) & __CI_PAGE_MASK)
@@ -2418,14 +2423,9 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
        rsp->port_rcv_remote_physical_errors =
                cpu_to_be64(read_dev_cntr(dd, C_DC_RMT_PHY_ERR,
                                          CNTR_INVALID_VL));
-       tmp = read_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL);
-       tmp2 = tmp + read_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL);
-       if (tmp2 < tmp) {
-               /* overflow/wrapped */
-               rsp->local_link_integrity_errors = cpu_to_be64(~0);
-       } else {
-               rsp->local_link_integrity_errors = cpu_to_be64(tmp2);
-       }
+       rsp->local_link_integrity_errors =
+               cpu_to_be64(read_dev_cntr(dd, C_DC_RX_REPLAY,
+                                         CNTR_INVALID_VL));
        tmp = read_dev_cntr(dd, C_DC_SEQ_CRC_CNT, CNTR_INVALID_VL);
        tmp2 = tmp + read_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT,
                                   CNTR_INVALID_VL);
@@ -2520,9 +2520,8 @@ static u64 get_error_counter_summary(struct ib_device *ibdev, u8 port,
        error_counter_summary += read_dev_cntr(dd, C_DC_RMT_PHY_ERR,
                                               CNTR_INVALID_VL);
        /* local link integrity must be right-shifted by the lli resolution */
-       tmp = read_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL);
-       tmp += read_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL);
-       error_counter_summary += (tmp >> res_lli);
+       error_counter_summary += (read_dev_cntr(dd, C_DC_RX_REPLAY,
+                                               CNTR_INVALID_VL) >> res_lli);
        /* link error recovery must b right-shifted by the ler resolution */
        tmp = read_dev_cntr(dd, C_DC_SEQ_CRC_CNT, CNTR_INVALID_VL);
        tmp += read_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT, CNTR_INVALID_VL);
@@ -2791,14 +2790,9 @@ static void pma_get_opa_port_ectrs(struct ib_device *ibdev,
        rsp->port_rcv_constraint_errors =
                cpu_to_be64(read_port_cntr(ppd, C_SW_RCV_CSTR_ERR,
                                           CNTR_INVALID_VL));
-       tmp = read_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL);
-       tmp2 = tmp + read_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL);
-       if (tmp2 < tmp) {
-               /* overflow/wrapped */
-               rsp->local_link_integrity_errors = cpu_to_be64(~0);
-       } else {
-               rsp->local_link_integrity_errors = cpu_to_be64(tmp2);
-       }
+       rsp->local_link_integrity_errors =
+               cpu_to_be64(read_dev_cntr(dd, C_DC_RX_REPLAY,
+                                         CNTR_INVALID_VL));
        rsp->excessive_buffer_overruns =
                cpu_to_be64(read_dev_cntr(dd, C_RCV_OVF, CNTR_INVALID_VL));
 }
@@ -3156,10 +3150,8 @@ static int pma_set_opa_portstatus(struct opa_pma_mad *pmp,
        if (counter_select & CS_PORT_RCV_REMOTE_PHYSICAL_ERRORS)
                write_dev_cntr(dd, C_DC_RMT_PHY_ERR, CNTR_INVALID_VL, 0);
 
-       if (counter_select & CS_LOCAL_LINK_INTEGRITY_ERRORS) {
-               write_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL, 0);
+       if (counter_select & CS_LOCAL_LINK_INTEGRITY_ERRORS)
                write_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL, 0);
-       }
 
        if (counter_select & CS_LINK_ERROR_RECOVERY) {
                write_dev_cntr(dd, C_DC_SEQ_CRC_CNT, CNTR_INVALID_VL, 0);
@@ -3388,7 +3380,7 @@ static void apply_cc_state(struct hfi1_pportdata *ppd)
         */
        spin_lock(&ppd->cc_state_lock);
 
-       old_cc_state = get_cc_state(ppd);
+       old_cc_state = get_cc_state_protected(ppd);
        if (!old_cc_state) {
                /* never active, or shutting down */
                spin_unlock(&ppd->cc_state_lock);
@@ -3411,7 +3403,7 @@ static void apply_cc_state(struct hfi1_pportdata *ppd)
 
        spin_unlock(&ppd->cc_state_lock);
 
-       call_rcu(&old_cc_state->rcu, cc_state_reclaim);
+       kfree_rcu(old_cc_state, rcu);
 }
 
 static int __subn_set_opa_cong_setting(struct opa_smp *smp, u32 am, u8 *data,
@@ -3566,13 +3558,6 @@ static int __subn_get_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data,
        return reply((struct ib_mad_hdr *)smp);
 }
 
-void cc_state_reclaim(struct rcu_head *rcu)
-{
-       struct cc_state *cc_state = container_of(rcu, struct cc_state, rcu);
-
-       kfree(cc_state);
-}
-
 static int __subn_set_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data,
                                   struct ib_device *ibdev, u8 port,
                                   u32 *resp_len)
@@ -3956,7 +3941,6 @@ void clear_linkup_counters(struct hfi1_devdata *dd)
        write_dev_cntr(dd, C_DC_SEQ_CRC_CNT, CNTR_INVALID_VL, 0);
        write_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT, CNTR_INVALID_VL, 0);
        /* LocalLinkIntegrityErrors */
-       write_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL, 0);
        write_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL, 0);
        /* ExcessiveBufferOverruns */
        write_dev_cntr(dd, C_RCV_OVF, CNTR_INVALID_VL, 0);