Skip to content

Commit cef498a

Browse files
sumitsemwalgregkh
authored andcommitted
PCI: Remove pci_resource_bar() and pci_iov_resource_bar()
From: Bjorn Helgaas <bhelgaas@google.com> [ Upstream commit 286c2378aaccc7343ebf17ec6cd86567659caf70 ] pci_std_update_resource() only deals with standard BARs, so we don't have to worry about the complications of VF BARs in an SR-IOV capability. Compute the BAR address inline and remove pci_resource_bar(). That makes pci_iov_resource_bar() unused, so remove that as well. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a87693e commit cef498a

4 files changed

Lines changed: 7 additions & 60 deletions

File tree

drivers/pci/iov.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -554,24 +554,6 @@ void pci_iov_release(struct pci_dev *dev)
554554
sriov_release(dev);
555555
}
556556

557-
/**
558-
* pci_iov_resource_bar - get position of the SR-IOV BAR
559-
* @dev: the PCI device
560-
* @resno: the resource number
561-
*
562-
* Returns position of the BAR encapsulated in the SR-IOV capability.
563-
*/
564-
int pci_iov_resource_bar(struct pci_dev *dev, int resno)
565-
{
566-
if (resno < PCI_IOV_RESOURCES || resno > PCI_IOV_RESOURCE_END)
567-
return 0;
568-
569-
BUG_ON(!dev->is_physfn);
570-
571-
return dev->sriov->pos + PCI_SRIOV_BAR +
572-
4 * (resno - PCI_IOV_RESOURCES);
573-
}
574-
575557
/**
576558
* pci_iov_update_resource - update a VF BAR
577559
* @dev: the PCI device

drivers/pci/pci.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4472,36 +4472,6 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
44724472
}
44734473
EXPORT_SYMBOL(pci_select_bars);
44744474

4475-
/**
4476-
* pci_resource_bar - get position of the BAR associated with a resource
4477-
* @dev: the PCI device
4478-
* @resno: the resource number
4479-
* @type: the BAR type to be filled in
4480-
*
4481-
* Returns BAR position in config space, or 0 if the BAR is invalid.
4482-
*/
4483-
int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
4484-
{
4485-
int reg;
4486-
4487-
if (resno < PCI_ROM_RESOURCE) {
4488-
*type = pci_bar_unknown;
4489-
return PCI_BASE_ADDRESS_0 + 4 * resno;
4490-
} else if (resno == PCI_ROM_RESOURCE) {
4491-
*type = pci_bar_mem32;
4492-
return dev->rom_base_reg;
4493-
} else if (resno < PCI_BRIDGE_RESOURCES) {
4494-
/* device specific resource */
4495-
*type = pci_bar_unknown;
4496-
reg = pci_iov_resource_bar(dev, resno);
4497-
if (reg)
4498-
return reg;
4499-
}
4500-
4501-
dev_err(&dev->dev, "BAR %d: invalid resource\n", resno);
4502-
return 0;
4503-
}
4504-
45054475
/* Some architectures require additional programming to enable VGA */
45064476
static arch_set_vga_state_t arch_set_vga_state;
45074477

drivers/pci/pci.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl,
232232
int pci_setup_device(struct pci_dev *dev);
233233
int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
234234
struct resource *res, unsigned int reg);
235-
int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type);
236235
void pci_configure_ari(struct pci_dev *dev);
237236
void __pci_bus_size_bridges(struct pci_bus *bus,
238237
struct list_head *realloc_head);
@@ -276,7 +275,6 @@ static inline void pci_restore_ats_state(struct pci_dev *dev)
276275
#ifdef CONFIG_PCI_IOV
277276
int pci_iov_init(struct pci_dev *dev);
278277
void pci_iov_release(struct pci_dev *dev);
279-
int pci_iov_resource_bar(struct pci_dev *dev, int resno);
280278
void pci_iov_update_resource(struct pci_dev *dev, int resno);
281279
resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
282280
void pci_restore_iov_state(struct pci_dev *dev);
@@ -291,10 +289,6 @@ static inline void pci_iov_release(struct pci_dev *dev)
291289

292290
{
293291
}
294-
static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno)
295-
{
296-
return 0;
297-
}
298292
static inline void pci_restore_iov_state(struct pci_dev *dev)
299293
{
300294
}

drivers/pci/setup-res.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
3232
u16 cmd;
3333
u32 new, check, mask;
3434
int reg;
35-
enum pci_bar_type type;
3635
struct resource *res = dev->resource + resno;
3736

3837
if (dev->is_virtfn) {
@@ -66,14 +65,16 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
6665
else
6766
mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
6867

69-
reg = pci_resource_bar(dev, resno, &type);
70-
if (!reg)
71-
return;
72-
if (type != pci_bar_unknown) {
68+
if (resno < PCI_ROM_RESOURCE) {
69+
reg = PCI_BASE_ADDRESS_0 + 4 * resno;
70+
} else if (resno == PCI_ROM_RESOURCE) {
7371
if (!(res->flags & IORESOURCE_ROM_ENABLE))
7472
return;
73+
74+
reg = dev->rom_base_reg;
7575
new |= PCI_ROM_ADDRESS_ENABLE;
76-
}
76+
} else
77+
return;
7778

7879
/*
7980
* We can't update a 64-bit BAR atomically, so when possible,

0 commit comments

Comments
 (0)