Skip to contentSkip to conversation

pci: Handle 5-bit and 8-bit tag field

PATCH In review Pierre Moreau 3 participants 5 messages Sep 16, 2015 – Oct 3, 2015 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 pci: Handle 5-bit and 8-bit tag field

If the hardware supports extended tag field (8-bit ones), then enabled it. This is usually done by the VBIOS, but not on some MBPs (see fdo#86537). In case extended tag field is not supported, 5-bit tag field is used which limits the possible values to 32. Apparently bits 7:0 of 0x8841c stores some number of outstanding requests, so cap it to 32 if extended tag is unsupported.

Fixes fdo#86537

v2: Restrict changes to chipsets >= 0x84
v3:
* Add nvkm_pci_mask to pci.h
* Mask bit 8 before setting it

---
 drm/nouveau/include/nvkm/subdev/pci.h |  1 +
 drm/nouveau/nvkm/subdev/pci/base.c    | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
drm/nouveau/include/nvkm/subdev/pci.h +1 -0
index 5b3c054..774ca66 100644
@@ -24,6 +24,7 @@ struct nvkm_pci {
 u32 nvkm_pci_rd32(struct nvkm_pci *, u16 addr);
 void nvkm_pci_wr08(struct nvkm_pci *, u16 addr, u8 data);
 void nvkm_pci_wr32(struct nvkm_pci *, u16 addr, u32 data);
+u32 nvkm_pci_mask(struct nvkm_pci *, u16 addr, u32 mask, u32 add);
 void nvkm_pci_rom_shadow(struct nvkm_pci *, bool shadow);
 
 int nv04_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
drm/nouveau/nvkm/subdev/pci/base.c +25 -0
index d1c148e..cb2835b 100644
@@ -46,6 +46,14 @@ nvkm_pci_wr32(struct nvkm_pci *pci, u16 addr, u32 data)
 	pci->func->wr32(pci, addr, data);
 }
 
+u32
+nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32 add)
+{
+	u32 data = pci->func->rd32(pci, addr);
+	pci->func->wr32(pci, addr, (data & ~mask) | add);
+	return data;
+}
+
 void
 nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow)
 {
@@ -115,6 +123,23 @@ nvkm_pci_init(struct nvkm_subdev *subdev)
 	if (ret)
 		return ret;
 
+	if (pci_is_pcie(pdev) && subdev->device->chipset >= 0x84) {
+		/* Tag field is 8-bit long, regardless of EXT_TAG.
+		 * However, if EXT_TAG is disabled, only the lower 5 bits of the tag
+		 * field should be used, limiting the number of request to 32.
+		 *
+		 * Apparently, 0x041c stores some limit on the number of requests
+		 * possible, so if EXT_TAG is disabled, limit that requests number to
+		 * 32
+		 *
+		 * Fixes fdo#86537
+		 */
+		if (nvkm_pci_rd32(pci, 0x007c) & 0x00000020)
+			nvkm_pci_mask(pci, 0x0080, 0x00000100, 0x00000100);
+		else
+			nvkm_pci_mask(pci, 0x041c, 0x00000060, 0x00000000);
+	}
+
 	pci->irq = pdev->irq;
 	return ret;
 }
Signature · 6 lines
2.5.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 1442435210-21276-1-git-send-email-pierre.morrow-GANU6spQydw@public.gmane.org

Tested-by Karol Herbst
#2 lore raw

----- Mail original -----

Quoted 10 lines

If the hardware supports extended tag field (8-bit ones), then enabled it. This
is usually done by the VBIOS, but not on some MBPs (see fdo#86537). In case extended tag field is not supported, 5-bit tag field is used which
limits the possible values to 32. Apparently bits 7:0 of 0x8841c stores some
number of outstanding requests, so cap it to 32 if extended tag is unsupported.

Quoted 8 lines
Fixes fdo#86537

v2: Restrict changes to chipsets >= 0x84
v3:
* Add nvkm_pci_mask to pci.h
* Mask bit 8 before setting it

Quoted 68 lines
---
 drm/nouveau/include/nvkm/subdev/pci.h |  1 +
 drm/nouveau/nvkm/subdev/pci/base.c    | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
drm/nouveau/include/nvkm/subdev/pci.h +1 -0
index 5b3c054..774ca66 100644
@@ -24,6 +24,7 @@ struct nvkm_pci {
 u32 nvkm_pci_rd32(struct nvkm_pci *, u16 addr);
 void nvkm_pci_wr08(struct nvkm_pci *, u16 addr, u8 data);
 void nvkm_pci_wr32(struct nvkm_pci *, u16 addr, u32 data);
+u32 nvkm_pci_mask(struct nvkm_pci *, u16 addr, u32 mask, u32 add);
 void nvkm_pci_rom_shadow(struct nvkm_pci *, bool shadow);
 
 int nv04_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
drm/nouveau/nvkm/subdev/pci/base.c +8 -0
index d1c148e..cb2835b 100644
@@ -46,6 +46,14 @@ nvkm_pci_wr32(struct nvkm_pci *pci, u16 addr, u32
 data)
 	pci->func->wr32(pci, addr, data);
 }
 
+u32
+nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32 add)
+{
+	u32 data = pci->func->rd32(pci, addr);
+	pci->func->wr32(pci, addr, (data & ~mask) | add);
+	return data;
+}
+
 void
 nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow)

