[PATCH AUTOSEL 5.10 8/9] drm/nouveau/dp: Don't probe eDP ports twice harder

2024-04-23 Thread Sasha Levin
From: Lyude Paul 

[ Upstream commit bf52d7f9b2067f02efe7e32697479097aba4a055 ]

I didn't pay close enough attention the last time I tried to fix this
problem - while we currently do correctly take care to make sure we don't
probe a connected eDP port more then once, we don't do the same thing for
eDP ports we found to be disconnected.

So, fix this and make sure we only ever probe eDP ports once and then leave
them at that connector state forever (since without HPD, it's not going to
change on its own anyway). This should get rid of the last few GSP errors
getting spit out during runtime suspend and resume on some machines, as we
tried to reprobe eDP ports in response to ACPI hotplug probe events.

Signed-off-by: Lyude Paul 
Reviewed-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240404233736.7946-3-ly...@redhat.com
(cherry picked from commit fe6660b661c3397af0867d5d098f5b26581f1290)
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_dp.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c 
b/drivers/gpu/drm/nouveau/nouveau_dp.c
index 447b7594b35ae..0107a21dc9f9b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -109,12 +109,15 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
u8 *dpcd = nv_encoder->dp.dpcd;
int ret = NOUVEAU_DP_NONE;
 
-   /* If we've already read the DPCD on an eDP device, we don't need to
-* reread it as it won't change
+   /* eDP ports don't support hotplugging - so there's no point in probing 
eDP ports unless we
+* haven't probed them once before.
 */
-   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
-   dpcd[DP_DPCD_REV] != 0)
-   return NOUVEAU_DP_SST;
+   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+   if (connector->status == connector_status_connected)
+   return NOUVEAU_DP_SST;
+   else if (connector->status == connector_status_disconnected)
+   return NOUVEAU_DP_NONE;
+   }
 
mutex_lock(_encoder->dp.hpd_irq_lock);
if (mstm) {
-- 
2.43.0



[PATCH AUTOSEL 5.15 8/9] drm/nouveau/dp: Don't probe eDP ports twice harder

2024-04-23 Thread Sasha Levin
From: Lyude Paul 

[ Upstream commit bf52d7f9b2067f02efe7e32697479097aba4a055 ]

I didn't pay close enough attention the last time I tried to fix this
problem - while we currently do correctly take care to make sure we don't
probe a connected eDP port more then once, we don't do the same thing for
eDP ports we found to be disconnected.

So, fix this and make sure we only ever probe eDP ports once and then leave
them at that connector state forever (since without HPD, it's not going to
change on its own anyway). This should get rid of the last few GSP errors
getting spit out during runtime suspend and resume on some machines, as we
tried to reprobe eDP ports in response to ACPI hotplug probe events.

Signed-off-by: Lyude Paul 
Reviewed-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240404233736.7946-3-ly...@redhat.com
(cherry picked from commit fe6660b661c3397af0867d5d098f5b26581f1290)
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_dp.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c 
b/drivers/gpu/drm/nouveau/nouveau_dp.c
index 447b7594b35ae..0107a21dc9f9b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -109,12 +109,15 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
u8 *dpcd = nv_encoder->dp.dpcd;
int ret = NOUVEAU_DP_NONE;
 
-   /* If we've already read the DPCD on an eDP device, we don't need to
-* reread it as it won't change
+   /* eDP ports don't support hotplugging - so there's no point in probing 
eDP ports unless we
+* haven't probed them once before.
 */
-   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
-   dpcd[DP_DPCD_REV] != 0)
-   return NOUVEAU_DP_SST;
+   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+   if (connector->status == connector_status_connected)
+   return NOUVEAU_DP_SST;
+   else if (connector->status == connector_status_disconnected)
+   return NOUVEAU_DP_NONE;
+   }
 
mutex_lock(_encoder->dp.hpd_irq_lock);
if (mstm) {
-- 
2.43.0



[PATCH AUTOSEL 6.1 8/9] drm/nouveau/dp: Don't probe eDP ports twice harder

2024-04-23 Thread Sasha Levin
From: Lyude Paul 

[ Upstream commit bf52d7f9b2067f02efe7e32697479097aba4a055 ]

I didn't pay close enough attention the last time I tried to fix this
problem - while we currently do correctly take care to make sure we don't
probe a connected eDP port more then once, we don't do the same thing for
eDP ports we found to be disconnected.

So, fix this and make sure we only ever probe eDP ports once and then leave
them at that connector state forever (since without HPD, it's not going to
change on its own anyway). This should get rid of the last few GSP errors
getting spit out during runtime suspend and resume on some machines, as we
tried to reprobe eDP ports in response to ACPI hotplug probe events.

Signed-off-by: Lyude Paul 
Reviewed-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240404233736.7946-3-ly...@redhat.com
(cherry picked from commit fe6660b661c3397af0867d5d098f5b26581f1290)
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_dp.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c 
b/drivers/gpu/drm/nouveau/nouveau_dp.c
index 53185746fb3d1..17e1e23a780e0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -109,12 +109,15 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
u8 *dpcd = nv_encoder->dp.dpcd;
int ret = NOUVEAU_DP_NONE, hpd;
 
-   /* If we've already read the DPCD on an eDP device, we don't need to
-* reread it as it won't change
+   /* eDP ports don't support hotplugging - so there's no point in probing 
eDP ports unless we
+* haven't probed them once before.
 */
-   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
-   dpcd[DP_DPCD_REV] != 0)
-   return NOUVEAU_DP_SST;
+   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+   if (connector->status == connector_status_connected)
+   return NOUVEAU_DP_SST;
+   else if (connector->status == connector_status_disconnected)
+   return NOUVEAU_DP_NONE;
+   }
 
mutex_lock(_encoder->dp.hpd_irq_lock);
if (mstm) {
-- 
2.43.0



[PATCH AUTOSEL 6.6 11/16] drm/nouveau/dp: Don't probe eDP ports twice harder

2024-04-23 Thread Sasha Levin
From: Lyude Paul 

[ Upstream commit bf52d7f9b2067f02efe7e32697479097aba4a055 ]

I didn't pay close enough attention the last time I tried to fix this
problem - while we currently do correctly take care to make sure we don't
probe a connected eDP port more then once, we don't do the same thing for
eDP ports we found to be disconnected.

So, fix this and make sure we only ever probe eDP ports once and then leave
them at that connector state forever (since without HPD, it's not going to
change on its own anyway). This should get rid of the last few GSP errors
getting spit out during runtime suspend and resume on some machines, as we
tried to reprobe eDP ports in response to ACPI hotplug probe events.

Signed-off-by: Lyude Paul 
Reviewed-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240404233736.7946-3-ly...@redhat.com
(cherry picked from commit fe6660b661c3397af0867d5d098f5b26581f1290)
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_dp.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c 
b/drivers/gpu/drm/nouveau/nouveau_dp.c
index 6a4980b2d4d4e..bf2ae67b03d94 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -108,12 +108,15 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
u8 *dpcd = nv_encoder->dp.dpcd;
int ret = NOUVEAU_DP_NONE, hpd;
 
-   /* If we've already read the DPCD on an eDP device, we don't need to
-* reread it as it won't change
+   /* eDP ports don't support hotplugging - so there's no point in probing 
eDP ports unless we
+* haven't probed them once before.
 */
-   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
-   dpcd[DP_DPCD_REV] != 0)
-   return NOUVEAU_DP_SST;
+   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+   if (connector->status == connector_status_connected)
+   return NOUVEAU_DP_SST;
+   else if (connector->status == connector_status_disconnected)
+   return NOUVEAU_DP_NONE;
+   }
 
mutex_lock(_encoder->dp.hpd_irq_lock);
if (mstm) {
-- 
2.43.0



[PATCH AUTOSEL 6.8 12/18] drm/nouveau/dp: Don't probe eDP ports twice harder

2024-04-23 Thread Sasha Levin
From: Lyude Paul 

[ Upstream commit bf52d7f9b2067f02efe7e32697479097aba4a055 ]

I didn't pay close enough attention the last time I tried to fix this
problem - while we currently do correctly take care to make sure we don't
probe a connected eDP port more then once, we don't do the same thing for
eDP ports we found to be disconnected.

So, fix this and make sure we only ever probe eDP ports once and then leave
them at that connector state forever (since without HPD, it's not going to
change on its own anyway). This should get rid of the last few GSP errors
getting spit out during runtime suspend and resume on some machines, as we
tried to reprobe eDP ports in response to ACPI hotplug probe events.

Signed-off-by: Lyude Paul 
Reviewed-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240404233736.7946-3-ly...@redhat.com
(cherry picked from commit fe6660b661c3397af0867d5d098f5b26581f1290)
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_dp.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c 
b/drivers/gpu/drm/nouveau/nouveau_dp.c
index 7de7707ec6a89..3f72bc38bd2c4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -225,12 +225,15 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
u8 *dpcd = nv_encoder->dp.dpcd;
int ret = NOUVEAU_DP_NONE, hpd;
 
-   /* If we've already read the DPCD on an eDP device, we don't need to
-* reread it as it won't change
+   /* eDP ports don't support hotplugging - so there's no point in probing 
eDP ports unless we
+* haven't probed them once before.
 */
-   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP &&
-   dpcd[DP_DPCD_REV] != 0)
-   return NOUVEAU_DP_SST;
+   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+   if (connector->status == connector_status_connected)
+   return NOUVEAU_DP_SST;
+   else if (connector->status == connector_status_disconnected)
+   return NOUVEAU_DP_NONE;
+   }
 
