Changeset 47991


Ignore:
Timestamp:
2015-12-23T18:12:56+01:00 (2 years ago)
Author:
rmilecki
Message:

ledtrig-netdev: drop locking from timer callback function

We may just delete timer on every trigger update and then start it again
if needed. This will let us avoid both: races and locking in frequently
called timer callback.

Signed-off-by: Rafał Miłecki <zajec5@…>

Backport of r47987

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/chaos_calmer/target/linux/generic/files/drivers/leds/ledtrig-netdev.c

    r47989 r47991  
    9393        if ((trigger_data->mode & (MODE_TX | MODE_RX)) != 0 && trigger_data->link_up) 
    9494                mod_timer(&trigger_data->timer, jiffies + trigger_data->interval); 
    95         else 
    96                 del_timer(&trigger_data->timer); 
    9795} 
    9896 
     
    120118 
    121119        spin_lock_bh(&trigger_data->lock); 
     120        del_timer_sync(&trigger_data->timer); 
    122121 
    123122        strcpy(trigger_data->device_name, buf); 
     
    130129                if (trigger_data->net_dev != NULL) 
    131130                        trigger_data->link_up = (dev_get_flags(trigger_data->net_dev) & IFF_LOWER_UP) != 0; 
    132                 set_baseline_state(trigger_data); /* updates LEDs, may start timers */ 
    133         } 
    134  
    135         spin_unlock_bh(&trigger_data->lock); 
     131        } 
     132 
     133        set_baseline_state(trigger_data); 
     134        spin_unlock_bh(&trigger_data->lock); 
     135 
    136136        return size; 
    137137} 
     
    201201 
    202202        spin_lock_bh(&trigger_data->lock); 
     203        del_timer_sync(&trigger_data->timer); 
     204 
    203205        trigger_data->mode = new_mode; 
     206 
    204207        set_baseline_state(trigger_data); 
    205208        spin_unlock_bh(&trigger_data->lock); 
     
    239242        if (count == size && value >= 5 && value <= 10000) { 
    240243                spin_lock_bh(&trigger_data->lock); 
     244                del_timer_sync(&trigger_data->timer); 
     245 
    241246                trigger_data->interval = msecs_to_jiffies(value); 
     247 
    242248                set_baseline_state(trigger_data); /* resets timer */ 
    243249                spin_unlock_bh(&trigger_data->lock); 
     250 
    244251                ret = count; 
    245252        } 
     
    261268 
    262269        spin_lock_bh(&trigger_data->lock); 
     270        del_timer_sync(&trigger_data->timer); 
    263271 
    264272        if (strcmp(dev->name, trigger_data->device_name)) 
     
    298306        struct rtnl_link_stats64 temp; 
    299307 
    300         spin_lock(&trigger_data->lock); 
    301  
    302308        if (!trigger_data->link_up || !trigger_data->net_dev || (trigger_data->mode & (MODE_TX | MODE_RX)) == 0) { 
    303309                /* we don't need to do timer work, just reflect link state. */ 
    304310                led_set_brightness(trigger_data->led_cdev, ((trigger_data->mode & MODE_LINK) != 0 && trigger_data->link_up) ? LED_FULL : LED_OFF); 
    305                 goto no_restart; 
     311                return; 
    306312        } 
    307313 
     
    335341        trigger_data->last_activity = new_activity; 
    336342        mod_timer(&trigger_data->timer, jiffies + trigger_data->interval); 
    337  
    338 no_restart: 
    339         spin_unlock(&trigger_data->lock); 
    340343} 
    341344 
     
    401404 
    402405                spin_lock_bh(&trigger_data->lock); 
     406                del_timer_sync(&trigger_data->timer); 
    403407 
    404408                if (trigger_data->net_dev) { 
     
    408412 
    409413                spin_unlock_bh(&trigger_data->lock); 
    410  
    411                 del_timer_sync(&trigger_data->timer); 
    412414 
    413415                kfree(trigger_data); 
Note: See TracChangeset for help on using the changeset viewer.