Re: [PATCH v13 1/9] gpu/drm/i915: Update indentation for VRR registers and bits

2024-06-06 Thread Nautiyal, Ankit K



On 6/7/2024 8:59 AM, Nautiyal, Ankit K wrote:


On 6/5/2024 10:31 PM, Mitul Golani wrote:

Update the indentation for the VRR register definition and
its bits, and fix checkpatch issues to ensure smooth movement
of registers and bits.

Signed-off-by: Mitul Golani 


LGTM

Reviewed-by: Ankit Nautiyal 


Having look at the next patch, I fee there are still few things that can 
be fixed in VRR regs since we are moving these into a new file.


IMHO, it would be great if we can make the changes so that the new file 
adheres to the formatting mentioned in i915_reg.h


Regards,

Ankit






---
  drivers/gpu/drm/i915/i915_reg.h | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h 
b/drivers/gpu/drm/i915/i915_reg.h

index 0569a23b83b2..6b39211b5469 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1152,7 +1152,7 @@
  #define _TRANS_VRR_CTL_B    0x61420
  #define _TRANS_VRR_CTL_C    0x62420
  #define _TRANS_VRR_CTL_D    0x63420
-#define TRANS_VRR_CTL(dev_priv, trans) _MMIO_TRANS2(dev_priv, trans, 
_TRANS_VRR_CTL_A)
+#define TRANS_VRR_CTL(dev_priv, trans) _MMIO_TRANS2(dev_priv, trans, 
_TRANS_VRR_CTL_A)

  #define   VRR_CTL_VRR_ENABLE    REG_BIT(31)
  #define   VRR_CTL_IGN_MAX_SHIFT    REG_BIT(30)
  #define   VRR_CTL_FLIP_LINE_EN    REG_BIT(29)
@@ -1160,7 +1160,8 @@
  #define   VRR_CTL_PIPELINE_FULL(x) 
REG_FIELD_PREP(VRR_CTL_PIPELINE_FULL_MASK, (x))

  #define   VRR_CTL_PIPELINE_FULL_OVERRIDE    REG_BIT(0)
  #define  XELPD_VRR_CTL_VRR_GUARDBAND_MASK REG_GENMASK(15, 0)
-#define  XELPD_VRR_CTL_VRR_GUARDBAND(x) 
REG_FIELD_PREP(XELPD_VRR_CTL_VRR_GUARDBAND_MASK, (x))
+#define  XELPD_VRR_CTL_VRR_GUARDBAND(x) 
REG_FIELD_PREP(XELPD_VRR_CTL_VRR_GUARDBAND_MASK, \

+    (x))
    #define _TRANS_VRR_VMAX_A    0x60424
  #define _TRANS_VRR_VMAX_B    0x61424
@@ -1190,7 +1191,7 @@
  #define _TRANS_VRR_STATUS_B    0x6142C
  #define _TRANS_VRR_STATUS_C    0x6242C
  #define _TRANS_VRR_STATUS_D    0x6342C
-#define TRANS_VRR_STATUS(dev_priv, trans) _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_STATUS_A)
+#define TRANS_VRR_STATUS(dev_priv, trans) _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_STATUS_A)

  #define   VRR_STATUS_VMAX_REACHED    REG_BIT(31)
  #define   VRR_STATUS_NOFLIP_TILL_BNDR    REG_BIT(30)
  #define   VRR_STATUS_FLIP_BEF_BNDR    REG_BIT(29)
@@ -1241,7 +1242,7 @@
  #define   TRANS_PUSH_SEND    REG_BIT(30)
    #define _TRANS_VRR_VSYNC_A    0x60078
-#define TRANS_VRR_VSYNC(dev_priv, trans) _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_VSYNC_A)
+#define TRANS_VRR_VSYNC(dev_priv, trans) _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_VSYNC_A)

  #define VRR_VSYNC_END_MASK    REG_GENMASK(28, 16)
  #define VRR_VSYNC_END(vsync_end) REG_FIELD_PREP(VRR_VSYNC_END_MASK, 
(vsync_end))

  #define VRR_VSYNC_START_MASK    REG_GENMASK(12, 0)


[PATCH] drm/tests: add missing MODULE_DESCRIPTION() macros

2024-06-06 Thread Jeff Johnson
t_modes_suite);
 
 MODULE_AUTHOR("Maxime Ripard ");
+MODULE_DESCRIPTION("Kunit test for drm_probe_helper functions");
 MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/tests/drm_rect_test.c 
b/drivers/gpu/drm/tests/drm_rect_test.c
index 76332cd2ead8..17e1f34b7610 100644
--- a/drivers/gpu/drm/tests/drm_rect_test.c
+++ b/drivers/gpu/drm/tests/drm_rect_test.c
@@ -526,4 +526,5 @@ static struct kunit_suite drm_rect_test_suite = {
 
 kunit_test_suite(drm_rect_test_suite);
 
+MODULE_DESCRIPTION("Test cases for the drm_rect functions");
 MODULE_LICENSE("GPL");

---
base-commit: 19ca0d8a433ff37018f9429f7e7739e9f3d3d2b4
change-id: 20240606-md-drivers-gpu-drm-tests-9d5db6f928b8



Re: [PATCH v13 1/9] gpu/drm/i915: Update indentation for VRR registers and bits

2024-06-06 Thread Nautiyal, Ankit K



On 6/5/2024 10:31 PM, Mitul Golani wrote:

Update the indentation for the VRR register definition and
its bits, and fix checkpatch issues to ensure smooth movement
of registers and bits.

Signed-off-by: Mitul Golani 


LGTM

Reviewed-by: Ankit Nautiyal 



---
  drivers/gpu/drm/i915/i915_reg.h | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 0569a23b83b2..6b39211b5469 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1152,7 +1152,7 @@
  #define _TRANS_VRR_CTL_B  0x61420
  #define _TRANS_VRR_CTL_C  0x62420
  #define _TRANS_VRR_CTL_D  0x63420
-#define TRANS_VRR_CTL(dev_priv, trans) _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_CTL_A)
+#define TRANS_VRR_CTL(dev_priv, trans) _MMIO_TRANS2(dev_priv, trans, 
_TRANS_VRR_CTL_A)
  #define   VRR_CTL_VRR_ENABLE  REG_BIT(31)
  #define   VRR_CTL_IGN_MAX_SHIFT   REG_BIT(30)
  #define   VRR_CTL_FLIP_LINE_ENREG_BIT(29)
@@ -1160,7 +1160,8 @@
  #define   VRR_CTL_PIPELINE_FULL(x)
REG_FIELD_PREP(VRR_CTL_PIPELINE_FULL_MASK, (x))
  #define   VRR_CTL_PIPELINE_FULL_OVERRIDE  REG_BIT(0)
  #define XELPD_VRR_CTL_VRR_GUARDBAND_MASK  REG_GENMASK(15, 0)
-#define  XELPD_VRR_CTL_VRR_GUARDBAND(x)
REG_FIELD_PREP(XELPD_VRR_CTL_VRR_GUARDBAND_MASK, (x))
+#define  XELPD_VRR_CTL_VRR_GUARDBAND(x)
REG_FIELD_PREP(XELPD_VRR_CTL_VRR_GUARDBAND_MASK, \
+   (x))
  
  #define _TRANS_VRR_VMAX_A		0x60424

  #define _TRANS_VRR_VMAX_B 0x61424
@@ -1190,7 +1191,7 @@
  #define _TRANS_VRR_STATUS_B   0x6142C
  #define _TRANS_VRR_STATUS_C   0x6242C
  #define _TRANS_VRR_STATUS_D   0x6342C
-#define TRANS_VRR_STATUS(dev_priv, trans)  _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_STATUS_A)
+#define TRANS_VRR_STATUS(dev_priv, trans)  _MMIO_TRANS2(dev_priv, trans, 
_TRANS_VRR_STATUS_A)
  #define   VRR_STATUS_VMAX_REACHED REG_BIT(31)
  #define   VRR_STATUS_NOFLIP_TILL_BNDR REG_BIT(30)
  #define   VRR_STATUS_FLIP_BEF_BNDRREG_BIT(29)
@@ -1241,7 +1242,7 @@
  #define   TRANS_PUSH_SEND REG_BIT(30)
  
  #define _TRANS_VRR_VSYNC_A		0x60078

-#define TRANS_VRR_VSYNC(dev_priv, trans)   _MMIO_TRANS2(dev_priv, 
trans, _TRANS_VRR_VSYNC_A)
+#define TRANS_VRR_VSYNC(dev_priv, trans)   _MMIO_TRANS2(dev_priv, trans, 
_TRANS_VRR_VSYNC_A)
  #define VRR_VSYNC_END_MASKREG_GENMASK(28, 16)
  #define VRR_VSYNC_END(vsync_end)  REG_FIELD_PREP(VRR_VSYNC_END_MASK, 
(vsync_end))
  #define VRR_VSYNC_START_MASK  REG_GENMASK(12, 0)


[git pull] drm fixes for 6.10-rc3

2024-06-06 Thread Dave Airlie
Hi Linus,

Weekly fixes, vmwgfx leads the way this week, with minor changes in xe
and amdgpu and a couple of other small fixes.

Seems quiet enough.

Dave.

drm-fixes-2024-06-07:
drm fixes for 6.10-rc3

xe:
- Update the LMTT when freeing VF GT config

amdgpu:
- Fix shutdown issues on some SMU 13.x platforms
- Silence some UBSAN flexible array warnings

panel:
- sitronix-st7789v: handle of_drm_get_panel_orientation
  failing error.

vmwgfx:
- filter modes greater than available graphics memory
- fix 3D vs STDU enable
- remove STDU logic from mode valid
- logging fix
- memcmp pointers fix
- remove unused struct
- screen target lifetime fix

komeda:
- unused struct removal
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:

  Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/kernel.git tags/drm-fixes-2024-06-07

for you to fetch changes up to eb55943aab89be99a26e34fc2175ebb3583a2778:

  Merge tag 'drm-misc-next-fixes-2024-06-07' of
https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
(2024-06-07 08:40:58 +1000)


drm fixes for 6.10-rc3

xe:
- Update the LMTT when freeing VF GT config

amdgpu:
- Fix shutdown issues on some SMU 13.x platforms
- Silence some UBSAN flexible array warnings

panel:
- sitronix-st7789v: handle of_drm_get_panel_orientation
  failing error.

vmwgfx:
- filter modes greater than available graphics memory
- fix 3D vs STDU enable
- remove STDU logic from mode valid
- logging fix
- memcmp pointers fix
- remove unused struct
- screen target lifetime fix

komeda:
- unused struct removal


Chen Ni (1):
  drm/panel: sitronix-st7789v: Add check for of_drm_get_panel_orientation

Dave Airlie (4):
  Merge tag 'drm-xe-fixes-2024-06-04' of
https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
  Merge tag 'amd-drm-fixes-6.10-2024-06-06' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
  Merge tag 'drm-misc-fixes-2024-06-07' of
https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
  Merge tag 'drm-misc-next-fixes-2024-06-07' of
https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes

Dr. David Alan Gilbert (2):
  drm/komeda: remove unused struct 'gamma_curve_segment'
  drm/vmwgfx: remove unused struct 'vmw_stdu_dma'

Ian Forbes (6):
  drm/vmwgfx: Filter modes which exceed graphics memory
  drm/vmwgfx: 3D disabled should not effect STDU memory limits
  drm/vmwgfx: Remove STDU logic from generic mode_valid function
  drm/vmwgfx: Standardize use of kibibytes when logging
  drm/vmwgfx: Don't destroy Screen Target when CRTC is enabled but inactive
  drm/vmwgfx: Don't memcmp equivalent pointers

Mario Limonciello (1):
  drm/amd: Fix shutdown (again) on some SMU v13.0.4/11 platforms

Michal Wajdeczko (1):
  drm/xe/pf: Update the LMTT when freeing VF GT config

Tasos Sahanidis (1):
  drm/amdgpu/pptable: Fix UBSAN array-index-out-of-bounds

 drivers/gpu/drm/amd/include/pptable.h  | 91 --
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c   | 20 ++---
 .../gpu/drm/arm/display/komeda/komeda_color_mgmt.c |  5 --
 drivers/gpu/drm/panel/panel-sitronix-st7789v.c |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c| 19 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h|  3 -
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c  |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c| 28 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c   | 60 --
 drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c |  1 +
 10 files changed, 135 insertions(+), 100 deletions(-)


Re: [PATCH] drm/nouveau: don't attempt to schedule hpd_work on headless cards

2024-06-06 Thread Dave Airlie
readding original poster

On Wed, 29 May 2024 at 09:57, Ben Skeggs  wrote:
>
> On 29/5/24 07:52, Vasily Khoruzhick wrote:
>
> > If the card doesn't have display hardware, hpd_work and hpd_lock are
> > left uninitialized which causes BUG when attempting to schedule hpd_work
> > on runtime PM resume.
>
> Hi,
>
> Good catch, thank you for looking at this.  A couple of initial comments
> below:
>
> Ben.
>
> >
> > Fix it by adding headless flag to DRM and skip any hpd if it's set.
> >
> > Fixes: ae1aadb1eb8d ("nouveau: don't fail driver load if no display hw 
> > present.")
> > Link: https://gitlab.freedesktop.org/drm/nouveau/-/issues/337
> > Signed-off-by: Vasily Khoruzhick 
> > ---
> >   drivers/gpu/drm/nouveau/dispnv04/disp.c |  2 +-
> >   drivers/gpu/drm/nouveau/dispnv50/disp.c |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_connector.c |  3 +++
> >   drivers/gpu/drm/nouveau/nouveau_display.c   | 11 ++-
> >   drivers/gpu/drm/nouveau/nouveau_drv.h   |  1 +
> >   5 files changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c 
> > b/drivers/gpu/drm/nouveau/dispnv04/disp.c
> > index 13705c5f1497..4b7497a8755c 100644
> > --- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
> > @@ -68,7 +68,7 @@ nv04_display_fini(struct drm_device *dev, bool runtime, 
> > bool suspend)
> >   if (nv_two_heads(dev))
> >   NVWriteCRTC(dev, 1, NV_PCRTC_INTR_EN_0, 0);
> >
> > - if (!runtime)
> > + if (!runtime && !drm->headless)
> >   cancel_work_sync(&drm->hpd_work);
> >
> >   if (!suspend)
> > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
> > b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > index 88728a0b2c25..674dc567e179 100644
> > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > @@ -2680,7 +2680,7 @@ nv50_display_fini(struct drm_device *dev, bool 
> > runtime, bool suspend)
> >   nv50_mstm_fini(nouveau_encoder(encoder));
> >   }
> >
> > - if (!runtime)
> > + if (!runtime && !drm->headless)
> >   cancel_work_sync(&drm->hpd_work);
> >   }
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c 
> > b/drivers/gpu/drm/nouveau/nouveau_connector.c
> > index 856b3ef5edb8..b315a2ef5b28 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> > @@ -1190,6 +1190,9 @@ nouveau_connector_hpd(struct nouveau_connector 
> > *nv_connector, u64 bits)
> >   u32 mask = drm_connector_mask(&nv_connector->base);
> >   unsigned long flags;
> >
> > + if (drm->headless)
> > + return;
> > +
>
> You shouldn't need this change, the function can't be called if there's
> no display.
>
>
> >   spin_lock_irqsave(&drm->hpd_lock, flags);
> >   if (!(drm->hpd_pending & mask)) {
> >   nv_connector->hpd_pending |= bits;
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
> > b/drivers/gpu/drm/nouveau/nouveau_display.c
> > index aed5d5b51b43..1961ef665e97 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> > @@ -450,6 +450,9 @@ nouveau_display_hpd_resume(struct drm_device *dev)
> >   {
> >   struct nouveau_drm *drm = nouveau_drm(dev);
> >
> > + if (drm->headless)
> > + return;
> > +
> >   spin_lock_irq(&drm->hpd_lock);
> >   drm->hpd_pending = ~0;
> >   spin_unlock_irq(&drm->hpd_lock);
> > @@ -468,6 +471,11 @@ nouveau_display_hpd_work(struct work_struct *work)
> >   int changed = 0;
> >   struct drm_connector *first_changed_connector = NULL;
> >
> > + WARN_ON_ONCE(drm->headless);
> > +
> > + if (drm->headless)
> > + return;
> > +
>
> Same here.
>
>
> >   pm_runtime_get_sync(dev->dev);
> >
> >   spin_lock_irq(&drm->hpd_lock);
> > @@ -635,7 +643,7 @@ nouveau_display_fini(struct drm_device *dev, bool 
> > suspend, bool runtime)
> >   }
> >   drm_connector_list_iter_end(&conn_iter);
> >
> > - if (!runtime)
> > + if (!runtime && !drm->headless)
> >   cancel_work_sync(&drm->hpd_work);
> >
> >   drm_kms_helper_poll_disable(dev);
> > @@ -729,6 +737,7 @@ nouveau_display_create(struct drm_device *dev)
> >   /* no display hw */
> >   if (ret == -ENODEV) {
> >   ret = 0;
> > + drm->headless = true;
> >   goto disp_create_err;
> >   }
> >
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h 
> > b/drivers/gpu/drm/nouveau/nouveau_drv.h
> > index e239c6bf4afa..25fca98a20bc 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_drv.h
> > +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
> > @@ -276,6 +276,7 @@ struct nouveau_drm {
> >   /* modesetting */
> >   struct nvbios vbios;
> >   struct nouveau_display *display;
> > + bool headless;
> >   struct work_s

[PATCH net-next v11 13/13] selftests: add ncdevmem, netcat for devmem TCP

2024-06-06 Thread Mina Almasry
ncdevmem is a devmem TCP netcat. It works similarly to netcat, but it
sends and receives data using the devmem TCP APIs. It uses udmabuf as
the dmabuf provider. It is compatible with a regular netcat running on
a peer, or a ncdevmem running on a peer.

In addition to normal netcat support, ncdevmem has a validation mode,
where it sends a specific pattern and validates this pattern on the
receiver side to ensure data integrity.

Suggested-by: Stanislav Fomichev 
Signed-off-by: Mina Almasry 

---
v9: 
https://lore.kernel.org/netdev/20240403002053.2376017-15-almasrym...@google.com/
- Remove unused nic_pci_addr entry (Cong).

v6:
- Updated to bind 8 queues.
- Added RSS configuration.
- Added some more tests for the netlink API.

Changes in v1:
- Many more general cleanups (Willem).
- Removed driver reset (Jakub).
- Removed hardcoded if index (Paolo).

RFC v2:
- General cleanups (Willem).

---
 tools/testing/selftests/net/.gitignore |   1 +
 tools/testing/selftests/net/Makefile   |   5 +
 tools/testing/selftests/net/ncdevmem.c | 542 +
 3 files changed, 548 insertions(+)
 create mode 100644 tools/testing/selftests/net/ncdevmem.c

diff --git a/tools/testing/selftests/net/.gitignore 
b/tools/testing/selftests/net/.gitignore
index 49a56eb5d0368..9cd3c99c6e5d4 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -17,6 +17,7 @@ ipv6_flowlabel
 ipv6_flowlabel_mgr
 log.txt
 msg_zerocopy
+ncdevmem
 nettest
 psock_fanout
 psock_snd
diff --git a/tools/testing/selftests/net/Makefile 
b/tools/testing/selftests/net/Makefile
index 6da63d1831c11..2600cce3ee382 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -5,6 +5,10 @@ CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
 CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES)
 # Additional include paths needed by kselftest.h
 CFLAGS += -I../
+CFLAGS += -I../../../net/ynl/generated/
+CFLAGS += -I../../../net/ynl/lib/
+
+LDLIBS += ../../../net/ynl/lib/ynl.a ../../../net/ynl/generated/protos.a
 
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
  rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
@@ -92,6 +96,7 @@ TEST_PROGS += fdb_flush.sh
 TEST_PROGS += fq_band_pktlimit.sh
 TEST_PROGS += vlan_hw_filter.sh
 TEST_PROGS += bpf_offload.py
+TEST_GEN_FILES += ncdevmem
 
 TEST_FILES := settings
 TEST_FILES += in_netns.sh lib.sh net_helper.sh setup_loopback.sh setup_veth.sh
diff --git a/tools/testing/selftests/net/ncdevmem.c 
b/tools/testing/selftests/net/ncdevmem.c
new file mode 100644
index 0..e00255e54f77b
--- /dev/null
+++ b/tools/testing/selftests/net/ncdevmem.c
@@ -0,0 +1,542 @@
+// SPDX-License-Identifier: GPL-2.0
+#define _GNU_SOURCE
+#define __EXPORTED_HEADERS__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#define __iovec_defined
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "netdev-user.h"
+#include 
+
+#define PAGE_SHIFT 12
+#define TEST_PREFIX "ncdevmem"
+#define NUM_PAGES 16000
+
+#ifndef MSG_SOCK_DEVMEM
+#define MSG_SOCK_DEVMEM 0x200
+#endif
+
+/*
+ * tcpdevmem netcat. Works similarly to netcat but does device memory TCP
+ * instead of regular TCP. Uses udmabuf to mock a dmabuf provider.
+ *
+ * Usage:
+ *
+ * On server:
+ * ncdevmem -s  -c  -f eth1 -d 3 -n :06:00.0 -l \
+ * -p 5201 -v 7
+ *
+ * On client:
+ * yes $(echo -e \\x01\\x02\\x03\\x04\\x05\\x06) | \
+ * tr \\n \\0 | \
+ * head -c 5G | \
+ * nc  5201 -p 5201
+ *
+ * Note this is compatible with regular netcat. i.e. the sender or receiver can
+ * be replaced with regular netcat to test the RX or TX path in isolation.
+ */
+
+static char *server_ip = "192.168.1.4";
+static char *client_ip = "192.168.1.2";
+static char *port = "5201";
+static size_t do_validation;
+static int start_queue = 8;
+static int num_queues = 8;
+static char *ifname = "eth1";
+static unsigned int ifindex = 3;
+static unsigned int iterations;
+static unsigned int dmabuf_id;
+
+void print_bytes(void *ptr, size_t size)
+{
+   unsigned char *p = ptr;
+   int i;
+
+   for (i = 0; i < size; i++)
+   printf("%02hhX ", p[i]);
+   printf("\n");
+}
+
+void print_nonzero_bytes(void *ptr, size_t size)
+{
+   unsigned char *p = ptr;
+   unsigned int i;
+
+   for (i = 0; i < size; i++)
+   putchar(p[i]);
+   printf("\n");
+}
+
+void validate_buffer(void *line, size_t size)
+{
+   static unsigned char seed = 1;
+   unsigned char *ptr = line;
+   int errors = 0;
+   size_t i;
+
+   for (i = 0; i < size; i++) {
+   if (ptr[i] != seed) {
+   fprintf(stderr,
+   "Failed validation: expected=%u, actual

[PATCH net-next v11 12/13] net: add devmem TCP documentation

2024-06-06 Thread Mina Almasry
Add documentation outlining the usage and details of devmem TCP.

Signed-off-by: Mina Almasry 
Reviewed-by: Bagas Sanjaya 

---

v9: 
https://lore.kernel.org/netdev/20240403002053.2376017-14-almasrym...@google.com/
- Bagas doc suggestions.

v8:
- Applied docs suggestions (Randy). Thanks!

v7:
- Applied docs suggestions (Jakub).

v2:

- Missing spdx (simon)
- add to index.rst (simon)

---
 Documentation/networking/devmem.rst | 258 
 Documentation/networking/index.rst  |   1 +
 2 files changed, 259 insertions(+)
 create mode 100644 Documentation/networking/devmem.rst

diff --git a/Documentation/networking/devmem.rst 
b/Documentation/networking/devmem.rst
new file mode 100644
index 0..f32acfd62075d
--- /dev/null
+++ b/Documentation/networking/devmem.rst
@@ -0,0 +1,258 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=
+Device Memory TCP
+=
+
+
+Intro
+=
+
+Device memory TCP (devmem TCP) enables receiving data directly into device
+memory (dmabuf). The feature is currently implemented for TCP sockets.
+
+
+Opportunity
+---
+
+A large number of data transfers have device memory as the source and/or
+destination. Accelerators drastically increased the prevalence of such
+transfers.  Some examples include:
+
+- Distributed training, where ML accelerators, such as GPUs on different hosts,
+  exchange data.
+
+- Distributed raw block storage applications transfer large amounts of data 
with
+  remote SSDs. Much of this data does not require host processing.
+
+Typically the Device-to-Device data transfers in the network are implemented as
+the following low-level operations: Device-to-Host copy, Host-to-Host network
+transfer, and Host-to-Device copy.
+
+The flow involving host copies is suboptimal, especially for bulk data 
transfers,
+and can put significant strains on system resources such as host memory
+bandwidth and PCIe bandwidth.
+
+Devmem TCP optimizes this use case by implementing socket APIs that enable
+the user to receive incoming network packets directly into device memory.
+
+Packet payloads go directly from the NIC to device memory.
+
+Packet headers go to host memory and are processed by the TCP/IP stack
+normally. The NIC must support header split to achieve this.
+
+Advantages:
+
+- Alleviate host memory bandwidth pressure, compared to existing
+  network-transfer + device-copy semantics.
+
+- Alleviate PCIe bandwidth pressure, by limiting data transfer to the lowest
+  level of the PCIe tree, compared to the traditional path which sends data
+  through the root complex.
+
+
+More Info
+-
+
+  slides, video
+https://netdevconf.org/0x17/sessions/talk/device-memory-tcp.html
+
+  patchset
+[RFC PATCH v6 00/12] Device Memory TCP
+
https://lore.kernel.org/netdev/20240305020153.2787423-1-almasrym...@google.com/
+
+
+Interface
+=
+
+Example
+---
+
+tools/testing/selftests/net/ncdevmem.c:do_server shows an example of setting up
+the RX path of this API.
+
+NIC Setup
+-
+
+Header split, flow steering, & RSS are required features for devmem TCP.
+
+Header split is used to split incoming packets into a header buffer in host
+memory, and a payload buffer in device memory.
+
+Flow steering & RSS are used to ensure that only flows targeting devmem land on
+an RX queue bound to devmem.
+
+Enable header split & flow steering::
+
+   # enable header split
+   ethtool -G eth1 tcp-data-split on
+
+
+   # enable flow steering
+   ethtool -K eth1 ntuple on
+
+Configure RSS to steer all traffic away from the target RX queue (queue 15 in
+this example)::
+
+   ethtool --set-rxfh-indir eth1 equal 15
+
+
+The user must bind a dmabuf to any number of RX queues on a given NIC using
+the netlink API::
+
+   /* Bind dmabuf to NIC RX queue 15 */
+   struct netdev_queue *queues;
+   queues = malloc(sizeof(*queues) * 1);
+
+   queues[0]._present.type = 1;
+   queues[0]._present.idx = 1;
+   queues[0].type = NETDEV_RX_QUEUE_TYPE_RX;
+   queues[0].idx = 15;
+
+   *ys = ynl_sock_create(&ynl_netdev_family, &yerr);
+
+   req = netdev_bind_rx_req_alloc();
+   netdev_bind_rx_req_set_ifindex(req, 1 /* ifindex */);
+   netdev_bind_rx_req_set_dmabuf_fd(req, dmabuf_fd);
+   __netdev_bind_rx_req_set_queues(req, queues, n_queue_index);
+
+   rsp = netdev_bind_rx(*ys, req);
+
+   dmabuf_id = rsp->dmabuf_id;
+
+
+The netlink API returns a dmabuf_id: a unique ID that refers to this dmabuf
+that has been bound.
+
+Socket Setup
+
+
+The socket must be flow steered to the dmabuf bound RX queue::
+
+   ethtool -N eth1 flow-type tcp4 ... queue 15,
+
+
+Receiving data
+--
+
+The user application must signal to the kernel that it is capable of receiving
+devmem data by passing the MSG_SOCK_DEVMEM flag to recvmsg::
+
+   ret = recvmsg(fd, &msg, MSG_SOCK_DEVMEM);
+
+Applications that do not specify the MSG_SOCK_DEVMEM flag will re

[PATCH net-next v11 11/13] net: add SO_DEVMEM_DONTNEED setsockopt to release RX frags

2024-06-06 Thread Mina Almasry
Add an interface for the user to notify the kernel that it is done
reading the devmem dmabuf frags returned as cmsg. The kernel will
drop the reference on the frags to make them available for reuse.

Signed-off-by: Willem de Bruijn 
Signed-off-by: Kaiyuan Zhang 
Signed-off-by: Mina Almasry 

---

v10:
- Fix leak of tokens (Nikolay).

v7:
- Updated SO_DEVMEM_* uapi to use the next available entry (Arnd).

v6:
- Squash in locking optimizations from eduma...@google.com. With his
  changes we lock the xarray once per sock_devmem_dontneed operation
  rather than once per frag.

Changes in v1:
- devmemtoken -> dmabuf_token (David).
- Use napi_pp_put_page() for refcounting (Yunsheng).
- Fix build error with missing socket options on other asms.

---
 arch/alpha/include/uapi/asm/socket.h  |  1 +
 arch/mips/include/uapi/asm/socket.h   |  1 +
 arch/parisc/include/uapi/asm/socket.h |  1 +
 arch/sparc/include/uapi/asm/socket.h  |  1 +
 include/uapi/asm-generic/socket.h |  1 +
 include/uapi/linux/uio.h  |  4 ++
 net/core/sock.c   | 61 +++
 7 files changed, 70 insertions(+)

diff --git a/arch/alpha/include/uapi/asm/socket.h 
b/arch/alpha/include/uapi/asm/socket.h
index ef4656a41058a..251b73c5481ea 100644
--- a/arch/alpha/include/uapi/asm/socket.h
+++ b/arch/alpha/include/uapi/asm/socket.h
@@ -144,6 +144,7 @@
 #define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
 #define SO_DEVMEM_DMABUF   79
 #define SCM_DEVMEM_DMABUF  SO_DEVMEM_DMABUF
+#define SO_DEVMEM_DONTNEED 80
 
 #if !defined(__KERNEL__)
 
diff --git a/arch/mips/include/uapi/asm/socket.h 
b/arch/mips/include/uapi/asm/socket.h
index 414807d55e33f..8ab7582291abf 100644
--- a/arch/mips/include/uapi/asm/socket.h
+++ b/arch/mips/include/uapi/asm/socket.h
@@ -155,6 +155,7 @@
 #define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
 #define SO_DEVMEM_DMABUF   79
 #define SCM_DEVMEM_DMABUF  SO_DEVMEM_DMABUF
+#define SO_DEVMEM_DONTNEED 80
 
 #if !defined(__KERNEL__)
 
diff --git a/arch/parisc/include/uapi/asm/socket.h 
b/arch/parisc/include/uapi/asm/socket.h
index 2b817efd45444..38fc0b188e084 100644
--- a/arch/parisc/include/uapi/asm/socket.h
+++ b/arch/parisc/include/uapi/asm/socket.h
@@ -136,6 +136,7 @@
 #define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
 #define SO_DEVMEM_DMABUF   79
 #define SCM_DEVMEM_DMABUF  SO_DEVMEM_DMABUF
+#define SO_DEVMEM_DONTNEED 80
 
 #if !defined(__KERNEL__)
 
diff --git a/arch/sparc/include/uapi/asm/socket.h 
b/arch/sparc/include/uapi/asm/socket.h
index 00248fc689773..57084ed2f3c4e 100644
--- a/arch/sparc/include/uapi/asm/socket.h
+++ b/arch/sparc/include/uapi/asm/socket.h
@@ -137,6 +137,7 @@
 #define SCM_DEVMEM_LINEARSO_DEVMEM_LINEAR
 #define SO_DEVMEM_DMABUF 0x0058
 #define SCM_DEVMEM_DMABUFSO_DEVMEM_DMABUF
+#define SO_DEVMEM_DONTNEED   0x0059
 
 #if !defined(__KERNEL__)
 
diff --git a/include/uapi/asm-generic/socket.h 
b/include/uapi/asm-generic/socket.h
index 25a2f5255f523..1acb77780f103 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -135,6 +135,7 @@
 #define SO_PASSPIDFD   76
 #define SO_PEERPIDFD   77
 
+#define SO_DEVMEM_DONTNEED 97
 #define SO_DEVMEM_LINEAR   98
 #define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
 #define SO_DEVMEM_DMABUF   99
diff --git a/include/uapi/linux/uio.h b/include/uapi/linux/uio.h
index 3a22ddae376a2..d17f8fcd93ec9 100644
--- a/include/uapi/linux/uio.h
+++ b/include/uapi/linux/uio.h
@@ -33,6 +33,10 @@ struct dmabuf_cmsg {
 */
 };
 
+struct dmabuf_token {
+   __u32 token_start;
+   __u32 token_count;
+};
 /*
  * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
  */
diff --git a/net/core/sock.c b/net/core/sock.c
index 69baddcfbd8c1..41586277c8dbb 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -124,6 +124,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1049,6 +1050,62 @@ static int sock_reserve_memory(struct sock *sk, int 
bytes)
return 0;
 }
 
+#ifdef CONFIG_PAGE_POOL
+static noinline_for_stack int
+sock_devmem_dontneed(struct sock *sk, sockptr_t optval, unsigned int optlen)
+{
+   unsigned int num_tokens, i, j, k, netmem_num = 0;
+   struct dmabuf_token *tokens;
+   netmem_ref netmems[16];
+   int ret = 0;
+
+   if (sk->sk_type != SOCK_STREAM || sk->sk_protocol != IPPROTO_TCP)
+   return -EBADF;
+
+   if (optlen % sizeof(struct dmabuf_token) ||
+   optlen > sizeof(*tokens) * 128)
+   return -EINVAL;
+
+   tokens = kvmalloc_array(128, sizeof(*tokens), GFP_KERNEL);
+   if (!tokens)
+   return -ENOMEM;
+
+   num_tokens = optlen / sizeof(struct dmabuf_token);
+   if (copy_from_sockptr(tokens, optval, optlen)) {
+   kvfree(tokens);
+   return -EFAULT;
+   }
+
+   xa_lock_bh(&sk->sk_user_frags);
+   for (i = 0; i < num_tokens; 

[PATCH net-next v11 07/13] memory-provider: dmabuf devmem memory provider

2024-06-06 Thread Mina Almasry
Implement a memory provider that allocates dmabuf devmem in the form of
net_iov.

The provider receives a reference to the struct netdev_dmabuf_binding
via the pool->mp_priv pointer. The driver needs to set this pointer for
the provider in the net_iov.

The provider obtains a reference on the netdev_dmabuf_binding which
guarantees the binding and the underlying mapping remains alive until
the provider is destroyed.

Usage of PP_FLAG_DMA_MAP is required for this memory provide such that
the page_pool can provide the driver with the dma-addrs of the devmem.

Support for PP_FLAG_DMA_SYNC_DEV is omitted for simplicity & p.order !=
0.

Signed-off-by: Willem de Bruijn 
Signed-off-by: Kaiyuan Zhang 
Signed-off-by: Mina Almasry 

---

v11:
- Rebase to not use the ops. (Christoph)

v8:
- Use skb_frag_size instead of frag->bv_len to fix patch-by-patch build
  error

v6:
- refactor new memory provider functions into net/core/devmem.c (Pavel)

v2:
- Disable devmem for p.order != 0

v1:
- static_branch check in page_is_page_pool_iov() (Willem & Paolo).
- PP_DEVMEM -> PP_IOV (David).
- Require PP_FLAG_DMA_MAP (Jakub).

---
 include/net/mp_dmabuf_devmem.h  | 46 
 include/net/netmem.h| 15 +++
 include/net/page_pool/helpers.h | 22 ++
 include/net/page_pool/types.h   |  2 +
 net/core/devmem.c   | 76 +
 net/core/page_pool.c| 70 +++---
 6 files changed, 205 insertions(+), 26 deletions(-)
 create mode 100644 include/net/mp_dmabuf_devmem.h

diff --git a/include/net/mp_dmabuf_devmem.h b/include/net/mp_dmabuf_devmem.h
new file mode 100644
index 0..7d290f3ad20bd
--- /dev/null
+++ b/include/net/mp_dmabuf_devmem.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Dmabuf device memory provider.
+ *
+ * Authors:Mina Almasry 
+ *
+ */
+#ifndef _NET_MP_DMABUF_DEVMEM_H
+#define _NET_MP_DMABUF_DEVMEM_H
+
+#include 
+
+#if defined(CONFIG_DMA_SHARED_BUFFER) && defined(CONFIG_GENERIC_ALLOCATOR)
+int mp_dmabuf_devmem_init(struct page_pool *pool);
+
+netmem_ref mp_dmabuf_devmem_alloc_netmems(struct page_pool *pool,
+gfp_t gfp);
+
+void mp_dmabuf_devmem_destroy(struct page_pool *pool);
+
+bool mp_dmabuf_devmem_release_page(struct page_pool *pool,
+ netmem_ref netmem);
+#else
+static inline int mp_dmabuf_devmem_init(struct page_pool *pool)
+{
+   return -EOPNOTSUPP;
+}
+
+static inline netmem_ref mp_dmabuf_devmem_alloc_netmems(struct page_pool *pool,
+gfp_t gfp)
+{
+   return 0;
+}
+
+static inline void mp_dmabuf_devmem_destroy(struct page_pool *pool)
+{
+}
+
+static inline bool mp_dmabuf_devmem_release_page(struct page_pool *pool,
+ netmem_ref netmem)
+{
+   return false;
+}
+#endif
+
+#endif /* _NET_MP_DMABUF_DEVMEM_H */
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 35ad237fdf29e..7c28d6fac6242 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -100,6 +100,21 @@ static inline struct page *netmem_to_page(netmem_ref 
netmem)
return (__force struct page *)netmem;
 }
 
+static inline struct net_iov *netmem_to_net_iov(netmem_ref netmem)
+{
+   if (netmem_is_net_iov(netmem))
+   return (struct net_iov *)((__force unsigned long)netmem &
+ ~NET_IOV);
+
+   DEBUG_NET_WARN_ON_ONCE(true);
+   return NULL;
+}
+
+static inline netmem_ref net_iov_to_netmem(struct net_iov *niov)
+{
+   return (__force netmem_ref)((unsigned long)niov | NET_IOV);
+}
+
 static inline netmem_ref page_to_netmem(struct page *page)
 {
return (__force netmem_ref)page;
diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index 1770c7be24afc..731f2d1e1ee10 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -477,4 +477,26 @@ static inline void page_pool_nid_changed(struct page_pool 
*pool, int new_nid)
page_pool_update_nid(pool, new_nid);
 }
 
+static inline void page_pool_set_pp_info(struct page_pool *pool,
+netmem_ref netmem)
+{
+   netmem_set_pp(netmem, pool);
+   netmem_or_pp_magic(netmem, PP_SIGNATURE);
+
+   /* Ensuring all pages have been split into one fragment initially:
+* page_pool_set_pp_info() is only called once for every page when it
+* is allocated from the page allocator and page_pool_fragment_page()
+* is dirtying the same cache line as the page->pp_magic above, so
+* the overhead is negligible.
+*/
+   page_pool_fragment_netmem(netmem, 1);
+   if (pool->has_init_callback)
+   pool->slow.init_callback(netmem, pool->slow.init_arg);
+}
+
+static inline void page_pool_clear_pp_info(netmem_ref netmem)
+{
+   netmem_clear_pp_m

[PATCH net-next v11 08/13] net: support non paged skb frags

2024-06-06 Thread Mina Almasry
Make skb_frag_page() fail in the case where the frag is not backed
by a page, and fix its relevant callers to handle this case.

Signed-off-by: Mina Almasry 


---

v10:
- Fixed newly generated kdoc warnings found by patchwork. While we're
  at it, fix the Return section of the functions I touched.

v6:
- Rebased on top of the merged netmem changes.

Changes in v1:
- Fix illegal_highdma() (Yunsheng).
- Rework napi_pp_put_page() slightly to reduce code churn (Willem).

---
 include/linux/skbuff.h | 42 +-
 include/linux/skbuff_ref.h |  9 
 net/core/dev.c |  3 ++-
 net/core/gro.c |  3 ++-
 net/core/skbuff.c  | 11 ++
 net/ipv4/esp4.c|  3 ++-
 net/ipv4/tcp.c |  3 +++
 net/ipv6/esp6.c|  3 ++-
 8 files changed, 67 insertions(+), 10 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index fe7d8dbef77e1..0a4df0025e6dc 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3492,21 +3492,58 @@ static inline void skb_frag_off_copy(skb_frag_t *fragto,
fragto->offset = fragfrom->offset;
 }
 
+/* Return: true if the skb_frag contains a net_iov. */
+static inline bool skb_frag_is_net_iov(const skb_frag_t *frag)
+{
+   return netmem_is_net_iov(frag->netmem);
+}
+
+/**
+ * skb_frag_net_iov - retrieve the net_iov referred to by fragment
+ * @frag: the fragment
+ *
+ * Return: the &struct net_iov associated with @frag. Returns NULL if this
+ * frag has no associated net_iov.
+ */
+static inline struct net_iov *skb_frag_net_iov(const skb_frag_t *frag)
+{
+   if (!skb_frag_is_net_iov(frag))
+   return NULL;
+
+   return netmem_to_net_iov(frag->netmem);
+}
+
 /**
  * skb_frag_page - retrieve the page referred to by a paged fragment
  * @frag: the paged fragment
  *
- * Returns the &struct page associated with @frag.
+ * Return: the &struct page associated with @frag. Returns NULL if this frag
+ * has no associated page.
  */
 static inline struct page *skb_frag_page(const skb_frag_t *frag)
 {
+   if (skb_frag_is_net_iov(frag))
+   return NULL;
+
return netmem_to_page(frag->netmem);
 }
 
+/**
+ * skb_frag_netmem - retrieve the netmem referred to by a fragment
+ * @frag: the fragment
+ *
+ * Return: the &netmem_ref associated with @frag.
+ */
+static inline netmem_ref skb_frag_netmem(const skb_frag_t *frag)
+{
+   return frag->netmem;
+}
+
 int skb_pp_cow_data(struct page_pool *pool, struct sk_buff **pskb,
unsigned int headroom);
 int skb_cow_data_for_xdp(struct page_pool *pool, struct sk_buff **pskb,
 struct bpf_prog *prog);
+
 /**
  * skb_frag_address - gets the address of the data contained in a paged 
fragment
  * @frag: the paged fragment buffer
@@ -3516,6 +3553,9 @@ int skb_cow_data_for_xdp(struct page_pool *pool, struct 
sk_buff **pskb,
  */
 static inline void *skb_frag_address(const skb_frag_t *frag)
 {
+   if (!skb_frag_page(frag))
+   return NULL;
+
return page_address(skb_frag_page(frag)) + skb_frag_off(frag);
 }
 
diff --git a/include/linux/skbuff_ref.h b/include/linux/skbuff_ref.h
index 16c241a234728..0f3c58007488a 100644
--- a/include/linux/skbuff_ref.h
+++ b/include/linux/skbuff_ref.h
@@ -34,14 +34,13 @@ static inline void skb_frag_ref(struct sk_buff *skb, int f)
 
 bool napi_pp_put_page(netmem_ref netmem);
 
-static inline void
-skb_page_unref(struct page *page, bool recycle)
+static inline void skb_page_unref(netmem_ref netmem, bool recycle)
 {
 #ifdef CONFIG_PAGE_POOL
-   if (recycle && napi_pp_put_page(page_to_netmem(page)))
+   if (recycle && napi_pp_put_page(netmem))
return;
 #endif
-   put_page(page);
+   put_page(netmem_to_page(netmem));
 }
 
 /**
@@ -54,7 +53,7 @@ skb_page_unref(struct page *page, bool recycle)
  */
 static inline void __skb_frag_unref(skb_frag_t *frag, bool recycle)
 {
-   skb_page_unref(skb_frag_page(frag), recycle);
+   skb_page_unref(skb_frag_netmem(frag), recycle);
 }
 
 /**
diff --git a/net/core/dev.c b/net/core/dev.c
index 25faa1fd64fc1..9fd81cf68350f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3432,8 +3432,9 @@ static int illegal_highdma(struct net_device *dev, struct 
sk_buff *skb)
if (!(dev->features & NETIF_F_HIGHDMA)) {
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+   struct page *page = skb_frag_page(frag);
 
-   if (PageHighMem(skb_frag_page(frag)))
+   if (page && PageHighMem(page))
return 1;
}
}
diff --git a/net/core/gro.c b/net/core/gro.c
index b3b43de1a6502..26f09c3e830b7 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -408,7 +408,8 @@ static inline void skb_gro_reset_offset(struct sk_buff 
*skb, u32 nhoff)
pinfo = 

[PATCH net-next v11 10/13] tcp: RX path for devmem TCP

2024-06-06 Thread Mina Almasry
In tcp_recvmsg_locked(), detect if the skb being received by the user
is a devmem skb. In this case - if the user provided the MSG_SOCK_DEVMEM
flag - pass it to tcp_recvmsg_devmem() for custom handling.

tcp_recvmsg_devmem() copies any data in the skb header to the linear
buffer, and returns a cmsg to the user indicating the number of bytes
returned in the linear buffer.

tcp_recvmsg_devmem() then loops over the unaccessible devmem skb frags,
and returns to the user a cmsg_devmem indicating the location of the
data in the dmabuf device memory. cmsg_devmem contains this information:

1. the offset into the dmabuf where the payload starts. 'frag_offset'.
2. the size of the frag. 'frag_size'.
3. an opaque token 'frag_token' to return to the kernel when the buffer
is to be released.

The pages awaiting freeing are stored in the newly added
sk->sk_user_frags, and each page passed to userspace is get_page()'d.
This reference is dropped once the userspace indicates that it is
done reading this page.  All pages are released when the socket is
destroyed.

Signed-off-by: Willem de Bruijn 
Signed-off-by: Kaiyuan Zhang 
Signed-off-by: Mina Almasry 

---

v11:
- Refactor to common function te remove conditional lock sparse warning
  (Paolo)

v7:
- Updated the SO_DEVMEM_* uapi to use the next available entries (Arnd).
- Updated dmabuf_cmsg struct to be __u64 padded (Arnd).
- Squashed fix from Eric to initialize sk_user_frags for passive
  sockets (Eric).

v6
- skb->dmabuf -> skb->readable (Pavel)
- Fixed asm definitions of SO_DEVMEM_LINEAR/SO_DEVMEM_DMABUF not found
  on some archs.
- Squashed in locking optimizations from eduma...@google.com. With this
  change we lock the xarray once per per tcp_recvmsg_dmabuf() rather
  than once per frag in xa_alloc().

Changes in v1:
- Added dmabuf_id to dmabuf_cmsg (David/Stan).
- Devmem -> dmabuf (David).
- Change tcp_recvmsg_dmabuf() check to skb->dmabuf (Paolo).
- Use __skb_frag_ref() & napi_pp_put_page() for refcounting (Yunsheng).

RFC v3:
- Fixed issue with put_cmsg() failing silently.

---
 arch/alpha/include/uapi/asm/socket.h  |   5 +
 arch/mips/include/uapi/asm/socket.h   |   5 +
 arch/parisc/include/uapi/asm/socket.h |   5 +
 arch/sparc/include/uapi/asm/socket.h  |   5 +
 include/linux/socket.h|   1 +
 include/net/netmem.h  |  13 ++
 include/net/sock.h|   2 +
 include/uapi/asm-generic/socket.h |   5 +
 include/uapi/linux/uio.h  |  13 ++
 net/ipv4/tcp.c| 255 +-
 net/ipv4/tcp_ipv4.c   |  10 +
 net/ipv4/tcp_minisocks.c  |   2 +
 12 files changed, 316 insertions(+), 5 deletions(-)

diff --git a/arch/alpha/include/uapi/asm/socket.h 
b/arch/alpha/include/uapi/asm/socket.h
index e94f621903fee..ef4656a41058a 100644
--- a/arch/alpha/include/uapi/asm/socket.h
+++ b/arch/alpha/include/uapi/asm/socket.h
@@ -140,6 +140,11 @@
 #define SO_PASSPIDFD   76
 #define SO_PEERPIDFD   77
 
+#define SO_DEVMEM_LINEAR   78
+#define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
+#define SO_DEVMEM_DMABUF   79
+#define SCM_DEVMEM_DMABUF  SO_DEVMEM_DMABUF
+
 #if !defined(__KERNEL__)
 
 #if __BITS_PER_LONG == 64
diff --git a/arch/mips/include/uapi/asm/socket.h 
b/arch/mips/include/uapi/asm/socket.h
index 60ebaed28a4ca..414807d55e33f 100644
--- a/arch/mips/include/uapi/asm/socket.h
+++ b/arch/mips/include/uapi/asm/socket.h
@@ -151,6 +151,11 @@
 #define SO_PASSPIDFD   76
 #define SO_PEERPIDFD   77
 
+#define SO_DEVMEM_LINEAR   78
+#define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
+#define SO_DEVMEM_DMABUF   79
+#define SCM_DEVMEM_DMABUF  SO_DEVMEM_DMABUF
+
 #if !defined(__KERNEL__)
 
 #if __BITS_PER_LONG == 64
diff --git a/arch/parisc/include/uapi/asm/socket.h 
b/arch/parisc/include/uapi/asm/socket.h
index be264c2b1a117..2b817efd45444 100644
--- a/arch/parisc/include/uapi/asm/socket.h
+++ b/arch/parisc/include/uapi/asm/socket.h
@@ -132,6 +132,11 @@
 #define SO_PASSPIDFD   0x404A
 #define SO_PEERPIDFD   0x404B
 
+#define SO_DEVMEM_LINEAR   78
+#define SCM_DEVMEM_LINEAR  SO_DEVMEM_LINEAR
+#define SO_DEVMEM_DMABUF   79
+#define SCM_DEVMEM_DMABUF  SO_DEVMEM_DMABUF
+
 #if !defined(__KERNEL__)
 
 #if __BITS_PER_LONG == 64
diff --git a/arch/sparc/include/uapi/asm/socket.h 
b/arch/sparc/include/uapi/asm/socket.h
index 682da3714686c..00248fc689773 100644
--- a/arch/sparc/include/uapi/asm/socket.h
+++ b/arch/sparc/include/uapi/asm/socket.h
@@ -133,6 +133,11 @@
 #define SO_PASSPIDFD 0x0055
 #define SO_PEERPIDFD 0x0056
 
+#define SO_DEVMEM_LINEAR 0x0057
+#define SCM_DEVMEM_LINEARSO_DEVMEM_LINEAR
+#define SO_DEVMEM_DMABUF 0x0058
+#define SCM_DEVMEM_DMABUFSO_DEVMEM_DMABUF
+
 #if !defined(__KERNEL__)
 
 
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 89d16b90370bd..b0defc2ea40ed 100644
--- a/include/linux/socket.h
+++ b/inc

[PATCH net-next v11 09/13] net: add support for skbs with unreadable frags

2024-06-06 Thread Mina Almasry
For device memory TCP, we expect the skb headers to be available in host
memory for access, and we expect the skb frags to be in device memory
and unaccessible to the host. We expect there to be no mixing and
matching of device memory frags (unaccessible) with host memory frags
(accessible) in the same skb.

Add a skb->devmem flag which indicates whether the frags in this skb
are device memory frags or not.

__skb_fill_netmem_desc() now checks frags added to skbs for net_iov,
and marks the skb as skb->devmem accordingly.

Add checks through the network stack to avoid accessing the frags of
devmem skbs and avoid coalescing devmem skbs with non devmem skbs.

Signed-off-by: Willem de Bruijn 
Signed-off-by: Kaiyuan Zhang 
Signed-off-by: Mina Almasry 


---

v11:
- drop excessive checks for frag 0 pull (Paolo)

v9: 
https://lore.kernel.org/netdev/20240403002053.2376017-11-almasrym...@google.com/
- change skb->readable to skb->unreadable (Pavel/David).

skb->readable was very complicated, because by default skbs are readable
so the flag needed to be set to true in all code paths where new skbs
were created or cloned. Forgetting to set skb->readable=true in some
paths caused crashes.

Flip it to skb->unreadable so that the default 0 value works well, and
we only need to set it to true when we add unreadable frags.

v6
- skb->dmabuf -> skb->readable (Pavel). Pavel's original suggestion was
  to remove the skb->dmabuf flag entirely, but when I looked into it
  closely, I found the issue that if we remove the flag we have to
  dereference the shinfo(skb) pointer to obtain the first frag, which
  can cause a performance regression if it dirties the cache line when
  the shinfo(skb) was not really needed. Instead, I converted the
  skb->dmabuf flag into a generic skb->readable flag which can be
  re-used by io_uring.

Changes in v1:
- Rename devmem -> dmabuf (David).
- Flip skb_frags_not_readable (Jakub).

---
 include/linux/skbuff.h | 19 +++--
 include/net/tcp.h  |  5 +++--
 net/core/datagram.c|  6 ++
 net/core/skbuff.c  | 48 --
 net/ipv4/tcp.c |  3 +++
 net/ipv4/tcp_input.c   | 13 +---
 net/ipv4/tcp_output.c  |  5 -
 net/packet/af_packet.c |  4 ++--
 8 files changed, 91 insertions(+), 12 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0a4df0025e6dc..9c9be08f96aa7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -827,6 +827,8 @@ enum skb_tstamp_type {
  * @csum_level: indicates the number of consecutive checksums found in
  * the packet minus one that have been verified as
  * CHECKSUM_UNNECESSARY (max 3)
+ * @unreadable: indicates that at least 1 of the fragments in this skb is
+ * unreadable.
  * @dst_pending_confirm: need to confirm neighbour
  * @decrypted: Decrypted SKB
  * @slow_gro: state present at GRO time, slower prepare step required
@@ -1008,7 +1010,7 @@ struct sk_buff {
 #if IS_ENABLED(CONFIG_IP_SCTP)
__u8csum_not_inet:1;
 #endif
-
+   __u8unreadable:1;
 #if defined(CONFIG_NET_SCHED) || defined(CONFIG_NET_XGRESS)
__u16   tc_index;   /* traffic control index */
 #endif
@@ -1800,6 +1802,12 @@ static inline void skb_zcopy_downgrade_managed(struct 
sk_buff *skb)
__skb_zcopy_downgrade_managed(skb);
 }
 
+/* Return true if frags in this skb are readable by the host. */
+static inline bool skb_frags_readable(const struct sk_buff *skb)
+{
+   return !skb->unreadable;
+}
+
 static inline void skb_mark_not_on_list(struct sk_buff *skb)
 {
skb->next = NULL;
@@ -2516,10 +2524,17 @@ static inline void skb_len_add(struct sk_buff *skb, int 
delta)
 static inline void __skb_fill_netmem_desc(struct sk_buff *skb, int i,
  netmem_ref netmem, int off, int size)
 {
-   struct page *page = netmem_to_page(netmem);
+   struct page *page;
 
__skb_fill_netmem_desc_noacc(skb_shinfo(skb), i, netmem, off, size);
 
+   if (netmem_is_net_iov(netmem)) {
+   skb->unreadable = true;
+   return;
+   }
+
+   page = netmem_to_page(netmem);
+
/* Propagate page pfmemalloc to the skb if we can. The problem is
 * that not all callers have unique ownership of the page but rely
 * on page_is_pfmemalloc doing the right thing(tm).
diff --git a/include/net/tcp.h b/include/net/tcp.h
index a70fc39090fe8..f74f50a45f14e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1060,7 +1060,7 @@ static inline int tcp_skb_mss(const struct sk_buff *skb)
 
 static inline bool tcp_skb_can_collapse_to(const struct sk_buff *skb)
 {
-   return likely(!TCP_SKB_CB(skb)->eor);
+   return likely(!TCP_SKB_CB(skb)->eor && skb_frags_readable(skb));
 }
 
 static inline bool tcp_skb_can_collapse(const struct sk_buff *to,
@@ -1069,7 +1069,8 @@ static 

[PATCH net-next v11 05/13] page_pool: convert to use netmem

2024-06-06 Thread Mina Almasry
Abstrace the memory type from the page_pool so we can later add support
for new memory types. Convert the page_pool to use the new netmem type
abstraction, rather than use struct page directly.

As of this patch the netmem type is a no-op abstraction: it's always a
struct page underneath. All the page pool internals are converted to
use struct netmem instead of struct page, and the page pool now exports
2 APIs:

1. The existing struct page API.
2. The new struct netmem API.

Keeping the existing API is transitional; we do not want to refactor all
the current drivers using the page pool at once.

The netmem abstraction is currently a no-op. The page_pool uses
page_to_netmem() to convert allocated pages to netmem, and uses
netmem_to_page() to convert the netmem back to pages to pass to mm APIs,

Follow up patches to this series add non-paged netmem support to the
page_pool. This change is factored out on its own to limit the code
churn to this 1 patch, for ease of code review.

Signed-off-by: Mina Almasry 

---

v11:
- Fix typing to remove sparse warning. (Paolo/Steven)

v9:
- Fix sparse error (Simon).

v8:
- Fix napi_pp_put_page() taking netmem instead of page to fix
  patch-by-patch build error.
- Add net/netmem.h include in this patch to fix patch-by-patch build
  error.

v6:

- Rebased on top of the merged netmem_ref type.

Cc: linux...@kvack.org
Cc: Matthew Wilcox 


---
 include/linux/skbuff_ref.h   |   4 +-
 include/net/netmem.h |  15 ++
 include/net/page_pool/helpers.h  | 120 
 include/net/page_pool/types.h|  14 +-
 include/trace/events/page_pool.h |  29 +--
 net/bpf/test_run.c   |   5 +-
 net/core/page_pool.c | 304 +--
 net/core/skbuff.c|   8 +-
 8 files changed, 301 insertions(+), 198 deletions(-)

diff --git a/include/linux/skbuff_ref.h b/include/linux/skbuff_ref.h
index 11f0a40634033..16c241a234728 100644
--- a/include/linux/skbuff_ref.h
+++ b/include/linux/skbuff_ref.h
@@ -32,13 +32,13 @@ static inline void skb_frag_ref(struct sk_buff *skb, int f)
__skb_frag_ref(&skb_shinfo(skb)->frags[f]);
 }
 
-bool napi_pp_put_page(struct page *page);
+bool napi_pp_put_page(netmem_ref netmem);
 
 static inline void
 skb_page_unref(struct page *page, bool recycle)
 {
 #ifdef CONFIG_PAGE_POOL
-   if (recycle && napi_pp_put_page(page))
+   if (recycle && napi_pp_put_page(page_to_netmem(page)))
return;
 #endif
put_page(page);
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 01dbdd216fae7..664df8325ece5 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -66,4 +66,19 @@ static inline netmem_ref page_to_netmem(struct page *page)
return (__force netmem_ref)page;
 }
 
+static inline int netmem_ref_count(netmem_ref netmem)
+{
+   return page_ref_count(netmem_to_page(netmem));
+}
+
+static inline unsigned long netmem_to_pfn(netmem_ref netmem)
+{
+   return page_to_pfn(netmem_to_page(netmem));
+}
+
+static inline netmem_ref netmem_compound_head(netmem_ref netmem)
+{
+   return page_to_netmem(compound_head(netmem_to_page(netmem)));
+}
+
 #endif /* _NET_NETMEM_H */
diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index 873631c79ab16..5e129d5304f53 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -55,6 +55,8 @@
 #include 
 
 #include 
+#include 
+#include 
 
 #ifdef CONFIG_PAGE_POOL_STATS
 /* Deprecated driver-facing API, use netlink instead */
@@ -103,7 +105,7 @@ static inline struct page *page_pool_dev_alloc_pages(struct 
page_pool *pool)
  * Get a page fragment from the page allocator or page_pool caches.
  *
  * Return:
- * Return allocated page fragment, otherwise return NULL.
+ * Return allocated page fragment, otherwise return 0.
  */
 static inline struct page *page_pool_dev_alloc_frag(struct page_pool *pool,
unsigned int *offset,
@@ -114,22 +116,22 @@ static inline struct page 
*page_pool_dev_alloc_frag(struct page_pool *pool,
return page_pool_alloc_frag(pool, offset, size, gfp);
 }
 
-static inline struct page *page_pool_alloc(struct page_pool *pool,
-  unsigned int *offset,
-  unsigned int *size, gfp_t gfp)
+static inline netmem_ref page_pool_alloc(struct page_pool *pool,
+unsigned int *offset,
+unsigned int *size, gfp_t gfp)
 {
unsigned int max_size = PAGE_SIZE << pool->p.order;
-   struct page *page;
+   netmem_ref netmem;
 
if ((*size << 1) > max_size) {
*size = max_size;
*offset = 0;
-   return page_pool_alloc_pages(pool, gfp);
+   return page_pool_alloc_netmem(pool, gfp);
}
 
-   page = page_pool_alloc_frag(pool, offset, *size, gfp);
-   if (unlikel

[PATCH net-next v11 06/13] page_pool: devmem support

2024-06-06 Thread Mina Almasry
Convert netmem to be a union of struct page and struct netmem. Overload
the LSB of struct netmem* to indicate that it's a net_iov, otherwise
it's a page.

Currently these entries in struct page are rented by the page_pool and
used exclusively by the net stack:

struct {
unsigned long pp_magic;
struct page_pool *pp;
unsigned long _pp_mapping_pad;
unsigned long dma_addr;
atomic_long_t pp_ref_count;
};

Mirror these (and only these) entries into struct net_iov and implement
netmem helpers that can access these common fields regardless of
whether the underlying type is page or net_iov.

Implement checks for net_iov in netmem helpers which delegate to mm
APIs, to ensure net_iov are never passed to the mm stack.

Signed-off-by: Mina Almasry 

---

v9: 
https://lore.kernel.org/netdev/20240403002053.2376017-8-almasrym...@google.com/
- Remove CONFIG checks in netmem_is_net_iov() (Pavel/David/Jens)

v7:
- Remove static_branch_unlikely from netmem_to_net_iov(). We're getting
  better results from the fast path in bench_page_pool_simple tests
  without the static_branch_unlikely, and the addition of
  static_branch_unlikely doesn't improve performance of devmem TCP.

  Additionally only check netmem_to_net_iov() if
  CONFIG_DMA_SHARED_BUFFER is enabled, otherwise dmabuf net_iovs cannot
  exist anyway.

  net-next base: 8 cycle fast path.
  with static_branch_unlikely: 10 cycle fast path.
  without static_branch_unlikely: 9 cycle fast path.
  CONFIG_DMA_SHARED_BUFFER disabled: 8 cycle fast path as baseline.

  Performance of devmem TCP is at 95% line rate is regardless of
  static_branch_unlikely or not.

v6:
- Rebased on top of the merged netmem_ref type.
- Rebased on top of the merged skb_pp_frag_ref() changes.

v5:
- Use netmem instead of page* with LSB set.
- Use pp_ref_count for refcounting net_iov.
- Removed many of the custom checks for netmem.

v1:
- Disable fragmentation support for iov properly.
- fix napi_pp_put_page() path (Yunsheng).
- Use pp_frag_count for devmem refcounting.

Cc: linux...@kvack.org
Cc: Matthew Wilcox 

---
 include/net/netmem.h| 137 ++--
 include/net/page_pool/helpers.h |  25 +++---
 net/core/devmem.c   |   3 +
 net/core/page_pool.c|  26 +++---
 net/core/skbuff.c   |  22 +++--
 5 files changed, 168 insertions(+), 45 deletions(-)

diff --git a/include/net/netmem.h b/include/net/netmem.h
index 664df8325ece5..35ad237fdf29e 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -9,14 +9,51 @@
 #define _NET_NETMEM_H
 
 #include 
+#include 
 
 /* net_iov */
 
+DECLARE_STATIC_KEY_FALSE(page_pool_mem_providers);
+
+/*  We overload the LSB of the struct page pointer to indicate whether it's
+ *  a page or net_iov.
+ */
+#define NET_IOV 0x01UL
+
 struct net_iov {
+   unsigned long __unused_padding;
+   unsigned long pp_magic;
+   struct page_pool *pp;
struct dmabuf_genpool_chunk_owner *owner;
unsigned long dma_addr;
+   atomic_long_t pp_ref_count;
 };
 
+/* These fields in struct page are used by the page_pool and net stack:
+ *
+ * struct {
+ * unsigned long pp_magic;
+ * struct page_pool *pp;
+ * unsigned long _pp_mapping_pad;
+ * unsigned long dma_addr;
+ * atomic_long_t pp_ref_count;
+ * };
+ *
+ * We mirror the page_pool fields here so the page_pool can access these fields
+ * without worrying whether the underlying fields belong to a page or net_iov.
+ *
+ * The non-net stack fields of struct page are private to the mm stack and must
+ * never be mirrored to net_iov.
+ */
+#define NET_IOV_ASSERT_OFFSET(pg, iov) \
+   static_assert(offsetof(struct page, pg) == \
+ offsetof(struct net_iov, iov))
+NET_IOV_ASSERT_OFFSET(pp_magic, pp_magic);
+NET_IOV_ASSERT_OFFSET(pp, pp);
+NET_IOV_ASSERT_OFFSET(dma_addr, dma_addr);
+NET_IOV_ASSERT_OFFSET(pp_ref_count, pp_ref_count);
+#undef NET_IOV_ASSERT_OFFSET
+
 static inline struct dmabuf_genpool_chunk_owner *
 net_iov_owner(const struct net_iov *niov)
 {
@@ -47,20 +84,22 @@ net_iov_binding(const struct net_iov *niov)
  */
 typedef unsigned long __bitwise netmem_ref;
 
+static inline bool netmem_is_net_iov(const netmem_ref netmem)
+{
+   return (__force unsigned long)netmem & NET_IOV;
+}
+
 /* This conversion fails (returns NULL) if the netmem_ref is not struct page
  * backed.
- *
- * Currently struct page is the only possible netmem, and this helper never
- * fails.
  */
 static inline struct page *netmem_to_page(netmem_ref netmem)
 {
+   if (WARN_ON_ONCE(netmem_is_net_iov(netmem)))
+   return NULL;
+
return (__force struct page *)netmem;
 }
 
-/* Converting from page to netmem is always safe, because a page can always be
- * a netmem.
- */
 static inline netmem_ref page_to_netmem(struct page *page)
 {
return (__force netmem_ref)page;
@@ -68,17 +107,103 @@ static i

[PATCH net-next v11 03/13] netdev: support binding dma-buf to netdevice

2024-06-06 Thread Mina Almasry
Add a netdev_dmabuf_binding struct which represents the
dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to
rx queues on the netdevice. On the binding, the dma_buf_attach
& dma_buf_map_attachment will occur. The entries in the sg_table from
mapping will be inserted into a genpool to make it ready
for allocation.

The chunks in the genpool are owned by a dmabuf_chunk_owner struct which
holds the dma-buf offset of the base of the chunk and the dma_addr of
the chunk. Both are needed to use allocations that come from this chunk.

We create a new type that represents an allocation from the genpool:
net_iov. We setup the net_iov allocation size in the
genpool to PAGE_SIZE for simplicity: to match the PAGE_SIZE normally
allocated by the page pool and given to the drivers.

The user can unbind the dmabuf from the netdevice by closing the netlink
socket that established the binding. We do this so that the binding is
automatically unbound even if the userspace process crashes.

The binding and unbinding leaves an indicator in struct netdev_rx_queue
that the given queue is bound, but the binding doesn't take effect until
the driver actually reconfigures its queues, and re-initializes its page
pool.

The netdev_dmabuf_binding struct is refcounted, and releases its
resources only when all the refs are released.

Signed-off-by: Willem de Bruijn 
Signed-off-by: Kaiyuan Zhang 
Signed-off-by: Mina Almasry 

---

v11:
- Fix build error with CONFIG_DMA_SHARED_BUFFER &&
  !CONFIG_GENERIC_ALLOCATOR
- Rebased on top of no memory provider ops.

v10:
- Moved net_iov_dma_addr() to devmem.h and made it devmem specific
  helper (David).

v9: https://lore.kernel.org/all/20240403002053.2376017-5-almasrym...@google.com/
- Removed net_devmem_restart_rx_queues and put it in its own patch
  (David).

v8:
- move dmabuf_devmem_ops usage to later patch to avoid patch-by-patch
  build error.

v7:
- Use IS_ERR() instead of IS_ERR_OR_NULL() for the dma_buf_get() return
  value.
- Changes netdev_* naming in devmem.c to net_devmem_* (Yunsheng).
- DMA_BIDIRECTIONAL -> DMA_FROM_DEVICE (Yunsheng).
- Added a comment around recovering of the old rx queue in
  net_devmem_restart_rx_queue(), and added freeing of old_mem if the
  restart of the old queue fails. (Yunsheng).
- Use kernel-family sock-priv (Jakub).
- Put pp_memory_provider_params in netdev_rx_queue instead of the
  dma-buf specific binding (Pavel & David).
- Move queue management ops to queue_mgmt_ops instead of netdev_ops
  (Jakub).
- Remove excess whitespaces (Jakub).
- Use genlmsg_iput (Jakub).

v6:
- Validate rx queue index
- Refactor new functions into devmem.c (Pavel)

v5:
- Renamed page_pool_iov to net_iov, and moved that support to devmem.h
  or netmem.h.

v1:
- Introduce devmem.h instead of bloating netdevice.h (Jakub)
- ENOTSUPP -> EOPNOTSUPP (checkpatch.pl I think)
- Remove unneeded rcu protection for binding->list (rtnl protected)
- Removed extraneous err_binding_put: label.
- Removed dma_addr += len (Paolo).
- Don't override err on netdev_bind_dmabuf_to_queue failure.
- Rename devmem -> dmabuf (David).
- Add id to dmabuf binding (David/Stan).
- Fix missing xa_destroy bound_rq_list.
- Use queue api to reset bound RX queues (Jakub).
- Update netlink API for rx-queue type (tx/re) (Jakub).

RFC v3:
- Support multi rx-queue binding

---
 Documentation/netlink/specs/netdev.yaml |   4 +
 include/net/devmem.h| 111 +++
 include/net/netdev_rx_queue.h   |   2 +
 include/net/netmem.h|  10 +
 include/net/page_pool/types.h   |   6 +
 net/core/Makefile   |   2 +-
 net/core/dev.c  |   3 +
 net/core/devmem.c   | 252 
 net/core/netdev-genl-gen.c  |   4 +
 net/core/netdev-genl-gen.h  |   4 +
 net/core/netdev-genl.c  | 101 +-
 11 files changed, 496 insertions(+), 3 deletions(-)
 create mode 100644 include/net/devmem.h
 create mode 100644 net/core/devmem.c

diff --git a/Documentation/netlink/specs/netdev.yaml 
b/Documentation/netlink/specs/netdev.yaml
index 899ac0882a098..d6d7cb01c145c 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -673,6 +673,10 @@ operations:
 - tx-packets
 - tx-bytes
 
+kernel-family:
+  headers: [ "linux/list.h"]
+  sock-priv: struct list_head
+
 mcast-groups:
   list:
 -
diff --git a/include/net/devmem.h b/include/net/devmem.h
new file mode 100644
index 0..eaf3fd965d7a8
--- /dev/null
+++ b/include/net/devmem.h
@@ -0,0 +1,111 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Device memory TCP support
+ *
+ * Authors:Mina Almasry 
+ * Willem de Bruijn 
+ * Kaiyuan Zhang 
+ *
+ */
+#ifndef _NET_DEVMEM_H
+#define _NET_DEVMEM_H
+
+struct net_devmem_dmabuf_binding {
+   struct dma_buf *dmabuf;
+   struct dma_buf_attachment *attach

[PATCH net-next v11 04/13] netdev: netdevice devmem allocator

2024-06-06 Thread Mina Almasry
Implement netdev devmem allocator. The allocator takes a given struct
netdev_dmabuf_binding as input and allocates net_iov from that
binding.

The allocation simply delegates to the binding's genpool for the
allocation logic and wraps the returned memory region in a net_iov
struct.

Signed-off-by: Willem de Bruijn 
Signed-off-by: Kaiyuan Zhang 
Signed-off-by: Mina Almasry 

---

v11:
- Fix extraneous inline directive (Paolo)

v8:
- Rename netdev_dmabuf_binding -> net_devmem_dmabuf_binding to avoid
  patch-by-patch build error.
- Move niov->pp_magic/pp/pp_ref_counter usage to later patch to avoid
  patch-by-patch build error.

v7:
- netdev_ -> net_devmem_* naming (Yunsheng).

v6:
- Add comment on net_iov_dma_addr to explain why we don't use
  niov->dma_addr (Pavel)
- Refactor new functions into net/core/devmem.c (Pavel)

v1:
- Rename devmem -> dmabuf (David).

---
 include/net/devmem.h | 13 +
 include/net/netmem.h | 18 ++
 net/core/devmem.c| 44 
 3 files changed, 75 insertions(+)

diff --git a/include/net/devmem.h b/include/net/devmem.h
index eaf3fd965d7a8..b65795a8f8f13 100644
--- a/include/net/devmem.h
+++ b/include/net/devmem.h
@@ -68,7 +68,20 @@ int net_devmem_bind_dmabuf(struct net_device *dev, unsigned 
int dmabuf_fd,
 void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding);
 int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx,
struct net_devmem_dmabuf_binding *binding);
+struct net_iov *
+net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding);
+void net_devmem_free_dmabuf(struct net_iov *ppiov);
 #else
+static inline struct net_iov *
+net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
+{
+   return NULL;
+}
+
+static inline void net_devmem_free_dmabuf(struct net_iov *ppiov)
+{
+}
+
 static inline void
 __net_devmem_dmabuf_binding_free(struct net_devmem_dmabuf_binding *binding)
 {
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 72e932a1a9489..01dbdd216fae7 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -14,8 +14,26 @@
 
 struct net_iov {
struct dmabuf_genpool_chunk_owner *owner;
+   unsigned long dma_addr;
 };
 
+static inline struct dmabuf_genpool_chunk_owner *
+net_iov_owner(const struct net_iov *niov)
+{
+   return niov->owner;
+}
+
+static inline unsigned int net_iov_idx(const struct net_iov *niov)
+{
+   return niov - net_iov_owner(niov)->niovs;
+}
+
+static inline struct net_devmem_dmabuf_binding *
+net_iov_binding(const struct net_iov *niov)
+{
+   return net_iov_owner(niov)->binding;
+}
+
 /* netmem */
 
 /**
diff --git a/net/core/devmem.c b/net/core/devmem.c
index 951a06004c430..b53ea67c020d3 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -32,6 +32,14 @@ static void net_devmem_dmabuf_free_chunk_owner(struct 
gen_pool *genpool,
kfree(owner);
 }
 
+static dma_addr_t net_devmem_get_dma_addr(const struct net_iov *niov)
+{
+   struct dmabuf_genpool_chunk_owner *owner = net_iov_owner(niov);
+
+   return owner->base_dma_addr +
+  ((dma_addr_t)net_iov_idx(niov) << PAGE_SHIFT);
+}
+
 void __net_devmem_dmabuf_binding_free(struct net_devmem_dmabuf_binding 
*binding)
 {
size_t size, avail;
@@ -54,6 +62,42 @@ void __net_devmem_dmabuf_binding_free(struct 
net_devmem_dmabuf_binding *binding)
kfree(binding);
 }
 
+struct net_iov *
+net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
+{
+   struct dmabuf_genpool_chunk_owner *owner;
+   unsigned long dma_addr;
+   struct net_iov *niov;
+   ssize_t offset;
+   ssize_t index;
+
+   dma_addr = gen_pool_alloc_owner(binding->chunk_pool, PAGE_SIZE,
+   (void **)&owner);
+   if (!dma_addr)
+   return NULL;
+
+   offset = dma_addr - owner->base_dma_addr;
+   index = offset / PAGE_SIZE;
+   niov = &owner->niovs[index];
+
+   niov->dma_addr = 0;
+
+   net_devmem_dmabuf_binding_get(binding);
+
+   return niov;
+}
+
+void net_devmem_free_dmabuf(struct net_iov *niov)
+{
+   struct net_devmem_dmabuf_binding *binding = net_iov_binding(niov);
+   unsigned long dma_addr = net_devmem_get_dma_addr(niov);
+
+   if (gen_pool_has_addr(binding->chunk_pool, dma_addr, PAGE_SIZE))
+   gen_pool_free(binding->chunk_pool, dma_addr, PAGE_SIZE);
+
+   net_devmem_dmabuf_binding_put(binding);
+}
+
 /* Protected by rtnl_lock() */
 static DEFINE_XARRAY_FLAGS(net_devmem_dmabuf_bindings, XA_FLAGS_ALLOC1);
 
-- 
2.45.2.505.gda0bf45e8d-goog



[PATCH net-next v11 02/13] net: netdev netlink api to bind dma-buf to a net device

2024-06-06 Thread Mina Almasry
API takes the dma-buf fd as input, and binds it to the netdevice. The
user can specify the rx queues to bind the dma-buf to.

Suggested-by: Stanislav Fomichev 
Signed-off-by: Mina Almasry 

---

v7:
- Use flags: [ admin-perm ] instead of a CAP_NET_ADMIN check.

Changes in v1:
- Add rx-queue-type to distingish rx from tx (Jakub)
- Return dma-buf ID from netlink API (David, Stan)

Changes in RFC-v3:
- Support binding multiple rx rx-queues

---
 Documentation/netlink/specs/netdev.yaml | 53 +
 include/uapi/linux/netdev.h | 19 +
 net/core/netdev-genl-gen.c  | 19 +
 net/core/netdev-genl-gen.h  |  2 +
 net/core/netdev-genl.c  |  6 +++
 tools/include/uapi/linux/netdev.h   | 19 +
 6 files changed, 118 insertions(+)

diff --git a/Documentation/netlink/specs/netdev.yaml 
b/Documentation/netlink/specs/netdev.yaml
index 959755be4d7f9..899ac0882a098 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -268,6 +268,45 @@ attribute-sets:
 name: napi-id
 doc: ID of the NAPI instance which services this queue.
 type: u32
+  -
+name: queue-dmabuf
+attributes:
+  -
+name: type
+doc: rx or tx queue
+type: u8
+enum: queue-type
+  -
+name: idx
+doc: queue index
+type: u32
+
+  -
+name: bind-dmabuf
+attributes:
+  -
+name: ifindex
+doc: netdev ifindex to bind the dma-buf to.
+type: u32
+checks:
+  min: 1
+  -
+name: queues
+doc: receive queues to bind the dma-buf to.
+type: nest
+nested-attributes: queue-dmabuf
+multi-attr: true
+  -
+name: dmabuf-fd
+doc: dmabuf file descriptor to bind.
+type: u32
+  -
+name: dmabuf-id
+doc: id of the dmabuf binding
+type: u32
+checks:
+  min: 1
+
 
   -
 name: qstats
@@ -579,6 +618,20 @@ operations:
   attributes:
 - ifindex
 reply: *queue-get-op
+-
+  name: bind-rx
+  doc: Bind dmabuf to netdev
+  attribute-set: bind-dmabuf
+  flags: [ admin-perm ]
+  do:
+request:
+  attributes:
+- ifindex
+- dmabuf-fd
+- queues
+reply:
+  attributes:
+- dmabuf-id
 -
   name: napi-get
   doc: Get information about NAPI instances configured on the system.
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index 43742ac5b00da..190a504a62358 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -136,6 +136,24 @@ enum {
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
 };
 
+enum {
+   NETDEV_A_QUEUE_DMABUF_TYPE = 1,
+   NETDEV_A_QUEUE_DMABUF_IDX,
+
+   __NETDEV_A_QUEUE_DMABUF_MAX,
+   NETDEV_A_QUEUE_DMABUF_MAX = (__NETDEV_A_QUEUE_DMABUF_MAX - 1)
+};
+
+enum {
+   NETDEV_A_BIND_DMABUF_IFINDEX = 1,
+   NETDEV_A_BIND_DMABUF_QUEUES,
+   NETDEV_A_BIND_DMABUF_DMABUF_FD,
+   NETDEV_A_BIND_DMABUF_DMABUF_ID,
+
+   __NETDEV_A_BIND_DMABUF_MAX,
+   NETDEV_A_BIND_DMABUF_MAX = (__NETDEV_A_BIND_DMABUF_MAX - 1)
+};
+
 enum {
NETDEV_A_QSTATS_IFINDEX = 1,
NETDEV_A_QSTATS_QUEUE_TYPE,
@@ -184,6 +202,7 @@ enum {
NETDEV_CMD_PAGE_POOL_CHANGE_NTF,
NETDEV_CMD_PAGE_POOL_STATS_GET,
NETDEV_CMD_QUEUE_GET,
+   NETDEV_CMD_BIND_RX,
NETDEV_CMD_NAPI_GET,
NETDEV_CMD_QSTATS_GET,
 
diff --git a/net/core/netdev-genl-gen.c b/net/core/netdev-genl-gen.c
index 8350a0afa9ec7..9acd0d893765a 100644
--- a/net/core/netdev-genl-gen.c
+++ b/net/core/netdev-genl-gen.c
@@ -27,6 +27,11 @@ const struct nla_policy 
netdev_page_pool_info_nl_policy[NETDEV_A_PAGE_POOL_IFIND
[NETDEV_A_PAGE_POOL_IFINDEX] = NLA_POLICY_FULL_RANGE(NLA_U32, 
&netdev_a_page_pool_ifindex_range),
 };
 
+const struct nla_policy 
netdev_queue_dmabuf_nl_policy[NETDEV_A_QUEUE_DMABUF_IDX + 1] = {
+   [NETDEV_A_QUEUE_DMABUF_TYPE] = NLA_POLICY_MAX(NLA_U8, 1),
+   [NETDEV_A_QUEUE_DMABUF_IDX] = { .type = NLA_U32, },
+};
+
 /* NETDEV_CMD_DEV_GET - do */
 static const struct nla_policy netdev_dev_get_nl_policy[NETDEV_A_DEV_IFINDEX + 
1] = {
[NETDEV_A_DEV_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
@@ -58,6 +63,13 @@ static const struct nla_policy 
netdev_queue_get_dump_nl_policy[NETDEV_A_QUEUE_IF
[NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
 };
 
+/* NETDEV_CMD_BIND_RX - do */
+static const struct nla_policy 
netdev_bind_rx_nl_policy[NETDEV_A_BIND_DMABUF_DMABUF_FD + 1] = {
+   [NETDEV_A_BIND_DMABUF_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
+   [NETDEV_A_BIND_DMABUF_DMABUF_FD] = { .type = NLA_U32, },
+   [NETDEV_A_BIND_DMABUF_QUEUES] = 
NLA_POLICY_NESTED(netdev_queue_dmabuf_nl_policy),
+};
+
 /* NETDEV_CMD_NAPI_GET - do */
 static const struct nla_policy netd

[PATCH net-next v11 01/13] netdev: add netdev_rx_queue_restart()

2024-06-06 Thread Mina Almasry
Add netdev_rx_queue_restart() function to netdev_rx_queue.h

Signed-off-by: David Wei 
Signed-off-by: Mina Almasry 

---

v11:
- Fix not checking dev->queue_mgmt_ops (Pavel).
- Fix ndo_queue_mem_free call that passed the wrong pointer (David).

v9: https://lore.kernel.org/all/20240502045410.3524155-4...@davidwei.uk/
(submitted by David).
- fixed SPDX license identifier (Simon).
- Rebased on top of merged queue API definition, and changed
  implementation to match that.
- Replace rtnl_lock() with rtnl_is_locked() to make it useable from my
  netlink code where rtnl is already locked.

---
 include/net/netdev_rx_queue.h |  3 ++
 net/core/Makefile |  1 +
 net/core/netdev_rx_queue.c| 74 +++
 3 files changed, 78 insertions(+)
 create mode 100644 net/core/netdev_rx_queue.c

diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h
index aa1716fb0e53c..e78ca52d67fbf 100644
--- a/include/net/netdev_rx_queue.h
+++ b/include/net/netdev_rx_queue.h
@@ -54,4 +54,7 @@ get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
return index;
 }
 #endif
+
+int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
+
 #endif
diff --git a/net/core/Makefile b/net/core/Makefile
index 62be9aef25285..f82232b358a2c 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o
 
 obj-y += net-sysfs.o
 obj-y += hotdata.o
+obj-y += netdev_rx_queue.o
 obj-$(CONFIG_PAGE_POOL) += page_pool.o page_pool_user.o
 obj-$(CONFIG_PROC_FS) += net-procfs.o
 obj-$(CONFIG_NET_PKTGEN) += pktgen.o
diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c
new file mode 100644
index 0..de0575cf6df5d
--- /dev/null
+++ b/net/core/netdev_rx_queue.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include 
+#include 
+#include 
+
+int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx)
+{
+   void *new_mem, *old_mem;
+   int err;
+
+   if (!dev->queue_mgmt_ops || !dev->queue_mgmt_ops->ndo_queue_stop ||
+   !dev->queue_mgmt_ops->ndo_queue_mem_free ||
+   !dev->queue_mgmt_ops->ndo_queue_mem_alloc ||
+   !dev->queue_mgmt_ops->ndo_queue_start)
+   return -EOPNOTSUPP;
+
+   DEBUG_NET_WARN_ON_ONCE(!rtnl_is_locked());
+
+   new_mem = kvzalloc(dev->queue_mgmt_ops->ndo_queue_mem_size, GFP_KERNEL);
+   if (!new_mem)
+   return -ENOMEM;
+
+   old_mem = kvzalloc(dev->queue_mgmt_ops->ndo_queue_mem_size, GFP_KERNEL);
+   if (!old_mem) {
+   err = -ENOMEM;
+   goto err_free_new_mem;
+   }
+
+   err = dev->queue_mgmt_ops->ndo_queue_mem_alloc(dev, new_mem, rxq_idx);
+   if (err)
+   goto err_free_old_mem;
+
+   err = dev->queue_mgmt_ops->ndo_queue_stop(dev, old_mem, rxq_idx);
+   if (err)
+   goto err_free_new_queue_mem;
+
+   err = dev->queue_mgmt_ops->ndo_queue_start(dev, new_mem, rxq_idx);
+   if (err)
+   goto err_start_queue;
+
+   dev->queue_mgmt_ops->ndo_queue_mem_free(dev, old_mem);
+
+   kvfree(old_mem);
+   kvfree(new_mem);
+
+   return 0;
+
+err_start_queue:
+   /* Restarting the queue with old_mem should be successful as we haven't
+* changed any of the queue configuration, and there is not much we can
+* do to recover from a failure here.
+*
+* WARN if the we fail to recover the old rx queue, and at least free
+* old_mem so we don't also leak that.
+*/
+   if (dev->queue_mgmt_ops->ndo_queue_start(dev, old_mem, rxq_idx)) {
+   WARN(1,
+"Failed to restart old queue in error path. RX queue %d 
may be unhealthy.",
+rxq_idx);
+   dev->queue_mgmt_ops->ndo_queue_mem_free(dev, old_mem);
+   }
+
+err_free_new_queue_mem:
+   dev->queue_mgmt_ops->ndo_queue_mem_free(dev, new_mem);
+
+err_free_old_mem:
+   kvfree(old_mem);
+
+err_free_new_mem:
+   kvfree(new_mem);
+
+   return err;
+}
-- 
2.45.2.505.gda0bf45e8d-goog



[PATCH net-next v11 00/13] Device Memory TCP

2024-06-06 Thread Mina Almasry
v11: https://patchwork.kernel.org/project/netdevbpf/list/?series=857457&state=*


Major Changes:
--

v11 addresses feedback received in v10. The major change is the removal
of the memory provider ops as requested by Christoph. We still
accomplish the same thing, but utilizing direct function calls with if
statements rather than generic ops.

Additionally address sparse warnings, bugs and review comments from
folks that reviewed.

As usual, the full devmem TCP changes including the full GVE driver
implementation is here:

https://github.com/mina/linux/commits/tcpdevmem-v11/

Detailed changelog:
---

- Fixes in netdev_rx_queue_restart() from Pavel & David.
- Remove commit e650e8c3a36f5 ("net: page_pool: create hooks for
custom page providers") from the series to address Christoph's
feedback and rebased other patches on the series on this change.
- Fixed build errors with CONFIG_DMA_SHARED_BUFFER &&
  !CONFIG_GENERIC_ALLOCATOR build.
- Fixed sparse warnings pointed out by Paolo.
- Drop unnecessary gro_pull_from_frag0 checks.
- Added Bagas reviewed-by to docs.

Cc: Bagas Sanjaya 
Cc: Steven Rostedt 
Cc: Christoph Hellwig 
Cc: Nikolay Aleksandrov 

v10: https://patchwork.kernel.org/project/netdevbpf/list/?series=852422&state=*


Major Changes:
--

v9 was sent right before the merge window closed (sorry!). v10 is almost
a re-send of the series now that the merge window re-opened. Only
rebased to latest net-next and addressed some minor iterative comments
received on v9.

As usual, the full devmem TCP changes including the full GVE driver
implementation is here:

https://github.com/mina/linux/commits/tcpdevmem-v10/

Detailed changelog:
---

- Fixed tokens leaking in DONTNEED setsockopt (Nikolay).
- Moved net_iov_dma_addr() to devmem.c and made it a devmem specific
  helpers (David).
- Rename hook alloc_pages to alloc_netmems as alloc_pages is now
  preprocessor macro defined and causes a build error.

v9:
===

Major Changes:
--

GVE queue API has been merged. Submitting this version as non-RFC after
rebasing on top of the merged API, and dropped the out of tree queue API
I was carrying on github. Addressed the little feedback v8 has received.

Detailed changelog:
--
- Added new patch from David Wei to this series for
  netdev_rx_queue_restart()
  - Fixed sparse error.
  - Removed CONFIG_ checks in netmem_is_net_iov()
  - Flipped skb->readable to skb->unreadable
  - Minor fixes to selftests & docs.

RFC v8:
===

Major Changes:
--

- Fixed build error generated by patch-by-patch build.
- Applied docs suggestions from Randy.

RFC v7:
===

Major Changes:
--

This revision largely rebases on top of net-next and addresses the feedback
RFCv6 received from folks, namely Jakub, Yunsheng, Arnd, David, & Pavel.

The series remains in RFC because the queue-API ndos defined in this
series are not yet implemented. I have a GVE implementation I carry out
of tree for my testing. A upstreamable GVE implementation is in the
works. Aside from that, in my estimation all the patches are ready for
review/merge. Please do take a look.

As usual the full devmem TCP changes including the full GVE driver
implementation is here:

https://github.com/mina/linux/commits/tcpdevmem-v7/

Detailed changelog:

- Use admin-perm in netlink API.
- Addressed feedback from Jakub with regards to netlink API
  implementation.
- Renamed devmem.c functions to something more appropriate for that
  file.
- Improve the performance seen through the page_pool benchmark.
- Fix the value definition of all the SO_DEVMEM_* uapi.
- Various fixes to documentation.

Perf - page-pool benchmark:
---

Improved performance of bench_page_pool_simple.ko tests compared to v6:

https://pastebin.com/raw/v5dYRg8L

  net-next base: 8 cycle fast path.
  RFC v6: 10 cycle fast path.
  RFC v7: 9 cycle fast path.
  RFC v7 with CONFIG_DMA_SHARED_BUFFER disabled: 8 cycle fast path,
 same as baseline.

Perf - Devmem TCP benchmark:
-

Perf is about the same regardless of the changes in v7, namely the
removal of the static_branch_unlikely to improve the page_pool benchmark
performance:

189/200gbps bi-directional throughput with RX devmem TCP and regular TCP
TX i.e. ~95% line rate.

RFC v6:
===

Major Changes:
--

This revision largely rebases on top of net-next and addresses the little
feedback RFCv5 received.

The series remains in RFC because the queue-API ndos defined in this
series are not yet implemented. I have a GVE implementation I carry out
of tree for my testing. A upstreamable GVE implementation is in the
works. Aside from that, in my estimation all the patches are ready for
review/merge. Please do take a look.

As usual the full devmem TCP changes including the full GVE driver
implementation is here:

https://github.com/mina/lin

Re: [PATCH v3 1/4] drm/sched: store the drm_device instead of the device

2024-06-06 Thread kernel test robot
Hi Pierre-Eric,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.10-rc2 next-20240606]
[cannot apply to drm-xe/drm-xe-next]
[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/Pierre-Eric-Pelloux-Prayer/drm-sched-store-the-drm_device-instead-of-the-device/20240606-211050
base:   linus/master
patch link:
https://lore.kernel.org/r/20240606130629.214827-2-pierre-eric.pelloux-prayer%40amd.com
patch subject: [PATCH v3 1/4] drm/sched: store the drm_device instead of the 
device
config: arm64-defconfig 
(https://download.01.org/0day-ci/archive/20240607/202406070826.asqumj48-...@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240607/202406070826.asqumj48-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202406070826.asqumj48-...@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
from include/drm/drm_print.h:31,
from include/drm/drm_mm.h:51,
from include/drm/drm_vma_manager.h:26,
from include/drm/drm_gem.h:42,
from drivers/gpu/drm/imagination/pvr_gem.h:12,
from drivers/gpu/drm/imagination/pvr_fw.h:9,
from drivers/gpu/drm/imagination/pvr_device.h:9,
from drivers/gpu/drm/imagination/pvr_context.h:17,
from drivers/gpu/drm/imagination/pvr_queue.c:8:
   drivers/gpu/drm/imagination/pvr_queue.c: In function 
'pvr_queue_timedout_job':
>> drivers/gpu/drm/imagination/pvr_queue.c:807:22: error: passing argument 1 of 
>> '_dev_err' from incompatible pointer type 
>> [-Werror=incompatible-pointer-types]
 807 | dev_err(sched->dev, "Job timeout\n");
 | ~^
 |  |
 |  struct drm_device *
   include/linux/dev_printk.h:110:25: note: in definition of macro 
'dev_printk_index_wrap'
 110 | _p_func(dev, fmt, ##__VA_ARGS__);
   \
 | ^~~
   drivers/gpu/drm/imagination/pvr_queue.c:807:9: note: in expansion of macro 
'dev_err'
 807 | dev_err(sched->dev, "Job timeout\n");
 | ^~~
   include/linux/dev_printk.h:50:36: note: expected 'const struct device *' but 
argument is of type 'struct drm_device *'
  50 | void _dev_err(const struct device *dev, const char *fmt, ...);
 |   ~^~~
   cc1: some warnings being treated as errors


vim +/_dev_err +807 drivers/gpu/drm/imagination/pvr_queue.c

eaf01ee5ba28b9 Sarah Walker 2023-11-22  787  
eaf01ee5ba28b9 Sarah Walker 2023-11-22  788  /**
eaf01ee5ba28b9 Sarah Walker 2023-11-22  789   * pvr_queue_timedout_job() - 
Handle a job timeout event.
eaf01ee5ba28b9 Sarah Walker 2023-11-22  790   * @s_job: The job this timeout 
occurred on.
eaf01ee5ba28b9 Sarah Walker 2023-11-22  791   *
eaf01ee5ba28b9 Sarah Walker 2023-11-22  792   * FIXME: We don't do anything 
here to unblock the situation, we just stop+start
eaf01ee5ba28b9 Sarah Walker 2023-11-22  793   * the scheduler, and re-assign 
parent fences in the middle.
eaf01ee5ba28b9 Sarah Walker 2023-11-22  794   *
eaf01ee5ba28b9 Sarah Walker 2023-11-22  795   * Return:
eaf01ee5ba28b9 Sarah Walker 2023-11-22  796   *  * DRM_GPU_SCHED_STAT_NOMINAL.
eaf01ee5ba28b9 Sarah Walker 2023-11-22  797   */
eaf01ee5ba28b9 Sarah Walker 2023-11-22  798  static enum drm_gpu_sched_stat
eaf01ee5ba28b9 Sarah Walker 2023-11-22  799  pvr_queue_timedout_job(struct 
drm_sched_job *s_job)
eaf01ee5ba28b9 Sarah Walker 2023-11-22  800  {
eaf01ee5ba28b9 Sarah Walker 2023-11-22  801 struct drm_gpu_scheduler *sched 
= s_job->sched;
eaf01ee5ba28b9 Sarah Walker 2023-11-22  802 struct pvr_queue *queue = 
container_of(sched, struct pvr_queue, scheduler);
eaf01ee5ba28b9 Sarah Walker 2023-11-22  803 struct pvr_device *pvr_dev = 
queue->ctx->pvr_dev;
eaf01ee5ba28b9 Sarah Walker 2023-11-22  804 struct pvr_job *job;
eaf01ee5ba28b9 Sarah Walker 2023-11-22  805 u32 job_count = 0;
eaf01ee5ba28b9 Sarah Walker 2023-11-22  806  
eaf01ee5ba28b9 Sarah Walker 2023-11-22 @807 dev_err(sched->dev, "Job 
timeout\n");
eaf01ee5ba28b9 Sarah Walker 2023-11-22  808  
eaf01ee5ba28b9 Sarah Walker 2023-11-22  

[PATCH v2] drm/mediatek: Log errors in probe with dev_err_probe()

2024-06-06 Thread Nícolas F . R . A . Prado
Use dev_err_probe() to log errors in the probe function of all drm
mediatek drivers. This avoids -EPROBE_DEFER return values from being
logged as errors, like the following:

  mediatek-disp-rdma 1c002000.rdma: Failed to add component: -517

As a side benefit it also standardizes the format of the error in the
log messages.

Signed-off-by: Nícolas F. R. A. Prado 
---
Changes in v2:
- Converted all dev_err() in probe functions to dev_err_probe() instead
  of just the ones in the component_add() error path
- Link to v1: 
https://lore.kernel.org/r/20240605-mtk-disp-rdma-dev-err-probe-v1-1-91259e1d3...@collabora.com
---
 drivers/gpu/drm/mediatek/mtk_cec.c  | 28 --
 drivers/gpu/drm/mediatek/mtk_disp_aal.c | 18 +++---
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c   | 18 +++---
 drivers/gpu/drm/mediatek/mtk_disp_color.c   | 18 +++---
 drivers/gpu/drm/mediatek/mtk_disp_gamma.c   | 18 +++---
 drivers/gpu/drm/mediatek/mtk_disp_merge.c   | 25 +---
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 24 ---
 drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c |  4 ++--
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c| 31 +++--
 drivers/gpu/drm/mediatek/mtk_dp.c   |  8 +++
 drivers/gpu/drm/mediatek/mtk_ethdr.c| 19 +++
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 31 ++---
 drivers/gpu/drm/mediatek/mtk_hdmi_ddc.c | 21 ++---
 drivers/gpu/drm/mediatek/mtk_mdp_rdma.c | 18 +++---
 drivers/gpu/drm/mediatek/mtk_padding.c  | 20 +++-
 15 files changed, 125 insertions(+), 176 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_cec.c 
b/drivers/gpu/drm/mediatek/mtk_cec.c
index 8519e9bade36..2de248443147 100644
--- a/drivers/gpu/drm/mediatek/mtk_cec.c
+++ b/drivers/gpu/drm/mediatek/mtk_cec.c
@@ -195,18 +195,14 @@ static int mtk_cec_probe(struct platform_device *pdev)
spin_lock_init(&cec->lock);
 
cec->regs = devm_platform_ioremap_resource(pdev, 0);
-   if (IS_ERR(cec->regs)) {
-   ret = PTR_ERR(cec->regs);
-   dev_err(dev, "Failed to ioremap cec: %d\n", ret);
-   return ret;
-   }
+   if (IS_ERR(cec->regs))
+   return dev_err_probe(dev, PTR_ERR(cec->regs),
+"Failed to ioremap cec\n");
 
cec->clk = devm_clk_get(dev, NULL);
-   if (IS_ERR(cec->clk)) {
-   ret = PTR_ERR(cec->clk);
-   dev_err(dev, "Failed to get cec clock: %d\n", ret);
-   return ret;
-   }
+   if (IS_ERR(cec->clk))
+   return dev_err_probe(dev, PTR_ERR(cec->clk),
+"Failed to get cec clock\n");
 
cec->irq = platform_get_irq(pdev, 0);
if (cec->irq < 0)
@@ -216,16 +212,12 @@ static int mtk_cec_probe(struct platform_device *pdev)
mtk_cec_htplg_isr_thread,
IRQF_SHARED | IRQF_TRIGGER_LOW |
IRQF_ONESHOT, "hdmi hpd", dev);
-   if (ret) {
-   dev_err(dev, "Failed to register cec irq: %d\n", ret);
-   return ret;
-   }
+   if (ret)
+   return dev_err_probe(dev, ret, "Failed to register cec irq\n");
 
ret = clk_prepare_enable(cec->clk);
-   if (ret) {
-   dev_err(dev, "Failed to enable cec clock: %d\n", ret);
-   return ret;
-   }
+   if (ret)
+   return dev_err_probe(dev, ret, "Failed to enable cec clock\n");
 
mtk_cec_htplg_irq_init(cec);
mtk_cec_htplg_irq_enable(cec);
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c 
b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
index 3ce8f32b06d5..59fb9a08d54b 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
@@ -175,16 +175,14 @@ static int mtk_disp_aal_probe(struct platform_device 
*pdev)
return -ENOMEM;
 
priv->clk = devm_clk_get(dev, NULL);
-   if (IS_ERR(priv->clk)) {
-   dev_err(dev, "failed to get aal clk\n");
-   return PTR_ERR(priv->clk);
-   }
+   if (IS_ERR(priv->clk))
+   return dev_err_probe(dev, PTR_ERR(priv->clk),
+"failed to get aal clk\n");
 
priv->regs = devm_platform_ioremap_resource(pdev, 0);
-   if (IS_ERR(priv->regs)) {
-   dev_err(dev, "failed to ioremap aal\n");
-   return PTR_ERR(priv->regs);
-   }
+   if (IS_ERR(priv->regs))
+   return dev_err_probe(dev, PTR_ERR(priv->regs),
+"failed to ioremap aal\n");
 
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
@@ -197,9 +195,9 @@ static int mtk_disp_aal_probe(str

Re: [PATCH v4 0/3] drm/mediatek: Add support for OF graphs

2024-06-06 Thread Nícolas F . R . A . Prado
On Thu, May 16, 2024 at 10:11:01AM +0200, AngeloGioacchino Del Regno wrote:
> Changes in v4:
>  - Fixed a typo that caused pure OF graphs pipelines multiple
>concurrent outputs to not get correctly parsed (port->id); 
>  - Added OVL_ADAPTOR support for OF graph specified pipelines;
>  - Now tested with fully OF Graph specified pipelines on MT8195
>Chromebooks and MT8395 boards;
>  - Rebased on next-20240516
> 
> Changes in v3:
>  - Rebased on next-20240502 because of renames in mediatek-drm
> 
> Changes in v2:
>  - Fixed wrong `required` block indentation in commit [2/3]
> 
> 
> The display IPs in MediaTek SoCs are *VERY* flexible and those support
> being interconnected with different instances of DDP IPs (for example,
> merge0 or merge1) and/or with different DDP IPs (for example, rdma can
> be connected with either color, dpi, dsi, merge, etc), forming a full
> Display Data Path that ends with an actual display.
> 
> This series was born because of an issue that I've found while enabling
> support for MT8195/MT8395 boards with DSI output as main display: the
> current mtk_drm_route variations would not work as currently, the driver
> hardcodes a display path for Chromebooks, which have a DisplayPort panel
> with DSC support, instead of a DSI panel without DSC support.
> 
> There are other reasons for which I wrote this series, and I find that
> hardcoding those paths - when a HW path is clearly board-specific - is
> highly suboptimal. Also, let's not forget about keeping this driver from
> becoming a huge list of paths for each combination of SoC->board->disp
> and... this and that.
> 
> For more information, please look at the commit description for each of
> the commits included in this series.
> 
> This series is essential to enable support for the MT8195/MT8395 EVK,
> Kontron i1200, Radxa NIO-12L and, mainly, for non-Chromebook boards
> and Chromebooks to co-exist without conflicts.
> 
> Besides, this is also a valid option for MT8188 Chromebooks which might
> have different DSI-or-eDP displays depending on the model (as far as I
> can see from the mtk_drm_route attempt for this SoC that is already
> present in this driver).
> 
> This series was tested on MT8195 Cherry Tomato and on MT8395 Radxa
> NIO-12L with both hardcoded paths, OF graph support and partially
> hardcoded paths, and pure OF graph support including pipelines that
> require OVL_ADAPTOR support.
> 
> AngeloGioacchino Del Regno (3):
>   dt-bindings: display: mediatek: Add OF graph support for board path
>   dt-bindings: arm: mediatek: mmsys: Add OF graph support for board path
>   drm/mediatek: Implement OF graphs support for display paths
> 
>  .../bindings/arm/mediatek/mediatek,mmsys.yaml |  28 ++
>  .../display/mediatek/mediatek,aal.yaml|  40 +++
>  .../display/mediatek/mediatek,ccorr.yaml  |  21 ++
>  .../display/mediatek/mediatek,color.yaml  |  22 ++
>  .../display/mediatek/mediatek,dither.yaml |  22 ++
>  .../display/mediatek/mediatek,dpi.yaml|  25 +-
>  .../display/mediatek/mediatek,dsc.yaml|  24 ++
>  .../display/mediatek/mediatek,dsi.yaml|  27 +-
>  .../display/mediatek/mediatek,ethdr.yaml  |  22 ++
>  .../display/mediatek/mediatek,gamma.yaml  |  19 ++
>  .../display/mediatek/mediatek,merge.yaml  |  23 ++
>  .../display/mediatek/mediatek,od.yaml |  22 ++
>  .../display/mediatek/mediatek,ovl-2l.yaml |  22 ++
>  .../display/mediatek/mediatek,ovl.yaml|  22 ++
>  .../display/mediatek/mediatek,postmask.yaml   |  21 ++
>  .../display/mediatek/mediatek,rdma.yaml   |  22 ++
>  .../display/mediatek/mediatek,ufoe.yaml   |  21 ++
>  drivers/gpu/drm/mediatek/mtk_disp_drv.h   |   1 +
>  .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c   |  40 ++-
>  drivers/gpu/drm/mediatek/mtk_dpi.c|  16 +-
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c| 282 --
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h|   2 +-
>  drivers/gpu/drm/mediatek/mtk_dsi.c|  10 +-
>  23 files changed, 713 insertions(+), 41 deletions(-)
> 
> -- 
> 2.45.0
> 

Hi Angelo,

I'm seeing issues with this series on MT8195-Tomato running on next-20240606:

[4.770965] refcount_t: addition on 0; use-after-free.
[4.770975] WARNING: CPU: 5 PID: 171 at lib/refcount.c:25 
refcount_warn_saturate+0xa0/0x144
[4.770983] Modules linked in: videobuf2_common rfkill(+) kfifo_buf 
onboard_usb_dev(+) mc hid_multitouch(+) cros_ec_chardev cros_kbd_led_backlight 
snd_sof_mt8195 elan_i2c mtk_adsp_common sbs_battery snd_soc_mt8195_afe 
snd_sof_xtensa_dsp pwm_bl lvts_thermal(+) mt6577_auxadc pcie_mediatek_gen3(+) 
snd_sof_of coreboot_table backlight mtk_scp mtk_rpmsg snd_sof mtk_svs 
snd_

[PATCH v11 1/8] x86/vmware: Introduce VMware hypercall API

2024-06-06 Thread Alexey Makhalov
Introduce vmware_hypercall family of functions. It is a common
implementation to be used by the VMware guest code and virtual
device drivers in architecture independent manner.

The API consists of vmware_hypercallX and vmware_hypercall_hb_{out,in}
set of functions by analogy with KVM hypercall API. Architecture
specific implementation is hidden inside.

It will simplify future enhancements in VMware hypercalls such
as SEV-ES and TDX related changes without needs to modify a
caller in device drivers code.

Current implementation extends an idea from commit bac7b4e84323
("x86/vmware: Update platform detection code for VMCALL/VMMCALL
hypercalls") to have a slow, but safe path vmware_hypercall_slow()
earlier during the boot when alternatives are not yet applied.
The code inherits VMWARE_CMD logic from the commit mentioned above.

Move common macros from vmware.c to vmware.h.

Signed-off-by: Alexey Makhalov 
---
 arch/x86/include/asm/vmware.h | 279 --
 arch/x86/kernel/cpu/vmware.c  |  58 ++-
 2 files changed, 315 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/vmware.h b/arch/x86/include/asm/vmware.h
index ac9fc51e2b18..724c8b9b4b8d 100644
--- a/arch/x86/include/asm/vmware.h
+++ b/arch/x86/include/asm/vmware.h
@@ -7,26 +7,277 @@
 #include 
 
 /*
- * The hypercall definitions differ in the low word of the %edx argument
- * in the following way: the old port base interface uses the port
- * number to distinguish between high- and low bandwidth versions.
+ * VMware hypercall ABI.
+ *
+ * - Low bandwidth (LB) hypercalls (I/O port based, vmcall and vmmcall)
+ * have up to 6 input and 6 output arguments passed and returned using
+ * registers: %eax (arg0), %ebx (arg1), %ecx (arg2), %edx (arg3),
+ * %esi (arg4), %edi (arg5).
+ * The following input arguments must be initialized by the caller:
+ * arg0 - VMWARE_HYPERVISOR_MAGIC
+ * arg2 - Hypercall command
+ * arg3 bits [15:0] - Port number, LB and direction flags
+ *
+ * - High bandwidth (HB) hypercalls are I/O port based only. They have
+ * up to 7 input and 7 output arguments passed and returned using
+ * registers: %eax (arg0), %ebx (arg1), %ecx (arg2), %edx (arg3),
+ * %esi (arg4), %edi (arg5), %ebp (arg6).
+ * The following input arguments must be initialized by the caller:
+ * arg0 - VMWARE_HYPERVISOR_MAGIC
+ * arg1 - Hypercall command
+ * arg3 bits [15:0] - Port number, HB and direction flags
+ *
+ * For compatibility purposes, x86_64 systems use only lower 32 bits
+ * for input and output arguments.
+ *
+ * The hypercall definitions differ in the low word of the %edx (arg3)
+ * in the following way: the old I/O port based interface uses the port
+ * number to distinguish between high- and low bandwidth versions, and
+ * uses IN/OUT instructions to define transfer direction.
  *
  * The new vmcall interface instead uses a set of flags to select
  * bandwidth mode and transfer direction. The flags should be loaded
- * into %dx by any user and are automatically replaced by the port
- * number if the VMWARE_HYPERVISOR_PORT method is used.
- *
- * In short, new driver code should strictly use the new definition of
- * %dx content.
+ * into arg3 by any user and are automatically replaced by the port
+ * number if the I/O port method is used.
+ */
+
+#define VMWARE_HYPERVISOR_HB   BIT(0)
+#define VMWARE_HYPERVISOR_OUT  BIT(1)
+
+#define VMWARE_HYPERVISOR_PORT 0x5658
+#define VMWARE_HYPERVISOR_PORT_HB  (VMWARE_HYPERVISOR_PORT | \
+VMWARE_HYPERVISOR_HB)
+
+#define VMWARE_HYPERVISOR_MAGIC0x564d5868U
+
+#define VMWARE_CMD_GETVERSION  10
+#define VMWARE_CMD_GETHZ   45
+#define VMWARE_CMD_GETVCPU_INFO68
+#define VMWARE_CMD_STEALCLOCK  91
+
+#define CPUID_VMWARE_FEATURES_ECX_VMMCALL  BIT(0)
+#define CPUID_VMWARE_FEATURES_ECX_VMCALL   BIT(1)
+
+extern unsigned long vmware_hypercall_slow(unsigned long cmd,
+  unsigned long in1, unsigned long in3,
+  unsigned long in4, unsigned long in5,
+  u32 *out1, u32 *out2, u32 *out3,
+  u32 *out4, u32 *out5);
+
+/*
+ * The low bandwidth call. The low word of %edx is presumed to have OUT bit
+ * set. The high word of %edx may contain input data from the caller.
  */
+#define VMWARE_HYPERCALL   \
+   ALTERNATIVE_2("movw %[port], %%dx\n\t"  \
+ "inl (%%dx), %%eax",  \
+ "vmcall", X86_FEATURE_VMCALL, \
+ "vmmcall", X86_FEATURE_VMW_VMMCALL)
+
+static inline
+unsigned long vmware_hypercall1(unsigned long cmd, unsigned long in1)
+{
+   unsigned long out0;
+
+   if (unlikely(!alternatives_patched) && !__is_defined(MODULE))
+   return vm

Re: [PATCH v10 1/8] x86/vmware: Introduce VMware hypercall API

2024-06-06 Thread Alexey Makhalov




On 6/3/24 10:58 AM, Borislav Petkov wrote:

On Wed, May 29, 2024 at 05:44:32PM -0700, Alexey Makhalov wrote:

While most of the vmware_hypercall callers are executed after alternative
patching applied, there are small amount of hypercalls running before that.
Only for them we have the logic of analyzing vmware_hypercall_mode as a
default alternative code. And there are 2 constraints:
1. vmcall/vmmcall are not supported by old ESXi/Workstation/Fusion. We have
to use in/out instructions. After the end of support of old hypervisors the
alternative can be simplified as follow:
ALTERNATIVE("vmcall", "vmmcall", X86_FEATURE_VMW_VMMCALL);
2. SEV-ES enabled VMs should use _only_ vmcall/vmmcall as in/out
instructions cause faults.

Another approach that we discussed internally was to use
ALTERNATIVE_2("movw %[port], %%dx; "inl (%%dx), %%eax", "vmcall",
X86_FEATURE_VMW_VMCALL, "vmmcall", X86_FEATURE_VMW_VMMCALL) for
vmware_hypercallX family of functions, _and_ to have a separate API
vmware_sev_hypercallX, with the silly dance without an alternative inside,
to be used only by early boot code, before alternative application. But,
it's error prone when things come to boot time related code movements or
rearrangements as it puts additional requirement for SEV-ES
understanding/testing for VMware guests.


Right, so since we're exporting that alternatives_patched thing already,
you might also try to do:

if (unlikely(!alternatives_patched))
return slow_hypercall_X_in_c();

asm_inline volatile(VMWARE_HYPERCALL...

where that slow_hypercall_X_in_c()* set of APIs does the checks in C.

And the VMWARE_HYPERCALL thing is a lot simpler then.

All in all, you'll have a lot less unreadable asm to pay attention to
and those APIs should be all easy and readable.



Thanks for the idea.

I improved the condition to eliminate slow path for modules such as 
vmmouse, vmwgfx.

   if (unlikely(!alternatives_patched) && !__is_defined(MODULE))
   return vmware_hypercall_slow(...);
It also drops the need for exporting vmware_hypercall_mode or 
vmware_hypercall_slow symbols.


Will post just Patch0001 for review here before sending v11 out.



Re: [PATCH v4 08/13] drm/msm/dpu: add support for virtual planes

2024-06-06 Thread Abhinav Kumar




On 3/13/2024 5:02 PM, Dmitry Baryshkov wrote:

Only several SSPP blocks support such features as YUV output or scaling,
thus different DRM planes have different features.  Properly utilizing
all planes requires the attention of the compositor, who should
prefer simpler planes to YUV-supporting ones. Otherwise it is very easy
to end up in a situation when all featureful planes are already
allocated for simple windows, leaving no spare plane for YUV playback.

To solve this problem make all planes virtual. Each plane is registered
as if it supports all possible features, but then at the runtime during
the atomic_check phase the driver selects backing SSPP block for each
plane.

Note, this does not provide support for using two different SSPP blocks
for a single plane or using two rectangles of an SSPP to drive two
planes. Each plane still gets its own SSPP and can utilize either a solo
rectangle or both multirect rectangles depending on the resolution.

Note #2: By default support for virtual planes is turned off and the
driver still uses old code path with preallocated SSPP block for each
plane. To enable virtual planes, pass 'msm.dpu_use_virtual_planes=1'
kernel parameter.



I like the overall approach in this patch. Some comments below.


Signed-off-by: Dmitry Baryshkov 
---
  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  50 +
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |  10 +-
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h   |   4 +
  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 230 +++---
  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.h |  19 ++
  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c|  77 
  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h|  28 +++
  7 files changed, 390 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 88c2e51ab166..794c5643584f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1168,6 +1168,49 @@ static bool dpu_crtc_needs_dirtyfb(struct drm_crtc_state 
*cstate)
return false;
  }
  
+static int dpu_crtc_reassign_planes(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state)

+{
+   int total_planes = crtc->dev->mode_config.num_total_plane;
+   struct drm_atomic_state *state = crtc_state->state;
+   struct dpu_global_state *global_state;
+   struct drm_plane_state **states;
+   struct drm_plane *plane;
+   int ret;
+
+   global_state = dpu_kms_get_global_state(crtc_state->state);
+   if (IS_ERR(global_state))
+   return PTR_ERR(global_state);
+
+   dpu_rm_release_all_sspp(global_state, crtc);
+


Do we need to call dpu_rm_release_all_sspp() even in the 
_dpu_plane_atomic_disable()?



+   if (!crtc_state->enable)
+   return 0;
+
+   states = kcalloc(total_planes, sizeof(*states), GFP_KERNEL);
+   if (!states)
+   return -ENOMEM;
+
+   drm_atomic_crtc_state_for_each_plane(plane, crtc_state) {
+   struct drm_plane_state *plane_state =
+   drm_atomic_get_plane_state(state, plane);
+
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto done;
+   }
+
+   states[plane_state->normalized_zpos] = plane_state;
+   }
+
+   ret = dpu_assign_plane_resources(global_state, state, crtc, states, 
total_planes);
+
+done:
+   kfree(states);
+   return ret;
+
+   return 0;
+}
+
  static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_atomic_state *state)
  {
@@ -1183,6 +1226,13 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
  
  	bool needs_dirtyfb = dpu_crtc_needs_dirtyfb(crtc_state);
  
+	if (dpu_use_virtual_planes &&

+   (crtc_state->planes_changed || crtc_state->zpos_changed)) {


Here, I assume you are relying on DRM to set zpos_changed. But can you 
please elaborate why we have to reassign planes when zpos_changes?



+   rc = dpu_crtc_reassign_planes(crtc, crtc_state);
+   if (rc < 0)
+   return rc;
+   }
+
if (!crtc_state->enable || 
!drm_atomic_crtc_effectively_active(crtc_state)) {
DRM_DEBUG_ATOMIC("crtc%d -> enable %d, active %d, skip 
atomic_check\n",
crtc->base.id, crtc_state->enable,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 9a1fe6868979..becdd98f3c40 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -51,6 +51,9 @@
  #define DPU_DEBUGFS_DIR "msm_dpu"
  #define DPU_DEBUGFS_HWMASKNAME "hw_log_mask"
  
+bool dpu_use_virtual_planes = false;

+module_param(dpu_use_virtual_planes, bool, 0);
+
  static int dpu_kms_hw_init(struct msm_kms *kms);
  static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
  
@@ -770,8 +773,11 @@ static int _

[PULL] drm-misc-next-fixes

2024-06-06 Thread Maarten Lankhorst

Hi Dave, Sima,

Pull request for a single patch lost in the wrong tree.

Cheers,
~Maarten

drm-misc-next-fixes-2024-06-07:
drm-misc-next-fixes for v6.10-rc3:
- Single unused struct removal that should have been in -fixes.
The following changes since commit 5a507b7d2be15fddb95bf8dee01110b723e2bcd9:

  drm/mst: Fix NULL pointer dereference at drm_dp_add_payload_part2 
(2024-05-21 16:36:59 -0400)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-next-fixes-2024-06-07


for you to fetch changes up to 539d33b5783804f22a62bd62ff463dfd1cef4265:

  drm/komeda: remove unused struct 'gamma_curve_segment' (2024-05-31 
12:09:51 +0100)



drm-misc-next-fixes for v6.10-rc3:
- Single unused struct removal that should have been in -fixes.


Dr. David Alan Gilbert (1):
  drm/komeda: remove unused struct 'gamma_curve_segment'

 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 5 -
 1 file changed, 5 deletions(-)


[PULL] drm-misc-fixes

2024-06-06 Thread Maarten Lankhorst

Hi Dave, Sima,

Lots of fixes for vmwgfx all over the place, and one fix for sitronix panel.

Cheers,
Maarten

drm-misc-fixes-2024-06-07:
drm-misc-fixes for v6.10-rc3:
- Robustness fixes for vmwgfx.
- Error check for of_drm_get_panel_orientation failing in
  sitronix-st7789v.
The following changes since commit bb195358806847217efba98de62b7decec3b371f:

  drm/msm: remove python 3.9 dependency for compiling msm (2024-05-30 
18:49:23 +0200)


are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/misc/kernel.git 
tags/drm-misc-fixes-2024-06-07


for you to fetch changes up to 5703fc058efdafcdd6b70776ee562478f0753acb:

  drm/vmwgfx: Don't memcmp equivalent pointers (2024-06-05 22:38:40 -0400)


drm-misc-fixes for v6.10-rc3:
- Robustness fixes for vmwgfx.
- Error check for of_drm_get_panel_orientation failing in
  sitronix-st7789v.


Chen Ni (1):
  drm/panel: sitronix-st7789v: Add check for 
of_drm_get_panel_orientation


Dr. David Alan Gilbert (1):
  drm/vmwgfx: remove unused struct 'vmw_stdu_dma'

Ian Forbes (6):
  drm/vmwgfx: Filter modes which exceed graphics memory
  drm/vmwgfx: 3D disabled should not effect STDU memory limits
  drm/vmwgfx: Remove STDU logic from generic mode_valid function
  drm/vmwgfx: Standardize use of kibibytes when logging
  drm/vmwgfx: Don't destroy Screen Target when CRTC is enabled but 
inactive

  drm/vmwgfx: Don't memcmp equivalent pointers

 drivers/gpu/drm/panel/panel-sitronix-st7789v.c |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c| 19 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h|  3 --
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c  |  4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c| 28 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c   | 60 
+++---

 6 files changed, 74 insertions(+), 44 deletions(-)


Re: [PATCH 1/2][RFC] amdgpu: fix a race in kfd_mem_export_dmabuf()

2024-06-06 Thread Felix Kuehling



On 2024-06-05 05:14, Christian König wrote:

Am 04.06.24 um 20:08 schrieb Felix Kuehling:


On 2024-06-03 22:13, Al Viro wrote:

Using drm_gem_prime_handle_to_fd() to set dmabuf up and insert it into
descriptor table, only to have it looked up by file descriptor and
remove it from descriptor table is not just too convoluted - it's
racy; another thread might have modified the descriptor table while
we'd been going through that song and dance.

It's not hard to fix - turn drm_gem_prime_handle_to_fd()
into a wrapper for a new helper that would simply return the
dmabuf, without messing with descriptor table.

Then kfd_mem_export_dmabuf() would simply use that new helper
and leave the descriptor table alone.

Signed-off-by: Al Viro 


This patch looks good to me on the amdgpu side. For the DRM side I'm 
adding dri-devel.


Yeah that patch should probably be split up and the DRM changes 
discussed separately.


On the other hand skimming over it it seems reasonable to me.

Felix are you going to look into this or should I take a look and try 
to push it through drm-misc-next?


It doesn't matter much to me, as long as we submit both changes together.

Thanks,
  Felix




Thanks,
Christian.



Acked-by: Felix Kuehling 



---
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index 8975cf41a91a..793780bb819c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -25,7 +25,6 @@
  #include 
  #include 
  #include 
-#include 
  #include 
    #include 
@@ -812,18 +811,13 @@ static int kfd_mem_export_dmabuf(struct 
kgd_mem *mem)

  if (!mem->dmabuf) {
  struct amdgpu_device *bo_adev;
  struct dma_buf *dmabuf;
-    int r, fd;
    bo_adev = amdgpu_ttm_adev(mem->bo->tbo.bdev);
-    r = drm_gem_prime_handle_to_fd(&bo_adev->ddev, 
bo_adev->kfd.client.file,
+    dmabuf = drm_gem_prime_handle_to_dmabuf(&bo_adev->ddev, 
bo_adev->kfd.client.file,

 mem->gem_handle,
  mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
-   DRM_RDWR : 0, &fd);
-    if (r)
-    return r;
-    dmabuf = dma_buf_get(fd);
-    close_fd(fd);
-    if (WARN_ON_ONCE(IS_ERR(dmabuf)))
+   DRM_RDWR : 0);
+    if (IS_ERR(dmabuf))
  return PTR_ERR(dmabuf);
  mem->dmabuf = dmabuf;
  }
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 03bd3c7bd0dc..622c51d3fe18 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -409,23 +409,9 @@ static struct dma_buf 
*export_and_register_object(struct drm_device *dev,

  return dmabuf;
  }
  -/**
- * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers
- * @dev: dev to export the buffer from
- * @file_priv: drm file-private structure
- * @handle: buffer handle to export
- * @flags: flags like DRM_CLOEXEC
- * @prime_fd: pointer to storage for the fd id of the create dma-buf
- *
- * This is the PRIME export function which must be used mandatorily 
by GEM
- * drivers to ensure correct lifetime management of the underlying 
GEM object.
- * The actual exporting from GEM object to a dma-buf is done 
through the

- * &drm_gem_object_funcs.export callback.
- */
-int drm_gem_prime_handle_to_fd(struct drm_device *dev,
+struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev,
 struct drm_file *file_priv, uint32_t handle,
-   uint32_t flags,
-   int *prime_fd)
+   uint32_t flags)
  {
  struct drm_gem_object *obj;
  int ret = 0;
@@ -434,14 +420,14 @@ int drm_gem_prime_handle_to_fd(struct 
drm_device *dev,

  mutex_lock(&file_priv->prime.lock);
  obj = drm_gem_object_lookup(file_priv, handle);
  if (!obj)  {
-    ret = -ENOENT;
+    dmabuf = ERR_PTR(-ENOENT);
  goto out_unlock;
  }
    dmabuf = drm_prime_lookup_buf_by_handle(&file_priv->prime, 
handle);

  if (dmabuf) {
  get_dma_buf(dmabuf);
-    goto out_have_handle;
+    goto out;
  }
    mutex_lock(&dev->object_name_lock);
@@ -463,7 +449,6 @@ int drm_gem_prime_handle_to_fd(struct drm_device 
*dev,

  /* normally the created dma-buf takes ownership of the ref,
   * but if that fails then drop the ref
   */
-    ret = PTR_ERR(dmabuf);
  mutex_unlock(&dev->object_name_lock);
  goto out;
  }
@@ -478,34 +463,49 @@ int drm_gem_prime_handle_to_fd(struct 
drm_device *dev,

  ret = drm_prime_add_buf_handle(&file_priv->prime,
 dmabuf, handle);
  mutex_unlock(&dev->object_name_lock);
-    if (ret)
-    goto fail_put_dmabuf;
-
-out_have_handle:
-    ret = dma_buf_fd(dmabuf, flags);
-    /*
- * We must _not_ remove the buffer from the handle cache since 
the newly
- * created dma

[PULL] drm-xe-next

2024-06-06 Thread Rodrigo Vivi
Hi Dave and Sima,

Here goes our first Xe pull request targeting 6.11.

A very active round, with highlight to many changes targeting
SR-IOV support and many different clean-ups.

Thanks,
Rodrigo.

drm-xe-next-2024-06-06:
UAPI Changes:
- Expose the L3 bank mask (Francois)

Cross-subsystem Changes:
- Update Xe driver maintainers (Oded)

Display (i915):
- Add missing include to intel_vga.c (Michal Wajdeczko)

Driver Changes:
- Fix Display (xe-only) detection for ADL-N (Lucas)
- Runtime PM fixes that enabled PC-10 and D3Cold (Francois, Rodrigo)
- Fix unexpected silent drm backmerge issues (Thomas)
- More (a lot more) preparation for SR-IOV support (Michal Wajdeczko)
- Devcoredump fixes and improvements (Jose, Tejas, Matt Brost)
- Introduce device 'wedged' state (Rodrigo)
- Improve debug and info messages (Michal Wajdeczko, Rodrigo, Nirmoy)
- Adding or fixing workarounds (Tejas, Shekhar, Lucas, Bommu)
- Check result of drmm_mutex_init (Michal Wajdeczko)
- Enlarge the critical dma fence area for preempt fences (Matt Auld)
- Prevent UAF in VM's rebind work (Matt Auld)
- GuC submit related clean-ups and fixes (Matt Brost, Himal, Jonathan, 
Niranjana)
- Prefer local helpers to perform dma reservation locking (Himal)
- Spelling and typo fixes (Colin, Francois)
- Prep patches for 1 job per VM bind IOCTL (no uapi change yet) (Matt Brost)
- Remove uninitialized end var from xe_gt_tlb_invalidation_range (Nirmoy)
- GSC related changes targeting LNL support (Daniele)
- Fix assert in L3 bank mask generation (Francois)
- Perform dma_map when moving system buffer objects to TT (Thomas)
- Add helpers for manipulating macro arguments (Michal Wajdeczko)
- Refactor default device atomic settings (Nirmoy)
- Add debugfs node to dump mocs (Janga)
- Use ordered WQ for G2H handler (Matt Brost)
- Clean up and fixes in header includes (Michal Wajdeczko)
- Prefer flexible-array over deprecated zero-lenght ones (Lucas)
- Add Indirect Ring State support (Niranjana)
- Fix UBSAN shift-out-of-bounds failure (Shuicheng)
- HWMon fixes and additions (Karthik)
- Clean-up refactor around probe init functions (Lucas, Michal Wajdeczko)
- Fix PCODE init function (Himal)
- Only use reserved BCS instances for usm migrate exec queue (Matt Brost)
- Only zap PTEs as needed (Matt Brost)
- Per client usage info (Lucas)
- Core hotunplug improvements converting stuff towards devm (Matt Auld)
- Don't emit false error if running in execlist mode (Michal Wajdeczko)
- Remove unused struct (Dr. David)
- Support/debug for slow GuC loads (John Harrison)
- Decouple job seqno and lrc seqno (Matt Brost)
- Allow migrate vm gpu submissions from reclaim context (Thomas)
- Rename drm-client running time to run_ticks and fix a UAF (Umesh)
- Check empty pinned BO list with lock held (Nirmoy)
- Drop undesired prefix from the platform name (Michal Wajdeczko)
- Remove unwanted mutex locking on xe file close (Niranjana)
- Replace format-less snprintf() with strscpy() (Arnd)
- Other general clean-ups on registers definitions and function names (Michal 
Wajdeczko)
- Add kernel-doc to some xe_lrc interfaces (Niranajana)
- Use missing lock in relay_needs_worker (Nirmoy)
- Drop redundant W=1 warnings from Makefile (Jani)
- Simplify if condition in preempt fences code (Thorsten)
- Flush engine buffers before signalling user fence on all engines (Andrzej)
- Don't overmap identity VRAM mapping (Matt Brost)
- Do not dereference NULL job->fence in trace points (Matt Brost)
- Add synchronous gt reset debugfs (Jonathan)
- Xe gt_idle fixes (Riana)

The following changes since commit 4a56c0ed5aa0bcbe1f5f7d755fb1fe1ebf48ae9c:

  Merge tag 'amd-drm-next-6.10-2024-04-26' of 
https://gitlab.freedesktop.org/agd5f/linux into drm-next (2024-04-30 14:43:00 
+1000)

are available in the Git repository at:

  https://gitlab.freedesktop.org/drm/xe/kernel.git tags/drm-xe-next-2024-06-06

for you to fetch changes up to 6800e63cf97bae62bca56d8e691544540d945f53:

  drm/xe: move disable_c6 call (2024-06-06 15:07:19 -0400)


UAPI Changes:
- Expose the L3 bank mask (Francois)

Cross-subsystem Changes:
- Update Xe driver maintainers (Oded)

Display (i915):
- Add missing include to intel_vga.c (Michal Wajdeczko)

Driver Changes:
- Fix Display (xe-only) detection for ADL-N (Lucas)
- Runtime PM fixes that enabled PC-10 and D3Cold (Francois, Rodrigo)
- Fix unexpected silent drm backmerge issues (Thomas)
- More (a lot more) preparation for SR-IOV support (Michal Wajdeczko)
- Devcoredump fixes and improvements (Jose, Tejas, Matt Brost)
- Introduce device 'wedged' state (Rodrigo)
- Improve debug and info messages (Michal Wajdeczko, Rodrigo, Nirmoy)
- Adding or fixing workarounds (Tejas, Shekhar, Lucas, Bommu)
- Check result of drmm_mutex_init (Michal Wajdeczko)
- Enlarge the critical dma fence area for preempt fences (Matt Auld)
- Prevent UAF in VM's rebind work (Matt Auld)
- GuC submit related clean-ups and fixes (Matt Brost, Himal, Jonathan, 
Niranjan

Re: [PATCH v2] drm/i915/guc: Enable w/a 16021333562 for DG2, MTL and ARL

2024-06-06 Thread Julia Filipchuk
On 5/28/2024 4:05 PM, john.c.harri...@intel.com wrote:
> Enable another workaround that is implemented inside the GuC.
> 
> v2: Use the correct Gen12 w/a id rather than the Xe version (review
> feedback from Matthew R) also extend to include ARL.
> 
> Signed-off-by: John Harrison 
> ---
Reviewed-by: Julia Filipchuk 


Re: [PATCH v3 2/4] dt-bindings: display/msm: hdmi: add qcom,hdmi-tx-8998

2024-06-06 Thread Rob Herring (Arm)


On Thu, 06 Jun 2024 18:07:48 +0200, Marc Gonzalez wrote:
> HDMI TX block embedded in the APQ8098.
> 
> Signed-off-by: Marc Gonzalez 
> ---
>  .../devicetree/bindings/display/msm/hdmi.yaml  | 28 
> --
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 

Reviewed-by: Rob Herring (Arm) 



Re: [PATCH] dt-bindings: display: panel: constrain 'reg' in DSI panels (part two)

2024-06-06 Thread Rob Herring (Arm)


On Wed, 05 Jun 2024 12:56:59 +0200, Krzysztof Kozlowski wrote:
> DSI-attached devices could respond to more than one virtual channel
> number, thus their bindings are supposed to constrain the 'reg' property
> to match hardware.  Add missing 'reg' constrain for DSI-attached display
> panels, based on DTS sources in Linux kernel (assume all devices take
> only one channel number).
> 
> Few bindings missed previous fixup: LG SW43408 and Raydium RM69380.
> 
> Signed-off-by: Krzysztof Kozlowski 
> 
> ---
> 
> This should apply on any tree.
> ---
>  .../devicetree/bindings/display/panel/lg,sw43408.yaml| 4 +++-
>  .../devicetree/bindings/display/panel/raydium,rm69380.yaml   | 5 +++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 

Applied, thanks!



RE: [syzbot] [mm?] general protection fault in dequeue_hugetlb_folio_nodemask

2024-06-06 Thread Deucher, Alexander
[AMD Official Use Only - AMD Internal Distribution Only]

> -Original Message-
> From: Limonciello, Mario 
> Sent: Thursday, June 6, 2024 10:56 AM
> To: Deucher, Alexander 
> Cc: syzbot ;
> Huang, Tim ; Pan, Xinhui ;
> airl...@gmail.com; a...@linux-foundation.org; Deucher, Alexander
> ; amd-...@lists.freedesktop.org; Koenig,
> Christian ; dan...@ffwll.ch; dri-
> de...@lists.freedesktop.org; evan.q...@amd.com; Lazar, Lijo
> ; linux-ker...@vger.kernel.org; linux...@kvack.org;
> muchun.s...@linux.dev; syzkaller-b...@googlegroups.com; Zhang, Yifan
> 
> Subject: Re: [syzbot] [mm?] general protection fault in
> dequeue_hugetlb_folio_nodemask
>
> On 6/6/2024 09:39, syzbot wrote:
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit:0e1980c40b6e Add linux-next specific files for 20240531
> > git tree:   linux-next
> > console+strace:
> > console+https://syzkaller.appspot.com/x/log.txt?x=166086f298
> > kernel config:
> > https://syzkaller.appspot.com/x/.config?x=d9c3ca4e54577b88
> > dashboard link:
> https://syzkaller.appspot.com/bug?extid=c019f68a83ef9b456444
> > compiler:   Debian clang version 15.0.6, GNU ld (GNU Binutils for 
> > Debian)
> 2.40
> > syz repro:
> https://syzkaller.appspot.com/x/repro.syz?x=12f4094a98
> > C reproducer:
> https://syzkaller.appspot.com/x/repro.c?x=15e1e43298
> >
> > Downloadable assets:
> > disk image:
> > https://storage.googleapis.com/syzbot-assets/44fb1d8b5978/disk-
> 0e1980c
> > 4.raw.xz
> > vmlinux:
> > https://storage.googleapis.com/syzbot-assets/a66ce5caf0b2/vmlinux-0e19
> > 80c4.xz kernel image:
> > https://storage.googleapis.com/syzbot-assets/8992fc8fe046/bzImage-
> 0e19
> > 80c4.xz
> >
> > The issue was bisected to:
> >
> > commit cd94d1b182d2986378550c9087571991bfee01d4
> > Author: Mario Limonciello 
> > Date:   Thu May 2 18:32:17 2024 +
> >
> >  dm/amd/pm: Fix problems with reboot/shutdown for some SMU
> > 13.0.4/13.0.11 users
> >
> > bisection log:
> > https://syzkaller.appspot.com/x/bisect.txt?x=176121c298
> > console output:
> > https://syzkaller.appspot.com/x/log.txt?x=10e121c298
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+c019f68a83ef9b456...@syzkaller.appspotmail.com
> > Fixes: cd94d1b182d2 ("dm/amd/pm: Fix problems with reboot/shutdown
> for
> > some SMU 13.0.4/13.0.11 users")
> >
> > Oops: general protection fault, probably for non-canonical address
> > 0xdc000489:  [#1] PREEMPT SMP KASAN PTI
> > KASAN: probably user-memory-access in range
> > [0x2448-0x244f]
> > CPU: 1 PID: 5089 Comm: syz-executor257 Not tainted
> > 6.10.0-rc1-next-20240531-syzkaller #0 Hardware name: Google Google
> > Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
> > RIP: 0010:zonelist_zone_idx include/linux/mmzone.h:1613 [inline]
> > RIP: 0010:next_zones_zonelist include/linux/mmzone.h:1644 [inline]
> > RIP: 0010:first_zones_zonelist include/linux/mmzone.h:1670 [inline]
> > RIP: 0010:dequeue_hugetlb_folio_nodemask+0x193/0xe40
> mm/hugetlb.c:1362
> > Code: 13 9b a0 ff c7 44 24 14 00 00 00 00 83 7c 24 40 00 0f 85 97 0c
> > 00 00 48 83 7c 24 20 00 0f 85 45 09 00 00 48 89 d8 48 c1 e8 03 <42> 0f
> > b6 04 28 84 c0 0f 85 58 09 00 00 44 8b 33 44 89 f7 8b 5c 24
> > RSP: 0018:c900035ef720 EFLAGS: 00010002
> > RAX: 0489 RBX: 2448 RCX:
> 888026ef
> > RDX:  RSI:  RDI:
> 
> > RBP: c900035ef858 R08: 81f5e070 R09: f520006bdee8
> > R10: dc00 R11: f520006bdee8 R12: 
> > R13: dc00 R14:  R15:
> 
> > FS:  64010380() GS:8880b950()
> > knlGS:
> > CS:  0010 DS:  ES:  CR0: 80050033
> > CR2: 005fdeb8 CR3: 7bd96000 CR4:
> 003506f0
> > DR0:  DR1:  DR2:
> 
> > DR3:  DR6: fffe0ff0 DR7:
> 0400 Call
> > Trace:
> >   
> >   alloc_hugetlb_folio_nodemask+0xae/0x3f0 mm/hugetlb.c:2603
> >   memfd_alloc_folio+0x15e/0x390 mm/memfd.c:75
> >   memfd_pin_folios+0x1066/0x1720 mm/gup.c:3864
> >   udmabuf_create+0x658/0x11c0 drivers/dma-buf/udmabuf.c:353
> >   udmabuf_ioctl_create drivers/dma-buf/udmabuf.c:420 [inline]
> >   udmabuf_ioctl+0x304/0x4f0 drivers/dma-buf/udmabuf.c:451
> >   vfs_ioctl fs/ioctl.c:51 [inline]
> >   __do_sys_ioctl fs/ioctl.c:907 [inline]
> >   __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893
> >   do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> >   do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
> >   entry_SYSCALL_64_after_hwframe+0x77/0x7f
> > RIP: 0033:0x7f5151a7a369
> > Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48
> > 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
> > 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
> > RSP: 002b:000

Re: [PATCH v2] MAINTAINERS: Update Xe driver maintainers

2024-06-06 Thread Lucas De Marchi


On Sun, 02 Jun 2024 21:09:59 +0200, Thomas Hellström wrote:
> Add Rodrigo Vivi as an Xe driver maintainer.
> 
> v2:
> - Cc also Lucas De Marchi (Rodrigo vivi)
> - Remove a blank line in commit the commit message (Lucas De Marchi)
> 
> 
> [...]

Applied to drm-xe-fixes, thanks!

[1/1] MAINTAINERS: Update Xe driver maintainers
  commit: a9f9b30e1748252d158f78a0c0affdc949671dd1

Best regards,
-- 
Lucas De Marchi 


Re: [PATCH 12/14] dt-bindings: display: rockchip,dw-hdmi: Add compatible for RK3588

2024-06-06 Thread Cristian Ciocaltea
On 6/6/24 5:58 PM, Rob Herring wrote:
> On Thu, Jun 6, 2024 at 5:51 AM Cristian Ciocaltea
>  wrote:
>>
>> On 6/6/24 2:22 AM, Rob Herring wrote:
>>> On Sat, Jun 01, 2024 at 04:12:34PM +0300, Cristian Ciocaltea wrote:
 Document the Synopsys DesignWare HDMI 2.1 Quad-Pixel (QP) TX controller
 found on Rockchip RK3588 SoC family.

 Since RK3588 uses different clocks than previous Rockchip SoCs and also
 requires a couple of reset lines and some additional properties, provide
 the required changes in the binding to accommodate all variants.

 Signed-off-by: Cristian Ciocaltea 
 ---
  .../display/rockchip/rockchip,dw-hdmi.yaml | 127 
 +++--
  1 file changed, 90 insertions(+), 37 deletions(-)

 diff --git 
 a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml 
 b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
 index 2aac62219ff6..60d6b815227f 100644
 --- 
 a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
 +++ 
 b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
 @@ -10,12 +10,10 @@ maintainers:
- Mark Yao 

  description: |
 -  The HDMI transmitter is a Synopsys DesignWare HDMI 1.4 TX controller IP
 -  with a companion PHY IP.
 -
 -allOf:
 -  - $ref: ../bridge/synopsys,dw-hdmi.yaml#
 -  - $ref: /schemas/sound/dai-common.yaml#
 +  For SoCs up to RK3568, the HDMI transmitter is a Synopsys DesignWare
 +  HDMI 1.4 TX controller IP with a companion PHY IP.
 +  The RK3588 SoC integrates the Synopsys DesignWare HDMI 2.1 Quad-Pixel 
 (QP)
 +  TX controller IP and a HDMI/eDP TX Combo PHY based on a Samsung IP 
 block.

  properties:
compatible:
 @@ -25,6 +23,7 @@ properties:
- rockchip,rk3328-dw-hdmi
- rockchip,rk3399-dw-hdmi
- rockchip,rk3568-dw-hdmi
 +  - rockchip,rk3588-dw-hdmi

reg-io-width:
  const: 4
 @@ -40,36 +39,6 @@ properties:
A 1.8V supply that powers up the SoC internal circuitry. The pin 
 name on the
SoC usually is HDMI_TX_AVDD_1V8.

 -  clocks:
 -minItems: 2
 -items:
 -  - {}
 -  - {}
 -  # The next three clocks are all optional, but shall be specified in 
 this
 -  # order when present.
 -  - description: The HDMI CEC controller main clock
 -  - description: Power for GRF IO
 -  - description: External clock for some HDMI PHY (old clock name, 
 deprecated)
 -  - description: External clock for some HDMI PHY (new name)
 -
 -  clock-names:
 -minItems: 2
 -items:
 -  - {}
 -  - {}
 -  - enum:
 -  - cec
 -  - grf
 -  - vpll
 -  - ref
 -  - enum:
 -  - grf
 -  - vpll
 -  - ref
 -  - enum:
 -  - vpll
 -  - ref
 -
ddc-i2c-bus:
  $ref: /schemas/types.yaml#/definitions/phandle
  description:
 @@ -131,13 +100,97 @@ properties:
  required:
- compatible
- reg
 -  - reg-io-width
- clocks
- clock-names
- interrupts
- ports
- rockchip,grf

 +allOf:
 +  - $ref: /schemas/sound/dai-common.yaml#
 +  - if:
 +  properties:
 +compatible:
 +  contains:
 +enum:
 +  - rockchip,rk3588-dw-hdmi
 +then:
 +  properties:
 +reg:
 +  maxItems: 1
 +
 +clocks:
 +  minItems: 1
 +  items:
 +- description: APB system interface clock
 +# The next clocks are optional, but shall be specified in this
 +# order when present.
 +- description: TMDS/FRL link clock
 +- description: EARC RX biphase clock
 +- description: Reference clock
 +- description: Audio interface clock
 +- description: Video datapath clock
 +
 +clock-names:
 +  minItems: 1
 +  items:
 +- const: pclk
 +- enum: [hdp, earc, ref, aud, hclk_vo1]
 +- enum: [earc, ref, aud, hclk_vo1]
 +- enum: [ref, aud, hclk_vo1]
 +- enum: [aud, hclk_vo1]
 +- const: hclk_vo1
 +
 +resets:
 +  minItems: 2
 +  maxItems: 2
 +
 +reset-names:
 +  items:
 +- const: ref
 +- const: hdp
 +
 +interrupts:
 +  minItems: 1
 +  maxItems: 5
 +
 +rockchip,vo1_grf:
 +  $ref: /schemas/types.yaml#/defin

[pull] amdgpu drm-fixes-6.10

2024-06-06 Thread Alex Deucher
Hi Dave, Sima,

A couple of fixes for 6.10.

The following changes since commit c3f38fa61af77b49866b006939479069cd451173:

  Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)

are available in the Git repository at:

  https://gitlab.freedesktop.org/agd5f/linux.git 
tags/amd-drm-fixes-6.10-2024-06-06

for you to fetch changes up to c6c4dd54012551cce5cde408b35468f2c62b0cce:

  drm/amdgpu/pptable: Fix UBSAN array-index-out-of-bounds (2024-06-05 13:43:34 
-0400)


amd-drm-fixes-6.10-2024-06-06:

amdgpu:
- Fix shutdown issues on some SMU 13.x platforms
- Silence some UBSAN flexible array warnings


Mario Limonciello (1):
  drm/amd: Fix shutdown (again) on some SMU v13.0.4/11 platforms

Tasos Sahanidis (1):
  drm/amdgpu/pptable: Fix UBSAN array-index-out-of-bounds

 drivers/gpu/drm/amd/include/pptable.h  | 91 --
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c   | 20 ++---
 2 files changed, 60 insertions(+), 51 deletions(-)


Re: [PATCH 2/2] drm/xe: Use drm_device managed mutex/mm init helpers in GGTT

2024-06-06 Thread Michal Wajdeczko



On 06.06.2024 19:25, Rodrigo Vivi wrote:
> On Fri, May 24, 2024 at 03:35:18PM +0200, Michal Wajdeczko wrote:
>> There is not need for private release action as there are existing
>> drmm_mm_init() and drmm_mutex_init() helpers that can be used.
>>
>> Signed-off-by: Michal Wajdeczko 
>> Cc: Thomas Hellström 
>> Cc: Rodrigo Vivi 
>> ---
>>  drivers/gpu/drm/xe/xe_ggtt.c | 23 +++
>>  1 file changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
>> index 17e5066763db..7c91fe212dcb 100644
>> --- a/drivers/gpu/drm/xe/xe_ggtt.c
>> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
>> @@ -96,14 +96,6 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 
>> start, u64 size)
>>  }
>>  }
>>  
>> -static void ggtt_fini_early(struct drm_device *drm, void *arg)
>> -{
>> -struct xe_ggtt *ggtt = arg;
>> -
>> -mutex_destroy(&ggtt->lock);
>> -drm_mm_takedown(&ggtt->mm);
>> -}
>> -
>>  static void ggtt_fini(struct drm_device *drm, void *arg)
>>  {
>>  struct xe_ggtt *ggtt = arg;
>> @@ -141,6 +133,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>>  struct xe_device *xe = tile_to_xe(ggtt->tile);
>>  struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>>  unsigned int gsm_size;
>> +int err;
>>  
>>  if (IS_SRIOV_VF(xe))
>>  gsm_size = SZ_8M; /* GGTT is expected to be 4GiB */
>> @@ -189,12 +182,18 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>>  else
>>  ggtt->pt_ops = &xelp_pt_ops;
>>  
>> -drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
>> -ggtt->size - xe_wopcm_size(xe));
>> -mutex_init(&ggtt->lock);
>> +err = drmm_mm_init(&xe->drm, &ggtt->mm, xe_wopcm_size(xe),
>> +   ggtt->size - xe_wopcm_size(xe));
>> +if (err)
>> +return err;
>> +
>> +err = drmm_mutex_init(&xe->drm, &ggtt->lock);
>> +if (err)
>> +return err;
> 
> My first impression here is that we would have a bug here if drmm_mm_init
> works, but drmm_mutex_init fails, but we are likely safe because the
> probe will also entirely fail if this mutex init fails.
> 
>> +
>>  primelockdep(ggtt);
>>  
>> -return drmm_add_action_or_reset(&xe->drm, ggtt_fini_early, ggtt);
> 
> But my question here is, why drmm and not devm for this ggtt case that
> only makes sense if the hardware/device is up and not about the module
> or no reason to keep it alive after the probe failure or device removal.
> 
> I know that the question is orthogonal to your patch. But if we decide to
> change the course later and move this towards devm, then we need to
> get back to the exit function and perhaps regular mutex.

but note that drm_mm alone does not interact with the hw, it's what we
eventually build on top of it (like here ggtt manager) may touch the hw

> 
> I mean, really nothing against this patch itself, specially if we are
> confident that drmm is the way to go with this ggtt. So, I'm not blocking
> here:
> 
> Reviewed-by: Rodrigo Vivi 
> 
>> +return 0;
>>  }
>>  
>>  static void xe_ggtt_invalidate(struct xe_ggtt *ggtt);
>> -- 
>> 2.43.0
>>


Re: [linux-next:master] BUILD REGRESSION ee78a17615ad0cfdbbc27182b1047cd36c9d4d5f

2024-06-06 Thread Steven Rostedt


Is there something new since the last report?

 https://lore.kernel.org/all/202406060125.8ggeepjs-...@intel.com/

If not, can we please not keep spamming, as it makes it harder to know
what to fix and what has been fixed.

-- Steve


On Fri, 07 Jun 2024 01:15:11 +0800
kernel test robot  wrote:

> tree/branch: 
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> branch HEAD: ee78a17615ad0cfdbbc27182b1047cd36c9d4d5f  Add linux-next 
> specific files for 20240606
> 
> Error/Warning reports:
> 
> https://lore.kernel.org/oe-kbuild-all/202406061744.rzdxfrrg-...@intel.com
> 
> Error/Warning: (recently discovered and may have been fixed)
> 
> kernel/trace/trace_selftest.c:761: warning: "BYTE_NUMBER" redefined
> 
> Unverified Error/Warning (likely false positive, please contact us if 
> interested):
> 
> arch/microblaze/boot/dts/system.dts:20.9-23.4: Warning (unit_address_vs_reg): 
> /memory: node has a reg or ranges property, but no unit name
> arch/microblaze/boot/dts/system.dts:272.4-19: Warning (clocks_property): 
> /amba_pl/dma@41e0:clocks: cell 0 is not a phandle reference
> arch/microblaze/boot/dts/system.dts:284.4-19: Warning (clocks_property): 
> /amba_pl/timer@41c0:clocks: cell 0 is not a phandle reference
> arch/microblaze/boot/dts/system.dts:339.4-19: Warning (clocks_property): 
> /amba_pl/i2c@4080:clocks: cell 0 is not a phandle reference
> arch/microblaze/boot/dts/system.dts:483.25-486.6: Warning 
> (unit_address_format): /amba_pl/flash@6000/partition@0x: unit 
> name should not have leading "0x"
> arch/microblaze/boot/dts/system.dts:483.25-486.6: Warning 
> (unit_address_format): /amba_pl/flash@6000/partition@0x: unit 
> name should not have leading 0s
> arch/microblaze/boot/dts/system.dts:50.4-19: Warning (clocks_property): 
> /cpus/cpu@0:clocks: cell 0 is not a phandle reference
> arch/microblaze/boot/dts/system.dts:560.4-19: Warning (clocks_property): 
> /amba_pl/serial@44a0:clocks: cell 0 is not a phandle reference
> arch/microblaze/boot/dts/system.dts:579.15-588.4: Warning (simple_bus_reg): 
> /amba_pl/gpio-restart: missing or empty reg/ranges property
> 
> Error/Warning ids grouped by kconfigs:
> 
> gcc_recent_errors
> |-- alpha-randconfig-r123-20240606
> |   `-- drivers-hwmon-cros_ec_hwmon.c:sparse:sparse:cast-to-restricted-__le16
> |-- loongarch-defconfig
> |   |-- 
> drivers-gpu-drm-amd-amdgpu-..-display-dc-hubbub-dcn401-dcn401_hubbub.o:warning:objtool:unexpected-relocation-symbol-type-in-.rela.discard.reachable
> |   `-- 
> drivers-thermal-thermal_trip.o:warning:objtool:unexpected-relocation-symbol-type-in-.rela.discard.reachable
> |-- microblaze-buildonly-randconfig-r001-20230308
> |   |-- 
> arch-microblaze-boot-dts-system.dts.-.:Warning-(simple_bus_reg):amba_pl-gpio-restart:missing-or-empty-reg-ranges-property
> |   |-- 
> arch-microblaze-boot-dts-system.dts.-.:Warning-(unit_address_format):amba_pl-flash-partition:unit-name-should-not-have-leading
> |   |-- 
> arch-microblaze-boot-dts-system.dts.-.:Warning-(unit_address_format):amba_pl-flash-partition:unit-name-should-not-have-leading-0s
> |   |-- 
> arch-microblaze-boot-dts-system.dts.-.:Warning-(unit_address_vs_reg):memory:node-has-a-reg-or-ranges-property-but-no-unit-name
> |   |-- 
> arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-dma-41e0:clocks:cell-is-not-a-phandle-reference
> |   |-- 
> arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-i2c:clocks:cell-is-not-a-phandle-reference
> |   |-- 
> arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-serial-44a0:clocks:cell-is-not-a-phandle-reference
> |   |-- 
> arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-timer-41c0:clocks:cell-is-not-a-phandle-reference
> |   `-- 
> arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):cpus-cpu:clocks:cell-is-not-a-phandle-reference
> |-- openrisc-randconfig-r121-20240606
> |   `-- 
> drivers-clk-qcom-camcc-sm7150.c:sparse:sparse:symbol-camcc_sm7150_hws-was-not-declared.-Should-it-be-static
> |-- sh-randconfig-c004-20211223
> |   `-- kernel-trace-trace_selftest.c:warning:BYTE_NUMBER-redefined
> |-- sh-randconfig-r111-20240606
> |   |-- 
> include-linux-container_of.h:error:struct-ftrace_ops-has-no-member-named-list
> |   |-- include-linux-list.h:error:struct-ftrace_ops-has-no-member-named-list
> |   |-- 
> include-linux-stddef.h:error:struct-ftrace_ops-has-no-member-named-list
> |   |-- 
> kernel-trace-fgraph.c:error:implicit-declaration-of-function-ftrace_shutdown_subops
> |   |-- 
> kernel-trace-fgraph.c:error:implicit-declaration-of-function-ftrace_startup_subops
> |   `-- 
> kernel-trace-fgraph.c:error:

Re: [PATCH v10 6/6] Documentation: iio: Document high-speed DMABUF based API

2024-06-06 Thread Randy Dunlap
Hi,

On 6/5/24 4:08 AM, Paul Cercueil wrote:
> Document the new DMABUF based API.
> 
> Signed-off-by: Paul Cercueil 
> Signed-off-by: Nuno Sa 
> 
> ---
> v2: - Explicitly state that the new interface is optional and is
>   not implemented by all drivers.
> - The IOCTLs can now only be called on the buffer FD returned by
>   IIO_BUFFER_GET_FD_IOCTL.
> - Move the page up a bit in the index since it is core stuff and not
>   driver-specific.
> 
> v3: Update the documentation to reflect the new API.
> 
> v5: Use description lists for the documentation of the three new IOCTLs
> instead of abusing subsections.
> 
> v8: Renamed dmabuf_api.rst -> iio_dmabuf_api.rst, and updated index.rst
> whose format changed in iio/togreg.
> ---
>  Documentation/iio/iio_dmabuf_api.rst | 54 
>  Documentation/iio/index.rst  |  1 +
>  2 files changed, 55 insertions(+)
>  create mode 100644 Documentation/iio/iio_dmabuf_api.rst
> 
> diff --git a/Documentation/iio/iio_dmabuf_api.rst 
> b/Documentation/iio/iio_dmabuf_api.rst
> new file mode 100644
> index ..1cd6cd51a582
> --- /dev/null
> +++ b/Documentation/iio/iio_dmabuf_api.rst
> @@ -0,0 +1,54 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +===
> +High-speed DMABUF interface for IIO
> +===
> +
> +1. Overview
> +===
> +
> +The Industrial I/O subsystem supports access to buffers through a
> +file-based interface, with read() and write() access calls through the
> +IIO device's dev node.
> +
> +It additionally supports a DMABUF based interface, where the userspace
> +can attach DMABUF objects (externally created) to a IIO buffer, and

I would say/write:to an IIO buffer,

> +subsequently use them for data transfers.
> +
> +A userspace application can then use this interface to share DMABUF
> +objects between several interfaces, allowing it to transfer data in a
> +zero-copy fashion, for instance between IIO and the USB stack.
> +
> +The userspace application can also memory-map the DMABUF objects, and
> +access the sample data directly. The advantage of doing this vs. the
> +read() interface is that it avoids an extra copy of the data between the
> +kernel and userspace. This is particularly useful for high-speed devices
> +which produce several megabytes or even gigabytes of data per second.
> +It does however increase the userspace-kernelspace synchronization
> +overhead, as the DMA_BUF_SYNC_START and DMA_BUF_SYNC_END IOCTLs have to
> +be used for data integrity.
> +
> +2. User API
> +===
> +
> +As part of this interface, three new IOCTLs have been added. These three
> +IOCTLs have to be performed on the IIO buffer's file descriptor,
> +obtained using the IIO_BUFFER_GET_FD_IOCTL() ioctl.
> +
> +  ``IIO_BUFFER_DMABUF_ATTACH_IOCTL(int)``

 (int fd)
?

> +Attach the DMABUF object, identified by its file descriptor, to the
> +IIO buffer. Returns zero on success, and a negative errno value on
> +error.
> +
> +  ``IIO_BUFFER_DMABUF_DETACH_IOCTL(int)``

ditto.

> +Detach the given DMABUF object, identified by its file descriptor,
> +from the IIO buffer. Returns zero on success, and a negative errno
> +value on error.
> +
> +Note that closing the IIO buffer's file descriptor will
> +automatically detach all previously attached DMABUF objects.
> +
> +  ``IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *iio_dmabuf)``
> +Enqueue a previously attached DMABUF object to the buffer queue.
> +Enqueued DMABUFs will be read from (if output buffer) or written to
> +(if input buffer) as long as the buffer is enabled.

thanks.
-- 
#Randy
https://people.kernel.org/tglx/notes-about-netiquette
https://subspace.kernel.org/etiquette.html


Re: [PATCH 1/2] drm: Add DRM-managed drm_mm_init()

2024-06-06 Thread Rodrigo Vivi
On Fri, May 24, 2024 at 03:35:17PM +0200, Michal Wajdeczko wrote:
> Add drmm_mm_init(), a helper that provides managed allocator cleanup.
> The allocator will be cleaned up with the final reference of the DRM
> device.
> 
> Signed-off-by: Michal Wajdeczko 
> Cc: Thomas Zimmermann 
> Cc: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_managed.c | 27 +++
>  include/drm/drm_managed.h |  3 +++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
> index 7646f67bda4e..2fb9656bada3 100644
> --- a/drivers/gpu/drm/drm_managed.c
> +++ b/drivers/gpu/drm/drm_managed.c
> @@ -13,6 +13,7 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  
>  #include "drm_internal.h"
> @@ -310,3 +311,29 @@ void __drmm_mutex_release(struct drm_device *dev, void 
> *res)
>   mutex_destroy(lock);
>  }
>  EXPORT_SYMBOL(__drmm_mutex_release);
> +
> +static void __drmm_mm_takedown(struct drm_device *dev, void *res)
> +{
> + struct drm_mm *mm = res;
> +
> + drm_mm_takedown(mm);
> +}
> +
> +/**
> + * drmm_mm_init - &drm_device managed drm_mm_init()
> + * @dev: DRM device
> + * @mm: the drm_mm structure to initialize
> + * @start: start of the range managed by @mm
> + * @size: end of the range managed by @mm
> + *
> + * This is a &drm_device managed version of drm_mm_init().
> + * The initialized allocator will be cleaned up on the final drm_dev_put().
> + *
> + * Return: 0 on success, or a negative errno code otherwise.
> + */
> +int drmm_mm_init(struct drm_device *dev, struct drm_mm *mm, u64 start, u64 
> size)
> +{
> + drm_mm_init(mm, start, size);
> + return drmm_add_action_or_reset(dev, __drmm_mm_takedown, mm);
> +}
> +EXPORT_SYMBOL(drmm_mm_init);
> diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
> index f547b09ca023..e8c2f29cb88a 100644
> --- a/include/drm/drm_managed.h
> +++ b/include/drm/drm_managed.h
> @@ -8,6 +8,7 @@
>  #include 
>  
>  struct drm_device;
> +struct drm_mm;
>  struct mutex;
>  
>  typedef void (*drmres_release_t)(struct drm_device *dev, void *res);
> @@ -127,4 +128,6 @@ void __drmm_mutex_release(struct drm_device *dev, void 
> *res);
>   drmm_add_action_or_reset(dev, __drmm_mutex_release, lock);   \
>  })\
>  
> +int drmm_mm_init(struct drm_device *dev, struct drm_mm *mm, u64 start, u64 
> size);

Reviewed-by: Rodrigo Vivi 

> +
>  #endif
> -- 
> 2.43.0
> 


Re: [PATCH 2/2] drm/xe: Use drm_device managed mutex/mm init helpers in GGTT

2024-06-06 Thread Rodrigo Vivi
On Fri, May 24, 2024 at 03:35:18PM +0200, Michal Wajdeczko wrote:
> There is not need for private release action as there are existing
> drmm_mm_init() and drmm_mutex_init() helpers that can be used.
> 
> Signed-off-by: Michal Wajdeczko 
> Cc: Thomas Hellström 
> Cc: Rodrigo Vivi 
> ---
>  drivers/gpu/drm/xe/xe_ggtt.c | 23 +++
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 17e5066763db..7c91fe212dcb 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -96,14 +96,6 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, 
> u64 size)
>   }
>  }
>  
> -static void ggtt_fini_early(struct drm_device *drm, void *arg)
> -{
> - struct xe_ggtt *ggtt = arg;
> -
> - mutex_destroy(&ggtt->lock);
> - drm_mm_takedown(&ggtt->mm);
> -}
> -
>  static void ggtt_fini(struct drm_device *drm, void *arg)
>  {
>   struct xe_ggtt *ggtt = arg;
> @@ -141,6 +133,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>   struct xe_device *xe = tile_to_xe(ggtt->tile);
>   struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>   unsigned int gsm_size;
> + int err;
>  
>   if (IS_SRIOV_VF(xe))
>   gsm_size = SZ_8M; /* GGTT is expected to be 4GiB */
> @@ -189,12 +182,18 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
>   else
>   ggtt->pt_ops = &xelp_pt_ops;
>  
> - drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
> - ggtt->size - xe_wopcm_size(xe));
> - mutex_init(&ggtt->lock);
> + err = drmm_mm_init(&xe->drm, &ggtt->mm, xe_wopcm_size(xe),
> +ggtt->size - xe_wopcm_size(xe));
> + if (err)
> + return err;
> +
> + err = drmm_mutex_init(&xe->drm, &ggtt->lock);
> + if (err)
> + return err;

My first impression here is that we would have a bug here if drmm_mm_init
works, but drmm_mutex_init fails, but we are likely safe because the
probe will also entirely fail if this mutex init fails.

> +
>   primelockdep(ggtt);
>  
> - return drmm_add_action_or_reset(&xe->drm, ggtt_fini_early, ggtt);

But my question here is, why drmm and not devm for this ggtt case that
only makes sense if the hardware/device is up and not about the module
or no reason to keep it alive after the probe failure or device removal.

I know that the question is orthogonal to your patch. But if we decide to
change the course later and move this towards devm, then we need to
get back to the exit function and perhaps regular mutex.

I mean, really nothing against this patch itself, specially if we are
confident that drmm is the way to go with this ggtt. So, I'm not blocking
here:

Reviewed-by: Rodrigo Vivi 

> + return 0;
>  }
>  
>  static void xe_ggtt_invalidate(struct xe_ggtt *ggtt);
> -- 
> 2.43.0
> 


Re: [RFC PATCH 2/3] drm/tidss: Add support for display sharing

2024-06-06 Thread Maxime Ripard
On Wed, May 29, 2024 at 08:16:46PM GMT, Devarsh Thakkar wrote:
> Hi Javier, Maxime, Daniel,
> 
> Sorry for the delay. Please find response inline.
> 
> On 16/05/24 18:21, Daniel Vetter wrote:
> > On Wed, May 15, 2024 at 04:45:09PM +0200, Javier Martinez Canillas wrote:
> >> Devarsh Thakkar  writes:
> 
> [..]
> 
> >>
> >> If I understand you correctly, for now the only real use case is when the
> >> the RTOS owns / manages the complete display pipeline and Linux can only
> >> own video planes.
> >>
> 
> Not exactly, What I mean is that this is the default configuration/example we
> intend to provide to customer as an out-of-box demo . But flexibility is
> provided to customer to modify the display sharing configuration per their
> use-case, for e.g at RTOS side in place of device-tree, we have a sysconfig
> menu [1] using which they can select the desired configuration, furthermore
> they can go ahead and edit the code too, so Linux driver is expected to be
> flexible to support different configurations as supported by the HW.

Everything you stated above can be achieved with the solutions we've
been suggesting too.

> I have a limited view of all possible use-cases which customer may try out
> with different configurations

I think that's a problem in itself. In order to properly reflect and
discuss a solution, we first need to have a problem. "Flexible
solutions" in practice never really work because you always end up not
flexible enough and still have to rework the whole thing. Except it's
now harder to do since you created something complicated first.

> few examples are shared below part from the one discussed earlier :
> 
> [Examples]:
> 1) Customer is running Linux as main OS but using RTOS to control some
> external peripherals like temperature sensor, motion sensor e.t.c. In that
> case if they want to display the sensor data too on the same monitor, then
> they can use the configuration where RTOS use single plane and Linux as the
> DSS master.

How would that work in real-world? If Linux is in charge of the display,
it can shut down the output whenever it wants too, including shutting
down the clocks or power domains, which then would probably make the
firmware crash?

A much more robust solution here would be to have either the firmware in
charge of the display and delegate a few planes, or provide some way for
Linux to access those sensors while being fully in charge of the
display.

> 2) Another configuration could be where RTOS want to control one full
> end-to-end pipeline going to one connector and Linux want to control full
> end-to-end pipeline going to another connector, that can be supported too
> using this scheme (as shared in this series).

That one is easy: you make the firmware adjust the DT when it boots
Linux and thus restrict the part of the display controller it can use.

It's mostly a DT binding issue.

> 3) Also I think, this device-tree based scheme could be leveraged in
> virtualization too with static partitioning based scheme using Xen for e.g. we
> split the DSS resources between host (DOM0) and the guest (DOMU).

I'm not sure you can leverage virtio at the firmware level, but
otherwise, it's pretty much what we've been suggesting the whole time:
make a generic interface between the firmware and Linux, and then write
a KMS driver for that interface.

Then the firmware can delegate planes to Linux, just like the hypervisor
would to a guest VM.

> >> The opposite is supported by the DSS hardware (thanks to its feature that
> >> allows partitioning the register space and having multiple per-host IRQs) 
> >> but it's not a real use case yet. The reason why this case is added to the
> >> DT binding is as you said for flexiblity and make the design future-proof.
>
> Not really, as explained above we are documenting all possible configurations
> which hardware supports as supported in software in the SDK and that's what we
> are aiming for upstream too.

Generally speaking, not all hardware configurations make sense to run
with in Linux, and there's tons of drivers were we support only a
limited set of capabilities precisely because some simply don't work
well with Linux. I'm glad you're (and your organization) is that
committed to Linux, but I don't think having that as an absolute goal is
reasonable.

Let's work on usecases, and make the most of it instead. In your
examples, 2 and 3 make total sense to be supported in Linux. I'm not
sure 1) does.

> [..] I'm probably missing something then here, but if the Linux side of
>  things is expected to keep the current configuration and keep it active
>  for it to work, what use-case would it be useful for?
> 
> >>>
> >>> It's just one of the partitioning possibilities that I mentioned here, 
> >>> that
> >>> Linux is in control of DSS as a whole and the user want the other host 
> >>> (be it
> >>> RTOS or any other core) to control a single plane. For e.g it could be 
> >>> Linux
> >>> (with GPU rendering) displaying

[linux-next:master] BUILD REGRESSION ee78a17615ad0cfdbbc27182b1047cd36c9d4d5f

2024-06-06 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
branch HEAD: ee78a17615ad0cfdbbc27182b1047cd36c9d4d5f  Add linux-next specific 
files for 20240606

Error/Warning reports:

https://lore.kernel.org/oe-kbuild-all/202406061744.rzdxfrrg-...@intel.com

Error/Warning: (recently discovered and may have been fixed)

kernel/trace/trace_selftest.c:761: warning: "BYTE_NUMBER" redefined

Unverified Error/Warning (likely false positive, please contact us if 
interested):

arch/microblaze/boot/dts/system.dts:20.9-23.4: Warning (unit_address_vs_reg): 
/memory: node has a reg or ranges property, but no unit name
arch/microblaze/boot/dts/system.dts:272.4-19: Warning (clocks_property): 
/amba_pl/dma@41e0:clocks: cell 0 is not a phandle reference
arch/microblaze/boot/dts/system.dts:284.4-19: Warning (clocks_property): 
/amba_pl/timer@41c0:clocks: cell 0 is not a phandle reference
arch/microblaze/boot/dts/system.dts:339.4-19: Warning (clocks_property): 
/amba_pl/i2c@4080:clocks: cell 0 is not a phandle reference
arch/microblaze/boot/dts/system.dts:483.25-486.6: Warning 
(unit_address_format): /amba_pl/flash@6000/partition@0x: unit name 
should not have leading "0x"
arch/microblaze/boot/dts/system.dts:483.25-486.6: Warning 
(unit_address_format): /amba_pl/flash@6000/partition@0x: unit name 
should not have leading 0s
arch/microblaze/boot/dts/system.dts:50.4-19: Warning (clocks_property): 
/cpus/cpu@0:clocks: cell 0 is not a phandle reference
arch/microblaze/boot/dts/system.dts:560.4-19: Warning (clocks_property): 
/amba_pl/serial@44a0:clocks: cell 0 is not a phandle reference
arch/microblaze/boot/dts/system.dts:579.15-588.4: Warning (simple_bus_reg): 
/amba_pl/gpio-restart: missing or empty reg/ranges property

Error/Warning ids grouped by kconfigs:

gcc_recent_errors
|-- alpha-randconfig-r123-20240606
|   `-- drivers-hwmon-cros_ec_hwmon.c:sparse:sparse:cast-to-restricted-__le16
|-- loongarch-defconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-dc-hubbub-dcn401-dcn401_hubbub.o:warning:objtool:unexpected-relocation-symbol-type-in-.rela.discard.reachable
|   `-- 
drivers-thermal-thermal_trip.o:warning:objtool:unexpected-relocation-symbol-type-in-.rela.discard.reachable
|-- microblaze-buildonly-randconfig-r001-20230308
|   |-- 
arch-microblaze-boot-dts-system.dts.-.:Warning-(simple_bus_reg):amba_pl-gpio-restart:missing-or-empty-reg-ranges-property
|   |-- 
arch-microblaze-boot-dts-system.dts.-.:Warning-(unit_address_format):amba_pl-flash-partition:unit-name-should-not-have-leading
|   |-- 
arch-microblaze-boot-dts-system.dts.-.:Warning-(unit_address_format):amba_pl-flash-partition:unit-name-should-not-have-leading-0s
|   |-- 
arch-microblaze-boot-dts-system.dts.-.:Warning-(unit_address_vs_reg):memory:node-has-a-reg-or-ranges-property-but-no-unit-name
|   |-- 
arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-dma-41e0:clocks:cell-is-not-a-phandle-reference
|   |-- 
arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-i2c:clocks:cell-is-not-a-phandle-reference
|   |-- 
arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-serial-44a0:clocks:cell-is-not-a-phandle-reference
|   |-- 
arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):amba_pl-timer-41c0:clocks:cell-is-not-a-phandle-reference
|   `-- 
arch-microblaze-boot-dts-system.dts.:Warning-(clocks_property):cpus-cpu:clocks:cell-is-not-a-phandle-reference
|-- openrisc-randconfig-r121-20240606
|   `-- 
drivers-clk-qcom-camcc-sm7150.c:sparse:sparse:symbol-camcc_sm7150_hws-was-not-declared.-Should-it-be-static
|-- sh-randconfig-c004-20211223
|   `-- kernel-trace-trace_selftest.c:warning:BYTE_NUMBER-redefined
|-- sh-randconfig-r111-20240606
|   |-- 
include-linux-container_of.h:error:struct-ftrace_ops-has-no-member-named-list
|   |-- include-linux-list.h:error:struct-ftrace_ops-has-no-member-named-list
|   |-- include-linux-stddef.h:error:struct-ftrace_ops-has-no-member-named-list
|   |-- 
kernel-trace-fgraph.c:error:implicit-declaration-of-function-ftrace_shutdown_subops
|   |-- 
kernel-trace-fgraph.c:error:implicit-declaration-of-function-ftrace_startup_subops
|   `-- 
kernel-trace-fgraph.c:error:struct-ftrace_ops-has-no-member-named-subop_list
|-- um-allyesconfig
|   `-- 
kernel-bpf-verifier.c:error:pcpu_hot-undeclared-(first-use-in-this-function)
`-- x86_64-randconfig-161-20240606
|-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_vm.c-amdgpu_vm_bo_update()-error:we-previously-assumed-bo-could-be-null-(see-line-)
|-- 
drivers-gpu-drm-i915-display-intel_dpt.c-intel_dpt_pin_to_ggtt()-error:uninitialized-symbol-vma-.
|-- 
drivers-gpu-drm-i915-display-intel_fb_pin.c-intel_fb_pin_to_dpt()-error:uninitialized-symbol-vma-.
`-- 
drivers-gpu-drm-i915-display-intel_fb_pin.c-intel_fb_pin_to_dpt()-error:vma-dereferencing-possible-ERR_PTR()
clang_recent_errors
|-- arm-randconfig-r133-20240606
|   |-- 

Re: [PATCH net-next v10 10/14] net: add support for skbs with unreadable frags

2024-06-06 Thread Mina Almasry
On Thu, Jun 6, 2024 at 9:49 AM Mina Almasry  wrote:
>
> On Tue, Jun 4, 2024 at 3:46 AM Paolo Abeni  wrote:
> >
> > On Thu, 2024-05-30 at 20:16 +, Mina Almasry wrote:
> > > diff --git a/net/core/gro.c b/net/core/gro.c
> > > index 26f09c3e830b7..7b9d018f552bd 100644
> > > --- a/net/core/gro.c
> > > +++ b/net/core/gro.c
> > > @@ -422,6 +422,9 @@ static void gro_pull_from_frag0(struct sk_buff *skb, 
> > > int grow)
> > >  {
> > >   struct skb_shared_info *pinfo = skb_shinfo(skb);
> > >
> > > + if (WARN_ON_ONCE(!skb_frags_readable(skb)))
> > > + return;
> > > +
> > >   BUG_ON(skb->end - skb->tail < grow);
> > >
> > >   memcpy(skb_tail_pointer(skb), NAPI_GRO_CB(skb)->frag0, grow);
> > > @@ -443,7 +446,7 @@ static void gro_try_pull_from_frag0(struct sk_buff 
> > > *skb)
> > >  {
> > >   int grow = skb_gro_offset(skb) - skb_headlen(skb);
> > >
> > > - if (grow > 0)
> > > + if (grow > 0 && skb_frags_readable(skb))
> > >   gro_pull_from_frag0(skb, grow);
> > >  }
> >
> > I'm unsure if this was already mentioned, so please pardon the eventual
> > duplicate...
> >
> > The above code is quite critical performance wise, and the previous
> > patch already prevent frag0 from being set to a non paged frag,
>
>
> Hi Paolo!
>
> The last patch, d4d25dd237a61 ("net: support non paged skb frags"),
> AFAICT doesn't prevent frag0 from being a non-paged frag. What we do
> is set ->frag0=skb->data, then prevent it from being reset to
> skb_frag_address() for non-paged skbs. ->frag0 will likely actually be
> a bad value for non-paged frags, so we need to check in
> gro_pul_from_frag0() so that we don't accidentally pull from a bad
> ->frag0 value.
>
> What I think I should do here is what you said. I should make sure
> frag0 and frag0_len is not set if it's a non-paged frag. Then, we
> don't need special checks in gro_pull_from_frag0 I think, because
> skb_gro_may_pull() should detect that frag0_len is 0 and should
> prevent a pull.
>
> I will apply this fix to the next iteration for your review. Let me
> know if I missed something.
>
>

Actually, sorry you're right. As written, d4d25dd237a61 ("net: support
non paged skb frags") prevents frag0 from being a non-paged frag. I
can just drop these excessive checks with no downside. Sorry for the
noise!

-- 
Thanks,
Mina


Re: [PATCH net-next v10 10/14] net: add support for skbs with unreadable frags

2024-06-06 Thread Mina Almasry
On Tue, Jun 4, 2024 at 3:46 AM Paolo Abeni  wrote:
>
> On Thu, 2024-05-30 at 20:16 +, Mina Almasry wrote:
> > diff --git a/net/core/gro.c b/net/core/gro.c
> > index 26f09c3e830b7..7b9d018f552bd 100644
> > --- a/net/core/gro.c
> > +++ b/net/core/gro.c
> > @@ -422,6 +422,9 @@ static void gro_pull_from_frag0(struct sk_buff *skb, 
> > int grow)
> >  {
> >   struct skb_shared_info *pinfo = skb_shinfo(skb);
> >
> > + if (WARN_ON_ONCE(!skb_frags_readable(skb)))
> > + return;
> > +
> >   BUG_ON(skb->end - skb->tail < grow);
> >
> >   memcpy(skb_tail_pointer(skb), NAPI_GRO_CB(skb)->frag0, grow);
> > @@ -443,7 +446,7 @@ static void gro_try_pull_from_frag0(struct sk_buff *skb)
> >  {
> >   int grow = skb_gro_offset(skb) - skb_headlen(skb);
> >
> > - if (grow > 0)
> > + if (grow > 0 && skb_frags_readable(skb))
> >   gro_pull_from_frag0(skb, grow);
> >  }
>
> I'm unsure if this was already mentioned, so please pardon the eventual
> duplicate...
>
> The above code is quite critical performance wise, and the previous
> patch already prevent frag0 from being set to a non paged frag,


Hi Paolo!

The last patch, d4d25dd237a61 ("net: support non paged skb frags"),
AFAICT doesn't prevent frag0 from being a non-paged frag. What we do
is set ->frag0=skb->data, then prevent it from being reset to
skb_frag_address() for non-paged skbs. ->frag0 will likely actually be
a bad value for non-paged frags, so we need to check in
gro_pul_from_frag0() so that we don't accidentally pull from a bad
->frag0 value.

What I think I should do here is what you said. I should make sure
frag0 and frag0_len is not set if it's a non-paged frag. Then, we
don't need special checks in gro_pull_from_frag0 I think, because
skb_gro_may_pull() should detect that frag0_len is 0 and should
prevent a pull.

I will apply this fix to the next iteration for your review. Let me
know if I missed something.


> so what
> about dropping the above additional checks?
>


--
Thanks,
Mina


Re: [PATCH v3 1/4] drm/sched: store the drm_device instead of the device

2024-06-06 Thread Matthew Brost
On Thu, Jun 06, 2024 at 03:18:14PM +0200, Christian König wrote:
> Am 06.06.24 um 15:06 schrieb Pierre-Eric Pelloux-Prayer:
> > When tracing is enabled, being able to identify which device is sending
> > events is useful; for this the next commit will extend events to include
> > drm_device::primary::index.
> 
> That sounds like a rather bad idea since the primary index is really just an
> arbitrary number and not defined for all devices.
> 
> Why not use the device name instead? This way you don't need this change in
> the first place.
> 

+1.

Matt

> Regards,
> Christian.
> 
> > 
> > Since the device member is only used in the drm_* log macros, we can
> > replace it by a drm_device pointer.
> > 
> > Signed-off-by: Pierre-Eric Pelloux-Prayer 
> > 
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 +-
> >   drivers/gpu/drm/etnaviv/etnaviv_sched.c|  2 +-
> >   drivers/gpu/drm/imagination/pvr_queue.c|  2 +-
> >   drivers/gpu/drm/lima/lima_sched.c  |  2 +-
> >   drivers/gpu/drm/msm/msm_ringbuffer.c   |  2 +-
> >   drivers/gpu/drm/nouveau/nouveau_sched.c|  2 +-
> >   drivers/gpu/drm/panfrost/panfrost_job.c|  2 +-
> >   drivers/gpu/drm/panthor/panthor_mmu.c  |  2 +-
> >   drivers/gpu/drm/panthor/panthor_sched.c|  2 +-
> >   drivers/gpu/drm/scheduler/sched_entity.c   |  2 +-
> >   drivers/gpu/drm/scheduler/sched_main.c | 26 +++---
> >   drivers/gpu/drm/v3d/v3d_sched.c| 12 +-
> >   drivers/gpu/drm/xe/xe_execlist.c   |  2 +-
> >   drivers/gpu/drm/xe/xe_gpu_scheduler.c  |  2 +-
> >   drivers/gpu/drm/xe/xe_gpu_scheduler.h  |  2 +-
> >   drivers/gpu/drm/xe/xe_guc_submit.c |  2 +-
> >   include/drm/gpu_scheduler.h|  4 ++--
> >   17 files changed, 35 insertions(+), 35 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index 932dc93b2e63..7f2a68ad8034 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -2738,7 +2738,7 @@ static int amdgpu_device_init_schedulers(struct 
> > amdgpu_device *adev)
> >ring->num_hw_submission, 0,
> >timeout, adev->reset_domain->wq,
> >ring->sched_score, ring->name,
> > -  adev->dev);
> > +  &adev->ddev);
> > if (r) {
> > DRM_ERROR("Failed to create scheduler on ring %s.\n",
> >   ring->name);
> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
> > b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> > index c4b04b0dee16..c4345b68a51f 100644
> > --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> > @@ -138,7 +138,7 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu)
> >  DRM_SCHED_PRIORITY_COUNT,
> >  etnaviv_hw_jobs_limit, etnaviv_job_hang_limit,
> >  msecs_to_jiffies(500), NULL, NULL,
> > -dev_name(gpu->dev), gpu->dev);
> > +dev_name(gpu->dev), gpu->drm);
> > if (ret)
> > return ret;
> > diff --git a/drivers/gpu/drm/imagination/pvr_queue.c 
> > b/drivers/gpu/drm/imagination/pvr_queue.c
> > index 5ed9c98fb599..cdbb6c01e952 100644
> > --- a/drivers/gpu/drm/imagination/pvr_queue.c
> > +++ b/drivers/gpu/drm/imagination/pvr_queue.c
> > @@ -1287,7 +1287,7 @@ struct pvr_queue *pvr_queue_create(struct pvr_context 
> > *ctx,
> >  pvr_dev->sched_wq, 1, 64 * 1024, 1,
> >  msecs_to_jiffies(500),
> >  pvr_dev->sched_wq, NULL, "pvr-queue",
> > -pvr_dev->base.dev);
> > +&pvr_dev->base);
> > if (err)
> > goto err_release_ufo;
> > diff --git a/drivers/gpu/drm/lima/lima_sched.c 
> > b/drivers/gpu/drm/lima/lima_sched.c
> > index bbf3f8feab94..db6ee7650468 100644
> > --- a/drivers/gpu/drm/lima/lima_sched.c
> > +++ b/drivers/gpu/drm/lima/lima_sched.c
> > @@ -526,7 +526,7 @@ int lima_sched_pipe_init(struct lima_sched_pipe *pipe, 
> > const char *name)
> >   1,
> >   lima_job_hang_limit,
> >   msecs_to_jiffies(timeout), NULL,
> > - NULL, name, pipe->ldev->dev);
> > + NULL, name, pipe->ldev->ddev);
> >   }
> >   void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)
> > diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c 
> > b/drivers/gpu/drm/msm/msm_ringbuffer.c
> > index 9d6655f96f0c..3a4b3816f2c9 100644
> > --- a/drivers/gpu/drm/msm/msm_ringbuffer.c
> > +++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
> > @@ -101,7 +101,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct 
> > msm_gpu *gpu, int id,
> > ret =

Re: [PATCH v2 1/3] dt-bindings: vendor-prefixes: Add PrimeView

2024-06-06 Thread Neil Armstrong
Hi,

On Thu, 06 Jun 2024 10:01:02 +0200, Primoz Fiser wrote:
> The Prime View International (PVI) is a LCD panel manufacturer.
> 
> 

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git 
(drm-misc-next)

[1/3] dt-bindings: vendor-prefixes: Add PrimeView
  
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/3b37a419b710797138c31c0f41c2a7d8aa9f62cd
[2/3] dt-bindings: display: simple: Add PrimeView PM070WL4 panel
  
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/d046611a6187379c19c58d928f342c6884fcbbe7
[3/3] drm/panel: simple: Add PrimeView PM070WL4 support
  
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/8d1330d24788e1e28f6939779391ce835f19fbd2

-- 
Neil



Re: [PATCH v3 2/4] dt-bindings: display/msm: hdmi: add qcom,hdmi-tx-8998

2024-06-06 Thread Conor Dooley
On Thu, Jun 06, 2024 at 06:07:48PM +0200, Marc Gonzalez wrote:
> HDMI TX block embedded in the APQ8098.
> 
> Signed-off-by: Marc Gonzalez 

Reviewed-by: Conor Dooley 

Thanks,
Conor.


signature.asc
Description: PGP signature


[PATCH v3 1/4] dt-bindings: display/msm: hdmi: add qcom,hdmi-phy-8998

2024-06-06 Thread Marc Gonzalez
HDMI PHY block embedded in the APQ8098.

Acked-by: Rob Herring (Arm) 
Signed-off-by: Marc Gonzalez 
---
 Documentation/devicetree/bindings/phy/qcom,hdmi-phy-qmp.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/phy/qcom,hdmi-phy-qmp.yaml 
b/Documentation/devicetree/bindings/phy/qcom,hdmi-phy-qmp.yaml
index 83fe4b39b56f4..78607ee3e2e84 100644
--- a/Documentation/devicetree/bindings/phy/qcom,hdmi-phy-qmp.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,hdmi-phy-qmp.yaml
@@ -14,6 +14,7 @@ properties:
   compatible:
 enum:
   - qcom,hdmi-phy-8996
+  - qcom,hdmi-phy-8998
 
   reg:
 maxItems: 6

-- 
2.34.1



[PATCH v3 4/4] arm64: dts: qcom: add HDMI nodes for msm8998

2024-06-06 Thread Marc Gonzalez
From: Arnaud Vrac 

Port device nodes from vendor code.

Signed-off-by: Arnaud Vrac 
Reviewed-by: Dmitry Baryshkov 
Signed-off-by: Marc Gonzalez 
---
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 100 +-
 1 file changed, 99 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/msm8998.dtsi 
b/arch/arm64/boot/dts/qcom/msm8998.dtsi
index ba5e873f0f35f..5c53957da61c5 100644
--- a/arch/arm64/boot/dts/qcom/msm8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8998.dtsi
@@ -2785,7 +2785,7 @@ mmcc: clock-controller@c8c {
 <&mdss_dsi0_phy 0>,
 <&mdss_dsi1_phy 1>,
 <&mdss_dsi1_phy 0>,
-<0>,
+<&hdmi_phy 0>,
 <0>,
 <0>,
 <&gcc GCC_MMSS_GPLL0_DIV_CLK>;
@@ -2890,6 +2890,14 @@ dpu_intf2_out: endpoint {
remote-endpoint = 
<&mdss_dsi1_in>;
};
};
+
+   port@2 {
+   reg = <2>;
+
+   dpu_intf3_out: endpoint {
+   remote-endpoint = 
<&hdmi_in>;
+   };
+   };
};
};
 
@@ -3045,6 +3053,96 @@ mdss_dsi1_phy: phy@c996400 {
 
status = "disabled";
};
+
+   hdmi: hdmi-tx@c9a {
+   compatible = "qcom,hdmi-tx-8998";
+   reg =   <0x0c9a 0x50c>,
+   <0x0078 0x6220>,
+   <0x0c9e 0x2c>;
+   reg-names = "core_physical",
+   "qfprom_physical",
+   "hdcp_physical";
+
+   interrupt-parent = <&mdss>;
+   interrupts = <8>;
+
+   clocks = <&mmcc MDSS_MDP_CLK>,
+<&mmcc MDSS_AHB_CLK>,
+<&mmcc MDSS_HDMI_CLK>,
+<&mmcc MDSS_HDMI_DP_AHB_CLK>,
+<&mmcc MDSS_EXTPCLK_CLK>,
+<&mmcc MDSS_AXI_CLK>,
+<&mmcc MNOC_AHB_CLK>,
+<&mmcc MISC_AHB_CLK>;
+   clock-names =
+   "mdp_core",
+   "iface",
+   "core",
+   "alt_iface",
+   "extp",
+   "bus",
+   "mnoc",
+   "iface_mmss";
+
+   phys = <&hdmi_phy>;
+   #sound-dai-cells = <1>;
+
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <&hdmi_hpd_default
+&hdmi_ddc_default
+&hdmi_cec_default>;
+   pinctrl-1 = <&hdmi_hpd_sleep
+&hdmi_ddc_default
+&hdmi_cec_default>;
+
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   hdmi_in: endpoint {
+   remote-endpoint = 
<&dpu_intf3_out>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+   hdmi_out: endpoint {
+   };
+   };
+   };
+   };
+
+   hdmi_phy: hdmi-phy@c9a0600 {
+   compatible = "qcom,hdmi-phy-8998";
+   reg = <0x0c9a0600 0x18b>,
+ <0x0

[PATCH v3 2/4] dt-bindings: display/msm: hdmi: add qcom,hdmi-tx-8998

2024-06-06 Thread Marc Gonzalez
HDMI TX block embedded in the APQ8098.

Signed-off-by: Marc Gonzalez 
---
 .../devicetree/bindings/display/msm/hdmi.yaml  | 28 --
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/hdmi.yaml 
b/Documentation/devicetree/bindings/display/msm/hdmi.yaml
index 47e97669821c3..d4a2033afea8d 100644
--- a/Documentation/devicetree/bindings/display/msm/hdmi.yaml
+++ b/Documentation/devicetree/bindings/display/msm/hdmi.yaml
@@ -19,14 +19,15 @@ properties:
   - qcom,hdmi-tx-8974
   - qcom,hdmi-tx-8994
   - qcom,hdmi-tx-8996
+  - qcom,hdmi-tx-8998
 
   clocks:
 minItems: 1
-maxItems: 5
+maxItems: 8
 
   clock-names:
 minItems: 1
-maxItems: 5
+maxItems: 8
 
   reg:
 minItems: 1
@@ -142,6 +143,7 @@ allOf:
   properties:
 clocks:
   minItems: 5
+  maxItems: 5
 clock-names:
   items:
 - const: mdp_core
@@ -151,6 +153,28 @@ allOf:
 - const: extp
 hdmi-mux-supplies: false
 
+  - if:
+  properties:
+compatible:
+  contains:
+enum:
+  - qcom,hdmi-tx-8998
+then:
+  properties:
+clocks:
+  minItems: 8
+  maxItems: 8
+clock-names:
+  items:
+- const: mdp_core
+- const: iface
+- const: core
+- const: alt_iface
+- const: extp
+- const: bus
+- const: mnoc
+- const: iface_mmss
+
 additionalProperties: false
 
 examples:

-- 
2.34.1



[PATCH v3 3/4] arm64: dts: qcom: msm8998: add HDMI GPIOs

2024-06-06 Thread Marc Gonzalez
MSM8998 GPIO pin controller reference design defines:

- CEC: pin 31
- DDC: pin 32,33
- HPD: pin 34

Downstream vendor code for reference:

https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/caf_migration/kernel.lnx.4.4.r38-rel/arch/arm/boot/dts/qcom/msm8998-pinctrl.dtsi#L2324-2400

mdss_hdmi_{cec,ddc,hpd}_{active,suspend}

Reviewed-by: Dmitry Baryshkov 
Signed-off-by: Marc Gonzalez 
---
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 28 
 1 file changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8998.dtsi 
b/arch/arm64/boot/dts/qcom/msm8998.dtsi
index e5f051f5a92de..ba5e873f0f35f 100644
--- a/arch/arm64/boot/dts/qcom/msm8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8998.dtsi
@@ -1434,6 +1434,34 @@ blsp2_spi6_default: blsp2-spi6-default-state {
drive-strength = <6>;
bias-disable;
};
+
+   hdmi_cec_default: hdmi-cec-default-state {
+   pins = "gpio31";
+   function = "hdmi_cec";
+   drive-strength = <2>;
+   bias-pull-up;
+   };
+
+   hdmi_ddc_default: hdmi-ddc-default-state {
+   pins = "gpio32", "gpio33";
+   function = "hdmi_ddc";
+   drive-strength = <2>;
+   bias-pull-up;
+   };
+
+   hdmi_hpd_default: hdmi-hpd-default-state {
+   pins = "gpio34";
+   function = "hdmi_hot";
+   drive-strength = <16>;
+   bias-pull-down;
+   };
+
+   hdmi_hpd_sleep: hdmi-hpd-sleep-state {
+   pins = "gpio34";
+   function = "hdmi_hot";
+   drive-strength = <2>;
+   bias-pull-down;
+   };
};
 
remoteproc_mss: remoteproc@408 {

-- 
2.34.1



[PATCH v3 0/4] HDMI TX support in msm8998

2024-06-06 Thread Marc Gonzalez
DT bits required for HDMI TX support in APQ8098 (msm8998 cousin)

Supersedes 

Changes in v3
- Address Rob's comments on patch 2:
  - 'maxItems: 5' for clocks in the 8996 if/then schema
  - match the order of 8996 for the clock-names in common

---
Arnaud Vrac (1):
  arm64: dts: qcom: add HDMI nodes for msm8998

Marc Gonzalez (3):
  dt-bindings: display/msm: hdmi: add qcom,hdmi-phy-8998
  dt-bindings: display/msm: hdmi: add qcom,hdmi-tx-8998
  arm64: dts: qcom: msm8998: add HDMI GPIOs

 .../devicetree/bindings/display/msm/hdmi.yaml  |  28 -
 .../devicetree/bindings/phy/qcom,hdmi-phy-qmp.yaml |   1 +
 arch/arm64/boot/dts/qcom/msm8998.dtsi  | 128 -
 3 files changed, 154 insertions(+), 3 deletions(-)
---
base-commit: 2c4f4d94dcbf6f500b92fff5600989ea23a207e8
change-id: 20240606-hdmi-tx-00ee8e7ddbac

Best regards,
-- 
Marc Gonzalez 



Re: [PATCH v2 2/3] dt-bindings: display: simple: Add PrimeView PM070WL4 panel

2024-06-06 Thread Conor Dooley
On Thu, Jun 06, 2024 at 10:01:03AM +0200, Primoz Fiser wrote:
> Add PrimeView PM070WL4 7.0" 800x480 TFT LCD panel compatible string.
> 
> Signed-off-by: Primoz Fiser 

Acked-by: Conor Dooley 


signature.asc
Description: PGP signature


Re: [PATCH v2 1/3] dt-bindings: vendor-prefixes: Add PrimeView

2024-06-06 Thread Conor Dooley
On Thu, Jun 06, 2024 at 10:01:02AM +0200, Primoz Fiser wrote:
> The Prime View International (PVI) is a LCD panel manufacturer.
> 
> Signed-off-by: Primoz Fiser 

Acked-by: Conor Dooley 


signature.asc
Description: PGP signature


Re: [PATCH] drm/msm/a6xx: Fix A702 UBWC mode

2024-06-06 Thread Dmitry Baryshkov
On Thu, Jun 06, 2024 at 01:10:49PM +0200, Konrad Dybcio wrote:
> UBWC_MODE is a one-bit-wide field, so a value of 2 is obviously bogus.
> 
> Replace it with the correct value (0).
> 
> Fixes: 18397519cb62 ("drm/msm/adreno: Add A702 support")
> Reported-by: Connor Abbott 
> Closes: 
> https://lore.kernel.org/linux-arm-msm/CACu1E7FTN=kwaDJMNiTmFspALzj2+Q-nvsN5ugi=vz4rdug...@mail.gmail.com/
> Signed-off-by: Konrad Dybcio 
> ---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov 
-- 
With best wishes
Dmitry


Re: [PATCH v4] drm/msm/a6xx: use __unused__ to fix compiler warnings for gen7_* includes

2024-06-06 Thread Dmitry Baryshkov
On Wed, Jun 05, 2024 at 11:34:15AM -0700, Abhinav Kumar wrote:
> GCC diagnostic pragma method throws below warnings in some of the versions
> 
> drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:16:9: warning: unknown
> option after '#pragma GCC diagnostic' kind [-Wpragmas]
>   #pragma GCC diagnostic ignored "-Wunused-const-variable"
>   ^
> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:18:0:
> drivers/gpu/drm/msm/adreno/adreno_gen7_0_0_snapshot.h:924:19: warning:
> 'gen7_0_0_external_core_regs' defined but not used [-Wunused-variable]
>   static const u32 *gen7_0_0_external_core_regs[] = {
> ^
> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:19:0:
> drivers/gpu/drm/msm/adreno/adreno_gen7_2_0_snapshot.h:748:19: warning:
> 'gen7_2_0_external_core_regs' defined but not used [-Wunused-variable]
>   static const u32 *gen7_2_0_external_core_regs[] = {
> ^
> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:20:0:
> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1188:43: warning:
> 'gen7_9_0_sptp_clusters' defined but not used [-Wunused-variable]
>   static struct gen7_sptp_cluster_registers gen7_9_0_sptp_clusters[] = {
> ^
> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1438:19: warning:
> 'gen7_9_0_external_core_regs' defined but not used [-Wunused-variable]
>   static const u32 *gen7_9_0_external_core_regs[] = {
> 
> Remove GCC version dependency by using __unused__ for the unused gen7_* 
> includes.
> 
> Changes in v2:
>   - Fix the warnings in the commit text
>   - Use __attribute((__unused__)) instead of local assignment
> 
> changes in v3:
>   - drop the Link from the auto add
> 
> changes in v4:
>   - replace __attribute((__unused__)) with __always_unused
> 
> Fixes: 64d6255650d4 ("drm/msm: More fully implement devcoredump for a7xx")
> Suggested-by: Rob Clark 
> Signed-off-by: Abhinav Kumar 
> ---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 12 
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry


Re: [RFC PATCH 6/8] rust: drm: gem: Add GEM object abstraction

2024-06-06 Thread Daniel Almeida
Hi Danilo, Lina


> On 20 May 2024, at 14:24, Danilo Krummrich  wrote:
> 
> From: Asahi Lina 
> 
> The DRM GEM subsystem is the DRM memory management subsystem used by
> most modern drivers. Add a Rust abstraction to allow Rust DRM driver
> implementations to use it.
> 
> Signed-off-by: Asahi Lina 
> Co-developed-by: Danilo Krummrich 
> Signed-off-by: Danilo Krummrich 
> ---
> rust/bindings/bindings_helper.h |   1 +
> rust/helpers.c  |  23 ++
> rust/kernel/drm/drv.rs  |   4 +-
> rust/kernel/drm/gem/mod.rs  | 406 
> rust/kernel/drm/mod.rs  |   1 +
> 5 files changed, 433 insertions(+), 2 deletions(-)
> create mode 100644 rust/kernel/drm/gem/mod.rs
> 
> diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
> index c591811ccb67..b245db8d5a87 100644
> --- a/rust/bindings/bindings_helper.h
> +++ b/rust/bindings/bindings_helper.h
> @@ -9,6 +9,7 @@
> #include 
> #include 
> #include 
> +#include 
> #include 
> #include 
> #include 
> diff --git a/rust/helpers.c b/rust/helpers.c
> index dc2405772b1a..30e86bf00337 100644
> --- a/rust/helpers.c
> +++ b/rust/helpers.c
> @@ -20,6 +20,7 @@
>  * Sorted alphabetically.
>  */
> 
> +#include 
> #include 
> #include 
> #include 
> @@ -302,6 +303,28 @@ u64 rust_helper_pci_resource_len(struct pci_dev *pdev, 
> int barnr)
> return pci_resource_len(pdev, barnr);
> }
> 
> +#ifdef CONFIG_DRM
> +
> +void rust_helper_drm_gem_object_get(struct drm_gem_object *obj)
> +{
> + drm_gem_object_get(obj);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_drm_gem_object_get);
> +
> +void rust_helper_drm_gem_object_put(struct drm_gem_object *obj)
> +{
> + drm_gem_object_put(obj);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_drm_gem_object_put);
> +
> +__u64 rust_helper_drm_vma_node_offset_addr(struct drm_vma_offset_node *node)
> +{
> + return drm_vma_node_offset_addr(node);
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_drm_vma_node_offset_addr);
> +
> +#endif
> +
> /*
>  * `bindgen` binds the C `size_t` type as the Rust `usize` type, so we can
>  * use it in contexts where Rust expects a `usize` like slice (array) indices.
> diff --git a/rust/kernel/drm/drv.rs b/rust/kernel/drm/drv.rs
> index c5a63663ea21..063b420f57e5 100644
> --- a/rust/kernel/drm/drv.rs
> +++ b/rust/kernel/drm/drv.rs
> @@ -113,7 +113,7 @@ pub struct AllocOps {
> }
> 
> /// Trait for memory manager implementations. Implemented internally.
> -pub trait AllocImpl: Sealed {
> +pub trait AllocImpl: Sealed + drm::gem::IntoGEMObject {
> /// The C callback operations for this memory manager.
> const ALLOC_OPS: AllocOps;
> }
> @@ -243,7 +243,7 @@ pub fn new(parent: &device::Device) -> Result {
> drm: drm::device::Device::new(parent, &vtable)?,
> registered: false,
> vtable,
> -fops: Default::default(), // TODO: GEM abstraction
> +fops: drm::gem::create_fops(),
> _pin: PhantomPinned,
> _p: PhantomData,
> })
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> new file mode 100644
> index ..4cd85d5f1df8
> --- /dev/null
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -0,0 +1,406 @@
> +// SPDX-License-Identifier: GPL-2.0 OR MIT
> +
> +//! DRM GEM API
> +//!
> +//! C header: 
> [`include/linux/drm/drm_gem.h`](../../../../include/linux/drm/drm_gem.h)
> +
> +use alloc::boxed::Box;
> +
> +use crate::{
> +alloc::flags::*,
> +bindings,
> +drm::{device, drv, file},
> +error::{to_result, Result},
> +prelude::*,
> +};
> +use core::{marker::PhantomPinned, mem, ops::Deref, ops::DerefMut};
> +
> +/// GEM object functions, which must be implemented by drivers.
> +pub trait BaseDriverObject: Sync + Send + Sized {
> +/// Create a new driver data object for a GEM object of a given size.
> +fn new(dev: &device::Device, size: usize) -> impl 
> PinInit;
> +
> +/// Open a new handle to an existing object, associated with a File.
> +fn open(
> +_obj: &<::Driver as drv::Driver>::Object,
> +_file: &file::File<<::Driver as 
> drv::Driver>::File>,

I wonder if these can be put into a type alias? As in,

type File = file::File<<::Driver as 
drv::Driver>::File>;

etc

That would clean things up a bit.

> +) -> Result {
> +Ok(())
> +}
> +
> +/// Close a handle to an existing object, associated with a File.
> +fn close(
> +_obj: &<::Driver as drv::Driver>::Object,
> +_file: &file::File<<::Driver as 
> drv::Driver>::File>,
> +) {
> +}
> +}
> +
> +/// Trait that represents a GEM object subtype
> +pub trait IntoGEMObject: Sized + crate::private::Sealed {
> +/// Owning driver for this type
> +type Driver: drv::Driver;
> +
> +/// Returns a reference to the raw `drm_gem_object` structure, which 
> must be valid as long as
> +/// this owning object is valid.
> +fn gem_obj(&self) -> &bindings::drm_gem_object;
> +
> +/// Converts a pointer to a `drm_gem_object` into

Re: [PATCH 12/14] dt-bindings: display: rockchip,dw-hdmi: Add compatible for RK3588

2024-06-06 Thread Rob Herring
On Thu, Jun 6, 2024 at 5:51 AM Cristian Ciocaltea
 wrote:
>
> On 6/6/24 2:22 AM, Rob Herring wrote:
> > On Sat, Jun 01, 2024 at 04:12:34PM +0300, Cristian Ciocaltea wrote:
> >> Document the Synopsys DesignWare HDMI 2.1 Quad-Pixel (QP) TX controller
> >> found on Rockchip RK3588 SoC family.
> >>
> >> Since RK3588 uses different clocks than previous Rockchip SoCs and also
> >> requires a couple of reset lines and some additional properties, provide
> >> the required changes in the binding to accommodate all variants.
> >>
> >> Signed-off-by: Cristian Ciocaltea 
> >> ---
> >>  .../display/rockchip/rockchip,dw-hdmi.yaml | 127 
> >> +++--
> >>  1 file changed, 90 insertions(+), 37 deletions(-)
> >>
> >> diff --git 
> >> a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml 
> >> b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
> >> index 2aac62219ff6..60d6b815227f 100644
> >> --- 
> >> a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
> >> +++ 
> >> b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
> >> @@ -10,12 +10,10 @@ maintainers:
> >>- Mark Yao 
> >>
> >>  description: |
> >> -  The HDMI transmitter is a Synopsys DesignWare HDMI 1.4 TX controller IP
> >> -  with a companion PHY IP.
> >> -
> >> -allOf:
> >> -  - $ref: ../bridge/synopsys,dw-hdmi.yaml#
> >> -  - $ref: /schemas/sound/dai-common.yaml#
> >> +  For SoCs up to RK3568, the HDMI transmitter is a Synopsys DesignWare
> >> +  HDMI 1.4 TX controller IP with a companion PHY IP.
> >> +  The RK3588 SoC integrates the Synopsys DesignWare HDMI 2.1 Quad-Pixel 
> >> (QP)
> >> +  TX controller IP and a HDMI/eDP TX Combo PHY based on a Samsung IP 
> >> block.
> >>
> >>  properties:
> >>compatible:
> >> @@ -25,6 +23,7 @@ properties:
> >>- rockchip,rk3328-dw-hdmi
> >>- rockchip,rk3399-dw-hdmi
> >>- rockchip,rk3568-dw-hdmi
> >> +  - rockchip,rk3588-dw-hdmi
> >>
> >>reg-io-width:
> >>  const: 4
> >> @@ -40,36 +39,6 @@ properties:
> >>A 1.8V supply that powers up the SoC internal circuitry. The pin 
> >> name on the
> >>SoC usually is HDMI_TX_AVDD_1V8.
> >>
> >> -  clocks:
> >> -minItems: 2
> >> -items:
> >> -  - {}
> >> -  - {}
> >> -  # The next three clocks are all optional, but shall be specified in 
> >> this
> >> -  # order when present.
> >> -  - description: The HDMI CEC controller main clock
> >> -  - description: Power for GRF IO
> >> -  - description: External clock for some HDMI PHY (old clock name, 
> >> deprecated)
> >> -  - description: External clock for some HDMI PHY (new name)
> >> -
> >> -  clock-names:
> >> -minItems: 2
> >> -items:
> >> -  - {}
> >> -  - {}
> >> -  - enum:
> >> -  - cec
> >> -  - grf
> >> -  - vpll
> >> -  - ref
> >> -  - enum:
> >> -  - grf
> >> -  - vpll
> >> -  - ref
> >> -  - enum:
> >> -  - vpll
> >> -  - ref
> >> -
> >>ddc-i2c-bus:
> >>  $ref: /schemas/types.yaml#/definitions/phandle
> >>  description:
> >> @@ -131,13 +100,97 @@ properties:
> >>  required:
> >>- compatible
> >>- reg
> >> -  - reg-io-width
> >>- clocks
> >>- clock-names
> >>- interrupts
> >>- ports
> >>- rockchip,grf
> >>
> >> +allOf:
> >> +  - $ref: /schemas/sound/dai-common.yaml#
> >> +  - if:
> >> +  properties:
> >> +compatible:
> >> +  contains:
> >> +enum:
> >> +  - rockchip,rk3588-dw-hdmi
> >> +then:
> >> +  properties:
> >> +reg:
> >> +  maxItems: 1
> >> +
> >> +clocks:
> >> +  minItems: 1
> >> +  items:
> >> +- description: APB system interface clock
> >> +# The next clocks are optional, but shall be specified in this
> >> +# order when present.
> >> +- description: TMDS/FRL link clock
> >> +- description: EARC RX biphase clock
> >> +- description: Reference clock
> >> +- description: Audio interface clock
> >> +- description: Video datapath clock
> >> +
> >> +clock-names:
> >> +  minItems: 1
> >> +  items:
> >> +- const: pclk
> >> +- enum: [hdp, earc, ref, aud, hclk_vo1]
> >> +- enum: [earc, ref, aud, hclk_vo1]
> >> +- enum: [ref, aud, hclk_vo1]
> >> +- enum: [aud, hclk_vo1]
> >> +- const: hclk_vo1
> >> +
> >> +resets:
> >> +  minItems: 2
> >> +  maxItems: 2
> >> +
> >> +reset-names:
> >> +  items:
> >> +- const: ref
> >> +- const: hdp
> >> +
> >> +interrupts:
> >> +  minItems: 1
> >> +  maxItems: 5
> >> +
> >> +rockchip,vo1_grf:
> >> +  $ref: /schemas/types.yaml#/definitions/phandle
> >> +  description: 

Re: [syzbot] [mm?] general protection fault in dequeue_hugetlb_folio_nodemask

2024-06-06 Thread Mario Limonciello

On 6/6/2024 09:39, syzbot wrote:

Hello,

syzbot found the following issue on:

HEAD commit:0e1980c40b6e Add linux-next specific files for 20240531
git tree:   linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=166086f298
kernel config:  https://syzkaller.appspot.com/x/.config?x=d9c3ca4e54577b88
dashboard link: https://syzkaller.appspot.com/bug?extid=c019f68a83ef9b456444
compiler:   Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 
2.40
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=12f4094a98
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15e1e43298

Downloadable assets:
disk image: 
https://storage.googleapis.com/syzbot-assets/44fb1d8b5978/disk-0e1980c4.raw.xz
vmlinux: 
https://storage.googleapis.com/syzbot-assets/a66ce5caf0b2/vmlinux-0e1980c4.xz
kernel image: 
https://storage.googleapis.com/syzbot-assets/8992fc8fe046/bzImage-0e1980c4.xz

The issue was bisected to:

commit cd94d1b182d2986378550c9087571991bfee01d4
Author: Mario Limonciello 
Date:   Thu May 2 18:32:17 2024 +

 dm/amd/pm: Fix problems with reboot/shutdown for some SMU 13.0.4/13.0.11 
users

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=176121c298
console output: https://syzkaller.appspot.com/x/log.txt?x=10e121c298

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c019f68a83ef9b456...@syzkaller.appspotmail.com
Fixes: cd94d1b182d2 ("dm/amd/pm: Fix problems with reboot/shutdown for some SMU 
13.0.4/13.0.11 users")

Oops: general protection fault, probably for non-canonical address 
0xdc000489:  [#1] PREEMPT SMP KASAN PTI
KASAN: probably user-memory-access in range 
[0x2448-0x244f]
CPU: 1 PID: 5089 Comm: syz-executor257 Not tainted 
6.10.0-rc1-next-20240531-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
04/02/2024
RIP: 0010:zonelist_zone_idx include/linux/mmzone.h:1613 [inline]
RIP: 0010:next_zones_zonelist include/linux/mmzone.h:1644 [inline]
RIP: 0010:first_zones_zonelist include/linux/mmzone.h:1670 [inline]
RIP: 0010:dequeue_hugetlb_folio_nodemask+0x193/0xe40 mm/hugetlb.c:1362
Code: 13 9b a0 ff c7 44 24 14 00 00 00 00 83 7c 24 40 00 0f 85 97 0c 00 00 48 83 7c 
24 20 00 0f 85 45 09 00 00 48 89 d8 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 85 58 
09 00 00 44 8b 33 44 89 f7 8b 5c 24
RSP: 0018:c900035ef720 EFLAGS: 00010002
RAX: 0489 RBX: 2448 RCX: 888026ef
RDX:  RSI:  RDI: 
RBP: c900035ef858 R08: 81f5e070 R09: f520006bdee8
R10: dc00 R11: f520006bdee8 R12: 
R13: dc00 R14:  R15: 
FS:  64010380() GS:8880b950() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 005fdeb8 CR3: 7bd96000 CR4: 003506f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
  
  alloc_hugetlb_folio_nodemask+0xae/0x3f0 mm/hugetlb.c:2603
  memfd_alloc_folio+0x15e/0x390 mm/memfd.c:75
  memfd_pin_folios+0x1066/0x1720 mm/gup.c:3864
  udmabuf_create+0x658/0x11c0 drivers/dma-buf/udmabuf.c:353
  udmabuf_ioctl_create drivers/dma-buf/udmabuf.c:420 [inline]
  udmabuf_ioctl+0x304/0x4f0 drivers/dma-buf/udmabuf.c:451
  vfs_ioctl fs/ioctl.c:51 [inline]
  __do_sys_ioctl fs/ioctl.c:907 [inline]
  __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893
  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
  do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
  entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5151a7a369
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 
48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 
c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:7ffd962ee9e8 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 7ffd962eebb8 RCX: 7f5151a7a369
RDX: 22c0 RSI: 40187542 RDI: 0003
RBP: 7f5151aed610 R08: 7ffd962eebb8 R09: 7ffd962eebb8
R10: 7ffd962eebb8 R11: 0246 R12: 0001
R13: 7ffd962eeba8 R14: 0001 R15: 0001
  
Modules linked in:
---[ end trace  ]---
RIP: 0010:zonelist_zone_idx include/linux/mmzone.h:1613 [inline]
RIP: 0010:next_zones_zonelist include/linux/mmzone.h:1644 [inline]
RIP: 0010:first_zones_zonelist include/linux/mmzone.h:1670 [inline]
RIP: 0010:dequeue_hugetlb_folio_nodemask+0x193/0xe40 mm/hugetlb.c:1362
Code: 13 9b a0 ff c7 44 24 14 00 00 00 00 83 7c 24 40 00 0f 85 97 0c 00 00 48 83 7c 
24 20 00 0f 85 45 09 00 00 48 89 d8 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 85 58 
09 00 00 44 8b 33 44 89 f7 8b 5c 24
RSP: 0018:c900035ef720 EFLAGS: 00010002
RAX: 0489 RBX: 2448 RCX: 888026e

Re: [PATCH v3 0/6] drm/ci: uprev mesa/IGT and generate testlist

2024-06-06 Thread Helen Koike




On 28/05/2024 23:40, Vignesh Raman wrote:

Uprev mesa and IGT to the latest version and stop vendoring the
testlist into the kernel. Instead, use the testlist from the
IGT build to ensure we do not miss renamed or newly added tests.
Update the xfails with the latest testlist run.

Add farm variable and update device type variable.

https://gitlab.freedesktop.org/vigneshraman/linux/-/pipelines/1187556

Vignesh Raman (6):
   drm/ci: uprev mesa version
   drm/ci: add farm variable
   drm/ci: generate testlist from build
   drm/ci: uprev IGT
   drm/ci: skip driver specific tests
   drm/ci: update xfails for the new testlist

  drivers/gpu/drm/ci/build-igt.sh   |   41 +-
  drivers/gpu/drm/ci/build.sh   |6 +-
  drivers/gpu/drm/ci/container.yml  |   12 +-
  drivers/gpu/drm/ci/gitlab-ci.yml  |   46 +-
  drivers/gpu/drm/ci/igt_runner.sh  |9 +-
  drivers/gpu/drm/ci/image-tags.yml |2 +-
  drivers/gpu/drm/ci/lava-submit.sh |4 +-
  drivers/gpu/drm/ci/test.yml   |   17 +-
  drivers/gpu/drm/ci/testlist.txt   | 2761 -
  .../gpu/drm/ci/xfails/amdgpu-stoney-fails.txt |   41 +-
  .../drm/ci/xfails/amdgpu-stoney-flakes.txt|7 +
  .../gpu/drm/ci/xfails/amdgpu-stoney-skips.txt |   33 +-
  drivers/gpu/drm/ci/xfails/i915-amly-fails.txt |   31 +
  .../gpu/drm/ci/xfails/i915-amly-flakes.txt|9 +
  drivers/gpu/drm/ci/xfails/i915-amly-skips.txt |   22 +-
  drivers/gpu/drm/ci/xfails/i915-apl-fails.txt  |   46 +-
  drivers/gpu/drm/ci/xfails/i915-apl-flakes.txt |6 +
  drivers/gpu/drm/ci/xfails/i915-apl-skips.txt  |   26 +-
  drivers/gpu/drm/ci/xfails/i915-cml-fails.txt  |   38 +
  drivers/gpu/drm/ci/xfails/i915-cml-flakes.txt |6 +
  drivers/gpu/drm/ci/xfails/i915-cml-skips.txt  |   23 +
  drivers/gpu/drm/ci/xfails/i915-glk-fails.txt  |   41 +-
  drivers/gpu/drm/ci/xfails/i915-glk-flakes.txt |7 +
  drivers/gpu/drm/ci/xfails/i915-glk-skips.txt  |   26 +-
  drivers/gpu/drm/ci/xfails/i915-kbl-fails.txt  |   42 +-
  drivers/gpu/drm/ci/xfails/i915-kbl-flakes.txt |7 +-
  drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt  |   36 +-
  drivers/gpu/drm/ci/xfails/i915-tgl-fails.txt  |   77 +-
  drivers/gpu/drm/ci/xfails/i915-tgl-skips.txt  |   28 +-
  drivers/gpu/drm/ci/xfails/i915-whl-fails.txt  |   63 +-
  drivers/gpu/drm/ci/xfails/i915-whl-flakes.txt |6 +
  drivers/gpu/drm/ci/xfails/i915-whl-skips.txt  |   22 +-
  .../drm/ci/xfails/mediatek-mt8173-fails.txt   |   30 +-
  .../drm/ci/xfails/mediatek-mt8173-flakes.txt  |   11 +
  .../drm/ci/xfails/mediatek-mt8173-skips.txt   |   16 +
  .../drm/ci/xfails/mediatek-mt8183-fails.txt   |   21 +-
  .../drm/ci/xfails/mediatek-mt8183-skips.txt   |   18 +
  .../gpu/drm/ci/xfails/meson-g12b-fails.txt|   24 +-
  .../gpu/drm/ci/xfails/meson-g12b-skips.txt|   18 +
  .../gpu/drm/ci/xfails/msm-apq8016-fails.txt   |   12 +-
  .../gpu/drm/ci/xfails/msm-apq8016-skips.txt   |   15 +
  .../gpu/drm/ci/xfails/msm-apq8096-fails.txt   |7 +
  .../gpu/drm/ci/xfails/msm-apq8096-flakes.txt  |6 +
  .../gpu/drm/ci/xfails/msm-apq8096-skips.txt   |   26 +-
  .../msm-sc7180-trogdor-kingoftown-fails.txt   |  175 +-
  .../msm-sc7180-trogdor-kingoftown-flakes.txt  |8 +
  .../msm-sc7180-trogdor-kingoftown-skips.txt   |   19 +
  ...sm-sc7180-trogdor-lazor-limozeen-fails.txt |  175 +-
  ...m-sc7180-trogdor-lazor-limozeen-flakes.txt |6 +
  ...sm-sc7180-trogdor-lazor-limozeen-skips.txt |   16 +
  .../gpu/drm/ci/xfails/msm-sdm845-fails.txt|   38 +-
  .../gpu/drm/ci/xfails/msm-sdm845-flakes.txt   |   25 +-
  .../gpu/drm/ci/xfails/msm-sdm845-skips.txt|   19 +
  .../drm/ci/xfails/rockchip-rk3288-fails.txt   |   62 +-
  .../drm/ci/xfails/rockchip-rk3288-skips.txt   |   21 +-
  .../drm/ci/xfails/rockchip-rk3399-fails.txt   |   83 +-
  .../drm/ci/xfails/rockchip-rk3399-flakes.txt  |   13 +-
  .../drm/ci/xfails/rockchip-rk3399-skips.txt   |   19 +
  drivers/gpu/drm/ci/xfails/update-xfails.py|4 +-
  .../drm/ci/xfails/virtio_gpu-none-fails.txt   |   94 +-
  .../drm/ci/xfails/virtio_gpu-none-skips.txt   |   20 +-
  61 files changed, 1348 insertions(+), 3194 deletions(-)
  delete mode 100644 drivers/gpu/drm/ci/testlist.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-amly-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-apl-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-cml-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-glk-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-whl-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/mediatek-mt8173-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/mediatek-mt8173-skips.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/mediatek-mt8183-skips.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/meson-g12b-skips.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/msm-apq8016-skips.txt
  create mode 100644 drivers/gp

[syzbot] [mm?] general protection fault in dequeue_hugetlb_folio_nodemask

2024-06-06 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:0e1980c40b6e Add linux-next specific files for 20240531
git tree:   linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=166086f298
kernel config:  https://syzkaller.appspot.com/x/.config?x=d9c3ca4e54577b88
dashboard link: https://syzkaller.appspot.com/bug?extid=c019f68a83ef9b456444
compiler:   Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 
2.40
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=12f4094a98
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15e1e43298

Downloadable assets:
disk image: 
https://storage.googleapis.com/syzbot-assets/44fb1d8b5978/disk-0e1980c4.raw.xz
vmlinux: 
https://storage.googleapis.com/syzbot-assets/a66ce5caf0b2/vmlinux-0e1980c4.xz
kernel image: 
https://storage.googleapis.com/syzbot-assets/8992fc8fe046/bzImage-0e1980c4.xz

The issue was bisected to:

commit cd94d1b182d2986378550c9087571991bfee01d4
Author: Mario Limonciello 
Date:   Thu May 2 18:32:17 2024 +

dm/amd/pm: Fix problems with reboot/shutdown for some SMU 13.0.4/13.0.11 
users

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=176121c298
console output: https://syzkaller.appspot.com/x/log.txt?x=10e121c298

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c019f68a83ef9b456...@syzkaller.appspotmail.com
Fixes: cd94d1b182d2 ("dm/amd/pm: Fix problems with reboot/shutdown for some SMU 
13.0.4/13.0.11 users")

Oops: general protection fault, probably for non-canonical address 
0xdc000489:  [#1] PREEMPT SMP KASAN PTI
KASAN: probably user-memory-access in range 
[0x2448-0x244f]
CPU: 1 PID: 5089 Comm: syz-executor257 Not tainted 
6.10.0-rc1-next-20240531-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
04/02/2024
RIP: 0010:zonelist_zone_idx include/linux/mmzone.h:1613 [inline]
RIP: 0010:next_zones_zonelist include/linux/mmzone.h:1644 [inline]
RIP: 0010:first_zones_zonelist include/linux/mmzone.h:1670 [inline]
RIP: 0010:dequeue_hugetlb_folio_nodemask+0x193/0xe40 mm/hugetlb.c:1362
Code: 13 9b a0 ff c7 44 24 14 00 00 00 00 83 7c 24 40 00 0f 85 97 0c 00 00 48 
83 7c 24 20 00 0f 85 45 09 00 00 48 89 d8 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 
85 58 09 00 00 44 8b 33 44 89 f7 8b 5c 24
RSP: 0018:c900035ef720 EFLAGS: 00010002
RAX: 0489 RBX: 2448 RCX: 888026ef
RDX:  RSI:  RDI: 
RBP: c900035ef858 R08: 81f5e070 R09: f520006bdee8
R10: dc00 R11: f520006bdee8 R12: 
R13: dc00 R14:  R15: 
FS:  64010380() GS:8880b950() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 005fdeb8 CR3: 7bd96000 CR4: 003506f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 
 alloc_hugetlb_folio_nodemask+0xae/0x3f0 mm/hugetlb.c:2603
 memfd_alloc_folio+0x15e/0x390 mm/memfd.c:75
 memfd_pin_folios+0x1066/0x1720 mm/gup.c:3864
 udmabuf_create+0x658/0x11c0 drivers/dma-buf/udmabuf.c:353
 udmabuf_ioctl_create drivers/dma-buf/udmabuf.c:420 [inline]
 udmabuf_ioctl+0x304/0x4f0 drivers/dma-buf/udmabuf.c:451
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5151a7a369
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 
c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:7ffd962ee9e8 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 7ffd962eebb8 RCX: 7f5151a7a369
RDX: 22c0 RSI: 40187542 RDI: 0003
RBP: 7f5151aed610 R08: 7ffd962eebb8 R09: 7ffd962eebb8
R10: 7ffd962eebb8 R11: 0246 R12: 0001
R13: 7ffd962eeba8 R14: 0001 R15: 0001
 
Modules linked in:
---[ end trace  ]---
RIP: 0010:zonelist_zone_idx include/linux/mmzone.h:1613 [inline]
RIP: 0010:next_zones_zonelist include/linux/mmzone.h:1644 [inline]
RIP: 0010:first_zones_zonelist include/linux/mmzone.h:1670 [inline]
RIP: 0010:dequeue_hugetlb_folio_nodemask+0x193/0xe40 mm/hugetlb.c:1362
Code: 13 9b a0 ff c7 44 24 14 00 00 00 00 83 7c 24 40 00 0f 85 97 0c 00 00 48 
83 7c 24 20 00 0f 85 45 09 00 00 48 89 d8 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 
85 58 09 00 00 44 8b 33 44 89 f7 8b 5c 24
RSP: 0018:c900035ef720 EFLAGS: 00010002
RAX: 0489 RBX: 2448 RCX: 888026ef
RDX:  RSI:  

Re: [PATCH v3 6/6] drm/ci: update xfails for the new testlist

2024-06-06 Thread Helen Koike




On 29/05/2024 06:49, Vignesh Raman wrote:

Hi Dmitry,

On 29/05/24 13:30, Dmitry Baryshkov wrote:

On Wed, May 29, 2024 at 08:10:49AM +0530, Vignesh Raman wrote:

Now the testlist is used from IGT build, so update
xfails with the new testlist.

Set the timeout of all i915 jobs to 1h30m since some jobs
takes more than 1 hour to complete.

Reviewed-by: Dmitry Baryshkov 


This had an explicit '# msm testlist' at the end. Please don't drop
important parts of tags. I didn't review fails/flakes for other
platforms.


Sorry I missed it. Will ask Helen to add the tag back when she merges this.


I'll add it

Acked-by: Helen Koike 

Thanks.
Helen



Regards,
Vignesh




Signed-off-by: Vignesh Raman 
---

v2:
   - Set the timeout of all i915 jobs to 1h30m and updated 
expectations file.


v3:
   - Add a link to the email reporting the flaky tests to the 
maintainers.


---
  drivers/gpu/drm/ci/test.yml   |   6 +-
  .../gpu/drm/ci/xfails/amdgpu-stoney-fails.txt |  41 ++--
  .../drm/ci/xfails/amdgpu-stoney-flakes.txt    |   7 +
  .../gpu/drm/ci/xfails/amdgpu-stoney-skips.txt |  18 ++
  drivers/gpu/drm/ci/xfails/i915-amly-fails.txt |  31 
  .../gpu/drm/ci/xfails/i915-amly-flakes.txt    |   9 +
  drivers/gpu/drm/ci/xfails/i915-amly-skips.txt |  11 ++
  drivers/gpu/drm/ci/xfails/i915-apl-fails.txt  |  46 +++--
  drivers/gpu/drm/ci/xfails/i915-apl-flakes.txt |   6 +
  drivers/gpu/drm/ci/xfails/i915-apl-skips.txt  |  15 ++
  drivers/gpu/drm/ci/xfails/i915-cml-fails.txt  |  38 
  drivers/gpu/drm/ci/xfails/i915-cml-flakes.txt |   6 +
  drivers/gpu/drm/ci/xfails/i915-cml-skips.txt  |  14 ++
  drivers/gpu/drm/ci/xfails/i915-glk-fails.txt  |  41 +++-
  drivers/gpu/drm/ci/xfails/i915-glk-flakes.txt |   7 +
  drivers/gpu/drm/ci/xfails/i915-glk-skips.txt  |  15 ++
  drivers/gpu/drm/ci/xfails/i915-kbl-fails.txt  |  42 ++---
  drivers/gpu/drm/ci/xfails/i915-kbl-flakes.txt |   7 +-
  drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt  |  25 +++
  drivers/gpu/drm/ci/xfails/i915-tgl-fails.txt  |  77 
  drivers/gpu/drm/ci/xfails/i915-tgl-skips.txt  |  17 ++
  drivers/gpu/drm/ci/xfails/i915-whl-fails.txt  |  63 ---
  drivers/gpu/drm/ci/xfails/i915-whl-flakes.txt |   6 +
  drivers/gpu/drm/ci/xfails/i915-whl-skips.txt  |  11 ++
  .../drm/ci/xfails/mediatek-mt8173-fails.txt   |  30 ++-
  .../drm/ci/xfails/mediatek-mt8173-flakes.txt  |  11 ++
  .../drm/ci/xfails/mediatek-mt8173-skips.txt   |   4 +
  .../drm/ci/xfails/mediatek-mt8183-fails.txt   |  21 +--
  .../drm/ci/xfails/mediatek-mt8183-skips.txt   |   4 +
  .../gpu/drm/ci/xfails/meson-g12b-fails.txt    |  24 +--
  .../gpu/drm/ci/xfails/meson-g12b-skips.txt    |   4 +
  .../gpu/drm/ci/xfails/msm-apq8016-fails.txt   |  12 +-
  .../gpu/drm/ci/xfails/msm-apq8016-skips.txt   |   4 +
  .../gpu/drm/ci/xfails/msm-apq8096-fails.txt   |   7 +
  .../gpu/drm/ci/xfails/msm-apq8096-flakes.txt  |   6 +
  .../gpu/drm/ci/xfails/msm-apq8096-skips.txt   |  12 ++
  .../msm-sc7180-trogdor-kingoftown-fails.txt   | 175 +-
  .../msm-sc7180-trogdor-kingoftown-flakes.txt  |   8 +
  .../msm-sc7180-trogdor-kingoftown-skips.txt   |   7 +
  ...sm-sc7180-trogdor-lazor-limozeen-fails.txt | 175 +-
  ...m-sc7180-trogdor-lazor-limozeen-flakes.txt |   6 +
  ...sm-sc7180-trogdor-lazor-limozeen-skips.txt |   4 +
  .../gpu/drm/ci/xfails/msm-sdm845-fails.txt    |  38 +---
  .../gpu/drm/ci/xfails/msm-sdm845-flakes.txt   |  25 ++-
  .../gpu/drm/ci/xfails/msm-sdm845-skips.txt    |   7 +
  .../drm/ci/xfails/rockchip-rk3288-fails.txt   |  62 +--
  .../drm/ci/xfails/rockchip-rk3288-skips.txt   |   4 +
  .../drm/ci/xfails/rockchip-rk3399-fails.txt   |  83 +
  .../drm/ci/xfails/rockchip-rk3399-flakes.txt  |  13 +-
  .../drm/ci/xfails/rockchip-rk3399-skips.txt   |   4 +
  drivers/gpu/drm/ci/xfails/update-xfails.py    |   4 +-
  .../drm/ci/xfails/virtio_gpu-none-fails.txt   |  94 +++---
  .../drm/ci/xfails/virtio_gpu-none-skips.txt   |   4 +
  53 files changed, 1023 insertions(+), 388 deletions(-)
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-amly-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-apl-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-cml-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-glk-flakes.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/i915-whl-flakes.txt
  create mode 100644 
drivers/gpu/drm/ci/xfails/mediatek-mt8173-flakes.txt

  create mode 100644 drivers/gpu/drm/ci/xfails/msm-apq8096-flakes.txt
  create mode 100644 
drivers/gpu/drm/ci/xfails/msm-sc7180-trogdor-kingoftown-flakes.txt
  create mode 100644 
drivers/gpu/drm/ci/xfails/msm-sc7180-trogdor-lazor-limozeen-flakes.txt


diff --git a/drivers/gpu/drm/ci/test.yml b/drivers/gpu/drm/ci/test.yml
index 2615f67f6aa3..322cce714657 100644
--- a/drivers/gpu/drm/ci/test.yml
+++ b/drivers/gpu/drm/ci/test.yml
@@ -191,6 +191,7 @@ rockchip:rk3399:
    extends:
  - .lava-igt:x86_64
    stage: i915
+  timeout: "1h30m"
    variables:
 

Re: [PATCH v3 5/6] drm/ci: skip driver specific tests

2024-06-06 Thread Helen Koike




On 28/05/2024 23:40, Vignesh Raman wrote:

Skip driver specific tests and skip kms tests for
panfrost driver since it is not a kms driver.

Reviewed-by: Dmitry Baryshkov 
Signed-off-by: Vignesh Raman 


Acked-by: Helen Koike 



---

v2:
   - Skip xe tests for amdgpu and virtio.

v3:
   - No changes.

---
  .../gpu/drm/ci/xfails/amdgpu-stoney-skips.txt   | 15 ++-
  drivers/gpu/drm/ci/xfails/i915-amly-skips.txt   | 11 ++-
  drivers/gpu/drm/ci/xfails/i915-apl-skips.txt| 11 ++-
  drivers/gpu/drm/ci/xfails/i915-cml-skips.txt|  9 +
  drivers/gpu/drm/ci/xfails/i915-glk-skips.txt| 11 ++-
  drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt| 11 ++-
  drivers/gpu/drm/ci/xfails/i915-tgl-skips.txt| 11 ++-
  drivers/gpu/drm/ci/xfails/i915-whl-skips.txt| 11 ++-
  .../gpu/drm/ci/xfails/mediatek-mt8173-skips.txt | 12 
  .../gpu/drm/ci/xfails/mediatek-mt8183-skips.txt | 14 ++
  drivers/gpu/drm/ci/xfails/meson-g12b-skips.txt  | 14 ++
  drivers/gpu/drm/ci/xfails/msm-apq8016-skips.txt | 11 +++
  drivers/gpu/drm/ci/xfails/msm-apq8096-skips.txt | 14 +-
  .../msm-sc7180-trogdor-kingoftown-skips.txt | 12 
  .../msm-sc7180-trogdor-lazor-limozeen-skips.txt | 12 
  drivers/gpu/drm/ci/xfails/msm-sdm845-skips.txt  | 12 
  .../gpu/drm/ci/xfails/rockchip-rk3288-skips.txt | 17 -
  .../gpu/drm/ci/xfails/rockchip-rk3399-skips.txt | 15 +++
  .../gpu/drm/ci/xfails/virtio_gpu-none-skips.txt | 16 +++-
  19 files changed, 229 insertions(+), 10 deletions(-)
  create mode 100644 drivers/gpu/drm/ci/xfails/mediatek-mt8173-skips.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/mediatek-mt8183-skips.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/meson-g12b-skips.txt
  create mode 100644 drivers/gpu/drm/ci/xfails/msm-apq8016-skips.txt

diff --git a/drivers/gpu/drm/ci/xfails/amdgpu-stoney-skips.txt 
b/drivers/gpu/drm/ci/xfails/amdgpu-stoney-skips.txt
index e2c538a0f954..21d26d5e67c2 100644
--- a/drivers/gpu/drm/ci/xfails/amdgpu-stoney-skips.txt
+++ b/drivers/gpu/drm/ci/xfails/amdgpu-stoney-skips.txt
@@ -1,2 +1,15 @@
  # Suspend to RAM seems to be broken on this machine
-.*suspend.*
\ No newline at end of file
+.*suspend.*
+
+# Skip driver specific tests
+msm_.*
+nouveau_.*
+panfrost_.*
+^v3d.*
+^vc4.*
+^vmwgfx*
+
+# Skip intel specific tests
+gem_.*
+i915_.*
+xe_.*
diff --git a/drivers/gpu/drm/ci/xfails/i915-amly-skips.txt 
b/drivers/gpu/drm/ci/xfails/i915-amly-skips.txt
index fe55540a3f9a..1e80987cf584 100644
--- a/drivers/gpu/drm/ci/xfails/i915-amly-skips.txt
+++ b/drivers/gpu/drm/ci/xfails/i915-amly-skips.txt
@@ -1,4 +1,13 @@
  # Suspend to RAM seems to be broken on this machine
  .*suspend.*
  # This is generating kernel oops with divide error
-kms_plane_scaling@invalid-parameters
\ No newline at end of file
+kms_plane_scaling@invalid-parameters
+
+# Skip driver specific tests
+^amdgpu.*
+msm_.*
+nouveau_.*
+panfrost_.*
+^v3d.*
+^vc4.*
+^vmwgfx*
diff --git a/drivers/gpu/drm/ci/xfails/i915-apl-skips.txt 
b/drivers/gpu/drm/ci/xfails/i915-apl-skips.txt
index 3430b215c06e..0104f2ffa8ba 100644
--- a/drivers/gpu/drm/ci/xfails/i915-apl-skips.txt
+++ b/drivers/gpu/drm/ci/xfails/i915-apl-skips.txt
@@ -3,4 +3,13 @@
  # This is generating kernel oops with divide error
  kms_plane_scaling@invalid-parameters
  # This is cascading issues
-kms_3d
\ No newline at end of file
+kms_3d
+
+# Skip driver specific tests
+^amdgpu.*
+msm_.*
+nouveau_.*
+panfrost_.*
+^v3d.*
+^vc4.*
+^vmwgfx*
diff --git a/drivers/gpu/drm/ci/xfails/i915-cml-skips.txt 
b/drivers/gpu/drm/ci/xfails/i915-cml-skips.txt
index 6d3d7ddc377f..398ebe163ad0 100644
--- a/drivers/gpu/drm/ci/xfails/i915-cml-skips.txt
+++ b/drivers/gpu/drm/ci/xfails/i915-cml-skips.txt
@@ -1,2 +1,11 @@
  # This is generating kernel oops with divide error
  kms_plane_scaling@invalid-parameters
+
+# Skip driver specific tests
+^amdgpu.*
+msm_.*
+nouveau_.*
+panfrost_.*
+^v3d.*
+^vc4.*
+^vmwgfx*
diff --git a/drivers/gpu/drm/ci/xfails/i915-glk-skips.txt 
b/drivers/gpu/drm/ci/xfails/i915-glk-skips.txt
index 4c7d00ce14bc..4f5419d62170 100644
--- a/drivers/gpu/drm/ci/xfails/i915-glk-skips.txt
+++ b/drivers/gpu/drm/ci/xfails/i915-glk-skips.txt
@@ -2,4 +2,13 @@
  .*suspend.*
  
  # This is generating kernel oops with divide error

-kms_plane_scaling@invalid-parameters
\ No newline at end of file
+kms_plane_scaling@invalid-parameters
+
+# Skip driver specific tests
+^amdgpu.*
+msm_.*
+nouveau_.*
+panfrost_.*
+^v3d.*
+^vc4.*
+^vmwgfx*
diff --git a/drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt 
b/drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt
index 4c7d00ce14bc..4f5419d62170 100644
--- a/drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt
+++ b/drivers/gpu/drm/ci/xfails/i915-kbl-skips.txt
@@ -2,4 +2,13 @@
  .*suspend.*
  
  # This is generating kernel oops with divide error

-kms_plane_scaling@invalid-parameters
\ No

Re: [PATCH v3 4/6] drm/ci: uprev IGT

2024-06-06 Thread Helen Koike




On 28/05/2024 23:40, Vignesh Raman wrote:

test-list.txt and test-list-full.txt are not generated for
cross-builds and they are required by drm-ci for testing
arm32 targets. This is fixed in igt-gpu-tools. So uprev
IGT to include the commit which fixes this issue. Also
disable building xe driver tests for non-intel platforms.

Reviewed-by: Dmitry Baryshkov 
Signed-off-by: Vignesh Raman 


Acked-by: Helen Koike 



---

v2:
   - Split IGT uprev to seperate patch.

v3:
   - No changes.

---
  drivers/gpu/drm/ci/build-igt.sh  | 4 
  drivers/gpu/drm/ci/gitlab-ci.yml | 2 +-
  2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ci/build-igt.sh b/drivers/gpu/drm/ci/build-igt.sh
index b7d2a49a6db3..eddb5f782a5e 100644
--- a/drivers/gpu/drm/ci/build-igt.sh
+++ b/drivers/gpu/drm/ci/build-igt.sh
@@ -45,6 +45,10 @@ MESON_OPTIONS="-Doverlay=disabled\
 -Dlibunwind=enabled   \
 -Dprefix=/igt"
  
+if [[ "$KERNEL_ARCH" = "arm64" ]] || [[ "$KERNEL_ARCH" = "arm" ]]; then

+MESON_OPTIONS="$MESON_OPTIONS -Dxe_driver=disabled"
+fi
+
  mkdir -p /igt
  meson build $MESON_OPTIONS $EXTRA_MESON_ARGS
  ninja -C build -j${FDO_CI_CONCURRENT:-4} || ninja -C build -j 1
diff --git a/drivers/gpu/drm/ci/gitlab-ci.yml b/drivers/gpu/drm/ci/gitlab-ci.yml
index 8f32de63d92e..1b29c3b6406b 100644
--- a/drivers/gpu/drm/ci/gitlab-ci.yml
+++ b/drivers/gpu/drm/ci/gitlab-ci.yml
@@ -5,7 +5,7 @@ variables:
UPSTREAM_REPO: git://anongit.freedesktop.org/drm/drm
TARGET_BRANCH: drm-next
  
-  IGT_VERSION: d2af13d9f5be5ce23d996e4afd3e45990f5ab977

+  IGT_VERSION: 0df7b9b97f9da0e364f5ee30fe331004b8c86b56
  
DEQP_RUNNER_GIT_URL: https://gitlab.freedesktop.org/anholt/deqp-runner.git

DEQP_RUNNER_GIT_TAG: v0.15.0


Re: [PATCH v3 2/6] drm/ci: add farm variable

2024-06-06 Thread Helen Koike




On 28/05/2024 23:40, Vignesh Raman wrote:

Mesa uses structured logs for logging and debug purpose,
https://mesa.pages.freedesktop.org/-/mesa/-/jobs/59165650/artifacts/results/job_detail.json

Since drm-ci uses the mesa scripts, add the farm variable
and update the device type for missing jobs.

Signed-off-by: Vignesh Raman 


Acked-by: Helen Koike 



---

v3:
   - New commit to add farm variable and update device type variable.

---
  drivers/gpu/drm/ci/test.yml | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ci/test.yml b/drivers/gpu/drm/ci/test.yml
index 8bc63912fddb..2615f67f6aa3 100644
--- a/drivers/gpu/drm/ci/test.yml
+++ b/drivers/gpu/drm/ci/test.yml
@@ -24,6 +24,7 @@
variables:
  HWCI_TEST_SCRIPT: "/install/igt_runner.sh"
  DEBIAN_ARCH: "armhf"
+FARM: collabora
dependencies:
  - testing:arm32
needs:
@@ -39,6 +40,7 @@
variables:
  HWCI_TEST_SCRIPT: "/install/igt_runner.sh"
  DEBIAN_ARCH: "arm64"
+FARM: collabora
dependencies:
  - testing:arm64
needs:
@@ -54,6 +56,7 @@
variables:
  HWCI_TEST_SCRIPT: "/install/igt_runner.sh"
  DEBIAN_ARCH: "amd64"
+FARM: collabora
dependencies:
  - testing:x86_64
needs:
@@ -74,6 +77,7 @@
  S3_ARTIFACT_NAME: "arm64/kernel-files"
  BM_KERNEL: https://${PIPELINE_ARTIFACTS_BASE}/arm64/Image.gz
  BM_CMDLINE: "ip=dhcp console=ttyMSM0,115200n8 $BM_KERNEL_EXTRA_ARGS 
root=/dev/nfs rw nfsrootdebug nfsroot=,tcp,nfsvers=4.2 init=/init $BM_KERNELARGS"
+FARM: google
needs:
  - debian/arm64_test
  - job: testing:arm64
@@ -116,8 +120,9 @@ msm:apq8016:
  - .baremetal-igt-arm64
stage: msm
variables:
+DEVICE_TYPE: apq8016-sbc-usb-host
  DRIVER_NAME: msm
-BM_DTB: https://${PIPELINE_ARTIFACTS_BASE}/arm64/apq8016-sbc-usb-host.dtb
+BM_DTB: https://${PIPELINE_ARTIFACTS_BASE}/arm64/${DEVICE_TYPE}.dtb
  GPU_VERSION: apq8016
  # disabling unused clocks congests with the MDSS runtime PM trying to
  # disable those clocks and causes boot to fail.
@@ -132,9 +137,10 @@ msm:apq8096:
  - .baremetal-igt-arm64
stage: msm
variables:
+DEVICE_TYPE: apq8096-db820c
  DRIVER_NAME: msm
  BM_KERNEL_EXTRA_ARGS: maxcpus=2
-BM_DTB: https://${PIPELINE_ARTIFACTS_BASE}/arm64/apq8096-db820c.dtb
+BM_DTB: https://${PIPELINE_ARTIFACTS_BASE}/arm64/${DEVICE_TYPE}.dtb
  GPU_VERSION: apq8096
  RUNNER_TAG: google-freedreno-db820c
script:
@@ -146,6 +152,7 @@ msm:sdm845:
stage: msm
parallel: 6
variables:
+DEVICE_TYPE: sdm845-cheza-r3
  DRIVER_NAME: msm
  BM_KERNEL: https://${PIPELINE_ARTIFACTS_BASE}/arm64/cheza-kernel
  GPU_VERSION: sdm845


Re: [PATCH v3 1/6] drm/ci: uprev mesa version

2024-06-06 Thread Helen Koike




On 28/05/2024 23:40, Vignesh Raman wrote:

zlib.net is not allowing tarball download anymore and results
in below error in kernel+rootfs_arm32 container build,
urllib.error.HTTPError: HTTP Error 403: Forbidden
urllib.error.HTTPError: HTTP Error 415: Unsupported Media Type

Uprev mesa to latest version which includes a fix for this issue.
https://gitlab.freedesktop.org/mesa/mesa/-/commit/908f444e

Use id_tokens for JWT authentication. Since s3 bucket is migrated to
mesa-rootfs, update the variables accordingly. Also copy helper scripts
to install, so that the ci jobs can use these scripts for logging.

Signed-off-by: Vignesh Raman 


Acked-by: Helen Koike 


---

v2:
   - Uprev to recent version and use id_tokens for JWT authentication

v3:
   - Move adding farm variable and updating device type variable to seperate 
commit

---
  drivers/gpu/drm/ci/build-igt.sh   |  2 +-
  drivers/gpu/drm/ci/build.sh   |  6 +++--
  drivers/gpu/drm/ci/container.yml  | 12 +++--
  drivers/gpu/drm/ci/gitlab-ci.yml  | 44 +--
  drivers/gpu/drm/ci/image-tags.yml |  2 +-
  drivers/gpu/drm/ci/lava-submit.sh |  4 +--
  6 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/ci/build-igt.sh b/drivers/gpu/drm/ci/build-igt.sh
index 500fa4f5c30a..7859554756c4 100644
--- a/drivers/gpu/drm/ci/build-igt.sh
+++ b/drivers/gpu/drm/ci/build-igt.sh
@@ -32,4 +32,4 @@ tar -cf artifacts/igt.tar /igt
  # Pass needed files to the test stage
  S3_ARTIFACT_NAME="igt.tar.gz"
  gzip -c artifacts/igt.tar > ${S3_ARTIFACT_NAME}
-ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${S3_ARTIFACT_NAME} 
https://${PIPELINE_ARTIFACTS_BASE}/${KERNEL_ARCH}/${S3_ARTIFACT_NAME}
+ci-fairy s3cp --token-file "${S3_JWT_FILE}" ${S3_ARTIFACT_NAME} 
https://${PIPELINE_ARTIFACTS_BASE}/${KERNEL_ARCH}/${S3_ARTIFACT_NAME}
diff --git a/drivers/gpu/drm/ci/build.sh b/drivers/gpu/drm/ci/build.sh
index 106f2d40d222..a67871fdcd3f 100644
--- a/drivers/gpu/drm/ci/build.sh
+++ b/drivers/gpu/drm/ci/build.sh
@@ -128,6 +128,7 @@ fi
  # Pass needed files to the test stage
  mkdir -p install
  cp -rfv .gitlab-ci/* install/.
+cp -rfv ci/*  install/.
  cp -rfv install/common install/ci-common
  cp -rfv drivers/gpu/drm/ci/* install/.
  
@@ -141,14 +142,15 @@ if [[ "$UPLOAD_TO_MINIO" = "1" ]]; then

  FILES_TO_UPLOAD="$FILES_TO_UPLOAD $(basename -a $DEVICE_TREES)"
  fi
  
+ls -l "${S3_JWT_FILE}"

  for f in $FILES_TO_UPLOAD; do
-ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" /lava-files/$f \
+ci-fairy s3cp --token-file "${S3_JWT_FILE}" /lava-files/$f \
  https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/$f
  done
  
  S3_ARTIFACT_NAME="kernel-files.tar.zst"

  tar --zstd -cf $S3_ARTIFACT_NAME install
-ci-fairy s3cp --token-file "${CI_JOB_JWT_FILE}" ${S3_ARTIFACT_NAME} 
https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/${S3_ARTIFACT_NAME}
+ci-fairy s3cp --token-file "${S3_JWT_FILE}" ${S3_ARTIFACT_NAME} 
https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/${S3_ARTIFACT_NAME}
  
  echo "Download vmlinux.xz from https://${PIPELINE_ARTIFACTS_BASE}/${DEBIAN_ARCH}/vmlinux.xz";

  fi
diff --git a/drivers/gpu/drm/ci/container.yml b/drivers/gpu/drm/ci/container.yml
index 9764e7921a4f..d6edf3635b23 100644
--- a/drivers/gpu/drm/ci/container.yml
+++ b/drivers/gpu/drm/ci/container.yml
@@ -36,15 +36,15 @@ debian/android_build:
rules:
  - when: never
  
-debian/x86_64_test-android:

+.debian/x86_64_test-android:
rules:
  - when: never
  
-windows_build_vs2019:

+windows_build_msvc:
rules:
  - when: never
  
-windows_test_vs2019:

+windows_test_msvc:
rules:
  - when: never
  
@@ -56,10 +56,6 @@ rustfmt:

 rules:
  - when: never
  
-windows_vs2019:

-   rules:
-- when: never
-
-clang-format:
+windows_msvc:
 rules:
  - when: never
\ No newline at end of file
diff --git a/drivers/gpu/drm/ci/gitlab-ci.yml b/drivers/gpu/drm/ci/gitlab-ci.yml
index 084e3ff8e3f4..8f32de63d92e 100644
--- a/drivers/gpu/drm/ci/gitlab-ci.yml
+++ b/drivers/gpu/drm/ci/gitlab-ci.yml
@@ -1,6 +1,6 @@
  variables:
DRM_CI_PROJECT_PATH: &drm-ci-project-path mesa/mesa
-  DRM_CI_COMMIT_SHA: &drm-ci-commit-sha 
9d162de9a05155e1c4041857a5848842749164cf
+  DRM_CI_COMMIT_SHA: &drm-ci-commit-sha 
e2b9c5a9e3e4f9b532067af8022eaef8d6fc6c00
  
UPSTREAM_REPO: git://anongit.freedesktop.org/drm/drm

TARGET_BRANCH: drm-next
@@ -19,33 +19,47 @@ variables:
bash download-git-cache.sh
rm download-git-cache.sh
set +o xtrace
+  S3_JWT_FILE: /s3_jwt
S3_HOST: s3.freedesktop.org
+  # This bucket is used to fetch the kernel image
+  S3_KERNEL_BUCKET: mesa-rootfs
+  # Bucket for git cache
+  S3_GITCACHE_BUCKET: git-cache
+  # Bucket for the pipeline artifacts pushed to S3
+  S3_ARTIFACTS_BUCKET: artifacts
# per-pipeline artifact storage on MinIO
-  PIPELINE_ARTIFACTS_BASE: 
${S3_HOST}/artifacts/${CI_PROJECT_PATH}/${CI_PIPELINE_ID}
+

[PATCH 6.6 314/744] fbdev: sh7760fb: allow modular build

2024-06-06 Thread Greg Kroah-Hartman
6.6-stable review patch.  If anyone has any objections, please let me know.

--

From: Randy Dunlap 

[ Upstream commit 51084f89d687e14d96278241e5200cde4b0985c7 ]

There is no reason to prohibit sh7760fb from being built as a
loadable module as suggested by Geert, so change the config symbol
from bool to tristate to allow that and change the FB dependency as
needed.

Fixes: f75f71b2c418 ("fbdev/sh7760fb: Depend on FB=y")
Suggested-by: Geert Uytterhoeven 
Signed-off-by: Randy Dunlap 
Cc: Thomas Zimmermann 
Cc: Javier Martinez Canillas 
Cc: John Paul Adrian Glaubitz 
Cc: Sam Ravnborg 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Acked-by: John Paul Adrian Glaubitz 
Acked-by: Javier Martinez Canillas 
Signed-off-by: Helge Deller 
Signed-off-by: Sasha Levin 
---
 drivers/video/fbdev/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index c29754b65c0ec..325298573e120 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -1761,8 +1761,8 @@ config FB_COBALT
depends on FB && MIPS_COBALT
 
 config FB_SH7760
-   bool "SH7760/SH7763/SH7720/SH7721 LCDC support"
-   depends on FB=y && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \
+   tristate "SH7760/SH7763/SH7720/SH7721 LCDC support"
+   depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \
|| CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721)
select FB_IOMEM_HELPERS
help
-- 
2.43.0





[PATCH 6.1 219/473] fbdev: sh7760fb: allow modular build

2024-06-06 Thread Greg Kroah-Hartman
6.1-stable review patch.  If anyone has any objections, please let me know.

--

From: Randy Dunlap 

[ Upstream commit 51084f89d687e14d96278241e5200cde4b0985c7 ]

There is no reason to prohibit sh7760fb from being built as a
loadable module as suggested by Geert, so change the config symbol
from bool to tristate to allow that and change the FB dependency as
needed.

Fixes: f75f71b2c418 ("fbdev/sh7760fb: Depend on FB=y")
Suggested-by: Geert Uytterhoeven 
Signed-off-by: Randy Dunlap 
Cc: Thomas Zimmermann 
Cc: Javier Martinez Canillas 
Cc: John Paul Adrian Glaubitz 
Cc: Sam Ravnborg 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Acked-by: John Paul Adrian Glaubitz 
Acked-by: Javier Martinez Canillas 
Signed-off-by: Helge Deller 
Signed-off-by: Sasha Levin 
---
 drivers/video/fbdev/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index ff95f19224901..37089d5a7ccc5 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -2014,8 +2014,8 @@ config FB_COBALT
depends on FB && MIPS_COBALT
 
 config FB_SH7760
-   bool "SH7760/SH7763/SH7720/SH7721 LCDC support"
-   depends on FB=y && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \
+   tristate "SH7760/SH7763/SH7720/SH7721 LCDC support"
+   depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \
|| CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721)
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
-- 
2.43.0





Re: [PATCH v12 12/13] media: imagination: Round to closest multiple for cropping region

2024-06-06 Thread Andy Shevchenko
On Thu, Jun 06, 2024 at 01:44:59PM +0200, Sebastian Fricke wrote:
> Hey,
> 
> On 04.06.2024 16:23, Devarsh Thakkar wrote:
> > If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up
> > (V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest
> > multiple of requested value while updating the crop rectangle coordinates.
> > 
> > Use the rounding macro which gives preference to rounding down in case two
> > nearest values (high and low) are possible to raise the probability of
> > cropping rectangle falling inside the bound region.
> > 
> > This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl
> > description as documented in v4l uapi [1] which specifies that driver
> > should choose crop rectangle as close as possible if no flags are passed by
> > user-space, as quoted below :
> > 
> > "``0`` - The driver can adjust the rectangle size freely and shall choose a
> > crop/compose rectangle as close as possible to the requested
> > one."
> > 
> > Link: 
> > https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst
> >  [1]
> > Signed-off-by: Devarsh Thakkar 
> 
> Acked-by: Sebastian Fricke 
> 
> Can, whoever picks up the math changes, pick up this change as well?
> I will send 1-6 via the media subsystem.

math.h is orphaned, meaning any Tier-1 maintainer may push this through.
So, there is nobody behind it.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v3 1/2] dt-bindings: display: panel: Add WL-355608-A8 panel

2024-06-06 Thread Neil Armstrong

On 06/06/2024 13:23, Maxime Ripard wrote:

On Thu, Jun 06, 2024 at 11:37:31AM GMT, Neil Armstrong wrote:

On 06/06/2024 11:32, Maxime Ripard wrote:

On Fri, May 31, 2024 at 09:12:14AM GMT, Ryan Walklin wrote:

The WL-355608-A8 is a 3.5" 640x480@60Hz RGB LCD display used in a
number of handheld gaming devices made by Anbernic. By consensus a
vendor prefix is not provided as the panel OEM is unknown.


Where has this consensus been found?

I had a look at the previous discussions, and I can't find any consensus
being reached there. And for that kind of thing, having the ack or
review of any of the DT maintainers would have been great.


There was a consensus with Conor, this is why he acked v2, see
https://lore.kernel.org/all/20240525-velvet-citable-a45dd06847a7@spud/


It's probably a matter of semantics here, but if it's with only one
person, it's not a consensus but an agreement.


```
I think if we genuinely do not know what the vendor is then we just
don't have a prefix.
```


And even then, I don't interpret Conor's statement as a formal agreement
but rather an acknowledgment of the issue.


Well since both maintainers (DT and Panel) agreed, isn't it all good ?




I agree with Conor so I applied the patchset after Connor reviewed it and the 
comment was fixed in v3:
https://lore.kernel.org/all/20240530-satchel-playgroup-e8aa6937b8b9@spud/


Yeah, I know. Still, it's a major deviation to what we've always been
doing, getting the DT maintainers voice on that would have been a good
idea.


I consider Conor's voice enough as one of the DT maintainers.

Neil



Maxime




Re: [PATCH v12 12/13] media: imagination: Round to closest multiple for cropping region

2024-06-06 Thread Devarsh Thakkar
Hi Sebastian

Thanks for the update.
On 06/06/24 17:14, Sebastian Fricke wrote:
> Hey,
> 
> On 04.06.2024 16:23, Devarsh Thakkar wrote:
>> If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up
>> (V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest
>> multiple of requested value while updating the crop rectangle coordinates.
>>
>> Use the rounding macro which gives preference to rounding down in case two
>> nearest values (high and low) are possible to raise the probability of
>> cropping rectangle falling inside the bound region.
>>
>> This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl
>> description as documented in v4l uapi [1] which specifies that driver
>> should choose crop rectangle as close as possible if no flags are passed by
>> user-space, as quoted below :
>>
>> "``0`` - The driver can adjust the rectangle size freely and shall choose a
>> crop/compose rectangle as close as possible to the requested
>> one."
>>
>> Link:
>> https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst
>>  [1]
>> Signed-off-by: Devarsh Thakkar 
> 
> Acked-by: Sebastian Fricke 
> 
> Can, whoever picks up the math changes, pick up this change as well?
> I will send 1-6 via the media subsystem.
> 

For [PATCH 1/13] to [PATCH 6/13] patches from the series,
I see few warnings reported to me offline for some of the patches which were
caught from using smatch/sparse related automation scripts which were somehow
missed by my equivalent test script. The fixes should be trivial though and I
will be rolling out a v13 soon to fix them up.

The rest of the patches (PATCH 7/13 to PATCH 13/13) no smatch/sparse related
warnings were caught for these though, and are good to go in. Although, I can
still include them in V13 too just to avoid any confusion.

Regards
Devarsh


Re: [PATCH v3 1/4] drm/sched: store the drm_device instead of the device

2024-06-06 Thread Ville Syrjälä
On Thu, Jun 06, 2024 at 03:18:14PM +0200, Christian König wrote:
> Am 06.06.24 um 15:06 schrieb Pierre-Eric Pelloux-Prayer:
> > When tracing is enabled, being able to identify which device is sending
> > events is useful; for this the next commit will extend events to include
> > drm_device::primary::index.
> 
> That sounds like a rather bad idea since the primary index is really 
> just an arbitrary number and not defined for all devices.
> 
> Why not use the device name instead? This way you don't need this change 
> in the first place.

FWIW dev_name() is what I added to all i915 display tracepoints.

-- 
Ville Syrjälä
Intel


Re: [PATCH v3 3/4] drm/sched: cleanup gpu_scheduler trace events

2024-06-06 Thread Christian König

Am 06.06.24 um 15:19 schrieb Steven Rostedt:

On Thu, 6 Jun 2024 15:06:24 +0200
Pierre-Eric Pelloux-Prayer  wrote:


Print identifiers instead of pointers:
* "fence=%p" is replaced by "fence=(context:%llu, seqno:%lld)" to have a
coherent way to print the fence. A possible follow up change would be
to use the same format in traces/../dma-fence.h.
* "entity=%p" is removed because the fence's context is already an
identifier of the job owner.

Signed-off-by: Pierre-Eric Pelloux-Prayer 
---
  .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 27 ++-
  1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h 
b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
index 0a19c121bda5..2d7f2252eb5d 100644
--- a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
@@ -58,9 +58,9 @@ DECLARE_EVENT_CLASS(drm_sched_job,
   &sched_job->sched->credit_count);
   __entry->dev_index = 
sched_job->sched->dev->primary->index;
   ),
-   TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job 
count:%d",
- __entry->entity, __entry->id,
- __entry->fence, __get_str(name),
+   TP_printk("id=%llu, fence=(context:%llu, seqno:%lld), ring=%s, job 
count:%u, hw job count:%d",
+ __entry->id,
+ __entry->fence->context, __entry->fence->seqno, 
__get_str(name),
  __entry->job_count, __entry->hw_job_count)
  );
  
@@ -72,9 +72,9 @@ DEFINE_EVENT(drm_sched_job, drm_sched_job,

  DEFINE_EVENT_PRINT(drm_sched_job, drm_run_job,
TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity),
TP_ARGS(sched_job, entity),
-   TP_printk("dev_index=%d entity=%p id=%llu, fence=%p, ring=%s, job 
count:%u, hw job count:%d",
- __entry->dev_index, __entry->entity, __entry->id,
- __entry->fence, __get_str(name),
+   TP_printk("dev_index=%d id=%llu, fence=(context:%llu, seqno:%lld), 
ring=%s, job count:%u, hw job count:%d",
+ __entry->dev_index, __entry->id,
+ __entry->fence->context, __entry->fence->seqno, 
__get_str(name),
  __entry->job_count, __entry->hw_job_count)

NACK!

You can't dereference pointers from TP_printk(). This is called seconds,
minutes, hours, even days or months after that pointer was assigned. How do
you know that pointer still points to anything?


Yeah, just wanted to reply the same thing. That is a really really bad idea.

You could in theory grab a reference to the fence, but we usually try to 
avoid that as well since it prevents modules from unloading.


Rather move the context and seqno directly as values into the trace event.

Christian.



-- Steve



  );
  
@@ -88,7 +88,8 @@ TRACE_EVENT(drm_sched_process_job,

TP_fast_assign(
__entry->fence = &fence->finished;
),
-   TP_printk("fence=%p signaled", __entry->fence)
+   TP_printk("fence=(context:%llu, seqno:%lld) signaled",
+ __entry->fence->context, __entry->fence->seqno)
  );
  
  TRACE_EVENT(drm_sched_job_wait_dep,

@@ -96,23 +97,25 @@ TRACE_EVENT(drm_sched_job_wait_dep,
TP_ARGS(sched_job, fence),
TP_STRUCT__entry(
 __string(name, sched_job->sched->name)
+__field(uint64_t, fence_context)
 __field(uint64_t, id)
 __field(struct dma_fence *, fence)
 __field(uint64_t, ctx)
-__field(unsigned, seqno)
+__field(uint64_t, seqno)
 ),
  
  	TP_fast_assign(

   __assign_str(name);
+  /* Store the hw exec fence context. */
+  __entry->fence_context = 
sched_job->entity->fence_context + 1;
   __entry->id = sched_job->id;
   __entry->fence = fence;
   __entry->ctx = fence->context;
   __entry->seqno = fence->seqno;
   ),
-   TP_printk("job ring=%s, id=%llu, depends fence=%p, context=%llu, 
seq=%u",
- __get_str(name), __entry->id,
- __entry->fence, __entry->ctx,
- __entry->seqno)
+   TP_printk("job ring=%s, fence_context=%llu, id=%llu, depends 
fence=(context:%llu, seqno:%lld)",
+ __get_str(name), __entry->fence_context, __entry->id,
+ __entry->ctx, __entry->seqno)
  );
  
  #endif




Re: [PATCH v3 3/4] drm/sched: cleanup gpu_scheduler trace events

2024-06-06 Thread Steven Rostedt
On Thu, 6 Jun 2024 15:06:24 +0200
Pierre-Eric Pelloux-Prayer  wrote:

> Print identifiers instead of pointers:
> * "fence=%p" is replaced by "fence=(context:%llu, seqno:%lld)" to have a
> coherent way to print the fence. A possible follow up change would be
> to use the same format in traces/../dma-fence.h.
> * "entity=%p" is removed because the fence's context is already an
> identifier of the job owner.
> 
> Signed-off-by: Pierre-Eric Pelloux-Prayer 
> ---
>  .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 27 ++-
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h 
> b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
> index 0a19c121bda5..2d7f2252eb5d 100644
> --- a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
> +++ b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
> @@ -58,9 +58,9 @@ DECLARE_EVENT_CLASS(drm_sched_job,
>  &sched_job->sched->credit_count);
>  __entry->dev_index = 
> sched_job->sched->dev->primary->index;
>  ),
> - TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw 
> job count:%d",
> -   __entry->entity, __entry->id,
> -   __entry->fence, __get_str(name),
> + TP_printk("id=%llu, fence=(context:%llu, seqno:%lld), ring=%s, job 
> count:%u, hw job count:%d",
> +   __entry->id,
> +   __entry->fence->context, __entry->fence->seqno, 
> __get_str(name),
> __entry->job_count, __entry->hw_job_count)
>  );
>  
> @@ -72,9 +72,9 @@ DEFINE_EVENT(drm_sched_job, drm_sched_job,
>  DEFINE_EVENT_PRINT(drm_sched_job, drm_run_job,
>   TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
> *entity),
>   TP_ARGS(sched_job, entity),
> - TP_printk("dev_index=%d entity=%p id=%llu, fence=%p, ring=%s, job 
> count:%u, hw job count:%d",
> -   __entry->dev_index, __entry->entity, __entry->id,
> -   __entry->fence, __get_str(name),
> + TP_printk("dev_index=%d id=%llu, fence=(context:%llu, seqno:%lld), 
> ring=%s, job count:%u, hw job count:%d",
> +   __entry->dev_index, __entry->id,
> +   __entry->fence->context, __entry->fence->seqno, 
> __get_str(name),
> __entry->job_count, __entry->hw_job_count)

NACK!

You can't dereference pointers from TP_printk(). This is called seconds,
minutes, hours, even days or months after that pointer was assigned. How do
you know that pointer still points to anything?

-- Steve


>  );
>  
> @@ -88,7 +88,8 @@ TRACE_EVENT(drm_sched_process_job,
>   TP_fast_assign(
>   __entry->fence = &fence->finished;
>   ),
> - TP_printk("fence=%p signaled", __entry->fence)
> + TP_printk("fence=(context:%llu, seqno:%lld) signaled",
> +   __entry->fence->context, __entry->fence->seqno)
>  );
>  
>  TRACE_EVENT(drm_sched_job_wait_dep,
> @@ -96,23 +97,25 @@ TRACE_EVENT(drm_sched_job_wait_dep,
>   TP_ARGS(sched_job, fence),
>   TP_STRUCT__entry(
>__string(name, sched_job->sched->name)
> +  __field(uint64_t, fence_context)
>__field(uint64_t, id)
>__field(struct dma_fence *, fence)
>__field(uint64_t, ctx)
> -  __field(unsigned, seqno)
> +  __field(uint64_t, seqno)
>),
>  
>   TP_fast_assign(
>  __assign_str(name);
> +/* Store the hw exec fence context. */
> +__entry->fence_context = 
> sched_job->entity->fence_context + 1;
>  __entry->id = sched_job->id;
>  __entry->fence = fence;
>  __entry->ctx = fence->context;
>  __entry->seqno = fence->seqno;
>  ),
> - TP_printk("job ring=%s, id=%llu, depends fence=%p, context=%llu, 
> seq=%u",
> -   __get_str(name), __entry->id,
> -   __entry->fence, __entry->ctx,
> -   __entry->seqno)
> + TP_printk("job ring=%s, fence_context=%llu, id=%llu, depends 
> fence=(context:%llu, seqno:%lld)",
> +   __get_str(name), __entry->fence_context, __entry->id,
> +   __entry->ctx, __entry->seqno)
>  );
>  
>  #endif



Re: [PATCH v3 1/4] drm/sched: store the drm_device instead of the device

2024-06-06 Thread Christian König

Am 06.06.24 um 15:06 schrieb Pierre-Eric Pelloux-Prayer:

When tracing is enabled, being able to identify which device is sending
events is useful; for this the next commit will extend events to include
drm_device::primary::index.


That sounds like a rather bad idea since the primary index is really 
just an arbitrary number and not defined for all devices.


Why not use the device name instead? This way you don't need this change 
in the first place.


Regards,
Christian.



Since the device member is only used in the drm_* log macros, we can
replace it by a drm_device pointer.

Signed-off-by: Pierre-Eric Pelloux-Prayer 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 +-
  drivers/gpu/drm/etnaviv/etnaviv_sched.c|  2 +-
  drivers/gpu/drm/imagination/pvr_queue.c|  2 +-
  drivers/gpu/drm/lima/lima_sched.c  |  2 +-
  drivers/gpu/drm/msm/msm_ringbuffer.c   |  2 +-
  drivers/gpu/drm/nouveau/nouveau_sched.c|  2 +-
  drivers/gpu/drm/panfrost/panfrost_job.c|  2 +-
  drivers/gpu/drm/panthor/panthor_mmu.c  |  2 +-
  drivers/gpu/drm/panthor/panthor_sched.c|  2 +-
  drivers/gpu/drm/scheduler/sched_entity.c   |  2 +-
  drivers/gpu/drm/scheduler/sched_main.c | 26 +++---
  drivers/gpu/drm/v3d/v3d_sched.c| 12 +-
  drivers/gpu/drm/xe/xe_execlist.c   |  2 +-
  drivers/gpu/drm/xe/xe_gpu_scheduler.c  |  2 +-
  drivers/gpu/drm/xe/xe_gpu_scheduler.h  |  2 +-
  drivers/gpu/drm/xe/xe_guc_submit.c |  2 +-
  include/drm/gpu_scheduler.h|  4 ++--
  17 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 932dc93b2e63..7f2a68ad8034 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2738,7 +2738,7 @@ static int amdgpu_device_init_schedulers(struct 
amdgpu_device *adev)
   ring->num_hw_submission, 0,
   timeout, adev->reset_domain->wq,
   ring->sched_score, ring->name,
-  adev->dev);
+  &adev->ddev);
if (r) {
DRM_ERROR("Failed to create scheduler on ring %s.\n",
  ring->name);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
index c4b04b0dee16..c4345b68a51f 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
@@ -138,7 +138,7 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu)
 DRM_SCHED_PRIORITY_COUNT,
 etnaviv_hw_jobs_limit, etnaviv_job_hang_limit,
 msecs_to_jiffies(500), NULL, NULL,
-dev_name(gpu->dev), gpu->dev);
+dev_name(gpu->dev), gpu->drm);
if (ret)
return ret;
  
diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c

index 5ed9c98fb599..cdbb6c01e952 100644
--- a/drivers/gpu/drm/imagination/pvr_queue.c
+++ b/drivers/gpu/drm/imagination/pvr_queue.c
@@ -1287,7 +1287,7 @@ struct pvr_queue *pvr_queue_create(struct pvr_context 
*ctx,
 pvr_dev->sched_wq, 1, 64 * 1024, 1,
 msecs_to_jiffies(500),
 pvr_dev->sched_wq, NULL, "pvr-queue",
-pvr_dev->base.dev);
+&pvr_dev->base);
if (err)
goto err_release_ufo;
  
diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c

index bbf3f8feab94..db6ee7650468 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -526,7 +526,7 @@ int lima_sched_pipe_init(struct lima_sched_pipe *pipe, 
const char *name)
  1,
  lima_job_hang_limit,
  msecs_to_jiffies(timeout), NULL,
- NULL, name, pipe->ldev->dev);
+ NULL, name, pipe->ldev->ddev);
  }
  
  void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)

diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c 
b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 9d6655f96f0c..3a4b3816f2c9 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -101,7 +101,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu 
*gpu, int id,
ret = drm_sched_init(&ring->sched, &msm_sched_ops, NULL,
 DRM_SCHED_PRIORITY_COUNT,
 num_hw_submissions, 0, sched_timeout,
-NULL, NULL, to_msm_bo(ring->bo)->name, 
gpu->dev->dev);
+NULL, NULL, to_msm_bo(ring->bo)->name, gpu->dev);

[PATCH] backlight: lm3509_bl: Fix NULL vs IS_ERR() check in register() function

2024-06-06 Thread Dan Carpenter
The devm_backlight_device_register() doesn't return NULL, it returns
error pointers.  Update the error checking to match.

Fixes: b72755f5b577 ("backlight: Add new lm3509 backlight driver")
Signed-off-by: Dan Carpenter 
---
 drivers/video/backlight/lm3509_bl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/video/backlight/lm3509_bl.c 
b/drivers/video/backlight/lm3509_bl.c
index ab57f79ffe23..c93cdedff5ad 100644
--- a/drivers/video/backlight/lm3509_bl.c
+++ b/drivers/video/backlight/lm3509_bl.c
@@ -114,9 +114,10 @@ lm3509_backlight_register(struct device *dev, const char 
*name_suffix,
}
 
bd = devm_backlight_device_register(dev, label, dev, data, ops, &props);
-   if (bd)
-   backlight_update_status(bd);
+   if (IS_ERR(bd))
+   return bd;
 
+   backlight_update_status(bd);
return bd;
 }
 
-- 
2.43.0



[PATCH v3 4/4] drm/sched: trace dependencies for gpu jobs

2024-06-06 Thread Pierre-Eric Pelloux-Prayer
Trace the fence dependencies similarly to how we print fences:

 ... , dependencies:{(context:606, seqno:38006)}

This allows tools to analyze the dependencies between the jobs (previously
it was only possible for fences traced by drm_sched_job_wait_dep).

Since drm_sched_job and drm_run_job use the same base event class,
the caller of trace_drm_run_job have to pass a dep_count of 0 (which
is ignored because dependencies are only considered at submit time).

Signed-off-by: Pierre-Eric Pelloux-Prayer 
---
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 58 ---
 drivers/gpu/drm/scheduler/sched_entity.c  |  8 ++-
 drivers/gpu/drm/scheduler/sched_main.c|  2 +-
 3 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h 
b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
index 2d7f2252eb5d..9d90237793a1 100644
--- a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "drm/drm_device.h"
@@ -35,9 +36,34 @@
 #define TRACE_SYSTEM gpu_scheduler
 #define TRACE_INCLUDE_FILE gpu_scheduler_trace
 
+#ifndef __TRACE_EVENT_GPU_SCHEDULER_PRINT_FN
+#define __TRACE_EVENT_GPU_SCHEDULER_PRINT_FN
+/* Similar to trace_print_array_seq but for fences. */
+static inline const char *__print_dma_fence_array(struct trace_seq *p, const 
void *buf, int count)
+{
+   const char *ret = trace_seq_buffer_ptr(p);
+   u64 *fences = (u64 *) buf;
+   const char *prefix = "";
+
+   trace_seq_putc(p, '{');
+   for (int i = 0; i < count; i++) {
+   u64 context = fences[2 * i], seqno = fences[2 * i + 1];
+
+   trace_seq_printf(p, "%s(context:%llu, seqno:%lld)",
+prefix, context, seqno);
+   prefix = ",";
+   }
+   trace_seq_putc(p, '}');
+   trace_seq_putc(p, 0);
+
+   return ret;
+}
+#endif
+
 DECLARE_EVENT_CLASS(drm_sched_job,
-   TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity),
-   TP_ARGS(sched_job, entity),
+   TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity,
+unsigned int dep_count),
+   TP_ARGS(sched_job, entity, dep_count),
TP_STRUCT__entry(
 __field(struct drm_sched_entity *, entity)
 __field(struct dma_fence *, fence)
@@ -46,9 +72,14 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 __field(u32, job_count)
 __field(int, hw_job_count)
 __field(int, dev_index)
+__field(int, n_deps)
+__dynamic_array(u64, deps, dep_count * 2)
 ),
 
TP_fast_assign(
+  unsigned long idx;
+  struct dma_fence *fence;
+  u64 *dyn_arr;
   __entry->entity = entity;
   __entry->id = sched_job->id;
   __entry->fence = &sched_job->s_fence->finished;
@@ -57,21 +88,32 @@ DECLARE_EVENT_CLASS(drm_sched_job,
   __entry->hw_job_count = atomic_read(
   &sched_job->sched->credit_count);
   __entry->dev_index = 
sched_job->sched->dev->primary->index;
+  __entry->n_deps = dep_count;
+  if (dep_count) {
+   dyn_arr = __get_dynamic_array(deps);
+   xa_for_each(&sched_job->dependencies, idx, 
fence) {
+   dyn_arr[2 * idx] = fence->context;
+   dyn_arr[2 * idx + 1] = fence->seqno;
+   }
+  }
   ),
-   TP_printk("id=%llu, fence=(context:%llu, seqno:%lld), ring=%s, job 
count:%u, hw job count:%d",
+   TP_printk("id=%llu, fence=(context:%llu, seqno:%lld), ring=%s, job 
count:%u, hw job count:%d, dependencies:%s",
  __entry->id,
  __entry->fence->context, __entry->fence->seqno, 
__get_str(name),
- __entry->job_count, __entry->hw_job_count)
+ __entry->job_count, __entry->hw_job_count,
+ __print_dma_fence_array(p, __get_dynamic_array(deps), 
__entry->n_deps))
 );
 
 DEFINE_EVENT(drm_sched_job, drm_sched_job,
-   TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity),
-   TP_ARGS(sched_job, entity)
+   TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity,
+unsigned int dep_count),
+   TP_ARGS(sched_job, entity, dep_count)
 );
 
 DEFINE_EVENT_PRINT(drm_sched_job, drm_run_job,

[PATCH v3 0/4] Improve gpu_scheduler trace events

2024-06-06 Thread Pierre-Eric Pelloux-Prayer
Hi,

This is the new version of my patch series aiming at improving the
trace events around gpu jobs.
The main ideas implemented are: trace dependencies between jobs and
identify the GPU running jobs (because 'ring' is not a unique attribute).

Changes from v2:
* dropped all amdgpu changes. The goal here is to make the gpu_scheduler
trace events usable by a tool, without dependencies on driver-specific
events
* dropped the vblank related changes. I'll post a separate series to
cover drm/vblank events later.
* reworked fence printing so it's coherent between all events.
* added a dev_index to let the tools parsing the events which GPU is
running a job. It wasn't needed before the gpu scheduler switch to
workqueues because the queue pid was enough to identify the hardware queue.
* dropped the changes to trace the "why" of a dependency. I implemented
a version based on Sima's suggestion using xa_tag_pointer but I'm not
convinced it's really useful, so I'm dropping it for now.

Open questions:
* assuming the new fence printing format is agreed on,
should we add some code to preserve the old format?
* checkpatch doesn't like the indentation in the last patch, because
everything is vertically aligned to 'TP_fast_assign('. How to best fix it?
  
   WARNING: Statements should start on a tabstop
   #82: FILE: drivers/gpu/drm/scheduler/gpu_scheduler_trace.h:80:
   +unsigned long idx;


v2: https://lists.freedesktop.org/archives/dri-devel/2024-February/441341.html

Pierre-Eric Pelloux-Prayer (4):
  drm/sched: store the drm_device instead of the device
  drm/sched: add dev_index=xx to the drm_sched_process_job event
  drm/sched: cleanup gpu_scheduler trace events
  drm/sched: trace dependencies for gpu jobs

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c|  2 +-
 drivers/gpu/drm/etnaviv/etnaviv_sched.c   |  2 +-
 drivers/gpu/drm/imagination/pvr_queue.c   |  2 +-
 drivers/gpu/drm/lima/lima_sched.c |  2 +-
 drivers/gpu/drm/msm/msm_ringbuffer.c  |  2 +-
 drivers/gpu/drm/nouveau/nouveau_sched.c   |  2 +-
 drivers/gpu/drm/panfrost/panfrost_job.c   |  2 +-
 drivers/gpu/drm/panthor/panthor_mmu.c |  2 +-
 drivers/gpu/drm/panthor/panthor_sched.c   |  2 +-
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 88 +++
 drivers/gpu/drm/scheduler/sched_entity.c  | 11 ++-
 drivers/gpu/drm/scheduler/sched_main.c| 28 +++---
 drivers/gpu/drm/v3d/v3d_sched.c   | 12 +--
 drivers/gpu/drm/xe/xe_execlist.c  |  2 +-
 drivers/gpu/drm/xe/xe_gpu_scheduler.c |  2 +-
 drivers/gpu/drm/xe/xe_gpu_scheduler.h |  2 +-
 drivers/gpu/drm/xe/xe_guc_submit.c|  2 +-
 include/drm/gpu_scheduler.h   |  4 +-
 18 files changed, 115 insertions(+), 54 deletions(-)

-- 
2.40.1



[PATCH v3 3/4] drm/sched: cleanup gpu_scheduler trace events

2024-06-06 Thread Pierre-Eric Pelloux-Prayer
Print identifiers instead of pointers:
* "fence=%p" is replaced by "fence=(context:%llu, seqno:%lld)" to have a
coherent way to print the fence. A possible follow up change would be
to use the same format in traces/../dma-fence.h.
* "entity=%p" is removed because the fence's context is already an
identifier of the job owner.

Signed-off-by: Pierre-Eric Pelloux-Prayer 
---
 .../gpu/drm/scheduler/gpu_scheduler_trace.h   | 27 ++-
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h 
b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
index 0a19c121bda5..2d7f2252eb5d 100644
--- a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
@@ -58,9 +58,9 @@ DECLARE_EVENT_CLASS(drm_sched_job,
   &sched_job->sched->credit_count);
   __entry->dev_index = 
sched_job->sched->dev->primary->index;
   ),
-   TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw 
job count:%d",
- __entry->entity, __entry->id,
- __entry->fence, __get_str(name),
+   TP_printk("id=%llu, fence=(context:%llu, seqno:%lld), ring=%s, job 
count:%u, hw job count:%d",
+ __entry->id,
+ __entry->fence->context, __entry->fence->seqno, 
__get_str(name),
  __entry->job_count, __entry->hw_job_count)
 );
 
@@ -72,9 +72,9 @@ DEFINE_EVENT(drm_sched_job, drm_sched_job,
 DEFINE_EVENT_PRINT(drm_sched_job, drm_run_job,
TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity),
TP_ARGS(sched_job, entity),
-   TP_printk("dev_index=%d entity=%p id=%llu, fence=%p, ring=%s, job 
count:%u, hw job count:%d",
- __entry->dev_index, __entry->entity, __entry->id,
- __entry->fence, __get_str(name),
+   TP_printk("dev_index=%d id=%llu, fence=(context:%llu, seqno:%lld), 
ring=%s, job count:%u, hw job count:%d",
+ __entry->dev_index, __entry->id,
+ __entry->fence->context, __entry->fence->seqno, 
__get_str(name),
  __entry->job_count, __entry->hw_job_count)
 );
 
@@ -88,7 +88,8 @@ TRACE_EVENT(drm_sched_process_job,
TP_fast_assign(
__entry->fence = &fence->finished;
),
-   TP_printk("fence=%p signaled", __entry->fence)
+   TP_printk("fence=(context:%llu, seqno:%lld) signaled",
+ __entry->fence->context, __entry->fence->seqno)
 );
 
 TRACE_EVENT(drm_sched_job_wait_dep,
@@ -96,23 +97,25 @@ TRACE_EVENT(drm_sched_job_wait_dep,
TP_ARGS(sched_job, fence),
TP_STRUCT__entry(
 __string(name, sched_job->sched->name)
+__field(uint64_t, fence_context)
 __field(uint64_t, id)
 __field(struct dma_fence *, fence)
 __field(uint64_t, ctx)
-__field(unsigned, seqno)
+__field(uint64_t, seqno)
 ),
 
TP_fast_assign(
   __assign_str(name);
+  /* Store the hw exec fence context. */
+  __entry->fence_context = 
sched_job->entity->fence_context + 1;
   __entry->id = sched_job->id;
   __entry->fence = fence;
   __entry->ctx = fence->context;
   __entry->seqno = fence->seqno;
   ),
-   TP_printk("job ring=%s, id=%llu, depends fence=%p, context=%llu, 
seq=%u",
- __get_str(name), __entry->id,
- __entry->fence, __entry->ctx,
- __entry->seqno)
+   TP_printk("job ring=%s, fence_context=%llu, id=%llu, depends 
fence=(context:%llu, seqno:%lld)",
+ __get_str(name), __entry->fence_context, __entry->id,
+ __entry->ctx, __entry->seqno)
 );
 
 #endif
-- 
2.40.1



[PATCH v3 2/4] drm/sched: add dev_index=xx to the drm_sched_process_job event

2024-06-06 Thread Pierre-Eric Pelloux-Prayer
Until the switch from kthread to workqueue, a userspace application could
determine the device index from the pid of the thread sending this event.

With workqueues this is not possible anymore, so the event needs to contain
this information (the ring name alone is not enough, because they're not
unique).

Signed-off-by: Pierre-Eric Pelloux-Prayer 
---
 drivers/gpu/drm/scheduler/gpu_scheduler_trace.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h 
b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
index c75302ca3427..0a19c121bda5 100644
--- a/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
+++ b/drivers/gpu/drm/scheduler/gpu_scheduler_trace.h
@@ -28,6 +28,9 @@
 #include 
 #include 
 
+#include "drm/drm_device.h"
+#include "drm/drm_file.h"
+
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM gpu_scheduler
 #define TRACE_INCLUDE_FILE gpu_scheduler_trace
@@ -42,6 +45,7 @@ DECLARE_EVENT_CLASS(drm_sched_job,
 __field(uint64_t, id)
 __field(u32, job_count)
 __field(int, hw_job_count)
+__field(int, dev_index)
 ),
 
TP_fast_assign(
@@ -52,6 +56,7 @@ DECLARE_EVENT_CLASS(drm_sched_job,
   __entry->job_count = 
spsc_queue_count(&entity->job_queue);
   __entry->hw_job_count = atomic_read(
   &sched_job->sched->credit_count);
+  __entry->dev_index = 
sched_job->sched->dev->primary->index;
   ),
TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw 
job count:%d",
  __entry->entity, __entry->id,
@@ -64,9 +69,13 @@ DEFINE_EVENT(drm_sched_job, drm_sched_job,
TP_ARGS(sched_job, entity)
 );
 
-DEFINE_EVENT(drm_sched_job, drm_run_job,
+DEFINE_EVENT_PRINT(drm_sched_job, drm_run_job,
TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity 
*entity),
-   TP_ARGS(sched_job, entity)
+   TP_ARGS(sched_job, entity),
+   TP_printk("dev_index=%d entity=%p id=%llu, fence=%p, ring=%s, job 
count:%u, hw job count:%d",
+ __entry->dev_index, __entry->entity, __entry->id,
+ __entry->fence, __get_str(name),
+ __entry->job_count, __entry->hw_job_count)
 );
 
 TRACE_EVENT(drm_sched_process_job,
-- 
2.40.1



[PATCH v3 1/4] drm/sched: store the drm_device instead of the device

2024-06-06 Thread Pierre-Eric Pelloux-Prayer
When tracing is enabled, being able to identify which device is sending
events is useful; for this the next commit will extend events to include
drm_device::primary::index.

Since the device member is only used in the drm_* log macros, we can
replace it by a drm_device pointer.

Signed-off-by: Pierre-Eric Pelloux-Prayer 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 +-
 drivers/gpu/drm/etnaviv/etnaviv_sched.c|  2 +-
 drivers/gpu/drm/imagination/pvr_queue.c|  2 +-
 drivers/gpu/drm/lima/lima_sched.c  |  2 +-
 drivers/gpu/drm/msm/msm_ringbuffer.c   |  2 +-
 drivers/gpu/drm/nouveau/nouveau_sched.c|  2 +-
 drivers/gpu/drm/panfrost/panfrost_job.c|  2 +-
 drivers/gpu/drm/panthor/panthor_mmu.c  |  2 +-
 drivers/gpu/drm/panthor/panthor_sched.c|  2 +-
 drivers/gpu/drm/scheduler/sched_entity.c   |  2 +-
 drivers/gpu/drm/scheduler/sched_main.c | 26 +++---
 drivers/gpu/drm/v3d/v3d_sched.c| 12 +-
 drivers/gpu/drm/xe/xe_execlist.c   |  2 +-
 drivers/gpu/drm/xe/xe_gpu_scheduler.c  |  2 +-
 drivers/gpu/drm/xe/xe_gpu_scheduler.h  |  2 +-
 drivers/gpu/drm/xe/xe_guc_submit.c |  2 +-
 include/drm/gpu_scheduler.h|  4 ++--
 17 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 932dc93b2e63..7f2a68ad8034 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2738,7 +2738,7 @@ static int amdgpu_device_init_schedulers(struct 
amdgpu_device *adev)
   ring->num_hw_submission, 0,
   timeout, adev->reset_domain->wq,
   ring->sched_score, ring->name,
-  adev->dev);
+  &adev->ddev);
if (r) {
DRM_ERROR("Failed to create scheduler on ring %s.\n",
  ring->name);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
index c4b04b0dee16..c4345b68a51f 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
@@ -138,7 +138,7 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu)
 DRM_SCHED_PRIORITY_COUNT,
 etnaviv_hw_jobs_limit, etnaviv_job_hang_limit,
 msecs_to_jiffies(500), NULL, NULL,
-dev_name(gpu->dev), gpu->dev);
+dev_name(gpu->dev), gpu->drm);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/imagination/pvr_queue.c 
b/drivers/gpu/drm/imagination/pvr_queue.c
index 5ed9c98fb599..cdbb6c01e952 100644
--- a/drivers/gpu/drm/imagination/pvr_queue.c
+++ b/drivers/gpu/drm/imagination/pvr_queue.c
@@ -1287,7 +1287,7 @@ struct pvr_queue *pvr_queue_create(struct pvr_context 
*ctx,
 pvr_dev->sched_wq, 1, 64 * 1024, 1,
 msecs_to_jiffies(500),
 pvr_dev->sched_wq, NULL, "pvr-queue",
-pvr_dev->base.dev);
+&pvr_dev->base);
if (err)
goto err_release_ufo;
 
diff --git a/drivers/gpu/drm/lima/lima_sched.c 
b/drivers/gpu/drm/lima/lima_sched.c
index bbf3f8feab94..db6ee7650468 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -526,7 +526,7 @@ int lima_sched_pipe_init(struct lima_sched_pipe *pipe, 
const char *name)
  1,
  lima_job_hang_limit,
  msecs_to_jiffies(timeout), NULL,
- NULL, name, pipe->ldev->dev);
+ NULL, name, pipe->ldev->ddev);
 }
 
 void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c 
b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 9d6655f96f0c..3a4b3816f2c9 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -101,7 +101,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu 
*gpu, int id,
ret = drm_sched_init(&ring->sched, &msm_sched_ops, NULL,
 DRM_SCHED_PRIORITY_COUNT,
 num_hw_submissions, 0, sched_timeout,
-NULL, NULL, to_msm_bo(ring->bo)->name, 
gpu->dev->dev);
+NULL, NULL, to_msm_bo(ring->bo)->name, gpu->dev);
if (ret) {
goto fail;
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_sched.c 
b/drivers/gpu/drm/nouveau/nouveau_sched.c
index 32fa2e273965..386839bed8a2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sched.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sched.c
@@ -419,7 +419,7 @@ nouveau_sched_init(struct nouveau

Re: [PATCH] drm/mediatek: Don't print error if EDEFER_PROBE returned on component_add

2024-06-06 Thread Jonathan Cameron
On Wed, 05 Jun 2024 12:50:25 -0400
Nícolas F. R. A. Prado  wrote:

> Use dev_err_probe() in the component_add() error path to prevent
> printing an error when the probe is deferred. This was observed on
> mt8195 with the disp-rdma driver:
> 
>   mediatek-disp-rdma 1c002000.rdma: Failed to add component: -517
> 
> But the same pattern is used across many other drivers, so update them
> all.
> 
> Signed-off-by: Nícolas F. R. A. Prado 
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_aal.c | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_ccorr.c   | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_color.c   | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_gamma.c   | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_merge.c   | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 2 +-
>  drivers/gpu/drm/mediatek/mtk_disp_rdma.c| 2 +-
>  drivers/gpu/drm/mediatek/mtk_ethdr.c| 2 +-
>  drivers/gpu/drm/mediatek/mtk_mdp_rdma.c | 2 +-
>  10 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c 
> b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> index 3ce8f32b06d5..892dc40458fb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c
> @@ -197,7 +197,7 @@ static int mtk_disp_aal_probe(struct platform_device 
> *pdev)
>  
>   ret = component_add(dev, &mtk_disp_aal_component_ops);
>   if (ret)
> - dev_err(dev, "Failed to add component: %d\n", ret);
> + dev_err_probe(dev, ret, "Failed to add component\n");
Perhaps
return dev_err_probe(...)

return 0;

Whilst I can see you are focused on this one problem case, it
might be better to use dev_err_probe() for all the similar
cases earlier in these functions.

Then that return dev_err_probe() pattern will make more sense
as it will be consistent with all the other calls.


Re: [PATCH] arm/komeda: Remove all CONFIG_DEBUG_FS conditional compilations

2024-06-06 Thread Liviu Dudau
On Thu, Jun 06, 2024 at 08:08:42PM +0800, pengfuyuan wrote:
> Since the debugfs functions have no-op stubs for CONFIG_DEBUG_FS=n,
> the compiler will optimize the rest away since they are no longer referenced.
> 
> The benefit of removing the conditional compilation is that the build
> is actually tested for both CONFIG_DEBUG_FS configuration values.
> Assuming most developers have it enabled, CONFIG_DEBUG_FS=n is not tested
> much and may fail the build due to the conditional compilation.
> 
> Reported-by: k2ci 
> Signed-off-by: pengfuyuan 

Acked-by: Liviu Dudau 

Thanks for the cleanup!

Best regards,
Liviu

> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 8 
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
> b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 14ee79becacb..5ba62e637a61 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -12,10 +12,8 @@
>  #include 
>  #include 
>  #include 
> -#ifdef CONFIG_DEBUG_FS
>  #include 
>  #include 
> -#endif
>  
>  #include 
>  
> @@ -43,7 +41,6 @@ static int komeda_register_show(struct seq_file *sf, void 
> *x)
>  
>  DEFINE_SHOW_ATTRIBUTE(komeda_register);
>  
> -#ifdef CONFIG_DEBUG_FS
>  static void komeda_debugfs_init(struct komeda_dev *mdev)
>  {
>   if (!debugfs_initialized())
> @@ -55,7 +52,6 @@ static void komeda_debugfs_init(struct komeda_dev *mdev)
>   debugfs_create_x16("err_verbosity", 0664, mdev->debugfs_root,
>  &mdev->err_verbosity);
>  }
> -#endif
>  
>  static ssize_t
>  core_id_show(struct device *dev, struct device_attribute *attr, char *buf)
> @@ -265,9 +261,7 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
>  
>   mdev->err_verbosity = KOMEDA_DEV_PRINT_ERR_EVENTS;
>  
> -#ifdef CONFIG_DEBUG_FS
>   komeda_debugfs_init(mdev);
> -#endif
>  
>   return mdev;
>  
> @@ -286,9 +280,7 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
>  
>   sysfs_remove_group(&dev->kobj, &komeda_sysfs_attr_group);
>  
> -#ifdef CONFIG_DEBUG_FS
>   debugfs_remove_recursive(mdev->debugfs_root);
> -#endif
>  
>   if (mdev->aclk)
>   clk_prepare_enable(mdev->aclk);
> -- 
> 2.25.1
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯


[PATCH] drm/edid: reduce DisplayID log spamming

2024-06-06 Thread Jani Nikula
Debug printing at DisplayID validation leads to lots of log spamming as
it's called at DisplayID iterators during EDID parsing. Remove it, and
replace with a less noisy message at connector EDID update.

Signed-off-by: Jani Nikula 
---
 drivers/gpu/drm/drm_displayid.c | 3 ---
 drivers/gpu/drm/drm_edid.c  | 5 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_displayid.c b/drivers/gpu/drm/drm_displayid.c
index 9d01d762801f..b4fd43783c50 100644
--- a/drivers/gpu/drm/drm_displayid.c
+++ b/drivers/gpu/drm/drm_displayid.c
@@ -33,9 +33,6 @@ validate_displayid(const u8 *displayid, int length, int idx)
if (IS_ERR(base))
return base;
 
-   DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
- base->rev, base->bytes, base->prod_id, base->ext_count);
-
/* +1 for DispID checksum */
dispid_length = sizeof(*base) + base->bytes + 1;
if (dispid_length > length - idx)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f68a41eeb1fa..9fc7292f5382 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -6629,6 +6629,11 @@ static void update_displayid_info(struct drm_connector 
*connector,
 
displayid_iter_edid_begin(drm_edid, &iter);
displayid_iter_for_each(block, &iter) {
+   drm_dbg_kms(connector->dev,
+   "[CONNECTOR:%d:%s] DisplayID extension version 
0x%02x, primary use 0x%02x\n",
+   connector->base.id, connector->name,
+   displayid_version(&iter),
+   displayid_primary_use(&iter));
if (displayid_version(&iter) == DISPLAY_ID_STRUCTURE_VER_20 &&
(displayid_primary_use(&iter) == 
PRIMARY_USE_HEAD_MOUNTED_VR ||
 displayid_primary_use(&iter) == 
PRIMARY_USE_HEAD_MOUNTED_AR))
-- 
2.39.2



Re: [PATCH v2] drm/client: Detect when ACPI lid is closed during initialization

2024-06-06 Thread Ville Syrjälä
On Thu, Jun 06, 2024 at 10:21:07AM +0300, Jani Nikula wrote:
> On Wed, 05 Jun 2024, Chris Bainbridge  wrote:
> > On Tue, Jun 04, 2024 at 10:02:29AM +0800, kernel test robot wrote:
> >> Hi Mario,
> >> 
> >> kernel test robot noticed the following build errors:
> >> 
> >> [auto build test ERROR on drm-misc/drm-misc-next]
> >> [also build test ERROR on drm/drm-next drm-exynos/exynos-drm-next 
> >> drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip 
> >> linus/master v6.10-rc2 next-20240603]
> >> [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/Mario-Limonciello/drm-client-Detect-when-ACPI-lid-is-closed-during-initialization/20240529-050440
> >> base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
> >> patch link:
> >> https://lore.kernel.org/r/20240528210319.1242-1-mario.limonciello%40amd.com
> >> patch subject: [PATCH v2] drm/client: Detect when ACPI lid is closed 
> >> during initialization
> >> config: i386-randconfig-053-20240604 
> >> (https://download.01.org/0day-ci/archive/20240604/202406040928.eu1griwv-...@intel.com/config)
> >> compiler: gcc-9 (Ubuntu 9.5.0-4ubuntu2) 9.5.0
> >> reproduce (this is a W=1 build): 
> >> (https://download.01.org/0day-ci/archive/20240604/202406040928.eu1griwv-...@intel.com/reproduce)
> >> 
> >> If you fix the issue in a separate patch/commit (i.e. not just a new 
> >> version of
> >> the same patch/commit), kindly add following tags
> >> | Reported-by: kernel test robot 
> >> | Closes: 
> >> https://lore.kernel.org/oe-kbuild-all/202406040928.eu1griwv-...@intel.com/
> >> 
> >> All errors (new ones prefixed by >>):
> >> 
> >>ld: drivers/gpu/drm/drm_client_modeset.o: in function 
> >> `drm_client_match_edp_lid':
> >> >> drivers/gpu/drm/drm_client_modeset.c:281:(.text+0x221b): undefined 
> >> >> reference to `acpi_lid_open'
> >> 
> >> 
> >> vim +281 drivers/gpu/drm/drm_client_modeset.c
> >> 
> >>260 
> >>261 static void drm_client_match_edp_lid(struct drm_device *dev,
> >>262  struct drm_connector 
> >> **connectors,
> >>263  unsigned int 
> >> connector_count,
> >>264  bool *enabled)
> >>265 {
> >>266 int i;
> >>267 
> >>268 for (i = 0; i < connector_count; i++) {
> >>269 struct drm_connector *connector = connectors[i];
> >>270 
> >>271 switch (connector->connector_type) {
> >>272 case DRM_MODE_CONNECTOR_LVDS:
> >>273 case DRM_MODE_CONNECTOR_eDP:
> >>274 if (!enabled[i])
> >>275 continue;
> >>276 break;
> >>277 default:
> >>278 continue;
> >>279 }
> >>280 
> >>  > 281 if (!acpi_lid_open()) {
> >>282 drm_dbg_kms(dev, "[CONNECTOR:%d:%s] lid 
> >> is closed, disabling\n",
> >>283 connector->base.id, 
> >> connector->name);
> >>284 enabled[i] = false;
> >>285 }
> >>286 }
> >>287 }
> >>288 
> >> 
> >> -- 
> >> 0-DAY CI Kernel Test Service
> >> https://github.com/intel/lkp-tests/wiki
> >
> > The failed config has CONFIG_ACPI_BUTTON=m. The build failure can be
> > fixed with:
> >
> > diff --git a/drivers/gpu/drm/drm_client_modeset.c 
> > b/drivers/gpu/drm/drm_client_modeset.c
> > index b76438c31761..0271e66f44f8 100644
> > --- a/drivers/gpu/drm/drm_client_modeset.c
> > +++ b/drivers/gpu/drm/drm_client_modeset.c
> > @@ -271,11 +271,13 @@ static void drm_client_match_edp_lid(struct 
> > drm_device *dev,
> > if (connector->connector_type != DRM_MODE_CONNECTOR_eDP || 
> > !enabled[i])
> > continue;
> >
> > +#if defined(CONFIG_ACPI_BUTTON)
> > if (!acpi_lid_open()) {
> > drm_dbg_kms(dev, "[CONNECTOR:%d:%s] lid is closed, 
> > disabling\n",
> > connector->base.id, connector->name);
> > enabled[i] = false;
> > }
> > +#endif
> > }
> >  }
> 
> No. This is because
> 
> CONFIG_DRM=y
> CONFIG_ACPI_BUTTON=m
> 
> The pedantically correct fix is probably having DRM
> 
>   depends on ACPI_BUTTON || ACPI_BUTTON=n
> 
> but seeing how i915 and xe just
> 
>   select ACPI_BUTTON if ACPI

Huh. We should nuke that as we haven't used this lid stuff in ages.

-- 
Ville Syrjälä
Intel


[Bug 218900] amdgpu: Fatal error during GPU init

2024-06-06 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=218900

Hanabishi (i.r.e.c.c.a.k.u.n+bugzilla.kernel@gmail.com) changed:

   What|Removed |Added

 CC||i.r.e.c.c.a.k.u.n+bugzilla.
   ||kernel@gmail.com

--- Comment #14 from Hanabishi 
(i.r.e.c.c.a.k.u.n+bugzilla.kernel@gmail.com) ---
*** Bug 218921 has been marked as a duplicate of this bug. ***

-- 
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 v13 5/9] drm/dp: Add refresh rate divider to struct representing AS SDP

2024-06-06 Thread Maxime Ripard
On Thu, Jun 06, 2024 at 02:38:45PM GMT, Jani Nikula wrote:
> On Wed, 05 Jun 2024, Mitul Golani  
> wrote:
> > Add target_rr_divider to structure representing AS SDP.
> > It is valid only in FAVT mode, sink device ignores the bit in AVT
> > mode.
> >
> > --v2:
> > - Update commit header and send patch to dri-devel.
> >
> > Signed-off-by: Mitul Golani 
> > Reviewed-by: Arun R Murthy 
> 
> Maxime, Maarten, Thomas, ack for merging this via drm-intel-next?

Acked-by: Maxime Ripard 

Maxime


signature.asc
Description: PGP signature


Re: [PATCH v2 10/12] media: platform: mtk-mdp3: Get fine-grain control of cmdq_pkt_finalize()

2024-06-06 Thread Benjamin Gaignard



Le 22/02/2024 à 16:41, Chun-Kuang Hu a écrit :

In order to have fine-grained control, use cmdq_pkt_eoc() and
cmdq_pkt_jump_rel() to replace cmdq_pkt_finalize().

Signed-off-by: Chun-Kuang Hu 
---
  drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 3 ++-
  drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 2 ++
  drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 +
  3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 6adac857a477..b720e69b341d 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -471,7 +471,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct 
mdp_cmdq_param *param)
dev_err(dev, "mdp_path_config error\n");
goto err_free_path;
}
-   cmdq_pkt_finalize(&cmd->pkt);
+   cmdq_pkt_eoc(&cmd->pkt);
+   cmdq_pkt_jump_rel(&cmd->pkt, CMDQ_INST_SIZE, mdp->cmdq_shift_pa);
  
  	for (i = 0; i < num_comp; i++)

memcpy(&comps[i], path->comps[i].comp,
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
index 94f4ed78523b..2214744c937c 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
@@ -231,6 +231,8 @@ static int mdp_probe(struct platform_device *pdev)
goto err_put_scp;
}
  
+	mdp->cmdq_shift_pa = cmdq_get_shift_pa(mdp->cmdq_clt->chan);

+
init_waitqueue_head(&mdp->callback_wq);
ida_init(&mdp->mdp_ida);
platform_set_drvdata(pdev, mdp);
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
index 7e21d226ceb8..ed61e0bb69ee 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
@@ -83,6 +83,7 @@ struct mdp_dev {
u32 id_count;
struct ida  mdp_ida;
struct cmdq_client  *cmdq_clt;
+   u8  cmdq_shift_pa;


Can send a new version of this series because this patch can't
be applied on media_tree/master branch.
The code look correct for me but we need to be able to applied it
to perform more checks.

Regards,
Benjamin


wait_queue_head_t   callback_wq;
  
  	struct v4l2_device			v4l2_dev;


[PATCH] arm/komeda: Remove all CONFIG_DEBUG_FS conditional compilations

2024-06-06 Thread pengfuyuan
Since the debugfs functions have no-op stubs for CONFIG_DEBUG_FS=n,
the compiler will optimize the rest away since they are no longer referenced.

The benefit of removing the conditional compilation is that the build
is actually tested for both CONFIG_DEBUG_FS configuration values.
Assuming most developers have it enabled, CONFIG_DEBUG_FS=n is not tested
much and may fail the build due to the conditional compilation.

Reported-by: k2ci 
Signed-off-by: pengfuyuan 
---
 drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
index 14ee79becacb..5ba62e637a61 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
@@ -12,10 +12,8 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_DEBUG_FS
 #include 
 #include 
-#endif
 
 #include 
 
@@ -43,7 +41,6 @@ static int komeda_register_show(struct seq_file *sf, void *x)
 
 DEFINE_SHOW_ATTRIBUTE(komeda_register);
 
-#ifdef CONFIG_DEBUG_FS
 static void komeda_debugfs_init(struct komeda_dev *mdev)
 {
if (!debugfs_initialized())
@@ -55,7 +52,6 @@ static void komeda_debugfs_init(struct komeda_dev *mdev)
debugfs_create_x16("err_verbosity", 0664, mdev->debugfs_root,
   &mdev->err_verbosity);
 }
-#endif
 
 static ssize_t
 core_id_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -265,9 +261,7 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
 
mdev->err_verbosity = KOMEDA_DEV_PRINT_ERR_EVENTS;
 
-#ifdef CONFIG_DEBUG_FS
komeda_debugfs_init(mdev);
-#endif
 
return mdev;
 
@@ -286,9 +280,7 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
 
sysfs_remove_group(&dev->kobj, &komeda_sysfs_attr_group);
 
-#ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(mdev->debugfs_root);
-#endif
 
if (mdev->aclk)
clk_prepare_enable(mdev->aclk);
-- 
2.25.1



Re: [PATCH] drm/msm/adreno: De-spaghettify the use of memory barriers

2024-06-06 Thread Konrad Dybcio
On 4.06.2024 4:40 PM, Will Deacon wrote:
> On Thu, May 16, 2024 at 01:55:26PM -0500, Andrew Halaney wrote:
>> On Thu, May 16, 2024 at 08:20:05PM GMT, Akhil P Oommen wrote:
>>> On Thu, May 16, 2024 at 08:15:34AM -0500, Andrew Halaney wrote:
 If I understand correctly, you don't need any memory barrier.
 writel()/readl()'s are ordered to the same endpoint. That goes for all
 the reordering/barrier comments mentioned below too.

 device-io.rst:

 The read and write functions are defined to be ordered. That is the
 compiler is not permitted to reorder the I/O sequence. When the 
 ordering
 can be compiler optimised, you can use __readb() and friends to
 indicate the relaxed ordering. Use this with care.

 memory-barriers.txt:

  (*) readX(), writeX():

The readX() and writeX() MMIO accessors take a pointer to the
peripheral being accessed as an __iomem * parameter. For pointers
mapped with the default I/O attributes (e.g. those returned by
ioremap()), the ordering guarantees are as follows:

1. All readX() and writeX() accesses to the same peripheral are 
 ordered
   with respect to each other. This ensures that MMIO register 
 accesses
   by the same CPU thread to a particular device will arrive in 
 program
   order.

>>>
>>> In arm64, a writel followed by readl translates to roughly the following
>>> sequence: dmb_wmb(), __raw_writel(), __raw_readl(), dmb_rmb(). I am not
>>> sure what is stopping compiler from reordering  __raw_writel() and 
>>> __raw_readl()
>>> above? I am assuming iomem cookie is ignored during compilation.
>>
>> It seems to me that is due to some usage of volatile there in
>> __raw_writel() etc, but to be honest after reading about volatile and
>> some threads from gcc mailing lists, I don't have a confident answer :)
>>
>>>
>>> Added Will to this thread if he can throw some light on this.
>>
>> Hopefully Will can school us.
> 
> The ordering in this case is ensured by the memory attributes used for
> ioremap(). When an MMIO region is mapped using Device-nGnRE attributes
> (as it the case for ioremap()), the "nR" part means "no reordering", so
> readX() and writeX() to that region are ordered wrt each other.
> 
> Note that guarantee _doesn't_ apply to other flavours of ioremap(), so
> e.g. ioremap_wc() won't give you the ordering.
> 
> Hope that helps,

Just to make sure I'm following, would mapping things as nGnRnE effectively
get rid of write buffering, perhaps being a way of debugging whether that
in particular is causing issues (at the cost of speed)?

Konrad


Re: [PATCH v3 1/2] dt-bindings: display: panel: Add WL-355608-A8 panel

2024-06-06 Thread Conor Dooley
On Thu, Jun 06, 2024 at 01:23:03PM +0200, Maxime Ripard wrote:
> On Thu, Jun 06, 2024 at 11:37:31AM GMT, Neil Armstrong wrote:
> > On 06/06/2024 11:32, Maxime Ripard wrote:
> > > On Fri, May 31, 2024 at 09:12:14AM GMT, Ryan Walklin wrote:
> > > > The WL-355608-A8 is a 3.5" 640x480@60Hz RGB LCD display used in a
> > > > number of handheld gaming devices made by Anbernic. By consensus a
> > > > vendor prefix is not provided as the panel OEM is unknown.
> > > 
> > > Where has this consensus been found?
> > > 
> > > I had a look at the previous discussions, and I can't find any consensus
> > > being reached there. And for that kind of thing, having the ack or
> > > review of any of the DT maintainers would have been great.
> > 
> > There was a consensus with Conor, this is why he acked v2, see
> > https://lore.kernel.org/all/20240525-velvet-citable-a45dd06847a7@spud/
> 
> It's probably a matter of semantics here, but if it's with only one
> person, it's not a consensus but an agreement.
> 
> > ```
> > I think if we genuinely do not know what the vendor is then we just
> > don't have a prefix.
> > ```
> 
> And even then, I don't interpret Conor's statement as a formal agreement
> but rather an acknowledgment of the issue.

I mean, I specifically left an r-b below that line in v2:
https://lore.kernel.org/all/20240530-satchel-playgroup-e8aa6937b8b9@spud/

I'm not a displays guy, so my sources were limited to what I could find
from search engines, but I spent some time looking for an actual vendor
of the panel and could not. All I found was various listings on places
like AliExpress that did not mention an manufacturer. I'd rather not
invent a vendor because we could not find the actual vendor of the
panel & it seemed rather unreasonable to block support for the device
on the basis of not being able to figure out the vendor. If you, as
someone knowledgeable on displays, can figure the vendor out, then
yeah we should definitely add it.

> > I agree with Conor so I applied the patchset after Connor reviewed it and 
> > the comment was fixed in v3:
> > https://lore.kernel.org/all/20240530-satchel-playgroup-e8aa6937b8b9@spud/
> 
> Yeah, I know. Still, it's a major deviation to what we've always been
> doing, getting the DT maintainers voice on that would have been a good
> idea.

Is it a consensus of DT maintainers you're looking for?

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH 12/14] dt-bindings: display: rockchip,dw-hdmi: Add compatible for RK3588

2024-06-06 Thread Cristian Ciocaltea
On 6/6/24 2:22 AM, Rob Herring wrote:
> On Sat, Jun 01, 2024 at 04:12:34PM +0300, Cristian Ciocaltea wrote:
>> Document the Synopsys DesignWare HDMI 2.1 Quad-Pixel (QP) TX controller
>> found on Rockchip RK3588 SoC family.
>>
>> Since RK3588 uses different clocks than previous Rockchip SoCs and also
>> requires a couple of reset lines and some additional properties, provide
>> the required changes in the binding to accommodate all variants.
>>
>> Signed-off-by: Cristian Ciocaltea 
>> ---
>>  .../display/rockchip/rockchip,dw-hdmi.yaml | 127 
>> +++--
>>  1 file changed, 90 insertions(+), 37 deletions(-)
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml 
>> b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
>> index 2aac62219ff6..60d6b815227f 100644
>> --- 
>> a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
>> +++ 
>> b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-hdmi.yaml
>> @@ -10,12 +10,10 @@ maintainers:
>>- Mark Yao 
>>  
>>  description: |
>> -  The HDMI transmitter is a Synopsys DesignWare HDMI 1.4 TX controller IP
>> -  with a companion PHY IP.
>> -
>> -allOf:
>> -  - $ref: ../bridge/synopsys,dw-hdmi.yaml#
>> -  - $ref: /schemas/sound/dai-common.yaml#
>> +  For SoCs up to RK3568, the HDMI transmitter is a Synopsys DesignWare
>> +  HDMI 1.4 TX controller IP with a companion PHY IP.
>> +  The RK3588 SoC integrates the Synopsys DesignWare HDMI 2.1 Quad-Pixel (QP)
>> +  TX controller IP and a HDMI/eDP TX Combo PHY based on a Samsung IP block.
>>  
>>  properties:
>>compatible:
>> @@ -25,6 +23,7 @@ properties:
>>- rockchip,rk3328-dw-hdmi
>>- rockchip,rk3399-dw-hdmi
>>- rockchip,rk3568-dw-hdmi
>> +  - rockchip,rk3588-dw-hdmi
>>  
>>reg-io-width:
>>  const: 4
>> @@ -40,36 +39,6 @@ properties:
>>A 1.8V supply that powers up the SoC internal circuitry. The pin name 
>> on the
>>SoC usually is HDMI_TX_AVDD_1V8.
>>  
>> -  clocks:
>> -minItems: 2
>> -items:
>> -  - {}
>> -  - {}
>> -  # The next three clocks are all optional, but shall be specified in 
>> this
>> -  # order when present.
>> -  - description: The HDMI CEC controller main clock
>> -  - description: Power for GRF IO
>> -  - description: External clock for some HDMI PHY (old clock name, 
>> deprecated)
>> -  - description: External clock for some HDMI PHY (new name)
>> -
>> -  clock-names:
>> -minItems: 2
>> -items:
>> -  - {}
>> -  - {}
>> -  - enum:
>> -  - cec
>> -  - grf
>> -  - vpll
>> -  - ref
>> -  - enum:
>> -  - grf
>> -  - vpll
>> -  - ref
>> -  - enum:
>> -  - vpll
>> -  - ref
>> -
>>ddc-i2c-bus:
>>  $ref: /schemas/types.yaml#/definitions/phandle
>>  description:
>> @@ -131,13 +100,97 @@ properties:
>>  required:
>>- compatible
>>- reg
>> -  - reg-io-width
>>- clocks
>>- clock-names
>>- interrupts
>>- ports
>>- rockchip,grf
>>  
>> +allOf:
>> +  - $ref: /schemas/sound/dai-common.yaml#
>> +  - if:
>> +  properties:
>> +compatible:
>> +  contains:
>> +enum:
>> +  - rockchip,rk3588-dw-hdmi
>> +then:
>> +  properties:
>> +reg:
>> +  maxItems: 1
>> +
>> +clocks:
>> +  minItems: 1
>> +  items:
>> +- description: APB system interface clock
>> +# The next clocks are optional, but shall be specified in this
>> +# order when present.
>> +- description: TMDS/FRL link clock
>> +- description: EARC RX biphase clock
>> +- description: Reference clock
>> +- description: Audio interface clock
>> +- description: Video datapath clock
>> +
>> +clock-names:
>> +  minItems: 1
>> +  items:
>> +- const: pclk
>> +- enum: [hdp, earc, ref, aud, hclk_vo1]
>> +- enum: [earc, ref, aud, hclk_vo1]
>> +- enum: [ref, aud, hclk_vo1]
>> +- enum: [aud, hclk_vo1]
>> +- const: hclk_vo1
>> +
>> +resets:
>> +  minItems: 2
>> +  maxItems: 2
>> +
>> +reset-names:
>> +  items:
>> +- const: ref
>> +- const: hdp
>> +
>> +interrupts:
>> +  minItems: 1
>> +  maxItems: 5
>> +
>> +rockchip,vo1_grf:
>> +  $ref: /schemas/types.yaml#/definitions/phandle
>> +  description: Some QP related data is accessed through VO1 GRF regs
>> +
>> +  required:
>> +- resets
>> +- reset-names
>> +- rockchip,vo1_grf
>> +
>> +else:
>> +  $ref: ../bridge/synopsys,dw-hdmi.yaml#
> 
> This is odd... With this plus the amount of conditional schema, I think 
> this should be a new schema doc. Doesn't have to have a c

[PATCH] i2c: imx-lpi2c: add eDMA mode support for LPI2C

2024-06-06 Thread carlos . song
From: Carlos Song 

Add eDMA mode support for LPI2C.

There are some differences between TX DMA mode and RX DMA mode.
LPI2C MTDR register is Controller Transmit Data Register.
When LPI2C send data, it is tx cmd register and tx data fifo.
When LPI2C receive data, it is just a rx cmd register. LPI2C MRDR
register is Controller Receive Data Register, received data are
stored in this.

MTDR[8:10] is CMD field and MTDR[0:7] is DATA filed.
+---+---+
|  C  M  D  |  D  A  T  A   |
+---+---+---+---+---+---+---+---+---+---+---+
| 10| 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+---+---+---+---+---+---+---+---+---+---+---+

MRDR is Controller Receive Data Register.
MRDR[0:7] is DATA filed.
+---+
|  D  A  T  A   |
+---+---+---+---+---+---+---+---+
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+---+---+---+---+---+---+---+---+

When the LPI2C controller needs to send data, tx cmd and 8-bit data
should be written into MTDR:
CMD: 000b: Transmit the value in DATA[7:0].
DATA: 8-bit data.

If LPI2C controller needs to send N 8-bit data, just write N times
(CMD(W) + DATA(u8)) to MTDR.

When the LPI2C controller needs to receive data, rx cmd should be
written into MTDR, the received data will be stored in the MRDR.

MTDR(CMD): 001b: Receive (DATA[7:0] + 1) 8-bit data.
MTDR(DATA): byte counter.
MRDR(DATA): 8-bit data.

So when LPI2C controller needs to receive N 8-bit data,
1. N <= 256:
Write 1 time (CMD(R) + BYTE COUNT(N-1)) into MTDR and receive data from
MRDR.
2. N > 256:
Write N/256 times (CMD(R) + BYTE COUNT(255)) + 1 time (CMD(R) + BYTE
COUNT(N%256)) into MTDR and receive data from MRDR.

Due to these differences, when LPI2C is in DMA TX mode, only enable TX
channel to send data. But when LPI2C is in DMA RX mode, TX and RX channel
are both enabled, TX channel is used to send RX cmd and RX channel is
used to receive data.

Signed-off-by: Carlos Song 
Reviewed-by: Frank Li 
---
 drivers/i2c/busses/i2c-imx-lpi2c.c | 536 -
 1 file changed, 528 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c 
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 0197786892a2..26640c1dadc7 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -8,6 +8,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +31,7 @@
 #define LPI2C_MCR  0x10/* i2c contrl register */
 #define LPI2C_MSR  0x14/* i2c status register */
 #define LPI2C_MIER 0x18/* i2c interrupt enable */
+#define LPI2C_MDER 0x1C/* i2c DMA enable */
 #define LPI2C_MCFGR0   0x20/* i2c master configuration */
 #define LPI2C_MCFGR1   0x24/* i2c master configuration */
 #define LPI2C_MCFGR2   0x28/* i2c master configuration */
@@ -70,11 +73,14 @@
 #define MCFGR1_AUTOSTOPBIT(8)
 #define MCFGR1_IGNACK  BIT(9)
 #define MRDR_RXEMPTY   BIT(14)
+#define MDER_TDDE  BIT(0)
+#define MDER_RDDE  BIT(1)
 
 #define I2C_CLK_RATIO  2
 #define CHUNK_DATA 256
 
 #define I2C_PM_TIMEOUT 10 /* ms */
+#define I2C_DMA_THRESHOLD  8 /* bytes */
 
 enum lpi2c_imx_mode {
STANDARD,   /* 100+Kbps */
@@ -108,6 +114,22 @@ struct lpi2c_imx_struct {
unsigned intrxfifosize;
enum lpi2c_imx_mode mode;
struct i2c_bus_recovery_info rinfo;
+
+   boolcan_use_dma;
+   boolusing_pio_mode;
+   u8  rx_cmd_buf_len;
+   u16 *rx_cmd_buf;
+   u8  *dma_buf;
+   unsigned intdma_len;
+   unsigned inttx_burst_num;
+   unsigned intrx_burst_num;
+   resource_size_t phy_addr;
+   dma_addr_t  dma_tx_addr;
+   dma_addr_t  dma_addr;
+   enum dma_data_direction dma_direction;
+   struct dma_chan *chan_tx;
+   struct dma_chan *chan_rx;
+   struct i2c_msg  *msg;
 };
 
 static void lpi2c_imx_intctrl(struct lpi2c_imx_struct *lpi2c_imx,
@@ -305,7 +327,7 @@ static int lpi2c_imx_master_disable(struct lpi2c_imx_struct 
*lpi2c_imx)
return 0;
 }
 
-static int lpi2c_imx_msg_complete(struct lpi2c_imx_struct *lpi2c_imx)
+static int lpi2c_imx_pio_msg_complete(struct lpi2c_imx_struct *lpi2c_imx)
 {
unsigned long time_left;
 
@@ -451,6 +473,444 @@ static void lpi2c_imx_read(struct lpi2c_imx_struct 
*lpi2c_imx,
lpi2c_imx_intctrl(lpi2c_imx, MIER_RDIE | MIER_NDIE);
 }
 
+static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg)
+{
+   if (!lpi2c_imx->can_use_dma)
+   return false;
+
+   /*
+* When the length of data is less than I2C_DMA_THRESHOLD,
+* cpu mode is used directly to avoid low performance.
+*/
+   if (msg->len < I2C_DMA_THRESHOLD)
+   return false;
+
+   return true;
+}
+
+static int lpi2c

Re: [PATCH v1 1/1] treewide: Align match_string() with sysfs_match_string()

2024-06-06 Thread Gautham R. Shenoy
On Sun, Jun 02, 2024 at 06:57:12PM +0300, Andy Shevchenko wrote:
> Make two APIs look similar. Hence convert match_string() to be
> a 2-argument macro. In order to avoid unneeded churn, convert
> all users as well. There is no functional change intended.


> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 1b7e82a0ad2e..b6f52f44625f 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1117,9 +1117,9 @@ static ssize_t store_energy_performance_preference(
>   if (ret != 1)
>   return -EINVAL;
>  
> - ret = match_string(energy_perf_strings, -1, str_preference);
> + ret = __match_string(energy_perf_strings, -1, str_preference);
>   if (ret < 0)
> - return -EINVAL;
> + return ret;
>  
>   mutex_lock(&amd_pstate_limits_lock);
>   ret = amd_pstate_set_energy_pref_index(cpudata, ret);


For drivers/cpufreq/amd-pstate.c

Acked-by: Gautham R. Shenoy 

--
Thanks and Regards
gautham.


Re: [PATCH 13/14] drm/bridge: synopsys: Add DW HDMI QP TX controller driver

2024-06-06 Thread Luis de Arquer

On 6/5/24 16:48, Heiko Stübner wrote:

Without this change, connecting to a DVI display does not work, and
reading the EDID ends in the "i2c read error" below.


I had a lot of problems initially with the vendor driver on my DVI 
display, and am aware that several changes were required.


However, I tested Cristian patch and worked fine. All modes were 
apparently detected from the display and they all worked. But maybe I 
was just lucky and it was using a somehow cached table, I can't say.


This is an AOC DVI display from 2011 with a passive adapter.



Luis


Re: [PATCH v1 1/1] treewide: Align match_string() with sysfs_match_string()

2024-06-06 Thread AngeloGioacchino Del Regno

Il 02/06/24 17:57, Andy Shevchenko ha scritto:

Make two APIs look similar. Hence convert match_string() to be
a 2-argument macro. In order to avoid unneeded churn, convert
all users as well. There is no functional change intended.

Signed-off-by: Andy Shevchenko 


For MediaTek

Reviewed-by: AngeloGioacchino Del Regno 





[PATCH] drm/hisilicon: Fix a NULL pointer access when call hibmc_unload

2024-06-06 Thread oushixiong1025
From: Shixiong Ou 

If Calling hibmc_mm_init() failed in hibmc_load(), the hibmc_unload()
will access a NULL pointer, as it don't call ww_mutex_init() to
initialize mode_config.connection_mutex but try to lock it when
calling drm_atomic_helper_shutdown() in hibmc_unload().

[   50.939211][  0] Unable to handle kernel NULL pointer dereference at virtual 
address 0018
..
[   51.149882][  0] Call trace:
[   51.152750][  0]  ww_mutex_lock+0xf0/0x1e0
[   51.156829][  0]  drm_modeset_lock+0x184/0x2c0
[   51.161254][  0]  drm_modeset_lock_all_ctx+0x98/0x188
[   51.166284][  0]  drm_atomic_helper_shutdown+0xa4/0x128
[   51.171487][  0]  hibmc_unload+0x50/0x2f0
[   51.175479][  0]  hibmc_load+0x5d8/0x888
[   51.179386][  0]  drm_dev_register+0x280/0x558
[   51.183811][  0]  drm_get_pci_dev+0x140/0x3c8
[   51.188150][  0]  hibmc_pci_probe+0x148/0x190
[   51.192489][  0]  local_pci_probe+0xc4/0x180
[   51.196742][  0]  pci_device_probe+0x328/0x530
[   51.201167][  0]  really_probe+0x498/0x9a0
[   51.205248][  0]  driver_probe_device+0x224/0x308
[   51.209932][  0]  device_driver_attach+0xec/0x128
[   51.214616][  0]  __driver_attach+0x144/0x280
[   51.218955][  0]  bus_for_each_dev+0x120/0x1a0
[   51.223380][  0]  driver_attach+0x48/0x60
[   51.227372][  0]  bus_add_driver+0x328/0x578
[   51.231625][  0]  driver_register+0x148/0x398
[   51.235965][  0]  __pci_register_driver+0x15c/0x1c8
[   51.240823][  0]  hibmc_init+0x2c/0x34
[   51.244557][  0]  do_one_initcall+0xc8/0x4a8
[   51.248810][  0]  kernel_init_freeable+0x678/0x75c
[   51.253582][  0]  kernel_init+0x18/0x128
[   51.257489][  0]  ret_from_fork+0x10/0x18

Add a initialized flag to avoid this.

Signed-off-by: Shixiong Ou 
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 8 ++--
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 57c21ec452b7..343f64d66e75 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -99,6 +99,7 @@ static int hibmc_kms_init(struct hibmc_drm_private *priv)
ret = drmm_mode_config_init(dev);
if (ret)
return ret;
+   priv->mode_config_initialized = true;
 
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
@@ -240,9 +241,12 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv)
 static int hibmc_unload(struct drm_device *dev)
 {
struct pci_dev *pdev = to_pci_dev(dev->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
 
-   drm_atomic_helper_shutdown(dev);
-
+   if(priv->mode_config_initialized){
+   drm_atomic_helper_shutdown(dev);
+   priv->mode_config_initialized = false;
+   }
free_irq(pdev->irq, dev);
 
pci_disable_msi(to_pci_dev(dev->dev));
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index 207aa3f660b0..08fd7cb59bb5 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -37,6 +37,7 @@ struct hibmc_drm_private {
struct drm_crtc crtc;
struct drm_encoder encoder;
struct hibmc_connector connector;
+   bool mode_config_initialized;
 };
 
 static inline struct hibmc_connector *to_hibmc_connector(struct drm_connector 
*connector)
-- 
2.25.1



[PATCH] drivers/base/devres.c: refactor using guards

2024-06-06 Thread Andrea Calabrese
Refactored devres.c using lock guards and scoped locks.
Changed functions:
- devres_for_each_res
- devres_add
- devres_find
- devres_get
- devres_remove
- release_nodes
- release_all
- devres_open_group
- find_group
- devres_remove_group
- devres_release_group
- devm_krealloc

Signed-off-by: Andrea Calabrese 

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 3df0025d12aa..8f72426ac0b6 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -194,14 +194,12 @@ void devres_for_each_res(struct device *dev, dr_release_t 
release,
 {
struct devres_node *node;
struct devres_node *tmp;
-   unsigned long flags;
 
if (!fn)
return;
 
-   spin_lock_irqsave(&dev->devres_lock, flags);
-   list_for_each_entry_safe_reverse(node, tmp,
-   &dev->devres_head, entry) {
+   guard(spinlock)(&dev->devres_lock);
+   list_for_each_entry_safe_reverse(node, tmp, &dev->devres_head, entry) {
struct devres *dr = container_of(node, struct devres, node);
 
if (node->release != release)
@@ -210,7 +208,6 @@ void devres_for_each_res(struct device *dev, dr_release_t 
release,
continue;
fn(dev, dr->data, data);
}
-   spin_unlock_irqrestore(&dev->devres_lock, flags);
 }
 EXPORT_SYMBOL_GPL(devres_for_each_res);
 
@@ -243,11 +240,9 @@ EXPORT_SYMBOL_GPL(devres_free);
 void devres_add(struct device *dev, void *res)
 {
struct devres *dr = container_of(res, struct devres, data);
-   unsigned long flags;
 
-   spin_lock_irqsave(&dev->devres_lock, flags);
+   guard(spinlock)(&dev->devres_lock);
add_dr(dev, &dr->node);
-   spin_unlock_irqrestore(&dev->devres_lock, flags);
 }
 EXPORT_SYMBOL_GPL(devres_add);
 
@@ -287,11 +282,8 @@ void * devres_find(struct device *dev, dr_release_t 
release,
   dr_match_t match, void *match_data)
 {
struct devres *dr;
-   unsigned long flags;
-
-   spin_lock_irqsave(&dev->devres_lock, flags);
+   guard(spinlock)(&dev->devres_lock);
dr = find_dr(dev, release, match, match_data);
-   spin_unlock_irqrestore(&dev->devres_lock, flags);
 
if (dr)
return dr->data;
@@ -318,16 +310,15 @@ void * devres_get(struct device *dev, void *new_res,
 {
struct devres *new_dr = container_of(new_res, struct devres, data);
struct devres *dr;
-   unsigned long flags;
-
-   spin_lock_irqsave(&dev->devres_lock, flags);
-   dr = find_dr(dev, new_dr->node.release, match, match_data);
-   if (!dr) {
-   add_dr(dev, &new_dr->node);
-   dr = new_dr;
-   new_res = NULL;
+   {
+   guard(spinlock)(&dev->devres_lock);
+   dr = find_dr(dev, new_dr->node.release, match, match_data);
+   if (!dr) {
+   add_dr(dev, &new_dr->node);
+   dr = new_dr;
+   new_res = NULL;
+   }
}
-   spin_unlock_irqrestore(&dev->devres_lock, flags);
devres_free(new_res);
 
return dr->data;
@@ -353,15 +344,20 @@ void * devres_remove(struct device *dev, dr_release_t 
release,
 dr_match_t match, void *match_data)
 {
struct devres *dr;
-   unsigned long flags;
-
-   spin_lock_irqsave(&dev->devres_lock, flags);
-   dr = find_dr(dev, release, match, match_data);
-   if (dr) {
-   list_del_init(&dr->node.entry);
-   devres_log(dev, &dr->node, "REM");
+   scoped_guard(spinlock, &dev->devres_lock) {
+   dr = find_dr(dev, release, match, match_data);
+   if (dr) {
+   list_del_init(&dr->node.entry);
+   devres_log(dev, &dr->node, "REM");
+   }
+   }
+   scoped_guard(spinlock, &dev->devres_lock) {
+   dr = find_dr(dev, release, match, match_data);
+   if (dr) {
+   list_del_init(&dr->node.entry);
+   devres_log(dev, &dr->node, "REM");
+   }
}
-   spin_unlock_irqrestore(&dev->devres_lock, flags);
 
if (dr)
return dr->data;
@@ -516,7 +512,6 @@ static void release_nodes(struct device *dev, struct 
list_head *todo)
  */
 int devres_release_all(struct device *dev)
 {
-   unsigned long flags;
LIST_HEAD(todo);
int cnt;
 
@@ -528,9 +523,9 @@ int devres_release_all(struct device *dev)
if (list_empty(&dev->devres_head))
return 0;
 
-   spin_lock_irqsave(&dev->devres_lock, flags);
-   cnt = remove_nodes(dev, dev->devres_head.next, &dev->devres_head, 
&todo);
-   spin_unlock_irqrestore(&dev->devres_lock, flags);
+   scoped_guard(spinlock, &dev->devres_lock) {
+   cnt = remove_nodes(dev, dev->devres_head.next, 
&dev->devres_head, &todo);
+   }
 
release_nodes(dev, &t

Re: [PATCH v12 12/13] media: imagination: Round to closest multiple for cropping region

2024-06-06 Thread Sebastian Fricke

Hey,

On 04.06.2024 16:23, Devarsh Thakkar wrote:

If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up
(V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest
multiple of requested value while updating the crop rectangle coordinates.

Use the rounding macro which gives preference to rounding down in case two
nearest values (high and low) are possible to raise the probability of
cropping rectangle falling inside the bound region.

This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl
description as documented in v4l uapi [1] which specifies that driver
should choose crop rectangle as close as possible if no flags are passed by
user-space, as quoted below :

"``0`` - The driver can adjust the rectangle size freely and shall choose a
crop/compose rectangle as close as possible to the requested
one."

Link: 
https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst
 [1]
Signed-off-by: Devarsh Thakkar 


Acked-by: Sebastian Fricke 

Can, whoever picks up the math changes, pick up this change as well?
I will send 1-6 via the media subsystem.

Regards,
Sebastian


---
V12: No change
V11: No change
V10: No change
V9:  No change
V8:  Update commit message with specification reference
V1->V7 (No change, patch introduced in V7)
---
drivers/media/platform/imagination/e5010-jpeg-enc.c | 8 
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c 
b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index e701d573a26a..d65646f0c38c 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -517,10 +517,10 @@ static int e5010_s_selection(struct file *file, void *fh, 
struct v4l2_selection

switch (s->flags) {
case 0:
-   s->r.width = round_down(s->r.width, 
queue->fmt->frmsize.step_width);
-   s->r.height = round_down(s->r.height, 
queue->fmt->frmsize.step_height);
-   s->r.left = round_down(s->r.left, 
queue->fmt->frmsize.step_width);
-   s->r.top = round_down(s->r.top, 2);
+   s->r.width = round_closest_down(s->r.width, 
queue->fmt->frmsize.step_width);
+   s->r.height = round_closest_down(s->r.height, 
queue->fmt->frmsize.step_height);
+   s->r.left = round_closest_down(s->r.left, 
queue->fmt->frmsize.step_width);
+   s->r.top = round_closest_down(s->r.top, 2);

if (s->r.left + s->r.width > queue->width)
s->r.width = round_down(s->r.width + s->r.left - 
queue->width,
--
2.39.1



  1   2   >