Re: [PATCH v1 4/6] dma-buf: Acquire wait-wound context on attachment

2022-07-14 Thread kernel test robot
Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20220714]
[also build test ERROR on v5.19-rc6]
[cannot apply to drm-misc/drm-misc-next drm-intel/for-linux-next 
media-tree/master linus/master v5.19-rc6 v5.19-rc5 v5.19-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Dmitry-Osipenko/Move-all-drivers-to-a-common-dma-buf-locking-convention/20220715-085556
base:37b355fdaf31ee18bda9a93c2a438dc1cbf57ec9
config: x86_64-allmodconfig 
(https://download.01.org/0day-ci/archive/20220715/202207151112.yi2gyyrx-...@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# 
https://github.com/intel-lab-lkp/linux/commit/ed55f535b8492ef30d7e94aae5811c772403ab4f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Dmitry-Osipenko/Move-all-drivers-to-a-common-dma-buf-locking-convention/20220715-085556
git checkout ed55f535b8492ef30d7e94aae5811c772403ab4f
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/i915/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/i915/i915_gem_ww.c:52:6: error: no previous prototype for 
>> 'i915_gem_ww_ctx_fini2' [-Werror=missing-prototypes]
  52 | void i915_gem_ww_ctx_fini2(struct i915_gem_ww_ctx *ww)
 |  ^
   cc1: all warnings being treated as errors


vim +/i915_gem_ww_ctx_fini2 +52 drivers/gpu/drm/i915/i915_gem_ww.c

51  
  > 52  void i915_gem_ww_ctx_fini2(struct i915_gem_ww_ctx *ww)
53  {
54  i915_gem_ww_ctx_unlock_all(ww);
55  WARN_ON(ww->contended);
56  }
57  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


[git pull] drm fixes for 5.19-rc7

2022-07-14 Thread Dave Airlie
Hi Linus,

This is the regular fixes pull for this week. This has a bunch of
amdgpu fixes, major one reverts the buddy allocator until it can be
tested more, otherwise just small ones, then i915 has a bunch of
fixes.

The outstanding firmware regressions reported by phoronix will
hopefully be dealt with ASAP.

Regards,
Dave.

drm-fixes-2022-07-15:
drm fixes for 5.19-rc7

amdgpu:
- revert buddy allocator support for now
- DP MST blank screen fix for specific platforms
- MEC firmware check fix for GC 10.3.7
- Deep color fix for DCE
- Fix possible divide by 0
- Coverage blend mode fix
- Fix cursor only commit timestamps

i915:
- Selftest fix
- TTM fix sg_table construction
- Error return fixes
- Fix a performance regression related to waitboost
- Fix GT resets
The following changes since commit 3590b44b9434af1b9c81c3f40189087ed4fe3635:

  Merge tag 'drm-misc-fixes-2022-07-07-1' of
ssh://git.freedesktop.org/git/drm/drm-misc into drm-fixes (2022-07-12
10:44:40 +1000)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm tags/drm-fixes-2022-07-15

for you to fetch changes up to 093f8d8f10aa22935bc8bf7100700f714ebaba9c:

  Merge tag 'amd-drm-fixes-5.19-2022-07-13' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes (2022-07-15
11:26:20 +1000)


drm fixes for 5.19-rc7

amdgpu:
- revert buddy allocator support for now
- DP MST blank screen fix for specific platforms
- MEC firmware check fix for GC 10.3.7
- Deep color fix for DCE
- Fix possible divide by 0
- Coverage blend mode fix
- Fix cursor only commit timestamps

i915:
- Selftest fix
- TTM fix sg_table construction
- Error return fixes
- Fix a performance regression related to waitboost
- Fix GT resets


Andrzej Hajda (1):
  drm/i915/selftests: fix subtraction overflow bug

Arunpravin Paneer Selvam (1):
  Revert "drm/amdgpu: add drm buddy support to amdgpu"

Chris Wilson (3):
  drm/i915/gt: Serialize GRDOM access between multiple engine resets
  drm/i915/gt: Serialize TLB invalidates with GT resets
  drm/i915/gem: Look for waitboosting across the whole object
prior to individual waits

Dan Carpenter (2):
  drm/i915/gvt: IS_ERR() vs NULL bug in intel_gvt_update_reg_whitelist()
  drm/i915/selftests: fix a couple IS_ERR() vs NULL tests

Daniele Ceraolo Spurio (1):
  drm/i915/guc: ADL-N should use the same GuC FW as ADL-S

Dave Airlie (3):
  Merge tag 'drm-misc-fixes-2022-07-14' of
git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
  Merge tag 'drm-intel-fixes-2022-07-13' of
git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
  Merge tag 'amd-drm-fixes-5.19-2022-07-13' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes

Fangzhi Zuo (1):
  drm/amd/display: Ignore First MST Sideband Message Return Error

Hangyu Hua (1):
  drm/i915: fix a possible refcount leak in intel_dp_add_mst_connector()

Mario Kleiner (1):
  drm/amd/display: Only use depth 36 bpp linebuffers on DCN display engines.

Matthew Auld (1):
  drm/i915/ttm: fix sg_table construction

Melissa Wen (1):
  drm/amd/display: correct check of coverage blend mode

Michel Dänzer (1):
  drm/amd/display: Ensure valid event timestamp for cursor-only commits

Prike Liang (1):
  drm/amdkfd: correct the MEC atomic support firmware checking for GC 10.3.7

Rodrigo Vivi (1):
  Merge tag 'gvt-fixes-2022-07-11' of
https://github.com/intel/gvt-linux into drm-intel-fixes

Thomas Hellström (1):
  drm/i915: Fix vm use-after-free in vma destruction

Yefim Barashkin (1):
  drm/amd/pm: Prevent divide by zero

 drivers/gpu/drm/Kconfig|   1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h |  97 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h|  10 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c   | 359 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h   |  89 -
 drivers/gpu/drm/amd/amdkfd/kfd_device.c|   2 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  84 -
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h  |   8 +
 .../amd/display/amdgpu_dm/amdgpu_dm_mst_types.c|  17 +
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c  |  11 +-
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c |   2 +
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c|  11 +-
 drivers/gpu/drm/i915/gem/i915_gem_wait.c   |  34 ++
 drivers/gpu/drm/i915/gt/intel_gt.c |  15 +-
 drivers/gpu/drm/i915/gt/intel_reset.c  |  37 ++-
 drivers/gpu/drm/i915/gt/selftest_lrc.c |   8 +-
 drivers/gpu/drm/i915/gvt/cmd_parser.c  |   6 +-
 drivers/gpu/drm/i915/i915_scatterlist.c|  19 +-
 drivers/gpu/drm/i915/i915_scatterlist.h|   6 +-
 drivers/gpu/drm/i915/intel_region_ttm.c|  10 +-
 

[PATCH v2 2/3] drm/bridge: it6505: Add i2c api power on check

2022-07-14 Thread allen
From: allen chen 

Use i2c bus to read/write when it6505 power off will occur i2c error.
Add this check will prevent i2c error when it6505 power off.

Signed-off-by: Pin-Yen Lin 
Signed-off-by: Allen Chen 
Reviewed-by: Robert Foss 
---
 drivers/gpu/drm/bridge/ite-it6505.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c 
b/drivers/gpu/drm/bridge/ite-it6505.c
index aa5e0aa1af85..cfd2c3275dc5 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -518,6 +518,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int 
reg_addr)
int err;
struct device *dev = >client->dev;
 
+   if (!it6505->powered)
+   return -ENODEV;
+
err = regmap_read(it6505->regmap, reg_addr, );
if (err < 0) {
dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err);
@@ -533,6 +536,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int 
reg_addr,
int err;
struct device *dev = >client->dev;
 
+   if (!it6505->powered)
+   return -ENODEV;
+
err = regmap_write(it6505->regmap, reg_addr, reg_val);
 
if (err < 0) {
@@ -550,6 +556,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned 
int reg,
int err;
struct device *dev = >client->dev;
 
+   if (!it6505->powered)
+   return -ENODEV;
+
err = regmap_update_bits(it6505->regmap, reg, mask, value);
if (err < 0) {
dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d",
@@ -2553,13 +2562,12 @@ static int it6505_poweron(struct it6505 *it6505)
usleep_range(1, 2);
}
 
+   it6505->powered = true;
it6505_reset_logic(it6505);
it6505_int_mask_enable(it6505);
it6505_init(it6505);
it6505_lane_off(it6505);
 
-   it6505->powered = true;
-
return 0;
 }
 
-- 
2.25.1



[PATCH v2 3/3] drm/bridge: it6505: Modified video clock calculation and video debug message

2022-07-14 Thread allen
From: allen chen 

Speed up video clock calculation and remove redundant video debug message.

Signed-off-by: Pin-Yen Lin 
Signed-off-by: Allen Chen 
Reviewed-by: Robert Foss 
---
 drivers/gpu/drm/bridge/ite-it6505.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c 
b/drivers/gpu/drm/bridge/ite-it6505.c
index cfd2c3275dc5..11a34ddb60a1 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -703,7 +703,7 @@ static void it6505_calc_video_info(struct it6505 *it6505)
DRM_DEV_DEBUG_DRIVER(dev, "hactive_start:%d, vactive_start:%d",
 hdes, vdes);
 
-   for (i = 0; i < 10; i++) {
+   for (i = 0; i < 3; i++) {
it6505_set_bits(it6505, REG_DATA_CTRL0, ENABLE_PCLK_COUNTER,
ENABLE_PCLK_COUNTER);
usleep_range(1, 15000);
@@ -720,7 +720,7 @@ static void it6505_calc_video_info(struct it6505 *it6505)
return;
}
 
-   sum /= 10;
+   sum /= 3;
pclk = 13500 * 2048 / sum;
it6505->video_info.clock = pclk;
it6505->video_info.hdisplay = hdew;
@@ -2344,8 +2344,6 @@ static void it6505_irq_hpd(struct it6505 *it6505)
 
if (!it6505_get_video_status(it6505))
it6505_video_reset(it6505);
-
-   it6505_calc_video_info(it6505);
} else {
memset(it6505->dpcd, 0, sizeof(it6505->dpcd));
 
-- 
2.25.1



[PATCH v2 1/3] drm/bridge: it6505: Modified power sequence

2022-07-14 Thread allen
From: allen chen 

Change power sequence to meet it6505 data sheet requirement when boot on.

Signed-off-by: Pin-Yen Lin 
Signed-off-by: Allen Chen 
Reviewed-by: Robert Foss 
---
 drivers/gpu/drm/bridge/ite-it6505.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c 
b/drivers/gpu/drm/bridge/ite-it6505.c
index 2d119e3016b3..aa5e0aa1af85 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -3029,7 +3029,7 @@ static int it6505_init_pdata(struct it6505 *it6505)
return PTR_ERR(pdata->ovdd);
}
 
