Skip to content

Commit e403fa3

Browse files
Stanislaw GruszkaKalle Valo
authored andcommitted
rt2x00: add restart hw
Add ieee80211_restart_hw() to watchdog and debugfs file for testing if restart works as expected. Signed-off-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 710e6cc commit e403fa3

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

drivers/net/wireless/ralink/rt2x00/rt2800lib.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,9 @@ void rt2800_watchdog(struct rt2x00_dev *rt2x00dev)
12631263

12641264
if (hung_rx)
12651265
rt2x00_warn(rt2x00dev, "Watchdog RX hung detected\n");
1266+
1267+
if (hung_tx || hung_rx)
1268+
ieee80211_restart_hw(rt2x00dev->hw);
12661269
}
12671270
EXPORT_SYMBOL_GPL(rt2800_watchdog);
12681271

@@ -10283,6 +10286,7 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
1028310286
__set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags);
1028410287
}
1028510288

10289+
__set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags);
1028610290
rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100);
1028710291

1028810292
/*

drivers/net/wireless/ralink/rt2x00/rt2x00.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ enum rt2x00_capability_flags {
712712
CAPABILITY_VCO_RECALIBRATION,
713713
CAPABILITY_EXTERNAL_PA_TX0,
714714
CAPABILITY_EXTERNAL_PA_TX1,
715+
CAPABILITY_RESTART_HW,
715716
};
716717

717718
/*
@@ -1268,6 +1269,12 @@ rt2x00_has_cap_vco_recalibration(struct rt2x00_dev *rt2x00dev)
12681269
return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_VCO_RECALIBRATION);
12691270
}
12701271

1272+
static inline bool
1273+
rt2x00_has_cap_restart_hw(struct rt2x00_dev *rt2x00dev)
1274+
{
1275+
return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_RESTART_HW);
1276+
}
1277+
12711278
/**
12721279
* rt2x00queue_map_txskb - Map a skb into DMA for TX purposes.
12731280
* @entry: Pointer to &struct queue_entry

drivers/net/wireless/ralink/rt2x00/rt2x00debug.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct rt2x00debug_intf {
5252
* - chipset file
5353
* - device state flags file
5454
* - device capability flags file
55+
* - hardware restart file
5556
* - register folder
5657
* - csr offset/value files
5758
* - eeprom offset/value files
@@ -68,6 +69,7 @@ struct rt2x00debug_intf {
6869
struct dentry *chipset_entry;
6970
struct dentry *dev_flags;
7071
struct dentry *cap_flags;
72+
struct dentry *restart_hw;
7173
struct dentry *register_folder;
7274
struct dentry *csr_off_entry;
7375
struct dentry *csr_val_entry;
@@ -566,6 +568,34 @@ static const struct file_operations rt2x00debug_fop_cap_flags = {
566568
.llseek = default_llseek,
567569
};
568570

571+
static ssize_t rt2x00debug_write_restart_hw(struct file *file,
572+
const char __user *buf,
573+
size_t length,
574+
loff_t *offset)
575+
{
576+
struct rt2x00debug_intf *intf = file->private_data;
577+
struct rt2x00_dev *rt2x00dev = intf->rt2x00dev;
578+
static unsigned long last_reset;
579+
580+
if (!rt2x00_has_cap_restart_hw(rt2x00dev))
581+
return -EOPNOTSUPP;
582+
583+
if (time_before(jiffies, last_reset + msecs_to_jiffies(2000)))
584+
return -EBUSY;
585+
586+
last_reset = jiffies;
587+
588+
ieee80211_restart_hw(rt2x00dev->hw);
589+
return length;
590+
}
591+
592+
static const struct file_operations rt2x00debug_restart_hw = {
593+
.owner = THIS_MODULE,
594+
.write = rt2x00debug_write_restart_hw,
595+
.open = simple_open,
596+
.llseek = generic_file_llseek,
597+
};
598+
569599
static struct dentry *rt2x00debug_create_file_driver(const char *name,
570600
struct rt2x00debug_intf
571601
*intf,
@@ -661,6 +691,10 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
661691
intf->driver_folder, intf,
662692
&rt2x00debug_fop_cap_flags);
663693

694+
intf->restart_hw = debugfs_create_file("restart_hw", 0200,
695+
intf->driver_folder, intf,
696+
&rt2x00debug_restart_hw);
697+
664698
intf->register_folder =
665699
debugfs_create_dir("register", intf->driver_folder);
666700

@@ -742,6 +776,7 @@ void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev)
742776
debugfs_remove(intf->csr_off_entry);
743777
debugfs_remove(intf->register_folder);
744778
debugfs_remove(intf->dev_flags);
779+
debugfs_remove(intf->restart_hw);
745780
debugfs_remove(intf->cap_flags);
746781
debugfs_remove(intf->chipset_entry);
747782
debugfs_remove(intf->driver_entry);

drivers/net/wireless/ralink/rt2x00/rt2x00dev.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,14 @@ int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
12581258
{
12591259
int retval;
12601260

1261-
if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
1262-
return 0;
1261+
if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) {
1262+
/*
1263+
* This is special case for ieee80211_restart_hw(), otherwise
1264+
* mac80211 never call start() two times in row without stop();
1265+
*/
1266+
rt2x00dev->ops->lib->pre_reset_hw(rt2x00dev);
1267+
rt2x00lib_stop(rt2x00dev);
1268+
}
12631269

12641270
/*
12651271
* If this is the first interface which is added,

0 commit comments

Comments
 (0)