{

drm/nouveau/nvkm/subdev/pci/base.c +3 -0
@@ -115,6 +123,23 @@ nvkm_pci_init(struct nvkm_subdev *subdev)
 	if (ret)
 		return ret;
 
+	if (pci_is_pcie(pdev) && subdev->device->chipset >= 0x84) {
+		/* Tag field is 8-bit long, regardless of EXT_TAG.
+		 * However, if EXT_TAG is disabled, only the lower 5 bits of the

tag

drm/nouveau/nvkm/subdev/pci/base.c +4 -0
+		 * field should be used, limiting the number of request to 32.
+		 *
+		 * Apparently, 0x041c stores some limit on the number of requests
+		 * possible, so if EXT_TAG is disabled, limit that requests number

to

drm/nouveau/nvkm/subdev/pci/base.c +10 -1
+		 * 32
+		 *
+		 * Fixes fdo#86537
+		 */
+		if (nvkm_pci_rd32(pci, 0x007c) & 0x00000020)
+			nvkm_pci_mask(pci, 0x0080, 0x00000100, 0x00000100);
+		else
+			nvkm_pci_mask(pci, 0x041c, 0x00000060, 0x00000000);
+	}
+
 	pci->irq = pdev->irq;
 	return ret;
 }
--

2.5.2

Quoted 5 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#3 lore raw

PATCH v4 1/1 pci: Handle 5-bit and 8-bit tag field

In reply to a message not in the archive