mutex_lock(_encoder->dp.hpd_irq_lock);
if (mstm) {
-- 
2.43.0



[PATCH AUTOSEL 6.8 13/43] nouveau/gsp: Avoid addressing beyond end of rpc->entries

2024-04-22 Thread Sasha Levin
From: Kees Cook 

[ Upstream commit 838ae9f45c4e43b4633d8b0ad1fbedff9ecf177d ]

Using the end of rpc->entries[] for addressing runs into both compile-time
and run-time detection of accessing beyond the end of the array. Use the
base pointer instead, since was allocated with the additional bytes for
storing the strings. Avoids the following warning in future GCC releases
with support for __counted_by:

In function 'fortify_memcpy_chk',
inlined from 'r535_gsp_rpc_set_registry' at 
../drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c:1123:3:
../include/linux/fortify-string.h:553:25: error: call to 
'__write_overflow_field' declared with attribute warning: detected write beyond 
size of field (1st parameter); maybe use struct_group()? 
[-Werror=attribute-warning]
  553 | __write_overflow_field(p_size_field, size);
  | ^~

for this code:

strings = (char *)>entries[NV_GSP_REG_NUM_ENTRIES];
...
memcpy(strings, r535_registry_entries[i].name, name_len);

Signed-off-by: Kees Cook 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240330141159.work.063-k...@kernel.org
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c
index a73a5b5897904..dcafbb2004ca2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c
@@ -1112,7 +1112,7 @@ r535_gsp_rpc_set_registry(struct nvkm_gsp *gsp)
rpc->numEntries = NV_GSP_REG_NUM_ENTRIES;
 
str_offset = offsetof(typeof(*rpc), entries[NV_GSP_REG_NUM_ENTRIES]);
-   strings = (char *)>entries[NV_GSP_REG_NUM_ENTRIES];
+   strings = (char *)rpc + str_offset;
for (i = 0; i < NV_GSP_REG_NUM_ENTRIES; i++) {
int name_len = strlen(r535_registry_entries[i].name) + 1;
 
-- 
2.43.0



[PATCH AUTOSEL 6.7 35/58] drm/nouveau: nvkm_gsp_radix3_sg() should use nvkm_gsp_mem_ctor()

2024-02-12 Thread Sasha Levin
From: Timur Tabi 

[ Upstream commit 34e659f34a7559ecfd9c1f5b24d4c291f3f54711 ]

Function nvkm_gsp_radix3_sg() uses nvkm_gsp_mem objects to allocate the
radix3 tables, but it unnecessarily creates those objects manually
instead of using the standard nvkm_gsp_mem_ctor() function like the
rest of the code does.

Signed-off-by: Timur Tabi 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20240202230608.1981026-2-tt...@nvidia.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c
index 9ee58e2a0eb2..09e2eb1369cb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c
@@ -1938,20 +1938,20 @@ nvkm_gsp_radix3_dtor(struct nvkm_gsp *gsp, struct 
nvkm_gsp_radix3 *rx3)
  * See kgspCreateRadix3_IMPL
  */
 static int
-nvkm_gsp_radix3_sg(struct nvkm_device *device, struct sg_table *sgt, u64 size,
+nvkm_gsp_radix3_sg(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size,
   struct nvkm_gsp_radix3 *rx3)
 {
u64 addr;
 
for (int i = ARRAY_SIZE(rx3->mem) - 1; i >= 0; i--) {
u64 *ptes;
-   int idx;
+   size_t bufsize;
+   int ret, idx;
 
-   rx3->mem[i].size = ALIGN((size / GSP_PAGE_SIZE) * sizeof(u64), 
GSP_PAGE_SIZE);
-   rx3->mem[i].data = dma_alloc_coherent(device->dev, 
rx3->mem[i].size,
- >mem[i].addr, 
GFP_KERNEL);
-   if (WARN_ON(!rx3->mem[i].data))
-   return -ENOMEM;
+   bufsize = ALIGN((size / GSP_PAGE_SIZE) * sizeof(u64), 
GSP_PAGE_SIZE);
+   ret = nvkm_gsp_mem_ctor(gsp, bufsize, >mem[i]);
+   if (ret)
+   return ret;
 
ptes = rx3->mem[i].data;
if (i == 2) {
@@ -1991,7 +1991,7 @@ r535_gsp_fini(struct nvkm_gsp *gsp, bool suspend)
if (ret)
return ret;
 
-   ret = nvkm_gsp_radix3_sg(gsp->subdev.device, >sr.sgt, len, 
>sr.radix3);
+   ret = nvkm_gsp_radix3_sg(gsp, >sr.sgt, len, 
>sr.radix3);
if (ret)
return ret;
 
@@ -2194,7 +2194,7 @@ r535_gsp_oneinit(struct nvkm_gsp *gsp)
memcpy(gsp->sig.data, data, size);
 
/* Build radix3 page table for ELF image. */
-   ret = nvkm_gsp_radix3_sg(device, >fw.mem.sgt, gsp->fw.len, 
>radix3);
+   ret = nvkm_gsp_radix3_sg(gsp, >fw.mem.sgt, gsp->fw.len, 
>radix3);
if (ret)
return ret;
 
-- 
2.43.0



Re: [PATCH AUTOSEL 6.1 5/5] nouveau: fix disp disabling with GSP

2024-01-14 Thread Sasha Levin

On Tue, Jan 09, 2024 at 06:51:25AM +1000, David Airlie wrote:

NAK for backporting this to anything, it is just a fix for 6.7


Dropped it from everywhere, thanks!

--
Thanks,
Sasha


[PATCH AUTOSEL 6.1 5/5] nouveau: fix disp disabling with GSP

2024-01-08 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit 7854ea0e408d7f2e8faaada1773f3ddf9cb538f5 ]

This func ptr here is normally static allocation, but gsp r535
uses a dynamic pointer, so we need to handle that better.

This fixes a crash with GSP when you use config=disp=0 to avoid
disp problems.

Signed-off-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231222043308.3090089-4-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 65c99d948b686..ae47eabd5d0bd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -359,7 +359,7 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
if (ret)
return ret;
 
-   if (disp->func->oneinit) {
+   if (disp->func && disp->func->oneinit) {
ret = disp->func->oneinit(disp);
if (ret)
return ret;
@@ -461,8 +461,10 @@ nvkm_disp_new_(const struct nvkm_disp_func *func, struct 
nvkm_device *device,
spin_lock_init(>client.lock);
 
ret = nvkm_engine_ctor(_disp, device, type, inst, true, 
>engine);
-   if (ret)
+   if (ret) {
+   disp->func = NULL;
return ret;
+   }
 
if (func->super) {
disp->super.wq = create_singlethread_workqueue("nvkm-disp");
-- 
2.43.0



[PATCH AUTOSEL 6.6 8/8] nouveau: fix disp disabling with GSP

2024-01-08 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit 7854ea0e408d7f2e8faaada1773f3ddf9cb538f5 ]

This func ptr here is normally static allocation, but gsp r535
uses a dynamic pointer, so we need to handle that better.

This fixes a crash with GSP when you use config=disp=0 to avoid
disp problems.

Signed-off-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231222043308.3090089-4-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 73104b59f97fe..54a3017f4756a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -276,7 +276,7 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
list_add_tail(>conn->head, >conns);
}
 
-   if (disp->func->oneinit) {
+   if (disp->func && disp->func->oneinit) {
ret = disp->func->oneinit(disp);
if (ret)
return ret;
@@ -377,8 +377,10 @@ nvkm_disp_new_(const struct nvkm_disp_func *func, struct 
nvkm_device *device,
spin_lock_init(>client.lock);
 
ret = nvkm_engine_ctor(_disp, device, type, inst, true, 
>engine);
-   if (ret)
+   if (ret) {
+   disp->func = NULL;
return ret;
+   }
 
if (func->super) {
disp->super.wq = create_singlethread_workqueue("nvkm-disp");
-- 
2.43.0



[PATCH AUTOSEL 5.4 07/12] nouveau/tu102: flush all pdbs on vmm flush

2023-12-11 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit cb9c919364653eeafb49e7ff5cd32f1ad64063ac ]

This is a hack around a bug exposed with the GSP code, I'm not sure
what is happening exactly, but it appears some of our flushes don't
result in proper tlb invalidation for out BAR2 and we get a BAR2
fault from GSP and it all dies.

Signed-off-by: Dave Airlie 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231130010852.4034774-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
index be91cffc3b52a..315000b2f8e3e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
@@ -32,7 +32,7 @@ tu102_vmm_flush(struct nvkm_vmm *vmm, int depth)
 
type = 0x0001; /* PAGE_ALL */
if (atomic_read(>engref[NVKM_SUBDEV_BAR]))
-   type |= 0x0004; /* HUB_ONLY */
+   type |= 0x0006; /* HUB_ONLY | ALL PDB (hack) */
 
mutex_lock(>mutex);
 
-- 
2.42.0



[PATCH AUTOSEL 5.10 09/16] nouveau/tu102: flush all pdbs on vmm flush

2023-12-11 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit cb9c919364653eeafb49e7ff5cd32f1ad64063ac ]

This is a hack around a bug exposed with the GSP code, I'm not sure
what is happening exactly, but it appears some of our flushes don't
result in proper tlb invalidation for out BAR2 and we get a BAR2
fault from GSP and it all dies.

Signed-off-by: Dave Airlie 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231130010852.4034774-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
index b1294d0076c08..72449bf613bf1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
@@ -32,7 +32,7 @@ tu102_vmm_flush(struct nvkm_vmm *vmm, int depth)
 
type |= 0x0001; /* PAGE_ALL */
if (atomic_read(>engref[NVKM_SUBDEV_BAR]))
-   type |= 0x0004; /* HUB_ONLY */
+   type |= 0x0006; /* HUB_ONLY | ALL PDB (hack) */
 
mutex_lock(>mutex);
 
-- 
2.42.0



[PATCH AUTOSEL 5.15 09/19] nouveau/tu102: flush all pdbs on vmm flush

2023-12-11 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit cb9c919364653eeafb49e7ff5cd32f1ad64063ac ]

This is a hack around a bug exposed with the GSP code, I'm not sure
what is happening exactly, but it appears some of our flushes don't
result in proper tlb invalidation for out BAR2 and we get a BAR2
fault from GSP and it all dies.

Signed-off-by: Dave Airlie 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231130010852.4034774-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
index 6cb5eefa45e9a..5a08458fe1b7f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
@@ -31,7 +31,7 @@ tu102_vmm_flush(struct nvkm_vmm *vmm, int depth)
 
type |= 0x0001; /* PAGE_ALL */
if (atomic_read(>engref[NVKM_SUBDEV_BAR]))
-   type |= 0x0004; /* HUB_ONLY */
+   type |= 0x0006; /* HUB_ONLY | ALL PDB (hack) */
 
mutex_lock(>mmu->mutex);
 
-- 
2.42.0



[PATCH AUTOSEL 6.1 13/29] nouveau/tu102: flush all pdbs on vmm flush

2023-12-11 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit cb9c919364653eeafb49e7ff5cd32f1ad64063ac ]

This is a hack around a bug exposed with the GSP code, I'm not sure
what is happening exactly, but it appears some of our flushes don't
result in proper tlb invalidation for out BAR2 and we get a BAR2
fault from GSP and it all dies.

Signed-off-by: Dave Airlie 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231130010852.4034774-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
index 6cb5eefa45e9a..5a08458fe1b7f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
@@ -31,7 +31,7 @@ tu102_vmm_flush(struct nvkm_vmm *vmm, int depth)
 
type |= 0x0001; /* PAGE_ALL */
if (atomic_read(>engref[NVKM_SUBDEV_BAR]))
-   type |= 0x0004; /* HUB_ONLY */
+   type |= 0x0006; /* HUB_ONLY | ALL PDB (hack) */
 
mutex_lock(>mmu->mutex);
 
-- 
2.42.0



[PATCH AUTOSEL 6.6 19/47] nouveau/tu102: flush all pdbs on vmm flush

2023-12-11 Thread Sasha Levin
From: Dave Airlie 

[ Upstream commit cb9c919364653eeafb49e7ff5cd32f1ad64063ac ]

This is a hack around a bug exposed with the GSP code, I'm not sure
what is happening exactly, but it appears some of our flushes don't
result in proper tlb invalidation for out BAR2 and we get a BAR2
fault from GSP and it all dies.

Signed-off-by: Dave Airlie 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231130010852.4034774-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
index 6cb5eefa45e9a..5a08458fe1b7f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmtu102.c
@@ -31,7 +31,7 @@ tu102_vmm_flush(struct nvkm_vmm *vmm, int depth)
 
type |= 0x0001; /* PAGE_ALL */
if (atomic_read(>engref[NVKM_SUBDEV_BAR]))
-   type |= 0x0004; /* HUB_ONLY */
+   type |= 0x0006; /* HUB_ONLY | ALL PDB (hack) */
 
mutex_lock(>mmu->mutex);
 
-- 
2.42.0



[Nouveau] [PATCH AUTOSEL 6.5 06/15] nouveau: use an rwlock for the event lock.

2023-11-22 Thread Sasha Levin
y: Danilo Krummrich 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231107053255.2257079-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvkm/core/event.h |  4 ++--
 drivers/gpu/drm/nouveau/nvkm/core/event.c | 12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h 
b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
index 82b267c111470..460459af272d6 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
@@ -14,7 +14,7 @@ struct nvkm_event {
int index_nr;
 
spinlock_t refs_lock;
-   spinlock_t list_lock;
+   rwlock_t list_lock;
int *refs;
 
struct list_head ntfy;
@@ -38,7 +38,7 @@ nvkm_event_init(const struct nvkm_event_func *func, struct 
nvkm_subdev *subdev,
int types_nr, int index_nr, struct nvkm_event *event)
 {
spin_lock_init(>refs_lock);
-   spin_lock_init(>list_lock);
+   rwlock_init(>list_lock);
return __nvkm_event_init(func, subdev, types_nr, index_nr, event);
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/event.c 
b/drivers/gpu/drm/nouveau/nvkm/core/event.c
index a6c877135598f..61fed7792e415 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/event.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/event.c
@@ -81,17 +81,17 @@ nvkm_event_ntfy_state(struct nvkm_event_ntfy *ntfy)
 static void
 nvkm_event_ntfy_remove(struct nvkm_event_ntfy *ntfy)
 {
-   spin_lock_irq(>event->list_lock);
+   write_lock_irq(>event->list_lock);
list_del_init(>head);
-   spin_unlock_irq(>event->list_lock);
+   write_unlock_irq(>event->list_lock);
 }
 
 static void
 nvkm_event_ntfy_insert(struct nvkm_event_ntfy *ntfy)
 {
-   spin_lock_irq(>event->list_lock);
+   write_lock_irq(>event->list_lock);
list_add_tail(>head, >event->ntfy);
-   spin_unlock_irq(>event->list_lock);
+   write_unlock_irq(>event->list_lock);
 }
 
 static void
@@ -176,7 +176,7 @@ nvkm_event_ntfy(struct nvkm_event *event, int id, u32 bits)
return;
 
nvkm_trace(event->subdev, "event: ntfy %08x on %d\n", bits, id);
-   spin_lock_irqsave(>list_lock, flags);
+   read_lock_irqsave(>list_lock, flags);
 
list_for_each_entry_safe(ntfy, ntmp, >ntfy, head) {
if (ntfy->id == id && ntfy->bits & bits) {
@@ -185,7 +185,7 @@ nvkm_event_ntfy(struct nvkm_event *event, int id, u32 bits)
}
}
 
-   spin_unlock_irqrestore(>list_lock, flags);
+   read_unlock_irqrestore(>list_lock, flags);
 }
 
 void
-- 
2.42.0



[Nouveau] [PATCH AUTOSEL 6.6 07/17] nouveau: use an rwlock for the event lock.

2023-11-22 Thread Sasha Levin
y: Danilo Krummrich 
Signed-off-by: Danilo Krummrich 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20231107053255.2257079-1-airl...@gmail.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvkm/core/event.h |  4 ++--
 drivers/gpu/drm/nouveau/nvkm/core/event.c | 12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h 
b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
index 82b267c111470..460459af272d6 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/event.h
@@ -14,7 +14,7 @@ struct nvkm_event {
int index_nr;
 
spinlock_t refs_lock;
-   spinlock_t list_lock;
+   rwlock_t list_lock;
int *refs;
 
struct list_head ntfy;
@@ -38,7 +38,7 @@ nvkm_event_init(const struct nvkm_event_func *func, struct 
nvkm_subdev *subdev,
int types_nr, int index_nr, struct nvkm_event *event)
 {
spin_lock_init(>refs_lock);
-   spin_lock_init(>list_lock);
+   rwlock_init(>list_lock);
return __nvkm_event_init(func, subdev, types_nr, index_nr, event);
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/event.c 
b/drivers/gpu/drm/nouveau/nvkm/core/event.c
index a6c877135598f..61fed7792e415 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/event.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/event.c
@@ -81,17 +81,17 @@ nvkm_event_ntfy_state(struct nvkm_event_ntfy *ntfy)
 static void
 nvkm_event_ntfy_remove(struct nvkm_event_ntfy *ntfy)
 {
-   spin_lock_irq(>event->list_lock);
+   write_lock_irq(>event->list_lock);
list_del_init(>head);
-   spin_unlock_irq(>event->list_lock);
+   write_unlock_irq(>event->list_lock);
 }
 
 static void
 nvkm_event_ntfy_insert(struct nvkm_event_ntfy *ntfy)
 {
-   spin_lock_irq(>event->list_lock);
+   write_lock_irq(>event->list_lock);
list_add_tail(>head, >event->ntfy);
-   spin_unlock_irq(>event->list_lock);
+   write_unlock_irq(>event->list_lock);
 }
 
 static void
@@ -176,7 +176,7 @@ nvkm_event_ntfy(struct nvkm_event *event, int id, u32 bits)
return;
 
nvkm_trace(event->subdev, "event: ntfy %08x on %d\n", bits, id);
-   spin_lock_irqsave(>list_lock, flags);
+   read_lock_irqsave(>list_lock, flags);
 
list_for_each_entry_safe(ntfy, ntmp, >ntfy, head) {
if (ntfy->id == id && ntfy->bits & bits) {
@@ -185,7 +185,7 @@ nvkm_event_ntfy(struct nvkm_event *event, int id, u32 bits)
}
}
 
-   spin_unlock_irqrestore(>list_lock, flags);
+   read_unlock_irqrestore(>list_lock, flags);
 }
 
 void
-- 
2.42.0



[Nouveau] [PATCH AUTOSEL 5.15 12/17] drm/nouveau/devinit/tu102-: wait for GFW_BOOT_PROGRESS == COMPLETED

2023-02-09 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit d22915d22ded21fd5b24b60d174775789f173997 ]

Starting from Turing, the driver is no longer responsible for initiating
DEVINIT when required as the GPU started loading a FW image from ROM and
executing DEVINIT itself after power-on.

However - we apparently still need to wait for it to complete.

This should correct some issues with runpm on some systems, where we get
control of the HW before it's been fully reinitialised after resume from
suspend.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20230130223715.1831509-1-bske...@redhat.com
Signed-off-by: Sasha Levin 
---
 .../drm/nouveau/nvkm/subdev/devinit/tu102.c   | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
index 634f64f88fc8b..81a1ad2c88a7e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
@@ -65,10 +65,33 @@ tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, 
u32 freq)
return ret;
 }
 
+static int
+tu102_devinit_wait(struct nvkm_device *device)
+{
+   unsigned timeout = 50 + 2000;
+
+   do {
+   if (nvkm_rd32(device, 0x118128) & 0x0001) {
+   if ((nvkm_rd32(device, 0x118234) & 0x00ff) == 0xff)
+   return 0;
+   }
+
+   usleep_range(1000, 2000);
+   } while (timeout--);
+
+   return -ETIMEDOUT;
+}
+
 int
 tu102_devinit_post(struct nvkm_devinit *base, bool post)
 {
struct nv50_devinit *init = nv50_devinit(base);
+   int ret;
+
+   ret = tu102_devinit_wait(init->base.subdev.device);
+   if (ret)
+   return ret;
+
gm200_devinit_preos(init, post);
return 0;
 }
-- 
2.39.0



[Nouveau] [PATCH AUTOSEL 6.1 22/38] drm/nouveau/devinit/tu102-: wait for GFW_BOOT_PROGRESS == COMPLETED

2023-02-09 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit d22915d22ded21fd5b24b60d174775789f173997 ]

Starting from Turing, the driver is no longer responsible for initiating
DEVINIT when required as the GPU started loading a FW image from ROM and
executing DEVINIT itself after power-on.

However - we apparently still need to wait for it to complete.

This should correct some issues with runpm on some systems, where we get
control of the HW before it's been fully reinitialised after resume from
suspend.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20230130223715.1831509-1-bske...@redhat.com
Signed-off-by: Sasha Levin 
---
 .../drm/nouveau/nvkm/subdev/devinit/tu102.c   | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
index 634f64f88fc8b..81a1ad2c88a7e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
@@ -65,10 +65,33 @@ tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, 
u32 freq)
return ret;
 }
 
+static int
+tu102_devinit_wait(struct nvkm_device *device)
+{
+   unsigned timeout = 50 + 2000;
+
+   do {
+   if (nvkm_rd32(device, 0x118128) & 0x0001) {
+   if ((nvkm_rd32(device, 0x118234) & 0x00ff) == 0xff)
+   return 0;
+   }
+
+   usleep_range(1000, 2000);
+   } while (timeout--);
+
+   return -ETIMEDOUT;
+}
+
 int
 tu102_devinit_post(struct nvkm_devinit *base, bool post)
 {
struct nv50_devinit *init = nv50_devinit(base);
+   int ret;
+
+   ret = tu102_devinit_wait(init->base.subdev.device);
+   if (ret)
+   return ret;
+
gm200_devinit_preos(init, post);
return 0;
 }
-- 
2.39.0



[Nouveau] [PATCH AUTOSEL 5.4 01/14] drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()

2022-10-09 Thread Sasha Levin
From: Jianglei Nie 

[ Upstream commit 6dc548745d5b5102e3c53dc5097296ac270b6c69 ]

nouveau_bo_alloc() allocates a memory chunk for "nvbo" with kzalloc().
When some error occurs, "nvbo" should be released. But when
WARN_ON(pi < 0)) equals true, the function return ERR_PTR without
releasing the "nvbo", which will lead to a memory leak.

We should release the "nvbo" with kfree() if WARN_ON(pi < 0)) equals true.

Signed-off-by: Jianglei Nie 
Signed-off-by: Lyude Paul 
Reviewed-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220705094306.2244103-1-niejianglei2...@163.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index f7603be569fc..9f9c70734180 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -276,8 +276,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int 
*align, u32 flags,
break;
}
 
-   if (WARN_ON(pi < 0))
+   if (WARN_ON(pi < 0)) {
+   kfree(nvbo);
return ERR_PTR(-EINVAL);
+   }
 
/* Disable compression if suitable settings couldn't be found. */
if (nvbo->comp && !vmm->page[pi].comp) {
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.10 01/22] drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()

2022-10-09 Thread Sasha Levin
From: Jianglei Nie 

[ Upstream commit 6dc548745d5b5102e3c53dc5097296ac270b6c69 ]

nouveau_bo_alloc() allocates a memory chunk for "nvbo" with kzalloc().
When some error occurs, "nvbo" should be released. But when
WARN_ON(pi < 0)) equals true, the function return ERR_PTR without
releasing the "nvbo", which will lead to a memory leak.

We should release the "nvbo" with kfree() if WARN_ON(pi < 0)) equals true.

Signed-off-by: Jianglei Nie 
Signed-off-by: Lyude Paul 
Reviewed-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220705094306.2244103-1-niejianglei2...@163.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index b4946b595d86..b57dcad8865f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -279,8 +279,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int 
*align, u32 domain,
break;
}
 
-   if (WARN_ON(pi < 0))
+   if (WARN_ON(pi < 0)) {
+   kfree(nvbo);
return ERR_PTR(-EINVAL);
+   }
 
/* Disable compression if suitable settings couldn't be found. */
if (nvbo->comp && !vmm->page[pi].comp) {
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.15 01/25] drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()

2022-10-09 Thread Sasha Levin
From: Jianglei Nie 

[ Upstream commit 6dc548745d5b5102e3c53dc5097296ac270b6c69 ]

nouveau_bo_alloc() allocates a memory chunk for "nvbo" with kzalloc().
When some error occurs, "nvbo" should be released. But when
WARN_ON(pi < 0)) equals true, the function return ERR_PTR without
releasing the "nvbo", which will lead to a memory leak.

We should release the "nvbo" with kfree() if WARN_ON(pi < 0)) equals true.

Signed-off-by: Jianglei Nie 
Signed-off-by: Lyude Paul 
Reviewed-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220705094306.2244103-1-niejianglei2...@163.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 511fb8dfb4c4..da58230bcb1f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -281,8 +281,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int 
*align, u32 domain,
break;
}
 
-   if (WARN_ON(pi < 0))
+   if (WARN_ON(pi < 0)) {
+   kfree(nvbo);
return ERR_PTR(-EINVAL);
+   }
 
/* Disable compression if suitable settings couldn't be found. */
if (nvbo->comp && !vmm->page[pi].comp) {
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.19 01/36] drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()

2022-10-09 Thread Sasha Levin
From: Jianglei Nie 

[ Upstream commit 6dc548745d5b5102e3c53dc5097296ac270b6c69 ]

nouveau_bo_alloc() allocates a memory chunk for "nvbo" with kzalloc().
When some error occurs, "nvbo" should be released. But when
WARN_ON(pi < 0)) equals true, the function return ERR_PTR without
releasing the "nvbo", which will lead to a memory leak.

We should release the "nvbo" with kfree() if WARN_ON(pi < 0)) equals true.

Signed-off-by: Jianglei Nie 
Signed-off-by: Lyude Paul 
Reviewed-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220705094306.2244103-1-niejianglei2...@163.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index e29175e4b44c..07a327ad5e2a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -281,8 +281,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int 
*align, u32 domain,
break;
}
 
-   if (WARN_ON(pi < 0))
+   if (WARN_ON(pi < 0)) {
+   kfree(nvbo);
return ERR_PTR(-EINVAL);
+   }
 
/* Disable compression if suitable settings couldn't be found. */
if (nvbo->comp && !vmm->page[pi].comp) {
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 6.0 01/44] drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()

2022-10-09 Thread Sasha Levin
From: Jianglei Nie 

[ Upstream commit 6dc548745d5b5102e3c53dc5097296ac270b6c69 ]

nouveau_bo_alloc() allocates a memory chunk for "nvbo" with kzalloc().
When some error occurs, "nvbo" should be released. But when
WARN_ON(pi < 0)) equals true, the function return ERR_PTR without
releasing the "nvbo", which will lead to a memory leak.

We should release the "nvbo" with kfree() if WARN_ON(pi < 0)) equals true.

Signed-off-by: Jianglei Nie 
Signed-off-by: Lyude Paul 
Reviewed-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220705094306.2244103-1-niejianglei2...@163.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index e29175e4b44c..07a327ad5e2a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -281,8 +281,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int 
*align, u32 domain,
break;
}
 
-   if (WARN_ON(pi < 0))
+   if (WARN_ON(pi < 0)) {
+   kfree(nvbo);
return ERR_PTR(-EINVAL);
+   }
 