-   pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+   pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(pdata->gpiod_reset)) {
dev_err(dev, "gpiod_reset gpio not found");
return PTR_ERR(pdata->gpiod_reset);
-- 
2.25.1



[PATCH v2 0/3] drm/bridge: it6505: Fixes bugs

2022-07-14 Thread allen
From: allen chen 

This series fixes some it6505 driver bugs and improve computing time.

Changes in v2:
  -  Change committe message occure to occur.

allen chen (3):
  drm/bridge: it6505: Modified power sequence
  drm/bridge: it6505: Add i2c api power on check
  drm/bridge: it6505: Modified video clock calculation and video debug
message

 drivers/gpu/drm/bridge/ite-it6505.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

-- 
2.25.1



[PATCH] mm/gup: migrate device coherent pages when pinning instead of failing

2022-07-14 Thread Alistair Popple
Currently any attempts to pin a device coherent page will fail. This is
because device coherent pages need to be managed by a device driver, and
pinning them would prevent a driver from migrating them off the device.

However this is no reason to fail pinning of these pages. These are
coherent and accessible from the CPU so can be migrated just like
pinning ZONE_MOVABLE pages. So instead of failing all attempts to pin
them first try migrating them out of ZONE_DEVICE.

[hch: rebased to the split device memory checks,
  moved migrate_device_page to migrate_device.c]

Signed-off-by: Alistair Popple 
Acked-by: Felix Kuehling 
Signed-off-by: Christoph Hellwig 
---

This patch hopefully addresses all of David's comments. It replaces both my "mm:
remove the vma check in migrate_vma_setup()" and "mm/gup: migrate device
coherent pages when pinning instead of failing" patches. I'm not sure what the
best way of including this is, perhaps Alex can respin the series with this
patch instead?

 - Alistair

 mm/gup.c| 50 +--
 mm/internal.h   |  1 +
 mm/migrate_device.c | 52 +
 3 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index b65fe8bf5af4..22b97ab61cd9 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1881,7 +1881,7 @@ static long check_and_migrate_movable_pages(unsigned long 
nr_pages,
unsigned long isolation_error_count = 0, i;
struct folio *prev_folio = NULL;
LIST_HEAD(movable_page_list);
-   bool drain_allow = true;
+   bool drain_allow = true, coherent_pages = false;
int ret = 0;
 
for (i = 0; i < nr_pages; i++) {
@@ -1891,9 +1891,38 @@ static long check_and_migrate_movable_pages(unsigned 
long nr_pages,
continue;
prev_folio = folio;
 
-   if (folio_is_longterm_pinnable(folio))
+   /*
+* Device coherent pages are managed by a driver and should not
+* be pinned indefinitely as it prevents the driver moving the
+* page. So when trying to pin with FOLL_LONGTERM instead try
+* to migrate the page out of device memory.
+*/
+   if (folio_is_device_coherent(folio)) {
+   /*
+* We always want a new GUP lookup with device coherent
+* pages.
+*/
+   pages[i] = 0;
+   coherent_pages = true;
+
+   /*
+* Migration will fail if the page is pinned, so convert
+* the pin on the source page to a normal reference.
+*/
+   if (gup_flags & FOLL_PIN) {
+   get_page(>page);
+   unpin_user_page(>page);
+   }
+
+   ret = migrate_device_coherent_page(>page);
+   if (ret)
+   goto unpin_pages;
+
continue;
+   }
 
+   if (folio_is_longterm_pinnable(folio))
+   continue;
/*
 * Try to move out any movable page before pinning the range.
 */
@@ -1919,7 +1948,8 @@ static long check_and_migrate_movable_pages(unsigned long 
nr_pages,
folio_nr_pages(folio));
}
 
-   if (!list_empty(_page_list) || isolation_error_count)
+   if (!list_empty(_page_list) || isolation_error_count
+   || coherent_pages)
goto unpin_pages;
 
/*
@@ -1929,10 +1959,16 @@ static long check_and_migrate_movable_pages(unsigned 
long nr_pages,
return nr_pages;
 
 unpin_pages:
-   if (gup_flags & FOLL_PIN) {
-   unpin_user_pages(pages, nr_pages);
-   } else {
-   for (i = 0; i < nr_pages; i++)
+   /*
+* pages[i] might be NULL if any device coherent pages were found.
+*/
+   for (i = 0; i < nr_pages; i++) {
+   if (!pages[i])
+   continue;
+
+   if (gup_flags & FOLL_PIN)
+   unpin_user_page(pages[i]);
+   else
put_page(pages[i]);
}
 
diff --git a/mm/internal.h b/mm/internal.h
index c0f8fbe0445b..899dab512c5a 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -853,6 +853,7 @@ int numa_migrate_prep(struct page *page, struct 
vm_area_struct *vma,
  unsigned long addr, int page_nid, int *flags);
 
 void free_zone_device_page(struct page *page);
+int migrate_device_coherent_page(struct page *page);
 
 /*
  * mm/gup.c
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 18bc6483f63a..7feeb447e3b9 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -686,6 +686,12 @@ void 

Re: [PATCH] drm/i915/guc: Don't use pr_err when not necessary

2022-07-14 Thread John Harrison

On 7/14/2022 17:40, john.c.harri...@intel.com wrote:

From: John Harrison 

A bunch of code was copy/pasted using pr_err as the default way to
report errors. However, drm_err is significantly more useful in
identifying where the error came from. So update the code to use that
instead.

Signed-off-by: John Harrison 
PS: Forgot to include the r-b tag from the previous post of this patch. 
Only change to this one is fix the last minute drm_debug to be drm_dbg 
and word the the commit message a bit better.




On 6/7/2022 15:25, Dixit, Ashutosh wrote:

On Tue, 07 Jun 2022 15:23:17 -0700, John Harrison wrote:

On 6/7/2022 15:07, Dixit, Ashutosh wrote:

On Tue, 07 Jun 2022 14:51:03 -0700, john.c.harri...@intel.com wrote:

From: John Harrison 

Don't use pr_err in places where we have access to a struct_drm.

Seem to be many more pr_err's in selftests. Is there a reason why drm_err's
cannot be used in selftests (especially those using an i915 device)?
Thanks.

I figured I'd start small and just do the gt/uc ones to being with as those
are the ones that affect me.

It sounds like the only reason to use pr_err is in the mock selftests where
there is no easy access to a DRM structure. For everything else, there is
no reason that I am aware of.

Fair enough:

Reviewed-by: Ashutosh Dixit 





---
  drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c  | 10 ++---
  drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 37 +--
  .../drm/i915/gt/uc/selftest_guc_multi_lrc.c   | 10 ++---
  3 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
index 27363091e1afa..19fde6bda8f9c 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
@@ -195,11 +195,11 @@ __uc_fw_auto_select(struct drm_i915_private *i915, struct 
intel_uc_fw *uc_fw)
fw_blobs[i].rev < fw_blobs[i - 1].rev)
continue;
  
-			pr_err("invalid FW blob order: %s r%u comes before %s r%u\n",

-  intel_platform_name(fw_blobs[i - 1].p),
-  fw_blobs[i - 1].rev,
-  intel_platform_name(fw_blobs[i].p),
-  fw_blobs[i].rev);
+   drm_err(>drm, "Invalid FW blob order: %s r%u comes 
before %s r%u\n",
+   intel_platform_name(fw_blobs[i - 1].p),
+   fw_blobs[i - 1].rev,
+   intel_platform_name(fw_blobs[i].p),
+   fw_blobs[i].rev);
  
  			uc_fw->path = NULL;

}
diff --git a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c 
b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
index 1df71d0796aec..20e0c39259fba 100644
--- a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
@@ -62,7 +62,7 @@ static int intel_guc_scrub_ctbs(void *arg)
ce = intel_context_create(engine);
if (IS_ERR(ce)) {
ret = PTR_ERR(ce);
-   pr_err("Failed to create context, %d: %d\n", i, ret);
+   drm_err(>i915->drm, "Failed to create context, %d: 
%d\n", i, ret);
goto err;
}
  
@@ -83,7 +83,7 @@ static int intel_guc_scrub_ctbs(void *arg)
  
  		if (IS_ERR(rq)) {

ret = PTR_ERR(rq);
-   pr_err("Failed to create request, %d: %d\n", i, ret);
+   drm_err(>i915->drm, "Failed to create request, %d: 
%d\n", i, ret);
goto err;
}
  
@@ -93,7 +93,7 @@ static int intel_guc_scrub_ctbs(void *arg)

for (i = 0; i < 3; ++i) {
ret = i915_request_wait(last[i], 0, HZ);
if (ret < 0) {
-   pr_err("Last request failed to complete: %d\n", ret);
+   drm_err(>i915->drm, "Last request failed to complete: 
%d\n", ret);
goto err;
}
i915_request_put(last[i]);
@@ -110,7 +110,7 @@ static int intel_guc_scrub_ctbs(void *arg)
/* GT will not idle if G2H are lost */
ret = intel_gt_wait_for_idle(gt, HZ);
if (ret < 0) {
-   pr_err("GT failed to idle: %d\n", ret);
+   drm_err(>i915->drm, "GT failed to idle: %d\n", ret);
goto err;
}
  
@@ -150,7 +150,7 @@ static int intel_guc_steal_guc_ids(void *arg)
  
  	ce = kcalloc(GUC_MAX_CONTEXT_ID, sizeof(*ce), GFP_KERNEL);

if (!ce) {
-   pr_err("Context array allocation failed\n");
+   drm_err(>i915->drm, "Context array allocation failed\n");
return -ENOMEM;
}
  
@@ -164,24 +164,24 @@ static int intel_guc_steal_guc_ids(void *arg)

if (IS_ERR(ce[context_index])) {
ret = PTR_ERR(ce[context_index]);

[PATCH v1 2/6] drm/gem: Take reservation lock for vmap/vunmap operations

2022-07-14 Thread Dmitry Osipenko
The new common dma-buf locking convention will require buffer importers
to hold the reservation lock around mapping operations. Make DRM GEM core
to take the lock around the vmapping operations and update QXL and i915
drivers to use the locked functions for the case where DRM core now holds
the lock. This patch prepares DRM core and drivers to transition to the
common dma-buf locking convention where vmapping of exported GEMs will
be done under the held reservation lock.

Signed-off-by: Dmitry Osipenko 
---
 drivers/gpu/drm/drm_client.c |  4 +--
 drivers/gpu/drm/drm_gem.c| 28 
 drivers/gpu/drm/drm_gem_framebuffer_helper.c |  6 ++---
 drivers/gpu/drm/drm_prime.c  |  4 +--
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c   |  2 +-
 drivers/gpu/drm/qxl/qxl_object.c | 17 ++--
 drivers/gpu/drm/qxl/qxl_prime.c  |  4 +--
 include/drm/drm_gem.h|  3 +++
 8 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 2b230b4d6942..fbcb1e995384 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -323,7 +323,7 @@ drm_client_buffer_vmap(struct drm_client_buffer *buffer,
 * fd_install step out of the driver backend hooks, to make that
 * final step optional for internal users.
 */
-   ret = drm_gem_vmap(buffer->gem, map);
+   ret = drm_gem_vmap_unlocked(buffer->gem, map);
if (ret)
return ret;
 
@@ -345,7 +345,7 @@ void drm_client_buffer_vunmap(struct drm_client_buffer 
*buffer)
 {
struct iosys_map *map = >map;
 
-   drm_gem_vunmap(buffer->gem, map);
+   drm_gem_vunmap_unlocked(buffer->gem, map);
 }
 EXPORT_SYMBOL(drm_client_buffer_vunmap);
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index eb0c2d041f13..9769c33cad99 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1155,6 +1155,8 @@ void drm_gem_print_info(struct drm_printer *p, unsigned 
int indent,
 
 int drm_gem_pin(struct drm_gem_object *obj)
 {
+   dma_resv_assert_held(obj->resv);
+
if (obj->funcs->pin)
return obj->funcs->pin(obj);
else
@@ -1163,6 +1165,8 @@ int drm_gem_pin(struct drm_gem_object *obj)
 
 void drm_gem_unpin(struct drm_gem_object *obj)
 {
+   dma_resv_assert_held(obj->resv);
+
if (obj->funcs->unpin)
obj->funcs->unpin(obj);
 }
@@ -1171,6 +1175,8 @@ int drm_gem_vmap(struct drm_gem_object *obj, struct 
iosys_map *map)
 {
int ret;
 
+   dma_resv_assert_held(obj->resv);
+
if (!obj->funcs->vmap)
return -EOPNOTSUPP;
 
@@ -1186,6 +1192,8 @@ EXPORT_SYMBOL(drm_gem_vmap);
 
 void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
 {
+   dma_resv_assert_held(obj->resv);
+
if (iosys_map_is_null(map))
return;
 
@@ -1197,6 +1205,26 @@ void drm_gem_vunmap(struct drm_gem_object *obj, struct 
iosys_map *map)
 }
 EXPORT_SYMBOL(drm_gem_vunmap);
 
+int drm_gem_vmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map)
+{
+   int ret;
+
+   dma_resv_lock(obj->resv, NULL);
+   ret = drm_gem_vmap(obj, map);
+   dma_resv_unlock(obj->resv);
+
+   return ret;
+}
+EXPORT_SYMBOL(drm_gem_vmap_unlocked);
+
+void drm_gem_vunmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map)
+{
+   dma_resv_lock(obj->resv, NULL);
+   drm_gem_vunmap(obj, map);
+   dma_resv_unlock(obj->resv);
+}
+EXPORT_SYMBOL(drm_gem_vunmap_unlocked);
+
 /**
  * drm_gem_lock_reservations - Sets up the ww context and acquires
  * the lock on an array of GEM objects.
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c 
b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index 880a4975507f..e35e224e6303 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -354,7 +354,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct 
iosys_map *map,
ret = -EINVAL;
goto err_drm_gem_vunmap;
}
-   ret = drm_gem_vmap(obj, [i]);
+   ret = drm_gem_vmap_unlocked(obj, [i]);
if (ret)
goto err_drm_gem_vunmap;
}
@@ -376,7 +376,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct 
iosys_map *map,
obj = drm_gem_fb_get_obj(fb, i);
if (!obj)
continue;
-   drm_gem_vunmap(obj, [i]);
+   drm_gem_vunmap_unlocked(obj, [i]);
}
return ret;
 }
@@ -403,7 +403,7 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct 
iosys_map *map)
continue;
if (iosys_map_is_null([i]))
continue;
-   drm_gem_vunmap(obj, [i]);
+   drm_gem_vunmap_unlocked(obj, 

[PATCH v1 6/6] dma-buf: Remove internal lock

2022-07-14 Thread Dmitry Osipenko
The internal dma-buf lock isn't needed anymore because the updated
locking specification claims that dma-buf reservation must be locked
by importers, and thus, the internal data is already protected by the
reservation lock. Remove the obsoleted internal lock.

Signed-off-by: Dmitry Osipenko 
---
 drivers/dma-buf/dma-buf.c | 5 -
 include/linux/dma-buf.h   | 9 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 37545ecb845a..4cc739537ebd 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -656,7 +656,6 @@ struct dma_buf *dma_buf_export(const struct 
dma_buf_export_info *exp_info)
 
dmabuf->file = file;
 
-   mutex_init(>lock);
INIT_LIST_HEAD(>attachments);
 
mutex_lock(_list.lock);
@@ -1459,7 +1458,6 @@ int dma_buf_vmap_unlocked(struct dma_buf *dmabuf, struct 
iosys_map *map)
return -EINVAL;
 
dma_resv_lock(dmabuf->resv, NULL);
-   mutex_lock(>lock);
if (dmabuf->vmapping_counter) {
dmabuf->vmapping_counter++;
BUG_ON(iosys_map_is_null(>vmap_ptr));
@@ -1479,7 +1477,6 @@ int dma_buf_vmap_unlocked(struct dma_buf *dmabuf, struct 
iosys_map *map)
*map = dmabuf->vmap_ptr;
 
 out_unlock:
-   mutex_unlock(>lock);
dma_resv_unlock(dmabuf->resv);
return ret;
 }
@@ -1500,13 +1497,11 @@ void dma_buf_vunmap_unlocked(struct dma_buf *dmabuf, 
struct iosys_map *map)
BUG_ON(!iosys_map_is_equal(>vmap_ptr, map));
 
dma_resv_lock(dmabuf->resv, NULL);
-   mutex_lock(>lock);
if (--dmabuf->vmapping_counter == 0) {
if (dmabuf->ops->vunmap)
dmabuf->ops->vunmap(dmabuf, map);
iosys_map_clear(>vmap_ptr);
}
-   mutex_unlock(>lock);
dma_resv_unlock(dmabuf->resv);
 }
 EXPORT_SYMBOL_NS_GPL(dma_buf_vunmap_unlocked, DMA_BUF);
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index da924a56d58f..abdd99042c77 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -326,15 +326,6 @@ struct dma_buf {
/** @ops: dma_buf_ops associated with this buffer object. */
const struct dma_buf_ops *ops;
 
-   /**
-* @lock:
-*
-* Used internally to serialize list manipulation, attach/detach and
-* vmap/unmap. Note that in many cases this is superseeded by
-* dma_resv_lock() on @resv.
-*/
-   struct mutex lock;
-
/**
 * @vmapping_counter:
 *
-- 
2.36.1



[PATCH v1 1/6] dma-buf: Add _unlocked postfix to function names

2022-07-14 Thread Dmitry Osipenko
Add _unlocked postfix to the dma-buf API function names in a preparation
to move all non-dynamic dma-buf users over to the dynamic locking
specification. This patch only renames API functions, preparing drivers
to the common locking convention. Later on we will make the "unlocked"
functions to take the reservation lock.

Suggested-by: Christian König 
Signed-off-by: Dmitry Osipenko 
---
 drivers/dma-buf/dma-buf.c | 76 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c   |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |  4 +-
 drivers/gpu/drm/armada/armada_gem.c   | 14 ++--
 drivers/gpu/drm/drm_gem_cma_helper.c  |  6 +-
 drivers/gpu/drm/drm_gem_shmem_helper.c|  6 +-
 drivers/gpu/drm/drm_prime.c   | 12 +--
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c   |  6 +-
 drivers/gpu/drm/exynos/exynos_drm_gem.c   |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c| 12 +--
 .../drm/i915/gem/selftests/i915_gem_dmabuf.c  | 20 ++---
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  8 +-
 drivers/gpu/drm/tegra/gem.c   | 27 +++
 drivers/infiniband/core/umem_dmabuf.c | 11 +--
 .../common/videobuf2/videobuf2-dma-contig.c   | 15 ++--
 .../media/common/videobuf2/videobuf2-dma-sg.c | 12 +--
 .../common/videobuf2/videobuf2-vmalloc.c  |  6 +-
 .../platform/nvidia/tegra-vde/dmabuf-cache.c  | 12 +--
 drivers/misc/fastrpc.c| 12 +--
 drivers/xen/gntdev-dmabuf.c   | 14 ++--
 include/linux/dma-buf.h   | 34 +
 21 files changed, 161 insertions(+), 152 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 44574fbe7482..d16237a6ffaa 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -795,7 +795,7 @@ static struct sg_table * __map_dma_buf(struct 
dma_buf_attachment *attach,
 }
 
 /**
- * dma_buf_dynamic_attach - Add the device to dma_buf's attachments list
+ * dma_buf_dynamic_attach_unlocked - Add the device to dma_buf's attachments 
list
  * @dmabuf:[in]buffer to attach device to.
  * @dev:   [in]device to be attached.
  * @importer_ops:  [in]importer operations for the attachment
@@ -817,9 +817,9 @@ static struct sg_table * __map_dma_buf(struct 
dma_buf_attachment *attach,
  * indicated with the error code -EBUSY.
  */
 struct dma_buf_attachment *
-dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
-  const struct dma_buf_attach_ops *importer_ops,
-  void *importer_priv)
+dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, struct device *dev,
+   const struct dma_buf_attach_ops *importer_ops,
+   void *importer_priv)
 {
struct dma_buf_attachment *attach;
int ret;
@@ -892,25 +892,25 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct 
device *dev,
if (dma_buf_is_dynamic(attach->dmabuf))
dma_resv_unlock(attach->dmabuf->resv);
 
-   dma_buf_detach(dmabuf, attach);
+   dma_buf_detach_unlocked(dmabuf, attach);
return ERR_PTR(ret);
 }
-EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, DMA_BUF);
+EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach_unlocked, DMA_BUF);
 
 /**
- * dma_buf_attach - Wrapper for dma_buf_dynamic_attach
+ * dma_buf_attach_unlocked - Wrapper for dma_buf_dynamic_attach
  * @dmabuf:[in]buffer to attach device to.
  * @dev:   [in]device to be attached.
  *
- * Wrapper to call dma_buf_dynamic_attach() for drivers which still use a 
static
- * mapping.
+ * Wrapper to call dma_buf_dynamic_attach_unlocked() for drivers which still
+ * use a static mapping.
  */
-struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
- struct device *dev)
+struct dma_buf_attachment *dma_buf_attach_unlocked(struct dma_buf *dmabuf,
+  struct device *dev)
 {
-   return dma_buf_dynamic_attach(dmabuf, dev, NULL, NULL);
+   return dma_buf_dynamic_attach_unlocked(dmabuf, dev, NULL, NULL);
 }
-EXPORT_SYMBOL_NS_GPL(dma_buf_attach, DMA_BUF);
+EXPORT_SYMBOL_NS_GPL(dma_buf_attach_unlocked, DMA_BUF);
 
 static void __unmap_dma_buf(struct dma_buf_attachment *attach,
struct sg_table *sg_table,
@@ -923,7 +923,7 @@ static void __unmap_dma_buf(struct dma_buf_attachment 
*attach,
 }
 
 /**
- * dma_buf_detach - Remove the given attachment from dmabuf's attachments list
+ * dma_buf_detach_unlocked - Remove the given attachment from dmabuf's 
attachments list
  * @dmabuf:[in]buffer to detach from.
  * @attach:[in]attachment to be detached; is free'd after this call.
  *
@@ -931,7 +931,8 @@ static void __unmap_dma_buf(struct dma_buf_attachment 
*attach,
  *
  * Optionally this calls _buf_ops.detach for device-specific detach.
  */
-void dma_buf_detach(struct 

[PATCH v1 4/6] dma-buf: Acquire wait-wound context on attachment

2022-07-14 Thread Dmitry Osipenko
Intel i915 GPU driver uses wait-wound mutex to lock multiple GEMs on the
attachment to the i915 dma-buf. In order to let all drivers utilize shared
wait-wound context during attachment in a general way, make dma-buf core to
acquire the ww context internally for the attachment operation and update
i915 driver to use the importer's ww context instead of the internal one.

>From now on all dma-buf exporters shall use the importer's ww context for
the attachment operation.

Signed-off-by: Dmitry Osipenko 
---
 drivers/dma-buf/dma-buf.c |  8 +-
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c|  2 +-
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c|  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_object.h|  6 ++---
 drivers/gpu/drm/i915/i915_gem_evict.c |  2 +-
 drivers/gpu/drm/i915/i915_gem_ww.c| 26 +++
 drivers/gpu/drm/i915/i915_gem_ww.h| 15 +--
 7 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 0ee588276534..37545ecb845a 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -807,6 +807,8 @@ static struct sg_table * __map_dma_buf(struct 
dma_buf_attachment *attach,
  * Optionally this calls _buf_ops.attach to allow device-specific attach
  * functionality.
  *
+ * Exporters shall use ww_ctx acquired by this function.
+ *
  * Returns:
  *
  * A pointer to newly created _buf_attachment on success, or a negative
@@ -822,6 +824,7 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
void *importer_priv)
 {
struct dma_buf_attachment *attach;
+   struct ww_acquire_ctx ww_ctx;
int ret;
 
if (WARN_ON(!dmabuf || !dev))
@@ -841,7 +844,8 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
attach->importer_ops = importer_ops;
attach->importer_priv = importer_priv;
 
-   dma_resv_lock(dmabuf->resv, NULL);
+   ww_acquire_init(_ctx, _ww_class);
+   dma_resv_lock(dmabuf->resv, _ctx);
 
if (dmabuf->ops->attach) {
ret = dmabuf->ops->attach(dmabuf, attach);
@@ -876,11 +880,13 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
}
 
dma_resv_unlock(dmabuf->resv);
+   ww_acquire_fini(_ctx);
 
return attach;
 
 err_attach:
dma_resv_unlock(attach->dmabuf->resv);
+   ww_acquire_fini(_ctx);
kfree(attach);
return ERR_PTR(ret);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c 
b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index c199bf71c373..9173f0232b16 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -173,7 +173,7 @@ static int i915_gem_dmabuf_attach(struct dma_buf *dmabuf,
if (!i915_gem_object_can_migrate(obj, INTEL_REGION_SMEM))
return -EOPNOTSUPP;
 
-   for_i915_gem_ww(, err, true) {
+   for_i915_dmabuf_ww(, dmabuf, err, true) {
err = i915_gem_object_migrate(obj, , INTEL_REGION_SMEM);
if (err)
continue;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 30fe847c6664..ad7d602fc43a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -3409,7 +3409,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
goto err_vma;
}
 
-   ww_acquire_done();
+   ww_acquire_done(eb.ww.ctx);
eb_capture_stage();
 
out_fence = eb_requests_create(, in_fence, out_fence_fd);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index e11d82a9f7c3..5ae38f94a5c7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -178,9 +178,9 @@ static inline int __i915_gem_object_lock(struct 
drm_i915_gem_object *obj,
int ret;
 
if (intr)
-   ret = dma_resv_lock_interruptible(obj->base.resv, ww ? >ctx 
: NULL);
+   ret = dma_resv_lock_interruptible(obj->base.resv, ww ? ww->ctx 
: NULL);
else
-   ret = dma_resv_lock(obj->base.resv, ww ? >ctx : NULL);
+   ret = dma_resv_lock(obj->base.resv, ww ? ww->ctx : NULL);
 
if (!ret && ww) {
i915_gem_object_get(obj);
@@ -216,7 +216,7 @@ static inline bool i915_gem_object_trylock(struct 
drm_i915_gem_object *obj,
if (!ww)
return dma_resv_trylock(obj->base.resv);
else
-   return ww_mutex_trylock(>base.resv->lock, >ctx);
+   return ww_mutex_trylock(>base.resv->lock, ww->ctx);
 }
 
 static inline void i915_gem_object_unlock(struct drm_i915_gem_object *obj)
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c 
b/drivers/gpu/drm/i915/i915_gem_evict.c
index 

[PATCH v1 3/6] dma-buf: Move all dma-bufs to dynamic locking specification

2022-07-14 Thread Dmitry Osipenko
This patch moves the non-dynamic dma-buf users over to the dynamic
locking specification. From now on all dma-buf importers are responsible
for holding dma-buf's reservation lock around operations performed over
dma-bufs. This strict locking convention prevents dead lock situation for
dma-buf importers and exporters.

Previously the "unlocked" versions of the dma-buf API functions weren't
taking the reservation lock and this patch makes them to take the lock.

Intel and AMD GPU drivers already were mapping imported dma-bufs under
the held lock, hence the "locked" variant of the functions are added
for them and the drivers are updated to use the "locked" versions.

Intel driver is also updated to not lock the exported buffer on
attachment since lock is now held by importer. We also need to move
the ww context acquirement from exporters (i915 driver) to importers,
otherwise lockdep won't be happy. This will be done in the next patch
since i915 is the only driver that uses ww context on attachment today
and it's not critical to make this change separately for i915 driver.

Signed-off-by: Dmitry Osipenko 
---
 drivers/dma-buf/dma-buf.c  | 125 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|   4 +-
 drivers/gpu/drm/drm_prime.c|   4 +-
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c |  12 +-
 include/linux/dma-buf.h|   6 +
 5 files changed, 104 insertions(+), 47 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index d16237a6ffaa..0ee588276534 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -841,14 +841,14 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
attach->importer_ops = importer_ops;
attach->importer_priv = importer_priv;
 
+   dma_resv_lock(dmabuf->resv, NULL);
+
if (dmabuf->ops->attach) {
ret = dmabuf->ops->attach(dmabuf, attach);
if (ret)
goto err_attach;
}
-   dma_resv_lock(dmabuf->resv, NULL);
list_add(>node, >attachments);
-   dma_resv_unlock(dmabuf->resv);
 
/* When either the importer or the exporter can't handle dynamic
 * mappings we cache the mapping here to avoid issues with the
@@ -859,7 +859,6 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
struct sg_table *sgt;
 
if (dma_buf_is_dynamic(attach->dmabuf)) {
-   dma_resv_lock(attach->dmabuf->resv, NULL);
ret = dmabuf->ops->pin(attach);
if (ret)
goto err_unlock;
@@ -872,15 +871,16 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
ret = PTR_ERR(sgt);
goto err_unpin;
}
-   if (dma_buf_is_dynamic(attach->dmabuf))
-   dma_resv_unlock(attach->dmabuf->resv);
attach->sgt = sgt;
attach->dir = DMA_BIDIRECTIONAL;
}
 
+   dma_resv_unlock(dmabuf->resv);
+
return attach;
 
 err_attach:
+   dma_resv_unlock(attach->dmabuf->resv);
kfree(attach);
return ERR_PTR(ret);
 
@@ -889,8 +889,7 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf *dmabuf, 
struct device *dev,
dmabuf->ops->unpin(attach);
 
 err_unlock:
-   if (dma_buf_is_dynamic(attach->dmabuf))
-   dma_resv_unlock(attach->dmabuf->resv);
+   dma_resv_unlock(dmabuf->resv);
 
dma_buf_detach_unlocked(dmabuf, attach);
return ERR_PTR(ret);
@@ -937,24 +936,23 @@ void dma_buf_detach_unlocked(struct dma_buf *dmabuf,
if (WARN_ON(!dmabuf || !attach))
return;
 
-   if (attach->sgt) {
-   if (dma_buf_is_dynamic(attach->dmabuf))
-   dma_resv_lock(attach->dmabuf->resv, NULL);
+   if (WARN_ON(dmabuf != attach->dmabuf))
+   return;
 
+   dma_resv_lock(dmabuf->resv, NULL);
+
+   if (attach->sgt) {
__unmap_dma_buf(attach, attach->sgt, attach->dir);
 
-   if (dma_buf_is_dynamic(attach->dmabuf)) {
+   if (dma_buf_is_dynamic(attach->dmabuf))
dmabuf->ops->unpin(attach);
-   dma_resv_unlock(attach->dmabuf->resv);
-   }
}
-
-   dma_resv_lock(dmabuf->resv, NULL);
list_del(>node);
-   dma_resv_unlock(dmabuf->resv);
+
if (dmabuf->ops->detach)
dmabuf->ops->detach(dmabuf, attach);
 
+   dma_resv_unlock(dmabuf->resv);
kfree(attach);
 }
 EXPORT_SYMBOL_NS_GPL(dma_buf_detach_unlocked, DMA_BUF);
@@ -1030,10 +1028,11 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_unpin, DMA_BUF);
  *
  * Important: Dynamic importers must wait for the exclusive fence of the struct
  * dma_resv attached to the DMA-BUF first.
+ *
+ * Importer is responsible for 

[PATCH v1 5/6] media: videobuf2: Stop using internal dma-buf lock

2022-07-14 Thread Dmitry Osipenko
All drivers that use dma-bufs have been moved to the updated locking
specification and now dma-buf reservation is guaranteed to be locked
by importers during the mapping operations. There is no need to take
the internal dma-buf lock anymore. Remove locking from the videobuf2
memory allocators.

Signed-off-by: Dmitry Osipenko 
---
 drivers/media/common/videobuf2/videobuf2-dma-contig.c | 11 +--
 drivers/media/common/videobuf2/videobuf2-dma-sg.c | 11 +--
 drivers/media/common/videobuf2/videobuf2-vmalloc.c| 11 +--
 3 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c 
b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index de762dbdaf78..2c69bf0470e7 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -382,18 +382,12 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
 {
struct vb2_dc_attachment *attach = db_attach->priv;
-   /* stealing dmabuf mutex to serialize map/unmap operations */
-   struct mutex *lock = _attach->dmabuf->lock;
struct sg_table *sgt;
 
-   mutex_lock(lock);
-
sgt = >sgt;
/* return previously mapped sg table */
-   if (attach->dma_dir == dma_dir) {
-   mutex_unlock(lock);
+   if (attach->dma_dir == dma_dir)
return sgt;
-   }
 
/* release any previous cache */
if (attach->dma_dir != DMA_NONE) {
@@ -409,14 +403,11 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
if (dma_map_sgtable(db_attach->dev, sgt, dma_dir,
DMA_ATTR_SKIP_CPU_SYNC)) {
pr_err("failed to map scatterlist\n");
-   mutex_unlock(lock);
return ERR_PTR(-EIO);
}
 
attach->dma_dir = dma_dir;
 
-   mutex_unlock(lock);
-
return sgt;
 }
 
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c 
b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index 39e11600304a..e63e718c0bf7 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -424,18 +424,12 @@ static struct sg_table *vb2_dma_sg_dmabuf_ops_map(
struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
 {
struct vb2_dma_sg_attachment *attach = db_attach->priv;
-   /* stealing dmabuf mutex to serialize map/unmap operations */
-   struct mutex *lock = _attach->dmabuf->lock;
struct sg_table *sgt;
 
-   mutex_lock(lock);
-
sgt = >sgt;
/* return previously mapped sg table */
-   if (attach->dma_dir == dma_dir) {
-   mutex_unlock(lock);
+   if (attach->dma_dir == dma_dir)
return sgt;
-   }
 
/* release any previous cache */
if (attach->dma_dir != DMA_NONE) {
@@ -446,14 +440,11 @@ static struct sg_table *vb2_dma_sg_dmabuf_ops_map(
/* mapping to the client with new direction */
if (dma_map_sgtable(db_attach->dev, sgt, dma_dir, 0)) {
pr_err("failed to map scatterlist\n");
-   mutex_unlock(lock);
return ERR_PTR(-EIO);
}
 
attach->dma_dir = dma_dir;
 
-   mutex_unlock(lock);
-
return sgt;
 }
 
diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c 
b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
index 7831bf545874..41db707e43a4 100644
--- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
+++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
@@ -267,18 +267,12 @@ static struct sg_table *vb2_vmalloc_dmabuf_ops_map(
struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
 {
struct vb2_vmalloc_attachment *attach = db_attach->priv;
-   /* stealing dmabuf mutex to serialize map/unmap operations */
-   struct mutex *lock = _attach->dmabuf->lock;
struct sg_table *sgt;
 
-   mutex_lock(lock);
-
sgt = >sgt;
/* return previously mapped sg table */
-   if (attach->dma_dir == dma_dir) {
-   mutex_unlock(lock);
+   if (attach->dma_dir == dma_dir)
return sgt;
-   }
 
/* release any previous cache */
if (attach->dma_dir != DMA_NONE) {
@@ -289,14 +283,11 @@ static struct sg_table *vb2_vmalloc_dmabuf_ops_map(
/* mapping to the client with new direction */
if (dma_map_sgtable(db_attach->dev, sgt, dma_dir, 0)) {
pr_err("failed to map scatterlist\n");
-   mutex_unlock(lock);
return ERR_PTR(-EIO);
}
 
attach->dma_dir = dma_dir;
 
-   mutex_unlock(lock);
-
return sgt;
 }
 
-- 
2.36.1



[PATCH v1 0/6] Move all drivers to a common dma-buf locking convention

2022-07-14 Thread Dmitry Osipenko
Hello,

This series moves all drivers to a dynamic dma-buf locking specification.
>From now on all dma-buf importers are made responsible for holding
dma-buf's reservation lock around all operations performed over dma-bufs.
This common locking convention allows us to utilize reservation lock more
broadly around kernel without fearing of potential dead locks.

This patchset passes all i915 selftests. It was also tested using VirtIO,
Panfrost, Lima and Tegra drivers. I tested cases of display+GPU,
display+V4L and GPU+V4L dma-buf sharing, which covers majority of kernel
drivers since rest of the drivers share same or similar code paths.

This is a continuation of [1] where Christian König asked to factor out
the dma-buf locking changes into separate series.

[1] 
https://lore.kernel.org/dri-devel/20220526235040.678984-1-dmitry.osipe...@collabora.com/

Dmitry Osipenko (6):
  dma-buf: Add _unlocked postfix to function names
  drm/gem: Take reservation lock for vmap/vunmap operations
  dma-buf: Move all dma-bufs to dynamic locking specification
  dma-buf: Acquire wait-wound context on attachment
  media: videobuf2: Stop using internal dma-buf lock
  dma-buf: Remove internal lock

 drivers/dma-buf/dma-buf.c | 198 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c   |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |   4 +-
 drivers/gpu/drm/armada/armada_gem.c   |  14 +-
 drivers/gpu/drm/drm_client.c  |   4 +-
 drivers/gpu/drm/drm_gem.c |  28 +++
 drivers/gpu/drm/drm_gem_cma_helper.c  |   6 +-
 drivers/gpu/drm/drm_gem_framebuffer_helper.c  |   6 +-
 drivers/gpu/drm/drm_gem_shmem_helper.c|   6 +-
 drivers/gpu/drm/drm_prime.c   |  12 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c   |   6 +-
 drivers/gpu/drm/exynos/exynos_drm_gem.c   |   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c|  20 +-
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c|   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_object.h|   6 +-
 .../drm/i915/gem/selftests/i915_gem_dmabuf.c  |  20 +-
 drivers/gpu/drm/i915/i915_gem_evict.c |   2 +-
 drivers/gpu/drm/i915/i915_gem_ww.c|  26 ++-
 drivers/gpu/drm/i915/i915_gem_ww.h|  15 +-
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |   8 +-
 drivers/gpu/drm/qxl/qxl_object.c  |  17 +-
 drivers/gpu/drm/qxl/qxl_prime.c   |   4 +-
 drivers/gpu/drm/tegra/gem.c   |  27 +--
 drivers/infiniband/core/umem_dmabuf.c |  11 +-
 .../common/videobuf2/videobuf2-dma-contig.c   |  26 +--
 .../media/common/videobuf2/videobuf2-dma-sg.c |  23 +-
 .../common/videobuf2/videobuf2-vmalloc.c  |  17 +-
 .../platform/nvidia/tegra-vde/dmabuf-cache.c  |  12 +-
 drivers/misc/fastrpc.c|  12 +-
 drivers/xen/gntdev-dmabuf.c   |  14 +-
 include/drm/drm_gem.h |   3 +
 include/linux/dma-buf.h   |  49 ++---
 32 files changed, 347 insertions(+), 257 deletions(-)

-- 
2.36.1



[PATCH] drm/i915/guc: Don't use pr_err when not necessary

2022-07-14 Thread John . C . Harrison
From: John Harrison 

A bunch of code was copy/pasted using pr_err as the default way to
report errors. However, drm_err is significantly more useful in
identifying where the error came from. So update the code to use that
instead.

Signed-off-by: John Harrison 
---
 drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c  | 10 ++---
 drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 37 +--
 .../drm/i915/gt/uc/selftest_guc_multi_lrc.c   | 10 ++---
 3 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
index 27363091e1afa..19fde6bda8f9c 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
@@ -195,11 +195,11 @@ __uc_fw_auto_select(struct drm_i915_private *i915, struct 
intel_uc_fw *uc_fw)
fw_blobs[i].rev < fw_blobs[i - 1].rev)
continue;
 
-   pr_err("invalid FW blob order: %s r%u comes before %s 
r%u\n",
-  intel_platform_name(fw_blobs[i - 1].p),
-  fw_blobs[i - 1].rev,
-  intel_platform_name(fw_blobs[i].p),
-  fw_blobs[i].rev);
+   drm_err(>drm, "Invalid FW blob order: %s r%u 
comes before %s r%u\n",
+   intel_platform_name(fw_blobs[i - 1].p),
+   fw_blobs[i - 1].rev,
+   intel_platform_name(fw_blobs[i].p),
+   fw_blobs[i].rev);
 
uc_fw->path = NULL;
}
diff --git a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c 
b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
index 1df71d0796aec..20e0c39259fba 100644
--- a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
@@ -62,7 +62,7 @@ static int intel_guc_scrub_ctbs(void *arg)
ce = intel_context_create(engine);
if (IS_ERR(ce)) {
ret = PTR_ERR(ce);
-   pr_err("Failed to create context, %d: %d\n", i, ret);
+   drm_err(>i915->drm, "Failed to create context, %d: 
%d\n", i, ret);
goto err;
}
 
@@ -83,7 +83,7 @@ static int intel_guc_scrub_ctbs(void *arg)
 
if (IS_ERR(rq)) {
ret = PTR_ERR(rq);
-   pr_err("Failed to create request, %d: %d\n", i, ret);
+   drm_err(>i915->drm, "Failed to create request, %d: 
%d\n", i, ret);
goto err;
}
 
@@ -93,7 +93,7 @@ static int intel_guc_scrub_ctbs(void *arg)
for (i = 0; i < 3; ++i) {
ret = i915_request_wait(last[i], 0, HZ);
if (ret < 0) {
-   pr_err("Last request failed to complete: %d\n", ret);
+   drm_err(>i915->drm, "Last request failed to 
complete: %d\n", ret);
goto err;
}
i915_request_put(last[i]);
@@ -110,7 +110,7 @@ static int intel_guc_scrub_ctbs(void *arg)
/* GT will not idle if G2H are lost */
ret = intel_gt_wait_for_idle(gt, HZ);
if (ret < 0) {
-   pr_err("GT failed to idle: %d\n", ret);
+   drm_err(>i915->drm, "GT failed to idle: %d\n", ret);
goto err;
}
 
@@ -150,7 +150,7 @@ static int intel_guc_steal_guc_ids(void *arg)
 
ce = kcalloc(GUC_MAX_CONTEXT_ID, sizeof(*ce), GFP_KERNEL);
if (!ce) {
-   pr_err("Context array allocation failed\n");
+   drm_err(>i915->drm, "Context array allocation failed\n");
return -ENOMEM;
}
 
@@ -164,24 +164,24 @@ static int intel_guc_steal_guc_ids(void *arg)
if (IS_ERR(ce[context_index])) {
ret = PTR_ERR(ce[context_index]);
ce[context_index] = NULL;
-   pr_err("Failed to create context: %d\n", ret);
+   drm_err(>i915->drm, "Failed to create context: %d\n", ret);
goto err_wakeref;
}
ret = igt_spinner_init(, engine->gt);
if (ret) {
-   pr_err("Failed to create spinner: %d\n", ret);
+   drm_err(>i915->drm, "Failed to create spinner: %d\n", ret);
goto err_contexts;
}
spin_rq = igt_spinner_create_request(, ce[context_index],
 MI_ARB_CHECK);
if (IS_ERR(spin_rq)) {
ret = PTR_ERR(spin_rq);
-   pr_err("Failed to create spinner request: %d\n", ret);
+   drm_err(>i915->drm, "Failed to create spinner request: 
%d\n", ret);
goto err_contexts;
}
ret = request_add_spin(spin_rq, );
if (ret) {
-   pr_err("Failed to add Spinner request: %d\n", ret);
+   

Re: [PATCH v5 4/9] drm: selftest: convert drm_format selftest to KUnit

2022-07-14 Thread Guenter Roeck
On Thu, Jul 14, 2022 at 04:51:40PM -0700, Guenter Roeck wrote:
> On Fri, Jul 08, 2022 at 05:30:47PM -0300, Maíra Canal wrote:
> > Considering the current adoption of the KUnit framework, convert the
> > DRM format selftest to the KUnit API.
> > 
> > Tested-by: David Gow 
> > Acked-by: Daniel Latypov 
> > Reviewed-by: Javier Martinez Canillas 
> > Signed-off-by: Maíra Canal 
> 
> This patch results in:
> 
> Building powerpc:allmodconfig ... failed
> --
> Error log:
> drivers/gpu/drm/tests/drm_format_test.c: In function 
> 'igt_check_drm_format_min_pitch':
> drivers/gpu/drm/tests/drm_format_test.c:271:1: error: the frame size of 3712 
> bytes is larger than 2048 bytes
> 

Also seen with i386:allyesconfig:

drivers/gpu/drm/tests/drm_format_test.c: In function 
'igt_check_drm_format_min_pitch':
drivers/gpu/drm/tests/drm_format_test.c:271:1: error: the frame size of 2572 
bytes is larger than 2048 bytes

Guenter


Re: [PATCH v5 4/9] drm: selftest: convert drm_format selftest to KUnit

2022-07-14 Thread Guenter Roeck
On Fri, Jul 08, 2022 at 05:30:47PM -0300, Maíra Canal wrote:
> Considering the current adoption of the KUnit framework, convert the
> DRM format selftest to the KUnit API.
> 
> Tested-by: David Gow 
> Acked-by: Daniel Latypov 
> Reviewed-by: Javier Martinez Canillas 
> Signed-off-by: Maíra Canal 

This patch results in:

Building powerpc:allmodconfig ... failed
--
Error log:
drivers/gpu/drm/tests/drm_format_test.c: In function 
'igt_check_drm_format_min_pitch':
drivers/gpu/drm/tests/drm_format_test.c:271:1: error: the frame size of 3712 
bytes is larger than 2048 bytes

presumably due to function nesting.

Guenter


Re: [PATCH v2 00/29] drm/kms: Stop registering multiple /sys/class/backlight devs for a single display

2022-07-14 Thread Lyude Paul
I assume you're probably good on review for the non-nouveau stuff, but if you
end up needing any help with that feel free to poke me!

On Tue, 2022-07-12 at 21:38 +0200, Hans de Goede wrote:
> Hi All,
> 
> As mentioned in my RFC titled "drm/kms: control display brightness through
> drm_connector properties":
> https://lore.kernel.org/dri-devel/0d188965-d809-81b5-74ce-7d30c49fe...@redhat.com/
> 
> The first step towards this is to deal with some existing technical debt
> in backlight handling on x86/ACPI boards, specifically we need to stop
> registering multiple /sys/class/backlight devs for a single display.
> 
> This series implements my RFC describing my plan for these cleanups:
> https://lore.kernel.org/dri-devel/98519ba0-7f18-201a-ea34-652f50343...@redhat.com/
> 
> This new version addresses the few small remarks made on version 1 (mainly
> changing patch 1/29) and more importantly this finishes the refactoring by
> else addressing all the bits from the "Other issues" section of
> the refactor RFC (resulting in patches 15-29 which are new in v2).
> 
> Please review and test! I hope to be able to make an immutable branch
> based on 5.20-rc1 + this series available for merging into the various
> touched subsystems once 5.20-rc2 is out.
> 
> Regards,
> 
> Hans
> 
> 
> Hans de Goede (29):
>   ACPI: video: Add acpi_video_backlight_use_native() helper
>   drm/i915: Don't register backlight when another backlight should be
>     used
>   drm/amdgpu: Don't register backlight when another backlight should be
>     used
>   drm/radeon: Don't register backlight when another backlight should be
>     used
>   drm/nouveau: Don't register backlight when another backlight should be
>     used
>   ACPI: video: Drop backlight_device_get_by_type() call from
>     acpi_video_get_backlight_type()
>   ACPI: video: Remove acpi_video_bus from list before tearing it down
>   ACPI: video: Simplify acpi_video_unregister_backlight()
>   ACPI: video: Make backlight class device registration a separate step
>   ACPI: video: Remove code to unregister acpi_video backlight when a
>     native backlight registers
>   drm/i915: Call acpi_video_register_backlight() (v2)
>   drm/nouveau: Register ACPI video backlight when nv_backlight
>     registration fails
>   drm/amdgpu: Register ACPI video backlight when skipping amdgpu
>     backlight registration
>   drm/radeon: Register ACPI video backlight when skipping radeon
>     backlight registration
>   ACPI: video: Refactor acpi_video_get_backlight_type() a bit
>   ACPI: video: Add Nvidia WMI EC brightness control detection
>   ACPI: video: Add Apple GMUX brightness control detection
>   platform/x86: apple-gmux: Stop calling acpi/video.h functions
>   platform/x86: toshiba_acpi: Stop using
>     acpi_video_set_dmi_backlight_type()
>   platform/x86: acer-wmi: Move backlight DMI quirks to
>     acpi/video_detect.c
>   platform/x86: asus-wmi: Drop DMI chassis-type check from backlight
>     handling
>   platform/x86: asus-wmi: Move acpi_backlight=vendor quirks to ACPI
>     video_detect.c
>   platform/x86: asus-wmi: Move acpi_backlight=native quirks to ACPI
>     video_detect.c
>   platform/x86: samsung-laptop: Move acpi_backlight=[vendor|native]
>     quirks to ACPI video_detect.c
>   ACPI: video: Remove acpi_video_set_dmi_backlight_type()
>   ACPI: video: Drop "Samsung X360" acpi_backlight=native quirk
>   ACPI: video: Drop Clevo/TUXEDO NL5xRU and NL5xNU acpi_backlight=native
>     quirks
>   ACPI: video: Fix indentation of video_detect_dmi_table[] entries
>   drm/todo: Add entry about dealing with brightness control on devices
>     with > 1 panel
> 
>  Documentation/gpu/todo.rst    |  68 +++
>  drivers/acpi/Kconfig  |   1 +
>  drivers/acpi/acpi_video.c |  59 ++-
>  drivers/acpi/video_detect.c   | 415 +++---
>  drivers/gpu/drm/Kconfig   |  12 +
>  .../gpu/drm/amd/amdgpu/atombios_encoders.c    |  14 +-
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   9 +
>  drivers/gpu/drm/gma500/Kconfig    |   2 +
>  drivers/gpu/drm/i915/Kconfig  |   2 +
>  .../gpu/drm/i915/display/intel_backlight.c    |   7 +
>  drivers/gpu/drm/i915/display/intel_display.c  |   8 +
>  drivers/gpu/drm/i915/display/intel_panel.c    |   3 +
>  drivers/gpu/drm/i915/i915_drv.h   |   2 +
>  drivers/gpu/drm/nouveau/nouveau_backlight.c   |  14 +
>  drivers/gpu/drm/radeon/atombios_encoders.c    |   7 +
>  drivers/gpu/drm/radeon/radeon_encoders.c  |  11 +-
>  .../gpu/drm/radeon/radeon_legacy_encoders.c   |   7 +
>  drivers/platform/x86/acer-wmi.c   |  66 ---
>  drivers/platform/x86/apple-gmux.c |   3 -
>  drivers/platform/x86/asus-nb-wmi.c    |  21 -
>  drivers/platform/x86/asus-wmi.c   |  13 -
>  drivers/platform/x86/asus-wmi.h   |   2 -
>  drivers/platform/x86/eeepc-wmi.c  |  25 +-
>  

Re: [Intel-gfx] [PATCH 1/1] drm/i915/guc: Update to GuC version 70.1.1

2022-07-14 Thread Dave Airlie
On Fri, 15 Apr 2022 at 10:15, Matt Roper  wrote:
>
> On Tue, Apr 12, 2022 at 03:59:55PM -0700, john.c.harri...@intel.com wrote:
> > From: John Harrison 
> >
> > The latest GuC firmware drops the context descriptor pool in favour of
> > passing all creation data in the create H2G. It also greatly simplifies
> > the work queue and removes the process descriptor used for multi-LRC
> > submission. So, remove all mention of LRC and process descriptors and
> > update the registration code accordingly.
> >
> > Unfortunately, the new API also removes the ability to set default
> > values for the scheduling policies at context registration time.
> > Instead, a follow up H2G must be sent. The individual scheduling
> > policy update H2G commands are also dropped in favour of a single KLV
> > based H2G. So, change the update wrappers accordingly and call this
> > during context registration..
> >
> > Of course, this second H2G per registration might fail due to being
> > backed up. The registration code has a complicated state machine to
> > cope with the actual registration call failing. However, if that works
> > then there is no support for unwinding if a further call should fail.
> > Unwinding would require sending a H2G to de-register - but that can't
> > be done because the CTB is already backed up.
> >
> > So instead, add a new flag to say whether the context has a pending
> > policy update. This is set if the policy H2G fails at registration
> > time. The submission code checks for this flag and retries the policy
> > update if set. If that call fails, the submission path early exists
> > with a retry error. This is something that is already supported for
> > other reasons.
> >
> > Signed-off-by: John Harrison 
> > Reviewed-by: Daniele Ceraolo Spurio 
>
> Applied to drm-intel-gt-next.  Thanks for the patch and review.
>

(cc'ing Linus and danvet, as a headsup, there is also a phoronix
article where this was discovered).

Okay WTF.

This is in no way acceptable. This needs to be fixed in 5.19-rc ASAP.

Once hardware is released and we remove the gate flag by default, you
cannot just bump firmware versions blindly.

The kernel needs to retain compatibility with all released firmwares
since a device was declared supported.

This needs to be reverted, and then 70 should be introduced with a
fallback to 69 versions.

Very disappointing, I expect this to get dealt with v.quickly.

Dave.


Re: [PATCH v2 05/29] drm/nouveau: Don't register backlight when another backlight should be used

2022-07-14 Thread Lyude Paul
Reviewed-by: Lyude Paul 

You also have permission to push this to drm-misc-whatever

On Tue, 2022-07-12 at 21:38 +0200, Hans de Goede wrote:
> Before this commit when we want userspace to use the acpi_video backlight
> device we register both the GPU's native backlight device and acpi_video's
> firmware acpi_video# backlight device. This relies on userspace preferring
> firmware type backlight devices over native ones.
> 
> Registering 2 backlight devices for a single display really is
> undesirable, don't register the GPU's native backlight device when
> another backlight device should be used.
> 
> Reviewed-by: Lyude Paul 
> Signed-off-by: Hans de Goede 
> ---
>  drivers/gpu/drm/nouveau/nouveau_backlight.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> index a2141d3d9b1d..91c504c7b82c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> @@ -34,6 +34,8 @@
>  #include 
>  #include 
>  
> +#include 
> +
>  #include "nouveau_drv.h"
>  #include "nouveau_reg.h"
>  #include "nouveau_encoder.h"
> @@ -405,6 +407,11 @@ nouveau_backlight_init(struct drm_connector *connector)
> goto fail_alloc;
> }
>  
> +   if (!acpi_video_backlight_use_native()) {
> +   NV_INFO(drm, "Skipping nv_backlight registration\n");
> +   goto fail_alloc;
> +   }
> +
> if (!nouveau_get_backlight_name(backlight_name, bl)) {
> NV_ERROR(drm, "Failed to retrieve a unique name for the
> backlight interface\n");
> goto fail_alloc;

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat



[PATCH RESEND v6] backlight: lp855x: Switch to atomic PWM API

2022-07-14 Thread Maíra Canal
Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
replace it for the atomic PWM API.

Reviewed-by: Uwe Kleine-König 
Reviewed-by: Daniel Thompson 
Signed-off-by: Maíra Canal 
---
V1 -> V2: Initialize variable and simplify conditional loop
V2 -> V3: Fix assignment of NULL variable
V3 -> V4: Replace division for pwm_set_relative_duty_cycle
V4 -> V5: Fix overwrite of state.period
V5 -> V6: Fix duty cycle rounding and set period outside conditional loop
---
 drivers/video/backlight/lp855x_bl.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/video/backlight/lp855x_bl.c 
b/drivers/video/backlight/lp855x_bl.c
index 2b9e203e..fc02c5c16055 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -218,9 +218,8 @@ static int lp855x_configure(struct lp855x *lp)
 
 static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
 {
-   unsigned int period = lp->pdata->period_ns;
-   unsigned int duty = br * period / max_br;
struct pwm_device *pwm;
+   struct pwm_state state;
 
/* request pwm device with the consumer name */
if (!lp->pwm) {
@@ -230,18 +229,16 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, 
int max_br)
 
lp->pwm = pwm;
 
-   /*
-* FIXME: pwm_apply_args() should be removed when switching to
-* the atomic PWM API.
-*/
-   pwm_apply_args(pwm);
+   pwm_init_state(lp->pwm, );
+   } else {
+   pwm_get_state(lp->pwm, );
}
 
-   pwm_config(lp->pwm, duty, period);
-   if (duty)
-   pwm_enable(lp->pwm);
-   else
-   pwm_disable(lp->pwm);
+   state.period = lp->pdata->period_ns;
+   state.duty_cycle = div_u64(br * state.period, max_br);
+   state.enabled = state.duty_cycle;
+
+   pwm_apply_state(lp->pwm, );
 }
 
 static int lp855x_bl_update_status(struct backlight_device *bl)
-- 
2.36.1



Re: [Freedreno] [PATCH v2.5] drm/msm/dsi: switch to DRM_PANEL_BRIDGE

2022-07-14 Thread Abhinav Kumar




On 7/12/2022 6:22 AM, Dmitry Baryshkov wrote:

Currently the DSI driver has two separate paths: one if the next device
in a chain is a bridge and another one if the panel is connected
directly to the DSI host. Simplify the code path by using panel-bridge
driver (already selected in Kconfig) and dropping support for
handling the panel directly.

Signed-off-by: Dmitry Baryshkov 
---

I'm not sending this as a separate patchset (I'd like to sort out mdp5
first), but more of a preview of changes related to
msm_dsi_manager_ext_bridge_init().

---
  drivers/gpu/drm/msm/dsi/dsi.c |  35 +---
  drivers/gpu/drm/msm/dsi/dsi.h |  16 +-
  drivers/gpu/drm/msm/dsi/dsi_host.c|  25 ---
  drivers/gpu/drm/msm/dsi/dsi_manager.c | 283 +++---
  4 files changed, 36 insertions(+), 323 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 1625328fa430..4edb9167e600 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -6,14 +6,6 @@
  #include "dsi.h"
  #include "dsi_cfg.h"
  
-struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi)

-{
-   if (!msm_dsi || !msm_dsi_device_connected(msm_dsi))
-   return NULL;
-
-   return msm_dsi->encoder;
-}
-
  bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi)
  {
unsigned long host_flags = msm_dsi_host_get_mode_flags(msm_dsi->host);
@@ -220,7 +212,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct 
drm_device *dev,
 struct drm_encoder *encoder)
  {
struct msm_drm_private *priv;
-   struct drm_bridge *ext_bridge;
int ret;
  
  	if (WARN_ON(!encoder) || WARN_ON(!msm_dsi) || WARN_ON(!dev))

@@ -254,26 +245,10 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct 
drm_device *dev,
goto fail;
}
  
-	/*

-* check if the dsi encoder output is connected to a panel or an
-* external bridge. We create a connector only if we're connected to a
-* drm_panel device. When we're connected to an external bridge, we
-* assume that the drm_bridge driver will create the connector itself.
-*/
-   ext_bridge = msm_dsi_host_get_bridge(msm_dsi->host);
-
-   if (ext_bridge)
-   msm_dsi->connector =
-   msm_dsi_manager_ext_bridge_init(msm_dsi->id);
-   else
-   msm_dsi->connector =
-   msm_dsi_manager_connector_init(msm_dsi->id);
-
-   if (IS_ERR(msm_dsi->connector)) {
-   ret = PTR_ERR(msm_dsi->connector);
+   ret = msm_dsi_manager_ext_bridge_init(msm_dsi->id);
+   if (ret) {
DRM_DEV_ERROR(dev->dev,
"failed to create dsi connector: %d\n", ret);
-   msm_dsi->connector = NULL;
goto fail;
}
  
@@ -287,12 +262,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,

msm_dsi->bridge = NULL;
}
  
-	/* don't destroy connector if we didn't make it */

-   if (msm_dsi->connector && !msm_dsi->external_bridge)
-   msm_dsi->connector->funcs->destroy(msm_dsi->connector);
-
-   msm_dsi->connector = NULL;


From what i can see all the usages of msm_dsi->connector are removed 
after this change. So can we drop that?



-
return ret;
  }
  
diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h

index 580a1e6358bf..703e4c88d7fb 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -12,7 +12,6 @@
  #include 
  #include 
  #include 
-#include 
  
  #include "msm_drv.h"

  #include "disp/msm_disp_snapshot.h"
@@ -49,8 +48,6 @@ struct msm_dsi {
struct drm_device *dev;
struct platform_device *pdev;
  
-	/* connector managed by us when we're connected to a drm_panel */

-   struct drm_connector *connector;
/* internal dsi bridge attached to MDP interface */
struct drm_bridge *bridge;
  
@@ -58,10 +55,8 @@ struct msm_dsi {

struct msm_dsi_phy *phy;
  
  	/*

-* panel/external_bridge connected to dsi bridge output, only one of the
-* two can be valid at a time
+* external_bridge connected to dsi bridge output
 */
-   struct drm_panel *panel;
struct drm_bridge *external_bridge;
  
  	struct device *phy_dev;

@@ -76,8 +71,7 @@ struct msm_dsi {
  /* dsi manager */
  struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
  void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
-struct drm_connector *msm_dsi_manager_connector_init(u8 id);
-struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
+int msm_dsi_manager_ext_bridge_init(u8 id);
  int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
  bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
  int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
@@ -87,11 +81,9 @@ void 

[pull] amdgpu, amdkfd, radeon drm-next-5.20

2022-07-14 Thread Alex Deucher
Hi Dave, Daniel,

A few more new things for 5.20.

The following changes since commit c5da61cf5bab30059f22ea368702c445ee87171a:

  drm/amdgpu/display: add missing FP_START/END checks dcn32_clk_mgr.c 
(2022-06-30 19:35:21 -0400)

are available in the Git repository at:

  https://gitlab.freedesktop.org/agd5f/linux.git 
tags/amd-drm-next-5.20-2022-07-14

for you to fetch changes up to b7be3ae759160aa3355ebeb0583f67fb9bda4dae:

  drm/amd/display: remove duplicate dcn314 includes (2022-07-13 20:57:05 -0400)


amd-drm-next-5.20-2022-07-14:

amdgpu:
- DCN3.2 updates
- DC SubVP support
- DP MST fixes
- Audio fixes
- DC code cleanup
- SMU13 updates
- Adjust GART size on newer APUs for S/G display
- Soft reset for GFX 11
- Soft reset for SDMA 6
- Add gfxoff status query for vangogh
- Improve BO domain pinning
- Fix timestamps for cursor only commits
- MES fixes
- DCN 3.1.4 support
- Misc fixes
- Misc code cleanup

amdkfd:
- Simplify GPUVM validation
- Unified memory for CWSR save/restore area
- fix possible list corruption on queue failure

radeon:
- Fix bogus power of two warning

UAPI:
- Unified memory for CWSR save/restore area for KFD
  Proposed userspace: 
https://lists.freedesktop.org/archives/amd-gfx/2022-June/080952.html


Alan Liu (1):
  drm/amd/display: Program ACP related register

Alex Deucher (11):
  drm/amdgpu: keep fbdev buffers pinned during suspend
  drm/amdgpu/display: disable prefer_shadow for generic fb helpers
  drm/amd/display: remove set but unused variable
  drm/amd/display: make get_refresh_rate() static
  drm/amd/display: fix non-x86/PPC64 compilation
  drm/amd/display: fix 32 bit compilation errors in dc_dmub_srv.c
  drm/amdgpu/gmc10: adjust gart size for parts that support S/G display
  drm/amdgpu: fix file permissions on some files
  drm/amd/display: make some dc_dmub_srv functions static
  drm/amd/display: attempt to fix the logic in commit_planes_for_stream()
  drm/amd/display: remove duplicate dcn314 includes

Alvin Lee (6):
  drm/amd/display: Add SubVP required code
  drm/amd/display: Change DET policy for MPO cases
  drm/amd/display: Make OPTC3 function accessible to other DCN
  drm/amd/display: Don't set dram clock change requirement for SubVP
  drm/amd/display: Maintain old audio programming sequence
  drm/amd/display: Exit SubVP if MPO in use

André Almeida (2):
  drm/amdpgu/debugfs: Simplify some exit paths
  drm/amd/pm: Implement get GFXOFF status for vangogh

Aric Cyr (3):
  drm/amd/display: 3.2.192
  drm/amd/display: 3.2.193
  drm/amd/display: 3.2.194

Aurabindo Pillai (5):
  drm/amd: Add debug mask for subviewport mclk switch
  drm/amd/display: remove stale debug setting
  drm/amd/display: Add callback to set dig mode
  drm/amd/display: Enable ODM combine default policy
  drm/amd/display: Add NBIO reg offsets to DC

Charlene Liu (1):
  drm/amd/display: add system info table log

Chris Park (4):
  drm/amd/display: Switch to correct DTO on HDMI
  drm/amd/display: Indicate stream change on ODM change
  drm/amd/display: OVT Update on InfoFrame and Mode Management
  drm/amd/display: Reduce SCDC Status Flags Definition

Dmytro Laktyushkin (2):
  drm/amd/display: disable timing sync b/w odm halves
  drm/amd/display: disable otg toggle w/a on boot

Duncan Ma (1):
  drm/amd/display: Add flag to modify MST delay

Eric Bernstein (3):
  drm/amd/display: Add function to set pixels per cycle
  drm/amd/display: Update gpuvm_max_page_table_levels IP param
  drm/amd/display: Fix null timing generator resource

Eric Huang (4):
  drm/amdkfd: add new flag for svm
  drm/amdkfd: change svm range evict
  drm/amdkfd: optimize svm range evict
  drm/amdkfd: bump KFD version for unified ctx save/restore memory

Ethan Wellenreiter (1):
  drm/amd/display: Re-implementing ARGB16161616 pixel format as 22

Evan Quan (2):
  drm/amd/pm: update SMU 13.0.0 driver_if header
  drm/amd/display: correct idle_power_optimizations disablement return value

Evgenii Krasnikov (1):
  drm/amd/display: add an option to skip wait for HPD when powering on eDP 
panel

Fangzhi Zuo (2):
  drm/amd/display: Fix dmub soft hang for PSR 1
  drm/amd/display: Ignore First MST Sideband Message Return Error

Guo Zhengkui (1):
  drm/amd/display: remove repeated includes

Hamza Mahfooz (2):
  drm/amd/display: enable PCON SST support for newer ASICs
  drm/amd/display: rename hdmi_frl_pcon_support

Harry Wentland (2):
  drm/amd/display: Move all linux includes into OS types
  drm/amd/display: Add DCN reg offsets to DC

Ilya Bakoulin (1):
  drm/amd/display: Fix black screen when disabling Freesync in OSD

Jack Xiao (7):
  drm/amdgpu/mes11: fix to unmap legacy queue
  drm/amdgpu/mes: fix 

Re: [PATCH v1] drm/scheduler: Don't kill jobs in interrupt context

2022-07-14 Thread Alex Deucher
On Thu, Jul 14, 2022 at 1:58 PM Andrey Grodzovsky
 wrote:
>
> On 2022-07-14 12:22, Alex Deucher wrote:
>
> > On Thu, Jul 14, 2022 at 10:14 AM Andrey Grodzovsky
> >  wrote:
> >>
> >> On 2022-07-14 05:57, Dmitry Osipenko wrote:
> >>> On 7/12/22 11:56, Dmitry Osipenko wrote:
>  On 7/6/22 18:46, Alex Deucher wrote:
> > On Wed, Jul 6, 2022 at 9:49 AM Andrey Grodzovsky
> >  wrote:
> >> On 2022-07-06 03:07, Dmitry Osipenko wrote:
> >>
> >>> Hello Andrey,
> >>>
> >>> On 5/17/22 17:48, Dmitry Osipenko wrote:
>  On 5/17/22 17:13, Andrey Grodzovsky wrote:
> > Done.
> >
> > Andrey
>  Awesome, thank you!
> 
> >>> Given that this drm-scheduler issue needs to be fixed in the 5.19-RC 
> >>> and
> >>> earlier, shouldn't it be in the drm-fixes and not in drm-next?
> >> I pushed it into drm-misc from where it got into drm-next. I don't have
> >> permission for drm-fixes.
> > The -fixes branch of drm-misc.
>  Now I don't see the scheduler bugfix neither in the -fixes branch nor in
>  the -next and today Dave sent out 5.19-rc7 pull request without the
>  scheduler fix. Could anyone please check what is going on with the DRM
>  patches? Thanks!
> 
>  https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffreedesktop%2Fdrm-misc%2Fcommits%2Fdrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7Cd62c2e6d3ec748cd639608da65b52548%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637934125954377887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=WPmMC%2B%2Fy83cUctuF%2FLNo9VhWnB%2FkpUVQotMh74VshB8%3Dreserved=0
>  https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fdrm%2Fdrm-misc%2Flog%2F%3Fh%3Ddrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7Cd62c2e6d3ec748cd639608da65b52548%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637934125954377887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=RzCMLUYLmUjSmvDm4E%2FJr%2B5rp7E8UvjFt1tmwBoBiVc%3Dreserved=0
> >>> The patch is in the drm-misc-next-fixes, so it wasn't moved to the
> >>> drm-misc-fixes.
> >>>
> >>> Andrey, don't you have access to drm-misc-fixes? Or you meant
> >>> drm-fixes=drm-misc-fixes?
> >>
> >> I have only accesses to drm-misc-next to which I pushed this patch.
> > anyone with drm-misc rights can commit to any of the branches in the
> > drm-misc tree.  You just need to check out and push the appropriate
> > branch.  then push the changes.  E.g.,
> > dim push-branch drm-misc-next
> > vs
> > dim push-branch drm-misc-next-fixes
> > etc.
> >
> > Alex
>
>
> I see, but what  is the reason then that Dave sent out 5.19-rc7 pull
> request without the
> scheduler fix if the patch was merged into drm-misc-next long ago ? All
> the changes from
> there are usually picked up for pull requests, no ?

drm-misc-next is for new stuff for the next kernel (e.g., 5.20).
drm-misc-fixes is for fixes for the current kernel cycle (e.g., 5.19).
See:
https://drm.pages.freedesktop.org/maintainer-tools/drm-misc.html

Alex

>
> Andrey
>
>
> >
> >
> >> Andrey
> >>
> >>


Re: [PATCH] drm/amd/display: Add missing hard-float compile flags for PPC64 builds

2022-07-14 Thread Guenter Roeck

On 7/14/22 11:49, Melissa Wen wrote:

O 07/13, Alex Deucher wrote:

On Wed, Jul 13, 2022 at 7:09 PM Guenter Roeck  wrote:


On Wed, Jul 13, 2022 at 05:20:40PM -0400, Alex Deucher wrote:


The problem is not the FPU operations, but the fact that soft-float
and hard-float compiled code is linked together. The soft-float and
hard-float ABIs on powerpc are not compatible, so one ends up with
an object file which is partially soft-float and partially hard-float
compiled and thus uses different ABIs. That can only create chaos,
so the linker complains about it.


I get that, I just don't see why only DCN 3.1.x files have this
problem.  The DCN 2.x files should as well.



Seen in drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile:

# prevent build errors regarding soft-float vs hard-float FP ABI tags
# this code is currently unused on ppc64, as it applies to Renoir APUs only
ifdef CONFIG_PPC64
CFLAGS_$(AMDDALPATH)/dc/clk_mgr/dcn21/rn_clk_mgr.o := $(call 
cc-option,-mno-gnu-attribute)
endif

Does that explain it ?


I would expect to see it in dcn20_resource.c and dcn30_clk_mgr.c for
example.  They follow the same pattern as the dcn 3.1.x files.  They
call functions that use FP, but maybe there is some FP code still in
those functions that we missed somehow.


Hi,

I'm a little late here, but I'm not able to reproduce the issue yet.
I have this setup:
- gcc 11.3.0
- binutils 2.38.50
- mainline kernel (torvalds) version: 5.19.0-rc6 (cross-compiling)
   -> make ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- allmodconfig
 => DRM_AMD_DC [=y] && HAS_IOMEM [=y] && DRM [=m] && DRM_AMDGPU [=m] && (X86 || 
PPC64 [=y]) && (!KCOV_INSTRUMENT_ALL [=n] || !KCOV_ENABLE_COMPARISONS [=n])
   -> make -j16 ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu-

Am I missing something?

So, as Alex mentioned the possibility of some non-isolated FPU code in
3.1, I reviewed dcn31 code and my best bet so far is that the issue
is here:

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c#L1721

Although dcn31_update_soc_for_wm_a() is only called inside
dml/dcn31/dcn31_fpu:
- dc->res_pool->funcs->update_soc_for_wm_a(dc, context);

it's declared in dcn31_resource and has FPU code. So, we should move it
to dml/dcn31/dcn31_fpu.

However, as I can't reproduce the issue, I don't know if it addresses
the problem reported here and also if everything will be clean after
moving it.



I don't think that would solve anything. As I have tried to point out,
the problem is that code compiled with hard-float is linked together
with code compiled with soft-float. An alternate fix might be something
like the one attached below, but I don't know if that would be correct
and/or complete.


Guenter,

Can you provide more info about your setup: cross-compile or not, any
flags, branch, etc?



Nothing special. Same compile options as the ones you use, and it is a
cross-compile environment. I tried gcc 11.2.0 with binutils 2.36.1
and gcc 11.3.0 with binutils 2.38.

Guenter

---
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn31/Makefile
index ec041e3cda30..44ff6f196860 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/Makefile
@@ -10,6 +10,8 @@
 #
 # Makefile for dcn31.

+CFLAGS_$(AMDDALPATH)/dc/dcn31/dcn31_resource.o := $(call 
cc-option,-mno-gnu-attribute)
+
 DCN31 = dcn31_resource.o dcn31_hubbub.o dcn31_hwseq.o dcn31_init.o 
dcn31_hubp.o \
dcn31_dccg.o dcn31_optc.o dcn31_dio_link_encoder.o dcn31_panel_cntl.o \
dcn31_apg.o dcn31_hpo_dp_stream_encoder.o dcn31_hpo_dp_link_encoder.o \
diff --git a/drivers/gpu/drm/amd/display/dc/dcn315/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn315/Makefile
index 59381d24800b..55fcae2d2aae 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn315/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn315/Makefile
@@ -25,6 +25,8 @@

 DCN315 = dcn315_resource.o

+CFLAGS_$(AMDDALPATH)/dc/dcn315/$(DCN315) := $(call 
cc-option,-mno-gnu-attribute)
+
 AMD_DAL_DCN315 = $(addprefix $(AMDDALPATH)/dc/dcn315/,$(DCN315))

 AMD_DISPLAY_FILES += $(AMD_DAL_DCN315)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn316/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn316/Makefile
index 819d44a9439b..7251ef9c1afb 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn316/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn316/Makefile
@@ -25,6 +25,8 @@

 DCN316 = dcn316_resource.o

+CFLAGS_$(AMDDALPATH)/dc/dcn316/$(DCN316) := $(call 
cc-option,-mno-gnu-attribute)
+
 AMD_DAL_DCN316 = $(addprefix $(AMDDALPATH)/dc/dcn316/,$(DCN316))

 AMD_DISPLAY_FILES += $(AMD_DAL_DCN316)


Re: [PATCH v2 27/29] ACPI: video: Drop Clevo/TUXEDO NL5xRU and NL5xNU acpi_backlight=native quirks

2022-07-14 Thread Hans de Goede
Hi,

On 7/13/22 19:21, Limonciello, Mario wrote:
> [Public]
> 
> 
> 
>> -Original Message-
>> From: Werner Sembach 
>> Sent: Wednesday, July 13, 2022 12:08
>> To: Hans de Goede ; Ben Skeggs
>> ; Karol Herbst ; Lyude
>> ; Daniel Dadap ; Maarten
>> Lankhorst ; Maxime Ripard
>> ; Thomas Zimmermann ;
>> Jani Nikula ; Joonas Lahtinen
>> ; Rodrigo Vivi ;
>> Tvrtko Ursulin ; Deucher, Alexander
>> ; Koenig, Christian
>> ; p...@vger.kernel.org; Pan, Xinhui
>> ; Rafael J . Wysocki ; Mika
>> Westerberg ; Lukas Wunner
>> ; Mark Gross ; Andy
>> Shevchenko 
>> Cc: nouv...@lists.freedesktop.org; Daniel Vetter ; David
>> Airlie ; intel-gfx ; dri-
>> de...@lists.freedesktop.org; amd-...@lists.freedesktop.org; Len Brown
>> ; linux-a...@vger.kernel.org; platform-driver-
>> x...@vger.kernel.org
>> Subject: Re: [PATCH v2 27/29] ACPI: video: Drop Clevo/TUXEDO NL5xRU and
>> NL5xNU acpi_backlight=native quirks
>>
>> Hi,
>>
>> On 7/12/22 21:39, Hans de Goede wrote:
>>> acpi_backlight=native is the default for these, but as the comment
>>> explains the quirk was still necessary because even briefly registering
>>> the acpi_video0 backlight; and then unregistering it once the native
>>> driver showed up, was leading to issues.
>>>
>>> After the "ACPI: video: Make backlight class device registration
>>> a separate step" patch from earlier in this patch-series, we no
>>> longer briefly register the acpi_video0 backlight on systems where
>>> the native driver should be used.
>>>
>>> So this is no longer an issue an the quirks are no longer needed.
>>>
>>> Cc: Werner Sembach 
>>> Signed-off-by: Hans de Goede 
>>
>> Tested and can confirm: The quirks are no longer needed with this Patchset.
>>
>> Tested-by: Werner Sembach 
> 
> Probably should include this link tag in this commit too then as it fixes
> the Tong Fang systems too.
> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=215683

Good point, I've added this to the version in my personal tree.

Regards,

Hans




> 
>>
>> Kind Regards,
>>
>> Werner Sembach
>>
>>> ---
>>>   drivers/acpi/video_detect.c | 75 -
>>>   1 file changed, 75 deletions(-)
>>>
>>> diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
>>> index 2a4d376a703e..4b9395d1bda7 100644
>>> --- a/drivers/acpi/video_detect.c
>>> +++ b/drivers/acpi/video_detect.c
>>> @@ -599,81 +599,6 @@ static const struct dmi_system_id
>> video_detect_dmi_table[] = {
>>> DMI_MATCH(DMI_BOARD_NAME, "N250P"),
>>> },
>>> },
>>> -   /*
>>> -* Clevo NL5xRU and NL5xNU/TUXEDO Aura 15 Gen1 and Gen2 have
>> both a
>>> -* working native and video interface. However the default detection
>>> -* mechanism first registers the video interface before unregistering
>>> -* it again and switching to the native interface during boot. This
>>> -* results in a dangling SBIOS request for backlight change for some
>>> -* reason, causing the backlight to switch to ~2% once per boot on
>> the
>>> -* first power cord connect or disconnect event. Setting the native
>>> -* interface explicitly circumvents this buggy behaviour, by avoiding
>>> -* the unregistering process.
>>> -*/
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xRU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "NL5xRU"),
>>> -   },
>>> -   },
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xRU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR,
>> "SchenkerTechnologiesGmbH"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "NL5xRU"),
>>> -   },
>>> -   },
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xRU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "NL5xRU"),
>>> -   },
>>> -   },
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xRU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "AURA1501"),
>>> -   },
>>> -   },
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xRU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "EDUBOOK1502"),
>>> -   },
>>> -   },
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xNU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "NL5xNU"),
>>> -   },
>>> -   },
>>> -   {
>>> -   .callback = video_detect_force_native,
>>> -   .ident = "Clevo NL5xNU",
>>> -   .matches = {
>>> -   DMI_MATCH(DMI_SYS_VENDOR,
>> "SchenkerTechnologiesGmbH"),
>>> -   DMI_MATCH(DMI_BOARD_NAME, "NL5xNU"),
>>> -   },
>>> -   },
>>> -   

