Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 144578
b: refs/heads/master
c: ddc9f82
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Apr 29, 2009
1 parent c2ddf62 commit ca2d224
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 335 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c428c89201a57a0ce24c37ed79e540d1f4101cf3
refs/heads/master: ddc9f824b09d790e93a800ba29ff3462f8fb5d0b
30 changes: 23 additions & 7 deletions trunk/drivers/net/e100.c
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
#define E100_82552_SMARTSPEED 0x14 /* SmartSpeed Ctrl register */
#define E100_82552_REV_ANEG 0x0200 /* Reverse auto-negotiation */
#define E100_82552_ANEG_NOW 0x0400 /* Auto-negotiate now */
static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
static void __e100_shutdown(struct pci_dev *pdev, bool *enable_wake)
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct nic *nic = netdev_priv(netdev);
Expand All @@ -2749,19 +2749,32 @@ static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
E100_82552_SMARTSPEED, smartspeed |
E100_82552_REV_ANEG | E100_82552_ANEG_NOW);
}
if (pci_enable_wake(pdev, PCI_D3cold, true))
pci_enable_wake(pdev, PCI_D3hot, true);
*enable_wake = true;
} else {
pci_enable_wake(pdev, PCI_D3hot, false);
*enable_wake = false;
}

pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);
}

return 0;
static int __e100_power_off(struct pci_dev *pdev, bool wake)
{
if (wake) {
return pci_prepare_to_sleep(pdev);
} else {
pci_wake_from_d3(pdev, false);
return pci_set_power_state(pdev, PCI_D3hot);
}
}

#ifdef CONFIG_PM
static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
{
bool wake;
__e100_shutdown(pdev, &wake);
return __e100_power_off(pdev, wake);
}

static int e100_resume(struct pci_dev *pdev)
{
struct net_device *netdev = pci_get_drvdata(pdev);
Expand Down Expand Up @@ -2792,7 +2805,10 @@ static int e100_resume(struct pci_dev *pdev)

static void e100_shutdown(struct pci_dev *pdev)
{
e100_suspend(pdev, PMSG_SUSPEND);
bool wake;
__e100_shutdown(pdev, &wake);
if (system_state == SYSTEM_POWER_OFF)
__e100_power_off(pdev, wake);
}

/* ------------------ PCI Error Recovery infrastructure -------------- */
Expand Down
73 changes: 68 additions & 5 deletions trunk/include/linux/netfilter/x_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,6 @@ struct xt_table
/* What hooks you will enter on */
unsigned int valid_hooks;

/* Lock for the curtain */
struct mutex lock;

/* Man behind the curtain... */
struct xt_table_info *private;

Expand Down Expand Up @@ -434,8 +431,74 @@ extern void xt_proto_fini(struct net *net, u_int8_t af);

extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
extern void xt_free_table_info(struct xt_table_info *info);
extern void xt_table_entry_swap_rcu(struct xt_table_info *old,
struct xt_table_info *new);

/*
* Per-CPU spinlock associated with per-cpu table entries, and
* with a counter for the "reading" side that allows a recursive
* reader to avoid taking the lock and deadlocking.
*
* "reading" is used by ip/arp/ip6 tables rule processing which runs per-cpu.
* It needs to ensure that the rules are not being changed while the packet
* is being processed. In some cases, the read lock will be acquired
* twice on the same CPU; this is okay because of the count.
*
* "writing" is used when reading counters.
* During replace any readers that are using the old tables have to complete
* before freeing the old table. This is handled by the write locking
* necessary for reading the counters.
*/
struct xt_info_lock {
spinlock_t lock;
unsigned char readers;
};
DECLARE_PER_CPU(struct xt_info_lock, xt_info_locks);

/*
* Note: we need to ensure that preemption is disabled before acquiring
* the per-cpu-variable, so we do it as a two step process rather than
* using "spin_lock_bh()".
*
* We _also_ need to disable bottom half processing before updating our
* nesting count, to make sure that the only kind of re-entrancy is this
* code being called by itself: since the count+lock is not an atomic
* operation, we can allow no races.
*
* _Only_ that special combination of being per-cpu and never getting
* re-entered asynchronously means that the count is safe.
*/
static inline void xt_info_rdlock_bh(void)
{
struct xt_info_lock *lock;

local_bh_disable();
lock = &__get_cpu_var(xt_info_locks);
if (!lock->readers++)
spin_lock(&lock->lock);
}

static inline void xt_info_rdunlock_bh(void)
{
struct xt_info_lock *lock = &__get_cpu_var(xt_info_locks);

if (!--lock->readers)
spin_unlock(&lock->lock);
local_bh_enable();
}

/*
* The "writer" side needs to get exclusive access to the lock,
* regardless of readers. This must be called with bottom half
* processing (and thus also preemption) disabled.
*/
static inline void xt_info_wrlock(unsigned int cpu)
{
spin_lock(&per_cpu(xt_info_locks, cpu).lock);
}

static inline void xt_info_wrunlock(unsigned int cpu)
{
spin_unlock(&per_cpu(xt_info_locks, cpu).lock);
}

/*
* This helper is performance critical and must be inlined
Expand Down
1 change: 1 addition & 0 deletions trunk/include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ enum {
/* HCI timeouts */
#define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
#define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */

Expand Down
8 changes: 5 additions & 3 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct hci_conn {
__u8 auth_type;
__u8 sec_level;
__u8 power_save;
__u16 disc_timeout;
unsigned long pend;

unsigned int sent;
Expand All @@ -180,7 +181,8 @@ struct hci_conn {
struct timer_list disc_timer;
struct timer_list idle_timer;

struct work_struct work;
struct work_struct work_add;
struct work_struct work_del;

struct device dev;

Expand Down Expand Up @@ -348,9 +350,9 @@ static inline void hci_conn_put(struct hci_conn *conn)
if (conn->type == ACL_LINK) {
del_timer(&conn->idle_timer);
if (conn->state == BT_CONNECTED) {
timeo = msecs_to_jiffies(HCI_DISCONN_TIMEOUT);
timeo = msecs_to_jiffies(conn->disc_timeout);
if (!conn->out)
timeo *= 5;
timeo *= 2;
} else
timeo = msecs_to_jiffies(10);
} else
Expand Down
10 changes: 4 additions & 6 deletions trunk/net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
conn->state = BT_OPEN;

conn->power_save = 1;
conn->disc_timeout = HCI_DISCONN_TIMEOUT;

switch (type) {
case ACL_LINK:
Expand Down Expand Up @@ -424,12 +425,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
if (sec_level == BT_SECURITY_SDP)
return 1;

if (sec_level == BT_SECURITY_LOW) {
if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0)
return hci_conn_auth(conn, sec_level, auth_type);
else
return 1;
}
if (sec_level == BT_SECURITY_LOW &&
(!conn->ssp_mode || !conn->hdev->ssp_mode))
return 1;

if (conn->link_mode & HCI_LM_ENCRYPT)
return hci_conn_auth(conn, sec_level, auth_type);
Expand Down
36 changes: 35 additions & 1 deletion trunk/net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (conn->type == ACL_LINK) {
conn->state = BT_CONFIG;
hci_conn_hold(conn);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
} else
conn->state = BT_CONNECTED;

Expand Down Expand Up @@ -1063,9 +1064,14 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
hci_proto_connect_cfm(conn, ev->status);
hci_conn_put(conn);
}
} else
} else {
hci_auth_cfm(conn, ev->status);

hci_conn_hold(conn);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
hci_conn_put(conn);
}