/* Disable compression if suitable settings couldn't be found. */
if (nvbo->comp && !vmm->page[pi].comp) {
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 4.14 09/14] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index be19bbe56bba..bb57df290f63 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 4.19 09/14] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index d777df5a64e6..2aa0d6fed580 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.4 16/25] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index d777df5a64e6..2aa0d6fed580 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.4 04/25] drm/nouveau: clear output poll workers before nouveau_fbcon_destroy()

2022-08-11 Thread Sasha Levin
From: Mark Menzynski 

[ Upstream commit 6b03816f869529393b37d03e5d75b68f7365a7a4 ]

Resources needed for output poll workers are destroyed in
nouveau_fbcon_fini() before output poll workers are cleared in
nouveau_display_fini(). This means there is a time between fbcon_fini()
and display_fini(), where if output poll happens, it crashes.

This patch introduces another output poll clearing before fbcon
resources are destroyed.

BUG: KASAN: use-after-free in
__drm_fb_helper_initial_config_and_unlock.cold+0x1f3/0x291
[drm_kms_helper]

Cc: Ben Skeggs 
Cc: Karol Herbst 
Cc: Lyude Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-de...@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Mark Menzynski 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220523113541.10562-1-mmenz...@redhat.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index c09ea357e88f..325fc94791c6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -606,6 +607,7 @@ nouveau_fbcon_fini(struct drm_device *dev)
if (!drm->fbcon)
return;
 
+   drm_kms_helper_poll_fini(dev);
nouveau_fbcon_accel_fini(dev);
nouveau_fbcon_destroy(dev, drm->fbcon);
kfree(drm->fbcon);
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.10 31/46] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index d777df5a64e6..2aa0d6fed580 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.10 04/46] drm/nouveau: clear output poll workers before nouveau_fbcon_destroy()

2022-08-11 Thread Sasha Levin
From: Mark Menzynski 

[ Upstream commit 6b03816f869529393b37d03e5d75b68f7365a7a4 ]

Resources needed for output poll workers are destroyed in
nouveau_fbcon_fini() before output poll workers are cleared in
nouveau_display_fini(). This means there is a time between fbcon_fini()
and display_fini(), where if output poll happens, it crashes.

This patch introduces another output poll clearing before fbcon
resources are destroyed.

BUG: KASAN: use-after-free in
__drm_fb_helper_initial_config_and_unlock.cold+0x1f3/0x291
[drm_kms_helper]

Cc: Ben Skeggs 
Cc: Karol Herbst 
Cc: Lyude Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-de...@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Mark Menzynski 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220523113541.10562-1-mmenz...@redhat.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 24ec5339efb4..502f960517fe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -603,6 +604,7 @@ nouveau_fbcon_fini(struct drm_device *dev)
if (!drm->fbcon)
return;
 
+   drm_kms_helper_poll_fini(dev);
nouveau_fbcon_accel_fini(dev);
nouveau_fbcon_destroy(dev, drm->fbcon);
kfree(drm->fbcon);
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.15 50/69] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 735cb6816f10..06b2f675f5da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.15 05/69] drm/nouveau: clear output poll workers before nouveau_fbcon_destroy()

2022-08-11 Thread Sasha Levin
From: Mark Menzynski 

[ Upstream commit 6b03816f869529393b37d03e5d75b68f7365a7a4 ]

Resources needed for output poll workers are destroyed in
nouveau_fbcon_fini() before output poll workers are cleared in
nouveau_display_fini(). This means there is a time between fbcon_fini()
and display_fini(), where if output poll happens, it crashes.

This patch introduces another output poll clearing before fbcon
resources are destroyed.

BUG: KASAN: use-after-free in
__drm_fb_helper_initial_config_and_unlock.cold+0x1f3/0x291
[drm_kms_helper]

Cc: Ben Skeggs 
Cc: Karol Herbst 
Cc: Lyude Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-de...@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Mark Menzynski 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220523113541.10562-1-mmenz...@redhat.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 4f9b3aa5deda..5226323e55d3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -605,6 +606,7 @@ nouveau_fbcon_fini(struct drm_device *dev)
if (!drm->fbcon)
return;
 
+   drm_kms_helper_poll_fini(dev);
nouveau_fbcon_accel_fini(dev);
nouveau_fbcon_destroy(dev, drm->fbcon);
kfree(drm->fbcon);
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.18 62/93] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 735cb6816f10..06b2f675f5da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.18 05/93] drm/nouveau: clear output poll workers before nouveau_fbcon_destroy()

2022-08-11 Thread Sasha Levin
From: Mark Menzynski 

[ Upstream commit 6b03816f869529393b37d03e5d75b68f7365a7a4 ]

Resources needed for output poll workers are destroyed in
nouveau_fbcon_fini() before output poll workers are cleared in
nouveau_display_fini(). This means there is a time between fbcon_fini()
and display_fini(), where if output poll happens, it crashes.

This patch introduces another output poll clearing before fbcon
resources are destroyed.

BUG: KASAN: use-after-free in
__drm_fb_helper_initial_config_and_unlock.cold+0x1f3/0x291
[drm_kms_helper]

Cc: Ben Skeggs 
Cc: Karol Herbst 
Cc: Lyude Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-de...@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Mark Menzynski 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220523113541.10562-1-mmenz...@redhat.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 4f9b3aa5deda..5226323e55d3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -605,6 +606,7 @@ nouveau_fbcon_fini(struct drm_device *dev)
if (!drm->fbcon)
return;
 
+   drm_kms_helper_poll_fini(dev);
nouveau_fbcon_accel_fini(dev);
nouveau_fbcon_destroy(dev, drm->fbcon);
kfree(drm->fbcon);
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.19 069/105] drm/nouveau/nvkm: use list_add_tail() when building object tree

2022-08-11 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 61c1f340bc809a1ca1e3c8794207a91cde1a7c78 ]

Fixes resume from hibernate failing on (at least) TU102, where cursor
channel init failed due to being performed before the core channel.

Not solid idea why suspend-to-ram worked, but, presumably HW being in
an entirely clean state has something to do with it.

Signed-off-by: Ben Skeggs 
Reviewed-by: Dave Airlie 
Signed-off-by: Dave Airlie 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/core/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c 
b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index 735cb6816f10..06b2f675f5da 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -128,7 +128,7 @@ nvkm_ioctl_new(struct nvkm_client *client,
if (ret == 0) {
ret = nvkm_object_init(object);
if (ret == 0) {
-   list_add(>head, >tree);
+   list_add_tail(>head, >tree);
if (nvkm_object_insert(object)) {
client->data = object;
return 0;
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 5.19 005/105] drm/nouveau: clear output poll workers before nouveau_fbcon_destroy()

2022-08-11 Thread Sasha Levin
From: Mark Menzynski 

[ Upstream commit 6b03816f869529393b37d03e5d75b68f7365a7a4 ]

Resources needed for output poll workers are destroyed in
nouveau_fbcon_fini() before output poll workers are cleared in
nouveau_display_fini(). This means there is a time between fbcon_fini()
and display_fini(), where if output poll happens, it crashes.

This patch introduces another output poll clearing before fbcon
resources are destroyed.

BUG: KASAN: use-after-free in
__drm_fb_helper_initial_config_and_unlock.cold+0x1f3/0x291
[drm_kms_helper]

Cc: Ben Skeggs 
Cc: Karol Herbst 
Cc: Lyude Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-de...@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Mark Menzynski 
Reviewed-by: Lyude Paul 
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20220523113541.10562-1-mmenz...@redhat.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 4f9b3aa5deda..5226323e55d3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -605,6 +606,7 @@ nouveau_fbcon_fini(struct drm_device *dev)
if (!drm->fbcon)
return;
 
+   drm_kms_helper_poll_fini(dev);
nouveau_fbcon_accel_fini(dev);
nouveau_fbcon_destroy(dev, drm->fbcon);
kfree(drm->fbcon);
-- 
2.35.1



[Nouveau] [PATCH AUTOSEL 4.14 04/56] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR

2022-01-17 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ]

There have been reports of the WFI timing out on some boards, and a
patch was proposed to just remove it.  This stuff is rather fragile,
and I believe the WFI might be needed with our FW prior to GM200.

However, we probably should not be touching PMU during init on GPUs
where we depend on NVIDIA FW, outside of limited circumstances, so
this should be a somewhat safer change that achieves the desired
result.

Reported-by: Diego Viola 
Signed-off-by: Ben Skeggs 
Reviewed-by: Karol Herbst 
Signed-off-by: Karol Herbst 
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c| 37 +++
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
index ce70a193caa7f..8cf3d1b4662de 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -70,20 +70,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
return 0;
 }
 
-static int
+static void
 nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
struct nvkm_device *device = pmu->subdev.device;
 
if (!pmu->func->enabled(pmu))
-   return 0;
-
-   /* Inhibit interrupts, and wait for idle. */
-   nvkm_wr32(device, 0x10a014, 0x);
-   nvkm_msec(device, 2000,
-   if (!nvkm_rd32(device, 0x10a04c))
-   break;
-   );
+   return;
 
/* Reset. */
if (pmu->func->reset)
@@ -94,25 +87,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
if (!(nvkm_rd32(device, 0x10a10c) & 0x0006))
break;
);
-
-   return 0;
 }
 
 static int
 nvkm_pmu_preinit(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   return nvkm_pmu_reset(pmu);
+   nvkm_pmu_reset(pmu);
+   return 0;
 }
 
 static int
 nvkm_pmu_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   int ret = nvkm_pmu_reset(pmu);
-   if (ret == 0 && pmu->func->init)
-   ret = pmu->func->init(pmu);
-   return ret;
+   struct nvkm_device *device = pmu->subdev.device;
+
+   if (!pmu->func->init)
+   return 0;
+
+   if (pmu->func->enabled(pmu)) {
+   /* Inhibit interrupts, and wait for idle. */
+   nvkm_wr32(device, 0x10a014, 0x);
+   nvkm_msec(device, 2000,
+   if (!nvkm_rd32(device, 0x10a04c))
+   break;
+   );
+
+   nvkm_pmu_reset(pmu);
+   }
+
+   return pmu->func->init(pmu);
 }
 
 static int
-- 
2.34.1



[Nouveau] [PATCH AUTOSEL 4.19 04/59] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR

2022-01-17 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ]

There have been reports of the WFI timing out on some boards, and a
patch was proposed to just remove it.  This stuff is rather fragile,
and I believe the WFI might be needed with our FW prior to GM200.

However, we probably should not be touching PMU during init on GPUs
where we depend on NVIDIA FW, outside of limited circumstances, so
this should be a somewhat safer change that achieves the desired
result.

Reported-by: Diego Viola 
Signed-off-by: Ben Skeggs 
Reviewed-by: Karol Herbst 
Signed-off-by: Karol Herbst 
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c| 37 +++
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
index ce70a193caa7f..8cf3d1b4662de 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -70,20 +70,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
return 0;
 }
 
-static int
+static void
 nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
struct nvkm_device *device = pmu->subdev.device;
 
if (!pmu->func->enabled(pmu))
-   return 0;
-
-   /* Inhibit interrupts, and wait for idle. */
-   nvkm_wr32(device, 0x10a014, 0x);
-   nvkm_msec(device, 2000,
-   if (!nvkm_rd32(device, 0x10a04c))
-   break;
-   );
+   return;
 
/* Reset. */
if (pmu->func->reset)
@@ -94,25 +87,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
if (!(nvkm_rd32(device, 0x10a10c) & 0x0006))
break;
);
-
-   return 0;
 }
 
 static int
 nvkm_pmu_preinit(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   return nvkm_pmu_reset(pmu);
+   nvkm_pmu_reset(pmu);
+   return 0;
 }
 
 static int
 nvkm_pmu_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   int ret = nvkm_pmu_reset(pmu);
-   if (ret == 0 && pmu->func->init)
-   ret = pmu->func->init(pmu);
-   return ret;
+   struct nvkm_device *device = pmu->subdev.device;
+
+   if (!pmu->func->init)
+   return 0;
+
+   if (pmu->func->enabled(pmu)) {
+   /* Inhibit interrupts, and wait for idle. */
+   nvkm_wr32(device, 0x10a014, 0x);
+   nvkm_msec(device, 2000,
+   if (!nvkm_rd32(device, 0x10a04c))
+   break;
+   );
+
+   nvkm_pmu_reset(pmu);
+   }
+
+   return pmu->func->init(pmu);
 }
 
 static int
-- 
2.34.1



[Nouveau] [PATCH AUTOSEL 5.4 06/73] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR

2022-01-17 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ]

There have been reports of the WFI timing out on some boards, and a
patch was proposed to just remove it.  This stuff is rather fragile,
and I believe the WFI might be needed with our FW prior to GM200.

However, we probably should not be touching PMU during init on GPUs
where we depend on NVIDIA FW, outside of limited circumstances, so
this should be a somewhat safer change that achieves the desired
result.

Reported-by: Diego Viola 
Signed-off-by: Ben Skeggs 
Reviewed-by: Karol Herbst 
Signed-off-by: Karol Herbst 
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c| 37 +++
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
index ea2e11771bca5..105b4be467a3e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -88,20 +88,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
return 0;
 }
 
-static int
+static void
 nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
struct nvkm_device *device = pmu->subdev.device;
 
if (!pmu->func->enabled(pmu))
-   return 0;
-
-   /* Inhibit interrupts, and wait for idle. */
-   nvkm_wr32(device, 0x10a014, 0x);
-   nvkm_msec(device, 2000,
-   if (!nvkm_rd32(device, 0x10a04c))
-   break;
-   );
+   return;
 
/* Reset. */
if (pmu->func->reset)
@@ -112,25 +105,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
if (!(nvkm_rd32(device, 0x10a10c) & 0x0006))
break;
);
-
-   return 0;
 }
 
 static int
 nvkm_pmu_preinit(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   return nvkm_pmu_reset(pmu);
+   nvkm_pmu_reset(pmu);
+   return 0;
 }
 
 static int
 nvkm_pmu_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   int ret = nvkm_pmu_reset(pmu);
-   if (ret == 0 && pmu->func->init)
-   ret = pmu->func->init(pmu);
-   return ret;
+   struct nvkm_device *device = pmu->subdev.device;
+
+   if (!pmu->func->init)
+   return 0;
+
+   if (pmu->func->enabled(pmu)) {
+   /* Inhibit interrupts, and wait for idle. */
+   nvkm_wr32(device, 0x10a014, 0x);
+   nvkm_msec(device, 2000,
+   if (!nvkm_rd32(device, 0x10a04c))
+   break;
+   );
+
+   nvkm_pmu_reset(pmu);
+   }
+
+   return pmu->func->init(pmu);
 }
 
 static int
-- 
2.34.1



[Nouveau] [PATCH AUTOSEL 5.10 008/116] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR

2022-01-17 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ]

There have been reports of the WFI timing out on some boards, and a
patch was proposed to just remove it.  This stuff is rather fragile,
and I believe the WFI might be needed with our FW prior to GM200.

However, we probably should not be touching PMU during init on GPUs
where we depend on NVIDIA FW, outside of limited circumstances, so
this should be a somewhat safer change that achieves the desired
result.

Reported-by: Diego Viola 
Signed-off-by: Ben Skeggs 
Reviewed-by: Karol Herbst 
Signed-off-by: Karol Herbst 
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c| 37 +++
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
index a0fe607c9c07f..3bfc55c571b5e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -94,20 +94,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
return 0;
 }
 
-static int
+static void
 nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
struct nvkm_device *device = pmu->subdev.device;
 
if (!pmu->func->enabled(pmu))
-   return 0;
-
-   /* Inhibit interrupts, and wait for idle. */
-   nvkm_wr32(device, 0x10a014, 0x);
-   nvkm_msec(device, 2000,
-   if (!nvkm_rd32(device, 0x10a04c))
-   break;
-   );
+   return;
 
/* Reset. */
if (pmu->func->reset)
@@ -118,25 +111,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
if (!(nvkm_rd32(device, 0x10a10c) & 0x0006))
break;
);
-
-   return 0;
 }
 
 static int
 nvkm_pmu_preinit(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   return nvkm_pmu_reset(pmu);
+   nvkm_pmu_reset(pmu);
+   return 0;
 }
 
 static int
 nvkm_pmu_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   int ret = nvkm_pmu_reset(pmu);
-   if (ret == 0 && pmu->func->init)
-   ret = pmu->func->init(pmu);
-   return ret;
+   struct nvkm_device *device = pmu->subdev.device;
+
+   if (!pmu->func->init)
+   return 0;
+
+   if (pmu->func->enabled(pmu)) {
+   /* Inhibit interrupts, and wait for idle. */
+   nvkm_wr32(device, 0x10a014, 0x);
+   nvkm_msec(device, 2000,
+   if (!nvkm_rd32(device, 0x10a04c))
+   break;
+   );
+
+   nvkm_pmu_reset(pmu);
+   }
+
+   return pmu->func->init(pmu);
 }
 
 static void *
-- 
2.34.1



[Nouveau] [PATCH AUTOSEL 5.15 013/188] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR

2022-01-17 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ]

There have been reports of the WFI timing out on some boards, and a
patch was proposed to just remove it.  This stuff is rather fragile,
and I believe the WFI might be needed with our FW prior to GM200.

However, we probably should not be touching PMU during init on GPUs
where we depend on NVIDIA FW, outside of limited circumstances, so
this should be a somewhat safer change that achieves the desired
result.

Reported-by: Diego Viola 
Signed-off-by: Ben Skeggs 
Reviewed-by: Karol Herbst 
Signed-off-by: Karol Herbst 
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c| 37 +++
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
index 24382875fb4f3..455e95a89259f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -94,20 +94,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
return 0;
 }
 
-static int
+static void
 nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
struct nvkm_device *device = pmu->subdev.device;
 
if (!pmu->func->enabled(pmu))
-   return 0;
-
-   /* Inhibit interrupts, and wait for idle. */
-   nvkm_wr32(device, 0x10a014, 0x);
-   nvkm_msec(device, 2000,
-   if (!nvkm_rd32(device, 0x10a04c))
-   break;
-   );
+   return;
 
/* Reset. */
if (pmu->func->reset)
@@ -118,25 +111,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
if (!(nvkm_rd32(device, 0x10a10c) & 0x0006))
break;
);
-
-   return 0;
 }
 
 static int
 nvkm_pmu_preinit(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   return nvkm_pmu_reset(pmu);
+   nvkm_pmu_reset(pmu);
+   return 0;
 }
 
 static int
 nvkm_pmu_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   int ret = nvkm_pmu_reset(pmu);