[PATCH v2 2/2] Documentation/gpu: Add GFXOFF section

2022-07-14 Thread André Almeida
Add a GFXOFF section at "GPU Power Controls" file, explaining what it is
and how userspace can interact with it.

Signed-off-by: André Almeida 
---
Changes from v1: file created

 Documentation/gpu/amdgpu/thermal.rst | 41 
 1 file changed, 41 insertions(+)

diff --git a/Documentation/gpu/amdgpu/thermal.rst 
b/Documentation/gpu/amdgpu/thermal.rst
index 8aeb0186c9ef..14c0fb874cf6 100644
--- a/Documentation/gpu/amdgpu/thermal.rst
+++ b/Documentation/gpu/amdgpu/thermal.rst
@@ -63,3 +63,44 @@ gpu_metrics
 
 .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
:doc: gpu_metrics
+
+GFXOFF
+==
+
+GFXOFF is a feature found in some mobile GPUs that saves power consumption. The
+card's firmware uses RLC (RunList Controller) to power off the gfx engine
+dynamically when there is no workload on gfx pipe and puts gfx into "idle"
+state. GFXOFF is on by default on supported GPUs.
+
+Userspace can interact with GFXOFF through a debugfs interface:
+
+``amdgpu_gfxoff``
+-
+
+Use it to enable/disable GFXOFF, and to check if it's current 
enabled/disabled::
+
+  $ xxd -l1 -p /sys/kernel/debug/dri/0/amdgpu_gfxoff
+  01
+
+- Write 0 to disable it, and 1 to enable it.
+- Read 0 means it's disabled, 1 it's enabled.
+
+If it's enabled, that means that the GPU is free to enter into GFXOFF mode as
+needed. Disabled means that it will never enter GFXOFF mode.
+
+``amdgpu_gfxoff_status``
+
+
+Read it to check current GFXOFF's status of a GPU::
+
+  $ xxd -l1 -p /sys/kernel/debug/dri/0/amdgpu_gfxoff_status
+  02
+
+- 0: GPU is in GFXOFF state, the gfx engine is powered down.
+- 1: Transition out of GFXOFF state
+- 2: Not in GFXOFF state
+- 3: Transition into GFXOFF state
+
+If GFXOFF is enabled, the value will be transitioning around [0, 3], always
+getting into 0 when possible. When it's disabled, it's always at 2. Returns
+``-EINVAL`` if it's not supported.
-- 
2.37.0



[PATCH v2 1/2] drm/amd/debugfs: Expose GFXOFF state to userspace

2022-07-14 Thread André Almeida
GFXOFF has two different "state" values: one to define if the GPU is
allowed/disallowed to enter GFXOFF, usually called state; and another
one to define if currently GFXOFF is being used, usually called status.
Even when GFXOFF is allowed, GPU firmware can decide to not used it
accordingly to the GPU load.

Userspace can allow/disallow GPUs to enter into GFXOFF via debugfs. The
kernel maintains a counter of requests for GFXOFF (gfx_off_req_count)
that should be decreased to allow GFXOFF and increased to disallow.

The issue with this interface is that userspace can't be sure if GFXOFF
is currently allowed. Even by checking amdgpu_gfxoff file, one might get
an ambiguous 2, that means that GPU is currently out of GFXOFF, but that
can be either because it's currently disallowed or because it's allowed
but given the current GPU load it's enabled. Then, userspace needs to
rely on the fact that GFXOFF is enabled by default on boot and to track
this information.

To make userspace life easier and GFXOFF more reliable, return the
current state of GFXOFF to userspace when reading amdgpu_gfxoff with the
same semantics of writing: 0 means not allowed, not 0 means allowed.

Expose the current status of GFXOFF through a new file,
amdgpu_gfxoff_status.

Signed-off-by: André Almeida 
---
Changes from v1: none

 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 49 -
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index f3b3c688e4e7..e2eec985adb3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -1117,13 +1117,50 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file 
*f, char __user *buf,
}
 