If the hardware supports extended tag field (8-bit ones), then enabled it. This is usually done by the VBIOS, but not on some MBPs (see fdo#86537). In case extended tag field is not supported, 5-bit tag field is used which limits the possible values to 32. Apparently bits 7:0 of 0x8841c stores some number of outstanding requests, so cap it to 32 if extended tag is unsupported.

Fixes fdo#86537

v2: Restrict changes to chipsets >= 0x84
v3:
* Add nvkm_pci_mask to pci.h
* Mask bit 8 before setting it
v4:
* Rename add argument of nvkm_pci_mask to value
* Move code from nvkm_pci_init to g84_pci_init and remove PCIe and chipset checks

---
 drm/nouveau/include/nvkm/subdev/pci.h |  4 +++
 drm/nouveau/nvkm/engine/device/base.c | 64 +++++++++++++++++------------------
 drm/nouveau/nvkm/subdev/pci/Kbuild    |  1 +
 drm/nouveau/nvkm/subdev/pci/base.c    | 43 ++++++++++++++++++++---
 drm/nouveau/nvkm/subdev/pci/g84.c     | 55 ++++++++++++++++++++++++++++++
 drm/nouveau/nvkm/subdev/pci/gf100.c   |  6 ++++
 drm/nouveau/nvkm/subdev/pci/nv40.c    |  6 ++++
 drm/nouveau/nvkm/subdev/pci/nv50.c    |  6 ++++
 drm/nouveau/nvkm/subdev/pci/priv.h    | 11 ++++++
 9 files changed, 159 insertions(+), 37 deletions(-)
 create mode 100644 drm/nouveau/nvkm/subdev/pci/g84.c
drm/nouveau/include/nvkm/subdev/pci.h +4 -0
index 5b3c054..ab79fd0 100644
@@ -24,11 +24,15 @@ struct nvkm_pci {
 u32 nvkm_pci_rd32(struct nvkm_pci *, u16 addr);
 void nvkm_pci_wr08(struct nvkm_pci *, u16 addr, u8 data);
 void nvkm_pci_wr32(struct nvkm_pci *, u16 addr, u32 data);
+u32 nvkm_pci_mask(struct nvkm_pci *, u16 addr, u32 mask, u32 value);
 void nvkm_pci_rom_shadow(struct nvkm_pci *, bool shadow);
 
 int nv04_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int nv40_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
+int nv40_pci_new_g84_init(struct nvkm_device *, int, struct nvkm_pci **);
 int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int nv50_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
+int nv50_pci_new_g84_init(struct nvkm_device *, int, struct nvkm_pci **);
 int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
+int gf100_pci_new_g84_init(struct nvkm_device *, int, struct nvkm_pci **);
 #endif
drm/nouveau/nvkm/engine/device/base.c +32 -32

256 lines not on this page · raw message

drm/nouveau/nvkm/subdev/pci/Kbuild +1 -0
index 99672c3..57652f5 100644
@@ -4,4 +4,5 @@ nvkm-y += nvkm/subdev/pci/nv04.o
 nvkm-y += nvkm/subdev/pci/nv40.o
 nvkm-y += nvkm/subdev/pci/nv4c.o
 nvkm-y += nvkm/subdev/pci/nv50.o
+nvkm-y += nvkm/subdev/pci/g84.o
 nvkm-y += nvkm/subdev/pci/gf100.o
drm/nouveau/nvkm/subdev/pci/base.c +38 -5

87 lines not on this page · raw message

drm/nouveau/nvkm/subdev/pci/g84.c new file +55 -0

55 lines not on this page · raw message

drm/nouveau/nvkm/subdev/pci/gf100.c +6 -0
index 86f8226..a836d5f 100644
@@ -42,3 +42,9 @@ gf100_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
 {
 	return nvkm_pci_new_(&gf100_pci_func, device, index, ppci);
 }
+
+int
+gf100_pci_new_g84_init(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
+{
+	return nvkm_pci_new(&g84_pci_func, &gf100_pci_func, device, index, ppci);
+}
drm/nouveau/nvkm/subdev/pci/nv40.c +6 -0
index 090a187..5e2ef13 100644
@@ -63,3 +63,9 @@ nv40_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
 {
 	return nvkm_pci_new_(&nv40_pci_func, device, index, ppci);
 }
+
+int
+nv40_pci_new_g84_init(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
+{
+	return nvkm_pci_new(&g84_pci_func, &nv40_pci_func, device, index, ppci);
+}
drm/nouveau/nvkm/subdev/pci/nv50.c +6 -0
index 3e167d4..998453e 100644
@@ -49,3 +49,9 @@ nv50_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
 {
 	return nvkm_pci_new_(&nv50_pci_func, device, index, ppci);
 }
+
+int
+nv50_pci_new_g84_init(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
+{
+	return nvkm_pci_new(&g84_pci_func, &nv50_pci_func, device, index, ppci);
+}
drm/nouveau/nvkm/subdev/pci/priv.h +11 -0
index d22c2c1..9615ae0 100644
@@ -3,8 +3,17 @@
 #define nvkm_pci(p) container_of((p), struct nvkm_pci, subdev)
 #include <subdev/pci.h>
 
+
+
+int nvkm_pci_fini(struct nvkm_subdev *subdev, bool suspend);
+int nvkm_pci_preinit(struct nvkm_subdev *subdev);
+int nvkm_pci_init(struct nvkm_subdev *subdev);
+void * nvkm_pci_dtor(struct nvkm_subdev *subdev);
 int nvkm_pci_new_(const struct nvkm_pci_func *, struct nvkm_device *,
 		  int index, struct nvkm_pci **);
+int nvkm_pci_new(const struct nvkm_subdev_func *,
+		 const struct nvkm_pci_func *, struct nvkm_device *,
+		 int index, struct nvkm_pci **);
 
 struct nvkm_pci_func {
 	u32 (*rd32)(struct nvkm_pci *, u16 addr);
@@ -13,6 +22,8 @@ struct nvkm_pci_func {
 	void (*msi_rearm)(struct nvkm_pci *);
 };
 
+extern const struct nvkm_subdev_func g84_pci_func;
+
 u32 nv40_pci_rd32(struct nvkm_pci *, u16);
 void nv40_pci_wr08(struct nvkm_pci *, u16, u8);
 void nv40_pci_wr32(struct nvkm_pci *, u16, u32);
Signature · 6 lines
2.5.3

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#4 lore raw

PATCH v5 1/1 pci: Handle 5-bit and 8-bit tag field

In reply to a message not in the archive

If the hardware supports extended tag field (8-bit ones), then enable it. This is usually done by the VBIOS, but not on some MBPs (see fdo#86537). In case extended tag field is not supported, 5-bit tag field is used which limits the possible number of requests to 32. Apparently bits 7:0 of 0x08841c stores some number of outstanding requests, so cap it to 32 if extended tag is unsupported.

Fixes fdo#86537

v2: Restrict changes to chipsets >= 0x84
v3:
* Add nvkm_pci_mask to pci.h
* Mask bit 8 before setting it
v4:
* Rename add argument of nvkm_pci_mask to value
* Move code from nvkm_pci_init to g84_pci_init and remove PCIe and chipset checks
v5:
* Rebase code on latest PCI structure
* Restore PCIe check
* Fix namings in nvkm_pci_mask
* Rephrase part of the commit message

---
 drm/nouveau/include/nvkm/subdev/pci.h |  1 +
 drm/nouveau/nvkm/subdev/pci/base.c    |  8 ++++++++
 drm/nouveau/nvkm/subdev/pci/g84.c     | 24 ++++++++++++++++++++++++
 drm/nouveau/nvkm/subdev/pci/g94.c     |  1 +
 drm/nouveau/nvkm/subdev/pci/gf100.c   |  1 +
 drm/nouveau/nvkm/subdev/pci/priv.h    |  2 ++
 6 files changed, 37 insertions(+)
drm/nouveau/include/nvkm/subdev/pci.h +1 -0
index 39ca88f..fee0a97 100644
@@ -24,6 +24,7 @@ struct nvkm_pci {
 u32 nvkm_pci_rd32(struct nvkm_pci *, u16 addr);
 void nvkm_pci_wr08(struct nvkm_pci *, u16 addr, u8 data);
 void nvkm_pci_wr32(struct nvkm_pci *, u16 addr, u32 data);
+u32 nvkm_pci_mask(struct nvkm_pci *, u16 addr, u32 mask, u32 value);
 void nvkm_pci_rom_shadow(struct nvkm_pci *, bool shadow);
 
 int nv04_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
drm/nouveau/nvkm/subdev/pci/base.c +8 -0
index 2110622..d671dcf 100644
@@ -46,6 +46,14 @@ nvkm_pci_wr32(struct nvkm_pci *pci, u16 addr, u32 data)
 	pci->func->wr32(pci, addr, data);
 }
 
+u32
+nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32 value)
+{
+	u32 data = pci->func->rd32(pci, addr);
+	pci->func->wr32(pci, addr, (data & ~mask) | value);
+	return data;
+}
+
 void
 nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow)
 {
drm/nouveau/nvkm/subdev/pci/g84.c +24 -0
index 8f3b001..3faa6bf 100644
@@ -25,8 +25,32 @@
 
 #include <core/pci.h>
 
+void
+g84_pci_init(struct nvkm_pci *pci)
+{
+	/* The following only concerns PCIe cards. */
+	if (!pci_is_pcie(pci->pdev))
+		return;
+
+	/* Tag field is 8-bit long, regardless of EXT_TAG.
+	 * However, if EXT_TAG is disabled, only the lower 5 bits of the tag
+	 * field should be used, limiting the number of request to 32.
+	 *
+	 * Apparently, 0x041c stores some limit on the number of requests
+	 * possible, so if EXT_TAG is disabled, limit that requests number to
+	 * 32
+	 *
+	 * Fixes fdo#86537
+	 */
+	if (nvkm_pci_rd32(pci, 0x007c) & 0x00000020)
+		nvkm_pci_mask(pci, 0x0080, 0x00000100, 0x00000100);
+	else
+		nvkm_pci_mask(pci, 0x041c, 0x00000060, 0x00000000);
+}
+
 static const struct nvkm_pci_func
 g84_pci_func = {
+	.init = g84_pci_init,
 	.rd32 = nv40_pci_rd32,
 	.wr08 = nv40_pci_wr08,
 	.wr32 = nv40_pci_wr32,
drm/nouveau/nvkm/subdev/pci/g94.c +1 -0
index 1714421..cd311ee 100644
@@ -25,6 +25,7 @@
 
 static const struct nvkm_pci_func
 g94_pci_func = {
+	.init = g84_pci_init,
 	.rd32 = nv40_pci_rd32,
 	.wr08 = nv40_pci_wr08,
 	.wr32 = nv40_pci_wr32,
drm/nouveau/nvkm/subdev/pci/gf100.c +1 -0
index 86f8226..25e1ae7 100644
@@ -31,6 +31,7 @@ gf100_pci_msi_rearm(struct nvkm_pci *pci)
 
 static const struct nvkm_pci_func
 gf100_pci_func = {
+	.init = g84_pci_init,
 	.rd32 = nv40_pci_rd32,
 	.wr08 = nv40_pci_wr08,
 	.wr32 = nv40_pci_wr32,
drm/nouveau/nvkm/subdev/pci/priv.h +2 -0
index 1acd4bc..cf46d38 100644
@@ -20,4 +20,6 @@ void nv40_pci_wr32(struct nvkm_pci *, u16, u32);
 void nv40_pci_msi_rearm(struct nvkm_pci *);
 
 void nv46_pci_msi_rearm(struct nvkm_pci *);
+
+void g84_pci_init(struct nvkm_pci *pci);
 #endif
Signature · 6 lines
2.6.0

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
#5 lore raw
In reply to Pierre Moreau
Quoted 44 lines · Pierre Moreau

If the hardware supports extended tag field (8-bit ones), then enabled it. This is usually done by the VBIOS, but not on some MBPs (see fdo#86537). In case extended tag field is not supported, 5-bit tag field is used which limits the possible values to 32. Apparently bits 7:0 of 0x8841c stores some number of outstanding requests, so cap it to 32 if extended tag is unsupported.

Fixes fdo#86537

v2: Restrict changes to chipsets >= 0x84 v3: * Add nvkm_pci_mask to pci.h * Mask bit 8 before setting it

drm/nouveau/include/nvkm/subdev/pci.h | 1 +
drm/nouveau/nvkm/subdev/pci/base.c | 25
+++++++++++++++++++++++++ 2 files changed, 26 insertions(+)

(quoted diff) +0 -0

b/drm/nouveau/include/nvkm/subdev/pci.h index 5b3c054..774ca66 100644 --- a/drm/nouveau/include/nvkm/subdev/pci.h +++ b/drm/nouveau/include/nvkm/subdev/pci.h @@ -24,6 +24,7 @@ struct nvkm_pci { u32 nvkm_pci_rd32(struct nvkm_pci *, u16 addr); void nvkm_pci_wr08(struct nvkm_pci *, u16 addr, u8 data); void nvkm_pci_wr32(struct nvkm_pci *, u16 addr, u32 data); +u32 nvkm_pci_mask(struct nvkm_pci *, u16 addr, u32 mask, u32 add); void nvkm_pci_rom_shadow(struct nvkm_pci *, bool shadow);

int nv04_pci_new(struct nvkm_device *, int, struct nvkm_pci **);

(quoted diff) +0 -0

b/drm/nouveau/nvkm/subdev/pci/base.c index d1c148e..cb2835b 100644 --- a/drm/nouveau/nvkm/subdev/pci/base.c +++ b/drm/nouveau/nvkm/subdev/pci/base.c @@ -46,6 +46,14 @@ nvkm_pci_wr32(struct nvkm_pci *pci, u16 addr, u32 data) pci->func->wr32(pci, addr, data); }

+u32 +nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32
add) +{ + u32 data = pci->func->rd32(pci, addr); +
pci->func->wr32(pci, addr, (data & ~mask) | add); + return data;

(quoted diff) +2 -0
+} + void nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow) { 
@@ -115,6 +123,23 @@ nvkm_pci_init(struct nvkm_subdev *subdev) if
 (ret) return ret;
 
+	if (pci_is_pcie(pdev) && subdev->device->chipset >= 0x84) { +		/*

Tag field is 8-bit long, regardless of EXT_TAG. + * However, if

Quoted 8 lines

EXT_TAG is disabled, only the lower 5 bits of the tag + * field
should be used, limiting the number of request to 32. + * + *
Apparently, 0x041c stores some limit on the number of requests +
* possible, so if EXT_TAG is disabled, limit that requests number
to + * 32 + * + * Fixes fdo#86537 + */ + if
(nvkm_pci_rd32(pci, 0x007c) & 0x00000020) + nvkm_pci_mask(pci,
0x0080, 0x00000100, 0x00000100); + else + nvkm_pci_mask(pci,
0x041c, 0x00000060, 0x00000000); + }

Please introduce a .init() to nvkm_pci_func(), and implement a g84.c that handles this (gf100.c can use g84_pci_init() from there).

The check for PCI-E is redundant too, all these boards are PCI-E.

Other than the above nit-picking, looks fine.

Thanks,
Ben.

Quoted 2 lines

+ pci->irq = pdev->irq; return ret; }

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel