aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uwb/uwb-debug.c
diff options
context:
space:
mode:
authorStefano Panella <stefano.panella@csr.com>2008-12-12 08:00:06 -0500
committerDavid Vrabel <david.vrabel@csr.com>2008-12-12 08:00:06 -0500
commit5b37717a23b8e40f6cf7ad85a26ddcf41c171e2c (patch)
tree3c611f907bc61c6e1900c4092e8f2f1e8eefd907 /drivers/uwb/uwb-debug.c
parentc35fa3ea1ae8198bd65c2c6e59d9ebd68c115a59 (diff)
uwb: improved MAS allocator and reservation conflict handling
Greatly enhance the MAS allocator: - Handle row and column reservations. - Permit all the available MAS to be allocated. - Follows the WiMedia rules on MAS selection. Take appropriate action when reservation conflicts are detected. - Correctly identify which reservation wins the conflict. - Protect alien BP reservations. - If an owned reservation loses, resize/move it. - Follow the backoff procedure before requesting additional MAS. When reservations are terminated, move the remaining reservations (if necessary) so they keep following the MAS allocation rules. Signed-off-by: Stefano Panella <stefano.panella@csr.com> Signed-off-by: David Vrabel <david.vrabel@csr.com>
Diffstat (limited to 'drivers/uwb/uwb-debug.c')
-rw-r--r--drivers/uwb/uwb-debug.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/drivers/uwb/uwb-debug.c b/drivers/uwb/uwb-debug.c
index a6debb9baf38..89b2e6a7214c 100644
--- a/drivers/uwb/uwb-debug.c
+++ b/drivers/uwb/uwb-debug.c
@@ -82,29 +82,21 @@ struct uwb_dbg {
82 struct dentry *reservations_f; 82 struct dentry *reservations_f;
83 struct dentry *accept_f; 83 struct dentry *accept_f;
84 struct dentry *drp_avail_f; 84 struct dentry *drp_avail_f;
85 spinlock_t list_lock;
85}; 86};
86 87
87static struct dentry *root_dir; 88static struct dentry *root_dir;
88 89
89static void uwb_dbg_rsv_cb(struct uwb_rsv *rsv) 90static void uwb_dbg_rsv_cb(struct uwb_rsv *rsv)
90{ 91{
91 struct uwb_rc *rc = rsv->rc; 92 struct uwb_dbg *dbg = rsv->pal_priv;
92 struct device *dev = &rc->uwb_dev.dev;
93 struct uwb_dev_addr devaddr;
94 char owner[UWB_ADDR_STRSIZE], target[UWB_ADDR_STRSIZE];
95
96 uwb_dev_addr_print(owner, sizeof(owner), &rsv->owner->dev_addr);
97 if (rsv->target.type == UWB_RSV_TARGET_DEV)
98 devaddr = rsv->target.dev->dev_addr;
99 else
100 devaddr = rsv->target.devaddr;
101 uwb_dev_addr_print(target, sizeof(target), &devaddr);
102 93
103 dev_dbg(dev, "debug: rsv %s -> %s: %s\n", 94 uwb_rsv_dump("debug", rsv);
104 owner, target, uwb_rsv_state_str(rsv->state));
105 95
106 if (rsv->state == UWB_RSV_STATE_NONE) { 96 if (rsv->state == UWB_RSV_STATE_NONE) {
97 spin_lock(&dbg->list_lock);
107 list_del(&rsv->pal_node); 98 list_del(&rsv->pal_node);
99 spin_unlock(&dbg->list_lock);
108 uwb_rsv_destroy(rsv); 100 uwb_rsv_destroy(rsv);
109 } 101 }
110} 102}
@@ -128,20 +120,21 @@ static int cmd_rsv_establish(struct uwb_rc *rc,
128 return -ENOMEM; 120 return -ENOMEM;
129 } 121 }
130 122
131 rsv->owner = &rc->uwb_dev; 123 rsv->target.type = UWB_RSV_TARGET_DEV;
132 rsv->target.type = UWB_RSV_TARGET_DEV; 124 rsv->target.dev = target;
133 rsv->target.dev = target; 125 rsv->type = cmd->type;
134 rsv->type = cmd->type; 126 rsv->max_mas = cmd->max_mas;
135 rsv->max_mas = cmd->max_mas; 127 rsv->min_mas = cmd->min_mas;
136 rsv->min_mas = cmd->min_mas; 128 rsv->max_interval = cmd->max_interval;
137 rsv->sparsity = cmd->sparsity;
138 129
139 ret = uwb_rsv_establish(rsv); 130 ret = uwb_rsv_establish(rsv);
140 if (ret) 131 if (ret)
141 uwb_rsv_destroy(rsv); 132 uwb_rsv_destroy(rsv);
142 else 133 else {
134 spin_lock(&(rc->dbg)->list_lock);
143 list_add_tail(&rsv->pal_node, &rc->dbg->rsvs); 135 list_add_tail(&rsv->pal_node, &rc->dbg->rsvs);
144 136 spin_unlock(&(rc->dbg)->list_lock);
137 }
145 return ret; 138 return ret;
146} 139}
147 140
@@ -151,17 +144,24 @@ static int cmd_rsv_terminate(struct uwb_rc *rc,
151 struct uwb_rsv *rsv, *found = NULL; 144 struct uwb_rsv *rsv, *found = NULL;
152 int i = 0; 145 int i = 0;
153 146
147 spin_lock(&(rc->dbg)->list_lock);
148
154 list_for_each_entry(rsv, &rc->dbg->rsvs, pal_node) { 149 list_for_each_entry(rsv, &rc->dbg->rsvs, pal_node) {
155 if (i == cmd->index) { 150 if (i == cmd->index) {
156 found = rsv; 151 found = rsv;
152 uwb_rsv_get(found);
157 break; 153 break;
158 } 154 }
159 i++; 155 i++;
160 } 156 }
157
158 spin_unlock(&(rc->dbg)->list_lock);
159
161 if (!found) 160 if (!found)
162 return -EINVAL; 161 return -EINVAL;
163 162
164 uwb_rsv_terminate(found); 163 uwb_rsv_terminate(found);
164 uwb_rsv_put(found);
165 165
166 return 0; 166 return 0;
167} 167}
@@ -191,7 +191,7 @@ static ssize_t command_write(struct file *file, const char __user *buf,
191 struct uwb_rc *rc = file->private_data; 191 struct uwb_rc *rc = file->private_data;
192 struct uwb_dbg_cmd cmd; 192 struct uwb_dbg_cmd cmd;
193 int ret = 0; 193 int ret = 0;
194 194
195 if (len != sizeof(struct uwb_dbg_cmd)) 195 if (len != sizeof(struct uwb_dbg_cmd))
196 return -EINVAL; 196 return -EINVAL;
197 197
@@ -325,7 +325,9 @@ static void uwb_dbg_new_rsv(struct uwb_pal *pal, struct uwb_rsv *rsv)
325 struct uwb_dbg *dbg = container_of(pal, struct uwb_dbg, pal); 325 struct uwb_dbg *dbg = container_of(pal, struct uwb_dbg, pal);
326 326
327 if (dbg->accept) { 327 if (dbg->accept) {
328 spin_lock(&dbg->list_lock);
328 list_add_tail(&rsv->pal_node, &dbg->rsvs); 329 list_add_tail(&rsv->pal_node, &dbg->rsvs);
330 spin_unlock(&dbg->list_lock);
329 uwb_rsv_accept(rsv, uwb_dbg_rsv_cb, dbg); 331 uwb_rsv_accept(rsv, uwb_dbg_rsv_cb, dbg);
330 } 332 }
331} 333}
@@ -341,6 +343,7 @@ void uwb_dbg_add_rc(struct uwb_rc *rc)
341 return; 343 return;
342 344
343 INIT_LIST_HEAD(&rc->dbg->rsvs); 345 INIT_LIST_HEAD(&rc->dbg->rsvs);
346 spin_lock_init(&(rc->dbg)->list_lock);
344 347
345 uwb_pal_init(&rc->dbg->pal); 348 uwb_pal_init(&rc->dbg->pal);
346 rc->dbg->pal.rc = rc; 349 rc->dbg->pal.rc = rc;