while (size) {
-   uint32_t value;
+   u32 value = adev->gfx.gfx_off_state;
+
+   r = put_user(value, (u32 *)buf);
+   if (r)
+   goto out;
+
+   result += 4;
+   buf += 4;
+   *pos += 4;
+   size -= 4;
+   }
+
+   r = result;
+out:
+   pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+
+   return r;
+}
+
+static ssize_t amdgpu_debugfs_gfxoff_status_read(struct file *f, char __user 
*buf,
+size_t size, loff_t *pos)
+{
+   struct amdgpu_device *adev = file_inode(f)->i_private;
+   ssize_t result = 0;
+   int r;
+
+   if (size & 0x3 || *pos & 0x3)
+   return -EINVAL;
+
+   r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
+   if (r < 0) {
+   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+   return r;
+   }
+
+   while (size) {
+   u32 value;
 
r = amdgpu_get_gfx_off_status(adev, );
if (r)
goto out;
 
-   r = put_user(value, (uint32_t *)buf);
+   r = put_user(value, (u32 *)buf);
if (r)
goto out;
 
@@ -1206,6 +1243,12 @@ static const struct file_operations 
amdgpu_debugfs_gfxoff_fops = {
.llseek = default_llseek
 };
 
+static const struct file_operations amdgpu_debugfs_gfxoff_status_fops = {
+   .owner = THIS_MODULE,
+   .read = amdgpu_debugfs_gfxoff_status_read,
+   .llseek = default_llseek
+};
+
 static const struct file_operations *debugfs_regs[] = {
_debugfs_regs_fops,
_debugfs_regs2_fops,
@@ -1217,6 +1260,7 @@ static const struct file_operations *debugfs_regs[] = {
_debugfs_wave_fops,
_debugfs_gpr_fops,
_debugfs_gfxoff_fops,
+   _debugfs_gfxoff_status_fops,
 };
 
 static const char *debugfs_regs_names[] = {
@@ -1230,6 +1274,7 @@ static const char *debugfs_regs_names[] = {
"amdgpu_wave",
"amdgpu_gpr",
"amdgpu_gfxoff",
+   "amdgpu_gfxoff_status",
 };
 
 /**
-- 
2.37.0



Re: [PATCH] drm/amd/display: Add missing hard-float compile flags for PPC64 builds

2022-07-14 Thread Melissa Wen
O 07/13, Alex Deucher wrote:
> On Wed, Jul 13, 2022 at 7:09 PM Guenter Roeck  wrote:
> >
> > On Wed, Jul 13, 2022 at 05:20:40PM -0400, Alex Deucher wrote:
> > > >
> > > > The problem is not the FPU operations, but the fact that soft-float
> > > > and hard-float compiled code is linked together. The soft-float and
> > > > hard-float ABIs on powerpc are not compatible, so one ends up with
> > > > an object file which is partially soft-float and partially hard-float
> > > > compiled and thus uses different ABIs. That can only create chaos,
> > > > so the linker complains about it.
> > >
> > > I get that, I just don't see why only DCN 3.1.x files have this
> > > problem.  The DCN 2.x files should as well.
> > >
> >
> > Seen in drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile:
> >
> > # prevent build errors regarding soft-float vs hard-float FP ABI tags
> > # this code is currently unused on ppc64, as it applies to Renoir APUs only
> > ifdef CONFIG_PPC64
> > CFLAGS_$(AMDDALPATH)/dc/clk_mgr/dcn21/rn_clk_mgr.o := $(call 
> > cc-option,-mno-gnu-attribute)
> > endif
> >
> > Does that explain it ?
> 
> I would expect to see it in dcn20_resource.c and dcn30_clk_mgr.c for
> example.  They follow the same pattern as the dcn 3.1.x files.  They
> call functions that use FP, but maybe there is some FP code still in
> those functions that we missed somehow.

Hi,

I'm a little late here, but I'm not able to reproduce the issue yet.
I have this setup:
- gcc 11.3.0
- binutils 2.38.50
- mainline kernel (torvalds) version: 5.19.0-rc6 (cross-compiling)
  -> make ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- allmodconfig
=> DRM_AMD_DC [=y] && HAS_IOMEM [=y] && DRM [=m] && DRM_AMDGPU [=m] && (X86 
|| PPC64 [=y]) && (!KCOV_INSTRUMENT_ALL [=n] || !KCOV_ENABLE_COMPARISONS [=n])
  -> make -j16 ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu-

Am I missing something?

So, as Alex mentioned the possibility of some non-isolated FPU code in
3.1, I reviewed dcn31 code and my best bet so far is that the issue
is here:

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c#L1721

Although dcn31_update_soc_for_wm_a() is only called inside
dml/dcn31/dcn31_fpu:
- dc->res_pool->funcs->update_soc_for_wm_a(dc, context);

it's declared in dcn31_resource and has FPU code. So, we should move it
to dml/dcn31/dcn31_fpu.

However, as I can't reproduce the issue, I don't know if it addresses
the problem reported here and also if everything will be clean after
moving it. 

Guenter,

Can you provide more info about your setup: cross-compile or not, any
flags, branch, etc?

Best Regards,

Melissa

> 
> Alex


signature.asc
Description: PGP signature


Re: [PATCH v2 00/29] drm/kms: Stop registering multiple /sys/class/backlight devs for a single display

2022-07-14 Thread Rafael J. Wysocki
On Tue, Jul 12, 2022 at 9:39 PM Hans de Goede  wrote:
>
> Hi All,
>
> As mentioned in my RFC titled "drm/kms: control display brightness through
> drm_connector properties":
> https://lore.kernel.org/dri-devel/0d188965-d809-81b5-74ce-7d30c49fe...@redhat.com/
>
> The first step towards this is to deal with some existing technical debt
> in backlight handling on x86/ACPI boards, specifically we need to stop
> registering multiple /sys/class/backlight devs for a single display.
>
> This series implements my RFC describing my plan for these cleanups:
> https://lore.kernel.org/dri-devel/98519ba0-7f18-201a-ea34-652f50343...@redhat.com/
>
> This new version addresses the few small remarks made on version 1 (mainly
> changing patch 1/29) and more importantly this finishes the refactoring by
> else addressing all the bits from the "Other issues" section of
> the refactor RFC (resulting in patches 15-29 which are new in v2).
>
> Please review and test! I hope to be able to make an immutable branch
> based on 5.20-rc1 + this series available for merging into the various
> touched subsystems once 5.20-rc2 is out.

Please feel free to add

Acked-by: Rafael J. Wysocki 

to all of the ACPI video patches in this series.

Thanks!

> Hans de Goede (29):
>   ACPI: video: Add acpi_video_backlight_use_native() helper
>   drm/i915: Don't register backlight when another backlight should be
> used
>   drm/amdgpu: Don't register backlight when another backlight should be
> used
>   drm/radeon: Don't register backlight when another backlight should be
> used
>   drm/nouveau: Don't register backlight when another backlight should be
> used
>   ACPI: video: Drop backlight_device_get_by_type() call from
> acpi_video_get_backlight_type()
>   ACPI: video: Remove acpi_video_bus from list before tearing it down
>   ACPI: video: Simplify acpi_video_unregister_backlight()
>   ACPI: video: Make backlight class device registration a separate step
>   ACPI: video: Remove code to unregister acpi_video backlight when a
> native backlight registers
>   drm/i915: Call acpi_video_register_backlight() (v2)
>   drm/nouveau: Register ACPI video backlight when nv_backlight
> registration fails
>   drm/amdgpu: Register ACPI video backlight when skipping amdgpu
> backlight registration
>   drm/radeon: Register ACPI video backlight when skipping radeon
> backlight registration
>   ACPI: video: Refactor acpi_video_get_backlight_type() a bit
>   ACPI: video: Add Nvidia WMI EC brightness control detection
>   ACPI: video: Add Apple GMUX brightness control detection
>   platform/x86: apple-gmux: Stop calling acpi/video.h functions
>   platform/x86: toshiba_acpi: Stop using
> acpi_video_set_dmi_backlight_type()
>   platform/x86: acer-wmi: Move backlight DMI quirks to
> acpi/video_detect.c
>   platform/x86: asus-wmi: Drop DMI chassis-type check from backlight
> handling
>   platform/x86: asus-wmi: Move acpi_backlight=vendor quirks to ACPI
> video_detect.c
>   platform/x86: asus-wmi: Move acpi_backlight=native quirks to ACPI
> video_detect.c
>   platform/x86: samsung-laptop: Move acpi_backlight=[vendor|native]
> quirks to ACPI video_detect.c
>   ACPI: video: Remove acpi_video_set_dmi_backlight_type()
>   ACPI: video: Drop "Samsung X360" acpi_backlight=native quirk
>   ACPI: video: Drop Clevo/TUXEDO NL5xRU and NL5xNU acpi_backlight=native
> quirks
>   ACPI: video: Fix indentation of video_detect_dmi_table[] entries
>   drm/todo: Add entry about dealing with brightness control on devices
> with > 1 panel
>
>  Documentation/gpu/todo.rst|  68 +++
>  drivers/acpi/Kconfig  |   1 +
>  drivers/acpi/acpi_video.c |  59 ++-
>  drivers/acpi/video_detect.c   | 415 +++---
>  drivers/gpu/drm/Kconfig   |  12 +
>  .../gpu/drm/amd/amdgpu/atombios_encoders.c|  14 +-
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   9 +
>  drivers/gpu/drm/gma500/Kconfig|   2 +
>  drivers/gpu/drm/i915/Kconfig  |   2 +
>  .../gpu/drm/i915/display/intel_backlight.c|   7 +
>  drivers/gpu/drm/i915/display/intel_display.c  |   8 +
>  drivers/gpu/drm/i915/display/intel_panel.c|   3 +
>  drivers/gpu/drm/i915/i915_drv.h   |   2 +
>  drivers/gpu/drm/nouveau/nouveau_backlight.c   |  14 +
>  drivers/gpu/drm/radeon/atombios_encoders.c|   7 +
>  drivers/gpu/drm/radeon/radeon_encoders.c  |  11 +-
>  .../gpu/drm/radeon/radeon_legacy_encoders.c   |   7 +
>  drivers/platform/x86/acer-wmi.c   |  66 ---
>  drivers/platform/x86/apple-gmux.c |   3 -
>  drivers/platform/x86/asus-nb-wmi.c|  21 -
>  drivers/platform/x86/asus-wmi.c   |  13 -
>  drivers/platform/x86/asus-wmi.h   |   2 -
>  drivers/platform/x86/eeepc-wmi.c  |  25 +-
>  drivers/platform/x86/samsung-laptop.c |  87 
>  

Re: [PATCH 01/10] drm/sched: move calling drm_sched_entity_select_rq

2022-07-14 Thread Andrey Grodzovsky

Found the new use case from the 5/10 of reordering CS ioctl.

Reviewed-by: Andrey Grodzovsky 

Andrey

On 2022-07-14 12:26, Christian König wrote:

We need this for limiting codecs like AV1 to the first instance for VCN3.

Essentially the idea is that we first initialize the job with entity, 
id etc... and before we submit it we select a new rq for the entity. 
In the meantime the VCN3 inline parse will have modified the available 
rqs for the entity.


See the patch "revert "fix limiting AV1 to the first instance on 
VCN3"" as well.


Christian.

Am 14.07.22 um 17:43 schrieb Andrey Grodzovsky:
Can you please remind me of the use case that requires this ? I 
browsed through
related mails in the past but haven't found when is that needed. For 
amdgpu

drm_sched_job_init and drm_sched_job_arm are called together and amdgpu
is the only one who supports modifying entity priority on the fly as 
far as i see.


Andrey

On 2022-07-14 06:38, Christian König wrote:
We already discussed that the call to drm_sched_entity_select_rq() 
needs

to move to drm_sched_job_arm() to be able to set a new scheduler list
between _init() and _arm(). This was just not applied for some reason.

Signed-off-by: Christian König 
CC: Andrey Grodzovsky 
CC: dri-devel@lists.freedesktop.org
---
  drivers/gpu/drm/scheduler/sched_main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c

index 68317d3a7a27..e0ab14e0fb6b 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -592,7 +592,6 @@ int drm_sched_job_init(struct drm_sched_job *job,
 struct drm_sched_entity *entity,
 void *owner)
  {
-    drm_sched_entity_select_rq(entity);
  if (!entity->rq)
  return -ENOENT;
  @@ -628,7 +627,7 @@ void drm_sched_job_arm(struct drm_sched_job *job)
  struct drm_sched_entity *entity = job->entity;
    BUG_ON(!entity);
-
+    drm_sched_entity_select_rq(entity);
  sched = entity->rq->sched;
    job->sched = sched;




Re: [PATCH v1] drm/scheduler: Don't kill jobs in interrupt context

2022-07-14 Thread Andrey Grodzovsky

On 2022-07-14 12:22, Alex Deucher wrote:


On Thu, Jul 14, 2022 at 10:14 AM Andrey Grodzovsky
 wrote:


On 2022-07-14 05:57, Dmitry Osipenko wrote:

On 7/12/22 11:56, Dmitry Osipenko wrote:

On 7/6/22 18:46, Alex Deucher wrote:

On Wed, Jul 6, 2022 at 9:49 AM Andrey Grodzovsky
 wrote:

On 2022-07-06 03:07, Dmitry Osipenko wrote:


Hello Andrey,

On 5/17/22 17:48, Dmitry Osipenko wrote:

On 5/17/22 17:13, Andrey Grodzovsky wrote:

Done.

Andrey

Awesome, thank you!


Given that this drm-scheduler issue needs to be fixed in the 5.19-RC and
earlier, shouldn't it be in the drm-fixes and not in drm-next?

I pushed it into drm-misc from where it got into drm-next. I don't have
permission for drm-fixes.

The -fixes branch of drm-misc.

Now I don't see the scheduler bugfix neither in the -fixes branch nor in
the -next and today Dave sent out 5.19-rc7 pull request without the
scheduler fix. Could anyone please check what is going on with the DRM
patches? Thanks!

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffreedesktop%2Fdrm-misc%2Fcommits%2Fdrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7Cd62c2e6d3ec748cd639608da65b52548%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637934125954377887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=WPmMC%2B%2Fy83cUctuF%2FLNo9VhWnB%2FkpUVQotMh74VshB8%3Dreserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fdrm%2Fdrm-misc%2Flog%2F%3Fh%3Ddrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7Cd62c2e6d3ec748cd639608da65b52548%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637934125954377887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=RzCMLUYLmUjSmvDm4E%2FJr%2B5rp7E8UvjFt1tmwBoBiVc%3Dreserved=0

The patch is in the drm-misc-next-fixes, so it wasn't moved to the
drm-misc-fixes.

Andrey, don't you have access to drm-misc-fixes? Or you meant
drm-fixes=drm-misc-fixes?


I have only accesses to drm-misc-next to which I pushed this patch.

anyone with drm-misc rights can commit to any of the branches in the
drm-misc tree.  You just need to check out and push the appropriate
branch.  then push the changes.  E.g.,
dim push-branch drm-misc-next
vs
dim push-branch drm-misc-next-fixes
etc.

Alex



I see, but what  is the reason then that Dave sent out 5.19-rc7 pull 
request without the
scheduler fix if the patch was merged into drm-misc-next long ago ? All 
the changes from

there are usually picked up for pull requests, no ?

Andrey






Andrey




[Bug 216120] [BISECTED][REGRESSION] drm/amdgpu: add drm buddy support to amdgpu

2022-07-14 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216120

--- Comment #6 from mat2003...@gmail.com ---
not quite there yet, after some hours of working with latest
linus+0001-drm-amdgpu-Fix-for-drm-buddy-memory-corruption.patch (latest commit
"vf/remap: return the amount of bytes actually deduplicated") display stopped
working, keyboard was working so I could reboot blindly. Part of journal
attached in comment 5. Maybe different bug.

I could perhaps bisect adding the patch to relevant steps but now I have had
too many gin and seem to be talking to myself anyway.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

[PATCH v2 0/2] Miscellaneous runtime PM fixes for Nouveau

2022-07-14 Thread Lyude Paul
Noticed these minor issues while trying to investigate

https://bugzilla.redhat.com/show_bug.cgi?id=2086470

While unfortunately I've been unable to confirm whether these patches
fix the specific problem in question, they're likely fixes we want to
pull in regardless.

Lyude Paul (2):
  drm/nouveau/acpi: Don't print error when we get -EINPROGRESS from
pm_runtime
  drm/nouveau: Don't pm_runtime_put_sync(), only
pm_runtime_put_autosuspend()

 drivers/gpu/drm/nouveau/nouveau_display.c | 4 ++--
 drivers/gpu/drm/nouveau/nouveau_fbcon.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.35.3



[PATCH v2 2/2] drm/nouveau: Don't pm_runtime_put_sync(), only pm_runtime_put_autosuspend()

2022-07-14 Thread Lyude Paul
While trying to fix another issue, it occurred to me that I don't actually
think there is any situation where we want pm_runtime_put() in nouveau to
be synchronous. In fact, this kind of just seems like it would cause
issues where we may unexpectedly block a thread we don't expect to be
blocked.

So, let's only use pm_runtime_put_autosuspend().

Changes since v1:
* Use pm_runtime_put_autosuspend(), not pm_runtime_put()

Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 9f5a45f24e5be..a2f5df568ca54 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -515,7 +515,7 @@ nouveau_display_hpd_work(struct work_struct *work)
 
pm_runtime_mark_last_busy(drm->dev->dev);
 noop:
-   pm_runtime_put_sync(drm->dev->dev);
+   pm_runtime_put_autosuspend(dev->dev);
 }
 
 #ifdef CONFIG_ACPI
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 5226323e55d34..3c7e0c9d6baf1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -467,7 +467,7 @@ nouveau_fbcon_set_suspend_work(struct work_struct *work)
if (state == FBINFO_STATE_RUNNING) {
nouveau_fbcon_hotplug_resume(drm->fbcon);
pm_runtime_mark_last_busy(drm->dev->dev);
-   pm_runtime_put_sync(drm->dev->dev);
+   pm_runtime_put_autosuspend(drm->dev->dev);
}
 }
 
-- 
2.35.3



[PATCH v2 1/2] drm/nouveau/acpi: Don't print error when we get -EINPROGRESS from pm_runtime

2022-07-14 Thread Lyude Paul
Since this isn't actually a failure.

Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 2cd0932b3d687..9f5a45f24e5be 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -537,7 +537,7 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, 
unsigned long val,
 * it's own hotplug events.
 */
pm_runtime_put_autosuspend(drm->dev->dev);
-   } else if (ret == 0) {
+   } else if (ret == 0 || ret == -EINPROGRESS) {
/* We've started resuming the GPU already, so
 * it will handle scheduling a full reprobe
 * itself
-- 
2.35.3



[Bug 216120] [BISECTED][REGRESSION] drm/amdgpu: add drm buddy support to amdgpu

2022-07-14 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216120

--- Comment #5 from mat2003...@gmail.com ---
Created attachment 301427
  --> https://bugzilla.kernel.org/attachment.cgi?id=301427=edit
journal 2022-07-14

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

Re: [PATCH] drm/amd/display: Enable building new display engine with KCOV enabled

2022-07-14 Thread Guenter Roeck

On 7/14/22 09:29, Alex Deucher wrote:

Applied.  Thanks!

On Wed, Jul 13, 2022 at 4:03 PM Harry Wentland  wrote:


On 2022-07-12 18:42, Guenter Roeck wrote:

The new display engine uses floating point math, which is not supported
by KCOV. Commit 9d1d02ff3678 ("drm/amd/display: Don't build DCN1 when kcov
is enabled") tried to work around the problem by disabling
CONFIG_DRM_AMD_DC_DCN if KCOV_INSTRUMENT_ALL and KCOV_ENABLE_COMPARISONS
are enabled. The result is that KCOV can not be enabled on systems which
require this display engine. A much simpler and less invasive solution is
to disable KCOV selectively when compiling the display enagine while


"enagine". Outch.

Anyway, thanks for applying.

Guenter


keeping it enabled for the rest of the kernel.

Fixes: 9d1d02ff3678 ("drm/amd/display: Don't build DCN1 when kcov is enabled")
Cc: Arnd Bergmann 
Cc: Leo Li 
Signed-off-by: Guenter Roeck 


Reviewed-by: Harry Wentland 

Harry


---
  drivers/gpu/drm/amd/display/Kconfig | 2 +-
  drivers/gpu/drm/amd/display/dc/Makefile | 3 +++
  2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/Kconfig 
b/drivers/gpu/drm/amd/display/Kconfig
index b4029c0d5d8c..96cbc87f7b6b 100644
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@ -6,7 +6,7 @@ config DRM_AMD_DC
   bool "AMD DC - Enable new display engine"
   default y
   select SND_HDA_COMPONENT if SND_HDA_CORE
- select DRM_AMD_DC_DCN if (X86 || PPC64) && !(KCOV_INSTRUMENT_ALL && 
KCOV_ENABLE_COMPARISONS)
+ select DRM_AMD_DC_DCN if (X86 || PPC64)
   help
 Choose this option if you want to use the new display engine
 support for AMDGPU. This adds required support for Vega and
diff --git a/drivers/gpu/drm/amd/display/dc/Makefile 
b/drivers/gpu/drm/amd/display/dc/Makefile
index b4eca0236435..b801973749d2 100644
--- a/drivers/gpu/drm/amd/display/dc/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/Makefile
@@ -26,6 +26,9 @@
  DC_LIBS = basics bios dml clk_mgr dce gpio irq link virtual

  ifdef CONFIG_DRM_AMD_DC_DCN
+
+KCOV_INSTRUMENT := n
+
  DC_LIBS += dcn20
  DC_LIBS += dsc
  DC_LIBS += dcn10






Re: [PATCH] drm/amd/debugfs: Expose GFXOFF state to userspace

2022-07-14 Thread Alex Deucher
On Thu, Jul 14, 2022 at 12:45 PM André Almeida  wrote:
>
>
>
> Às 13:42 de 14/07/22, Alex Deucher escreveu:
> > On Wed, Jul 13, 2022 at 11:15 AM André Almeida  
> > wrote:
> >>
> >> GFXOFF has two different "state" values: one to define if the GPU is
> >> allowed/disallowed to enter GFXOFF, usually called state; and another
> >> one to define if currently GFXOFF is being used, usually called status.
> >> Even when GFXOFF is allowed, GPU firmware can decide to not used it
> >> accordingly to the GPU load.
> >>
> >> Userspace can allow/disallow GPUs to enter into GFXOFF via debugfs. The
> >> kernel maintains a counter of requests for GFXOFF (gfx_off_req_count)
> >> that should be decreased to allow GFXOFF and increased to disallow.
> >>
> >> The issue with this interface is that userspace can't be sure if GFXOFF
> >> is currently allowed. Even by checking amdgpu_gfxoff file, one might get
> >> an ambiguous 2, that means that GPU is currently out of GFXOFF, but that
> >> can be either because it's currently disallowed or because it's allowed
> >> but given the current GPU load it's enabled. Then, userspace needs to
> >> rely on the fact that GFXOFF is enabled by default on boot and to track
> >> this information.
> >>
> >> To make userspace life easier and GFXOFF more reliable, return the
> >> current state of GFXOFF to userspace when reading amdgpu_gfxoff with the
> >> same semantics of writing: 0 means not allowed, not 0 means allowed.
> >>
> >
> > This looks good. Can you document this in the amdgpu kerneldoc?
> >
>
> Sure, let me send a v2 with that

While you are at it, if we are missing docs for the other gfxoff file
can you add that as well?

Thanks!

Alex

>
> > Alex
> >
> >> Expose the current status of GFXOFF through a new file,
> >> amdgpu_gfxoff_status.
> >>
> >> Signed-off-by: André Almeida 
> >> ---
> >>  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 49 -
> >>  1 file changed, 47 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
> >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> >> index f3b3c688e4e7..e2eec985adb3 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> >> @@ -1117,13 +1117,50 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct 
> >> file *f, char __user *buf,
> >> }
> >>
> >> while (size) {
> >> -   uint32_t value;
> >> +   u32 value = adev->gfx.gfx_off_state;
> >> +
> >> +   r = put_user(value, (u32 *)buf);
> >> +   if (r)
> >> +   goto out;
> >> +
> >> +   result += 4;
> >> +   buf += 4;
> >> +   *pos += 4;
> >> +   size -= 4;
> >> +   }
> >> +
> >> +   r = result;
> >> +out:
> >> +   pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
> >> +   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
> >> +
> >> +   return r;
> >> +}
> >> +
> >> +static ssize_t amdgpu_debugfs_gfxoff_status_read(struct file *f, char 
> >> __user *buf,
> >> +size_t size, loff_t *pos)
> >> +{
> >> +   struct amdgpu_device *adev = file_inode(f)->i_private;
> >> +   ssize_t result = 0;
> >> +   int r;
> >> +
> >> +   if (size & 0x3 || *pos & 0x3)
> >> +   return -EINVAL;
> >> +
> >> +   r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
> >> +   if (r < 0) {
> >> +   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
> >> +   return r;
> >> +   }
> >> +
> >> +   while (size) {
> >> +   u32 value;
> >>
> >> r = amdgpu_get_gfx_off_status(adev, );
> >> if (r)
> >> goto out;
> >>
> >> -   r = put_user(value, (uint32_t *)buf);
> >> +   r = put_user(value, (u32 *)buf);
> >> if (r)
> >> goto out;
> >>
> >> @@ -1206,6 +1243,12 @@ static const struct file_operations 
> >> amdgpu_debugfs_gfxoff_fops = {
> >> .llseek = default_llseek
> >>  };
> >>
> >> +static const struct file_operations amdgpu_debugfs_gfxoff_status_fops = {
> >> +   .owner = THIS_MODULE,
> >> +   .read = amdgpu_debugfs_gfxoff_status_read,
> >> +   .llseek = default_llseek
> >> +};
> >> +
> >>  static const struct file_operations *debugfs_regs[] = {
> >> _debugfs_regs_fops,
> >> _debugfs_regs2_fops,
> >> @@ -1217,6 +1260,7 @@ static const struct file_operations *debugfs_regs[] 
> >> = {
> >> _debugfs_wave_fops,
> >> _debugfs_gpr_fops,
> >> _debugfs_gfxoff_fops,
> >> +   _debugfs_gfxoff_status_fops,
> >>  };
> >>
> >>  static const char *debugfs_regs_names[] = {
> >> @@ -1230,6 +1274,7 @@ static const char *debugfs_regs_names[] = {
> >> "amdgpu_wave",
> >> "amdgpu_gpr",
> >> "amdgpu_gfxoff",
> >> +   "amdgpu_gfxoff_status",
> >>  };
> 

Re: [PATCH] drm/amd/debugfs: Expose GFXOFF state to userspace

2022-07-14 Thread André Almeida



Às 13:42 de 14/07/22, Alex Deucher escreveu:
> On Wed, Jul 13, 2022 at 11:15 AM André Almeida  wrote:
>>
>> GFXOFF has two different "state" values: one to define if the GPU is
>> allowed/disallowed to enter GFXOFF, usually called state; and another
>> one to define if currently GFXOFF is being used, usually called status.
>> Even when GFXOFF is allowed, GPU firmware can decide to not used it
>> accordingly to the GPU load.
>>
>> Userspace can allow/disallow GPUs to enter into GFXOFF via debugfs. The
>> kernel maintains a counter of requests for GFXOFF (gfx_off_req_count)
>> that should be decreased to allow GFXOFF and increased to disallow.
>>
>> The issue with this interface is that userspace can't be sure if GFXOFF
>> is currently allowed. Even by checking amdgpu_gfxoff file, one might get
>> an ambiguous 2, that means that GPU is currently out of GFXOFF, but that
>> can be either because it's currently disallowed or because it's allowed
>> but given the current GPU load it's enabled. Then, userspace needs to
>> rely on the fact that GFXOFF is enabled by default on boot and to track
>> this information.
>>
>> To make userspace life easier and GFXOFF more reliable, return the
>> current state of GFXOFF to userspace when reading amdgpu_gfxoff with the
>> same semantics of writing: 0 means not allowed, not 0 means allowed.
>>
> 
> This looks good. Can you document this in the amdgpu kerneldoc?
> 

Sure, let me send a v2 with that

> Alex
> 
>> Expose the current status of GFXOFF through a new file,
>> amdgpu_gfxoff_status.
>>
>> Signed-off-by: André Almeida 
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 49 -
>>  1 file changed, 47 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>> index f3b3c688e4e7..e2eec985adb3 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>> @@ -1117,13 +1117,50 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct 
>> file *f, char __user *buf,
>> }
>>
>> while (size) {
>> -   uint32_t value;
>> +   u32 value = adev->gfx.gfx_off_state;
>> +
>> +   r = put_user(value, (u32 *)buf);
>> +   if (r)
>> +   goto out;
>> +
>> +   result += 4;
>> +   buf += 4;
>> +   *pos += 4;
>> +   size -= 4;
>> +   }
>> +
>> +   r = result;
>> +out:
>> +   pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
>> +   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
>> +
>> +   return r;
>> +}
>> +
>> +static ssize_t amdgpu_debugfs_gfxoff_status_read(struct file *f, char 
>> __user *buf,
>> +size_t size, loff_t *pos)
>> +{
>> +   struct amdgpu_device *adev = file_inode(f)->i_private;
>> +   ssize_t result = 0;
>> +   int r;
>> +
>> +   if (size & 0x3 || *pos & 0x3)
>> +   return -EINVAL;
>> +
>> +   r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
>> +   if (r < 0) {
>> +   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
>> +   return r;
>> +   }
>> +
>> +   while (size) {
>> +   u32 value;
>>
>> r = amdgpu_get_gfx_off_status(adev, );
>> if (r)
>> goto out;
>>
>> -   r = put_user(value, (uint32_t *)buf);
>> +   r = put_user(value, (u32 *)buf);
>> if (r)
>> goto out;
>>
>> @@ -1206,6 +1243,12 @@ static const struct file_operations 
>> amdgpu_debugfs_gfxoff_fops = {
>> .llseek = default_llseek
>>  };
>>
>> +static const struct file_operations amdgpu_debugfs_gfxoff_status_fops = {
>> +   .owner = THIS_MODULE,
>> +   .read = amdgpu_debugfs_gfxoff_status_read,
>> +   .llseek = default_llseek
>> +};
>> +
>>  static const struct file_operations *debugfs_regs[] = {
>> _debugfs_regs_fops,
>> _debugfs_regs2_fops,
>> @@ -1217,6 +1260,7 @@ static const struct file_operations *debugfs_regs[] = {
>> _debugfs_wave_fops,
>> _debugfs_gpr_fops,
>> _debugfs_gfxoff_fops,
>> +   _debugfs_gfxoff_status_fops,
>>  };
>>
>>  static const char *debugfs_regs_names[] = {
>> @@ -1230,6 +1274,7 @@ static const char *debugfs_regs_names[] = {
>> "amdgpu_wave",
>> "amdgpu_gpr",
>> "amdgpu_gfxoff",
>> +   "amdgpu_gfxoff_status",
>>  };
>>
>>  /**
>> --
>> 2.37.0
>>


Re: [PATCH] drm/amd/debugfs: Expose GFXOFF state to userspace

2022-07-14 Thread Alex Deucher
On Wed, Jul 13, 2022 at 11:15 AM André Almeida  wrote:
>
> GFXOFF has two different "state" values: one to define if the GPU is
> allowed/disallowed to enter GFXOFF, usually called state; and another
> one to define if currently GFXOFF is being used, usually called status.
> Even when GFXOFF is allowed, GPU firmware can decide to not used it
> accordingly to the GPU load.
>
> Userspace can allow/disallow GPUs to enter into GFXOFF via debugfs. The
> kernel maintains a counter of requests for GFXOFF (gfx_off_req_count)
> that should be decreased to allow GFXOFF and increased to disallow.
>
> The issue with this interface is that userspace can't be sure if GFXOFF
> is currently allowed. Even by checking amdgpu_gfxoff file, one might get
> an ambiguous 2, that means that GPU is currently out of GFXOFF, but that
> can be either because it's currently disallowed or because it's allowed
> but given the current GPU load it's enabled. Then, userspace needs to
> rely on the fact that GFXOFF is enabled by default on boot and to track
> this information.
>
> To make userspace life easier and GFXOFF more reliable, return the
> current state of GFXOFF to userspace when reading amdgpu_gfxoff with the
> same semantics of writing: 0 means not allowed, not 0 means allowed.
>

This looks good. Can you document this in the amdgpu kerneldoc?

Alex

> Expose the current status of GFXOFF through a new file,
> amdgpu_gfxoff_status.
>
> Signed-off-by: André Almeida 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 49 -
>  1 file changed, 47 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index f3b3c688e4e7..e2eec985adb3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -1117,13 +1117,50 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file 
> *f, char __user *buf,
> }
>
> while (size) {
> -   uint32_t value;
> +   u32 value = adev->gfx.gfx_off_state;
> +
> +   r = put_user(value, (u32 *)buf);
> +   if (r)
> +   goto out;
> +
> +   result += 4;
> +   buf += 4;
> +   *pos += 4;
> +   size -= 4;
> +   }
> +
> +   r = result;
> +out:
> +   pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
> +   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
> +
> +   return r;
> +}
> +
> +static ssize_t amdgpu_debugfs_gfxoff_status_read(struct file *f, char __user 
> *buf,
> +size_t size, loff_t *pos)
> +{
> +   struct amdgpu_device *adev = file_inode(f)->i_private;
> +   ssize_t result = 0;
> +   int r;
> +
> +   if (size & 0x3 || *pos & 0x3)
> +   return -EINVAL;
> +
> +   r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
> +   if (r < 0) {
> +   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
> +   return r;
> +   }
> +
> +   while (size) {
> +   u32 value;
>
> r = amdgpu_get_gfx_off_status(adev, );
> if (r)
> goto out;
>
> -   r = put_user(value, (uint32_t *)buf);
> +   r = put_user(value, (u32 *)buf);
> if (r)
> goto out;
>
> @@ -1206,6 +1243,12 @@ static const struct file_operations 
> amdgpu_debugfs_gfxoff_fops = {
> .llseek = default_llseek
>  };
>
> +static const struct file_operations amdgpu_debugfs_gfxoff_status_fops = {
> +   .owner = THIS_MODULE,
> +   .read = amdgpu_debugfs_gfxoff_status_read,
> +   .llseek = default_llseek
> +};
> +
>  static const struct file_operations *debugfs_regs[] = {
> _debugfs_regs_fops,
> _debugfs_regs2_fops,
> @@ -1217,6 +1260,7 @@ static const struct file_operations *debugfs_regs[] = {
> _debugfs_wave_fops,
> _debugfs_gpr_fops,
> _debugfs_gfxoff_fops,
> +   _debugfs_gfxoff_status_fops,
>  };
>
>  static const char *debugfs_regs_names[] = {
> @@ -1230,6 +1274,7 @@ static const char *debugfs_regs_names[] = {
> "amdgpu_wave",
> "amdgpu_gpr",
> "amdgpu_gfxoff",
> +   "amdgpu_gfxoff_status",
>  };
>
>  /**
> --
> 2.37.0
>


Re: [PATCH] drm/amdgpu: Clarify asics naming in Kconfig options

2022-07-14 Thread Alex Deucher
Applied.  Thanks!

On Thu, Jul 14, 2022 at 9:50 AM André Almeida  wrote:
>
> Clarify which architecture those asics acronyms refers to.
>
> Signed-off-by: André Almeida 
> ---
>  drivers/gpu/drm/amd/amdgpu/Kconfig | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig 
> b/drivers/gpu/drm/amd/amdgpu/Kconfig
> index 74a8105fd2c0..d55275de 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Kconfig
> +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
> @@ -4,7 +4,7 @@ config DRM_AMDGPU_SI
> depends on DRM_AMDGPU
> help
>   Choose this option if you want to enable experimental support
> - for SI asics.
> + for SI (Southern Islands) asics.
>
>   SI is already supported in radeon. Experimental support for SI
>   in amdgpu will be disabled by default and is still provided by
> @@ -16,7 +16,8 @@ config DRM_AMDGPU_CIK
> bool "Enable amdgpu support for CIK parts"
> depends on DRM_AMDGPU
> help
> - Choose this option if you want to enable support for CIK asics.
> + Choose this option if you want to enable support for CIK (Sea
> + Islands) asics.
>
>   CIK is already supported in radeon. Support for CIK in amdgpu
>   will be disabled by default and is still provided by radeon.
> --
> 2.37.0
>


Re: [PATCH][next] drm/amd/display: Fix spelling mistake "supporing" -> "supporting"

2022-07-14 Thread Alex Deucher
Applied.  Thanks!

Alex

On Thu, Jul 14, 2022 at 6:34 AM Colin Ian King  wrote:
>
> There is a spelling mistake in a dml_print message. Fix it.
>
> Signed-off-by: Colin Ian King 
> ---
>  .../gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c| 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c 
> b/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c
> index 6101c962ab0a..fc4d7474c111 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c
> @@ -2994,7 +2994,7 @@ static void 
> DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerforman
> for (k = 0; k < v->NumberOfActivePlanes; ++k) {
> if (v->ImmediateFlipSupportedForPipe[k] == 
> false) {
>  #ifdef __DML_VBA_DEBUG__
> -   dml_print("DML::%s: Pipe %0d not 
> supporing iflip\n", __func__, k);
> +   dml_print("DML::%s: Pipe %0d not 
> supporting iflip\n", __func__, k);
>  #endif
> v->ImmediateFlipSupported = false;
> }
> --
> 2.35.3
>


Re: [PATCH] drm/amd/display: Enable building new display engine with KCOV enabled

2022-07-14 Thread Alex Deucher
Applied.  Thanks!

On Wed, Jul 13, 2022 at 4:03 PM Harry Wentland  wrote:
>
> On 2022-07-12 18:42, Guenter Roeck wrote:
> > The new display engine uses floating point math, which is not supported
> > by KCOV. Commit 9d1d02ff3678 ("drm/amd/display: Don't build DCN1 when kcov
> > is enabled") tried to work around the problem by disabling
> > CONFIG_DRM_AMD_DC_DCN if KCOV_INSTRUMENT_ALL and KCOV_ENABLE_COMPARISONS
> > are enabled. The result is that KCOV can not be enabled on systems which
> > require this display engine. A much simpler and less invasive solution is
> > to disable KCOV selectively when compiling the display enagine while
> > keeping it enabled for the rest of the kernel.
> >
> > Fixes: 9d1d02ff3678 ("drm/amd/display: Don't build DCN1 when kcov is 
> > enabled")
> > Cc: Arnd Bergmann 
> > Cc: Leo Li 
> > Signed-off-by: Guenter Roeck 
>
> Reviewed-by: Harry Wentland 
>
> Harry
>
> > ---
> >  drivers/gpu/drm/amd/display/Kconfig | 2 +-
> >  drivers/gpu/drm/amd/display/dc/Makefile | 3 +++
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/Kconfig 
> > b/drivers/gpu/drm/amd/display/Kconfig
> > index b4029c0d5d8c..96cbc87f7b6b 100644
> > --- a/drivers/gpu/drm/amd/display/Kconfig
> > +++ b/drivers/gpu/drm/amd/display/Kconfig
> > @@ -6,7 +6,7 @@ config DRM_AMD_DC
> >   bool "AMD DC - Enable new display engine"
> >   default y
> >   select SND_HDA_COMPONENT if SND_HDA_CORE
> > - select DRM_AMD_DC_DCN if (X86 || PPC64) && !(KCOV_INSTRUMENT_ALL && 
> > KCOV_ENABLE_COMPARISONS)
> > + select DRM_AMD_DC_DCN if (X86 || PPC64)
> >   help
> > Choose this option if you want to use the new display engine
> > support for AMDGPU. This adds required support for Vega and
> > diff --git a/drivers/gpu/drm/amd/display/dc/Makefile 
> > b/drivers/gpu/drm/amd/display/dc/Makefile
> > index b4eca0236435..b801973749d2 100644
> > --- a/drivers/gpu/drm/amd/display/dc/Makefile
> > +++ b/drivers/gpu/drm/amd/display/dc/Makefile
> > @@ -26,6 +26,9 @@
> >  DC_LIBS = basics bios dml clk_mgr dce gpio irq link virtual
> >
> >  ifdef CONFIG_DRM_AMD_DC_DCN
> > +
> > +KCOV_INSTRUMENT := n
> > +
> >  DC_LIBS += dcn20
> >  DC_LIBS += dsc
> >  DC_LIBS += dcn10
>


Re: [PATCH 01/10] drm/sched: move calling drm_sched_entity_select_rq

2022-07-14 Thread Christian König

We need this for limiting codecs like AV1 to the first instance for VCN3.

Essentially the idea is that we first initialize the job with entity, id 
etc... and before we submit it we select a new rq for the entity. In the 
meantime the VCN3 inline parse will have modified the available rqs for 
the entity.


See the patch "revert "fix limiting AV1 to the first instance on VCN3"" 
as well.


Christian.

Am 14.07.22 um 17:43 schrieb Andrey Grodzovsky:
Can you please remind me of the use case that requires this ? I 
browsed through
related mails in the past but haven't found when is that needed. For 
amdgpu

drm_sched_job_init and drm_sched_job_arm are called together and amdgpu
is the only one who supports modifying entity priority on the fly as 
far as i see.


Andrey

On 2022-07-14 06:38, Christian König wrote:

We already discussed that the call to drm_sched_entity_select_rq() needs
to move to drm_sched_job_arm() to be able to set a new scheduler list
between _init() and _arm(). This was just not applied for some reason.

Signed-off-by: Christian König 
CC: Andrey Grodzovsky 
CC: dri-devel@lists.freedesktop.org
---
  drivers/gpu/drm/scheduler/sched_main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c

index 68317d3a7a27..e0ab14e0fb6b 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -592,7 +592,6 @@ int drm_sched_job_init(struct drm_sched_job *job,
 struct drm_sched_entity *entity,
 void *owner)
  {
-    drm_sched_entity_select_rq(entity);
  if (!entity->rq)
  return -ENOENT;
  @@ -628,7 +627,7 @@ void drm_sched_job_arm(struct drm_sched_job *job)
  struct drm_sched_entity *entity = job->entity;
    BUG_ON(!entity);
-
+    drm_sched_entity_select_rq(entity);
  sched = entity->rq->sched;
    job->sched = sched;




Re: [PATCH v1] drm/scheduler: Don't kill jobs in interrupt context

2022-07-14 Thread Alex Deucher
On Thu, Jul 14, 2022 at 10:14 AM Andrey Grodzovsky
 wrote:
>
>
> On 2022-07-14 05:57, Dmitry Osipenko wrote:
> > On 7/12/22 11:56, Dmitry Osipenko wrote:
> >> On 7/6/22 18:46, Alex Deucher wrote:
> >>> On Wed, Jul 6, 2022 at 9:49 AM Andrey Grodzovsky
> >>>  wrote:
>  On 2022-07-06 03:07, Dmitry Osipenko wrote:
> 
> > Hello Andrey,
> >
> > On 5/17/22 17:48, Dmitry Osipenko wrote:
> >> On 5/17/22 17:13, Andrey Grodzovsky wrote:
> >>> Done.
> >>>
> >>> Andrey
> >> Awesome, thank you!
> >>
> > Given that this drm-scheduler issue needs to be fixed in the 5.19-RC and
> > earlier, shouldn't it be in the drm-fixes and not in drm-next?
> 
>  I pushed it into drm-misc from where it got into drm-next. I don't have
>  permission for drm-fixes.
> >>> The -fixes branch of drm-misc.
> >> Now I don't see the scheduler bugfix neither in the -fixes branch nor in
> >> the -next and today Dave sent out 5.19-rc7 pull request without the
> >> scheduler fix. Could anyone please check what is going on with the DRM
> >> patches? Thanks!
> >>
> >> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffreedesktop%2Fdrm-misc%2Fcommits%2Fdrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7C68b627b8482a4fd28a5608da657f4375%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637933894551324163%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=CDdLG%2F7SqCudEnjhBSsXqq15mfhlHlS3xAdAfB%2Bh%2F1s%3Dreserved=0
> >> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fdrm%2Fdrm-misc%2Flog%2F%3Fh%3Ddrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7C68b627b8482a4fd28a5608da657f4375%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637933894551324163%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=4Vz40j6F%2FzHYckXEyPEunj9DRSoTXikhNxZDXeocTss%3Dreserved=0
> > The patch is in the drm-misc-next-fixes, so it wasn't moved to the
> > drm-misc-fixes.
> >
> > Andrey, don't you have access to drm-misc-fixes? Or you meant
> > drm-fixes=drm-misc-fixes?
>
>
> I have only accesses to drm-misc-next to which I pushed this patch.

anyone with drm-misc rights can commit to any of the branches in the
drm-misc tree.  You just need to check out and push the appropriate
branch.  then push the changes.  E.g.,
dim push-branch drm-misc-next
vs
dim push-branch drm-misc-next-fixes
etc.

Alex


>
> Andrey
>
>
> >


[PATCH] mm: move page zone helpers from mm.h to mmzone.h

2022-07-14 Thread Alex Sierra
[WHY]
It makes more sense to have these helpers in zone specific header
file, rather than the generic mm.h

Signed-off-by: Alex Sierra 
---
 include/linux/memremap.h |  2 +-
 include/linux/mm.h   | 78 ---
 include/linux/mmzone.h   | 80 
 3 files changed, 81 insertions(+), 79 deletions(-)

diff --git a/include/linux/memremap.h b/include/linux/memremap.h
index 8af304f6b504..77229165c914 100644
--- a/include/linux/memremap.h
+++ b/include/linux/memremap.h
@@ -2,7 +2,7 @@
 #ifndef _LINUX_MEMREMAP_H_
 #define _LINUX_MEMREMAP_H_
 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3b31b33bd5be..2df8c2b98d36 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1049,84 +1049,6 @@ vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf);
  *   back into memory.
  */
 
-/*
- * The zone field is never updated after free_area_init_core()
- * sets it, so none of the operations on it need to be atomic.
- */
-
-/* Page flags: | [SECTION] | [NODE] | ZONE | [LAST_CPUPID] | ... | FLAGS | */
-#define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS_WIDTH)
-#define NODES_PGOFF(SECTIONS_PGOFF - NODES_WIDTH)
-#define ZONES_PGOFF(NODES_PGOFF - ZONES_WIDTH)
-#define LAST_CPUPID_PGOFF  (ZONES_PGOFF - LAST_CPUPID_WIDTH)
-#define KASAN_TAG_PGOFF(LAST_CPUPID_PGOFF - KASAN_TAG_WIDTH)
-
-/*
- * Define the bit shifts to access each section.  For non-existent
- * sections we define the shift as 0; that plus a 0 mask ensures
- * the compiler will optimise away reference to them.
- */
-#define SECTIONS_PGSHIFT   (SECTIONS_PGOFF * (SECTIONS_WIDTH != 0))
-#define NODES_PGSHIFT  (NODES_PGOFF * (NODES_WIDTH != 0))
-#define ZONES_PGSHIFT  (ZONES_PGOFF * (ZONES_WIDTH != 0))
-#define LAST_CPUPID_PGSHIFT(LAST_CPUPID_PGOFF * (LAST_CPUPID_WIDTH != 0))
-#define KASAN_TAG_PGSHIFT  (KASAN_TAG_PGOFF * (KASAN_TAG_WIDTH != 0))
-
-/* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allocator */
-#ifdef NODE_NOT_IN_PAGE_FLAGS
-#define ZONEID_SHIFT   (SECTIONS_SHIFT + ZONES_SHIFT)
-#define ZONEID_PGOFF   ((SECTIONS_PGOFF < ZONES_PGOFF)? \
-   SECTIONS_PGOFF : ZONES_PGOFF)
-#else
-#define ZONEID_SHIFT   (NODES_SHIFT + ZONES_SHIFT)
-#define ZONEID_PGOFF   ((NODES_PGOFF < ZONES_PGOFF)? \
-   NODES_PGOFF : ZONES_PGOFF)
-#endif
-
-#define ZONEID_PGSHIFT (ZONEID_PGOFF * (ZONEID_SHIFT != 0))
-
-#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1)
-#define NODES_MASK ((1UL << NODES_WIDTH) - 1)
-#define SECTIONS_MASK  ((1UL << SECTIONS_WIDTH) - 1)
-#define LAST_CPUPID_MASK   ((1UL << LAST_CPUPID_SHIFT) - 1)
-#define KASAN_TAG_MASK ((1UL << KASAN_TAG_WIDTH) - 1)
-#define ZONEID_MASK((1UL << ZONEID_SHIFT) - 1)
-
-static inline enum zone_type page_zonenum(const struct page *page)
-{
-   ASSERT_EXCLUSIVE_BITS(page->flags, ZONES_MASK << ZONES_PGSHIFT);
-   return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
-}
-
-static inline enum zone_type folio_zonenum(const struct folio *folio)
-{
-   return page_zonenum(>page);
-}
-
-#ifdef CONFIG_ZONE_DEVICE
-static inline bool is_zone_device_page(const struct page *page)
-{
-   return page_zonenum(page) == ZONE_DEVICE;
-}
-extern void memmap_init_zone_device(struct zone *, unsigned long,
-   unsigned long, struct dev_pagemap *);
-#else
-static inline bool is_zone_device_page(const struct page *page)
-{
-   return false;
-}
-#endif
-
-static inline bool folio_is_zone_device(const struct folio *folio)
-{
-   return is_zone_device_page(>page);
-}
-
-static inline bool is_zone_movable_page(const struct page *page)
-{
-   return page_zonenum(page) == ZONE_MOVABLE;
-}
-
 #if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX)
 DECLARE_STATIC_KEY_FALSE(devmap_managed_key);
 
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index aab70355d64f..47fc41f43c48 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -730,6 +730,86 @@ static inline bool zone_is_empty(struct zone *zone)
return zone->spanned_pages == 0;
 }
 
+#ifndef BUILD_VDSO32_64
+/*
+ * The zone field is never updated after free_area_init_core()
+ * sets it, so none of the operations on it need to be atomic.
+ */
+
+/* Page flags: | [SECTION] | [NODE] | ZONE | [LAST_CPUPID] | ... | FLAGS | */
+#define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS_WIDTH)
+#define NODES_PGOFF(SECTIONS_PGOFF - NODES_WIDTH)
+#define ZONES_PGOFF(NODES_PGOFF - ZONES_WIDTH)
+#define LAST_CPUPID_PGOFF  (ZONES_PGOFF - LAST_CPUPID_WIDTH)
+#define KASAN_TAG_PGOFF(LAST_CPUPID_PGOFF - KASAN_TAG_WIDTH)
+
+/*
+ * Define the bit shifts to access 

Re: [PATCH -next] drm/amdgpu: double free error and freeing uninitialized null pointer

2022-07-14 Thread André Almeida
Às 12:06 de 14/07/22, Sebin Sebastian escreveu:
> On Tue, Jul 12, 2022 at 12:14:27PM -0300, André Almeida wrote:
>> Hi Sebin,
>>
>> Às 10:29 de 10/07/22, Sebin Sebastian escreveu:
>>> Fix two coverity warning's double free and and an uninitialized pointer
>>> read. Both tmp and new are pointing at same address and both are freed
>>> which leads to double free. Freeing tmp in the condition after new is
>>> assigned with new address fixes the double free issue. new is not
>>> initialized to null which also leads to a free on an uninitialized
>>> pointer.
>>> Coverity issue: 1518665 (uninitialized pointer read)
>>> 1518679 (double free)
>>
>> What are those numbers?
>>
> These numbers are the issue ID's for the errors that are being reported
> by the coverity static analyzer tool.
> 

I see, but I don't know which tool was used, so those seem like random
number to me. I would just remove this part of your commit message, but
if you want to keep it, you need to at least mention what's the tool.

>>>
>>> Signed-off-by: Sebin Sebastian 
>>> ---
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 8 +---
>>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>>> index f3b3c688e4e7..d82fe0e1b06b 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>>> @@ -1660,7 +1660,7 @@ static ssize_t 
>>> amdgpu_reset_dump_register_list_write(struct file *f,
>>>  {
>>> struct amdgpu_device *adev = (struct amdgpu_device 
>>> *)file_inode(f)->i_private;
>>> char reg_offset[11];
>>> -   uint32_t *new, *tmp = NULL;
>>> +   uint32_t *new = NULL, *tmp = NULL;
>>> int ret, i = 0, len = 0;
>>>  
>>> do {
>>> @@ -1692,17 +1692,19 @@ static ssize_t 
>>> amdgpu_reset_dump_register_list_write(struct file *f,
>>> goto error_free;
>>> }
>>
>> If the `if (!new) {` above this line is true, will be tmp freed?
>>
> Yes, It doesn't seem to free tmp here. Should I free tmp immediately
> after the do while loop and remove `kfree(tmp)` from the `if (ret)`
> block? Thanks for pointing out the errors.

If you free immediately after the while loop, then you would risk a use
after free here:

swap(adev->reset_dump_reg_list, tmp);

So this isn't the solution either.

> 
>>> ret = down_write_killable(>reset_domain->sem);
>>> -   if (ret)
>>> +   if (ret) {
>>> +   kfree(tmp);
>>> goto error_free;
>>> +   }
>>>  
>>> swap(adev->reset_dump_reg_list, tmp);
>>> swap(adev->reset_dump_reg_value, new);
>>> adev->num_regs = i;
>>> up_write(>reset_domain->sem);
>>> +   kfree(tmp);
>>> ret = size;
>>>  
>>>  error_free:
>>> -   kfree(tmp);
>>> kfree(new);
>>> return ret;
>>>  }


Re: [PATCH 01/10] drm/sched: move calling drm_sched_entity_select_rq

2022-07-14 Thread Andrey Grodzovsky
Can you please remind me of the use case that requires this ? I browsed 
through

related mails in the past but haven't found when is that needed. For amdgpu
drm_sched_job_init and drm_sched_job_arm are called together and amdgpu
is the only one who supports modifying entity priority on the fly as far 
as i see.


Andrey

On 2022-07-14 06:38, Christian König wrote:

We already discussed that the call to drm_sched_entity_select_rq() needs
to move to drm_sched_job_arm() to be able to set a new scheduler list
between _init() and _arm(). This was just not applied for some reason.

Signed-off-by: Christian König 
CC: Andrey Grodzovsky 
CC: dri-devel@lists.freedesktop.org
---
  drivers/gpu/drm/scheduler/sched_main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index 68317d3a7a27..e0ab14e0fb6b 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -592,7 +592,6 @@ int drm_sched_job_init(struct drm_sched_job *job,
   struct drm_sched_entity *entity,
   void *owner)
  {
-   drm_sched_entity_select_rq(entity);
if (!entity->rq)
return -ENOENT;
  
@@ -628,7 +627,7 @@ void drm_sched_job_arm(struct drm_sched_job *job)

struct drm_sched_entity *entity = job->entity;
  
  	BUG_ON(!entity);

-
+   drm_sched_entity_select_rq(entity);
sched = entity->rq->sched;
  
  	job->sched = sched;


Re: [PATCH v2 16/21] drm/i915: Define GuC Based TLB invalidation routines

2022-07-14 Thread Michal Wajdeczko



On 14.07.2022 14:06, Mauro Carvalho Chehab wrote:
> From: Prathap Kumar Valsan 
> 
> Add routines to interface with GuC firmware for selective TLB invalidation
> supported on XeHP.
> 
> Signed-off-by: Prathap Kumar Valsan 
> Cc: Matthew Brost 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C 
> on the cover.
> See [PATCH v2 00/21] at: 
> https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/
> 
>  .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h  |  3 +
>  drivers/gpu/drm/i915/gt/uc/intel_guc.c| 90 +++
>  drivers/gpu/drm/i915/gt/uc/intel_guc.h| 10 +++
>  drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h   |  3 +
>  4 files changed, 106 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
> b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
> index fb0af33e43cc..5c019856a269 100644
> --- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
> +++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
> @@ -188,6 +188,9 @@ enum intel_guc_state_capture_event_status {
>  #define INTEL_GUC_TLB_INVAL_FLUSH_CACHE (1 << 31)
>  
>  enum intel_guc_tlb_invalidation_type {
> + INTEL_GUC_TLB_INVAL_FULL = 0x0,
> + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE = 0x1,
> + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX = 0x2,
>   INTEL_GUC_TLB_INVAL_GUC = 0x3,
>  };
>  
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c 
> b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
> index 8a104a292598..98260a7bc90b 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
> @@ -923,6 +923,96 @@ static int guc_send_invalidate_tlb(struct intel_guc 
> *guc, u32 *action, u32 size)
>   return err;
>  }
>  
> + /* Full TLB invalidation */
> +int intel_guc_invalidate_tlb_full(struct intel_guc *guc,
> +   enum intel_guc_tlb_inval_mode mode)
> +{
> + u32 action[] = {
> + INTEL_GUC_ACTION_TLB_INVALIDATION,
> + 0,
> + INTEL_GUC_TLB_INVAL_FULL << INTEL_GUC_TLB_INVAL_TYPE_SHIFT |
> + mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT |
> + INTEL_GUC_TLB_INVAL_FLUSH_CACHE,
> + };
> +
> + if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION(guc)) {
> + DRM_ERROR("Tlb invalidation: Operation not supported in this 
> platform!\n");

s/Tlb/TLB

and use drm_err() or even consider GEM_BUG_ON() as this looks more like
a coding mistake if we will be here, no ?

> + return 0;
> + }
> +
> + return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
> +}
> +
> +/*
> + * Selective TLB Invalidation for Address Range:
> + * TLB's in the Address Range is Invalidated across all engines.
> + */
> +int intel_guc_invalidate_tlb_page_selective(struct intel_guc *guc,
> + enum intel_guc_tlb_inval_mode mode,
> + u64 start, u64 length)
> +{
> + u64 vm_total = BIT_ULL(INTEL_INFO(guc_to_gt(guc)->i915)->ppgtt_size);
> + u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K));