-   if (ret == 0 && pmu->func->init)
-   ret = pmu->func->init(pmu);
-   return ret;
+   struct nvkm_device *device = pmu->subdev.device;
+
+   if (!pmu->func->init)
+   return 0;
+
+   if (pmu->func->enabled(pmu)) {
+   /* Inhibit interrupts, and wait for idle. */
+   nvkm_wr32(device, 0x10a014, 0x);
+   nvkm_msec(device, 2000,
+   if (!nvkm_rd32(device, 0x10a04c))
+   break;
+   );
+
+   nvkm_pmu_reset(pmu);
+   }
+
+   return pmu->func->init(pmu);
 }
 
 static void *
-- 
2.34.1



[Nouveau] [PATCH AUTOSEL 5.16 017/217] drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR

2022-01-17 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 1d2271d2fb85e54bfc9630a6c30ac0feb9ffb983 ]

There have been reports of the WFI timing out on some boards, and a
patch was proposed to just remove it.  This stuff is rather fragile,
and I believe the WFI might be needed with our FW prior to GM200.

However, we probably should not be touching PMU during init on GPUs
where we depend on NVIDIA FW, outside of limited circumstances, so
this should be a somewhat safer change that achieves the desired
result.

Reported-by: Diego Viola 
Signed-off-by: Ben Skeggs 
Reviewed-by: Karol Herbst 
Signed-off-by: Karol Herbst 
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/10
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/subdev/pmu/base.c| 37 +++
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
index 24382875fb4f3..455e95a89259f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -94,20 +94,13 @@ nvkm_pmu_fini(struct nvkm_subdev *subdev, bool suspend)
return 0;
 }
 
-static int
+static void
 nvkm_pmu_reset(struct nvkm_pmu *pmu)
 {
struct nvkm_device *device = pmu->subdev.device;
 
if (!pmu->func->enabled(pmu))
-   return 0;
-
-   /* Inhibit interrupts, and wait for idle. */
-   nvkm_wr32(device, 0x10a014, 0x);
-   nvkm_msec(device, 2000,
-   if (!nvkm_rd32(device, 0x10a04c))
-   break;
-   );
+   return;
 
/* Reset. */
if (pmu->func->reset)
@@ -118,25 +111,37 @@ nvkm_pmu_reset(struct nvkm_pmu *pmu)
if (!(nvkm_rd32(device, 0x10a10c) & 0x0006))
break;
);
-
-   return 0;
 }
 
 static int
 nvkm_pmu_preinit(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   return nvkm_pmu_reset(pmu);
+   nvkm_pmu_reset(pmu);
+   return 0;
 }
 
 static int
 nvkm_pmu_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pmu *pmu = nvkm_pmu(subdev);
-   int ret = nvkm_pmu_reset(pmu);
-   if (ret == 0 && pmu->func->init)
-   ret = pmu->func->init(pmu);
-   return ret;
+   struct nvkm_device *device = pmu->subdev.device;
+
+   if (!pmu->func->init)
+   return 0;
+
+   if (pmu->func->enabled(pmu)) {
+   /* Inhibit interrupts, and wait for idle. */
+   nvkm_wr32(device, 0x10a014, 0x);
+   nvkm_msec(device, 2000,
+   if (!nvkm_rd32(device, 0x10a04c))
+   break;
+   );
+
+   nvkm_pmu_reset(pmu);
+   }
+
+   return pmu->func->init(pmu);
 }
 
 static void *
-- 
2.34.1



Re: [Nouveau] [PATCH AUTOSEL 5.13 20/26] drm/nouveau: recognise GA107

2021-08-30 Thread Sasha Levin

On Mon, Aug 30, 2021 at 01:09:24PM -0400, Lyude Paul wrote:

oops-except for "drm/nouveau: block a bunch of classes from userspace" of
course. the rest are fine though


Yup, that one is gone :)

--
Thanks,
Sasha


Re: [Nouveau] [PATCH AUTOSEL 4.14 6/7] drm/nouveau: block a bunch of classes from userspace

2021-08-30 Thread Sasha Levin

On Tue, Aug 24, 2021 at 01:05:32PM -0400, Lyude Paul wrote:

This isn't at all intended to be a fix to be backported, so I don't think this
should be included. I don't know about 5/7, but I'll let Benjamin comment on
that one


I'll drop it, thanks!

--
Thanks,
Sasha


Re: [Nouveau] [PATCH AUTOSEL 5.13 20/26] drm/nouveau: recognise GA107

2021-08-30 Thread Sasha Levin

On Tue, Aug 24, 2021 at 01:08:28PM -0400, Lyude Paul wrote:

This is more hardware enablement, I'm not sure this should be going into
stable either. Ben?


We take this sort of hardware enablement patches (where the platform
code is already there, and we just add quirks/ids/etc.

--
Thanks,
Sasha


[Nouveau] [PATCH AUTOSEL 4.14 6/7] drm/nouveau: block a bunch of classes from userspace

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 148a8653789c01f159764ffcc3f370008966b42f ]

Long ago, there had been plans for making use of a bunch of these APIs
from userspace and there's various checks in place to stop misbehaving.

Countless other projects have occurred in the meantime, and the pieces
didn't finish falling into place for that to happen.

They will (hopefully) in the not-too-distant future, but it won't look
quite as insane.  The super checks are causing problems right now, and
are going to be removed.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 +
 drivers/gpu/drm/nouveau/nouveau_usif.c| 57 ++-
 .../gpu/drm/nouveau/nvkm/engine/device/user.c |  2 +-
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h 
b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index 2740278d226b..61c17acd507c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -4,7 +4,8 @@
 
 struct nv_device_v0 {
__u8  version;
-   __u8  pad01[7];
+   __u8  priv;
+   __u8  pad02[6];
__u64 device;   /* device identifier, ~0 for client default */
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index fb6b1d0f7fef..fc54a26598cc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -151,6 +151,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
ret = nvif_device_init(>base.object, 0, NV_DEVICE,
   &(struct nv_device_v0) {
.device = ~0,
+   .priv = true,
   }, sizeof(struct nv_device_v0),
   >device);
if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 9dc10b17ad34..5da1f4d223d7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -32,6 +32,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 struct usif_notify_p {
struct drm_pending_event base;
struct {
@@ -261,7 +264,7 @@ usif_object_dtor(struct usif_object *object)
 }
 
 static int
-usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
+usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 
argc, bool parent_abi16)
 {
struct nouveau_cli *cli = nouveau_cli(f);
struct nvif_client *client = >base;
@@ -271,23 +274,48 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct usif_object *object;
int ret = -ENOSYS;
 
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, true)))
+   return ret;
+
+   switch (args->v0.oclass) {
+   case NV_DMA_FROM_MEMORY:
+   case NV_DMA_TO_MEMORY:
+   case NV_DMA_IN_MEMORY:
+   return -EINVAL;
+   case NV_DEVICE: {
+   union {
+   struct nv_device_v0 v0;
+   } *args = data;
+
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, 
false)))
+   return ret;
+
+   args->v0.priv = false;
+   break;
+   }
+   default:
+   if (!parent_abi16)
+   return -EINVAL;
+   break;
+   }
+
if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
return -ENOMEM;
list_add(>head, >objects);
 
-   if (!(ret = nvif_unpack(ret, , , args->v0, 0, 0, true))) {
-   object->route = args->v0.route;
-   object->token = args->v0.token;
-   args->v0.route = NVDRM_OBJECT_USIF;
-   args->v0.token = (unsigned long)(void *)object;
-   ret = nvif_client_ioctl(client, argv, argc);
-   args->v0.token = object->token;
-   args->v0.route = object->route;
+   object->route = args->v0.route;
+   object->token = args->v0.token;
+   args->v0.route = NVDRM_OBJECT_USIF;
+   args->v0.token = (unsigned long)(void *)object;
+   ret = nvif_client_ioctl(client, argv, argc);
+   if (ret) {
+   usif_object_dtor(object);
+   return ret;
}
 
-   if (ret)
-   usif_object_dtor(object);
-   return ret;
+   args->v0.token = object->token;
+   args->v0.route = object->route;
+   return 0;
 }
 
 int
@@ -301,6 +329,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 
argc)
struct nvif_ioctl_v0 v0;
} *argv = data;
struct usif_object *object;
+   bool abi16 = false;
   

[Nouveau] [PATCH AUTOSEL 4.14 5/7] drm/nouveau/disp: power down unused DP links during init

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 6eaa1f3c59a707332e921e32782ffcad49915c5e ]

When booted with multiple displays attached, the EFI GOP driver on (at
least) Ampere, can leave DP links powered up that aren't being used to
display anything.  This confuses our tracking of SOR routing, with the
likely result being a failed modeset and display engine hang.

Fix this by (ab?)using the DisableLT IED script to power-down the link,
restoring HW to a state the driver expects.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c   | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h   | 1 +
 drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 9 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 5e51a5c1eb01..d11cb1f887f7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -418,7 +418,7 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
return ret;
 }
 
-static void
+void
 nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
 {
struct nvkm_dp *dp = nvkm_dp(outp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
index 495f665a0ee6..12d6ff4cfa95 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
@@ -32,6 +32,7 @@ struct nvkm_dp {
 
 int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,
struct nvkm_outp **);
+void nvkm_dp_disable(struct nvkm_outp *, struct nvkm_ior *);
 
 /* DPCD Receiver Capabilities */
 #define DPCD_RC00_DPCD_REV  0x0
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index bbba77ff9385..81c0f0513c74 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "outp.h"
+#include "dp.h"
 #include "ior.h"
 
 #include 
@@ -207,6 +208,14 @@ nvkm_outp_init_route(struct nvkm_outp *outp)
if (!ior->arm.head || ior->arm.proto != proto) {
OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,
 ior->arm.proto, proto);
+
+   /* The EFI GOP driver on Ampere can leave unused DP links 
routed,
+* which we don't expect.  The DisableLT IED script *should* get
+* us back to where we need to be.
+*/
+   if (ior->func->route.get && !ior->arm.head && outp->info.type 
== DCB_OUTPUT_DP)
+   nvkm_dp_disable(outp, ior);
+
return;
}
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 4.19 09/10] drm/nouveau: block a bunch of classes from userspace

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 148a8653789c01f159764ffcc3f370008966b42f ]

Long ago, there had been plans for making use of a bunch of these APIs
from userspace and there's various checks in place to stop misbehaving.

Countless other projects have occurred in the meantime, and the pieces
didn't finish falling into place for that to happen.

They will (hopefully) in the not-too-distant future, but it won't look
quite as insane.  The super checks are causing problems right now, and
are going to be removed.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 +
 drivers/gpu/drm/nouveau/nouveau_usif.c| 57 ++-
 .../gpu/drm/nouveau/nvkm/engine/device/user.c |  2 +-
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h 
b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index 4f5233107f5f..82daa2bf8415 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -4,7 +4,8 @@
 
 struct nv_device_v0 {
__u8  version;
-   __u8  pad01[7];
+   __u8  priv;
+   __u8  pad02[6];
__u64 device;   /* device identifier, ~0 for client default */
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 81999bed1e4a..f4f0a1772774 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -237,6 +237,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
ret = nvif_device_init(>base.object, 0, NV_DEVICE,
   &(struct nv_device_v0) {
.device = ~0,
+   .priv = true,
   }, sizeof(struct nv_device_v0),
   >device);
if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 9dc10b17ad34..5da1f4d223d7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -32,6 +32,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 struct usif_notify_p {
struct drm_pending_event base;
struct {
@@ -261,7 +264,7 @@ usif_object_dtor(struct usif_object *object)
 }
 
 static int
-usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
+usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 
argc, bool parent_abi16)
 {
struct nouveau_cli *cli = nouveau_cli(f);
struct nvif_client *client = >base;
@@ -271,23 +274,48 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct usif_object *object;
int ret = -ENOSYS;
 
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, true)))
+   return ret;
+
+   switch (args->v0.oclass) {
+   case NV_DMA_FROM_MEMORY:
+   case NV_DMA_TO_MEMORY:
+   case NV_DMA_IN_MEMORY:
+   return -EINVAL;
+   case NV_DEVICE: {
+   union {
+   struct nv_device_v0 v0;
+   } *args = data;
+
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, 
false)))
+   return ret;
+
+   args->v0.priv = false;
+   break;
+   }
+   default:
+   if (!parent_abi16)
+   return -EINVAL;
+   break;
+   }
+
if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
return -ENOMEM;
list_add(>head, >objects);
 
-   if (!(ret = nvif_unpack(ret, , , args->v0, 0, 0, true))) {
-   object->route = args->v0.route;
-   object->token = args->v0.token;
-   args->v0.route = NVDRM_OBJECT_USIF;
-   args->v0.token = (unsigned long)(void *)object;
-   ret = nvif_client_ioctl(client, argv, argc);
-   args->v0.token = object->token;
-   args->v0.route = object->route;
+   object->route = args->v0.route;
+   object->token = args->v0.token;
+   args->v0.route = NVDRM_OBJECT_USIF;
+   args->v0.token = (unsigned long)(void *)object;
+   ret = nvif_client_ioctl(client, argv, argc);
+   if (ret) {
+   usif_object_dtor(object);
+   return ret;
}
 
-   if (ret)
-   usif_object_dtor(object);
-   return ret;
+   args->v0.token = object->token;
+   args->v0.route = object->route;
+   return 0;
 }
 
 int
@@ -301,6 +329,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 
argc)
struct nvif_ioctl_v0 v0;
} *argv = data;
struct usif_object *object;
+   bool abi16 = false;
   

[Nouveau] [PATCH AUTOSEL 4.19 08/10] drm/nouveau/disp: power down unused DP links during init

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 6eaa1f3c59a707332e921e32782ffcad49915c5e ]

When booted with multiple displays attached, the EFI GOP driver on (at
least) Ampere, can leave DP links powered up that aren't being used to
display anything.  This confuses our tracking of SOR routing, with the
likely result being a failed modeset and display engine hang.

Fix this by (ab?)using the DisableLT IED script to power-down the link,
restoring HW to a state the driver expects.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c   | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h   | 1 +
 drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 9 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 818d21bd28d3..1d2837c5a8f2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -419,7 +419,7 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
return ret;
 }
 
-static void
+void
 nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
 {
struct nvkm_dp *dp = nvkm_dp(outp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
index 495f665a0ee6..12d6ff4cfa95 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
@@ -32,6 +32,7 @@ struct nvkm_dp {
 
 int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,
struct nvkm_outp **);
+void nvkm_dp_disable(struct nvkm_outp *, struct nvkm_ior *);
 
 /* DPCD Receiver Capabilities */
 #define DPCD_RC00_DPCD_REV  0x0
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index c62030c96fba..4b1c72fd8f03 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "outp.h"
+#include "dp.h"
 #include "ior.h"
 
 #include 
@@ -216,6 +217,14 @@ nvkm_outp_init_route(struct nvkm_outp *outp)
if (!ior->arm.head || ior->arm.proto != proto) {
OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,
 ior->arm.proto, proto);
+
+   /* The EFI GOP driver on Ampere can leave unused DP links 
routed,
+* which we don't expect.  The DisableLT IED script *should* get
+* us back to where we need to be.
+*/
+   if (ior->func->route.get && !ior->arm.head && outp->info.type 
== DCB_OUTPUT_DP)
+   nvkm_dp_disable(outp, ior);
+
return;
}
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 5.4 09/10] drm/nouveau: block a bunch of classes from userspace

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 148a8653789c01f159764ffcc3f370008966b42f ]

Long ago, there had been plans for making use of a bunch of these APIs
from userspace and there's various checks in place to stop misbehaving.

Countless other projects have occurred in the meantime, and the pieces
didn't finish falling into place for that to happen.

They will (hopefully) in the not-too-distant future, but it won't look
quite as insane.  The super checks are causing problems right now, and
are going to be removed.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 +
 drivers/gpu/drm/nouveau/nouveau_usif.c| 57 ++-
 .../gpu/drm/nouveau/nvkm/engine/device/user.c |  2 +-
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h 
b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index cd9a2e687bb6..08bda344e32f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -4,7 +4,8 @@
 
 struct nv_device_v0 {
__u8  version;
-   __u8  pad01[7];
+   __u8  priv;
+   __u8  pad02[6];
__u64 device;   /* device identifier, ~0 for client default */
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 5347e5bdee8c..3e7c55a2302c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -241,6 +241,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
ret = nvif_device_init(>base.object, 0, NV_DEVICE,
   &(struct nv_device_v0) {
.device = ~0,
+   .priv = true,
   }, sizeof(struct nv_device_v0),
   >device);
if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 9dc10b17ad34..5da1f4d223d7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -32,6 +32,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 struct usif_notify_p {
struct drm_pending_event base;
struct {
@@ -261,7 +264,7 @@ usif_object_dtor(struct usif_object *object)
 }
 
 static int
-usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
+usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 
argc, bool parent_abi16)
 {
struct nouveau_cli *cli = nouveau_cli(f);
struct nvif_client *client = >base;
@@ -271,23 +274,48 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct usif_object *object;
int ret = -ENOSYS;
 
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, true)))
+   return ret;
+
+   switch (args->v0.oclass) {
+   case NV_DMA_FROM_MEMORY:
+   case NV_DMA_TO_MEMORY:
+   case NV_DMA_IN_MEMORY:
+   return -EINVAL;
+   case NV_DEVICE: {
+   union {
+   struct nv_device_v0 v0;
+   } *args = data;
+
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, 
false)))
+   return ret;
+
+   args->v0.priv = false;
+   break;
+   }
+   default:
+   if (!parent_abi16)
+   return -EINVAL;
+   break;
+   }
+
if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
return -ENOMEM;
list_add(>head, >objects);
 
-   if (!(ret = nvif_unpack(ret, , , args->v0, 0, 0, true))) {
-   object->route = args->v0.route;
-   object->token = args->v0.token;
-   args->v0.route = NVDRM_OBJECT_USIF;
-   args->v0.token = (unsigned long)(void *)object;
-   ret = nvif_client_ioctl(client, argv, argc);
-   args->v0.token = object->token;
-   args->v0.route = object->route;
+   object->route = args->v0.route;
+   object->token = args->v0.token;
+   args->v0.route = NVDRM_OBJECT_USIF;
+   args->v0.token = (unsigned long)(void *)object;
+   ret = nvif_client_ioctl(client, argv, argc);
+   if (ret) {
+   usif_object_dtor(object);
+   return ret;
}
 
-   if (ret)
-   usif_object_dtor(object);
-   return ret;
+   args->v0.token = object->token;
+   args->v0.route = object->route;
+   return 0;
 }
 
 int
@@ -301,6 +329,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 
argc)
struct nvif_ioctl_v0 v0;
} *argv = data;
struct usif_object *object;
+   bool abi16 = false;
   

