]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: bfa: use proper time accessor for stats_reset_time
authorArnd Bergmann <arnd@arndb.de>
Fri, 10 Nov 2017 15:37:10 +0000 (16:37 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:57 +0000 (13:16 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853915
We use the deprecated do_gettimeofday() function to read the current
time when resetting the statistics in both bfa_port and bfa_svc. This
works fine because overflow is handled correctly, but we want to get rid
of do_gettimeofday() and using a non-monotonic time suffers from
concurrent settimeofday calls and other problems.

This uses the ktime_get_seconds() function instead, which does what we
need here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Anil Gurumurthy <Anil.Gurumurthy@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 8f604a036bce849a3410f4940fa09e8eb2760bbf)
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/scsi/bfa/bfa_port.c
drivers/scsi/bfa/bfa_port.h
drivers/scsi/bfa/bfa_svc.c
drivers/scsi/bfa/bfa_svc.h

index da1721e0d1673cef13d95b5675789a1fec02f21a..079bc77f4102665beddb004323ce16a99f2053c0 100644 (file)
@@ -96,14 +96,11 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
        port->stats_busy = BFA_FALSE;
 
        if (status == BFA_STATUS_OK) {
-               struct timeval tv;
-
                memcpy(port->stats, port->stats_dma.kva,
                       sizeof(union bfa_port_stats_u));
                bfa_port_stats_swap(port, port->stats);
 
-               do_gettimeofday(&tv);
-               port->stats->fc.secs_reset = tv.tv_sec - port->stats_reset_time;
+               port->stats->fc.secs_reset = ktime_get_seconds() - port->stats_reset_time;
        }
 
        if (port->stats_cbfn) {
@@ -124,16 +121,13 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
 static void
 bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
 {
-       struct timeval tv;
-
        port->stats_status = status;
        port->stats_busy   = BFA_FALSE;
 
        /*
        * re-initialize time stamp for stats reset
        */
-       do_gettimeofday(&tv);
-       port->stats_reset_time = tv.tv_sec;
+       port->stats_reset_time = ktime_get_seconds();
 
        if (port->stats_cbfn) {
                port->stats_cbfn(port->stats_cbarg, status);
@@ -471,8 +465,6 @@ void
 bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
                 void *dev, struct bfa_trc_mod_s *trcmod)
 {
-       struct timeval tv;
-
        WARN_ON(!port);
 
        port->dev    = dev;
@@ -494,8 +486,7 @@ bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
        /*
         * initialize time stamp for stats reset
         */
-       do_gettimeofday(&tv);
-       port->stats_reset_time = tv.tv_sec;
+       port->stats_reset_time = ktime_get_seconds();
 
        bfa_trc(port, 0);
 }
index 26dc1bf14c85e14a8ffc69fc8d823f8b2d3449f4..0c3b200243caee4cb18e8ee944820ec304da01c1 100644 (file)
@@ -36,7 +36,7 @@ struct bfa_port_s {
        bfa_port_stats_cbfn_t           stats_cbfn;
        void                            *stats_cbarg;
        bfa_status_t                    stats_status;
-       u32                     stats_reset_time;
+       time64_t                        stats_reset_time;
        union bfa_port_stats_u          *stats;
        struct bfa_dma_s                stats_dma;
        bfa_boolean_t                   endis_pending;
index 7356fdec79f560b54dc9b0ff90a920c2b6f8541f..a25216397787016a4c44aecbcabdba934f644455 100644 (file)
@@ -3047,7 +3047,6 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
        struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
        struct bfa_port_cfg_s *port_cfg = &fcport->cfg;
        struct bfa_fcport_ln_s *ln = &fcport->ln;
-       struct timeval tv;
 
        fcport->bfa = bfa;
        ln->fcport = fcport;
@@ -3060,8 +3059,7 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
        /*
         * initialize time stamp for stats reset
         */
-       do_gettimeofday(&tv);
-       fcport->stats_reset_time = tv.tv_sec;
+       fcport->stats_reset_time = ktime_get_seconds();
        fcport->stats_dma_ready = BFA_FALSE;
 
        /*
@@ -3295,9 +3293,7 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
        union bfa_fcport_stats_u *ret;
 
        if (complete) {
-               struct timeval tv;
-               if (fcport->stats_status == BFA_STATUS_OK)
-                       do_gettimeofday(&tv);
+               time64_t time = ktime_get_seconds();
 
                list_for_each_safe(qe, qen, &fcport->stats_pending_q) {
                        bfa_q_deq(&fcport->stats_pending_q, &qe);
@@ -3312,7 +3308,7 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
                                        bfa_fcport_fcoe_stats_swap(&ret->fcoe,
                                                        &fcport->stats->fcoe);
                                        ret->fcoe.secs_reset =
-                                       tv.tv_sec - fcport->stats_reset_time;
+                                               time - fcport->stats_reset_time;
                                }
                        }
                        bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
@@ -3373,13 +3369,10 @@ __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
        struct list_head *qe, *qen;
 
        if (complete) {
-               struct timeval tv;
-
                /*
                 * re-initialize time stamp for stats reset
                 */
-               do_gettimeofday(&tv);
-               fcport->stats_reset_time = tv.tv_sec;
+               fcport->stats_reset_time = ktime_get_seconds();
                list_for_each_safe(qe, qen, &fcport->statsclr_pending_q) {
                        bfa_q_deq(&fcport->statsclr_pending_q, &qe);
                        cb = (struct bfa_cb_pending_q_s *)qe;
index ea2278bc78a8d44f497a5985357dcd9ce28c9625..7e8fb6231d491b507aadbcb0fb45aef2f126fef8 100644 (file)
@@ -505,7 +505,7 @@ struct bfa_fcport_s {
        struct list_head        stats_pending_q;
        struct list_head        statsclr_pending_q;
        bfa_boolean_t           stats_qfull;
-       u32             stats_reset_time; /*  stats reset time stamp */
+       time64_t                stats_reset_time; /*  stats reset time stamp */
        bfa_boolean_t           diag_busy; /*  diag busy status */
        bfa_boolean_t           beacon; /*  port beacon status */
        bfa_boolean_t           link_e2e_beacon; /*  link beacon status */