drop extra ( )

> + u32 full_range = vm_total == length;

bool ?

> + u32 action[] = {
> + INTEL_GUC_ACTION_TLB_INVALIDATION,
> + 0,
> + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE << 
> INTEL_GUC_TLB_INVAL_TYPE_SHIFT |
> + mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT |
> + INTEL_GUC_TLB_INVAL_FLUSH_CACHE,
> + 0,
> + full_range ? full_range : lower_32_bits(start),
> + full_range ? 0 : upper_32_bits(start),
> + full_range ? 0 : address_mask,
> + };
> +
> + if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION_SELECTIVE(guc)) {
> + DRM_ERROR("Tlb invalidation: Operation not supported in this 
> platform!\n");

as above

> + return 0;
> + }
> +
> + GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE_4K));
> + GEM_BUG_ON(!IS_ALIGNED(length, I915_GTT_PAGE_SIZE_4K));
> + GEM_BUG_ON(range_overflows(start, length, vm_total));
> +
> + return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
> +}
> +
> +/*
> + * Selective TLB Invalidation for Context:
> + * Invalidates all TLB's for a specific context across all engines.
> + */
> +int intel_guc_invalidate_tlb_page_selective_ctx(struct intel_guc *guc,
> + enum intel_guc_tlb_inval_mode 
> mode,
> + u64 start, u64 length, u32 
> ctxid)
> +{
> + u64 vm_total = BIT_ULL(INTEL_INFO(guc_to_gt(guc)->i915)->ppgtt_size);
> + u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K));

drop ( )

> + u32 full_range = vm_total == length;

bool

