Lines Matching +full:- +full:- +full:target +full:- +full:list

1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/list.h>
17 struct list_head list; member
25 struct agp_3_5_dev *cur, *n = list_entry(new, struct agp_3_5_dev, list); in agp_3_5_dev_list_insert()
29 cur = list_entry(pos, struct agp_3_5_dev, list); in agp_3_5_dev_list_insert()
30 if (cur->maxbw > n->maxbw) in agp_3_5_dev_list_insert()
36 static void agp_3_5_dev_list_sort(struct agp_3_5_dev *list, unsigned int ndevs) in agp_3_5_dev_list_sort() argument
40 struct list_head *pos, *tmp, *head = &list->list, *start = head->next; in agp_3_5_dev_list_sort()
46 cur = list_entry(pos, struct agp_3_5_dev, list); in agp_3_5_dev_list_sort()
47 dev = cur->dev; in agp_3_5_dev_list_sort()
49 pci_read_config_dword(dev, cur->capndx+AGPNISTAT, &nistat); in agp_3_5_dev_list_sort()
50 cur->maxbw = (nistat >> 16) & 0xff; in agp_3_5_dev_list_sort()
53 pos = pos->next; in agp_3_5_dev_list_sort()
80 struct pci_dev *td = bridge->dev, *dev; in agp_3_5_isochronous_node_enable()
81 struct list_head *head = &dev_list->list, *pos; in agp_3_5_isochronous_node_enable()
83 struct isoch_data *master, target; in agp_3_5_isochronous_node_enable() local
97 ret = -ENOMEM; in agp_3_5_isochronous_node_enable()
102 * Sort the device list by maxbw. We need to do this because the in agp_3_5_isochronous_node_enable()
107 * We don't exactly do this, we divide target resources by ndevs in agp_3_5_isochronous_node_enable()
119 pci_read_config_dword(td, bridge->capndx+AGPNISTAT, &tnistat); in agp_3_5_isochronous_node_enable()
120 pci_read_config_dword(td, bridge->capndx+AGPSTAT, &tstatus); in agp_3_5_isochronous_node_enable()
122 /* Extract power-on defaults from the target */ in agp_3_5_isochronous_node_enable()
123 target.maxbw = (tnistat >> 16) & 0xff; in agp_3_5_isochronous_node_enable()
124 target.n = (tnistat >> 8) & 0xff; in agp_3_5_isochronous_node_enable()
125 target.y = (tnistat >> 6) & 0x3; in agp_3_5_isochronous_node_enable()
126 target.l = (tnistat >> 3) & 0x7; in agp_3_5_isochronous_node_enable()
127 target.rq = (tstatus >> 24) & 0xff; in agp_3_5_isochronous_node_enable()
129 y_max = target.y; in agp_3_5_isochronous_node_enable()
132 * Extract power-on defaults for each device in dev_list. Along in agp_3_5_isochronous_node_enable()
137 cur = list_entry(pos, struct agp_3_5_dev, list); in agp_3_5_isochronous_node_enable()
138 dev = cur->dev; in agp_3_5_isochronous_node_enable()
140 pci_read_config_dword(dev, cur->capndx+AGPNISTAT, &mnistat); in agp_3_5_isochronous_node_enable()
154 if (tot_bw > target.maxbw) { in agp_3_5_isochronous_node_enable()
155 dev_err(&td->dev, "isochronous bandwidth required " in agp_3_5_isochronous_node_enable()
158 ret = -ENODEV; in agp_3_5_isochronous_node_enable()
162 target.y = y_max; in agp_3_5_isochronous_node_enable()
165 * Write the calculated payload size into the target's NICMD in agp_3_5_isochronous_node_enable()
167 * in the target's NISTAT register, so we need to do this now in agp_3_5_isochronous_node_enable()
170 pci_read_config_word(td, bridge->capndx+AGPNICMD, &tnicmd); in agp_3_5_isochronous_node_enable()
172 tnicmd |= target.y << 6; in agp_3_5_isochronous_node_enable()
173 pci_write_config_word(td, bridge->capndx+AGPNICMD, tnicmd); in agp_3_5_isochronous_node_enable()
175 /* Reread the target's ISOCH_N */ in agp_3_5_isochronous_node_enable()
176 pci_read_config_dword(td, bridge->capndx+AGPNISTAT, &tnistat); in agp_3_5_isochronous_node_enable()
177 target.n = (tnistat >> 8) & 0xff; in agp_3_5_isochronous_node_enable()
181 master[cdev].y = target.y; in agp_3_5_isochronous_node_enable()
188 * than the target can handle. */ in agp_3_5_isochronous_node_enable()
189 if (tot_n > target.n) { in agp_3_5_isochronous_node_enable()
190 dev_err(&td->dev, "number of isochronous " in agp_3_5_isochronous_node_enable()
194 ret = -ENODEV; in agp_3_5_isochronous_node_enable()
198 /* Calculate left over ISOCH_N capability in the target. We'll give in agp_3_5_isochronous_node_enable()
200 rem = target.n - tot_n; in agp_3_5_isochronous_node_enable()
217 master[cdev].rq *= (1 << (master[cdev].y - 1)); in agp_3_5_isochronous_node_enable()
221 master[ndevs-1].n += rem; in agp_3_5_isochronous_node_enable()
224 * target is providing. */ in agp_3_5_isochronous_node_enable()
225 rq_isoch = (target.y > 0x1) ? target.n * (1 << (target.y - 1)) : target.n; in agp_3_5_isochronous_node_enable()
226 rq_async = target.rq - rq_isoch; in agp_3_5_isochronous_node_enable()
228 /* Exit if the minimal RQ needs of the masters exceeds what the target in agp_3_5_isochronous_node_enable()
231 dev_err(&td->dev, "number of request queue slots " in agp_3_5_isochronous_node_enable()
235 ret = -ENODEV; in agp_3_5_isochronous_node_enable()
239 /* Calculate asynchronous RQ capability in the target (per master) as in agp_3_5_isochronous_node_enable()
243 rem_isoch = rq_isoch - tot_rq; in agp_3_5_isochronous_node_enable()
249 dev = cur->dev; in agp_3_5_isochronous_node_enable()
251 master[cdev].rq += (cdev == ndevs - 1) in agp_3_5_isochronous_node_enable()
254 pci_read_config_word(dev, cur->capndx+AGPNICMD, &mnicmd); in agp_3_5_isochronous_node_enable()
255 pci_read_config_dword(dev, cur->capndx+AGPCMD, &mcmd); in agp_3_5_isochronous_node_enable()
265 pci_write_config_dword(dev, cur->capndx+AGPCMD, mcmd); in agp_3_5_isochronous_node_enable()
266 pci_write_config_word(dev, cur->capndx+AGPNICMD, mnicmd); in agp_3_5_isochronous_node_enable()
280 * target by ndevs. Distribute this many slots to each AGP 3.0 device,
287 struct list_head *head = &dev_list->list, *pos; in agp_3_5_nonisochronous_node_enable()
292 pci_read_config_dword(bridge->dev, bridge->capndx+AGPSTAT, &tstatus); in agp_3_5_nonisochronous_node_enable()
299 for (pos=head->next; cdev<ndevs; cdev++, pos=pos->next) { in agp_3_5_nonisochronous_node_enable()
300 cur = list_entry(pos, struct agp_3_5_dev, list); in agp_3_5_nonisochronous_node_enable()
302 pci_read_config_dword(cur->dev, cur->capndx+AGPCMD, &mcmd); in agp_3_5_nonisochronous_node_enable()
304 mcmd |= ((cdev == ndevs - 1) ? rem : mrq) << 24; in agp_3_5_nonisochronous_node_enable()
305 pci_write_config_dword(cur->dev, cur->capndx+AGPCMD, mcmd); in agp_3_5_nonisochronous_node_enable()
315 struct pci_dev *td = bridge->dev, *dev = NULL; in agp_3_5_enable()
326 /* Extract some power-on defaults from the target */ in agp_3_5_enable()
327 pci_read_config_dword(td, bridge->capndx+AGPSTAT, &tstatus); in agp_3_5_enable()
330 return -ENODEV; in agp_3_5_enable()
333 * Allocate a head for our AGP 3.5 device list in agp_3_5_enable()
337 ret = -ENOMEM; in agp_3_5_enable()
340 head = &dev_list->list; in agp_3_5_enable()
349 switch ((dev->class >>8) & 0xff00) { in agp_3_5_enable()
357 dev_info(&td->dev, "wacky, found unclassified AGP device %s [%04x/%04x]\n", in agp_3_5_enable()
359 dev->vendor, dev->device); in agp_3_5_enable()
366 ret = -ENOMEM; in agp_3_5_enable()
369 cur->dev = dev; in agp_3_5_enable()
371 pos = &cur->list; in agp_3_5_enable()
388 cur = list_entry(pos, struct agp_3_5_dev, list); in agp_3_5_enable()
389 dev = cur->dev; in agp_3_5_enable()
406 dev_err(&td->dev, "woah! Non-AGP device %s on " in agp_3_5_enable()
409 ret = -ENODEV; in agp_3_5_enable()
415 dev_err(&td->dev, "woah! AGP 2.0 device %s on " in agp_3_5_enable()
418 ret = -ENODEV; in agp_3_5_enable()
422 cur->capndx = mcapndx; in agp_3_5_enable()
424 pci_read_config_dword(dev, cur->capndx+AGPSTAT, &mstatus); in agp_3_5_enable()
427 dev_err(&td->dev, "woah! AGP 3.x device %s not " in agp_3_5_enable()
431 ret = -ENODEV; in agp_3_5_enable()
437 * Call functions to divide target resources amongst the AGP 3.0 in agp_3_5_enable()
444 dev_info(&td->dev, "something bad happened setting " in agp_3_5_enable()
446 "non-isochronous xfer mode\n"); in agp_3_5_enable()
455 for (pos=head->next; pos!=head; ) { in agp_3_5_enable()
456 cur = list_entry(pos, struct agp_3_5_dev, list); in agp_3_5_enable()
458 pos = pos->next; in agp_3_5_enable()