if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
if (!ev->status) {
struct hci_cp_set_conn_encrypt cp;
Expand Down Expand Up @@ -1479,7 +1485,21 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb

static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_pin_code_req *ev = (void *) skb->data;
struct hci_conn *conn;

BT_DBG("%s", hdev->name);

hci_dev_lock(hdev);

conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
if (conn) {
hci_conn_hold(conn);
conn->disc_timeout = HCI_PAIRING_TIMEOUT;
hci_conn_put(conn);
}

hci_dev_unlock(hdev);
}

static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
Expand All @@ -1489,7 +1509,21 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff

static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_link_key_notify *ev = (void *) skb->data;
struct hci_conn *conn;

BT_DBG("%s", hdev->name);

hci_dev_lock(hdev);

conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
if (conn) {
hci_conn_hold(conn);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
hci_conn_put(conn);
}

hci_dev_unlock(hdev);
}

static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb)
Expand Down
37 changes: 16 additions & 21 deletions trunk/net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
struct class *bt_class = NULL;
EXPORT_SYMBOL_GPL(bt_class);

static struct workqueue_struct *btaddconn;
static struct workqueue_struct *btdelconn;
static struct workqueue_struct *bluetooth;

static inline char *link_typetostr(int type)
{
Expand Down Expand Up @@ -88,9 +87,10 @@ static struct device_type bt_link = {

static void add_conn(struct work_struct *work)
{
struct hci_conn *conn = container_of(work, struct hci_conn, work);
struct hci_conn *conn = container_of(work, struct hci_conn, work_add);

flush_workqueue(btdelconn);
/* ensure previous add/del is complete */
flush_workqueue(bluetooth);

if (device_add(&conn->dev) < 0) {
BT_ERR("Failed to register connection device");
Expand All @@ -114,9 +114,9 @@ void hci_conn_add_sysfs(struct hci_conn *conn)

device_initialize(&conn->dev);

INIT_WORK(&conn->work, add_conn);
INIT_WORK(&conn->work_add, add_conn);

queue_work(btaddconn, &conn->work);
queue_work(bluetooth, &conn->work_add);
}

/*
Expand All @@ -131,9 +131,12 @@ static int __match_tty(struct device *dev, void *data)

static void del_conn(struct work_struct *work)
{
struct hci_conn *conn = container_of(work, struct hci_conn, work);
struct hci_conn *conn = container_of(work, struct hci_conn, work_del);
struct hci_dev *hdev = conn->hdev;

/* ensure previous add/del is complete */
flush_workqueue(bluetooth);

while (1) {
struct device *dev;

Expand All @@ -156,9 +159,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn)
if (!device_is_registered(&conn->dev))
return;

INIT_WORK(&conn->work, del_conn);
INIT_WORK(&conn->work_del, del_conn);

queue_work(btdelconn, &conn->work);
queue_work(bluetooth, &conn->work_del);
}

static inline char *host_typetostr(int type)
Expand Down Expand Up @@ -435,20 +438,13 @@ void hci_unregister_sysfs(struct hci_dev *hdev)

int __init bt_sysfs_init(void)
{
btaddconn = create_singlethread_workqueue("btaddconn");
if (!btaddconn)
return -ENOMEM;

btdelconn = create_singlethread_workqueue("btdelconn");
if (!btdelconn) {
destroy_workqueue(btaddconn);
bluetooth = create_singlethread_workqueue("bluetooth");
if (!bluetooth)
return -ENOMEM;
}

bt_class = class_create(THIS_MODULE, "bluetooth");
if (IS_ERR(bt_class)) {
destroy_workqueue(btdelconn);
destroy_workqueue(btaddconn);
destroy_workqueue(bluetooth);
return PTR_ERR(bt_class);
}

Expand All @@ -457,8 +453,7 @@ int __init bt_sysfs_init(void)

void bt_sysfs_cleanup(void)
{
destroy_workqueue(btaddconn);
destroy_workqueue(btdelconn);
destroy_workqueue(bluetooth);

class_destroy(bt_class);
}
Loading

0 comments on commit ca2d224

Please sign in to comment.