> + u32 action[] = {
> + INTEL_GUC_ACTION_TLB_INVALIDATION,
> + 0,
> + INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX << 
> 

Re: [PATCH -next] drm/amdgpu: double free error and freeing uninitialized null pointer

2022-07-14 Thread Sebin Sebastian
On Tue, Jul 12, 2022 at 12:14:27PM -0300, André Almeida wrote:
> Hi Sebin,
> 
> Às 10:29 de 10/07/22, Sebin Sebastian escreveu:
> > Fix two coverity warning's double free and and an uninitialized pointer
> > read. Both tmp and new are pointing at same address and both are freed
> > which leads to double free. Freeing tmp in the condition after new is
> > assigned with new address fixes the double free issue. new is not
> > initialized to null which also leads to a free on an uninitialized
> > pointer.
> > Coverity issue: 1518665 (uninitialized pointer read)
> > 1518679 (double free)
> 
> What are those numbers?
>
These numbers are the issue ID's for the errors that are being reported
by the coverity static analyzer tool.

> > 
> > Signed-off-by: Sebin Sebastian 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 8 +---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> > index f3b3c688e4e7..d82fe0e1b06b 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> > @@ -1660,7 +1660,7 @@ static ssize_t 
> > amdgpu_reset_dump_register_list_write(struct file *f,
> >  {
> > struct amdgpu_device *adev = (struct amdgpu_device 
> > *)file_inode(f)->i_private;
> > char reg_offset[11];
> > -   uint32_t *new, *tmp = NULL;
> > +   uint32_t *new = NULL, *tmp = NULL;
> > int ret, i = 0, len = 0;
> >  
> > do {
> > @@ -1692,17 +1692,19 @@ static ssize_t 
> > amdgpu_reset_dump_register_list_write(struct file *f,
> > goto error_free;
> > }
> 
> If the `if (!new) {` above this line is true, will be tmp freed?
> 
Yes, It doesn't seem to free tmp here. Should I free tmp immediately
after the do while loop and remove `kfree(tmp)` from the `if (ret)`
block? Thanks for pointing out the errors.

> > ret = down_write_killable(>reset_domain->sem);
> > -   if (ret)
> > +   if (ret) {
> > +   kfree(tmp);
> > goto error_free;
> > +   }
> >  
> > swap(adev->reset_dump_reg_list, tmp);
> > swap(adev->reset_dump_reg_value, new);
> > adev->num_regs = i;
> > up_write(>reset_domain->sem);
> > +   kfree(tmp);
> > ret = size;
> >  
> >  error_free:
> > -   kfree(tmp);
> > kfree(new);
> > return ret;
> >  }


Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Christian König

Am 14.07.22 um 15:33 schrieb Alex Deucher:

On Thu, Jul 14, 2022 at 9:09 AM Christian König
 wrote:

Hi Mauro,

well the last time I checked drm-tip was clean.

The revert is necessary because we had some problems with the commit
which we couldn't fix in the 5.19 cycle.

Would it be worth reverting the revert and applying the actual fix[1]?
  It's a huge revert unfortunately while the actual fix is like 10
lines of code.  I'm concerned there will be subtle fallout from the
revert due to how extensive it is.


We have other bug fixes and cleanups around that patch which didn't made 
it into 5.19 either. I don't want to create an ever greater mess.


Real question is why building drm-tip work for me but not for others?

Christian.



[1] - 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2Fuploads%2F564b2cc2b5ea87357f39e45c3a1a44e2%2F0001-drm-amdgpu-Fix-for-drm-buddy-memory-corruption.patchdata=05%7C01%7Cchristian.koenig%40amd.com%7Cee3322f9e7c54aaabb9f08da659d74a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637934024189075602%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=cGS2JZt84FMlA4V57pAA2ilXDC5pvr8ryZcUoHpXKXA%3Dreserved=0

Alex



I will double check drm-tip once more.

Regards,
Christian.

Am 14.07.22 um 14:54 schrieb Mauro Carvalho Chehab:

On Fri, 8 Jul 2022 03:21:24 -0700
Arunpravin Paneer Selvam  wrote:


This reverts the following commits:
commit 708d19d9f362 ("drm/amdgpu: move internal vram_mgr function into the C 
file")
commit 5e3f1e7729ec ("drm/amdgpu: fix start calculation in amdgpu_vram_mgr_new")
commit c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu")

[WHY]
Few users reported garbaged graphics as soon as x starts,
reverting until this can be resolved.

Signed-off-by: Arunpravin Paneer Selvam 

This revert is currently breaking drm-tip. Please revert it ASAP, as it
is preventing CI bots to properly test new patches on the top of current
drm-tip:

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function ‘amdgpu_vram_mgr_new’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: error: ‘cur_size’ 
undeclared (first use in this function)
459 | if (cur_size != size) {
| ^~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: note: each undeclared 
identifier is reported only once for each function it appears in
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:25: error: ‘size’ undeclared 
(first use in this function); did you mean ‘ksize’?
459 | if (cur_size != size) {
| ^~~~
| ksize
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:30: error: ‘vres’ undeclared 
(first use in this function); did you mean ‘res’?
465 | trim_list = >blocks;
|  ^~~~
|  res
In file included from ./include/linux/bits.h:22,
   from ./include/linux/ratelimit_types.h:5,
   from ./include/linux/ratelimit.h:5,
   from ./include/linux/dev_printk.h:16,
   from ./include/linux/device.h:15,
   from ./include/linux/dma-mapping.h:7,
   from drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:25:
./include/linux/container_of.h:19:54: error: invalid use of undefined type 
‘struct drm_buddy_block’
 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) || 
  \
|  ^~
./include/linux/build_bug.h:78:56: note: in definition of macro 
‘__static_assert’
 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|^~~~
./include/linux/container_of.h:19:9: note: in expansion of macro ‘static_assert’
 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) || 
  \
| ^
./include/linux/container_of.h:19:23: note: in expansion of macro ‘__same_type’
 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) || 
  \
|   ^~~
./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
520 | container_of(ptr, type, member)
| ^~~~
./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
542 | list_entry((ptr)->prev, type, member)
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion of 
macro ‘list_last_entry’
473 | block = list_last_entry(>blocks, 
typeof(*block), link);
| ^~~
././include/linux/compiler_types.h:295:27: error: expression in static 
assertion is not an integer
295 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
typeof(b))

Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Mauro Carvalho Chehab
On Thu, 14 Jul 2022 09:33:23 -0400
Alex Deucher  wrote:

> On Thu, Jul 14, 2022 at 9:09 AM Christian König
>  wrote:
> >
> > Hi Mauro,
> >
> > well the last time I checked drm-tip was clean.
> >
> > The revert is necessary because we had some problems with the commit
> > which we couldn't fix in the 5.19 cycle.  
> 
> Would it be worth reverting the revert and applying the actual fix[1]?
>  It's a huge revert unfortunately while the actual fix is like 10
> lines of code.  I'm concerned there will be subtle fallout from the
> revert due to how extensive it is.
> 
> [1] - 
> https://gitlab.freedesktop.org/drm/amd/uploads/564b2cc2b5ea87357f39e45c3a1a44e2/0001-drm-amdgpu-Fix-for-drm-buddy-memory-corruption.patch

The tree now seems to be clean. I re-submitted a CI trybot job to double-check
if everything is ok.

Probably the issue was due to some badly solved merge conflict.

Thank you!
Mauro

> 
> Alex
> 
> 
> >
> > I will double check drm-tip once more.
> >
> > Regards,
> > Christian.
> >
> > Am 14.07.22 um 14:54 schrieb Mauro Carvalho Chehab:  
> > > On Fri, 8 Jul 2022 03:21:24 -0700
> > > Arunpravin Paneer Selvam  wrote:
> > >  
> > >> This reverts the following commits:
> > >> commit 708d19d9f362 ("drm/amdgpu: move internal vram_mgr function into 
> > >> the C file")
> > >> commit 5e3f1e7729ec ("drm/amdgpu: fix start calculation in 
> > >> amdgpu_vram_mgr_new")
> > >> commit c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu")
> > >>
> > >> [WHY]
> > >> Few users reported garbaged graphics as soon as x starts,
> > >> reverting until this can be resolved.
> > >>
> > >> Signed-off-by: Arunpravin Paneer Selvam 
> > >>   
> > > This revert is currently breaking drm-tip. Please revert it ASAP, as it
> > > is preventing CI bots to properly test new patches on the top of current
> > > drm-tip:
> > >
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function 
> > > ‘amdgpu_vram_mgr_new’:
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: error: ‘cur_size’ 
> > > undeclared (first use in this function)
> > >459 | if (cur_size != size) {
> > >| ^~~~
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: note: each 
> > > undeclared identifier is reported only once for each function it appears 
> > > in
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:25: error: ‘size’ 
> > > undeclared (first use in this function); did you mean ‘ksize’?
> > >459 | if (cur_size != size) {
> > >| ^~~~
> > >| ksize
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:30: error: ‘vres’ 
> > > undeclared (first use in this function); did you mean ‘res’?
> > >465 | trim_list = >blocks;
> > >|  ^~~~
> > >|  res
> > > In file included from ./include/linux/bits.h:22,
> > >   from ./include/linux/ratelimit_types.h:5,
> > >   from ./include/linux/ratelimit.h:5,
> > >   from ./include/linux/dev_printk.h:16,
> > >   from ./include/linux/device.h:15,
> > >   from ./include/linux/dma-mapping.h:7,
> > >   from drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:25:
> > > ./include/linux/container_of.h:19:54: error: invalid use of undefined 
> > > type ‘struct drm_buddy_block’
> > > 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) 
> > > ||   \
> > >|  ^~
> > > ./include/linux/build_bug.h:78:56: note: in definition of macro 
> > > ‘__static_assert’
> > > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> > >|^~~~
> > > ./include/linux/container_of.h:19:9: note: in expansion of macro 
> > > ‘static_assert’
> > > 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) 
> > > ||   \
> > >| ^
> > > ./include/linux/container_of.h:19:23: note: in expansion of macro 
> > > ‘__same_type’
> > > 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) 
> > > ||   \
> > >|   ^~~
> > > ./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
> > >520 | container_of(ptr, type, member)
> > >| ^~~~
> > > ./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
> > >542 | list_entry((ptr)->prev, type, member)
> > >| ^~
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion 
> > > of macro ‘list_last_entry’
> > >473 | block = list_last_entry(>blocks, 
> > > typeof(*block), link);
> > >| ^~~
> > > ././include/linux/compiler_types.h:295:27: error: expression in static 
> 

Re: [PATCH 0/3] drm/vc4: use drm managed resources

2022-07-14 Thread Danilo Krummrich

Hi Maxime,

On 7/13/22 11:10, Maxime Ripard wrote:

Hi Danilo,

On Wed, Jul 13, 2022 at 10:54:57AM +0200, Danilo Krummrich wrote:

This patch series converts DRM modeset object allocations from devm_*()
to drmm_*() memory allocators, or their corresponding convenience
wrappers, respectively, in order to tie the release action to the
underlaying struct drm_device.

This can prevent potential use-after free issues on driver unload or
EPROBE_DEFERRED backoff.


Yeah, the driver had a lot of this kind of issues.

As it turns out, at the moment you sent it, I was applying a larger
series (hopefully) addressing all of them:
https://lore.kernel.org/all/20220711173939.1132294-1-max...@cerno.tech/

Ah, great! That's covering even more than the series I sent.


Maxime


- Danilo



Re: [PATCH v1] drm/scheduler: Don't kill jobs in interrupt context

2022-07-14 Thread Dmitry Osipenko
On 7/14/22 17:14, Andrey Grodzovsky wrote:
> 
> On 2022-07-14 05:57, Dmitry Osipenko wrote:
>> On 7/12/22 11:56, Dmitry Osipenko wrote:
>>> On 7/6/22 18:46, Alex Deucher wrote:
 On Wed, Jul 6, 2022 at 9:49 AM Andrey Grodzovsky
  wrote:
> On 2022-07-06 03:07, Dmitry Osipenko wrote:
>
>> Hello Andrey,
>>
>> On 5/17/22 17:48, Dmitry Osipenko wrote:
>>> On 5/17/22 17:13, Andrey Grodzovsky wrote:
 Done.

 Andrey
>>> Awesome, thank you!
>>>
>> Given that this drm-scheduler issue needs to be fixed in the
>> 5.19-RC and
>> earlier, shouldn't it be in the drm-fixes and not in drm-next?
>
> I pushed it into drm-misc from where it got into drm-next. I don't
> have
> permission for drm-fixes.
 The -fixes branch of drm-misc.
>>> Now I don't see the scheduler bugfix neither in the -fixes branch nor in
>>> the -next and today Dave sent out 5.19-rc7 pull request without the
>>> scheduler fix. Could anyone please check what is going on with the DRM
>>> patches? Thanks!
>>>
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffreedesktop%2Fdrm-misc%2Fcommits%2Fdrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7C68b627b8482a4fd28a5608da657f4375%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637933894551324163%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=CDdLG%2F7SqCudEnjhBSsXqq15mfhlHlS3xAdAfB%2Bh%2F1s%3Dreserved=0
>>>
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fdrm%2Fdrm-misc%2Flog%2F%3Fh%3Ddrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7C68b627b8482a4fd28a5608da657f4375%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637933894551324163%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=4Vz40j6F%2FzHYckXEyPEunj9DRSoTXikhNxZDXeocTss%3Dreserved=0
>>>
>> The patch is in the drm-misc-next-fixes, so it wasn't moved to the
>> drm-misc-fixes.
>>
>> Andrey, don't you have access to drm-misc-fixes? Or you meant
>> drm-fixes=drm-misc-fixes?
> 
> 
> I have only accesses to drm-misc-next to which I pushed this patch.

Thank you for the clarification. IIUC, the drm-misc-next-fixes should
become drm-misc-fixes, but perhaps it was late for the 5.19-rc6 for this
patch.

-- 
Best regards,
Dmitry


Re: [PATCH] drm: Fix EDID firmware load on resume

2022-07-14 Thread André Almeida
Hi Matthieu,

Thanks for your patch.

Às 11:58 de 06/07/22, Matthieu CHARETTE escreveu:
> Loading an EDID using drm.edid_firmware parameter makes resume to fail
> after firmware cache is being cleaned. This is because edid_load() use a
> temporary device to request the firmware. This cause the EDID firmware
> not to be cached from suspend. And, requesting the EDID firmware return
> an error during resume.
> So the request_firmware() call should use a permanent device for each
> connector. Also, we should cache the EDID even if no monitor is
> connected, in case it's plugged while suspended.
> 
> Signed-off-by: Matthieu CHARETTE 
> ---
> drivers/gpu/drm/drm_connector.c | 9 
> drivers/gpu/drm/drm_edid_load.c | 81 -
> include/drm/drm_connector.h | 12 +
> include/drm/drm_edid.h | 3 ++
> 4 files changed, 94 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c
> b/drivers/gpu/drm/drm_connector.c
> index 1c48d162c77e..e8819ebf1c4b 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -31,6 +31,7 @@
> #include 
> #include 
> 
> +#include 
> #include 
> 
> #include "drm_crtc_internal.h"
> @@ -289,6 +290,9 @@ int drm_connector_init(struct drm_device *dev,
> 
>  drm_connector_get_cmdline_mode(connector);
> 
> + connector->edid_load_pdev = NULL;
> + drm_cache_edid_firmware(connector);
> +
>  /* We should add connectors at the end to avoid upsetting the connector
>   * index too much.
>   */
> @@ -473,6 +477,11 @@ void drm_connector_cleanup(struct drm_connector
> *connector)
>   connector->tile_group = NULL;
>  }
> 
> + if (connector->edid_load_pdev) {
> + platform_device_unregister(connector->edid_load_pdev);
> + connector->edid_load_pdev = NULL;
> + }
> +

The indentation of your patch is wrong in different places, like in this
if here. It should be like

+ if (connector->edid_load_pdev) {
+   platform_device_unregister(connector->edid_load_pdev);
+   connector->edid_load_pdev = NULL;
+ }

./scripts/checkpatch.pl can help you detect those issues for your v2

Thanks,
André


Re: [PATCH v1] drm/scheduler: Don't kill jobs in interrupt context

2022-07-14 Thread Andrey Grodzovsky



On 2022-07-14 05:57, Dmitry Osipenko wrote:

On 7/12/22 11:56, Dmitry Osipenko wrote:

On 7/6/22 18:46, Alex Deucher wrote:

On Wed, Jul 6, 2022 at 9:49 AM Andrey Grodzovsky
 wrote:

On 2022-07-06 03:07, Dmitry Osipenko wrote:


Hello Andrey,

On 5/17/22 17:48, Dmitry Osipenko wrote:

On 5/17/22 17:13, Andrey Grodzovsky wrote:

Done.

Andrey

Awesome, thank you!


Given that this drm-scheduler issue needs to be fixed in the 5.19-RC and
earlier, shouldn't it be in the drm-fixes and not in drm-next?


I pushed it into drm-misc from where it got into drm-next. I don't have
permission for drm-fixes.

The -fixes branch of drm-misc.

Now I don't see the scheduler bugfix neither in the -fixes branch nor in
the -next and today Dave sent out 5.19-rc7 pull request without the
scheduler fix. Could anyone please check what is going on with the DRM
patches? Thanks!

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffreedesktop%2Fdrm-misc%2Fcommits%2Fdrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7C68b627b8482a4fd28a5608da657f4375%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637933894551324163%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=CDdLG%2F7SqCudEnjhBSsXqq15mfhlHlS3xAdAfB%2Bh%2F1s%3Dreserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fdrm%2Fdrm-misc%2Flog%2F%3Fh%3Ddrm-misc-fixesdata=05%7C01%7Candrey.grodzovsky%40amd.com%7C68b627b8482a4fd28a5608da657f4375%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637933894551324163%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=4Vz40j6F%2FzHYckXEyPEunj9DRSoTXikhNxZDXeocTss%3Dreserved=0

The patch is in the drm-misc-next-fixes, so it wasn't moved to the
drm-misc-fixes.

Andrey, don't you have access to drm-misc-fixes? Or you meant
drm-fixes=drm-misc-fixes?



I have only accesses to drm-misc-next to which I pushed this patch.

Andrey






[PULL] drm-misc-next-fixes

2022-07-14 Thread Thomas Zimmermann
Hi Dave and Daniel,

here's the first PR for drm-misc-next-fixes for v5.20.

Best regards
Thomas

drm-misc-next-fixes-2022-07-14:
Short summary of fixes:

 - dma-buf: revert change to fence handling
 - mgag200: fix PCI register initialization
The following changes since commit 0180290abb5ce5c870f84a00ffeda5802f641dce:

  Merge tag 'topic/nouveau-misc-2022-07-13-1' of 
git://anongit.freedesktop.org/drm/drm into drm-next (2022-07-13 14:27:12 +1000)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-next-fixes-2022-07-14

for you to fetch changes up to 7d09c7606346db9a48b62b4e02454a6b8f323043:

  drm/mgag200: Don't read-back PCI option register before writing (2022-07-14 
15:14:45 +0200)


Short summary of fixes:

 - dma-buf: revert change to fence handling
 - mgag200: fix PCI register initialization


Christian König (1):
  dma-buf: revert "return only unsignaled fences in 
dma_fence_unwrap_for_each v3"

Thomas Zimmermann (2):
  Merge drm/drm-next into drm-misc-next-fixes
  drm/mgag200: Don't read-back PCI option register before writing

 drivers/dma-buf/dma-fence-unwrap.c| 3 ++-
 drivers/gpu/drm/mgag200/mgag200_drv.c | 6 --
 include/linux/dma-fence-unwrap.h  | 6 +-
 3 files changed, 3 insertions(+), 12 deletions(-)

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


Re: [PATCH v2 09/21] drm/i915/guc: Define CTB based TLB invalidation routines

2022-07-14 Thread Michal Wajdeczko



On 14.07.2022 14:06, Mauro Carvalho Chehab wrote:
> From: Prathap Kumar Valsan 
> 
> Add routines to interface with GuC firmware for TLB invalidation.
> 
> Signed-off-by: Prathap Kumar Valsan 
> Cc: Bruce Chang 
> Cc: Michal Wajdeczko 
> Cc: Matthew Brost 
> Cc: Chris Wilson 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
> 
> To avoid mailbombing on a large number of people, only mailing lists were C/C 
> on the cover.
> See [PATCH v2 00/21] at: 
> https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/
> 
>  .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h  | 35 +++
>  drivers/gpu/drm/i915/gt/uc/intel_guc.c| 90 ++
>  drivers/gpu/drm/i915/gt/uc/intel_guc.h| 13 +++
>  drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 24 -
>  drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h   |  6 ++
>  .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 91 ++-
>  6 files changed, 253 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
> b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
> index 4ef9990ed7f8..2e39d8df4c82 100644
> --- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
> +++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
> @@ -134,6 +134,10 @@ enum intel_guc_action {
>   INTEL_GUC_ACTION_REGISTER_CONTEXT_MULTI_LRC = 0x4601,
>   INTEL_GUC_ACTION_CLIENT_SOFT_RESET = 0x5507,
>   INTEL_GUC_ACTION_SET_ENG_UTIL_BUFF = 0x550A,
> + INTEL_GUC_ACTION_NOTIFY_MEMORY_CAT_ERROR = 0x6000,

should this be part of this patch ?

> + INTEL_GUC_ACTION_PAGE_FAULT_NOTIFICATION = 0x6001,
> + INTEL_GUC_ACTION_TLB_INVALIDATION = 0x7000,
> + INTEL_GUC_ACTION_TLB_INVALIDATION_DONE = 0x7001,

can we document layout of these actions ?

>   INTEL_GUC_ACTION_STATE_CAPTURE_NOTIFICATION = 0x8002,
>   INTEL_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE = 0x8003,
>   INTEL_GUC_ACTION_NOTIFY_CRASH_DUMP_POSTED = 0x8004,
> @@ -177,4 +181,35 @@ enum intel_guc_state_capture_event_status {
>  
>  #define INTEL_GUC_STATE_CAPTURE_EVENT_STATUS_MASK  0x00FF
>  
> +#define INTEL_GUC_TLB_INVAL_TYPE_SHIFT 0
> +#define INTEL_GUC_TLB_INVAL_MODE_SHIFT 8

can we stop using SHIFT-based definitions and start using MASK-based
instead ? then we will be able to use FIELD_PREP/GET like we do for i915_reg

> +/* Flush PPC or SMRO caches along with TLB invalidation request */
> +#define INTEL_GUC_TLB_INVAL_FLUSH_CACHE (1 << 31)
> +
> +enum intel_guc_tlb_invalidation_type {
> + INTEL_GUC_TLB_INVAL_GUC = 0x3,
> +};
> +
> +/*
> + * 0: Heavy mode of Invalidation:
> + * The pipeline of the engine(s) for which the invalidation is targeted to is
> + * blocked, and all the in-flight transactions are guaranteed to be Globally
> + * Observed before completing the TLB invalidation
> + * 1: Lite mode of Invalidation:
> + * TLBs of the targeted engine(s) are immediately invalidated.
> + * In-flight transactions are NOT guaranteed to be Globally Observed before
> + * completing TLB invalidation.
> + * Light Invalidation Mode is to be used only when
> + * it can be guaranteed (by SW) that the address translations remain 
> invariant
> + * for the in-flight transactions across the TLB invalidation. In other 
> words,
> + * this mode can be used when the TLB invalidation is intended to clear out 
> the
> + * stale cached translations that are no longer in use. Light Invalidation 
> Mode
> + * is much faster than the Heavy Invalidation Mode, as it does not wait for 
> the
> + * in-flight transactions to be GOd.
> + */

either drop this comment or squash with patch 10/21 to fix it

> +enum intel_guc_tlb_inval_mode {
> + INTEL_GUC_TLB_INVAL_MODE_HEAVY = 0x0,
> + INTEL_GUC_TLB_INVAL_MODE_LITE = 0x1,
> +};
> +
>  #endif /* _ABI_GUC_ACTIONS_ABI_H */
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c 
> b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
> index 2706a8c65090..5c59f9b144a3 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
> @@ -855,6 +855,96 @@ int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, 
> u64 value)
>   return __guc_self_cfg(guc, key, 2, value);
>  }
>  
> +static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 *action, u32 
> size)

nit: maybe since MMIO TLB has moved to dedicated file, we can do the
same with GUC TLB code like "intel_guc_tlb.c" ?

> +{
> + struct intel_guc_tlb_wait _wq, *wq = &_wq;
> + DEFINE_WAIT_FUNC(wait, woken_wake_function);
> + int err = 0;
> + u32 seqno;
> +
> + init_waitqueue_head(&_wq.wq);
> +
> + if (xa_alloc_cyclic_irq(>tlb_lookup, , wq,
> + xa_limit_32b, >next_seqno,
> + GFP_ATOMIC | __GFP_NOWARN) < 0) {
> + /* Under severe memory pressure? Serialise TLB allocations */
> + xa_lock_irq(>tlb_lookup);
> + wq = xa_load(>tlb_lookup, guc->serial_slot);
> + wait_event_lock_irq(wq->wq,
> +  

[PATCH] drm/amdgpu: Clarify asics naming in Kconfig options

2022-07-14 Thread André Almeida
Clarify which architecture those asics acronyms refers to.

Signed-off-by: André Almeida 
---
 drivers/gpu/drm/amd/amdgpu/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig 
b/drivers/gpu/drm/amd/amdgpu/Kconfig
index 74a8105fd2c0..d55275de 100644
--- a/drivers/gpu/drm/amd/amdgpu/Kconfig
+++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
@@ -4,7 +4,7 @@ config DRM_AMDGPU_SI
depends on DRM_AMDGPU
help
  Choose this option if you want to enable experimental support
- for SI asics.
+ for SI (Southern Islands) asics.
 
  SI is already supported in radeon. Experimental support for SI
  in amdgpu will be disabled by default and is still provided by
@@ -16,7 +16,8 @@ config DRM_AMDGPU_CIK
bool "Enable amdgpu support for CIK parts"
depends on DRM_AMDGPU
help
- Choose this option if you want to enable support for CIK asics.
+ Choose this option if you want to enable support for CIK (Sea
+ Islands) asics.
 
  CIK is already supported in radeon. Support for CIK in amdgpu
  will be disabled by default and is still provided by radeon.
-- 
2.37.0



Re: [linux-next:master] BUILD REGRESSION 4662b7adea50bb62e993a67f611f3be625d3df0d

2022-07-14 Thread Philip Li
On Thu, Jul 14, 2022 at 01:35:35PM +0100, Russell King (Oracle) wrote:
> Hi,
> 
> I don't mean to discourge test systems, but looking at this, I just go
> "meh" and delete it - it doesn't seem to contain obviously useful
> information. One has to read every damn line to see if there's something
> of relevence, which I for one am not going to do.
> 
> Is there some kind of improvement that could be done to this to make it
> more useful - such as only sending the warnings/errors to the
> appropriate mailing lists for those - rather than grouping everything
> together into one email. At least that should make the stuff (a) more
> relevant and (b) easier to parse.

Thanks for the feedback Russell, we will further consider how to make this
summary report more helpful, and reduce unnecessary distribution to many
mailing list.

Typically, 0day ci sends 2 kinds of reports, one is bisected report, which
has specific warning/error as you mentioned to related receivers. Such as
https://lore.kernel.org/all/202207130344.auqexe4e-...@intel.com/

The other is this summary, we want to give an overview to the owner for the
head status. And we will re-consider the appropriate audiences for the mail
and the contents to make it clear.

> 
> Russell.
> 
> On Thu, Jul 14, 2022 at 09:56:19AM +0800, kernel test robot wrote:
> > tree/branch: 
> > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > branch HEAD: 4662b7adea50bb62e993a67f611f3be625d3df0d  Add linux-next 
> > specific files for 20220713
> > 
> > Error/Warning reports:
> > 
> > https://lore.kernel.org/linux-doc/202207021352.ppktuy8v-...@intel.com
> > https://lore.kernel.org/linux-doc/202207031437.qih6lfcx-...@intel.com
> > https://lore.kernel.org/linux-doc/202207051821.3f0erisl-...@intel.com
> > https://lore.kernel.org/linux-doc/202207140742.gtpk4u8i-...@intel.com
> > https://lore.kernel.org/linux-mm/202206292052.lsfui3zo-...@intel.com
> > https://lore.kernel.org/linux-mm/202207140042.ck3tlk6j-...@intel.com
> > https://lore.kernel.org/llvm/202207090100.acxdj79h-...@intel.com
> > 
> > Error/Warning: (recently discovered and may have been fixed)
> > 
> > Documentation/PCI/endpoint/pci-vntb-function.rst:82: WARNING: Unexpected 
> > indentation.
> > Documentation/PCI/endpoint/pci-vntb-howto.rst:131: WARNING: Title underline 
> > too short.
> > Documentation/filesystems/netfs_library.rst:384: WARNING: Inline emphasis 
> > start-string without end-string.
> > Documentation/filesystems/netfs_library:609: fs/netfs/buffered_read.c:318: 
> > WARNING: Inline emphasis start-string without end-string.
> > Documentation/virt/kvm/api.rst:8256: WARNING: Title underline too short.
> > Documentation/virt/kvm/api.rst:8263: WARNING: Unexpected indentation.
> > drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:2837:6: warning: no 
> > previous prototype for function 'dc_reset_state' [-Wmissing-prototypes]
> > drivers/mmc/host/sdhci-of-aspeed-test.c:10: undefined reference to 
> > `kunit_binary_assert_format'
> > drivers/pci/endpoint/functions/pci-epf-vntb.c:975:5: warning: no previous 
> > prototype for 'pci_read' [-Wmissing-prototypes]
> > drivers/pci/endpoint/functions/pci-epf-vntb.c:984:5: warning: no previous 
> > prototype for 'pci_write' [-Wmissing-prototypes]
> > drivers/vfio/vfio_iommu_type1.c:2141:35: warning: cast to smaller integer 
> > type 'enum iommu_cap' from 'void *' [-Wvoid-pointer-to-enum-cast]
> > fs/ntfs/attrib.c:705:18: warning: Either the condition '!al' is redundant 
> > or there is pointer arithmetic with NULL pointer. 
> > [nullPointerArithmeticRedundantCheck]
> > fs/ntfs/layout.h:126:43: warning: Parameter 'p' can be declared with const 
> > [constParameter]
> > fs/ntfs/ntfs.h:144:3: warning: Assignment of function parameter has no 
> > effect outside the function. [uselessAssignmentArg]
> > fs/super.c:1310:57: warning: Parameter 'data' can be declared with const 
> > [constParameter]
> > fs/super.c:750:52: warning: Parameter 'bdev' can be declared with const 
> > [constParameter]
> > ipc/shm.c:158:0: warning: failed to expand 'ipc_init_proc_interface', it is 
> > invalid to use a preprocessor directive as macro parameter 
> > [preprocessorErrorDirective]
> > kernel/bpf/task_iter.c:152:11: warning: Redundant initialization for 
> > 'curr_fd'. The initialized value is overwritten before it is read. 
> > [redundantInitialization]
> > kernel/bpf/task_iter.c:498:59: warning: Parameter 'v' can be declared with 
> > const [constParameter]
> > kernel/fork.c:3256:42: warning: Parameter 'table' can be declared with 
> > const [constParameter]
> > kernel/fork.c:942:33: warning: Parameter 'src' can be declared with const 
> > [constParameter]
> > kernel/sched/fair.c:5081:25: warning: Uninitialized variables: cfs_rq.load, 
> > cfs_rq.nr_running, cfs_rq.h_nr_running, cfs_rq.idle_nr_running, 
> > cfs_rq.idle_h_nr_running, cfs_rq.exec_clock, cfs_rq.min_vruntime, 
> > cfs_rq.min_vruntime_copy, cfs_rq.tasks_timeline, cfs_rq.curr, cfs_rq.next, 
> > 

Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Alex Deucher
On Thu, Jul 14, 2022 at 9:09 AM Christian König
 wrote:
>
> Hi Mauro,
>
> well the last time I checked drm-tip was clean.
>
> The revert is necessary because we had some problems with the commit
> which we couldn't fix in the 5.19 cycle.

Would it be worth reverting the revert and applying the actual fix[1]?
 It's a huge revert unfortunately while the actual fix is like 10
lines of code.  I'm concerned there will be subtle fallout from the
revert due to how extensive it is.

[1] - 
https://gitlab.freedesktop.org/drm/amd/uploads/564b2cc2b5ea87357f39e45c3a1a44e2/0001-drm-amdgpu-Fix-for-drm-buddy-memory-corruption.patch

Alex


>
> I will double check drm-tip once more.
>
> Regards,
> Christian.
>
> Am 14.07.22 um 14:54 schrieb Mauro Carvalho Chehab:
> > On Fri, 8 Jul 2022 03:21:24 -0700
> > Arunpravin Paneer Selvam  wrote:
> >
> >> This reverts the following commits:
> >> commit 708d19d9f362 ("drm/amdgpu: move internal vram_mgr function into the 
> >> C file")
> >> commit 5e3f1e7729ec ("drm/amdgpu: fix start calculation in 
> >> amdgpu_vram_mgr_new")
> >> commit c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu")
> >>
> >> [WHY]
> >> Few users reported garbaged graphics as soon as x starts,
> >> reverting until this can be resolved.
> >>
> >> Signed-off-by: Arunpravin Paneer Selvam 
> > This revert is currently breaking drm-tip. Please revert it ASAP, as it
> > is preventing CI bots to properly test new patches on the top of current
> > drm-tip:
> >
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function 
> > ‘amdgpu_vram_mgr_new’:
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: error: ‘cur_size’ 
> > undeclared (first use in this function)
> >459 | if (cur_size != size) {
> >| ^~~~
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: note: each undeclared 
> > identifier is reported only once for each function it appears in
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:25: error: ‘size’ 
> > undeclared (first use in this function); did you mean ‘ksize’?
> >459 | if (cur_size != size) {
> >| ^~~~
> >| ksize
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:30: error: ‘vres’ 
> > undeclared (first use in this function); did you mean ‘res’?
> >465 | trim_list = >blocks;
> >|  ^~~~
> >|  res
> > In file included from ./include/linux/bits.h:22,
> >   from ./include/linux/ratelimit_types.h:5,
> >   from ./include/linux/ratelimit.h:5,
> >   from ./include/linux/dev_printk.h:16,
> >   from ./include/linux/device.h:15,
> >   from ./include/linux/dma-mapping.h:7,
> >   from drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:25:
> > ./include/linux/container_of.h:19:54: error: invalid use of undefined type 
> > ‘struct drm_buddy_block’
> > 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
> >  \
> >|  ^~
> > ./include/linux/build_bug.h:78:56: note: in definition of macro 
> > ‘__static_assert’
> > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >|^~~~
> > ./include/linux/container_of.h:19:9: note: in expansion of macro 
> > ‘static_assert’
> > 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
> >  \
> >| ^
> > ./include/linux/container_of.h:19:23: note: in expansion of macro 
> > ‘__same_type’
> > 19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
> >  \
> >|   ^~~
> > ./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
> >520 | container_of(ptr, type, member)
> >| ^~~~
> > ./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
> >542 | list_entry((ptr)->prev, type, member)
> >| ^~
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion of 
> > macro ‘list_last_entry’
> >473 | block = list_last_entry(>blocks, 
> > typeof(*block), link);
> >| ^~~
> > ././include/linux/compiler_types.h:295:27: error: expression in static 
> > assertion is not an integer
> >295 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
> > typeof(b))
> >|   ^~~~
> > ./include/linux/build_bug.h:78:56: note: in definition of macro 
> > ‘__static_assert’
> > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >|^~~~
> > 

Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Christian König

Am 14.07.22 um 15:19 schrieb Mauro Carvalho Chehab:

On Thu, 14 Jul 2022 15:08:48 +0200
Christian König  wrote:


Hi Mauro,

well the last time I checked drm-tip was clean.

The revert is necessary because we had some problems with the commit
which we couldn't fix in the 5.19 cycle.

I see. I don't have any issues with the patch itself, provided that drm-tip
build doesn't break ;-)


I will double check drm-tip once more.

Did a new rebase on the top of:
bc04f10d22f7 (drm-tip/drm-tip) drm-tip: 2022y-07m-14d-12h-41m-36s UTC 
integration manifest


I have absolutely no idea what's going wrong here.

After just running "dim rebuild-tip" once more my drm-tip is at:

commit bc04f10d22f7d8a6d76abe431cfb6ef6ba67ad0c (drm-tip/drm-tip, drm-tip)
Author: Christian König 
Date:   Thu Jul 14 14:42:33 2022 +0200

    drm-tip: 2022y-07m-14d-12h-41m-36s UTC integration manifest

And that's compiling perfectly fine.

Regards,
Christian.



And it is still broken on amdgpu_vram_mgr.c, but now with different issues:

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function ‘amdgpu_vram_mgr_new’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:13: error: ‘i’ undeclared 
(first use in this function)
   465 | if (i == 1)
   | ^
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:13: note: each undeclared 
identifier is reported only once for each function it appears in
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:466:17: error: ‘node’ undeclared 
(first use in this function)
   466 | node->base.placement |= TTM_PL_FLAG_CONTIGUOUS;
   | ^~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:365:33: error: unused variable 
‘block’ [-Werror=unused-variable]
   365 | struct drm_buddy_block *block;
   | ^
cc1: all warnings being treated as errors

Regards,
Mauro




Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Mauro Carvalho Chehab
On Thu, 14 Jul 2022 15:08:48 +0200
Christian König  wrote:

> Hi Mauro,
> 
> well the last time I checked drm-tip was clean.
> 
> The revert is necessary because we had some problems with the commit 
> which we couldn't fix in the 5.19 cycle.

I see. I don't have any issues with the patch itself, provided that drm-tip
build doesn't break ;-)

> I will double check drm-tip once more.

Did a new rebase on the top of:
bc04f10d22f7 (drm-tip/drm-tip) drm-tip: 2022y-07m-14d-12h-41m-36s UTC 
integration manifest

And it is still broken on amdgpu_vram_mgr.c, but now with different issues:

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function ‘amdgpu_vram_mgr_new’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:13: error: ‘i’ undeclared 
(first use in this function)
  465 | if (i == 1)
  | ^
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:13: note: each undeclared 
identifier is reported only once for each function it appears in
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:466:17: error: ‘node’ undeclared 
(first use in this function)
  466 | node->base.placement |= TTM_PL_FLAG_CONTIGUOUS;
  | ^~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:365:33: error: unused variable 
‘block’ [-Werror=unused-variable]
  365 | struct drm_buddy_block *block;
  | ^
cc1: all warnings being treated as errors

Regards,
Mauro


Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Christian König

Hi Mauro,

well the last time I checked drm-tip was clean.

The revert is necessary because we had some problems with the commit 
which we couldn't fix in the 5.19 cycle.


I will double check drm-tip once more.

Regards,
Christian.

Am 14.07.22 um 14:54 schrieb Mauro Carvalho Chehab:

On Fri, 8 Jul 2022 03:21:24 -0700
Arunpravin Paneer Selvam  wrote:


This reverts the following commits:
commit 708d19d9f362 ("drm/amdgpu: move internal vram_mgr function into the C 
file")
commit 5e3f1e7729ec ("drm/amdgpu: fix start calculation in amdgpu_vram_mgr_new")
commit c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu")

[WHY]
Few users reported garbaged graphics as soon as x starts,
reverting until this can be resolved.

Signed-off-by: Arunpravin Paneer Selvam 

This revert is currently breaking drm-tip. Please revert it ASAP, as it
is preventing CI bots to properly test new patches on the top of current
drm-tip:

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function ‘amdgpu_vram_mgr_new’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: error: ‘cur_size’ 
undeclared (first use in this function)
   459 | if (cur_size != size) {
   | ^~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: note: each undeclared 
identifier is reported only once for each function it appears in
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:25: error: ‘size’ undeclared 
(first use in this function); did you mean ‘ksize’?
   459 | if (cur_size != size) {
   | ^~~~
   | ksize
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:30: error: ‘vres’ undeclared 
(first use in this function); did you mean ‘res’?
   465 | trim_list = >blocks;
   |  ^~~~
   |  res
In file included from ./include/linux/bits.h:22,
  from ./include/linux/ratelimit_types.h:5,
  from ./include/linux/ratelimit.h:5,
  from ./include/linux/dev_printk.h:16,
  from ./include/linux/device.h:15,
  from ./include/linux/dma-mapping.h:7,
  from drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:25:
./include/linux/container_of.h:19:54: error: invalid use of undefined type 
‘struct drm_buddy_block’
19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
 \
   |  ^~
./include/linux/build_bug.h:78:56: note: in definition of macro 
‘__static_assert’
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
   |^~~~
./include/linux/container_of.h:19:9: note: in expansion of macro ‘static_assert’
19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
 \
   | ^
./include/linux/container_of.h:19:23: note: in expansion of macro ‘__same_type’
19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
 \
   |   ^~~
./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
   520 | container_of(ptr, type, member)
   | ^~~~
./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
   542 | list_entry((ptr)->prev, type, member)
   | ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion of 
macro ‘list_last_entry’
   473 | block = list_last_entry(>blocks, 
typeof(*block), link);
   | ^~~
././include/linux/compiler_types.h:295:27: error: expression in static 
assertion is not an integer
   295 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
typeof(b))
   |   ^~~~
./include/linux/build_bug.h:78:56: note: in definition of macro 
‘__static_assert’
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
   |^~~~
./include/linux/container_of.h:19:9: note: in expansion of macro ‘static_assert’
19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
 \
   | ^
./include/linux/container_of.h:19:23: note: in expansion of macro ‘__same_type’
19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||  
 \
   |   ^~~
./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
   520 | container_of(ptr, type, member)
   | ^~~~
./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
   542 | list_entry((ptr)->prev, type, member)
   | ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion of 
macro ‘list_last_entry’
   473 | 

[PATCH 2/2] drm/virtio: kms: use drm managed resources

2022-07-14 Thread Danilo Krummrich
Allocate driver structures with drm managed resource allocators in order
to cleanup/simplify the drm driver .release callback.

Signed-off-by: Danilo Krummrich 
---
 drivers/gpu/drm/virtio/virtgpu_kms.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c 
b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 3313b92db531..63ebe63ef409 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -28,6 +28,7 @@
 #include 
 
 #include 
+#include 
 
 #include "virtgpu_drv.h"
 
@@ -66,10 +67,11 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device 
*vgdev,
 {
int i, ret;
bool invalid_capset_id = false;
+   struct drm_device *drm = vgdev->ddev;
 
-   vgdev->capsets = kcalloc(num_capsets,
-sizeof(struct virtio_gpu_drv_capset),
-GFP_KERNEL);
+   vgdev->capsets = drmm_kcalloc(drm, num_capsets,
+ sizeof(struct virtio_gpu_drv_capset),
+ GFP_KERNEL);
if (!vgdev->capsets) {
DRM_ERROR("failed to allocate cap sets\n");
return;
@@ -94,7 +96,7 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device 
*vgdev,
 
if (ret == 0 || invalid_capset_id) {
spin_lock(>display_info_lock);
-   kfree(vgdev->capsets);
+   drmm_kfree(drm, vgdev->capsets);
vgdev->capsets = NULL;
spin_unlock(>display_info_lock);
return;
@@ -126,7 +128,7 @@ int virtio_gpu_init(struct drm_device *dev)
if (!virtio_has_feature(dev_to_virtio(dev->dev), VIRTIO_F_VERSION_1))
return -ENODEV;
 
-   vgdev = kzalloc(sizeof(struct virtio_gpu_device), GFP_KERNEL);
+   vgdev = drmm_kzalloc(dev, sizeof(struct virtio_gpu_device), GFP_KERNEL);
if (!vgdev)
return -ENOMEM;
 
@@ -257,7 +259,6 @@ int virtio_gpu_init(struct drm_device *dev)
vgdev->vdev->config->del_vqs(vgdev->vdev);
 err_vqs:
dev->dev_private = NULL;
-   kfree(vgdev);
return ret;
 }
 
@@ -296,9 +297,6 @@ void virtio_gpu_release(struct drm_device *dev)
 
if (vgdev->has_host_visible)
drm_mm_takedown(>host_visible_mm);
-
-   kfree(vgdev->capsets);
-   kfree(vgdev);
 }
 
 int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
-- 
2.36.1



[PATCH 1/2] drm/virtio: plane: use drm managed resources

2022-07-14 Thread Danilo Krummrich
Use drm managed resource allocation (drmm_universal_plane_alloc()) in
order to cleanup/simplify drm plane .destroy callback.

Signed-off-by: Danilo Krummrich 
---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 30 +++---
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 6d3cc9e238a4..3008551d6a05 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -67,16 +67,10 @@ uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
return format;
 }
 
-static void virtio_gpu_plane_destroy(struct drm_plane *plane)
-{
-   drm_plane_cleanup(plane);
-   kfree(plane);
-}
-
 static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
.update_plane   = drm_atomic_helper_update_plane,
.disable_plane  = drm_atomic_helper_disable_plane,
-   .destroy= virtio_gpu_plane_destroy,
+   .destroy= drm_plane_cleanup,
.reset  = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state   = drm_atomic_helper_plane_destroy_state,
@@ -379,11 +373,7 @@ struct drm_plane *virtio_gpu_plane_init(struct 
virtio_gpu_device *vgdev,
const struct drm_plane_helper_funcs *funcs;
struct drm_plane *plane;
const uint32_t *formats;
-   int ret, nformats;
-
-   plane = kzalloc(sizeof(*plane), GFP_KERNEL);
-   if (!plane)
-   return ERR_PTR(-ENOMEM);
+   int nformats;
 
if (type == DRM_PLANE_TYPE_CURSOR) {
formats = virtio_gpu_cursor_formats;
@@ -394,17 +384,13 @@ struct drm_plane *virtio_gpu_plane_init(struct 
virtio_gpu_device *vgdev,
nformats = ARRAY_SIZE(virtio_gpu_formats);
funcs = _gpu_primary_helper_funcs;
}
-   ret = drm_universal_plane_init(dev, plane, 1 << index,
-  _gpu_plane_funcs,
-  formats, nformats,
-  NULL, type, NULL);
-   if (ret)
-   goto err_plane_init;
+
+   plane = drmm_universal_plane_alloc(dev, struct drm_plane, dev,
+  1 << index, _gpu_plane_funcs,
+  formats, nformats, NULL, type, NULL);
+   if (IS_ERR(plane))
+   return plane;
 
drm_plane_helper_add(plane, funcs);
return plane;
-
-err_plane_init:
-   kfree(plane);
-   return ERR_PTR(ret);
 }
-- 
2.36.1



[PATCH 0/2] drm/virtio: use drm managed resources

2022-07-14 Thread Danilo Krummrich
This patch series converts plain memory allocations for driver structures and
planes to drm managed allocations in order to cleanup/simply the corresponding
release/destroy callbacks.

Danilo Krummrich (2):
  drm/virtio: plane: use drm managed resources
  drm/virtio: kms: use drm managed resources

 drivers/gpu/drm/virtio/virtgpu_kms.c   | 16 ++
 drivers/gpu/drm/virtio/virtgpu_plane.c | 30 +++---
 2 files changed, 15 insertions(+), 31 deletions(-)

-- 
2.36.1



[PATCH] drm: flip-work: rename commited -> committed

2022-07-14 Thread Colin Ian King
There is a spelling mistake in the list head variable, rename it.

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/drm_flip_work.c | 10 +-
 include/drm/drm_flip_work.h |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_flip_work.c b/drivers/gpu/drm/drm_flip_work.c
index 060b753881a2..8efb5f2c5773 100644
--- a/drivers/gpu/drm/drm_flip_work.c
+++ b/drivers/gpu/drm/drm_flip_work.c
@@ -104,7 +104,7 @@ void drm_flip_work_commit(struct drm_flip_work *work,
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
-   list_splice_tail(>queued, >commited);
+   list_splice_tail(>queued, >committed);
INIT_LIST_HEAD(>queued);
spin_unlock_irqrestore(>lock, flags);
queue_work(wq, >worker);
@@ -122,8 +122,8 @@ static void flip_worker(struct work_struct *w)
 
INIT_LIST_HEAD();
spin_lock_irqsave(>lock, flags);
-   list_splice_tail(>commited, );
-   INIT_LIST_HEAD(>commited);
+   list_splice_tail(>committed, );
+   INIT_LIST_HEAD(>committed);
spin_unlock_irqrestore(>lock, flags);
 
if (list_empty())
@@ -149,7 +149,7 @@ void drm_flip_work_init(struct drm_flip_work *work,
 {
work->name = name;
INIT_LIST_HEAD(>queued);
-   INIT_LIST_HEAD(>commited);
+   INIT_LIST_HEAD(>committed);
spin_lock_init(>lock);
work->func = func;
 
@@ -165,6 +165,6 @@ EXPORT_SYMBOL(drm_flip_work_init);
  */
 void drm_flip_work_cleanup(struct drm_flip_work *work)
 {
-   WARN_ON(!list_empty(>queued) || !list_empty(>commited));
+   WARN_ON(!list_empty(>queued) || !list_empty(>committed));
 }
 EXPORT_SYMBOL(drm_flip_work_cleanup);
diff --git a/include/drm/drm_flip_work.h b/include/drm/drm_flip_work.h
index 21c3d512d25c..2e1342cdc568 100644
--- a/include/drm/drm_flip_work.h
+++ b/include/drm/drm_flip_work.h
@@ -67,15 +67,15 @@ struct drm_flip_task {
  * @func: callback fxn called for each committed item
  * @worker: worker which calls @func
  * @queued: queued tasks
- * @commited: commited tasks
- * @lock: lock to access queued and commited lists
+ * @committed: committed tasks
+ * @lock: lock to access queued and committed lists
  */
 struct drm_flip_work {
const char *name;
drm_flip_func_t func;
struct work_struct worker;
struct list_head queued;
-   struct list_head commited;
+   struct list_head committed;
spinlock_t lock;
 };
 
-- 
2.35.3



Re: [PATCH] Revert "drm/amdgpu: add drm buddy support to amdgpu"

2022-07-14 Thread Mauro Carvalho Chehab
On Fri, 8 Jul 2022 03:21:24 -0700
Arunpravin Paneer Selvam  wrote:

> This reverts the following commits:
> commit 708d19d9f362 ("drm/amdgpu: move internal vram_mgr function into the C 
> file")
> commit 5e3f1e7729ec ("drm/amdgpu: fix start calculation in 
> amdgpu_vram_mgr_new")
> commit c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu")
> 
> [WHY]
> Few users reported garbaged graphics as soon as x starts,
> reverting until this can be resolved.
> 
> Signed-off-by: Arunpravin Paneer Selvam 

This revert is currently breaking drm-tip. Please revert it ASAP, as it
is preventing CI bots to properly test new patches on the top of current
drm-tip:

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c: In function ‘amdgpu_vram_mgr_new’:
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: error: ‘cur_size’ 
undeclared (first use in this function)
  459 | if (cur_size != size) {
  | ^~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:13: note: each undeclared 
identifier is reported only once for each function it appears in
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:459:25: error: ‘size’ undeclared 
(first use in this function); did you mean ‘ksize’?
  459 | if (cur_size != size) {
  | ^~~~
  | ksize
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:465:30: error: ‘vres’ undeclared 
(first use in this function); did you mean ‘res’?
  465 | trim_list = >blocks;
  |  ^~~~
  |  res
In file included from ./include/linux/bits.h:22,
 from ./include/linux/ratelimit_types.h:5,
 from ./include/linux/ratelimit.h:5,
 from ./include/linux/dev_printk.h:16,
 from ./include/linux/device.h:15,
 from ./include/linux/dma-mapping.h:7,
 from drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:25:
./include/linux/container_of.h:19:54: error: invalid use of undefined type 
‘struct drm_buddy_block’
   19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||   
\
  |  ^~
./include/linux/build_bug.h:78:56: note: in definition of macro 
‘__static_assert’
   78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
  |^~~~
./include/linux/container_of.h:19:9: note: in expansion of macro ‘static_assert’
   19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||   
\
  | ^
./include/linux/container_of.h:19:23: note: in expansion of macro ‘__same_type’
   19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||   
\
  |   ^~~
./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
  520 | container_of(ptr, type, member)
  | ^~~~
./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
  542 | list_entry((ptr)->prev, type, member)
  | ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion of 
macro ‘list_last_entry’
  473 | block = list_last_entry(>blocks, 
typeof(*block), link);
  | ^~~
././include/linux/compiler_types.h:295:27: error: expression in static 
assertion is not an integer
  295 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), 
typeof(b))
  |   ^~~~
./include/linux/build_bug.h:78:56: note: in definition of macro 
‘__static_assert’
   78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
  |^~~~
./include/linux/container_of.h:19:9: note: in expansion of macro ‘static_assert’
   19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||   
\
  | ^
./include/linux/container_of.h:19:23: note: in expansion of macro ‘__same_type’
   19 | static_assert(__same_type(*(ptr), ((type *)0)->member) ||   
\
  |   ^~~
./include/linux/list.h:520:9: note: in expansion of macro ‘container_of’
  520 | container_of(ptr, type, member)
  | ^~~~
./include/linux/list.h:542:9: note: in expansion of macro ‘list_entry’
  542 | list_entry((ptr)->prev, type, member)
  | ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:473:33: note: in expansion of 
macro ‘list_last_entry’
  473 | block = list_last_entry(>blocks, 
typeof(*block), link);
  | ^~~
In file included from ./include/uapi/linux/posix_types.h:5,
 from ./include/uapi/linux/types.h:14,
 from ./include/linux/types.h:6,
 from 

Re: [linux-next:master] BUILD REGRESSION 4662b7adea50bb62e993a67f611f3be625d3df0d

2022-07-14 Thread Russell King (Oracle)
Hi,

I don't mean to discourge test systems, but looking at this, I just go
"meh" and delete it - it doesn't seem to contain obviously useful
information. One has to read every damn line to see if there's something
of relevence, which I for one am not going to do.

Is there some kind of improvement that could be done to this to make it
more useful - such as only sending the warnings/errors to the
appropriate mailing lists for those - rather than grouping everything
together into one email. At least that should make the stuff (a) more
relevant and (b) easier to parse.

Russell.

On Thu, Jul 14, 2022 at 09:56:19AM +0800, kernel test robot wrote:
> tree/branch: 
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> branch HEAD: 4662b7adea50bb62e993a67f611f3be625d3df0d  Add linux-next 
> specific files for 20220713
> 
> Error/Warning reports:
> 
> https://lore.kernel.org/linux-doc/202207021352.ppktuy8v-...@intel.com
> https://lore.kernel.org/linux-doc/202207031437.qih6lfcx-...@intel.com
> https://lore.kernel.org/linux-doc/202207051821.3f0erisl-...@intel.com
> https://lore.kernel.org/linux-doc/202207140742.gtpk4u8i-...@intel.com
> https://lore.kernel.org/linux-mm/202206292052.lsfui3zo-...@intel.com
> https://lore.kernel.org/linux-mm/202207140042.ck3tlk6j-...@intel.com
> https://lore.kernel.org/llvm/202207090100.acxdj79h-...@intel.com
> 
> Error/Warning: (recently discovered and may have been fixed)
> 
> Documentation/PCI/endpoint/pci-vntb-function.rst:82: WARNING: Unexpected 
> indentation.
> Documentation/PCI/endpoint/pci-vntb-howto.rst:131: WARNING: Title underline 
> too short.
> Documentation/filesystems/netfs_library.rst:384: WARNING: Inline emphasis 
> start-string without end-string.
> Documentation/filesystems/netfs_library:609: fs/netfs/buffered_read.c:318: 
> WARNING: Inline emphasis start-string without end-string.
> Documentation/virt/kvm/api.rst:8256: WARNING: Title underline too short.
> Documentation/virt/kvm/api.rst:8263: WARNING: Unexpected indentation.
> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:2837:6: warning: no 
> previous prototype for function 'dc_reset_state' [-Wmissing-prototypes]
> drivers/mmc/host/sdhci-of-aspeed-test.c:10: undefined reference to 
> `kunit_binary_assert_format'
> drivers/pci/endpoint/functions/pci-epf-vntb.c:975:5: warning: no previous 
> prototype for 'pci_read' [-Wmissing-prototypes]
> drivers/pci/endpoint/functions/pci-epf-vntb.c:984:5: warning: no previous 
> prototype for 'pci_write' [-Wmissing-prototypes]
> drivers/vfio/vfio_iommu_type1.c:2141:35: warning: cast to smaller integer 
> type 'enum iommu_cap' from 'void *' [-Wvoid-pointer-to-enum-cast]
> fs/ntfs/attrib.c:705:18: warning: Either the condition '!al' is redundant or 
> there is pointer arithmetic with NULL pointer. 
> [nullPointerArithmeticRedundantCheck]
> fs/ntfs/layout.h:126:43: warning: Parameter 'p' can be declared with const 
> [constParameter]
> fs/ntfs/ntfs.h:144:3: warning: Assignment of function parameter has no effect 
> outside the function. [uselessAssignmentArg]
> fs/super.c:1310:57: warning: Parameter 'data' can be declared with const 
> [constParameter]
> fs/super.c:750:52: warning: Parameter 'bdev' can be declared with const 
> [constParameter]
> ipc/shm.c:158:0: warning: failed to expand 'ipc_init_proc_interface', it is 
> invalid to use a preprocessor directive as macro parameter 
> [preprocessorErrorDirective]
> kernel/bpf/task_iter.c:152:11: warning: Redundant initialization for 
> 'curr_fd'. The initialized value is overwritten before it is read. 
> [redundantInitialization]
> kernel/bpf/task_iter.c:498:59: warning: Parameter 'v' can be declared with 
> const [constParameter]
> kernel/fork.c:3256:42: warning: Parameter 'table' can be declared with const 
> [constParameter]
> kernel/fork.c:942:33: warning: Parameter 'src' can be declared with const 
> [constParameter]
> kernel/sched/fair.c:5081:25: warning: Uninitialized variables: cfs_rq.load, 
> cfs_rq.nr_running, cfs_rq.h_nr_running, cfs_rq.idle_nr_running, 
> cfs_rq.idle_h_nr_running, cfs_rq.exec_clock, cfs_rq.min_vruntime, 
> cfs_rq.min_vruntime_copy, cfs_rq.tasks_timeline, cfs_rq.curr, cfs_rq.next, 
> cfs_rq.last, cfs_rq.skip [uninitvar]
> kernel/sched/fair.c:6967:7: warning: Local variable 'min_vruntime' shadows 
> outer function [shadowFunction]
> lib/maple_tree.c:1522:52: warning: Parameter 'gaps' can be declared with 
> const [constParameter]
> lib/maple_tree.c:1871:21: warning: Array index 'split' is used before limits 
> check. [arrayIndexThenCheck]
> lib/maple_tree.c:2033:55: warning: Parameter 'mas' can be declared with const 
> [constParameter]
> lib/maple_tree.c:2426:8: warning: Redundant initialization for 'r_tmp'. The 
> initialized value is overwritten before it is read. [redundantInitialization]
> lib/maple_tree.c:2427:8: warning: Redundant initialization for 'l_tmp'. The 
> initialized value is overwritten before it is read. [redundantInitialization]
> 

Re: [PATCH 3/3] drm/komeda - Fix handling of pending crtc state commit to avoid lock-up

2022-07-14 Thread Robin Murphy

On 2022-07-11 11:13, Liviu Dudau wrote:
[...]

But nothing worrying. It does work, though doesn't compile due to:

drivers/gpu/drm/arm/display/komeda/komeda_kms.c: In function
‘komeda_kms_atomic_commit_hw_done’:
drivers/gpu/drm/arm/display/komeda/komeda_kms.c:77:9: error: ‘for’ loop
initial declarations are only allowed in C99 or C11 mode
77 | for (int i = 0; i < kms->n_crtcs; i++) {
   | ^~~
drivers/gpu/drm/arm/display/komeda/komeda_kms.c:77:9: note: use option
‘-std=c9
’, ‘-std=gnu99’, ‘-std=c11’ or ‘-std=gnu11’ to compile your code

but that was a trivial fixup.


Interesting that I'm not seeing that, probably due to using GCC12? Anyway, I'll 
fix
that and send a proper patch.


FWIW we do use -std=gnu11 since 5.18 (see e8c07082a810), but I'm not 
entirely sure what the status quo is for using the new features in fixes 
which might also warrant backporting to stable. I believe Carsten's 
stuck on an older kernel thanks to constraints of the rest of that 
project ;)


Cheers,
Robin.


Re: [PATCH v2 4/5] drm/modes: Add support for driver-specific named modes

2022-07-14 Thread Maxime Ripard
On Thu, Jul 14, 2022 at 11:04:09AM +0200, Geert Uytterhoeven wrote:
> The mode parsing code recognizes named modes only if they are explicitly
> listed in the internal whitelist, which is currently limited to "NTSC"
> and "PAL".
> 
> Provide a mechanism for drivers to override this list to support custom
> mode names.
> 
> Ideally, this list should just come from the driver's actual list of
> modes, but connector->probed_modes is not yet populated at the time of
> parsing.
> 
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Hans de Goede 

Like we discussed on IRC, I'm not sure allowing drivers to handle named
modes is the right thing to do.

Named modes in general were a workaround the fact that we were missing
infos in drm_display_mode to describe all the modes.

I think we really should focus on addressing that first, and then
creating some kind of backward compat layer to create an initial DRM
state from a named mode provided on the command line.

Maxime


signature.asc
Description: PGP signature


[PATCH v2 08/21] drm/i915/gt: Move TLB invalidation to its own file

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Prepare for supporting more TLB invalidation scenarios by moving
the current MMIO invalidation to its own file.

Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/Makefile |   1 +
 drivers/gpu/drm/i915/gem/i915_gem_pages.c |   4 +-
 drivers/gpu/drm/i915/gt/intel_gt.c| 168 +---
 drivers/gpu/drm/i915/gt/intel_gt.h|  12 --
 drivers/gpu/drm/i915/gt/intel_tlb.c   | 183 ++
 drivers/gpu/drm/i915/gt/intel_tlb.h   |  29 
 drivers/gpu/drm/i915/i915_vma.c   |   1 +
 7 files changed, 219 insertions(+), 179 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gt/intel_tlb.c
 create mode 100644 drivers/gpu/drm/i915/gt/intel_tlb.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 522ef9b4aff3..d3df9832d1f7 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -126,6 +126,7 @@ gt-y += \
gt/intel_sseu.o \
gt/intel_sseu_debugfs.o \
gt/intel_timeline.o \
+   gt/intel_tlb.o \
gt/intel_workarounds.o \
gt/shmem_utils.o \
gt/sysfs_engines.o
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c 
b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 8357dbdcab5c..1cd76cc5d9f3 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -7,7 +7,7 @@
 #include 
 
 #include "gt/intel_gt.h"
-#include "gt/intel_gt_pm.h"
+#include "gt/intel_tlb.h"
 
 #include "i915_drv.h"
 #include "i915_gem_object.h"
@@ -199,7 +199,7 @@ static void flush_tlb_invalidate(struct drm_i915_gem_object 
*obj)
if (!obj->mm.tlb)
return;
 
-   intel_gt_invalidate_tlb(gt, obj->mm.tlb);
+   intel_gt_invalidate_tlb_full(gt, obj->mm.tlb);
obj->mm.tlb = 0;
 }
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index f435e06125aa..18d82cd620bd 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -11,9 +11,7 @@
 #include "pxp/intel_pxp.h"
 
 #include "i915_drv.h"
-#include "i915_perf_oa_regs.h"
 #include "intel_context.h"
-#include "intel_engine_pm.h"
 #include "intel_engine_regs.h"
 #include "intel_ggtt_gmch.h"
 #include "intel_gt.h"
@@ -31,6 +29,7 @@
 #include "intel_renderstate.h"
 #include "intel_rps.h"
 #include "intel_gt_sysfs.h"
+#include "intel_tlb.h"
 #include "intel_uncore.h"
 #include "shmem_utils.h"
 
@@ -48,8 +47,7 @@ static void __intel_gt_init_early(struct intel_gt *gt)
intel_gt_init_reset(gt);
intel_gt_init_requests(gt);
intel_gt_init_timelines(gt);
-   mutex_init(>tlb.invalidate_lock);
-   seqcount_mutex_init(>tlb.seqno, >tlb.invalidate_lock);
+   intel_gt_init_tlb(gt);
intel_gt_pm_init_early(gt);
 
intel_uc_init_early(>uc);
@@ -770,7 +768,7 @@ void intel_gt_driver_late_release_all(struct 
drm_i915_private *i915)
intel_gt_fini_requests(gt);
intel_gt_fini_reset(gt);
intel_gt_fini_timelines(gt);
-   mutex_destroy(>tlb.invalidate_lock);
+   intel_gt_fini_tlb(gt);
intel_engines_free(gt);
}
 }
@@ -881,163 +879,3 @@ void intel_gt_info_print(const struct intel_gt_info *info,
 
intel_sseu_dump(>sseu, p);
 }
-
-struct reg_and_bit {
-   i915_reg_t reg;
-   u32 bit;
-};
-
-static struct reg_and_bit
-get_reg_and_bit(const struct intel_engine_cs *engine, const bool gen8,
-   const i915_reg_t *regs, const unsigned int num)
-{
-   const unsigned int class = engine->class;
-   struct reg_and_bit rb = { };
-
-   if (drm_WARN_ON_ONCE(>i915->drm,
-class >= num || !regs[class].reg))
-   return rb;
-
-   rb.reg = regs[class];
-   if (gen8 && class == VIDEO_DECODE_CLASS)
-   rb.reg.reg += 4 * engine->instance; /* GEN8_M2TCR */
-   else
-   rb.bit = engine->instance;
-
-   rb.bit = BIT(rb.bit);
-
-   return rb;
-}
-
-static void mmio_invalidate_full(struct intel_gt *gt)
-{
-   static const i915_reg_t gen8_regs[] = {
-   [RENDER_CLASS]  = GEN8_RTCR,
-   [VIDEO_DECODE_CLASS]= GEN8_M1TCR, /* , GEN8_M2TCR */
-   [VIDEO_ENHANCEMENT_CLASS]   = GEN8_VTCR,
-   [COPY_ENGINE_CLASS] = GEN8_BTCR,
-   };
-   static const i915_reg_t gen12_regs[] = {
-   [RENDER_CLASS]  = GEN12_GFX_TLB_INV_CR,
-   [VIDEO_DECODE_CLASS]= GEN12_VD_TLB_INV_CR,
-   [VIDEO_ENHANCEMENT_CLASS]   = GEN12_VE_TLB_INV_CR,
-   [COPY_ENGINE_CLASS] = 

[PATCH v2 19/21] drm/i915/gt: document TLB cache invalidation functions

2022-07-14 Thread Mauro Carvalho Chehab
Add a description for the kAPI functions inside intel_tlb.c.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_tlb.c | 36 +
 1 file changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_tlb.c 
b/drivers/gpu/drm/i915/gt/intel_tlb.c
index 15ed83226676..aa2e0086ae88 100644
--- a/drivers/gpu/drm/i915/gt/intel_tlb.c
+++ b/drivers/gpu/drm/i915/gt/intel_tlb.c
@@ -146,6 +146,18 @@ static void mmio_invalidate_full(struct intel_gt *gt)
intel_uncore_forcewake_put_delayed(uncore, FORCEWAKE_ALL);
 }
 
+/**
+ * intel_gt_invalidate_tlb_full - do full TLB cache invalidation
+ * @gt: GT structure
+ * @seqno: sequence number
+ *
+ * Do a full TLB cache invalidation if the @seqno is bigger than the last
+ * full TLB cache invalidation.
+ *
+ * Note:
+ * The TLB cache invalidation logic depends on GEN-specific registers.
+ * It currently supports GEN8 to GEN12 and GuC-based TLB cache invalidation.
+ */
 void intel_gt_invalidate_tlb_full(struct intel_gt *gt, u32 seqno)
 {
intel_wakeref_t wakeref;
@@ -220,6 +232,17 @@ static bool mmio_invalidate_range(struct intel_gt *gt, u64 
start, u64 length)
return err == 0;
 }
 
+/**
+ * intel_gt_invalidate_tlb_range - do full TLB cache invalidation
+ * @gt: GT structure
+ * @start: range start
+ * @length: range length
+ *
+ * Do a selected TLB cache invalidation on a range pointed by @start
+ * with @length size.
+ *
+ * Only some GuC-based GPUs can do a selective cache invalidation.
+ */
 bool intel_gt_invalidate_tlb_range(struct intel_gt *gt,
   u64 start, u64 length)
 {
@@ -247,12 +270,25 @@ bool intel_gt_invalidate_tlb_range(struct intel_gt *gt,
return true;
 }
 
+/**
+ * intel_gt_init_tlb - initialize TLB-specific vars
+ * @gt: GT structure
+ *
+ * TLB cache invalidation logic internally uses some resources that require
+ * initialization. Should be called before doing any TLB cache invalidation.
+ */
 void intel_gt_init_tlb(struct intel_gt *gt)
 {
mutex_init(>tlb.invalidate_lock);
seqcount_mutex_init(>tlb.seqno, >tlb.invalidate_lock);
 }
 
+/**
+ * intel_gt_fini_tlb - initialize TLB-specific vars
+ * @gt: GT structure
+ *
+ * Frees any resources needed by TLB cache invalidation logic.
+ */
 void intel_gt_fini_tlb(struct intel_gt *gt)
 {
mutex_destroy(>tlb.invalidate_lock);
-- 
2.36.1



[PATCH v2 01/21] drm/i915/gt: Ignore TLB invalidations on idle engines

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Check if the device is powered down prior to any engine activity,
as, on such cases, all the TLBs were already invalidated, so an
explicit TLB invalidation is not needed, thus reducing the
performance regression impact due to it.

This becomes more significant with GuC, as it can only do so when
the connection to the GuC is awake.

Cc: sta...@vger.kernel.org
Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Cc: Andi Shyti 
Cc: Thomas Hellström 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 10 ++
 drivers/gpu/drm/i915/gt/intel_gt.c| 17 ++---
 drivers/gpu/drm/i915/gt/intel_gt_pm.h |  3 +++
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c 
b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 97c820eee115..6835279943df 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -6,14 +6,15 @@
 
 #include 
 
+#include "gt/intel_gt.h"
+#include "gt/intel_gt_pm.h"
+
 #include "i915_drv.h"
 #include "i915_gem_object.h"
 #include "i915_scatterlist.h"
 #include "i915_gem_lmem.h"
 #include "i915_gem_mman.h"
 
-#include "gt/intel_gt.h"
-
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
 struct sg_table *pages,
 unsigned int sg_page_sizes)
@@ -217,10 +218,11 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object 
*obj)
 
if (test_and_clear_bit(I915_BO_WAS_BOUND_BIT, >flags)) {
struct drm_i915_private *i915 = to_i915(obj->base.dev);
+   struct intel_gt *gt = to_gt(i915);
intel_wakeref_t wakeref;
 
-   with_intel_runtime_pm_if_active(>runtime_pm, wakeref)
-   intel_gt_invalidate_tlbs(to_gt(i915));
+   with_intel_gt_pm_if_awake(gt, wakeref)
+   intel_gt_invalidate_tlbs(gt);
}
 
return pages;
diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 68c2b0d8f187..c4d43da84d8e 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -12,6 +12,7 @@
 
 #include "i915_drv.h"
 #include "intel_context.h"
+#include "intel_engine_pm.h"
 #include "intel_engine_regs.h"
 #include "intel_ggtt_gmch.h"
 #include "intel_gt.h"
@@ -924,6 +925,7 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
struct drm_i915_private *i915 = gt->i915;
struct intel_uncore *uncore = gt->uncore;
struct intel_engine_cs *engine;
+   intel_engine_mask_t awake, tmp;
enum intel_engine_id id;
const i915_reg_t *regs;
unsigned int num = 0;
@@ -947,26 +949,31 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
 
GEM_TRACE("\n");
 
-   assert_rpm_wakelock_held(>runtime_pm);
-
mutex_lock(>tlb_invalidate_lock);
intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
 
spin_lock_irq(>lock); /* serialise invalidate with GT reset */
 
+   awake = 0;
for_each_engine(engine, gt, id) {
struct reg_and_bit rb;
 
+   if (!intel_engine_pm_is_awake(engine))
+   continue;
+
rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
if (!i915_mmio_reg_offset(rb.reg))
continue;
 
intel_uncore_write_fw(uncore, rb.reg, rb.bit);
+   awake |= engine->mask;
}
 
spin_unlock_irq(>lock);
 
-   for_each_engine(engine, gt, id) {
+   for_each_engine_masked(engine, gt, awake, tmp) {
+   struct reg_and_bit rb;
+
/*
 * HW architecture suggest typical invalidation time at 40us,
 * with pessimistic cases up to 100us and a recommendation to
@@ -974,12 +981,8 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
 */
const unsigned int timeout_us = 100;
const unsigned int timeout_ms = 4;
-   struct reg_and_bit rb;
 
rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
-   if (!i915_mmio_reg_offset(rb.reg))
-   continue;
-
if (__intel_wait_for_register_fw(uncore,
 rb.reg, rb.bit, 0,
 timeout_us, timeout_ms,
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h 
b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
index bc898df7a48c..a334787a4939 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
@@ -55,6 +55,9 @@ 

[PATCH v2 15/21] drm/i915: Add platform macro for selective tlb flush

2022-07-14 Thread Mauro Carvalho Chehab
From: Prathap Kumar Valsan 

Add support for selective TLB invalidation, which is a platform
feature supported on XeHP.

Signed-off-by: Prathap Kumar Valsan 
Cc: Niranjana Vishwanathapura 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/i915_drv.h  | 3 +++
 drivers/gpu/drm/i915/i915_pci.c  | 1 +
 drivers/gpu/drm/i915/intel_device_info.h | 1 +
 3 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f1f70257dbe0..73494960a3a8 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1312,6 +1312,9 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
 
 #define HAS_GT_UC(dev_priv)(INTEL_INFO(dev_priv)->has_gt_uc)
 
+#define HAS_SELECTIVE_TLB_INVALIDATION(dev_priv) \
+   (INTEL_INFO(dev_priv)->has_selective_tlb_invalidation)
+
 #define HAS_POOLED_EU(dev_priv)(INTEL_INFO(dev_priv)->has_pooled_eu)
 
 #define HAS_GLOBAL_MOCS_REGISTERS(dev_priv)
(INTEL_INFO(dev_priv)->has_global_mocs)
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index aacc10f2e73f..30d945fe384b 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -1022,6 +1022,7 @@ static const struct intel_device_info adl_p_info = {
.has_reset_engine = 1, \
.has_rps = 1, \
.has_runtime_pm = 1, \
+   .has_selective_tlb_invalidation = 1, \
.ppgtt_size = 48, \
.ppgtt_type = INTEL_PPGTT_FULL
 
diff --git a/drivers/gpu/drm/i915/intel_device_info.h 
b/drivers/gpu/drm/i915/intel_device_info.h
index 23bf230aa104..92a38b8f7c47 100644
--- a/drivers/gpu/drm/i915/intel_device_info.h
+++ b/drivers/gpu/drm/i915/intel_device_info.h
@@ -170,6 +170,7 @@ enum intel_ppgtt_type {
func(has_rc6p); \
func(has_rps); \
func(has_runtime_pm); \
+   func(has_selective_tlb_invalidation); \
func(has_snoop); \
func(has_coherent_ggtt); \
func(unfenced_needs_alignment); \
-- 
2.36.1



[PATCH v2 14/21] drm/i915: document tlb field at struct drm_i915_gem_object

2022-07-14 Thread Mauro Carvalho Chehab
Add documentation to the TLB field inside
struct drm_i915_gem_object.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gem/i915_gem_object_types.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 3c1d0b750a67..6f5b9e34a4d7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -618,6 +618,7 @@ struct drm_i915_gem_object {
 */
bool dirty:1;
 
+   /** @mm.tlb: array with TLB invalidate IDs */
u32 tlb[I915_MAX_GT];
} mm;
 
-- 
2.36.1



[PATCH v2 02/21] drm/i915/gt: document with_intel_gt_pm_if_awake()

2022-07-14 Thread Mauro Carvalho Chehab
Add a kernel-doc markup to document this new macro.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_gt_pm.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h 
b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
index a334787a4939..4d4caf612fdc 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
@@ -55,6 +55,13 @@ static inline void intel_gt_pm_might_put(struct intel_gt *gt)
for (tmp = 1, intel_gt_pm_get(gt); tmp; \
 intel_gt_pm_put(gt), tmp = 0)
 
+/**
+ * with_intel_gt_pm_if_awake - if GT is PM awake, get a reference to prevent
+ * it to sleep, run some code and then put the reference away.
+ *
+ * @gt: pointer to the gt
+ * @wf: pointer to a temporary wakeref.
+ */
 #define with_intel_gt_pm_if_awake(gt, wf) \
for (wf = intel_gt_pm_get_if_awake(gt); wf; intel_gt_pm_put_async(gt), 
wf = 0)
 
-- 
2.36.1



[PATCH v2 18/21] drm/i915: Use selective tlb invalidations where supported

2022-07-14 Thread Mauro Carvalho Chehab
From: Prathap Kumar Valsan 

For platforms supporting selective tlb invalidations, we don't need to
do a full tlb invalidation. Rather do a range based tlb invalidation for
every unbind of purged vma belongs to an active vm.

[mchehab: change moved from intel_ppgtt.c to i915_vma.c]
Signed-off-by: Prathap Kumar Valsan 
Cc: Niranjana Vishwanathapura 
Cc: Fei Yang 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_ppgtt.c |  2 +-
 drivers/gpu/drm/i915/i915_vma.c   | 14 +-
 drivers/gpu/drm/i915/i915_vma.h   |  3 ++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c 
b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
index f764d250e929..74782fb2ccbd 100644
--- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
@@ -211,7 +211,7 @@ void ppgtt_unbind_vma(struct i915_address_space *vm,
return;
 
vm->clear_range(vm, vma_res->start, vma_res->vma_size);
-   vma_invalidate_tlb(vm, vma_res->tlb);
+   vma_invalidate_tlb(vm, vma_res->tlb, vma_res->start, vma_res->vma_size);
 }
 
 static unsigned long pd_count(u64 size, int shift)
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 5edc745dcc51..6d881a6b403a 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -1309,7 +1309,8 @@ I915_SELFTEST_EXPORT int i915_vma_get_pages(struct 
i915_vma *vma)
return err;
 }
 
-void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb)
+void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb,
+   u64 start, u64 size)
 {
struct intel_gt *gt;
int id;
@@ -1325,9 +1326,11 @@ void vma_invalidate_tlb(struct i915_address_space *vm, 
u32 *tlb)
 * the most recent TLB invalidation seqno, and if we have not yet
 * flushed the TLBs upon release, perform a full invalidation.
 */
-   for_each_gt(gt, vm->i915, id)
-   WRITE_ONCE(tlb[id],
-  intel_gt_next_invalidate_tlb_full(vm->gt));
+   for_each_gt(gt, vm->i915, id) {
+   if (!intel_gt_invalidate_tlb_range(gt, start, size))
+   WRITE_ONCE(tlb[id],
+  intel_gt_next_invalidate_tlb_full(vm->gt));
+   }
 }
 
 static void __vma_put_pages(struct i915_vma *vma, unsigned int count)
@@ -1980,7 +1983,8 @@ struct dma_fence *__i915_vma_evict(struct i915_vma *vma, 
bool async)
dma_fence_put(unbind_fence);
unbind_fence = NULL;
}
-   vma_invalidate_tlb(vma->vm, vma->obj->mm.tlb);
+   vma_invalidate_tlb(vma->vm, vma->obj->mm.tlb,
+  vma->node.start, vma->size);
}
 
/*
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 33a58f605d75..3f0af9595e59 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -213,7 +213,8 @@ bool i915_vma_misplaced(const struct i915_vma *vma,
u64 size, u64 alignment, u64 flags);
 void __i915_vma_set_map_and_fenceable(struct i915_vma *vma);
 void i915_vma_revoke_mmap(struct i915_vma *vma);
-void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb);
+void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb,
+   u64 start, u64 size);
 struct dma_fence *__i915_vma_evict(struct i915_vma *vma, bool async);
 int __i915_vma_unbind(struct i915_vma *vma);
 int __must_check i915_vma_unbind(struct i915_vma *vma);
-- 
2.36.1



[PATCH v2 09/21] drm/i915/guc: Define CTB based TLB invalidation routines

2022-07-14 Thread Mauro Carvalho Chehab
From: Prathap Kumar Valsan 

Add routines to interface with GuC firmware for TLB invalidation.

Signed-off-by: Prathap Kumar Valsan 
Cc: Bruce Chang 
Cc: Michal Wajdeczko 
Cc: Matthew Brost 
Cc: Chris Wilson 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h  | 35 +++
 drivers/gpu/drm/i915/gt/uc/intel_guc.c| 90 ++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h| 13 +++
 drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 24 -
 drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h   |  6 ++
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 91 ++-
 6 files changed, 253 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
index 4ef9990ed7f8..2e39d8df4c82 100644
--- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
+++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
@@ -134,6 +134,10 @@ enum intel_guc_action {
INTEL_GUC_ACTION_REGISTER_CONTEXT_MULTI_LRC = 0x4601,
INTEL_GUC_ACTION_CLIENT_SOFT_RESET = 0x5507,
INTEL_GUC_ACTION_SET_ENG_UTIL_BUFF = 0x550A,
+   INTEL_GUC_ACTION_NOTIFY_MEMORY_CAT_ERROR = 0x6000,
+   INTEL_GUC_ACTION_PAGE_FAULT_NOTIFICATION = 0x6001,
+   INTEL_GUC_ACTION_TLB_INVALIDATION = 0x7000,
+   INTEL_GUC_ACTION_TLB_INVALIDATION_DONE = 0x7001,
INTEL_GUC_ACTION_STATE_CAPTURE_NOTIFICATION = 0x8002,
INTEL_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE = 0x8003,
INTEL_GUC_ACTION_NOTIFY_CRASH_DUMP_POSTED = 0x8004,
@@ -177,4 +181,35 @@ enum intel_guc_state_capture_event_status {
 
 #define INTEL_GUC_STATE_CAPTURE_EVENT_STATUS_MASK  0x00FF
 
+#define INTEL_GUC_TLB_INVAL_TYPE_SHIFT 0
+#define INTEL_GUC_TLB_INVAL_MODE_SHIFT 8
+/* Flush PPC or SMRO caches along with TLB invalidation request */
+#define INTEL_GUC_TLB_INVAL_FLUSH_CACHE (1 << 31)
+
+enum intel_guc_tlb_invalidation_type {
+   INTEL_GUC_TLB_INVAL_GUC = 0x3,
+};
+
+/*
+ * 0: Heavy mode of Invalidation:
+ * The pipeline of the engine(s) for which the invalidation is targeted to is
+ * blocked, and all the in-flight transactions are guaranteed to be Globally
+ * Observed before completing the TLB invalidation
+ * 1: Lite mode of Invalidation:
+ * TLBs of the targeted engine(s) are immediately invalidated.
+ * In-flight transactions are NOT guaranteed to be Globally Observed before
+ * completing TLB invalidation.
+ * Light Invalidation Mode is to be used only when
+ * it can be guaranteed (by SW) that the address translations remain invariant
+ * for the in-flight transactions across the TLB invalidation. In other words,
+ * this mode can be used when the TLB invalidation is intended to clear out the
+ * stale cached translations that are no longer in use. Light Invalidation Mode
+ * is much faster than the Heavy Invalidation Mode, as it does not wait for the
+ * in-flight transactions to be GOd.
+ */
+enum intel_guc_tlb_inval_mode {
+   INTEL_GUC_TLB_INVAL_MODE_HEAVY = 0x0,
+   INTEL_GUC_TLB_INVAL_MODE_LITE = 0x1,
+};
+
 #endif /* _ABI_GUC_ACTIONS_ABI_H */
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
index 2706a8c65090..5c59f9b144a3 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
@@ -855,6 +855,96 @@ int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, 
u64 value)
return __guc_self_cfg(guc, key, 2, value);
 }
 
+static int guc_send_invalidate_tlb(struct intel_guc *guc, u32 *action, u32 
size)
+{
+   struct intel_guc_tlb_wait _wq, *wq = &_wq;
+   DEFINE_WAIT_FUNC(wait, woken_wake_function);
+   int err = 0;
+   u32 seqno;
+
+   init_waitqueue_head(&_wq.wq);
+
+   if (xa_alloc_cyclic_irq(>tlb_lookup, , wq,
+   xa_limit_32b, >next_seqno,
+   GFP_ATOMIC | __GFP_NOWARN) < 0) {
+   /* Under severe memory pressure? Serialise TLB allocations */
+   xa_lock_irq(>tlb_lookup);
+   wq = xa_load(>tlb_lookup, guc->serial_slot);
+   wait_event_lock_irq(wq->wq,
+   !READ_ONCE(wq->status),
+   guc->tlb_lookup.xa_lock);
+   /*
+* Update wq->status under lock to ensure only one waiter can
+* issue the tlb invalidation command using the serial slot at a
+* time. The condition is set to false before releasing the lock
+* so that other caller continue to wait until woken up again.
+*/
+   wq->status = 1;
+   xa_unlock_irq(>tlb_lookup);
+
+   seqno = guc->serial_slot;
+   }
+
+   action[1] = seqno;
+
+   

[PATCH v2 11/21] drm/i915/guc: document the TLB invalidation struct members

2022-07-14 Thread Mauro Carvalho Chehab
Add documentation for the 3 new members of struct intel_guc
that are used to handle TLB cache invalidation logic.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/uc/intel_guc.h | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h 
b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
index f82a121b0838..73c46d405dc4 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
@@ -76,11 +76,23 @@ struct intel_guc {
 */
atomic_t outstanding_submission_g2h;
 
-   /** @interrupts: pointers to GuC interrupt-managing functions. */
+   /**
+* @tlb_lookup: TLB cache invalidation lookup table.
+*/
struct xarray tlb_lookup;
+
+   /**
+* @serial_slot: index to the latest allocated element at the
+* @tlb_lookup xarray.
+*/
u32 serial_slot;
+
+   /**
+* @next_seqno: next index to be allocated at the @tlb_lookup xarray.
+*/
u32 next_seqno;
 
+   /** @interrupts: pointers to GuC interrupt-managing functions. */
struct {
void (*reset)(struct intel_guc *guc);
void (*enable)(struct intel_guc *guc);
-- 
2.36.1



[PATCH v2 00/21] Fix performance regressions with TLB and add GuC support

2022-07-14 Thread Mauro Carvalho Chehab
TLB invalidation is a slow operation. It should not be doing lightly, as it
causes performance regressions, like this:

[178.821002] i915 :00:02.0: [drm] *ERROR* rcs0 TLB invalidation did not 
complete in 4ms!

This series contain 

1) some patches that makes TLB invalidation to happen only on
active, non-wedged engines, doing cache invalidation in batch 
and only when GT objects are exposed to userspace:

  drm/i915/gt: Ignore TLB invalidations on idle engines
  drm/i915/gt: Only invalidate TLBs exposed to user manipulation
  drm/i915/gt: Skip TLB invalidations once wedged
  drm/i915/gt: Batch TLB invalidations
  drm/i915/gt: Move TLB invalidation to its own file

2) It fixes two bugs, being the first a workaround:

  drm/i915/gt: Invalidate TLB of the OA unit at TLB invalidations
  drm/i915: Invalidate the TLBs on each GT

  drm/i915/guc: Introduce TLB_INVALIDATION_ALL action

3) It adds GuC support. Besides providing TLB invalidation on some
additional hardware, this should also help serializing GuC operations
with TLB invalidation:

  drm/i915/guc: Introduce TLB_INVALIDATION_ALL action
  drm/i915/guc: Define CTB based TLB invalidation routines
  drm/i915: Add platform macro for selective tlb flush
  drm/i915: Define GuC Based TLB invalidation routines
  drm/i915: Add generic interface for tlb invalidation for XeHP
  drm/i915: Use selective tlb invalidations where supported

4) It adds the corresponding kernel-doc markups for the kAPI
used for TLB invalidation.

