Changeset 679 for GPL/trunk/lib32/pci.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/lib32/pci.c
r604 r679 25 25 * 26 26 */ 27 27 #define CONFIG_PM 28 28 #include "linux.h" 29 29 #include <linux/init.h> 30 30 #include <linux/poll.h> 31 #include <linux/dma-mapping.h> 31 32 #include <asm/uaccess.h> 32 33 #include <asm/hardirq.h> … … 183 184 memset((void near *)pcidev, 0, sizeof(struct pci_dev)); 184 185 185 pcidev-> _class = ulTmp2;186 pcidev->class = ulTmp2; 186 187 pcidev->vendor = detectedId & 0xffff; 187 188 pcidev->device = detectedId >> 16; … … 201 202 pcidev->sibling = NULL; 202 203 pcidev->next = NULL; 203 pcidev->dma_mask = 0xFFFFFFFF; 204 pcidev->dma_mask = 0xffffffff; 205 pcidev->dev.dma_mask = &pcidev->dma_mask; 206 pcidev->dev.coherent_dma_mask = 0xffffffffull; 204 207 205 208 // Subsystem ID 206 209 pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, &pcidev->subsystem_vendor); 207 210 pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, &pcidev->subsystem_device); 211 212 // revision 213 pci_read_config_byte(pcidev, PCI_REVISION_ID, &pcidev->revision); 208 214 209 215 // I/O and MEM … … 296 302 if(a->flags & IORESOURCE_MEM) { 297 303 if(RMRequestMem(/*hResMgr,*/ start, n) == FALSE) { 298 printk("RMRequestIO failed for io %x,length %x\n", start, n);304 printk("RMRequestIO failed for mem %x length %x\n", start, n); 299 305 return NULL; 300 306 } … … 302 308 else if(a->flags & IORESOURCE_IO) { 303 309 if(RMRequestIO(/*hResMgr,*/ start, n) == FALSE) { 304 printk("RMRequestIO failed for io %x ,length %x\n", start, n);310 printk("RMRequestIO failed for io %x length %x\n", start, n); 305 311 return NULL; 306 312 } … … 477 483 struct pci_dev *pcidev; 478 484 struct pci_device_id IdTable; 485 USHORT usVendor, usDevice; 479 486 int iAdapter = 0; 480 487 … … 499 506 int iTableIx; 500 507 501 rprintf(("pci_register_driver: query_device found %x %x:%x class=%x checking %s", 502 ulLast, pcidev->vendor, pcidev->device, pcidev->_class, driver->name)); 508 rprintf((__func__": query_device found %x %04x:%04x class=%x checking %s", 509 ulLast, pcidev->vendor, pcidev->device, pcidev->class, driver->name)); 510 511 usVendor = 0; 512 usDevice = 0; 503 513 504 514 for( iTableIx = 0; driver->id_table[iTableIx].vendor; iTableIx++) … … 506 516 struct pci_device_id const *pDriverId = &driver->id_table[iTableIx]; 507 517 508 if ( (pDriverId->class) && ((pcidev-> _class & pDriverId->class_mask) != pDriverId->class) ) continue;518 if ( (pDriverId->class) && ((pcidev->class & pDriverId->class_mask) != pDriverId->class) ) continue; 509 519 if (pDriverId->vendor != pcidev->vendor) continue; 510 520 if ( (pDriverId->device != PCI_ANY_ID) && (pDriverId->device != pcidev->device) ) continue; 511 521 512 rprintf(("pci_register_driver: matched %d %x:%x/%x with %x:%x/%x %x (%s)", iTableIx, 513 pcidev->vendor, pcidev->device, pcidev->_class, 522 /* skip a duplicate device that could be matched by both and exact match and a class match */ 523 if (usVendor == pcidev->vendor && usDevice == pcidev->device) continue; 524 usVendor = pcidev->vendor; 525 usDevice = pcidev->device; 526 527 rprintf((__func__": matched %d %x:%x/%x with %x:%x/%x %x (%s)", iTableIx, 528 pcidev->vendor, pcidev->device, pcidev->class, 514 529 pDriverId->vendor, pDriverId->device, pDriverId->class, pDriverId->class_mask, driver->name)); 515 530 516 531 if ((iAdapterNumber >= 0) && (iAdapter < iAdapterNumber)) 517 532 { 533 rprintf((__func__": AdapterNumber=%x skipping Adapter=%x", iAdapterNumber, iAdapter)); 518 534 iAdapter++; 519 535 continue; 520 536 } 521 537 522 RMInit();523 538 if (driver->probe(pcidev, pDriverId) == 0) 524 539 { … … 527 542 528 543 // create adapter 529 RMDone((pcidev->device << 16) | pcidev->vendor, &pcidev->hAdapter, &pcidev->hDevice); 544 RMCreateAdapterU32((pcidev->device << 16) | pcidev->vendor, &pcidev->hAdapter, ulLast, iNumCards); 545 530 546 iNumCards++; 531 547 pcidev = NULL; /* we need a new slot */ 532 548 break; 533 549 } 534 RMDone(0, 0, 0); 550 // release resources which were possibly allocated during probe() 551 RMDeallocRes(); 535 552 } /* for id_table loop */ 536 553 … … 647 664 //try not to exhaust low memory (< 16mb) so allocate from the high region first 648 665 //if that doesn't satisfy the dma mask requirement, then get it from the low 649 //regi noanyway666 //region anyway 650 667 if(hwdev->dma_mask > 0x00ffffff) { 651 668 order = __compat_get_order(size); … … 666 683 ret = (void *)__get_free_pages(gfp, __compat_get_order(size)); 667 684 } 668 669 685 if (ret != NULL) { 670 686 memset(ret, 0, size); … … 672 688 } 673 689 return ret; 690 } 691 692 #if 0 693 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, 694 dma_addr_t *dma_handle) 695 { 696 return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC); 697 } 698 #endif 699 #if 0 700 void *dma_alloc_coherent(struct device *dev, size_t size, 701 dma_addr_t *dma_handle, gfp_t gfp) 702 { 703 void *ret = NULL; 704 int order; 705 706 dprintf(("dma_alloc_coherent %d mask %x", size, (dev) ? dev->dma_mask : 0)); 707 if (dev == NULL || *dev->dma_mask != 0xffffffff) { 708 dprintf(("dma_alloc_coherent")); 709 //try not to exhaust low memory (< 16mb) so allocate from the high region first 710 //if that doesn't satisfy the dma mask requirement, then get it from the low 711 //region anyway 712 if(*dev->dma_mask > 0x00ffffff) { 713 dprintf(("dma_alloc_coherent2")); 714 order = __compat_get_order(size); 715 ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order); 716 *dma_handle = virt_to_bus(ret); 717 if(*dma_handle > *dev->dma_mask) { 718 dprintf(("dma_alloc_coherent3")); 719 free_pages((unsigned long)ret, __compat_get_order(size)); 720 //be sure and allocate below 16 mb 721 gfp |= GFP_DMA; 722 ret = NULL; 723 } 724 dprintf(("dma_alloc_coherent3a")); 725 } 726 else { //must always allocate below 16 mb 727 dprintf(("dma_alloc_coherent4")); 728 gfp |= GFP_DMA; 729 } 730 } 731 if(ret == NULL) { 732 dprintf(("dma_alloc_coherent5")); 733 ret = (void *)__get_free_pages(gfp, __compat_get_order(size)); 734 } 735 736 if (ret != NULL) { 737 memset(ret, 0, size); 738 *dma_handle = virt_to_bus(ret); 739 } 740 return ret; 741 742 } 743 #endif 744 745 int dma_supported(struct device *dev, u64 mask) 746 { 747 return 1; 748 } 749 750 int dma_set_coherent_mask(struct device *dev, u64 mask) 751 { 752 /* 753 * Truncate the mask to the actually supported dma_addr_t width to 754 * avoid generating unsupportable addresses. 755 */ 756 mask = (dma_addr_t)mask; 757 758 if (!dma_supported(dev, mask)) 759 return -EIO; 760 761 dev->coherent_dma_mask = mask; 762 return 0; 763 } 764 765 int dma_set_mask(struct device *dev, u64 mask) 766 { 767 /* 768 * Truncate the mask to the actually supported dma_addr_t width to 769 * avoid generating unsupportable addresses. 770 */ 771 mask = (dma_addr_t)mask; 772 773 if (!dev->dma_mask || !dma_supported(dev, mask)) 774 return -EIO; 775 776 *dev->dma_mask = mask; 777 return 0; 674 778 } 675 779 … … 888 992 } 889 993 890 const struct pci_device_id * pci_match_ device(const struct pci_device_id *ids, struct pci_dev *dev)994 const struct pci_device_id * pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev) 891 995 { 892 996 u16 subsystem_vendor, subsystem_device; … … 900 1004 (ids->subvendor == PCI_ANY_ID || ids->subvendor == subsystem_vendor) && 901 1005 (ids->subdevice == PCI_ANY_ID || ids->subdevice == subsystem_device) && 902 !((ids->class ^ dev-> _class) & ids->class_mask))1006 !((ids->class ^ dev->class) & ids->class_mask)) 903 1007 return ids; 904 1008 ids++; … … 981 1085 if(pci_devices[i].devfn) 982 1086 { 983 RMSetHandles(pci_devices[i].hAdapter , pci_devices[i].hDevice); /* DAZ - dirty hack */1087 RMSetHandles(pci_devices[i].hAdapter); /* DAZ - dirty hack */ 984 1088 driver = pci_devices[i].pcidriver; 985 1089 if(driver && driver->resume) { … … 1004 1108 if(pci_devices[i].devfn) 1005 1109 { 1006 RMSetHandles(pci_devices[i].hAdapter , pci_devices[i].hDevice); /* DAZ - dirty hack */1110 RMSetHandles(pci_devices[i].hAdapter); /* DAZ - dirty hack */ 1007 1111 driver = pci_devices[i].pcidriver; 1008 1112 if(driver && driver->suspend) { … … 1040 1144 #endif 1041 1145 1146 /** 1147 * pci_status_get_and_clear_errors - return and clear error bits in PCI_STATUS 1148 * @pdev: the PCI device 1149 * 1150 * Returns error bits set in PCI_STATUS and clears them. 1151 */ 1152 int pci_status_get_and_clear_errors(struct pci_dev *pdev) 1153 { 1154 u16 status; 1155 int ret; 1156 1157 ret = pci_read_config_word(pdev, PCI_STATUS, &status); 1158 if (ret != PCIBIOS_SUCCESSFUL) 1159 return -EIO; 1160 1161 status &= PCI_STATUS_ERROR_BITS; 1162 if (status) 1163 pci_write_config_word(pdev, PCI_STATUS, status); 1164 1165 return status; 1166 } 1167
Note:
See TracChangeset
for help on using the changeset viewer.