@@ -850,6 +850,66 @@ struct resource *pci_find_resource(struct pci_dev *dev, struct resource *res)
850850}
851851EXPORT_SYMBOL (pci_find_resource );
852852
853+ /**
854+ * pci_resource_name - Return the name of the PCI resource
855+ * @dev: PCI device to query
856+ * @i: index of the resource
857+ *
858+ * Return the standard PCI resource (BAR) name according to their index.
859+ */
860+ const char * pci_resource_name (struct pci_dev * dev , unsigned int i )
861+ {
862+ static const char * const bar_name [] = {
863+ "BAR 0" ,
864+ "BAR 1" ,
865+ "BAR 2" ,
866+ "BAR 3" ,
867+ "BAR 4" ,
868+ "BAR 5" ,
869+ "ROM" ,
870+ #ifdef CONFIG_PCI_IOV
871+ "VF BAR 0" ,
872+ "VF BAR 1" ,
873+ "VF BAR 2" ,
874+ "VF BAR 3" ,
875+ "VF BAR 4" ,
876+ "VF BAR 5" ,
877+ #endif
878+ "bridge window" , /* "io" included in %pR */
879+ "bridge window" , /* "mem" included in %pR */
880+ "bridge window" , /* "mem pref" included in %pR */
881+ };
882+ static const char * const cardbus_name [] = {
883+ "BAR 1" ,
884+ "unknown" ,
885+ "unknown" ,
886+ "unknown" ,
887+ "unknown" ,
888+ "unknown" ,
889+ #ifdef CONFIG_PCI_IOV
890+ "unknown" ,
891+ "unknown" ,
892+ "unknown" ,
893+ "unknown" ,
894+ "unknown" ,
895+ "unknown" ,
896+ #endif
897+ "CardBus bridge window 0" , /* I/O */
898+ "CardBus bridge window 1" , /* I/O */
899+ "CardBus bridge window 0" , /* mem */
900+ "CardBus bridge window 1" , /* mem */
901+ };
902+
903+ if (dev -> hdr_type == PCI_HEADER_TYPE_CARDBUS &&
904+ i < ARRAY_SIZE (cardbus_name ))
905+ return cardbus_name [i ];
906+
907+ if (i < ARRAY_SIZE (bar_name ))
908+ return bar_name [i ];
909+
910+ return "unknown" ;
911+ }
912+
853913/**
854914 * pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
855915 * @dev: the PCI device to operate on
@@ -3290,6 +3350,7 @@ static struct resource *pci_ea_get_resource(struct pci_dev *dev, u8 bei,
32903350static int pci_ea_read (struct pci_dev * dev , int offset )
32913351{
32923352 struct resource * res ;
3353+ const char * res_name ;
32933354 int ent_size , ent_offset = offset ;
32943355 resource_size_t start , end ;
32953356 unsigned long flags ;
@@ -3319,6 +3380,7 @@ static int pci_ea_read(struct pci_dev *dev, int offset)
33193380 goto out ;
33203381
33213382 res = pci_ea_get_resource (dev , bei , prop );
3383+ res_name = pci_resource_name (dev , bei );
33223384 if (!res ) {
33233385 pci_err (dev , "Unsupported EA entry BEI: %u\n" , bei );
33243386 goto out ;
@@ -3392,16 +3454,16 @@ static int pci_ea_read(struct pci_dev *dev, int offset)
33923454 res -> flags = flags ;
33933455
33943456 if (bei <= PCI_EA_BEI_BAR5 )
3395- pci_info (dev , "BAR %d: %pR ( from Enhanced Allocation, properties %#02x) \n" ,
3396- bei , res , prop );
3457+ pci_info (dev , "%s %pR: from Enhanced Allocation, properties %#02x\n" ,
3458+ res_name , res , prop );
33973459 else if (bei == PCI_EA_BEI_ROM )
3398- pci_info (dev , "ROM: %pR ( from Enhanced Allocation, properties %#02x) \n" ,
3399- res , prop );
3460+ pci_info (dev , "%s %pR: from Enhanced Allocation, properties %#02x\n" ,
3461+ res_name , res , prop );
34003462 else if (bei >= PCI_EA_BEI_VF_BAR0 && bei <= PCI_EA_BEI_VF_BAR5 )
3401- pci_info (dev , "VF BAR %d: %pR ( from Enhanced Allocation, properties %#02x) \n" ,
3402- bei - PCI_EA_BEI_VF_BAR0 , res , prop );
3463+ pci_info (dev , "%s %pR: from Enhanced Allocation, properties %#02x\n" ,
3464+ res_name , res , prop );
34033465 else
3404- pci_info (dev , "BEI %d res: %pR ( from Enhanced Allocation, properties %#02x) \n" ,
3466+ pci_info (dev , "BEI %d %pR: from Enhanced Allocation, properties %#02x\n" ,
34053467 bei , res , prop );
34063468
34073469out :
@@ -6689,14 +6751,15 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
66896751 resource_size_t align , bool resize )
66906752{
66916753 struct resource * r = & dev -> resource [bar ];
6754+ const char * r_name = pci_resource_name (dev , bar );
66926755 resource_size_t size ;
66936756
66946757 if (!(r -> flags & IORESOURCE_MEM ))
66956758 return ;
66966759
66976760 if (r -> flags & IORESOURCE_PCI_FIXED ) {
6698- pci_info (dev , "BAR%d %pR: ignoring requested alignment %#llx\n" ,
6699- bar , r , (unsigned long long )align );
6761+ pci_info (dev , "%s %pR: ignoring requested alignment %#llx\n" ,
6762+ r_name , r , (unsigned long long )align );
67006763 return ;
67016764 }
67026765
@@ -6732,8 +6795,8 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
67326795 * devices and we use the second.
67336796 */
67346797
6735- pci_info (dev , "BAR%d %pR: requesting alignment to %#llx\n" ,
6736- bar , r , (unsigned long long )align );
6798+ pci_info (dev , "%s %pR: requesting alignment to %#llx\n" ,
6799+ r_name , r , (unsigned long long )align );
67376800
67386801 if (resize ) {
67396802 r -> start = 0 ;
0 commit comments