While I could have split this into smaller pieces, I'm opting to send
them altogether, in order for CI trybot to better verify what issues
will be closed with this series.

---

v2:
  - no changes. Just rebased on the top of drm-tip: 2022y-07m-14d-08h-35m-36s,
   as CI trybot was having troubles applying it. Hopefully, it will now work.

Chris Wilson (7):
  drm/i915/gt: Ignore TLB invalidations on idle engines
  drm/i915/gt: Invalidate TLB of the OA unit at TLB invalidations
  drm/i915/gt: Only invalidate TLBs exposed to user manipulation
  drm/i915/gt: Skip TLB invalidations once wedged
  drm/i915/gt: Batch TLB invalidations
  drm/i915/gt: Move TLB invalidation to its own file
  drm/i915: Invalidate the TLBs on each GT

Mauro Carvalho Chehab (8):
  drm/i915/gt: document with_intel_gt_pm_if_awake()
  drm/i915/gt: describe the new tlb parameter at i915_vma_resource
  drm/i915/guc: use kernel-doc for enum intel_guc_tlb_inval_mode
  drm/i915/guc: document the TLB invalidation struct members
  drm/i915: document tlb field at struct drm_i915_gem_object
  drm/i915/gt: document TLB cache invalidation functions
  drm/i915/guc: describe enum intel_guc_tlb_invalidation_type
  drm/i915/guc: document TLB cache invalidation functions

Piotr Piórkowski (1):
  drm/i915/guc: Introduce TLB_INVALIDATION_ALL action

Prathap Kumar Valsan (5):
  drm/i915/guc: Define CTB based TLB invalidation routines
  drm/i915: Add platform macro for selective tlb flush
  drm/i915: Define GuC Based TLB invalidation routines
  drm/i915: Add generic interface for tlb invalidation for XeHP
  drm/i915: Use selective tlb invalidations where supported

 drivers/gpu/drm/i915/Makefile |   1 +
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |   6 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c |  28 +-
 drivers/gpu/drm/i915/gt/intel_engine.h|   1 +
 drivers/gpu/drm/i915/gt/intel_gt.c| 125 +---
 drivers/gpu/drm/i915/gt/intel_gt.h|   2 -
 .../gpu/drm/i915/gt/intel_gt_buffer_pool.h|   3 +-
 drivers/gpu/drm/i915/gt/intel_gt_defines.h|  11 +
 drivers/gpu/drm/i915/gt/intel_gt_pm.h |  10 +
 drivers/gpu/drm/i915/gt/intel_gt_regs.h   |   8 +
 drivers/gpu/drm/i915/gt/intel_gt_types.h  |  22 +-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c |   8 +-
 drivers/gpu/drm/i915/gt/intel_tlb.c   | 295 ++
 drivers/gpu/drm/i915/gt/intel_tlb.h   |  30 ++
 .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h  |  54 
 drivers/gpu/drm/i915/gt/uc/intel_guc.c| 232 ++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h|  36 +++
 drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c |  24 +-
 drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h   |   9 +
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c |  91 +-
 drivers/gpu/drm/i915/i915_drv.h   |   4 +-
 drivers/gpu/drm/i915/i915_pci.c   |   1 +
 drivers/gpu/drm/i915/i915_vma.c   |  46 ++-
 drivers/gpu/drm/i915/i915_vma.h   |   2 +
 drivers/gpu/drm/i915/i915_vma_resource.c  |   9 +-
 drivers/gpu/drm/i915/i915_vma_resource.h  |   6 +-
 drivers/gpu/drm/i915/intel_device_info.h  |   1 +
 27 files changed, 910 insertions(+), 155 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gt/intel_gt_defines.h
 create mode 100644 drivers/gpu/drm/i915/gt/intel_tlb.c
 create mode 100644 drivers/gpu/drm/i915/gt/intel_tlb.h

-- 
2.36.1




[PATCH v2 04/21] drm/i915/gt: Only invalidate TLBs exposed to user manipulation

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Don't flush TLBs when the buffer is only used in the GGTT under full
control of the kernel, as there's no risk of concurrent access
and stale access from prefetch.

We only need to invalidate the TLB if they are accessible by the user.
That helps to reduce the performance regression introduced by TLB
invalidate logic.

Cc: sta...@vger.kernel.org
Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Cc: Andi Shyti 
Acked-by: Thomas Hellström 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/i915_vma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index ef3b04c7e153..646f419b2035 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -538,7 +538,8 @@ int i915_vma_bind(struct i915_vma *vma,
   bind_flags);
}
 
-   set_bit(I915_BO_WAS_BOUND_BIT, >obj->flags);
+   if (bind_flags & I915_VMA_LOCAL_BIND)
+   set_bit(I915_BO_WAS_BOUND_BIT, >obj->flags);
 