[Nouveau] [PATCH AUTOSEL 5.4 08/10] drm/nouveau/disp: power down unused DP links during init

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 6eaa1f3c59a707332e921e32782ffcad49915c5e ]

When booted with multiple displays attached, the EFI GOP driver on (at
least) Ampere, can leave DP links powered up that aren't being used to
display anything.  This confuses our tracking of SOR routing, with the
likely result being a failed modeset and display engine hang.

Fix this by (ab?)using the DisableLT IED script to power-down the link,
restoring HW to a state the driver expects.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c   | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h   | 1 +
 drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 9 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 818d21bd28d3..1d2837c5a8f2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -419,7 +419,7 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
return ret;
 }
 
-static void
+void
 nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
 {
struct nvkm_dp *dp = nvkm_dp(outp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
index 428b3f488f03..e484d0c3b0d4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
@@ -32,6 +32,7 @@ struct nvkm_dp {
 
 int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,
struct nvkm_outp **);
+void nvkm_dp_disable(struct nvkm_outp *, struct nvkm_ior *);
 
 /* DPCD Receiver Capabilities */
 #define DPCD_RC00_DPCD_REV  0x0
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index c62030c96fba..4b1c72fd8f03 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "outp.h"
+#include "dp.h"
 #include "ior.h"
 
 #include 
@@ -216,6 +217,14 @@ nvkm_outp_init_route(struct nvkm_outp *outp)
if (!ior->arm.head || ior->arm.proto != proto) {
OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,
 ior->arm.proto, proto);
+
+   /* The EFI GOP driver on Ampere can leave unused DP links 
routed,
+* which we don't expect.  The DisableLT IED script *should* get
+* us back to where we need to be.
+*/
+   if (ior->func->route.get && !ior->arm.head && outp->info.type 
== DCB_OUTPUT_DP)
+   nvkm_dp_disable(outp, ior);
+
return;
}
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 5.10 16/18] drm/nouveau/kms/nv50: workaround EFI GOP window channel format differences

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit e78b1b545c6cfe9f87fc577128e00026fff230ba ]

Should fix some initial modeset failures on (at least) Ampere boards.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 27 +
 drivers/gpu/drm/nouveau/dispnv50/head.c | 13 
 drivers/gpu/drm/nouveau/dispnv50/head.h |  1 +
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 5b8cabb099eb..c2d34c91e840 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2202,6 +2202,33 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state 
*state)
interlock[NV50_DISP_INTERLOCK_CORE] = 0;
}
 
+   /* Finish updating head(s)...
+*
+* NVD is rather picky about both where window assignments can change,
+* *and* about certain core and window channel states matching.
+*
+* The EFI GOP driver on newer GPUs configures window channels with a
+* different output format to what we do, and the core channel update
+* in the assign_windows case above would result in a state mismatch.
+*
+* Delay some of the head update until after that point to workaround
+* the issue.  This only affects the initial modeset.
+*
+* TODO: handle this better when adding flexible window mapping
+*/
+   for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, 
new_crtc_state, i) {
+   struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
+   struct nv50_head *head = nv50_head(crtc);
+
+   NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name,
+ asyh->set.mask, asyh->clr.mask);
+
+   if (asyh->set.mask) {
+   nv50_head_flush_set_wndw(head, asyh);
+   interlock[NV50_DISP_INTERLOCK_CORE] = 1;
+   }
+   }
+
/* Update plane(s). */
for_each_new_plane_in_state(state, plane, new_plane_state, i) {
struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
b/drivers/gpu/drm/nouveau/dispnv50/head.c
index 841edfaf5b9d..61826cac3061 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -49,11 +49,8 @@ nv50_head_flush_clr(struct nv50_head *head,
 }
 
 void
-nv50_head_flush_set(struct nv50_head *head, struct nv50_head_atom *asyh)
+nv50_head_flush_set_wndw(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-   if (asyh->set.view   ) head->func->view(head, asyh);
-   if (asyh->set.mode   ) head->func->mode(head, asyh);
-   if (asyh->set.core   ) head->func->core_set(head, asyh);
if (asyh->set.olut   ) {
asyh->olut.offset = nv50_lut_load(>olut,
  asyh->olut.buffer,
@@ -61,6 +58,14 @@ nv50_head_flush_set(struct nv50_head *head, struct 
nv50_head_atom *asyh)
  asyh->olut.load);
head->func->olut_set(head, asyh);
}
+}
+
+void
+nv50_head_flush_set(struct nv50_head *head, struct nv50_head_atom *asyh)
+{
+   if (asyh->set.view   ) head->func->view(head, asyh);
+   if (asyh->set.mode   ) head->func->mode(head, asyh);
+   if (asyh->set.core   ) head->func->core_set(head, asyh);
if (asyh->set.curs   ) head->func->curs_set(head, asyh);
if (asyh->set.base   ) head->func->base(head, asyh);
if (asyh->set.ovly   ) head->func->ovly(head, asyh);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.h 
b/drivers/gpu/drm/nouveau/dispnv50/head.h
index dae841dc05fd..0bac6be9ba34 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.h
@@ -21,6 +21,7 @@ struct nv50_head {
 
 struct nv50_head *nv50_head_create(struct drm_device *, int index);
 void nv50_head_flush_set(struct nv50_head *head, struct nv50_head_atom *asyh);
+void nv50_head_flush_set_wndw(struct nv50_head *head, struct nv50_head_atom 
*asyh);
 void nv50_head_flush_clr(struct nv50_head *head,
 struct nv50_head_atom *asyh, bool flush);
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 5.10 17/18] drm/nouveau: block a bunch of classes from userspace

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 148a8653789c01f159764ffcc3f370008966b42f ]

Long ago, there had been plans for making use of a bunch of these APIs
from userspace and there's various checks in place to stop misbehaving.

Countless other projects have occurred in the meantime, and the pieces
didn't finish falling into place for that to happen.

They will (hopefully) in the not-too-distant future, but it won't look
quite as insane.  The super checks are causing problems right now, and
are going to be removed.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 +
 drivers/gpu/drm/nouveau/nouveau_usif.c| 57 ++-
 .../gpu/drm/nouveau/nvkm/engine/device/user.c |  2 +-
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h 
b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index cd9a2e687bb6..08bda344e32f 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -4,7 +4,8 @@
 
 struct nv_device_v0 {
__u8  version;
-   __u8  pad01[7];
+   __u8  priv;
+   __u8  pad02[6];
__u64 device;   /* device identifier, ~0 for client default */
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 42fc5c813a9b..12b00f1d66de 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -242,6 +242,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
ret = nvif_device_ctor(>base.object, "drmDevice", 0, NV_DEVICE,
   &(struct nv_device_v0) {
.device = ~0,
+   .priv = true,
   }, sizeof(struct nv_device_v0),
   >device);
if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 9dc10b17ad34..5da1f4d223d7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -32,6 +32,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 struct usif_notify_p {
struct drm_pending_event base;
struct {
@@ -261,7 +264,7 @@ usif_object_dtor(struct usif_object *object)
 }
 
 static int
-usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
+usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 
argc, bool parent_abi16)
 {
struct nouveau_cli *cli = nouveau_cli(f);
struct nvif_client *client = >base;
@@ -271,23 +274,48 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct usif_object *object;
int ret = -ENOSYS;
 
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, true)))
+   return ret;
+
+   switch (args->v0.oclass) {
+   case NV_DMA_FROM_MEMORY:
+   case NV_DMA_TO_MEMORY:
+   case NV_DMA_IN_MEMORY:
+   return -EINVAL;
+   case NV_DEVICE: {
+   union {
+   struct nv_device_v0 v0;
+   } *args = data;
+
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, 
false)))
+   return ret;
+
+   args->v0.priv = false;
+   break;
+   }
+   default:
+   if (!parent_abi16)
+   return -EINVAL;
+   break;
+   }
+
if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
return -ENOMEM;
list_add(>head, >objects);
 
-   if (!(ret = nvif_unpack(ret, , , args->v0, 0, 0, true))) {
-   object->route = args->v0.route;
-   object->token = args->v0.token;
-   args->v0.route = NVDRM_OBJECT_USIF;
-   args->v0.token = (unsigned long)(void *)object;
-   ret = nvif_client_ioctl(client, argv, argc);
-   args->v0.token = object->token;
-   args->v0.route = object->route;
+   object->route = args->v0.route;
+   object->token = args->v0.token;
+   args->v0.route = NVDRM_OBJECT_USIF;
+   args->v0.token = (unsigned long)(void *)object;
+   ret = nvif_client_ioctl(client, argv, argc);
+   if (ret) {
+   usif_object_dtor(object);
+   return ret;
}
 
-   if (ret)
-   usif_object_dtor(object);
-   return ret;
+   args->v0.token = object->token;
+   args->v0.route = object->route;
+   return 0;
 }
 
 int
@@ -301,6 +329,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 
argc)
struct nvif_ioctl_v0 v0;
} *argv = data;
struct usif_object *object;
+   b

[Nouveau] [PATCH AUTOSEL 5.10 15/18] drm/nouveau/disp: power down unused DP links during init

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 6eaa1f3c59a707332e921e32782ffcad49915c5e ]

When booted with multiple displays attached, the EFI GOP driver on (at
least) Ampere, can leave DP links powered up that aren't being used to
display anything.  This confuses our tracking of SOR routing, with the
likely result being a failed modeset and display engine hang.

Fix this by (ab?)using the DisableLT IED script to power-down the link,
restoring HW to a state the driver expects.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c   | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h   | 1 +
 drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 9 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 3800aeb507d0..2a7b8bc3ec4d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -419,7 +419,7 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
return ret;
 }
 
-static void
+void
 nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
 {
struct nvkm_dp *dp = nvkm_dp(outp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
index 428b3f488f03..e484d0c3b0d4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
@@ -32,6 +32,7 @@ struct nvkm_dp {
 
 int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,
struct nvkm_outp **);
+void nvkm_dp_disable(struct nvkm_outp *, struct nvkm_ior *);
 
 /* DPCD Receiver Capabilities */
 #define DPCD_RC00_DPCD_REV  0x0
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index dffcac249211..129982fef7ef 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "outp.h"
+#include "dp.h"
 #include "ior.h"
 
 #include 
@@ -257,6 +258,14 @@ nvkm_outp_init_route(struct nvkm_outp *outp)
if (!ior->arm.head || ior->arm.proto != proto) {
OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,
 ior->arm.proto, proto);
+
+   /* The EFI GOP driver on Ampere can leave unused DP links 
routed,
+* which we don't expect.  The DisableLT IED script *should* get
+* us back to where we need to be.
+*/
+   if (ior->func->route.get && !ior->arm.head && outp->info.type 
== DCB_OUTPUT_DP)
+   nvkm_dp_disable(outp, ior);
+
return;
}
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 5.13 23/26] drm/nouveau: block a bunch of classes from userspace

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 148a8653789c01f159764ffcc3f370008966b42f ]

Long ago, there had been plans for making use of a bunch of these APIs
from userspace and there's various checks in place to stop misbehaving.

Countless other projects have occurred in the meantime, and the pieces
didn't finish falling into place for that to happen.

They will (hopefully) in the not-too-distant future, but it won't look
quite as insane.  The super checks are causing problems right now, and
are going to be removed.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvif/cl0080.h |  3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 +
 drivers/gpu/drm/nouveau/nouveau_usif.c| 57 ++-
 .../gpu/drm/nouveau/nvkm/engine/device/user.c |  2 +-
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h 
b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
index 0b86c44878e0..59759c4fb62e 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -4,7 +4,8 @@
 
 struct nv_device_v0 {
__u8  version;
-   __u8  pad01[7];
+   __u8  priv;
+   __u8  pad02[6];
__u64 device;   /* device identifier, ~0 for client default */
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 885815ea917f..5cadd7c5a252 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -242,6 +242,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
ret = nvif_device_ctor(>base.object, "drmDevice", 0, NV_DEVICE,
   &(struct nv_device_v0) {
.device = ~0,
+   .priv = true,
   }, sizeof(struct nv_device_v0),
   >device);
if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c 
b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 9dc10b17ad34..5da1f4d223d7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -32,6 +32,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 struct usif_notify_p {
struct drm_pending_event base;
struct {
@@ -261,7 +264,7 @@ usif_object_dtor(struct usif_object *object)
 }
 
 static int
-usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
+usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 
argc, bool parent_abi16)
 {
struct nouveau_cli *cli = nouveau_cli(f);
struct nvif_client *client = >base;
@@ -271,23 +274,48 @@ usif_object_new(struct drm_file *f, void *data, u32 size, 
void *argv, u32 argc)
struct usif_object *object;
int ret = -ENOSYS;
 
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, true)))
+   return ret;
+
+   switch (args->v0.oclass) {
+   case NV_DMA_FROM_MEMORY:
+   case NV_DMA_TO_MEMORY:
+   case NV_DMA_IN_MEMORY:
+   return -EINVAL;
+   case NV_DEVICE: {
+   union {
+   struct nv_device_v0 v0;
+   } *args = data;
+
+   if ((ret = nvif_unpack(ret, , , args->v0, 0, 0, 
false)))
+   return ret;
+
+   args->v0.priv = false;
+   break;
+   }
+   default:
+   if (!parent_abi16)
+   return -EINVAL;
+   break;
+   }
+
if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
return -ENOMEM;
list_add(>head, >objects);
 
-   if (!(ret = nvif_unpack(ret, , , args->v0, 0, 0, true))) {
-   object->route = args->v0.route;
-   object->token = args->v0.token;
-   args->v0.route = NVDRM_OBJECT_USIF;
-   args->v0.token = (unsigned long)(void *)object;
-   ret = nvif_client_ioctl(client, argv, argc);
-   args->v0.token = object->token;
-   args->v0.route = object->route;
+   object->route = args->v0.route;
+   object->token = args->v0.token;
+   args->v0.route = NVDRM_OBJECT_USIF;
+   args->v0.token = (unsigned long)(void *)object;
+   ret = nvif_client_ioctl(client, argv, argc);
+   if (ret) {
+   usif_object_dtor(object);
+   return ret;
}
 
-   if (ret)
-   usif_object_dtor(object);
-   return ret;
+   args->v0.token = object->token;
+   args->v0.route = object->route;
+   return 0;
 }
 
 int
@@ -301,6 +329,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 
argc)
struct nvif_ioctl_v0 v0;
} *argv = data;
struct usif_object *object;
+   b

[Nouveau] [PATCH AUTOSEL 5.13 22/26] drm/nouveau/kms/nv50: workaround EFI GOP window channel format differences

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit e78b1b545c6cfe9f87fc577128e00026fff230ba ]

Should fix some initial modeset failures on (at least) Ampere boards.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 27 +
 drivers/gpu/drm/nouveau/dispnv50/head.c | 13 
 drivers/gpu/drm/nouveau/dispnv50/head.h |  1 +
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 1c9c0cdf85db..578aaac2e277 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2235,6 +2235,33 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state 
*state)
interlock[NV50_DISP_INTERLOCK_CORE] = 0;
}
 
+   /* Finish updating head(s)...
+*
+* NVD is rather picky about both where window assignments can change,
+* *and* about certain core and window channel states matching.
+*
+* The EFI GOP driver on newer GPUs configures window channels with a
+* different output format to what we do, and the core channel update
+* in the assign_windows case above would result in a state mismatch.
+*
+* Delay some of the head update until after that point to workaround
+* the issue.  This only affects the initial modeset.
+*
+* TODO: handle this better when adding flexible window mapping
+*/
+   for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, 
new_crtc_state, i) {
+   struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
+   struct nv50_head *head = nv50_head(crtc);
+
+   NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name,
+ asyh->set.mask, asyh->clr.mask);
+
+   if (asyh->set.mask) {
+   nv50_head_flush_set_wndw(head, asyh);
+   interlock[NV50_DISP_INTERLOCK_CORE] = 1;
+   }
+   }
+
/* Update plane(s). */
for_each_new_plane_in_state(state, plane, new_plane_state, i) {
struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
b/drivers/gpu/drm/nouveau/dispnv50/head.c
index ec361d17e900..d66f97280282 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -50,11 +50,8 @@ nv50_head_flush_clr(struct nv50_head *head,
 }
 
 void
-nv50_head_flush_set(struct nv50_head *head, struct nv50_head_atom *asyh)
+nv50_head_flush_set_wndw(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-   if (asyh->set.view   ) head->func->view(head, asyh);
-   if (asyh->set.mode   ) head->func->mode(head, asyh);
-   if (asyh->set.core   ) head->func->core_set(head, asyh);
if (asyh->set.olut   ) {
asyh->olut.offset = nv50_lut_load(>olut,
  asyh->olut.buffer,
@@ -62,6 +59,14 @@ nv50_head_flush_set(struct nv50_head *head, struct 
nv50_head_atom *asyh)
  asyh->olut.load);
head->func->olut_set(head, asyh);
}
+}
+
+void
+nv50_head_flush_set(struct nv50_head *head, struct nv50_head_atom *asyh)
+{
+   if (asyh->set.view   ) head->func->view(head, asyh);
+   if (asyh->set.mode   ) head->func->mode(head, asyh);
+   if (asyh->set.core   ) head->func->core_set(head, asyh);
if (asyh->set.curs   ) head->func->curs_set(head, asyh);
if (asyh->set.base   ) head->func->base(head, asyh);
if (asyh->set.ovly   ) head->func->ovly(head, asyh);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.h 
b/drivers/gpu/drm/nouveau/dispnv50/head.h
index dae841dc05fd..0bac6be9ba34 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.h
@@ -21,6 +21,7 @@ struct nv50_head {
 
 struct nv50_head *nv50_head_create(struct drm_device *, int index);
 void nv50_head_flush_set(struct nv50_head *head, struct nv50_head_atom *asyh);
+void nv50_head_flush_set_wndw(struct nv50_head *head, struct nv50_head_atom 
*asyh);
 void nv50_head_flush_clr(struct nv50_head *head,
 struct nv50_head_atom *asyh, bool flush);
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 5.13 21/26] drm/nouveau/disp: power down unused DP links during init

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 6eaa1f3c59a707332e921e32782ffcad49915c5e ]

When booted with multiple displays attached, the EFI GOP driver on (at
least) Ampere, can leave DP links powered up that aren't being used to
display anything.  This confuses our tracking of SOR routing, with the
likely result being a failed modeset and display engine hang.

Fix this by (ab?)using the DisableLT IED script to power-down the link,
restoring HW to a state the driver expects.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c   | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h   | 1 +
 drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | 9 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 55fbfe28c6dc..9669472a2749 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -440,7 +440,7 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
return ret;
 }
 
