@@ -850,6 +850,66 @@ struct resource *pci_find_resource(struct pci_dev *dev, struct resource *res)
850
850
}
851
851
EXPORT_SYMBOL (pci_find_resource );
852
852
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
+
853
913
/**
854
914
* pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
855
915
* @dev: the PCI device to operate on
@@ -3290,6 +3350,7 @@ static struct resource *pci_ea_get_resource(struct pci_dev *dev, u8 bei,
3290
3350
static int pci_ea_read (struct pci_dev * dev , int offset )
3291
3351
{
3292
3352
struct resource * res ;
3353
+ const char * res_name ;
3293
3354
int ent_size , ent_offset = offset ;
3294
3355
resource_size_t start , end ;
3295
3356
unsigned long flags ;
@@ -3319,6 +3380,7 @@ static int pci_ea_read(struct pci_dev *dev, int offset)
3319
3380
goto out ;
3320
3381
3321
3382
res = pci_ea_get_resource (dev , bei , prop );
3383
+ res_name = pci_resource_name (dev , bei );
3322
3384
if (!res ) {
3323
3385
pci_err (dev , "Unsupported EA entry BEI: %u\n" , bei );
3324
3386
goto out ;
@@ -3392,16 +3454,16 @@ static int pci_ea_read(struct pci_dev *dev, int offset)
3392
3454
res -> flags = flags ;
3393
3455
3394
3456
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 );
3397
3459
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 );
3400
3462
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 );
3403
3465
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" ,
3405
3467
bei , res , prop );
3406
3468
3407
3469
out :
@@ -6689,14 +6751,15 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
6689
6751
resource_size_t align , bool resize )
6690
6752
{
6691
6753
struct resource * r = & dev -> resource [bar ];
6754
+ const char * r_name = pci_resource_name (dev , bar );
6692
6755
resource_size_t size ;
6693
6756
6694
6757
if (!(r -> flags & IORESOURCE_MEM ))
6695
6758
return ;
6696
6759
6697
6760
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 );
6700
6763
return ;
6701
6764
}
6702
6765
@@ -6732,8 +6795,8 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
6732
6795
* devices and we use the second.
6733
6796
*/
6734
6797
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 );
6737
6800
6738
6801
if (resize ) {
6739
6802
r -> start = 0 ;
0 commit comments