atomic_or(bind_flags, >flags);
return 0;
-- 
2.36.1



[PATCH v2 06/21] drm/i915/gt: Batch TLB invalidations

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Invalidate TLB in patch, in order to reduce performance regressions.

Currently, every caller performs a full barrier around a TLB
invalidation, ignoring all other invalidations that may have already
removed their PTEs from the cache. As this is a synchronous operation
and can be quite slow, we cause multiple threads to contend on the TLB
invalidate mutex blocking userspace.

We only need to invalidate the TLB once after replacing our PTE to
ensure that there is no possible continued access to the physical
address before releasing our pages. By tracking a seqno for each full
TLB invalidate we can quickly determine if one has been performed since
rewriting the PTE, and only if necessary trigger one for ourselves.

That helps to reduce the performance regression introduced by TLB
invalidate logic.

[mchehab: rebased to not require moving the code to a separate file]

Cc: sta...@vger.kernel.org
Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Suggested-by: Tvrtko Ursulin 
Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  3 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 21 +---
 drivers/gpu/drm/i915/gt/intel_gt.c| 53 ++-
 drivers/gpu/drm/i915/gt/intel_gt.h| 12 -
 drivers/gpu/drm/i915/gt/intel_gt_types.h  | 18 ++-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c |  8 ++-
 drivers/gpu/drm/i915/i915_vma.c   | 34 +---
 drivers/gpu/drm/i915/i915_vma.h   |  1 +
 drivers/gpu/drm/i915/i915_vma_resource.c  |  5 +-
 drivers/gpu/drm/i915/i915_vma_resource.h  |  6 ++-
 10 files changed, 125 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 5cf36a130061..9f6b14ec189a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -335,7 +335,6 @@ struct drm_i915_gem_object {
 #define I915_BO_READONLY  BIT(7)
 #define I915_TILING_QUIRK_BIT 8 /* unknown swizzling; do not release! */
 #define I915_BO_PROTECTED BIT(9)
-#define I915_BO_WAS_BOUND_BIT 10
/**
 * @mem_flags - Mutable placement-related flags
 *
@@ -616,6 +615,8 @@ struct drm_i915_gem_object {
 * pages were last acquired.
 */
bool dirty:1;
+
+   u32 tlb;
} mm;
 
struct {
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c 
b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 6835279943df..8357dbdcab5c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -191,6 +191,18 @@ static void unmap_object(struct drm_i915_gem_object *obj, 
void *ptr)
vunmap(ptr);
 }
 
+static void flush_tlb_invalidate(struct drm_i915_gem_object *obj)
+{
+   struct drm_i915_private *i915 = to_i915(obj->base.dev);
+   struct intel_gt *gt = to_gt(i915);
+
+   if (!obj->mm.tlb)
+   return;
+
+   intel_gt_invalidate_tlb(gt, obj->mm.tlb);
+   obj->mm.tlb = 0;
+}
+
 struct sg_table *
 __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 {
@@ -216,14 +228,7 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object 
*obj)
__i915_gem_object_reset_page_iter(obj);
obj->mm.page_sizes.phys = obj->mm.page_sizes.sg = 0;
 
-   if (test_and_clear_bit(I915_BO_WAS_BOUND_BIT, >flags)) {
-   struct drm_i915_private *i915 = to_i915(obj->base.dev);
-   struct intel_gt *gt = to_gt(i915);
-   intel_wakeref_t wakeref;
-
-   with_intel_gt_pm_if_awake(gt, wakeref)
-   intel_gt_invalidate_tlbs(gt);
-   }
+   flush_tlb_invalidate(obj);
 
return pages;
 }
diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 5c55a90672f4..f435e06125aa 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -38,8 +38,6 @@ static void __intel_gt_init_early(struct intel_gt *gt)
 {
spin_lock_init(>irq_lock);
 
-   mutex_init(>tlb_invalidate_lock);
-
INIT_LIST_HEAD(>closed_vma);
spin_lock_init(>closed_lock);
 
@@ -50,6 +48,8 @@ static void __intel_gt_init_early(struct intel_gt *gt)
intel_gt_init_reset(gt);
intel_gt_init_requests(gt);
intel_gt_init_timelines(gt);
+   mutex_init(>tlb.invalidate_lock);
+   seqcount_mutex_init(>tlb.seqno, >tlb.invalidate_lock);
intel_gt_pm_init_early(gt);
 
intel_uc_init_early(>uc);
@@ -770,6 +770,7 @@ void intel_gt_driver_late_release_all(struct 
drm_i915_private 

[PATCH v2 13/21] drm/i915: Invalidate the TLBs on each GT

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

With multi-GT devices, the object may have been bound on each GT.
Invalidate the TLBs across all GT before releasing the pages
back to the system.

Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gem/i915_gem_object_types.h |  4 +++-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c| 13 -
 drivers/gpu/drm/i915/gt/intel_engine.h   |  1 +
 drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.h   |  3 ++-
 drivers/gpu/drm/i915/gt/intel_gt_defines.h   | 11 +++
 drivers/gpu/drm/i915/gt/intel_gt_types.h |  4 +++-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c|  4 ++--
 drivers/gpu/drm/i915/i915_drv.h  |  1 -
 drivers/gpu/drm/i915/i915_vma.c  | 14 +++---
 drivers/gpu/drm/i915/i915_vma.h  |  2 +-
 10 files changed, 42 insertions(+), 15 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gt/intel_gt_defines.h

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 9f6b14ec189a..3c1d0b750a67 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -17,6 +17,8 @@
 #include "i915_selftest.h"
 #include "i915_vma_resource.h"
 
+#include "gt/intel_gt_defines.h"
+
 struct drm_i915_gem_object;
 struct intel_fronbuffer;
 struct intel_memory_region;
@@ -616,7 +618,7 @@ struct drm_i915_gem_object {
 */
bool dirty:1;
 
-   u32 tlb;
+   u32 tlb[I915_MAX_GT];
} mm;
 
struct {
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c 
b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 1cd76cc5d9f3..4a6a2f2e8148 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -194,13 +194,16 @@ static void unmap_object(struct drm_i915_gem_object *obj, 
void *ptr)
 static void flush_tlb_invalidate(struct drm_i915_gem_object *obj)
 {
struct drm_i915_private *i915 = to_i915(obj->base.dev);
-   struct intel_gt *gt = to_gt(i915);
+   struct intel_gt *gt;
+   int id;
 
-   if (!obj->mm.tlb)
-   return;
+   for_each_gt(gt, i915, id) {
+   if (!obj->mm.tlb[id])
+   continue;
 
-   intel_gt_invalidate_tlb_full(gt, obj->mm.tlb);
-   obj->mm.tlb = 0;
+   intel_gt_invalidate_tlb_full(gt, obj->mm.tlb[id]);
+   obj->mm.tlb[id] = 0;
+   }
 }
 
 struct sg_table *
diff --git a/drivers/gpu/drm/i915/gt/intel_engine.h 
b/drivers/gpu/drm/i915/gt/intel_engine.h
index 04e435bce79b..fe1dc55bf8f7 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine.h
@@ -18,6 +18,7 @@
 #include "intel_gt_types.h"
 #include "intel_timeline.h"
 #include "intel_workarounds.h"
+#include "uc/intel_guc_submission.h"
 
 struct drm_printer;
 struct intel_context;
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.h 
b/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.h
index 487b8a5520f1..8d41cf0c937a 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.h
@@ -11,8 +11,9 @@
 #include "i915_active.h"
 #include "intel_gt_buffer_pool_types.h"
 
-struct intel_gt;
+enum i915_map_type;
 struct i915_request;
+struct intel_gt;
 
 struct intel_gt_buffer_pool_node *
 intel_gt_get_buffer_pool(struct intel_gt *gt, size_t size,
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_defines.h 
b/drivers/gpu/drm/i915/gt/intel_gt_defines.h
new file mode 100644
index ..7c711726d663
--- /dev/null
+++ b/drivers/gpu/drm/i915/gt/intel_gt_defines.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __INTEL_GT_DEFINES__
+#define __INTEL_GT_DEFINES__
+
+#define I915_MAX_GT 4
+
+#endif
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h 
b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index 3804a583382b..b857c3972251 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
@@ -19,7 +19,6 @@
 #include "uc/intel_uc.h"
 #include "intel_gsc.h"
 
-#include "i915_vma.h"
 #include "intel_engine_types.h"
 #include "intel_gt_buffer_pool_types.h"
 #include "intel_hwconfig.h"
@@ -31,8 +30,11 @@
 #include "intel_wakeref.h"
 #include "pxp/intel_pxp_types.h"
 
+#include "intel_gt_defines.h"
+
 struct drm_i915_private;
 struct i915_ggtt;
+struct i915_vma;
 struct intel_engine_cs;
 struct intel_uncore;
 
diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c 
b/drivers/gpu/drm/i915/gt/intel_ppgtt.c
index 2da6c82a8bd2..f764d250e929 100644
--- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c

[PATCH v2 03/21] drm/i915/gt: Invalidate TLB of the OA unit at TLB invalidations

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Ensure that the TLB of the OA unit is also invalidated
on gen12 HW, as just invalidating the TLB of an engine is not
enough.

Cc: sta...@vger.kernel.org
Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Cc: Andi Shyti 
Acked-by: Thomas Hellström 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_gt.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index c4d43da84d8e..1d84418e8676 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -11,6 +11,7 @@
 #include "pxp/intel_pxp.h"
 
 #include "i915_drv.h"
+#include "i915_perf_oa_regs.h"
 #include "intel_context.h"
 #include "intel_engine_pm.h"
 #include "intel_engine_regs.h"
@@ -969,6 +970,15 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
awake |= engine->mask;
}
 
+   /* Wa_2207587034:tgl,dg1,rkl,adl-s,adl-p */
+   if (awake &&
+   (IS_TIGERLAKE(i915) ||
+IS_DG1(i915) ||
+IS_ROCKETLAKE(i915) ||
+IS_ALDERLAKE_S(i915) ||
+IS_ALDERLAKE_P(i915)))
+   intel_uncore_write_fw(uncore, GEN12_OA_TLB_INV_CR, 1);
+
spin_unlock_irq(>lock);
 
for_each_engine_masked(engine, gt, awake, tmp) {
-- 
2.36.1



[PATCH v2 17/21] drm/i915: Add generic interface for tlb invalidation for XeHP

2022-07-14 Thread Mauro Carvalho Chehab
From: Prathap Kumar Valsan 

Add an interface for GuC TLB actions, supporting both selective and
full TLB invalidations. After this change, when GuC is enabled,
tlb invalidations use GuC ct. Otherwise, use mmio interface.

Signed-off-by: Prathap Kumar Valsan 
Cc: Niranjana Vishwanathapura 
Cc: Fei Yang 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_gt_regs.h |  8 +++
 drivers/gpu/drm/i915/gt/intel_tlb.c | 78 -
 drivers/gpu/drm/i915/gt/intel_tlb.h |  1 +
 3 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_regs.h 
b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
index 60d6eb5f245b..52508a9c23e5 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_regs.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
@@ -1054,6 +1054,14 @@
 
 #define GEN12_GAM_DONE _MMIO(0xcf68)
 
+#define XEHP_TLB_INV_DESC0 _MMIO(0xcf7c)
+#define   XEHP_TLB_INV_DESC0_ADDR_LO   REG_GENMASK(31, 12)
+#define   XEHP_TLB_INV_DESC0_ADDR_MASK REG_GENMASK(8, 3)
+#define   XEHP_TLB_INV_DESC0_G REG_GENMASK(2, 1)
+#define   XEHP_TLB_INV_DESC0_VALID REG_BIT(0)
+#define XEHP_TLB_INV_DESC1 _MMIO(0xcf80)
+#define   XEHP_TLB_INV_DESC0_ADDR_HI   REG_GENMASK(31, 0)
+
 #define GEN7_HALF_SLICE_CHICKEN1   _MMIO(0xe100) /* IVB GT1 + VLV 
*/
 #define   GEN7_MAX_PS_THREAD_DEP   (8 << 12)
 #define   GEN7_SINGLE_SUBSCAN_DISPATCH_ENABLE  (1 << 10)
diff --git a/drivers/gpu/drm/i915/gt/intel_tlb.c 
b/drivers/gpu/drm/i915/gt/intel_tlb.c
index af8cae979489..15ed83226676 100644
--- a/drivers/gpu/drm/i915/gt/intel_tlb.c
+++ b/drivers/gpu/drm/i915/gt/intel_tlb.c
@@ -10,6 +10,7 @@
 #include "intel_gt_pm.h"
 #include "intel_gt_regs.h"
 #include "intel_tlb.h"
+#include "uc/intel_guc.h"
 
 struct reg_and_bit {
i915_reg_t reg;
@@ -159,11 +160,16 @@ void intel_gt_invalidate_tlb_full(struct intel_gt *gt, 
u32 seqno)
return;
 
with_intel_gt_pm_if_awake(gt, wakeref) {
+   struct intel_guc *guc = >uc.guc;
+
mutex_lock(>tlb.invalidate_lock);
if (tlb_seqno_passed(gt, seqno))
goto unlock;
 
-   mmio_invalidate_full(gt);
+   if (INTEL_GUC_SUPPORTS_TLB_INVALIDATION(guc))
+   intel_guc_invalidate_tlb_full(guc, 
INTEL_GUC_TLB_INVAL_MODE_HEAVY);
+   else
+   mmio_invalidate_full(gt);
 
write_seqcount_invalidate(>tlb.seqno);
 unlock:
@@ -171,6 +177,76 @@ void intel_gt_invalidate_tlb_full(struct intel_gt *gt, u32 
seqno)
}
 }
 
+static bool mmio_invalidate_range(struct intel_gt *gt, u64 start, u64 length)
+{
+   u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K));
+   u64 vm_total = BIT_ULL(INTEL_INFO(gt->i915)->ppgtt_size);
+   intel_wakeref_t wakeref;
+   u32 dw0, dw1;
+   int err;
+
+   GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE_4K));
+   GEM_BUG_ON(!IS_ALIGNED(length, I915_GTT_PAGE_SIZE_4K));
+   GEM_BUG_ON(range_overflows(start, length, vm_total));
+
+   dw0 = FIELD_PREP(XEHP_TLB_INV_DESC0_ADDR_LO, (lower_32_bits(start) >> 
12)) |
+   FIELD_PREP(XEHP_TLB_INV_DESC0_ADDR_MASK, address_mask) |
+   FIELD_PREP(XEHP_TLB_INV_DESC0_G, 0x3) |
+   FIELD_PREP(XEHP_TLB_INV_DESC0_VALID, 0x1);
+   dw1 = upper_32_bits(start);
+
+   err = 0;
+   with_intel_gt_pm_if_awake(gt, wakeref) {
+   struct intel_uncore *uncore = gt->uncore;
+
+   intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
+
+   mutex_lock(>tlb.invalidate_lock);
+   intel_uncore_write_fw(uncore, XEHP_TLB_INV_DESC1, dw1);
+   intel_uncore_write_fw(uncore, XEHP_TLB_INV_DESC0, dw0);
+   err = __intel_wait_for_register_fw(uncore,
+  XEHP_TLB_INV_DESC0,
+  XEHP_TLB_INV_DESC0_VALID,
+  0, 100, 10, NULL);
+   mutex_unlock(>tlb.invalidate_lock);
+
+   intel_uncore_forcewake_put_delayed(uncore, FORCEWAKE_ALL);
+   }
+
+   if (err)
+   drm_err_ratelimited(>i915->drm,
+   "TLB invalidation response timed out\n");
+
+   return err == 0;
+}
+
+bool intel_gt_invalidate_tlb_range(struct intel_gt *gt,
+  u64 start, u64 length)
+{
+   struct intel_guc *guc = >uc.guc;
+   intel_wakeref_t wakeref;
+
+   if (intel_gt_is_wedged(gt))
+   return true;
+
+   if 

[PATCH v2 16/21] drm/i915: Define GuC Based TLB invalidation routines

2022-07-14 Thread Mauro Carvalho Chehab
From: Prathap Kumar Valsan 

Add routines to interface with GuC firmware for selective TLB invalidation
supported on XeHP.

Signed-off-by: Prathap Kumar Valsan 
Cc: Matthew Brost 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 .../gpu/drm/i915/gt/uc/abi/guc_actions_abi.h  |  3 +
 drivers/gpu/drm/i915/gt/uc/intel_guc.c| 90 +++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h| 10 +++
 drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h   |  3 +
 4 files changed, 106 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
index fb0af33e43cc..5c019856a269 100644
--- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
+++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
@@ -188,6 +188,9 @@ enum intel_guc_state_capture_event_status {
 #define INTEL_GUC_TLB_INVAL_FLUSH_CACHE (1 << 31)
 
 enum intel_guc_tlb_invalidation_type {
+   INTEL_GUC_TLB_INVAL_FULL = 0x0,
+   INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE = 0x1,
+   INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX = 0x2,
INTEL_GUC_TLB_INVAL_GUC = 0x3,
 };
 
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
index 8a104a292598..98260a7bc90b 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
@@ -923,6 +923,96 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, 
u32 *action, u32 size)
return err;
 }
 
+ /* Full TLB invalidation */
+int intel_guc_invalidate_tlb_full(struct intel_guc *guc,
+ enum intel_guc_tlb_inval_mode mode)
+{
+   u32 action[] = {
+   INTEL_GUC_ACTION_TLB_INVALIDATION,
+   0,
+   INTEL_GUC_TLB_INVAL_FULL << INTEL_GUC_TLB_INVAL_TYPE_SHIFT |
+   mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT |
+   INTEL_GUC_TLB_INVAL_FLUSH_CACHE,
+   };
+
+   if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION(guc)) {
+   DRM_ERROR("Tlb invalidation: Operation not supported in this 
platform!\n");
+   return 0;
+   }
+
+   return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
+}
+
+/*
+ * Selective TLB Invalidation for Address Range:
+ * TLB's in the Address Range is Invalidated across all engines.
+ */
+int intel_guc_invalidate_tlb_page_selective(struct intel_guc *guc,
+   enum intel_guc_tlb_inval_mode mode,
+   u64 start, u64 length)
+{
+   u64 vm_total = BIT_ULL(INTEL_INFO(guc_to_gt(guc)->i915)->ppgtt_size);
+   u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K));
+   u32 full_range = vm_total == length;
+   u32 action[] = {
+   INTEL_GUC_ACTION_TLB_INVALIDATION,
+   0,
+   INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE << 
INTEL_GUC_TLB_INVAL_TYPE_SHIFT |
+   mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT |
+   INTEL_GUC_TLB_INVAL_FLUSH_CACHE,
+   0,
+   full_range ? full_range : lower_32_bits(start),
+   full_range ? 0 : upper_32_bits(start),
+   full_range ? 0 : address_mask,
+   };
+
+   if (!INTEL_GUC_SUPPORTS_TLB_INVALIDATION_SELECTIVE(guc)) {
+   DRM_ERROR("Tlb invalidation: Operation not supported in this 
platform!\n");
+   return 0;
+   }
+
+   GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE_4K));
+   GEM_BUG_ON(!IS_ALIGNED(length, I915_GTT_PAGE_SIZE_4K));
+   GEM_BUG_ON(range_overflows(start, length, vm_total));
+
+   return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
+}
+
+/*
+ * Selective TLB Invalidation for Context:
+ * Invalidates all TLB's for a specific context across all engines.
+ */
+int intel_guc_invalidate_tlb_page_selective_ctx(struct intel_guc *guc,
+   enum intel_guc_tlb_inval_mode 
mode,
+   u64 start, u64 length, u32 
ctxid)
+{
+   u64 vm_total = BIT_ULL(INTEL_INFO(guc_to_gt(guc)->i915)->ppgtt_size);
+   u32 address_mask = (ilog2(length) - ilog2(I915_GTT_PAGE_SIZE_4K));
+   u32 full_range = vm_total == length;
+   u32 action[] = {
+   INTEL_GUC_ACTION_TLB_INVALIDATION,
+   0,
+   INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX << 
INTEL_GUC_TLB_INVAL_TYPE_SHIFT |
+   mode << INTEL_GUC_TLB_INVAL_MODE_SHIFT |
+   INTEL_GUC_TLB_INVAL_FLUSH_CACHE,
+   ctxid,
+   full_range ? full_range : lower_32_bits(start),
+   full_range ? 0 : upper_32_bits(start),
+   full_range ? 0 : address_mask,
+   };
+
+   if 

[PATCH v2 20/21] drm/i915/guc: describe enum intel_guc_tlb_invalidation_type

2022-07-14 Thread Mauro Carvalho Chehab
Add a description for intel_guc_tlb_invalidation_type enum.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
index 5c019856a269..e97065c62d28 100644
--- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
+++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
@@ -187,6 +187,18 @@ enum intel_guc_state_capture_event_status {
 /* Flush PPC or SMRO caches along with TLB invalidation request */
 #define INTEL_GUC_TLB_INVAL_FLUSH_CACHE (1 << 31)
 
+/**
+ * enum intel_guc_tlb_invalidation_type - type of TLB cache invalidation
+ *
+ * @INTEL_GUC_TLB_INVAL_FULL:
+ * Global TLB invalidation
+ * @INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE:
+ * Page-selective TLB cache invalidation
+ * @INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE_CTX:
+ * Context-selective TLB cache invalidation
+ * @INTEL_GUC_TLB_INVAL_GUC:
+ * Invalidate TLB on GuC itself
+ */
 enum intel_guc_tlb_invalidation_type {
INTEL_GUC_TLB_INVAL_FULL = 0x0,
INTEL_GUC_TLB_INVAL_PAGE_SELECTIVE = 0x1,
-- 
2.36.1



[PATCH v2 10/21] drm/i915/guc: use kernel-doc for enum intel_guc_tlb_inval_mode

2022-07-14 Thread Mauro Carvalho Chehab
Transform the comments for intel_guc_tlb_inval_mode into a
kernel-doc markup.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
index 2e39d8df4c82..14e35a2f8306 100644
--- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
+++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
@@ -190,15 +190,18 @@ enum intel_guc_tlb_invalidation_type {
INTEL_GUC_TLB_INVAL_GUC = 0x3,
 };
 
-/*
- * 0: Heavy mode of Invalidation:
+/**
+ * enum intel_guc_tlb_inval_mode - define the mode for TLB cache invlidation
+ *
+ * @INTEL_GUC_TLB_INVAL_MODE_HEAVY: Heavy Invalidation Mode.
  * The pipeline of the engine(s) for which the invalidation is targeted to is
  * blocked, and all the in-flight transactions are guaranteed to be Globally
- * Observed before completing the TLB invalidation
- * 1: Lite mode of Invalidation:
+ * Observed before completing the TLB invalidation.
+ * @INTEL_GUC_TLB_INVAL_MODE_LITE: Light Invalidation Mode.
  * TLBs of the targeted engine(s) are immediately invalidated.
  * In-flight transactions are NOT guaranteed to be Globally Observed before
  * completing TLB invalidation.
+ *
  * Light Invalidation Mode is to be used only when
  * it can be guaranteed (by SW) that the address translations remain invariant
  * for the in-flight transactions across the TLB invalidation. In other words,
-- 
2.36.1



[PATCH v2 21/21] drm/i915/guc: document TLB cache invalidation functions

2022-07-14 Thread Mauro Carvalho Chehab
Add documentation for the kAPI functions that do TLB cache
invalidation via GuC.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/uc/intel_guc.c | 52 ++
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
index 98260a7bc90b..173833bc3a62 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
@@ -923,7 +923,14 @@ static int guc_send_invalidate_tlb(struct intel_guc *guc, 
u32 *action, u32 size)
return err;
 }
 
- /* Full TLB invalidation */
+/**
+ * intel_guc_invalidate_tlb_full - GuC full TLB invalidation
+ *
+ * @guc: the guc
+ * @mode: mode of TLB cache invalidation (heavy or lite)
+ *
+ * Use GuC to do a full TLB cache invalidation if supported.
+ */
 int intel_guc_invalidate_tlb_full(struct intel_guc *guc,
  enum intel_guc_tlb_inval_mode mode)
 {
@@ -943,8 +950,17 @@ int intel_guc_invalidate_tlb_full(struct intel_guc *guc,
return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
 }
 
-/*
- * Selective TLB Invalidation for Address Range:
+/**
+ * intel_guc_invalidate_tlb_page_selective - GuC selective TLB invalidation
+ * for an address range
+ *
+ * @guc: the guc
+ * @mode: mode of TLB cache invalidation (heavy or lite)
+ * @start: range start
+ * @length: range length
+ *
+ * Use GuC to do a selective TLB invalidation if supported.
+ *
  * TLB's in the Address Range is Invalidated across all engines.
  */
 int intel_guc_invalidate_tlb_page_selective(struct intel_guc *guc,
@@ -978,8 +994,18 @@ int intel_guc_invalidate_tlb_page_selective(struct 
intel_guc *guc,
return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
 }
 
-/*
- * Selective TLB Invalidation for Context:
+/**
+ * intel_guc_invalidate_tlb_page_selective_ctx - GuC selective TLB
+ * invalidation for a context
+ *
+ * @guc: the guc
+ * @mode: mode of TLB cache invalidation (heavy or lite)
+ * @start: range start
+ * @length: range length
+ * @ctxid: context ID
+ *
+ * Use GuC to do a selective TLB invalidation on a context if supported.
+ *
  * Invalidates all TLB's for a specific context across all engines.
  */
 int intel_guc_invalidate_tlb_page_selective_ctx(struct intel_guc *guc,
@@ -1013,8 +1039,13 @@ int intel_guc_invalidate_tlb_page_selective_ctx(struct 
intel_guc *guc,
return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
 }
 
-/*
- * Guc TLB Invalidation: Invalidate the TLB's of GuC itself.
+/**
+ * intel_guc_invalidate_tlb_guc - GuC self TLB invalidation
+ *
+ * @guc: the guc
+ * @mode: mode of TLB cache invalidation (heavy or lite)
+ *
+ * Use GuC to invalidate the TLB's of GuC itself.
  */
 int intel_guc_invalidate_tlb_guc(struct intel_guc *guc,
 enum intel_guc_tlb_inval_mode mode)
@@ -1035,6 +1066,13 @@ int intel_guc_invalidate_tlb_guc(struct intel_guc *guc,
return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
 }
 
+/**
+ * intel_guc_invalidate_tlb_all - GuC global TLB invalidation
+ *
+ * @guc: the guc
+ *
+ * Use GuC to do a complete TLB invalidation on all tables
+ */
 int intel_guc_invalidate_tlb_all(struct intel_guc *guc)
 {
u32 action[] = {
-- 
2.36.1



[PATCH v2 12/21] drm/i915/guc: Introduce TLB_INVALIDATION_ALL action

2022-07-14 Thread Mauro Carvalho Chehab
From: Piotr Piórkowski 

Add a new way to invalidate TLB via GuC using actions 0x7002
(TLB_INVALIDATION_ALL).

Those actions will be used on upcoming patches.

Signed-off-by: Piotr Piórkowski 
Cc: Michal Wajdeczko 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h |  1 +
 drivers/gpu/drm/i915/gt/uc/intel_guc.c   | 14 ++
 drivers/gpu/drm/i915/gt/uc/intel_guc.h   |  1 +
 3 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h 
b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
index 14e35a2f8306..fb0af33e43cc 100644
--- a/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
+++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_actions_abi.h
@@ -138,6 +138,7 @@ enum intel_guc_action {
INTEL_GUC_ACTION_PAGE_FAULT_NOTIFICATION = 0x6001,
INTEL_GUC_ACTION_TLB_INVALIDATION = 0x7000,
INTEL_GUC_ACTION_TLB_INVALIDATION_DONE = 0x7001,
+   INTEL_GUC_ACTION_TLB_INVALIDATION_ALL = 0x7002,
INTEL_GUC_ACTION_STATE_CAPTURE_NOTIFICATION = 0x8002,
INTEL_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE = 0x8003,
INTEL_GUC_ACTION_NOTIFY_CRASH_DUMP_POSTED = 0x8004,
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
index 5c59f9b144a3..8a104a292598 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.c
@@ -945,6 +945,20 @@ int intel_guc_invalidate_tlb_guc(struct intel_guc *guc,
return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
 }
 
+int intel_guc_invalidate_tlb_all(struct intel_guc *guc)
+{
+   u32 action[] = {
+   INTEL_GUC_ACTION_TLB_INVALIDATION_ALL,
+   0,
+   INTEL_GUC_TLB_INVAL_MODE_HEAVY << 
INTEL_GUC_TLB_INVAL_MODE_SHIFT |
+   INTEL_GUC_TLB_INVAL_FLUSH_CACHE,
+   };
+
+   GEM_BUG_ON(!INTEL_GUC_SUPPORTS_TLB_INVALIDATION(guc));
+
+   return guc_send_invalidate_tlb(guc, action, ARRAY_SIZE(action));
+}
+
 /**
  * intel_guc_load_status - dump information about GuC load status
  * @guc: the GuC
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h 
b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
index 73c46d405dc4..01c6478451cc 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
@@ -386,6 +386,7 @@ int intel_guc_self_cfg64(struct intel_guc *guc, u16 key, 
u64 value);
 
 int intel_guc_invalidate_tlb_guc(struct intel_guc *guc,
 enum intel_guc_tlb_inval_mode mode);
+int intel_guc_invalidate_tlb_all(struct intel_guc *guc);
 
 static inline bool intel_guc_is_supported(struct intel_guc *guc)
 {
-- 
2.36.1



[PATCH v2 05/21] drm/i915/gt: Skip TLB invalidations once wedged

2022-07-14 Thread Mauro Carvalho Chehab
From: Chris Wilson 

Skip all further TLB invalidations once the device is wedged and
had been reset, as, on such cases, it can no longer process instructions
on the GPU and the user no longer has access to the TLB's in each engine.

That helps to reduce the performance regression introduced by TLB
invalidate logic.

Cc: sta...@vger.kernel.org
Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store")
Signed-off-by: Chris Wilson 
Cc: Fei Yang 
Cc: Andi Shyti 
Acked-by: Thomas Hellström 
Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/gt/intel_gt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c 
b/drivers/gpu/drm/i915/gt/intel_gt.c
index 1d84418e8676..5c55a90672f4 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -934,6 +934,9 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt)
if (I915_SELFTEST_ONLY(gt->awake == -ENODEV))
return;
 
+   if (intel_gt_is_wedged(gt))
+   return;
+
if (GRAPHICS_VER(i915) == 12) {
regs = gen12_regs;
num = ARRAY_SIZE(gen12_regs);
-- 
2.36.1



[PATCH v2 07/21] drm/i915/gt: describe the new tlb parameter at i915_vma_resource

2022-07-14 Thread Mauro Carvalho Chehab
TLB cache invalidation can happen on two different situations:

1. synchronously, at __vma_put_pages();
2. asynchronously.

On the first case, TLB cache invalidation happens inside
__vma_put_pages(). So, no need to do it later on.

However, on the second case, the pages will keep in memory
until __i915_vma_evict() is called.

So, we need to store the TLB data at struct i915_vma_resource,
in order to do a TLB cache invalidation before allowing
userspace to re-use the same memory.

So, i915_vma_resource_unbind() has gained a new parameter
in order to store the TLB data at the second case.

Document it.

Signed-off-by: Mauro Carvalho Chehab 
---

To avoid mailbombing on a large number of people, only mailing lists were C/C 
on the cover.
See [PATCH v2 00/21] at: 
https://lore.kernel.org/all/cover.1657800199.git.mche...@kernel.org/

 drivers/gpu/drm/i915/i915_vma_resource.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_vma_resource.c 
b/drivers/gpu/drm/i915/i915_vma_resource.c
index 5a67995ea5fe..4fe09ea0a825 100644
--- a/drivers/gpu/drm/i915/i915_vma_resource.c
+++ b/drivers/gpu/drm/i915/i915_vma_resource.c
@@ -216,6 +216,10 @@ i915_vma_resource_fence_notify(struct i915_sw_fence *fence,
 /**
  * i915_vma_resource_unbind - Unbind a vma resource
  * @vma_res: The vma resource to unbind.
+ * @tlb: pointer to vma->obj->mm.tlb associated with the resource
+ *  to be stored at vma_res->tlb. When not-NULL, it will be used
+ *  to do TLB cache invalidation before freeing a VMA resource.
+ *  used only for async unbind.
  *
  * At this point this function does little more than publish a fence that
  * signals immediately unless signaling is held back.
-- 
2.36.1



Re: [PATCH v2 5/5] drm/modes: parse_cmdline: Add support for named modes containing dashes

2022-07-14 Thread Maxime Ripard
On Thu, Jul 14, 2022 at 11:04:10AM +0200, Geert Uytterhoeven wrote:
> It is fairly common for named video modes to contain dashes (e.g.
> "tt-mid" on Atari, "dblntsc-ff" on Amiga).  Currently such mode names
> are not recognized, as the dash is considered to be a separator between
> mode name and bpp.
> 
> Fix this by skipping any dashes that are not followed immediately by a
> digit when looking for the separator.
> 
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Hans de Goede 

Ditto, we should have a test for that

Maxime


signature.asc
Description: PGP signature


Re: [PATCH v2 3/5] drm/modes: parse_cmdline: Make mode->*specified handling more uniform

2022-07-14 Thread Maxime Ripard
On Thu, Jul 14, 2022 at 11:04:08AM +0200, Geert Uytterhoeven wrote:
> The various mode->*specified flags are not handled in an uniform way:
> some flags are set by the corresponding drm_mode_parse_cmdline_*()
> function, some flags by the caller of the function, and some flags by
> both.
> 
> Make this uniform by making this the responsibility of the various
> parsing helpers, i.e.
>   - Move the setting of mode->specified from caller to callee,
>   - Drop the duplicate setting of mode->bpp_specified and
> mode->refresh_specified from callers.
> 
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Hans de Goede 
> Acked-by: Thomas Zimmermann 

Acked-by: Maxime Ripard 

Maxime


signature.asc
Description: PGP signature


Re: [PATCH v2 2/5] drm/modes: Extract drm_mode_parse_cmdline_named_mode()

2022-07-14 Thread Maxime Ripard
On Thu, Jul 14, 2022 at 11:04:07AM +0200, Geert Uytterhoeven wrote:
> Extract the code to check for a named mode parameter into its own
> function, to streamline the main parsing flow.
> 
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Hans de Goede 
> Acked-by: Thomas Zimmermann 

Acked-by: Maxime Ripard 

Maxime


signature.asc
Description: PGP signature


Re: [PATCH v2 1/5] drm/modes: parse_cmdline: Handle empty mode name part

2022-07-14 Thread Maxime Ripard
Hi,

On Thu, Jul 14, 2022 at 11:04:06AM +0200, Geert Uytterhoeven wrote:
> If no mode name part was specified, mode_end is zero, and the "ret ==
> mode_end" check does the wrong thing.
> 
> Fix this by skipping all named mode handling when mode_end is zero.
> 
> Fixes: 7b1cce760afe38b4 ("drm/modes: parse_cmdline: Allow specifying 
> stand-alone options")
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Hans de Goede 
> Acked-by: Thomas Zimmermann 

We should add a test for that in drivers/gpu/drm/tests/drm_cmdline_parser_test.c

Maxime


signature.asc
Description: PGP signature


  1   2   >