-static void
+void
 nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
 {
struct nvkm_dp *dp = nvkm_dp(outp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
index 428b3f488f03..e484d0c3b0d4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
@@ -32,6 +32,7 @@ struct nvkm_dp {
 
 int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,
struct nvkm_outp **);
+void nvkm_dp_disable(struct nvkm_outp *, struct nvkm_ior *);
 
 /* DPCD Receiver Capabilities */
 #define DPCD_RC00_DPCD_REV  0x0
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index dffcac249211..129982fef7ef 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "outp.h"
+#include "dp.h"
 #include "ior.h"
 
 #include 
@@ -257,6 +258,14 @@ nvkm_outp_init_route(struct nvkm_outp *outp)
if (!ior->arm.head || ior->arm.proto != proto) {
OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,
 ior->arm.proto, proto);
+
+   /* The EFI GOP driver on Ampere can leave unused DP links 
routed,
+* which we don't expect.  The DisableLT IED script *should* get
+* us back to where we need to be.
+*/
+   if (ior->func->route.get && !ior->arm.head && outp->info.type 
== DCB_OUTPUT_DP)
+   nvkm_dp_disable(outp, ior);
+
return;
}
 
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 5.13 20/26] drm/nouveau: recognise GA107

2021-08-23 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit fa25f28ef2cef19bc9ffeb827b8ecbf48af7f892 ]

Still no GA106 as I don't have HW to verif.

Signed-off-by: Ben Skeggs 
Reviewed-by: Lyude Paul 
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/nouveau/nvkm/engine/device/base.c | 21 +++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index b930f539feec..93ddf63d1114 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -2624,6 +2624,26 @@ nv174_chipset = {
.dma  = { 0x0001, gv100_dma_new },
 };
 
+static const struct nvkm_device_chip
+nv177_chipset = {
+   .name = "GA107",
+   .bar  = { 0x0001, tu102_bar_new },
+   .bios = { 0x0001, nvkm_bios_new },
+   .devinit  = { 0x0001, ga100_devinit_new },
+   .fb   = { 0x0001, ga102_fb_new },
+   .gpio = { 0x0001, ga102_gpio_new },
+   .i2c  = { 0x0001, gm200_i2c_new },
+   .imem = { 0x0001, nv50_instmem_new },
+   .mc   = { 0x0001, ga100_mc_new },
+   .mmu  = { 0x0001, tu102_mmu_new },
+   .pci  = { 0x0001, gp100_pci_new },
+   .privring = { 0x0001, gm200_privring_new },
+   .timer= { 0x0001, gk20a_timer_new },
+   .top  = { 0x0001, ga100_top_new },
+   .disp = { 0x0001, ga102_disp_new },
+   .dma  = { 0x0001, gv100_dma_new },
+};
+
 static int
 nvkm_device_event_ctor(struct nvkm_object *object, void *data, u32 size,
   struct nvkm_notify *notify)
@@ -3049,6 +3069,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
case 0x168: device->chip = _chipset; break;
case 0x172: device->chip = _chipset; break;
case 0x174: device->chip = _chipset; break;
+   case 0x177: device->chip = _chipset; break;
default:
if (nvkm_boolopt(device->cfgopt, 
"NvEnableUnsupportedChipsets", false)) {
switch (device->chipset) {
-- 
2.30.2



[Nouveau] [PATCH AUTOSEL 4.4 2/2] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 78f520d05de9..58c310930bf2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -458,7 +458,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
@@ -478,7 +478,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.9 2/2] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index a2e6a81669e7..94b7798bdea4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -447,7 +447,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
@@ -467,7 +467,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.14 2/2] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index e427f80344c4..a2d770acd10a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -450,7 +450,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
@@ -470,7 +470,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.19 2/2] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7214022dfb91..d230536e7086 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -512,7 +512,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
@@ -532,7 +532,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 2/3] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index f8015e0318d7..f7603be569fc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -542,7 +542,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
@@ -562,7 +562,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 3/4] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7daa12eec01b..b4946b595d86 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -590,7 +590,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
@@ -610,7 +610,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
 
/* Don't waste time looping if the object is coherent */
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.12 4/5] drm/nouveau: fix dma_address check for CPU/GPU sync

2021-06-28 Thread Sasha Levin
From: Christian König 

[ Upstream commit d330099115597bbc238d6758a4930e72b49ea9ba ]

AGP for example doesn't have a dma_address array.

Signed-off-by: Christian König 
Acked-by: Alex Deucher 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210614110517.1624-1-christian.koe...@amd.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index f2720a006199..0a47a2a5553d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -549,7 +549,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
int i, j;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
if (!ttm_dma->pages) {
NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
@@ -585,7 +585,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
int i, j;
 
-   if (!ttm_dma)
+   if (!ttm_dma || !ttm_dma->dma_address)
return;
if (!ttm_dma->pages) {
NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
-- 
2.30.2

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.11 39/44] nouveau: Skip unvailable ttm page entries

2021-03-25 Thread Sasha Levin
From: Tobias Klausmann 

[ Upstream commit e94c55b8e0a0bbe9a026250cf31e2fa45957d776 ]

Starting with commit f295c8cfec833c2707ff1512da10d65386dde7af
("drm/nouveau: fix dma syncing warning with debugging on.")
the following oops occures:

   BUG: kernel NULL pointer dereference, address: 
   #PF: supervisor read access in kernel mode
   #PF: error_code(0x) - not-present page
   PGD 0 P4D 0
   Oops:  [#1] PREEMPT SMP PTI
   CPU: 6 PID: 1013 Comm: Xorg.bin Tainted: G E 5.11.0-desktop-rc0+ #2
   Hardware name: Acer Aspire VN7-593G/Pluto_KLS, BIOS V1.11 08/01/2018
   RIP: 0010:nouveau_bo_sync_for_device+0x40/0xb0 [nouveau]
   Call Trace:
nouveau_bo_validate+0x5d/0x80 [nouveau]
nouveau_gem_ioctl_pushbuf+0x662/0x1120 [nouveau]
? nouveau_gem_ioctl_new+0xf0/0xf0 [nouveau]
drm_ioctl_kernel+0xa6/0xf0 [drm]
drm_ioctl+0x1f4/0x3a0 [drm]
? nouveau_gem_ioctl_new+0xf0/0xf0 [nouveau]
nouveau_drm_ioctl+0x50/0xa0 [nouveau]
__x64_sys_ioctl+0x7e/0xb0
do_syscall_64+0x33/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xae
   ---[ end trace ccfb1e7f4064374f ]---
   RIP: 0010:nouveau_bo_sync_for_device+0x40/0xb0 [nouveau]

The underlying problem is not introduced by the commit, yet it uncovered the
underlying issue. The cited commit relies on valid pages. This is not given for
due to some bugs. For now, just warn and work around the issue by just ignoring
the bad ttm objects.
Below is some debug info gathered while debugging this issue:

nouveau :01:00.0: DRM: ttm_dma->num_pages: 2048
nouveau :01:00.0: DRM: ttm_dma->pages is NULL
nouveau :01:00.0: DRM: ttm_dma: e96058e7
nouveau :01:00.0: DRM: ttm_dma->page_flags:
nouveau :01:00.0: DRM: ttm_dma:   Populated: 1
nouveau :01:00.0: DRM: ttm_dma:   No Retry: 0
nouveau :01:00.0: DRM: ttm_dma:   SG: 256
nouveau :01:00.0: DRM: ttm_dma:   Zero Alloc: 0
nouveau :01:00.0: DRM: ttm_dma:   Swapped: 0

Signed-off-by: Tobias Klausmann 
Signed-off-by: Dave Airlie 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210313222159.3346-1-tobias.klausm...@freenet.de
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index f1c9a22083be..e05565f284dc 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -551,6 +551,10 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
 
if (!ttm_dma)
return;
+   if (!ttm_dma->pages) {
+   NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
+   return;
+   }
 
/* Don't waste time looping if the object is coherent */
if (nvbo->force_coherent)
@@ -583,6 +587,10 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
 
if (!ttm_dma)
return;
+   if (!ttm_dma->pages) {
+   NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
+   return;
+   }
 
/* Don't waste time looping if the object is coherent */
if (nvbo->force_coherent)
-- 
2.30.1

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 04/25] drm/nouveau/nvif: fix method count when pushing an array

2021-02-02 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit d502297008142645edf5c791af424ed321e5da84 ]

Reported-by: Lyude Paul 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/include/nvif/push.h | 216 ++--
 1 file changed, 108 insertions(+), 108 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/push.h 
b/drivers/gpu/drm/nouveau/include/nvif/push.h
index 168d7694ede5c..6d3a8a3d2087b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/push.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/push.h
@@ -123,131 +123,131 @@ PUSH_KICK(struct nvif_push *push)
 } while(0)
 #endif
 
-#define PUSH_1(X,f,ds,n,c,o,p,s,mA,dA) do {\
-   PUSH_##o##_HDR((p), s, mA, (c)+(n));   \
-   PUSH_##f(X, (p), X##mA, 1, o, (dA), ds, "");   \
+#define PUSH_1(X,f,ds,n,o,p,s,mA,dA) do { \
+   PUSH_##o##_HDR((p), s, mA, (ds)+(n)); \
+   PUSH_##f(X, (p), X##mA, 1, o, (dA), ds, "");  \
 } while(0)
-#define PUSH_2(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PUSH_ASSERT((mB) - (mA) == (1?PUSH_##o##_INC), "mthd1");   \
-   PUSH_1(X, DATA_, 1, ds, (c)+(n), o, (p), s, X##mA, (dA), ##a); \
-   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");   \
+#define PUSH_2(X,f,ds,n,o,p,s,mB,dB,mA,dA,a...) do {  \
+   PUSH_ASSERT((mB) - (mA) == (1?PUSH_##o##_INC), "mthd1");  \
+   PUSH_1(X, DATA_, 1, (ds) + (n), o, (p), s, X##mA, (dA), ##a); \
+   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");  \
 } while(0)
-#define PUSH_3(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd2");   \
-   PUSH_2(X, DATA_, 1, ds, (c)+(n), o, (p), s, X##mA, (dA), ##a); \
-   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");   \
+#define PUSH_3(X,f,ds,n,o,p,s,mB,dB,mA,dA,a...) do {  \
+   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd2");  \
+   PUSH_2(X, DATA_, 1, (ds) + (n), o, (p), s, X##mA, (dA), ##a); \
+   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");  \
 } while(0)
-#define PUSH_4(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd3");   \
-   PUSH_3(X, DATA_, 1, ds, (c)+(n), o, (p), s, X##mA, (dA), ##a); \
-   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");   \
+#define PUSH_4(X,f,ds,n,o,p,s,mB,dB,mA,dA,a...) do {  \
+   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd3");  \
+   PUSH_3(X, DATA_, 1, (ds) + (n), o, (p), s, X##mA, (dA), ##a); \
+   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");  \
 } while(0)
-#define PUSH_5(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd4");   \
-   PUSH_4(X, DATA_, 1, ds, (c)+(n), o, (p), s, X##mA, (dA), ##a); \
-   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");   \
+#define PUSH_5(X,f,ds,n,o,p,s,mB,dB,mA,dA,a...) do {  \
+   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd4");  \
+   PUSH_4(X, DATA_, 1, (ds) + (n), o, (p), s, X##mA, (dA), ##a); \
+   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");  \
 } while(0)
-#define PUSH_6(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd5");   \
-   PUSH_5(X, DATA_, 1, ds, (c)+(n), o, (p), s, X##mA, (dA), ##a); \
-   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");   \
+#define PUSH_6(X,f,ds,n,o,p,s,mB,dB,mA,dA,a...) do {  \
+   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd5");  \
+   PUSH_5(X, DATA_, 1, (ds) + (n), o, (p), s, X##mA, (dA), ##a); \
+   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");  \
 } while(0)
-#define PUSH_7(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd6");   \
-   PUSH_6(X, DATA_, 1, ds, (c)+(n), o, (p), s, X##mA, (dA), ##a); \
-   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");   \
+#define PUSH_7(X,f,ds,n,o,p,s,mB,dB,mA,dA,a...) do {  \
+   PUSH_ASSERT((mB) - (mA) == (0?PUSH_##o##_INC), "mthd6");  \
+   PUSH_6(X, DATA_, 1, (ds) + (n), o, (p), s, X##mA, (dA), ##a); \
+   PUSH_##f(X, (p), X##mB, 0, o, (dB), ds, "");  \
 } while(0)
-#define PUSH_8(X,f,ds,n,c,o,p,s,mB,dB,mA,dA,a...) do { \
-   PU

[Nouveau] [PATCH AUTOSEL 4.4 4/4] drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit ba6e9ab0fcf3d76e3952deb12b5f993991621d9c ]

Noticed while debugging GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c
index 7cac8fe372b6b..a3cede8df4fd9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c
@@ -33,7 +33,7 @@ static void
 gm204_i2c_aux_fini(struct gm204_i2c_aux *aux)
 {
struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0031, 0x);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0071, 0x);
 }
 
 static int
@@ -54,10 +54,10 @@ gm204_i2c_aux_init(struct gm204_i2c_aux *aux)
AUX_ERR(>base, "begin idle timeout %08x", ctrl);
return -EBUSY;
}
-   } while (ctrl & 0x0301);
+   } while (ctrl & 0x0701);
 
/* set some magic, and wait up to 1ms for it to appear */
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0030, ureq);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0070, ureq);
timeout = 1000;
do {
ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm204_i2c_aux_init(struct gm204_i2c_aux *aux)
gm204_i2c_aux_fini(aux);
return -EBUSY;
}
-   } while ((ctrl & 0x0300) != urep);
+   } while ((ctrl & 0x0700) != urep);
 
return 0;
 }
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.4 3/4] drm/nouveau/bios: fix issue shadowing expansion ROMs

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 402a89660e9dc880710b12773076a336c9dab3d7 ]

This issue has generally been covered up by the presence of additional
expansion ROMs after the ones we're interested in, with header fetches
of subsequent images loading enough of the ROM to hide the issue.

Noticed on GA102, which lacks a type 0x70 image compared to TU102,.

[  906.364197] nouveau :09:00.0: bios: : type 00, 65024 bytes
[  906.381205] nouveau :09:00.0: bios: fe00: type 03, 91648 bytes
[  906.405213] nouveau :09:00.0: bios: 00026400: type e0, 22016 bytes
[  906.410984] nouveau :09:00.0: bios: 0002ba00: type e0, 366080 bytes

vs

[   22.961901] nouveau :09:00.0: bios: : type 00, 60416 bytes
[   22.984174] nouveau :09:00.0: bios: ec00: type 03, 71168 bytes
[   23.010446] nouveau :09:00.0: bios: 00020200: type e0, 48128 bytes
[   23.028220] nouveau :09:00.0: bios: 0002be00: type e0, 140800 bytes
[   23.080196] nouveau :09:00.0: bios: 0004e400: type 70, 7168 bytes

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 7deb81b6dbac6..4b571cc6bc70f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
   image.base, image.type, image.size);
 
-   if (!shadow_fetch(bios, mthd, image.size)) {
+   if (!shadow_fetch(bios, mthd, image.base + image.size)) {
nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
return 0;
}
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.9 4/4] drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit ba6e9ab0fcf3d76e3952deb12b5f993991621d9c ]

Noticed while debugging GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
index a5783f4d972e3..c49795e779be4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
@@ -33,7 +33,7 @@ static void
 gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
 {
struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0031, 0x);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0071, 0x);
 }
 
 static int
@@ -54,10 +54,10 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
AUX_ERR(>base, "begin idle timeout %08x", ctrl);
return -EBUSY;
}
-   } while (ctrl & 0x0301);
+   } while (ctrl & 0x0701);
 
/* set some magic, and wait up to 1ms for it to appear */
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0030, ureq);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0070, ureq);
timeout = 1000;
do {
ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
gm200_i2c_aux_fini(aux);
return -EBUSY;
}
-   } while ((ctrl & 0x0300) != urep);
+   } while ((ctrl & 0x0700) != urep);
 
return 0;
 }
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.9 3/4] drm/nouveau/bios: fix issue shadowing expansion ROMs

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 402a89660e9dc880710b12773076a336c9dab3d7 ]

This issue has generally been covered up by the presence of additional
expansion ROMs after the ones we're interested in, with header fetches
of subsequent images loading enough of the ROM to hide the issue.

Noticed on GA102, which lacks a type 0x70 image compared to TU102,.

[  906.364197] nouveau :09:00.0: bios: : type 00, 65024 bytes
[  906.381205] nouveau :09:00.0: bios: fe00: type 03, 91648 bytes
[  906.405213] nouveau :09:00.0: bios: 00026400: type e0, 22016 bytes
[  906.410984] nouveau :09:00.0: bios: 0002ba00: type e0, 366080 bytes

vs

[   22.961901] nouveau :09:00.0: bios: : type 00, 60416 bytes
[   22.984174] nouveau :09:00.0: bios: ec00: type 03, 71168 bytes
[   23.010446] nouveau :09:00.0: bios: 00020200: type e0, 48128 bytes
[   23.028220] nouveau :09:00.0: bios: 0002be00: type e0, 140800 bytes
[   23.080196] nouveau :09:00.0: bios: 0004e400: type 70, 7168 bytes

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 7deb81b6dbac6..4b571cc6bc70f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
   image.base, image.type, image.size);
 
-   if (!shadow_fetch(bios, mthd, image.size)) {
+   if (!shadow_fetch(bios, mthd, image.base + image.size)) {
nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
return 0;
}
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.14 9/9] drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit ba6e9ab0fcf3d76e3952deb12b5f993991621d9c ]

Noticed while debugging GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
index edb6148cbca04..d0e80ad526845 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
@@ -33,7 +33,7 @@ static void
 gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
 {
struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0031, 0x);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0071, 0x);
 }
 
 static int
@@ -54,10 +54,10 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
AUX_ERR(>base, "begin idle timeout %08x", ctrl);
return -EBUSY;
}
-   } while (ctrl & 0x0301);
+   } while (ctrl & 0x0701);
 
/* set some magic, and wait up to 1ms for it to appear */
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0030, ureq);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0070, ureq);
timeout = 1000;
do {
ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
gm200_i2c_aux_fini(aux);
return -EBUSY;
}
-   } while ((ctrl & 0x0300) != urep);
+   } while ((ctrl & 0x0700) != urep);
 
return 0;
 }
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.14 8/9] drm/nouveau/privring: ack interrupts the same way as RM

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit e05e06cd34f5311f677294a08b609acfbc315236 ]

