Skip to content

Commit 2a7275a

Browse files
Ley Foon Tanbjorn-helgaas
authored andcommitted
PCI: altera: Fix TLP_CFG_DW0 for TLP write
eb57671 ("PCI: altera: Simplify TLB_CFG_DW0 usage") used TLP_FMTTYPE_CFGRD* (instead of TLP_FMTTYPE_CFGWR*) for TLP writes, which causes writing to configuration space to fail. Fix it by using correct FMTTYPE for write operation. Fixes: eb57671 ("PCI: altera: Simplify TLB_CFG_DW0 usage") Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> CC: stable@vger.kernel.org # v4.9+
1 parent c046406 commit 2a7275a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/pci/host/pcie-altera.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@
5757
#define TLP_WRITE_TAG 0x10
5858
#define RP_DEVFN 0
5959
#define TLP_REQ_ID(bus, devfn) (((bus) << 8) | (devfn))
60-
#define TLP_CFG_DW0(pcie, bus) \
60+
#define TLP_CFGRD_DW0(pcie, bus) \
6161
((((bus == pcie->root_bus_nr) ? TLP_FMTTYPE_CFGRD0 \
6262
: TLP_FMTTYPE_CFGRD1) << 24) | \
6363
TLP_PAYLOAD_SIZE)
64+
#define TLP_CFGWR_DW0(pcie, bus) \
65+
((((bus == pcie->root_bus_nr) ? TLP_FMTTYPE_CFGWR0 \
66+
: TLP_FMTTYPE_CFGWR1) << 24) | \
67+
TLP_PAYLOAD_SIZE)
6468
#define TLP_CFG_DW1(pcie, tag, be) \
6569
(((TLP_REQ_ID(pcie->root_bus_nr, RP_DEVFN)) << 16) | (tag << 8) | (be))
6670
#define TLP_CFG_DW2(bus, devfn, offset) \
@@ -222,7 +226,7 @@ static int tlp_cfg_dword_read(struct altera_pcie *pcie, u8 bus, u32 devfn,
222226
{
223227
u32 headers[TLP_HDR_SIZE];
224228

225-
headers[0] = TLP_CFG_DW0(pcie, bus);
229+
headers[0] = TLP_CFGRD_DW0(pcie, bus);
226230
headers[1] = TLP_CFG_DW1(pcie, TLP_READ_TAG, byte_en);
227231
headers[2] = TLP_CFG_DW2(bus, devfn, where);
228232

@@ -237,7 +241,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn,
237241
u32 headers[TLP_HDR_SIZE];
238242
int ret;
239243

240-
headers[0] = TLP_CFG_DW0(pcie, bus);
244+
headers[0] = TLP_CFGWR_DW0(pcie, bus);
241245
headers[1] = TLP_CFG_DW1(pcie, TLP_WRITE_TAG, byte_en);
242246
headers[2] = TLP_CFG_DW2(bus, devfn, where);
243247

0 commit comments

Comments
 (0)