aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xen-pciback/pci_stub.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-19 19:40:51 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-19 20:58:35 -0400
commita92336a1176b2119eaa990a1e8bf3109665fdbc6 (patch)
treeaf8ac49b47136acddb5320b9a62be2361bfaf99c /drivers/xen/xen-pciback/pci_stub.c
parentc288b67b9b4d65790e1a1a1fd982330730b68f46 (diff)
xen/pciback: Drop two backends, squash and cleanup some code.
- Remove the slot and controller controller backend as they are not used. - Document the find pciback_[read|write]_config_[byte|word|dword] to make it easier to find. - Collapse the code from conf_space_capability_msi into pciback_ops.c - Collapse conf_space_capability_[pm|vpd].c in conf_space_capability.c [and remove the conf_space_capability.h file] - Rename all visible functions from pciback to xen_pcibk. - Rename all the printk/pr_info, etc that use the "pciback" to say "xen-pciback". - Convert functions that are not referenced outside the code to be static to save on name space. - Do the same thing for structures that are internal to the driver. - Run checkpatch.pl after the renames and fixup its warnings and fix any compile errors caused by the variable rename - Cleanup any structs that checkpath.pl commented about or just look odd. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/xen-pciback/pci_stub.c')
-rw-r--r--drivers/xen/xen-pciback/pci_stub.c217
1 files changed, 111 insertions, 106 deletions
diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
index c4d1071ebbe6..aec214ac0a14 100644
--- a/drivers/xen/xen-pciback/pci_stub.c
+++ b/drivers/xen/xen-pciback/pci_stub.c
@@ -21,12 +21,12 @@
21#include "conf_space.h" 21#include "conf_space.h"
22#include "conf_space_quirks.h" 22#include "conf_space_quirks.h"
23 23
24#define DRV_NAME "pciback" 24#define DRV_NAME "xen-pciback"
25 25
26static char *pci_devs_to_hide; 26static char *pci_devs_to_hide;
27wait_queue_head_t aer_wait_queue; 27wait_queue_head_t xen_pcibk_aer_wait_queue;
28/*Add sem for sync AER handling and pciback remove/reconfigue ops, 28/*Add sem for sync AER handling and xen_pcibk remove/reconfigue ops,
29* We want to avoid in middle of AER ops, pciback devices is being removed 29* We want to avoid in middle of AER ops, xen_pcibk devices is being removed
30*/ 30*/
31static DECLARE_RWSEM(pcistub_sem); 31static DECLARE_RWSEM(pcistub_sem);
32module_param_named(hide, pci_devs_to_hide, charp, 0444); 32module_param_named(hide, pci_devs_to_hide, charp, 0444);
@@ -46,7 +46,7 @@ struct pcistub_device {
46 spinlock_t lock; 46 spinlock_t lock;
47 47
48 struct pci_dev *dev; 48 struct pci_dev *dev;
49 struct pciback_device *pdev;/* non-NULL if struct pci_dev is in use */ 49 struct xen_pcibk_device *pdev;/* non-NULL if struct pci_dev is in use */
50}; 50};
51 51
52/* Access to pcistub_devices & seized_devices lists and the initialize_devices 52/* Access to pcistub_devices & seized_devices lists and the initialize_devices
@@ -95,9 +95,9 @@ static void pcistub_device_release(struct kref *kref)
95 xen_unregister_device_domain_owner(psdev->dev); 95 xen_unregister_device_domain_owner(psdev->dev);
96 96
97 /* Clean-up the device */ 97 /* Clean-up the device */
98 pciback_reset_device(psdev->dev); 98 xen_pcibk_reset_device(psdev->dev);
99 pciback_config_free_dyn_fields(psdev->dev); 99 xen_pcibk_config_free_dyn_fields(psdev->dev);
100 pciback_config_free_dev(psdev->dev); 100 xen_pcibk_config_free_dev(psdev->dev);
101 kfree(pci_get_drvdata(psdev->dev)); 101 kfree(pci_get_drvdata(psdev->dev));
102 pci_set_drvdata(psdev->dev, NULL); 102 pci_set_drvdata(psdev->dev, NULL);
103 103
@@ -142,7 +142,7 @@ out:
142 return psdev; 142 return psdev;
143} 143}
144 144
145static struct pci_dev *pcistub_device_get_pci_dev(struct pciback_device *pdev, 145static struct pci_dev *pcistub_device_get_pci_dev(struct xen_pcibk_device *pdev,
146 struct pcistub_device *psdev) 146 struct pcistub_device *psdev)
147{ 147{
148 struct pci_dev *pci_dev = NULL; 148 struct pci_dev *pci_dev = NULL;
@@ -163,7 +163,7 @@ static struct pci_dev *pcistub_device_get_pci_dev(struct pciback_device *pdev,
163 return pci_dev; 163 return pci_dev;
164} 164}
165 165
166struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev, 166struct pci_dev *pcistub_get_pci_dev_by_slot(struct xen_pcibk_device *pdev,
167 int domain, int bus, 167 int domain, int bus,
168 int slot, int func) 168 int slot, int func)
169{ 169{
@@ -187,7 +187,7 @@ struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev,
187 return found_dev; 187 return found_dev;
188} 188}
189 189
190struct pci_dev *pcistub_get_pci_dev(struct pciback_device *pdev, 190struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev,
191 struct pci_dev *dev) 191 struct pci_dev *dev)
192{ 192{
193 struct pcistub_device *psdev; 193 struct pcistub_device *psdev;
@@ -224,15 +224,15 @@ void pcistub_put_pci_dev(struct pci_dev *dev)
224 spin_unlock_irqrestore(&pcistub_devices_lock, flags); 224 spin_unlock_irqrestore(&pcistub_devices_lock, flags);
225 225
226 /*hold this lock for avoiding breaking link between 226 /*hold this lock for avoiding breaking link between
227 * pcistub and pciback when AER is in processing 227 * pcistub and xen_pcibk when AER is in processing
228 */ 228 */
229 down_write(&pcistub_sem); 229 down_write(&pcistub_sem);
230 /* Cleanup our device 230 /* Cleanup our device
231 * (so it's ready for the next domain) 231 * (so it's ready for the next domain)
232 */ 232 */
233 pciback_reset_device(found_psdev->dev); 233 xen_pcibk_reset_device(found_psdev->dev);
234 pciback_config_free_dyn_fields(found_psdev->dev); 234 xen_pcibk_config_free_dyn_fields(found_psdev->dev);
235 pciback_config_reset_dev(found_psdev->dev); 235 xen_pcibk_config_reset_dev(found_psdev->dev);
236 236
237 spin_lock_irqsave(&found_psdev->lock, flags); 237 spin_lock_irqsave(&found_psdev->lock, flags);
238 found_psdev->pdev = NULL; 238 found_psdev->pdev = NULL;
@@ -282,13 +282,13 @@ static int __devinit pcistub_match(struct pci_dev *dev)
282 282
283static int __devinit pcistub_init_device(struct pci_dev *dev) 283static int __devinit pcistub_init_device(struct pci_dev *dev)
284{ 284{
285 struct pciback_dev_data *dev_data; 285 struct xen_pcibk_dev_data *dev_data;
286 int err = 0; 286 int err = 0;
287 287
288 dev_dbg(&dev->dev, "initializing...\n"); 288 dev_dbg(&dev->dev, "initializing...\n");
289 289
290 /* The PCI backend is not intended to be a module (or to work with 290 /* The PCI backend is not intended to be a module (or to work with
291 * removable PCI devices (yet). If it were, pciback_config_free() 291 * removable PCI devices (yet). If it were, xen_pcibk_config_free()
292 * would need to be called somewhere to free the memory allocated 292 * would need to be called somewhere to free the memory allocated
293 * here and then to call kfree(pci_get_drvdata(psdev->dev)). 293 * here and then to call kfree(pci_get_drvdata(psdev->dev)).
294 */ 294 */
@@ -308,8 +308,8 @@ static int __devinit pcistub_init_device(struct pci_dev *dev)
308 308
309 dev_dbg(&dev->dev, "initializing config\n"); 309 dev_dbg(&dev->dev, "initializing config\n");
310 310
311 init_waitqueue_head(&aer_wait_queue); 311 init_waitqueue_head(&xen_pcibk_aer_wait_queue);
312 err = pciback_config_init_dev(dev); 312 err = xen_pcibk_config_init_dev(dev);
313 if (err) 313 if (err)
314 goto out; 314 goto out;
315 315
@@ -329,12 +329,12 @@ static int __devinit pcistub_init_device(struct pci_dev *dev)
329 * data is setup before we export) 329 * data is setup before we export)
330 */ 330 */
331 dev_dbg(&dev->dev, "reset device\n"); 331 dev_dbg(&dev->dev, "reset device\n");
332 pciback_reset_device(dev); 332 xen_pcibk_reset_device(dev);
333 333
334 return 0; 334 return 0;
335 335
336config_release: 336config_release:
337 pciback_config_free_dev(dev); 337 xen_pcibk_config_free_dev(dev);
338 338
339out: 339out:
340 pci_set_drvdata(dev, NULL); 340 pci_set_drvdata(dev, NULL);
@@ -354,7 +354,7 @@ static int __init pcistub_init_devices_late(void)
354 unsigned long flags; 354 unsigned long flags;
355 int err = 0; 355 int err = 0;
356 356
357 pr_debug("pciback: pcistub_init_devices_late\n"); 357 pr_debug(DRV_NAME ": pcistub_init_devices_late\n");
358 358
359 spin_lock_irqsave(&pcistub_devices_lock, flags); 359 spin_lock_irqsave(&pcistub_devices_lock, flags);
360 360
@@ -458,7 +458,7 @@ static void pcistub_remove(struct pci_dev *dev)
458 458
459 spin_lock_irqsave(&pcistub_devices_lock, flags); 459 spin_lock_irqsave(&pcistub_devices_lock, flags);
460 460
461 pciback_config_quirk_release(dev); 461 xen_pcibk_config_quirk_release(dev);
462 462
463 list_for_each_entry(psdev, &pcistub_devices, dev_list) { 463 list_for_each_entry(psdev, &pcistub_devices, dev_list) {
464 if (psdev->dev == dev) { 464 if (psdev->dev == dev) {
@@ -474,17 +474,17 @@ static void pcistub_remove(struct pci_dev *dev)
474 found_psdev->pdev); 474 found_psdev->pdev);
475 475
476 if (found_psdev->pdev) { 476 if (found_psdev->pdev) {
477 printk(KERN_WARNING "pciback: ****** removing device " 477 printk(KERN_WARNING DRV_NAME ": ****** removing device "
478 "%s while still in-use! ******\n", 478 "%s while still in-use! ******\n",
479 pci_name(found_psdev->dev)); 479 pci_name(found_psdev->dev));
480 printk(KERN_WARNING "pciback: ****** driver domain may " 480 printk(KERN_WARNING DRV_NAME ": ****** driver domain may"
481 "still access this device's i/o resources!\n"); 481 " still access this device's i/o resources!\n");
482 printk(KERN_WARNING "pciback: ****** shutdown driver " 482 printk(KERN_WARNING DRV_NAME ": ****** shutdown driver "
483 "domain before binding device\n"); 483 "domain before binding device\n");
484 printk(KERN_WARNING "pciback: ****** to other drivers " 484 printk(KERN_WARNING DRV_NAME ": ****** to other drivers "
485 "or domains\n"); 485 "or domains\n");
486 486
487 pciback_release_pci_dev(found_psdev->pdev, 487 xen_pcibk_release_pci_dev(found_psdev->pdev,
488 found_psdev->dev); 488 found_psdev->dev);
489 } 489 }
490 490
@@ -541,11 +541,12 @@ again:
541} 541}
542 542
543/* For each aer recovery step error_detected, mmio_enabled, etc, front_end and 543/* For each aer recovery step error_detected, mmio_enabled, etc, front_end and
544 * backend need to have cooperation. In pciback, those steps will do similar 544 * backend need to have cooperation. In xen_pcibk, those steps will do similar
545 * jobs: send service request and waiting for front_end response. 545 * jobs: send service request and waiting for front_end response.
546*/ 546*/
547static pci_ers_result_t common_process(struct pcistub_device *psdev, 547static pci_ers_result_t common_process(struct pcistub_device *psdev,
548 pci_channel_state_t state, int aer_cmd, pci_ers_result_t result) 548 pci_channel_state_t state, int aer_cmd,
549 pci_ers_result_t result)
549{ 550{
550 pci_ers_result_t res = result; 551 pci_ers_result_t res = result;
551 struct xen_pcie_aer_op *aer_op; 552 struct xen_pcie_aer_op *aer_op;
@@ -557,21 +558,21 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
557 /*useful for error_detected callback*/ 558 /*useful for error_detected callback*/
558 aer_op->err = state; 559 aer_op->err = state;
559 /*pcifront_end BDF*/ 560 /*pcifront_end BDF*/
560 ret = pciback_get_pcifront_dev(psdev->dev, psdev->pdev, 561 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev,
561 &aer_op->domain, &aer_op->bus, &aer_op->devfn); 562 &aer_op->domain, &aer_op->bus, &aer_op->devfn);
562 if (!ret) { 563 if (!ret) {
563 dev_err(&psdev->dev->dev, 564 dev_err(&psdev->dev->dev,
564 "pciback: failed to get pcifront device\n"); 565 DRV_NAME ": failed to get pcifront device\n");
565 return PCI_ERS_RESULT_NONE; 566 return PCI_ERS_RESULT_NONE;
566 } 567 }
567 wmb(); 568 wmb();
568 569
569 dev_dbg(&psdev->dev->dev, 570 dev_dbg(&psdev->dev->dev,
570 "pciback: aer_op %x dom %x bus %x devfn %x\n", 571 DRV_NAME ": aer_op %x dom %x bus %x devfn %x\n",
571 aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn); 572 aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn);
572 /*local flag to mark there's aer request, pciback callback will use this 573 /*local flag to mark there's aer request, xen_pcibk callback will use
573 * flag to judge whether we need to check pci-front give aer service 574 * this flag to judge whether we need to check pci-front give aer
574 * ack signal 575 * service ack signal
575 */ 576 */
576 set_bit(_PCIB_op_pending, (unsigned long *)&psdev->pdev->flags); 577 set_bit(_PCIB_op_pending, (unsigned long *)&psdev->pdev->flags);
577 578
@@ -584,8 +585,9 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
584 wmb(); 585 wmb();
585 notify_remote_via_irq(psdev->pdev->evtchn_irq); 586 notify_remote_via_irq(psdev->pdev->evtchn_irq);
586 587
587 ret = wait_event_timeout(aer_wait_queue, !(test_bit(_XEN_PCIB_active, 588 ret = wait_event_timeout(xen_pcibk_aer_wait_queue,
588 (unsigned long *)&psdev->pdev->sh_info->flags)), 300*HZ); 589 !(test_bit(_XEN_PCIB_active, (unsigned long *)
590 &psdev->pdev->sh_info->flags)), 300*HZ);
589 591
590 if (!ret) { 592 if (!ret) {
591 if (test_bit(_XEN_PCIB_active, 593 if (test_bit(_XEN_PCIB_active,
@@ -603,8 +605,8 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
603 if (test_bit(_XEN_PCIF_active, 605 if (test_bit(_XEN_PCIF_active,
604 (unsigned long *)&psdev->pdev->sh_info->flags)) { 606 (unsigned long *)&psdev->pdev->sh_info->flags)) {
605 dev_dbg(&psdev->dev->dev, 607 dev_dbg(&psdev->dev->dev,
606 "schedule pci_conf service in pciback\n"); 608 "schedule pci_conf service in xen_pcibk\n");
607 test_and_schedule_op(psdev->pdev); 609 xen_pcibk_test_and_schedule_op(psdev->pdev);
608 } 610 }
609 611
610 res = (pci_ers_result_t)aer_op->err; 612 res = (pci_ers_result_t)aer_op->err;
@@ -612,19 +614,19 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
612} 614}
613 615
614/* 616/*
615* pciback_slot_reset: it will send the slot_reset request to pcifront in case 617* xen_pcibk_slot_reset: it will send the slot_reset request to pcifront in case
616* of the device driver could provide this service, and then wait for pcifront 618* of the device driver could provide this service, and then wait for pcifront
617* ack. 619* ack.
618* @dev: pointer to PCI devices 620* @dev: pointer to PCI devices
619* return value is used by aer_core do_recovery policy 621* return value is used by aer_core do_recovery policy
620*/ 622*/
621static pci_ers_result_t pciback_slot_reset(struct pci_dev *dev) 623static pci_ers_result_t xen_pcibk_slot_reset(struct pci_dev *dev)
622{ 624{
623 struct pcistub_device *psdev; 625 struct pcistub_device *psdev;
624 pci_ers_result_t result; 626 pci_ers_result_t result;
625 627
626 result = PCI_ERS_RESULT_RECOVERED; 628 result = PCI_ERS_RESULT_RECOVERED;
627 dev_dbg(&dev->dev, "pciback_slot_reset(bus:%x,devfn:%x)\n", 629 dev_dbg(&dev->dev, "xen_pcibk_slot_reset(bus:%x,devfn:%x)\n",
628 dev->bus->number, dev->devfn); 630 dev->bus->number, dev->devfn);
629 631
630 down_write(&pcistub_sem); 632 down_write(&pcistub_sem);
@@ -635,12 +637,12 @@ static pci_ers_result_t pciback_slot_reset(struct pci_dev *dev)
635 637
636 if (!psdev || !psdev->pdev) { 638 if (!psdev || !psdev->pdev) {
637 dev_err(&dev->dev, 639 dev_err(&dev->dev,
638 "pciback device is not found/assigned\n"); 640 DRV_NAME " device is not found/assigned\n");
639 goto end; 641 goto end;
640 } 642 }
641 643
642 if (!psdev->pdev->sh_info) { 644 if (!psdev->pdev->sh_info) {
643 dev_err(&dev->dev, "pciback device is not connected or owned" 645 dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
644 " by HVM, kill it\n"); 646 " by HVM, kill it\n");
645 kill_domain_by_device(psdev); 647 kill_domain_by_device(psdev);
646 goto release; 648 goto release;
@@ -669,20 +671,20 @@ end:
669} 671}
670 672
671 673
672/*pciback_mmio_enabled: it will send the mmio_enabled request to pcifront 674/*xen_pcibk_mmio_enabled: it will send the mmio_enabled request to pcifront
673* in case of the device driver could provide this service, and then wait 675* in case of the device driver could provide this service, and then wait
674* for pcifront ack 676* for pcifront ack
675* @dev: pointer to PCI devices 677* @dev: pointer to PCI devices
676* return value is used by aer_core do_recovery policy 678* return value is used by aer_core do_recovery policy
677*/ 679*/
678 680
679static pci_ers_result_t pciback_mmio_enabled(struct pci_dev *dev) 681static pci_ers_result_t xen_pcibk_mmio_enabled(struct pci_dev *dev)
680{ 682{
681 struct pcistub_device *psdev; 683 struct pcistub_device *psdev;
682 pci_ers_result_t result; 684 pci_ers_result_t result;
683 685
684 result = PCI_ERS_RESULT_RECOVERED; 686 result = PCI_ERS_RESULT_RECOVERED;
685 dev_dbg(&dev->dev, "pciback_mmio_enabled(bus:%x,devfn:%x)\n", 687 dev_dbg(&dev->dev, "xen_pcibk_mmio_enabled(bus:%x,devfn:%x)\n",
686 dev->bus->number, dev->devfn); 688 dev->bus->number, dev->devfn);
687 689
688 down_write(&pcistub_sem); 690 down_write(&pcistub_sem);
@@ -693,12 +695,12 @@ static pci_ers_result_t pciback_mmio_enabled(struct pci_dev *dev)
693 695
694 if (!psdev || !psdev->pdev) { 696 if (!psdev || !psdev->pdev) {
695 dev_err(&dev->dev, 697 dev_err(&dev->dev,
696 "pciback device is not found/assigned\n"); 698 DRV_NAME " device is not found/assigned\n");
697 goto end; 699 goto end;
698 } 700 }
699 701
700 if (!psdev->pdev->sh_info) { 702 if (!psdev->pdev->sh_info) {
701 dev_err(&dev->dev, "pciback device is not connected or owned" 703 dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
702 " by HVM, kill it\n"); 704 " by HVM, kill it\n");
703 kill_domain_by_device(psdev); 705 kill_domain_by_device(psdev);
704 goto release; 706 goto release;
@@ -725,7 +727,7 @@ end:
725 return result; 727 return result;
726} 728}
727 729
728/*pciback_error_detected: it will send the error_detected request to pcifront 730/*xen_pcibk_error_detected: it will send the error_detected request to pcifront
729* in case of the device driver could provide this service, and then wait 731* in case of the device driver could provide this service, and then wait
730* for pcifront ack. 732* for pcifront ack.
731* @dev: pointer to PCI devices 733* @dev: pointer to PCI devices
@@ -733,14 +735,14 @@ end:
733* return value is used by aer_core do_recovery policy 735* return value is used by aer_core do_recovery policy
734*/ 736*/
735 737
736static pci_ers_result_t pciback_error_detected(struct pci_dev *dev, 738static pci_ers_result_t xen_pcibk_error_detected(struct pci_dev *dev,
737 pci_channel_state_t error) 739 pci_channel_state_t error)
738{ 740{
739 struct pcistub_device *psdev; 741 struct pcistub_device *psdev;
740 pci_ers_result_t result; 742 pci_ers_result_t result;
741 743
742 result = PCI_ERS_RESULT_CAN_RECOVER; 744 result = PCI_ERS_RESULT_CAN_RECOVER;
743 dev_dbg(&dev->dev, "pciback_error_detected(bus:%x,devfn:%x)\n", 745 dev_dbg(&dev->dev, "xen_pcibk_error_detected(bus:%x,devfn:%x)\n",
744 dev->bus->number, dev->devfn); 746 dev->bus->number, dev->devfn);
745 747
746 down_write(&pcistub_sem); 748 down_write(&pcistub_sem);
@@ -751,12 +753,12 @@ static pci_ers_result_t pciback_error_detected(struct pci_dev *dev,
751 753
752 if (!psdev || !psdev->pdev) { 754 if (!psdev || !psdev->pdev) {
753 dev_err(&dev->dev, 755 dev_err(&dev->dev,
754 "pciback device is not found/assigned\n"); 756 DRV_NAME " device is not found/assigned\n");
755 goto end; 757 goto end;
756 } 758 }
757 759
758 if (!psdev->pdev->sh_info) { 760 if (!psdev->pdev->sh_info) {
759 dev_err(&dev->dev, "pciback device is not connected or owned" 761 dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
760 " by HVM, kill it\n"); 762 " by HVM, kill it\n");
761 kill_domain_by_device(psdev); 763 kill_domain_by_device(psdev);
762 goto release; 764 goto release;
@@ -784,17 +786,17 @@ end:
784 return result; 786 return result;
785} 787}
786 788
787/*pciback_error_resume: it will send the error_resume request to pcifront 789/*xen_pcibk_error_resume: it will send the error_resume request to pcifront
788* in case of the device driver could provide this service, and then wait 790* in case of the device driver could provide this service, and then wait
789* for pcifront ack. 791* for pcifront ack.
790* @dev: pointer to PCI devices 792* @dev: pointer to PCI devices
791*/ 793*/
792 794
793static void pciback_error_resume(struct pci_dev *dev) 795static void xen_pcibk_error_resume(struct pci_dev *dev)
794{ 796{
795 struct pcistub_device *psdev; 797 struct pcistub_device *psdev;
796 798
797 dev_dbg(&dev->dev, "pciback_error_resume(bus:%x,devfn:%x)\n", 799 dev_dbg(&dev->dev, "xen_pcibk_error_resume(bus:%x,devfn:%x)\n",
798 dev->bus->number, dev->devfn); 800 dev->bus->number, dev->devfn);
799 801
800 down_write(&pcistub_sem); 802 down_write(&pcistub_sem);
@@ -805,12 +807,12 @@ static void pciback_error_resume(struct pci_dev *dev)
805 807
806 if (!psdev || !psdev->pdev) { 808 if (!psdev || !psdev->pdev) {
807 dev_err(&dev->dev, 809 dev_err(&dev->dev,
808 "pciback device is not found/assigned\n"); 810 DRV_NAME " device is not found/assigned\n");
809 goto end; 811 goto end;
810 } 812 }
811 813
812 if (!psdev->pdev->sh_info) { 814 if (!psdev->pdev->sh_info) {
813 dev_err(&dev->dev, "pciback device is not connected or owned" 815 dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
814 " by HVM, kill it\n"); 816 " by HVM, kill it\n");
815 kill_domain_by_device(psdev); 817 kill_domain_by_device(psdev);
816 goto release; 818 goto release;
@@ -832,12 +834,12 @@ end:
832 return; 834 return;
833} 835}
834 836
835/*add pciback AER handling*/ 837/*add xen_pcibk AER handling*/
836static struct pci_error_handlers pciback_error_handler = { 838static struct pci_error_handlers xen_pcibk_error_handler = {
837 .error_detected = pciback_error_detected, 839 .error_detected = xen_pcibk_error_detected,
838 .mmio_enabled = pciback_mmio_enabled, 840 .mmio_enabled = xen_pcibk_mmio_enabled,
839 .slot_reset = pciback_slot_reset, 841 .slot_reset = xen_pcibk_slot_reset,
840 .resume = pciback_error_resume, 842 .resume = xen_pcibk_error_resume,
841}; 843};
842 844
843/* 845/*
@@ -845,12 +847,14 @@ static struct pci_error_handlers pciback_error_handler = {
845 * for a normal device. I don't want it to be loaded automatically. 847 * for a normal device. I don't want it to be loaded automatically.
846 */ 848 */
847 849
848static struct pci_driver pciback_pci_driver = { 850static struct pci_driver xen_pcibk_pci_driver = {
849 .name = DRV_NAME, 851 /* The name should be xen_pciback, but until the tools are updated
852 * we will keep it as pciback. */
853 .name = "pciback",
850 .id_table = pcistub_ids, 854 .id_table = pcistub_ids,
851 .probe = pcistub_probe, 855 .probe = pcistub_probe,
852 .remove = pcistub_remove, 856 .remove = pcistub_remove,
853 .err_handler = &pciback_error_handler, 857 .err_handler = &xen_pcibk_error_handler,
854}; 858};
855 859
856static inline int str_to_slot(const char *buf, int *domain, int *bus, 860static inline int str_to_slot(const char *buf, int *domain, int *bus,
@@ -899,7 +903,7 @@ static int pcistub_device_id_add(int domain, int bus, int slot, int func)
899 pci_dev_id->bus = bus; 903 pci_dev_id->bus = bus;
900 pci_dev_id->devfn = PCI_DEVFN(slot, func); 904 pci_dev_id->devfn = PCI_DEVFN(slot, func);
901 905
902 pr_debug("pciback: wants to seize %04x:%02x:%02x.%01x\n", 906 pr_debug(DRV_NAME ": wants to seize %04x:%02x:%02x.%01x\n",
903 domain, bus, slot, func); 907 domain, bus, slot, func);
904 908
905 spin_lock_irqsave(&device_ids_lock, flags); 909 spin_lock_irqsave(&device_ids_lock, flags);
@@ -929,7 +933,7 @@ static int pcistub_device_id_remove(int domain, int bus, int slot, int func)
929 933
930 err = 0; 934 err = 0;
931 935
932 pr_debug("pciback: removed %04x:%02x:%02x.%01x from " 936 pr_debug(DRV_NAME ": removed %04x:%02x:%02x.%01x from "
933 "seize list\n", domain, bus, slot, func); 937 "seize list\n", domain, bus, slot, func);
934 } 938 }
935 } 939 }
@@ -965,9 +969,9 @@ static int pcistub_reg_add(int domain, int bus, int slot, int func, int reg,
965 field->init = NULL; 969 field->init = NULL;
966 field->reset = NULL; 970 field->reset = NULL;
967 field->release = NULL; 971 field->release = NULL;
968 field->clean = pciback_config_field_free; 972 field->clean = xen_pcibk_config_field_free;
969 973
970 err = pciback_config_quirks_add_field(dev, field); 974 err = xen_pcibk_config_quirks_add_field(dev, field);
971 if (err) 975 if (err)
972 kfree(field); 976 kfree(field);
973out: 977out:
@@ -1041,7 +1045,7 @@ DRIVER_ATTR(slots, S_IRUSR, pcistub_slot_show, NULL);
1041static ssize_t pcistub_irq_handler_show(struct device_driver *drv, char *buf) 1045static ssize_t pcistub_irq_handler_show(struct device_driver *drv, char *buf)
1042{ 1046{
1043 struct pcistub_device *psdev; 1047 struct pcistub_device *psdev;
1044 struct pciback_dev_data *dev_data; 1048 struct xen_pcibk_dev_data *dev_data;
1045 size_t count = 0; 1049 size_t count = 0;
1046 unsigned long flags; 1050 unsigned long flags;
1047 1051
@@ -1073,7 +1077,7 @@ static ssize_t pcistub_irq_handler_switch(struct device_driver *drv,
1073 size_t count) 1077 size_t count)
1074{ 1078{
1075 struct pcistub_device *psdev; 1079 struct pcistub_device *psdev;
1076 struct pciback_dev_data *dev_data; 1080 struct xen_pcibk_dev_data *dev_data;
1077 int domain, bus, slot, func; 1081 int domain, bus, slot, func;
1078 int err = -ENOENT; 1082 int err = -ENOENT;
1079 1083
@@ -1127,13 +1131,13 @@ static ssize_t pcistub_quirk_show(struct device_driver *drv, char *buf)
1127{ 1131{
1128 int count = 0; 1132 int count = 0;
1129 unsigned long flags; 1133 unsigned long flags;
1130 struct pciback_config_quirk *quirk; 1134 struct xen_pcibk_config_quirk *quirk;
1131 struct pciback_dev_data *dev_data; 1135 struct xen_pcibk_dev_data *dev_data;
1132 const struct config_field *field; 1136 const struct config_field *field;
1133 const struct config_field_entry *cfg_entry; 1137 const struct config_field_entry *cfg_entry;
1134 1138
1135 spin_lock_irqsave(&device_ids_lock, flags); 1139 spin_lock_irqsave(&device_ids_lock, flags);
1136 list_for_each_entry(quirk, &pciback_quirks, quirks_list) { 1140 list_for_each_entry(quirk, &xen_pcibk_quirks, quirks_list) {
1137 if (count >= PAGE_SIZE) 1141 if (count >= PAGE_SIZE)
1138 goto out; 1142 goto out;
1139 1143
@@ -1175,7 +1179,7 @@ static ssize_t permissive_add(struct device_driver *drv, const char *buf,
1175 int domain, bus, slot, func; 1179 int domain, bus, slot, func;
1176 int err; 1180 int err;
1177 struct pcistub_device *psdev; 1181 struct pcistub_device *psdev;
1178 struct pciback_dev_data *dev_data; 1182 struct xen_pcibk_dev_data *dev_data;
1179 err = str_to_slot(buf, &domain, &bus, &slot, &func); 1183 err = str_to_slot(buf, &domain, &bus, &slot, &func);
1180 if (err) 1184 if (err)
1181 goto out; 1185 goto out;
@@ -1213,7 +1217,7 @@ out:
1213static ssize_t permissive_show(struct device_driver *drv, char *buf) 1217static ssize_t permissive_show(struct device_driver *drv, char *buf)
1214{ 1218{
1215 struct pcistub_device *psdev; 1219 struct pcistub_device *psdev;
1216 struct pciback_dev_data *dev_data; 1220 struct xen_pcibk_dev_data *dev_data;
1217 size_t count = 0; 1221 size_t count = 0;
1218 unsigned long flags; 1222 unsigned long flags;
1219 spin_lock_irqsave(&pcistub_devices_lock, flags); 1223 spin_lock_irqsave(&pcistub_devices_lock, flags);
@@ -1237,17 +1241,18 @@ DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show, permissive_add);
1237 1241
1238static void pcistub_exit(void) 1242static void pcistub_exit(void)
1239{ 1243{
1240 driver_remove_file(&pciback_pci_driver.driver, &driver_attr_new_slot); 1244 driver_remove_file(&xen_pcibk_pci_driver.driver, &driver_attr_new_slot);
1241 driver_remove_file(&pciback_pci_driver.driver, 1245 driver_remove_file(&xen_pcibk_pci_driver.driver,
1242 &driver_attr_remove_slot); 1246 &driver_attr_remove_slot);
1243 driver_remove_file(&pciback_pci_driver.driver, &driver_attr_slots); 1247 driver_remove_file(&xen_pcibk_pci_driver.driver, &driver_attr_slots);
1244 driver_remove_file(&pciback_pci_driver.driver, &driver_attr_quirks); 1248 driver_remove_file(&xen_pcibk_pci_driver.driver, &driver_attr_quirks);
1245 driver_remove_file(&pciback_pci_driver.driver, &driver_attr_permissive); 1249 driver_remove_file(&xen_pcibk_pci_driver.driver,
1246 driver_remove_file(&pciback_pci_driver.driver, 1250 &driver_attr_permissive);
1251 driver_remove_file(&xen_pcibk_pci_driver.driver,
1247 &driver_attr_irq_handlers); 1252 &driver_attr_irq_handlers);
1248 driver_remove_file(&pciback_pci_driver.driver, 1253 driver_remove_file(&xen_pcibk_pci_driver.driver,
1249 &driver_attr_irq_handler_state); 1254 &driver_attr_irq_handler_state);
1250 pci_unregister_driver(&pciback_pci_driver); 1255 pci_unregister_driver(&xen_pcibk_pci_driver);
1251} 1256}
1252 1257
1253static int __init pcistub_init(void) 1258static int __init pcistub_init(void)
@@ -1286,30 +1291,30 @@ static int __init pcistub_init(void)
1286 * first one to get offered PCI devices as they become 1291 * first one to get offered PCI devices as they become
1287 * available (and thus we can be the first to grab them) 1292 * available (and thus we can be the first to grab them)
1288 */ 1293 */
1289 err = pci_register_driver(&pciback_pci_driver); 1294 err = pci_register_driver(&xen_pcibk_pci_driver);
1290 if (err < 0) 1295 if (err < 0)
1291 goto out; 1296 goto out;
1292 1297
1293 err = driver_create_file(&pciback_pci_driver.driver, 1298 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1294 &driver_attr_new_slot); 1299 &driver_attr_new_slot);
1295 if (!err) 1300 if (!err)
1296 err = driver_create_file(&pciback_pci_driver.driver, 1301 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1297 &driver_attr_remove_slot); 1302 &driver_attr_remove_slot);
1298 if (!err) 1303 if (!err)
1299 err = driver_create_file(&pciback_pci_driver.driver, 1304 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1300 &driver_attr_slots); 1305 &driver_attr_slots);
1301 if (!err) 1306 if (!err)
1302 err = driver_create_file(&pciback_pci_driver.driver, 1307 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1303 &driver_attr_quirks); 1308 &driver_attr_quirks);
1304 if (!err) 1309 if (!err)
1305 err = driver_create_file(&pciback_pci_driver.driver, 1310 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1306 &driver_attr_permissive); 1311 &driver_attr_permissive);
1307 1312
1308 if (!err) 1313 if (!err)
1309 err = driver_create_file(&pciback_pci_driver.driver, 1314 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1310 &driver_attr_irq_handlers); 1315 &driver_attr_irq_handlers);
1311 if (!err) 1316 if (!err)
1312 err = driver_create_file(&pciback_pci_driver.driver, 1317 err = driver_create_file(&xen_pcibk_pci_driver.driver,
1313 &driver_attr_irq_handler_state); 1318 &driver_attr_irq_handler_state);
1314 if (err) 1319 if (err)
1315 pcistub_exit(); 1320 pcistub_exit();
@@ -1318,7 +1323,7 @@ out:
1318 return err; 1323 return err;
1319 1324
1320parse_error: 1325parse_error:
1321 printk(KERN_ERR "pciback: Error parsing pci_devs_to_hide at \"%s\"\n", 1326 printk(KERN_ERR DRV_NAME ": Error parsing pci_devs_to_hide at \"%s\"\n",
1322 pci_devs_to_hide + pos); 1327 pci_devs_to_hide + pos);
1323 return -EINVAL; 1328 return -EINVAL;
1324} 1329}
@@ -1326,7 +1331,7 @@ parse_error:
1326#ifndef MODULE 1331#ifndef MODULE
1327/* 1332/*
1328 * fs_initcall happens before device_initcall 1333 * fs_initcall happens before device_initcall
1329 * so pciback *should* get called first (b/c we 1334 * so xen_pcibk *should* get called first (b/c we
1330 * want to suck up any device before other drivers 1335 * want to suck up any device before other drivers
1331 * get a chance by being the first pci device 1336 * get a chance by being the first pci device
1332 * driver to register) 1337 * driver to register)
@@ -1334,14 +1339,14 @@ parse_error:
1334fs_initcall(pcistub_init); 1339fs_initcall(pcistub_init);
1335#endif 1340#endif
1336 1341
1337static int __init pciback_init(void) 1342static int __init xen_pcibk_init(void)
1338{ 1343{
1339 int err; 1344 int err;
1340 1345
1341 if (!xen_initial_domain()) 1346 if (!xen_initial_domain())
1342 return -ENODEV; 1347 return -ENODEV;
1343 1348
1344 err = pciback_config_init(); 1349 err = xen_pcibk_config_init();
1345 if (err) 1350 if (err)
1346 return err; 1351 return err;
1347 1352
@@ -1352,20 +1357,20 @@ static int __init pciback_init(void)
1352#endif 1357#endif
1353 1358
1354 pcistub_init_devices_late(); 1359 pcistub_init_devices_late();
1355 err = pciback_xenbus_register(); 1360 err = xen_pcibk_xenbus_register();
1356 if (err) 1361 if (err)
1357 pcistub_exit(); 1362 pcistub_exit();
1358 1363
1359 return err; 1364 return err;
1360} 1365}
1361 1366
1362static void __exit pciback_cleanup(void) 1367static void __exit xen_pcibk_cleanup(void)
1363{ 1368{
1364 pciback_xenbus_unregister(); 1369 xen_pcibk_xenbus_unregister();
1365 pcistub_exit(); 1370 pcistub_exit();
1366} 1371}
1367 1372
1368module_init(pciback_init); 1373module_init(xen_pcibk_init);
1369module_exit(pciback_cleanup); 1374module_exit(xen_pcibk_cleanup);
1370 1375
1371MODULE_LICENSE("Dual BSD/GPL"); 1376MODULE_LICENSE("Dual BSD/GPL");