Whatever it is that we were doing before doesn't work on Ampere.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c | 10 +++---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c | 10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
index d80dbc8f09b20..55a4ea4393c62 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0400));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gf100_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0400));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gf100_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0400));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0400), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gf100_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x121c4c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x121c4c) & 0x003f))
+   break;
+   );
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
index 9025ed1bd2a99..4caf3ef087e1d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0800));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gk104_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0800));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gk104_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0800));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0800), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gk104_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x12004c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x12004c) & 0x003f))
+   break;
+   );
 }
 
 static int
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.14 7/9] drm/nouveau/bios: fix issue shadowing expansion ROMs

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 402a89660e9dc880710b12773076a336c9dab3d7 ]

This issue has generally been covered up by the presence of additional
expansion ROMs after the ones we're interested in, with header fetches
of subsequent images loading enough of the ROM to hide the issue.

Noticed on GA102, which lacks a type 0x70 image compared to TU102,.

[  906.364197] nouveau :09:00.0: bios: : type 00, 65024 bytes
[  906.381205] nouveau :09:00.0: bios: fe00: type 03, 91648 bytes
[  906.405213] nouveau :09:00.0: bios: 00026400: type e0, 22016 bytes
[  906.410984] nouveau :09:00.0: bios: 0002ba00: type e0, 366080 bytes

vs

[   22.961901] nouveau :09:00.0: bios: : type 00, 60416 bytes
[   22.984174] nouveau :09:00.0: bios: ec00: type 03, 71168 bytes
[   23.010446] nouveau :09:00.0: bios: 00020200: type e0, 48128 bytes
[   23.028220] nouveau :09:00.0: bios: 0002be00: type e0, 140800 bytes
[   23.080196] nouveau :09:00.0: bios: 0004e400: type 70, 7168 bytes

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 7deb81b6dbac6..4b571cc6bc70f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
   image.base, image.type, image.size);
 
-   if (!shadow_fetch(bios, mthd, image.size)) {
+   if (!shadow_fetch(bios, mthd, image.base + image.size)) {
nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
return 0;
}
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.19 15/15] drm/nouveau/kms/nv50-: fix case where notifier buffer is at offset 0

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit caeb6ab899c3d36a74cda6e299c6e1c9c4e2a22e ]

VRAM offset 0 is a valid address, triggered on GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++--
 drivers/gpu/drm/nouveau/dispnv50/disp.h | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 1bb0a9f6fa730..fbe156302ee86 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -131,7 +131,7 @@ nv50_dmac_destroy(struct nv50_dmac *dmac)
 
 int
 nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
-const s32 *oclass, u8 head, void *data, u32 size, u64 syncbuf,
+const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
 struct nv50_dmac *dmac)
 {
struct nouveau_cli *cli = (void *)device->object.client;
@@ -166,7 +166,7 @@ nv50_dmac_create(struct nvif_device *device, struct 
nvif_object *disp,
if (ret)
return ret;
 
-   if (!syncbuf)
+   if (syncbuf < 0)
return 0;
 
ret = nvif_object_init(>base.user, 0xf000, NV_DMA_IN_MEMORY,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h 
b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 66c125a6b0b3c..55205d23360c8 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -68,7 +68,7 @@ struct nv50_dmac {
 
 int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
 const s32 *oclass, u8 head, void *data, u32 size,
-u64 syncbuf, struct nv50_dmac *dmac);
+s64 syncbuf, struct nv50_dmac *dmac);
 void nv50_dmac_destroy(struct nv50_dmac *);
 
 u32 *evo_wait(struct nv50_dmac *, int nr);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c 
b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index f7dbd965e4e72..b49a212af4d8d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -68,7 +68,7 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct 
nouveau_drm *drm,
int ret;
 
ret = nv50_dmac_create(>client.device, >disp->object,
-  , 0, , sizeof(args), 0,
+  , 0, , sizeof(args), -1,
   >wimm);
if (ret) {
NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.19 14/15] drm/nouveau/mmu: fix vram heap sizing

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit add42781ad76c5ae65127bf13852a4c6b2f08849 ]

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index ee11ccaf0563c..cb51e248cb41b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -316,9 +316,9 @@ nvkm_mmu_vram(struct nvkm_mmu *mmu)
 {
struct nvkm_device *device = mmu->subdev.device;
struct nvkm_mm *mm = >fb->ram->vram;
-   const u32 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
-   const u32 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
-   const u32 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
+   const u64 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
+   const u64 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
+   const u64 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
u8 type = NVKM_MEM_KIND * !!mmu->func->kind;
u8 heap = NVKM_MEM_VRAM;
int heapM, heapN, heapU;
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.19 13/15] drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit ba6e9ab0fcf3d76e3952deb12b5f993991621d9c ]

Noticed while debugging GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
index edb6148cbca04..d0e80ad526845 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
@@ -33,7 +33,7 @@ static void
 gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
 {
struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0031, 0x);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0071, 0x);
 }
 
 static int
@@ -54,10 +54,10 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
AUX_ERR(>base, "begin idle timeout %08x", ctrl);
return -EBUSY;
}
-   } while (ctrl & 0x0301);
+   } while (ctrl & 0x0701);
 
/* set some magic, and wait up to 1ms for it to appear */
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0030, ureq);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0070, ureq);
timeout = 1000;
do {
ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
gm200_i2c_aux_fini(aux);
return -EBUSY;
}
-   } while ((ctrl & 0x0300) != urep);
+   } while ((ctrl & 0x0700) != urep);
 
return 0;
 }
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.19 12/15] drm/nouveau/privring: ack interrupts the same way as RM

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit e05e06cd34f5311f677294a08b609acfbc315236 ]

Whatever it is that we were doing before doesn't work on Ampere.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c | 10 +++---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c | 10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
index d80dbc8f09b20..55a4ea4393c62 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0400));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gf100_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0400));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gf100_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0400));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0400), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gf100_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x121c4c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x121c4c) & 0x003f))
+   break;
+   );
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
index 9025ed1bd2a99..4caf3ef087e1d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0800));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gk104_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0800));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gk104_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0800));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0800), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gk104_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x12004c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x12004c) & 0x003f))
+   break;
+   );
 }
 
 static int
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 4.19 11/15] drm/nouveau/bios: fix issue shadowing expansion ROMs

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 402a89660e9dc880710b12773076a336c9dab3d7 ]

This issue has generally been covered up by the presence of additional
expansion ROMs after the ones we're interested in, with header fetches
of subsequent images loading enough of the ROM to hide the issue.

Noticed on GA102, which lacks a type 0x70 image compared to TU102,.

[  906.364197] nouveau :09:00.0: bios: : type 00, 65024 bytes
[  906.381205] nouveau :09:00.0: bios: fe00: type 03, 91648 bytes
[  906.405213] nouveau :09:00.0: bios: 00026400: type e0, 22016 bytes
[  906.410984] nouveau :09:00.0: bios: 0002ba00: type e0, 366080 bytes

vs

[   22.961901] nouveau :09:00.0: bios: : type 00, 60416 bytes
[   22.984174] nouveau :09:00.0: bios: ec00: type 03, 71168 bytes
[   23.010446] nouveau :09:00.0: bios: 00020200: type e0, 48128 bytes
[   23.028220] nouveau :09:00.0: bios: 0002be00: type e0, 140800 bytes
[   23.080196] nouveau :09:00.0: bios: 0004e400: type 70, 7168 bytes

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 7deb81b6dbac6..4b571cc6bc70f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
   image.base, image.type, image.size);
 
-   if (!shadow_fetch(bios, mthd, image.size)) {
+   if (!shadow_fetch(bios, mthd, image.base + image.size)) {
nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
return 0;
}
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 25/26] drm/nouveau/mmu: fix vram heap sizing

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit add42781ad76c5ae65127bf13852a4c6b2f08849 ]

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index ee11ccaf0563c..cb51e248cb41b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -316,9 +316,9 @@ nvkm_mmu_vram(struct nvkm_mmu *mmu)
 {
struct nvkm_device *device = mmu->subdev.device;
struct nvkm_mm *mm = >fb->ram->vram;
-   const u32 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
-   const u32 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
-   const u32 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
+   const u64 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
+   const u64 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
+   const u64 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
u8 type = NVKM_MEM_KIND * !!mmu->func->kind;
u8 heap = NVKM_MEM_VRAM;
int heapM, heapN, heapU;
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 26/26] drm/nouveau/kms/nv50-: fix case where notifier buffer is at offset 0

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit caeb6ab899c3d36a74cda6e299c6e1c9c4e2a22e ]

VRAM offset 0 is a valid address, triggered on GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++--
 drivers/gpu/drm/nouveau/dispnv50/disp.h | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index ee2b1e1199e09..daa79d39201f9 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -132,7 +132,7 @@ nv50_dmac_destroy(struct nv50_dmac *dmac)
 
 int
 nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
-const s32 *oclass, u8 head, void *data, u32 size, u64 syncbuf,
+const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
 struct nv50_dmac *dmac)
 {
struct nouveau_cli *cli = (void *)device->object.client;
@@ -167,7 +167,7 @@ nv50_dmac_create(struct nvif_device *device, struct 
nvif_object *disp,
if (ret)
return ret;
 
-   if (!syncbuf)
+   if (syncbuf < 0)
return 0;
 
ret = nvif_object_init(>base.user, 0xf000, NV_DMA_IN_MEMORY,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h 
b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 7c41b0599d1ac..284068fa6d007 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -70,7 +70,7 @@ struct nv50_dmac {
 
 int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
 const s32 *oclass, u8 head, void *data, u32 size,
-u64 syncbuf, struct nv50_dmac *dmac);
+s64 syncbuf, struct nv50_dmac *dmac);
 void nv50_dmac_destroy(struct nv50_dmac *);
 
 u32 *evo_wait(struct nv50_dmac *, int nr);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c 
b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index f7dbd965e4e72..b49a212af4d8d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -68,7 +68,7 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct 
nouveau_drm *drm,
int ret;
 
ret = nv50_dmac_create(>client.device, >disp->object,
-  , 0, , sizeof(args), 0,
+  , 0, , sizeof(args), -1,
   >wimm);
if (ret) {
NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 24/26] drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit ba6e9ab0fcf3d76e3952deb12b5f993991621d9c ]

Noticed while debugging GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
index edb6148cbca04..d0e80ad526845 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
@@ -33,7 +33,7 @@ static void
 gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
 {
struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0031, 0x);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0071, 0x);
 }
 
 static int
@@ -54,10 +54,10 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
AUX_ERR(>base, "begin idle timeout %08x", ctrl);
return -EBUSY;
}
-   } while (ctrl & 0x0301);
+   } while (ctrl & 0x0701);
 
/* set some magic, and wait up to 1ms for it to appear */
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0030, ureq);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0070, ureq);
timeout = 1000;
do {
ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
gm200_i2c_aux_fini(aux);
return -EBUSY;
}
-   } while ((ctrl & 0x0300) != urep);
+   } while ((ctrl & 0x0700) != urep);
 
return 0;
 }
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 23/26] drm/nouveau/privring: ack interrupts the same way as RM

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit e05e06cd34f5311f677294a08b609acfbc315236 ]

Whatever it is that we were doing before doesn't work on Ampere.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c | 10 +++---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c | 10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
index d80dbc8f09b20..55a4ea4393c62 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0400));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gf100_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0400));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gf100_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0400));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0400), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gf100_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x121c4c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x121c4c) & 0x003f))
+   break;
+   );
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
index 9025ed1bd2a99..4caf3ef087e1d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0800));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gk104_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0800));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gk104_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0800));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0800), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gk104_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x12004c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x12004c) & 0x003f))
+   break;
+   );
 }
 
 static int
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 22/26] drm/nouveau/bios: fix issue shadowing expansion ROMs

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 402a89660e9dc880710b12773076a336c9dab3d7 ]

This issue has generally been covered up by the presence of additional
expansion ROMs after the ones we're interested in, with header fetches
of subsequent images loading enough of the ROM to hide the issue.

Noticed on GA102, which lacks a type 0x70 image compared to TU102,.

[  906.364197] nouveau :09:00.0: bios: : type 00, 65024 bytes
[  906.381205] nouveau :09:00.0: bios: fe00: type 03, 91648 bytes
[  906.405213] nouveau :09:00.0: bios: 00026400: type e0, 22016 bytes
[  906.410984] nouveau :09:00.0: bios: 0002ba00: type e0, 366080 bytes

vs

[   22.961901] nouveau :09:00.0: bios: : type 00, 60416 bytes
[   22.984174] nouveau :09:00.0: bios: ec00: type 03, 71168 bytes
[   23.010446] nouveau :09:00.0: bios: 00020200: type e0, 48128 bytes
[   23.028220] nouveau :09:00.0: bios: 0002be00: type e0, 140800 bytes
[   23.080196] nouveau :09:00.0: bios: 0004e400: type 70, 7168 bytes

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 7deb81b6dbac6..4b571cc6bc70f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
   image.base, image.type, image.size);
 
-   if (!shadow_fetch(bios, mthd, image.size)) {
+   if (!shadow_fetch(bios, mthd, image.base + image.size)) {
nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
return 0;
}
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 40/45] drm/nouveau/kms/nv50-: fix case where notifier buffer is at offset 0

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit caeb6ab899c3d36a74cda6e299c6e1c9c4e2a22e ]

VRAM offset 0 is a valid address, triggered on GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 ++--
 drivers/gpu/drm/nouveau/dispnv50/disp.h | 2 +-
 drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 36d6b6093d16d..5b8cabb099eb1 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -221,7 +221,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
 
 int
 nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
-const s32 *oclass, u8 head, void *data, u32 size, u64 syncbuf,
+const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
 struct nv50_dmac *dmac)
 {
struct nouveau_cli *cli = (void *)device->object.client;
@@ -270,7 +270,7 @@ nv50_dmac_create(struct nvif_device *device, struct 
nvif_object *disp,
if (ret)
return ret;
 
-   if (!syncbuf)
+   if (syncbuf < 0)
return 0;
 
ret = nvif_object_ctor(>base.user, "kmsSyncCtxDma", 
NV50_DISP_HANDLE_SYNCBUF,
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h 
b/drivers/gpu/drm/nouveau/dispnv50/disp.h
index 92bddc0836171..38dec11e7dda5 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h
@@ -95,7 +95,7 @@ struct nv50_outp_atom {
 
 int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
 const s32 *oclass, u8 head, void *data, u32 size,
-u64 syncbuf, struct nv50_dmac *dmac);
+s64 syncbuf, struct nv50_dmac *dmac);
 void nv50_dmac_destroy(struct nv50_dmac *);
 
 /*
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c 
b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
index 685b708713242..b390029c69ec1 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c
@@ -76,7 +76,7 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct 
nouveau_drm *drm,
int ret;
 
ret = nv50_dmac_create(>client.device, >disp->object,
-  , 0, , sizeof(args), 0,
+  , 0, , sizeof(args), -1,
   >wimm);
if (ret) {
NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 39/45] drm/nouveau/mmu: fix vram heap sizing

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit add42781ad76c5ae65127bf13852a4c6b2f08849 ]

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index de91e9a261725..6d5212ae2fd57 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -316,9 +316,9 @@ nvkm_mmu_vram(struct nvkm_mmu *mmu)
 {
struct nvkm_device *device = mmu->subdev.device;
struct nvkm_mm *mm = >fb->ram->vram;
-   const u32 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
-   const u32 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
-   const u32 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
+   const u64 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
+   const u64 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
+   const u64 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
u8 type = NVKM_MEM_KIND * !!mmu->func->kind;
u8 heap = NVKM_MEM_VRAM;
int heapM, heapN, heapU;
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 38/45] drm/nouveau/i2c/gm200: increase width of aux semaphore owner fields

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit ba6e9ab0fcf3d76e3952deb12b5f993991621d9c ]

Noticed while debugging GA102.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
index edb6148cbca04..d0e80ad526845 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c
@@ -33,7 +33,7 @@ static void
 gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
 {
struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0031, 0x);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0071, 0x);
 }
 
 static int
@@ -54,10 +54,10 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
AUX_ERR(>base, "begin idle timeout %08x", ctrl);
return -EBUSY;
}
-   } while (ctrl & 0x0301);
+   } while (ctrl & 0x0701);
 
/* set some magic, and wait up to 1ms for it to appear */
-   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0030, ureq);
+   nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x0070, ureq);
timeout = 1000;
do {
ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
gm200_i2c_aux_fini(aux);
return -EBUSY;
}
-   } while ((ctrl & 0x0300) != urep);
+   } while ((ctrl & 0x0700) != urep);
 
return 0;
 }
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 36/45] drm/nouveau/bios: fix issue shadowing expansion ROMs

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit 402a89660e9dc880710b12773076a336c9dab3d7 ]

This issue has generally been covered up by the presence of additional
expansion ROMs after the ones we're interested in, with header fetches
of subsequent images loading enough of the ROM to hide the issue.

Noticed on GA102, which lacks a type 0x70 image compared to TU102,.

[  906.364197] nouveau :09:00.0: bios: : type 00, 65024 bytes
[  906.381205] nouveau :09:00.0: bios: fe00: type 03, 91648 bytes
[  906.405213] nouveau :09:00.0: bios: 00026400: type e0, 22016 bytes
[  906.410984] nouveau :09:00.0: bios: 0002ba00: type e0, 366080 bytes

vs

[   22.961901] nouveau :09:00.0: bios: : type 00, 60416 bytes
[   22.984174] nouveau :09:00.0: bios: ec00: type 03, 71168 bytes
[   23.010446] nouveau :09:00.0: bios: 00020200: type e0, 48128 bytes
[   23.028220] nouveau :09:00.0: bios: 0002be00: type e0, 140800 bytes
[   23.080196] nouveau :09:00.0: bios: 0004e400: type 70, 7168 bytes

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 7deb81b6dbac6..4b571cc6bc70f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
   image.base, image.type, image.size);
 
-   if (!shadow_fetch(bios, mthd, image.size)) {
+   if (!shadow_fetch(bios, mthd, image.base + image.size)) {
nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
return 0;
}
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.10 37/45] drm/nouveau/privring: ack interrupts the same way as RM

2021-01-19 Thread Sasha Levin
From: Ben Skeggs 

[ Upstream commit e05e06cd34f5311f677294a08b609acfbc315236 ]

Whatever it is that we were doing before doesn't work on Ampere.

Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c | 10 +++---
 drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c | 10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
index 2340040942c93..1115376bc85f5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0400));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gf100_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0400));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0400), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gf100_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0400));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0400));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0400), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gf100_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x121c4c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x121c4c) & 0x003f))
+   break;
+   );
 }
 
 static int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
index f3915f85838ed..22e487b493ad1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "priv.h"
+#include 
 
 static void
 gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0800));
nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x122128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -42,7 +42,6 @@ gk104_ibus_intr_rop(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0800));
nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x124128 + (i * 0x0800), 0x0200, 0x);
 }
 
 static void
@@ -53,7 +52,6 @@ gk104_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0800));
u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0800));
nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
-   nvkm_mask(device, 0x128128 + (i * 0x0800), 0x0200, 0x);
 }
 
 void
@@ -90,6 +88,12 @@ gk104_ibus_intr(struct nvkm_subdev *ibus)
intr1 &= ~stat;
}
}
+
+   nvkm_mask(device, 0x12004c, 0x003f, 0x0002);
+   nvkm_msec(device, 2000,
+   if (!(nvkm_rd32(device, 0x12004c) & 0x003f))
+   break;
+   );
 }
 
 static int
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 23/24] drm/nouveau/gem: fix "refcount_t: underflow; use-after-free"

2020-11-02 Thread Sasha Levin
From: Karol Herbst 

[ Upstream commit 925681454d7b557d404b5d28ef4469fac1b2e105 ]

we can't use nouveau_bo_ref here as no ttm object was allocated and
nouveau_bo_ref mainly deals with that. Simply deallocate the object.

Signed-off-by: Karol Herbst 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 7d39d4949ee77..2dd9fcab464b1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -197,7 +197,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int 
align, uint32_t domain,
 * to the caller, instead of a normal nouveau_bo ttm reference. */
ret = drm_gem_object_init(drm->dev, >bo.base, size);
if (ret) {
-   nouveau_bo_ref(NULL, );
+   drm_gem_object_release(>bo.base);
+   kfree(nvbo);
return ret;
}
 
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.8 27/29] drm/nouveau/nouveau: fix the start/end range for migration

2020-11-02 Thread Sasha Levin
From: Ralph Campbell 

[ Upstream commit cfa736f5a6f31ca8a05459b5720aac030247ad1b ]

The user level OpenCL code shouldn't have to align start and end
addresses to a page boundary. That is better handled in the nouveau
driver. The npages field is also redundant since it can be computed
from the start and end addresses.

Signed-off-by: Ralph Campbell 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c 
b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 6586d9d398740..11b7cc3625cf8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -116,11 +116,11 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
struct nouveau_cli *cli = nouveau_cli(file_priv);
struct drm_nouveau_svm_bind *args = data;
unsigned target, cmd, priority;
-   unsigned long addr, end, size;
+   unsigned long addr, end;
struct mm_struct *mm;
 
args->va_start &= PAGE_MASK;
-   args->va_end &= PAGE_MASK;
+   args->va_end = ALIGN(args->va_end, PAGE_SIZE);
 
/* Sanity check arguments */
if (args->reserved0 || args->reserved1)
@@ -129,8 +129,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
return -EINVAL;
if (args->va_start >= args->va_end)
return -EINVAL;
-   if (!args->npages)
-   return -EINVAL;
 
cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT;
cmd &= NOUVEAU_SVM_BIND_COMMAND_MASK;
@@ -162,12 +160,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
if (args->stride)
return -EINVAL;
 
-   size = ((unsigned long)args->npages) << PAGE_SHIFT;
-   if ((args->va_start + size) <= args->va_start)
-   return -EINVAL;
-   if ((args->va_start + size) > args->va_end)
-   return -EINVAL;
-
/*
 * Ok we are ask to do something sane, for now we only support migrate
 * commands but we will add things like memory policy (what to do on
@@ -182,7 +174,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
return -EINVAL;
}
 
-   for (addr = args->va_start, end = args->va_start + size; addr < end;) {
+   for (addr = args->va_start, end = args->va_end; addr < end;) {
struct vm_area_struct *vma;
unsigned long next;
 
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.4 22/24] drm/nouveau/nouveau: fix the start/end range for migration

2020-11-02 Thread Sasha Levin
From: Ralph Campbell 

[ Upstream commit cfa736f5a6f31ca8a05459b5720aac030247ad1b ]

The user level OpenCL code shouldn't have to align start and end
addresses to a page boundary. That is better handled in the nouveau
driver. The npages field is also redundant since it can be computed
from the start and end addresses.

Signed-off-by: Ralph Campbell 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c 
b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 824654742a604..0be4668c780bf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -112,11 +112,11 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
struct nouveau_cli *cli = nouveau_cli(file_priv);
struct drm_nouveau_svm_bind *args = data;
unsigned target, cmd, priority;
-   unsigned long addr, end, size;
+   unsigned long addr, end;
struct mm_struct *mm;
 
args->va_start &= PAGE_MASK;
-   args->va_end &= PAGE_MASK;
+   args->va_end = ALIGN(args->va_end, PAGE_SIZE);
 
/* Sanity check arguments */
if (args->reserved0 || args->reserved1)
@@ -125,8 +125,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
return -EINVAL;
if (args->va_start >= args->va_end)
return -EINVAL;
-   if (!args->npages)
-   return -EINVAL;
 
cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT;
cmd &= NOUVEAU_SVM_BIND_COMMAND_MASK;
@@ -158,12 +156,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
if (args->stride)
return -EINVAL;
 
-   size = ((unsigned long)args->npages) << PAGE_SHIFT;
-   if ((args->va_start + size) <= args->va_start)
-   return -EINVAL;
-   if ((args->va_start + size) > args->va_end)
-   return -EINVAL;
-
/*
 * Ok we are ask to do something sane, for now we only support migrate
 * commands but we will add things like memory policy (what to do on
@@ -178,7 +170,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
return -EINVAL;
}
 
-   for (addr = args->va_start, end = args->va_start + size; addr < end;) {
+   for (addr = args->va_start, end = args->va_end; addr < end;) {
struct vm_area_struct *vma;
unsigned long next;
 
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.8 28/29] drm/nouveau/gem: fix "refcount_t: underflow; use-after-free"

2020-11-02 Thread Sasha Levin
From: Karol Herbst 

[ Upstream commit 925681454d7b557d404b5d28ef4469fac1b2e105 ]

we can't use nouveau_bo_ref here as no ttm object was allocated and
nouveau_bo_ref mainly deals with that. Simply deallocate the object.

Signed-off-by: Karol Herbst 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index c5ee5b7364a09..ee5fec1ad9a46 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -197,7 +197,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int 
align, uint32_t domain,
 * to the caller, instead of a normal nouveau_bo ttm reference. */
ret = drm_gem_object_init(drm->dev, >bo.base, size);
if (ret) {
-   nouveau_bo_ref(NULL, );
+   drm_gem_object_release(>bo.base);
+   kfree(nvbo);
return ret;
}
 
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.9 34/35] drm/nouveau/gem: fix "refcount_t: underflow; use-after-free"

2020-11-02 Thread Sasha Levin
From: Karol Herbst 

[ Upstream commit 925681454d7b557d404b5d28ef4469fac1b2e105 ]

we can't use nouveau_bo_ref here as no ttm object was allocated and
nouveau_bo_ref mainly deals with that. Simply deallocate the object.

Signed-off-by: Karol Herbst 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 81f111ad3f4fd..124d3dcc5c590 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -198,7 +198,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int 
align, uint32_t domain,
 * to the caller, instead of a normal nouveau_bo ttm reference. */
ret = drm_gem_object_init(drm->dev, >bo.base, size);
if (ret) {
-   nouveau_bo_ref(NULL, );
+   drm_gem_object_release(>bo.base);
+   kfree(nvbo);
return ret;
}
 
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH AUTOSEL 5.9 33/35] drm/nouveau/nouveau: fix the start/end range for migration

2020-11-02 Thread Sasha Levin
From: Ralph Campbell 

[ Upstream commit cfa736f5a6f31ca8a05459b5720aac030247ad1b ]

The user level OpenCL code shouldn't have to align start and end
addresses to a page boundary. That is better handled in the nouveau
driver. The npages field is also redundant since it can be computed
from the start and end addresses.

Signed-off-by: Ralph Campbell 
Signed-off-by: Ben Skeggs 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c 
b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 2df1c04605594..4f69e4c3dafde 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -105,11 +105,11 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
struct nouveau_cli *cli = nouveau_cli(file_priv);
struct drm_nouveau_svm_bind *args = data;
unsigned target, cmd, priority;
-   unsigned long addr, end, size;
+   unsigned long addr, end;
struct mm_struct *mm;
 
args->va_start &= PAGE_MASK;
-   args->va_end &= PAGE_MASK;
+   args->va_end = ALIGN(args->va_end, PAGE_SIZE);
 
/* Sanity check arguments */
if (args->reserved0 || args->reserved1)
@@ -118,8 +118,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
return -EINVAL;
if (args->va_start >= args->va_end)
return -EINVAL;
-   if (!args->npages)
-   return -EINVAL;
 
cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT;
cmd &= NOUVEAU_SVM_BIND_COMMAND_MASK;
@@ -151,12 +149,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
if (args->stride)
return -EINVAL;
 
-   size = ((unsigned long)args->npages) << PAGE_SHIFT;
-   if ((args->va_start + size) <= args->va_start)
-   return -EINVAL;
-   if ((args->va_start + size) > args->va_end)
-   return -EINVAL;
-
/*
 * Ok we are ask to do something sane, for now we only support migrate
 * commands but we will add things like memory policy (what to do on
@@ -171,7 +163,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
return -EINVAL;
}
 
-   for (addr = args->va_start, end = args->va_start + size; addr < end;) {
+   for (addr = args->va_start, end = args->va_end; addr < end;) {
struct vm_area_struct *vma;
unsigned long next;
 
-- 
2.27.0

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH v5 1/2] drm/nouveau/kms/nv50-: Program notifier offset before requesting disp caps

2020-09-07 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 4a2cb4181b07 ("drm/nouveau/kms/nv50-: Probe SOR and PIOR caps 
for DP interlacing support").

The bot has tested the following trees: v5.8.7.

v5.8.7: Failed to apply! Possible dependencies:
0a96099691c8 ("drm/nouveau/kms/nv50-: implement proper push buffer control 
logic")
0bc8ffe09771 ("drm/nouveau/kms/nv50-: Move hard-coded object handles into 
header")
12885ecbfe62 ("drm/nouveau/kms/nvd9-: Add CRC support")
203f6eaf4182 ("drm/nouveau/kms/nv50-: convert core update() to new push 
macros")
2853ccf09255 ("drm/nouveau/kms/nv50-: wrap existing command submission in 
nvif_push interface")
344c2e5a4796 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
or_ctrl()")
3c43c362b3a5 ("drm/nouveau/kms/nv50-: convert core caps_init() to new push 
macros")
5e691222eac6 ("drm/nouveau/kms/nv50-: convert core init() to new push 
macros")
9ec5e8204053 ("drm/nouveau/kms/nv50-: convert core or_ctrl() to new push 
macros")
b11d8ca151d0 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core init()")
b505935e56b2 ("drm/nouveau/kms/nv50-: convert core wndw_owner() to new push 
macros")
d8b24526ef68 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
caps_init()")
e79c9a0ba5e7 ("drm/nouveau/nvif: give every mem object a human-readable 
identifier")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH v3] mm/thp: fix __split_huge_pmd_locked() for migration PMD

2020-09-05 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 84c3fc4e9c56 ("mm: thp: check pmd migration entry in common 
path").

The bot has tested the following trees: v5.8.6, v5.4.62, v4.19.143, v4.14.196.

v5.8.6: Build OK!
v5.4.62: Failed to apply! Possible dependencies:
0d1c20722ab3 ("mm: memcontrol: switch to native NR_FILE_PAGES and NR_SHMEM 
counters")
3fba69a56e16 ("mm: memcontrol: drop @compound parameter from memcg charging 
API")
468c398233da ("mm: memcontrol: switch to native NR_ANON_THPS counter")
72981e0e7b60 ("userfaultfd: wp: add UFFDIO_COPY_MODE_WP")
83d116c53058 ("mm: fix double page fault on arm64 if PTE_AF is cleared")
85b9f46e8ea4 ("mm, thp: track fallbacks due to failed memcg charges 
separately")
92855270ff08 ("mm/memcontrol.c: cleanup some useless code")
be5d0a74c62d ("mm: memcontrol: switch to native NR_ANON_MAPPED counter")
c23a0c99793f ("mm/migrate: clean up some minor coding style")
dcdf11ee1441 ("mm, shmem: add vmstat for hugepage fallback")
f4129ea3591a ("mm: fix NUMA node file count error in replace_page_cache()")
ffe945e633b5 ("khugepaged: do not stop collapse if less than half PTEs are 
referenced")

v4.19.143: Failed to apply! Possible dependencies:
0ac261042084 ("x86/irq/64: Init hardirq_stack_ptr during CPU hotplug")
0d1c20722ab3 ("mm: memcontrol: switch to native NR_FILE_PAGES and NR_SHMEM 
counters")
117ed4548541 ("x86/irq/64: Remove stack overflow debug code")
231c4846b106 ("x86/irq/32: Make irq stack a character array")
30842211506e ("x86/exceptions: Remove unused stack defines on 32bit")
39656e83dab9 ("mm: lift the x86_32 PAE version of gup_get_pte to common 
code")
468c398233da ("mm: memcontrol: switch to native NR_ANON_THPS counter")
4f44b8f0b33b ("x86/irq/64: Remove a hardcoded irq_stack_union access")
66c7ceb47f62 ("x86/irq/32: Handle irq stack allocation failure proper")
758a2e312228 ("x86/irq/64: Rename irq_stack_ptr to hardirq_stack_ptr")
7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
a754fe2b76d1 ("x86/irq/32: Rename hard/softirq_stack to 
hard/softirq_stack_ptr")
aa641c287b2f ("x86/irq/32: Define IRQ_STACK_SIZE")
be5d0a74c62d ("mm: memcontrol: switch to native NR_ANON_MAPPED counter")
df835e7083be ("x86/irq/64: Sanitize the top/bottom confusion")
e6401c130931 ("x86/irq/64: Split the IRQ stack into its own pages")

v4.14.196: Failed to apply! Possible dependencies:
050e9baa9dc9 ("Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables")
0d1c20722ab3 ("mm: memcontrol: switch to native NR_FILE_PAGES and NR_SHMEM 
counters")
117ed4548541 ("x86/irq/64: Remove stack overflow debug code")
152e93af3cfe ("mm, thp: Do not make pmd/pud dirty without a reason")
2a61f4747eea ("stack-protector: test compiler capability in Kconfig and 
drop AUTO mode")
2b8383927525 ("Makefile: move stack-protector compiler breakage test 
earlier")
2bc2f688fdf8 ("Makefile: move stack-protector availability out of Kconfig")
39656e83dab9 ("mm: lift the x86_32 PAE version of gup_get_pte to common 
code")
44c6dc940b19 ("Makefile: introduce CONFIG_CC_STACKPROTECTOR_AUTO")
4645b9fe84bf ("mm/mmu_notifier: avoid call to invalidate_range() in 
range_end()")
468c398233da ("mm: memcontrol: switch to native NR_ANON_THPS counter")
59c66c5f8c4f ("mm: factor out page cache page freeing into a separate 
function")
5ecc4d852c03 ("mm: factor out checks and accounting from 
__delete_from_page_cache()")
76253fbc8fbf ("mm: move accounting updates before page_cache_tree_delete()")
7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
8373b7d9d174 ("Documentation: kconfig: add recommended way to describe 
compiler support")
99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
be5d0a74c62d ("mm: memcontrol: switch to native NR_ANON_MAPPED counter")
e6401c130931 ("x86/irq/64: Split the IRQ stack into its own pages")
fadae2953072 ("thp: use mm_file_counter to determine update which rss 
counter")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH v4] drm/nouveau/kms/nv50-: Program notifier offset before requesting disp caps

2020-09-02 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 4a2cb4181b07 ("drm/nouveau/kms/nv50-: Probe SOR and PIOR caps 
for DP interlacing support").

The bot has tested the following trees: v5.8.5.

v5.8.5: Failed to apply! Possible dependencies:
0a96099691c8 ("drm/nouveau/kms/nv50-: implement proper push buffer control 
logic")
0bc8ffe09771 ("drm/nouveau/kms/nv50-: Move hard-coded object handles into 
header")
12885ecbfe62 ("drm/nouveau/kms/nvd9-: Add CRC support")
203f6eaf4182 ("drm/nouveau/kms/nv50-: convert core update() to new push 
macros")
2853ccf09255 ("drm/nouveau/kms/nv50-: wrap existing command submission in 
nvif_push interface")
344c2e5a4796 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
or_ctrl()")
3c43c362b3a5 ("drm/nouveau/kms/nv50-: convert core caps_init() to new push 
macros")
5e691222eac6 ("drm/nouveau/kms/nv50-: convert core init() to new push 
macros")
9ec5e8204053 ("drm/nouveau/kms/nv50-: convert core or_ctrl() to new push 
macros")
b11d8ca151d0 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core init()")
b505935e56b2 ("drm/nouveau/kms/nv50-: convert core wndw_owner() to new push 
macros")
d8b24526ef68 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
caps_init()")
e79c9a0ba5e7 ("drm/nouveau/nvif: give every mem object a human-readable 
identifier")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH] drm/nouveau/kms/nv50-: Program notifier offset before requesting disp caps

2020-08-26 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 4a2cb4181b07 ("drm/nouveau/kms/nv50-: Probe SOR and PIOR caps 
for DP interlacing support").

The bot has tested the following trees: v5.8.2.

v5.8.2: Failed to apply! Possible dependencies:
3c43c362b3a5 ("drm/nouveau/kms/nv50-: convert core caps_init() to new push 
macros")
5e691222eac6 ("drm/nouveau/kms/nv50-: convert core init() to new push 
macros")
d8b24526ef68 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
caps_init()")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [PATCH v2 1/2] drm/nouveau/kms/nv50-: Program notifier offset before requesting disp caps

2020-08-26 Thread Sasha Levin
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 4a2cb4181b07 ("drm/nouveau/kms/nv50-: Probe SOR and PIOR caps 
for DP interlacing support").

The bot has tested the following trees: v5.8.2.

v5.8.2: Failed to apply! Possible dependencies:
3c43c362b3a5 ("drm/nouveau/kms/nv50-: convert core caps_init() to new push 
macros")
5e691222eac6 ("drm/nouveau/kms/nv50-: convert core init() to new push 
macros")
d8b24526ef68 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core 
caps_init()")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


  1   2   3   >