source
large_stringclasses 2
values | subject
large_stringclasses 112
values | code
large_stringclasses 112
values | critique
large_stringlengths 61
3.04M
⌀ | metadata
dict |
|---|---|---|---|---|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 12:18:44 +0200",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
On Mon, Feb 02, 2026 at 12:18:44PM +0200, Bogdan Sandu wrote:
You resent the same thing again?
confused,
greg k-h
|
{
"author": "Greg KH <gregkh@linuxfoundation.org>",
"date": "Mon, 2 Feb 2026 11:32:15 +0100",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
The previous patch has now been separated into four smaller ones, each one fixing a specific type of checkpatch.pl issue.
Bogdan Sandu (4):
media: ipu3: fix alignment
media: ipu3: use tabs
media: ipu3: avoid ending lines with paranthesis
media: ipu3: use BIT()
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:29 +0200",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Fix alignment with parentheses.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 22 +++++++++++-----------
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 +++++------
drivers/staging/media/ipu3/ipu3.c | 4 ++--
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..145501e90 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1241,6 +1242,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1250,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1270,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2036,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2169,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..c33186208 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -774,7 +774,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:30 +0200",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Use tabs instead of spaces.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 145501e90..e990eb5b3 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -1034,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:31 +0200",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Don't end line with paranthesis.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 13 +++++--------
drivers/staging/media/ipu3/ipu3.c | 3 +--
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index e990eb5b3..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -1226,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index c33186208..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:32 +0200",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH] Cleanup ipu3 driver
|
Clean up warnings generated by ./scripts/checkpatch.pl regarding the ipu3 driver at /drivers/staging/media/ipu3
More specifically, the following files have been affected: ipu3-css.c, ipu3-mmu.c, ipu3-mmu.h, ipu3-v4l2.c, ipu3.c, ipu3.h
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-css.c | 39 ++++++++++++--------------
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 ++-
drivers/staging/media/ipu3/ipu3-v4l2.c | 11 ++++----
drivers/staging/media/ipu3/ipu3.c | 7 ++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 777cac1c2..832581547 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -118,7 +118,8 @@ static const struct {
/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
- struct v4l2_pix_format_mplane *fmt, u32 flags)
+ struct v4l2_pix_format_mplane *fmt,
+ u32 flags)
{
struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix;
unsigned int i;
@@ -1033,8 +1034,8 @@ static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
3 * cfg_dvs->num_horizontal_blocks / 2 *
cfg_dvs->num_vertical_blocks) ||
imgu_css_pool_init(imgu, &css_pipe->pool.obgrid,
- imgu_css_fw_obgrid_size(
- &css->fwp->binary_header[css_pipe->bindex])))
+ imgu_css_fw_obgrid_size
+ (&css->fwp->binary_header[css_pipe->bindex])))
goto out_of_memory;
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
@@ -1225,8 +1226,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
for (j = IMGU_ABI_PARAM_CLASS_CONFIG; j < IMGU_ABI_PARAM_CLASS_NUM; j++)
for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++) {
- if (imgu_css_dma_buffer_resize(
- imgu,
+ if (imgu_css_dma_buffer_resize(imgu,
&css_pipe->binary_params_cs[j - 1][i],
bi->info.isp.sp.mem_initializers.params[j][i].size))
goto out_of_memory;
@@ -1241,6 +1241,7 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height =
ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].height,
IMGU_DVS_BLOCK_H) + 2 * IMGU_GDC_BUF_Y;
+
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].height;
w = ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width,
2 * IPU3_UAPI_ISP_VEC_ELEMS) + 2 * IMGU_GDC_BUF_X;
@@ -1248,10 +1249,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].bytesperpixel * w;
size = w * h * BYPC + (w / 2) * (h / 2) * BYPC * 2;
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_REF].mem[i],
+ size))
goto out_of_memory;
/* TNR frames for temporal noise reduction, FRAME_FORMAT_YUV_LINE */
@@ -1269,10 +1269,9 @@ static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
h = css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].height;
size = w * ALIGN(h * 3 / 2 + 3, 2); /* +3 for vf_pp prefetch */
for (i = 0; i < IPU3_CSS_AUX_FRAMES; i++)
- if (imgu_css_dma_buffer_resize(
- imgu,
- &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
- size))
+ if (imgu_css_dma_buffer_resize(imgu,
+ &css_pipe->aux_frames[IPU3_CSS_AUX_FRAME_TNR].mem[i],
+ size))
goto out_of_memory;
return 0;
@@ -2036,7 +2035,7 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
struct imgu_css_buffer, list);
if (queue != b->queue ||
daddr != css_pipe->abi_buffers
- [b->queue][b->queue_pos].daddr) {
+ [b->queue][b->queue_pos].daddr) {
spin_unlock(&css_pipe->qlock);
dev_err(css->dev, "dequeued bad buffer 0x%x\n", daddr);
return ERR_PTR(-EIO);
@@ -2169,7 +2168,7 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
map = imgu_css_pool_last(&css_pipe->pool.acc, 1);
/* user acc */
r = imgu_css_cfg_acc(css, pipe, use, acc, map->vaddr,
- set_params ? &set_params->acc_param : NULL);
+ set_params ? &set_params->acc_param : NULL);
if (r < 0)
goto fail;
}
@@ -2298,13 +2297,11 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
if (obgrid)
imgu_css_pool_put(&css_pipe->pool.obgrid);
if (vmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_VMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_VMEM0]);
if (dmem0)
- imgu_css_pool_put(
- &css_pipe->pool.binary_params_p
- [IMGU_ABI_MEM_ISP_DMEM0]);
+ imgu_css_pool_put(&css_pipe->pool.binary_params_p
+ [IMGU_ABI_MEM_ISP_DMEM0]);
fail_no_put:
return r;
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 2f6041d34..8ebfcddab 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -245,9 +245,9 @@ static int imgu_subdev_set_selection(struct v4l2_subdev *sd,
struct v4l2_rect *rect;
dev_dbg(&imgu->pci_dev->dev,
- "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
- imgu_sd->pipe, sel->which, sel->target,
- sel->r.width, sel->r.height);
+ "set subdev %u sel which %u target 0x%4x rect [%ux%u]",
+ imgu_sd->pipe, sel->which, sel->target,
+ sel->r.width, sel->r.height);
if (sel->pad != IMGU_NODE_IN)
return -EINVAL;
@@ -288,7 +288,7 @@ static int imgu_link_setup(struct media_entity *entity,
WARN_ON(pad >= IMGU_NODE_NUM);
dev_dbg(&imgu->pci_dev->dev, "pipe %u pad %u is %s", pipe, pad,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
imgu_pipe = &imgu->imgu_pipe[pipe];
imgu_pipe->nodes[pad].enabled = flags & MEDIA_LNK_FL_ENABLED;
@@ -303,7 +303,7 @@ static int imgu_link_setup(struct media_entity *entity,
__clear_bit(pipe, imgu->css.enabled_pipes);
dev_dbg(&imgu->pci_dev->dev, "pipe %u is %s", pipe,
- str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
+ str_enabled_disabled(flags & MEDIA_LNK_FL_ENABLED));
return 0;
}
@@ -750,7 +750,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
} else {
fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp;
}
-
}
if (!try) {
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index bdf5a4577..fe343d368 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -151,7 +151,7 @@ static int imgu_dummybufs_init(struct imgu_device *imgu, unsigned int pipe)
/* May be called from atomic context */
static struct imgu_css_buffer *imgu_dummybufs_get(struct imgu_device *imgu,
- int queue, unsigned int pipe)
+ int queue, unsigned int pipe)
{
unsigned int i;
struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe];
@@ -556,8 +556,7 @@ static irqreturn_t imgu_isr_threaded(int irq, void *imgu_ptr)
buf->vid_buf.vbb.vb2_buf.timestamp = ns;
buf->vid_buf.vbb.field = V4L2_FIELD_NONE;
buf->vid_buf.vbb.sequence =
- atomic_inc_return(
- &imgu_pipe->nodes[node].sequence);
+ atomic_inc_return(&imgu_pipe->nodes[node].sequence);
dev_dbg(&imgu->pci_dev->dev, "vb2 buffer sequence %d",
buf->vid_buf.vbb.sequence);
}
@@ -774,7 +773,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
synchronize_irq(pci_dev->irq);
/* Wait until all buffers in CSS are done. */
if (!wait_event_timeout(imgu->buf_drain_wq,
- imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
+ imgu_css_queue_empty(&imgu->css), msecs_to_jiffies(1000)))
dev_err(dev, "wait buffer drain timeout.\n");
imgu_css_stop_streaming(&imgu->css);
--
2.51.0
|
Prefer BIT() macro over manual bitshift.
Signed-off-by: Bogdan Sandu <bogdanelsandu2011@gmail.com>
---
drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
drivers/staging/media/ipu3/ipu3-mmu.h | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c
index cb9bf5fb2..95ce34ad8 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.c
+++ b/drivers/staging/media/ipu3/ipu3-mmu.c
@@ -21,7 +21,7 @@
#include "ipu3-mmu.h"
#define IPU3_PT_BITS 10
-#define IPU3_PT_PTES (1UL << IPU3_PT_BITS)
+#define IPU3_PT_PTES (BIT(IPU3_PT_BITS))
#define IPU3_PT_SIZE (IPU3_PT_PTES << 2)
#define IPU3_PT_ORDER (IPU3_PT_SIZE >> PAGE_SHIFT)
diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h
index a5f0bca7e..990482f10 100644
--- a/drivers/staging/media/ipu3/ipu3-mmu.h
+++ b/drivers/staging/media/ipu3/ipu3-mmu.h
@@ -5,8 +5,10 @@
#ifndef __IPU3_MMU_H
#define __IPU3_MMU_H
+#include <linux/bitops.h>
+
#define IPU3_PAGE_SHIFT 12
-#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT)
+#define IPU3_PAGE_SIZE (BIT(IPU3_PAGE_SHIFT))
/**
* struct imgu_mmu_info - Describes mmu geometry
--
2.51.0
|
{
"author": "Bogdan Sandu <bogdanelsandu2011@gmail.com>",
"date": "Mon, 2 Feb 2026 19:50:33 +0200",
"thread_id": "2026020258-very-numbly-b36b@gregkh.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Convert the device tree binding documentation for tilcdc
from plain text to DT binding schema.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Rename binding file to ti,am33xx-tilcdc.yaml.
- Use generic node name and drop unused label.
---
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++++++++++++++++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 -----------------
2 files changed, 100 insertions(+), 82 deletions(-)
diff --git a/Documentation/devicetree/bindings/display/tilcdc/ti,am33xx-tilcdc.yaml b/Documentation/devicetree/bindings/display/tilcdc/ti,am33xx-tilcdc.yaml
new file mode 100644
index 0000000000000..eb0ebb678fa87
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/tilcdc/ti,am33xx-tilcdc.yaml
@@ -0,0 +1,100 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2025 Bootlin
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/tilcdc/ti,am33xx-tilcdc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI LCD Controller, found on AM335x, DA850, AM18x and OMAP-L138
+
+maintainers:
+ - Kory Maincent <kory.maincent@bootlin.com>
+
+properties:
+ compatible:
+ enum:
+ - ti,am33xx-tilcdc
+ - ti,da850-tilcdc
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ port:
+ $ref: /schemas/graph.yaml#/properties/port
+
+ ti,hwmods:
+ $ref: /schemas/types.yaml#/definitions/string
+ description:
+ Name of the hwmod associated to the LCDC
+
+ max-bandwidth:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ The maximum pixels per second that the memory interface / lcd
+ controller combination can sustain
+ # maximum: 2048*2048*60
+ maximum: 251658240
+
+ max-width:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ The maximum horizontal pixel width supported by the lcd controller.
+ maximum: 2048
+
+ max-pixelclock:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ The maximum pixel clock that can be supported by the lcd controller
+ in KHz.
+
+ blue-and-red-wiring:
+ enum: [straight, crossed]
+ description:
+ This property deals with the LCDC revision 2 (found on AM335x)
+ color errata [1].
+ - "straight" indicates normal wiring that supports RGB565,
+ BGR888, and XBGR8888 color formats.
+ - "crossed" indicates wiring that has blue and red wires
+ crossed. This setup supports BGR565, RGB888 and XRGB8888
+ formats.
+ - If the property is not present or its value is not recognized
+ the legacy mode is assumed. This configuration supports RGB565,
+ RGB888 and XRGB8888 formats. However, depending on wiring, the red
+ and blue colors are swapped in either 16 or 24-bit color modes.
+
+ [1] There is an errata about AM335x color wiring. For 16-bit color
+ mode the wires work as they should (LCD_DATA[0:4] is for Blue[3:7]),
+ but for 24 bit color modes the wiring of blue and red components is
+ crossed and LCD_DATA[0:4] is for Red[3:7] and LCD_DATA[11:15] is
+ for Blue[3-7]. For more details see section 3.1.1 in AM335x
+ Silicon Errata
+ https://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360
+
+required:
+ - compatible
+ - interrupts
+ - reg
+ - port
+
+additionalProperties: false
+
+examples:
+ - |
+ display-controller@4830e000 {
+ compatible = "ti,am33xx-tilcdc";
+ reg = <0x4830e000 0x1000>;
+ interrupt-parent = <&intc>;
+ interrupts = <36>;
+ ti,hwmods = "lcdc";
+
+ blue-and-red-wiring = "crossed";
+
+ port {
+ endpoint {
+ remote-endpoint = <&hdmi_0>;
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
deleted file mode 100644
index 3b3d0bbfcfff4..0000000000000
--- a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-Device-Tree bindings for tilcdc DRM driver
-
-Required properties:
- - compatible: value should be one of the following:
- - "ti,am33xx-tilcdc" for AM335x based boards
- - "ti,da850-tilcdc" for DA850/AM18x/OMAP-L138 based boards
- - interrupts: the interrupt number
- - reg: base address and size of the LCDC device
-
-Recommended properties:
- - ti,hwmods: Name of the hwmod associated to the LCDC
-
-Optional properties:
- - max-bandwidth: The maximum pixels per second that the memory
- interface / lcd controller combination can sustain
- - max-width: The maximum horizontal pixel width supported by
- the lcd controller.
- - max-pixelclock: The maximum pixel clock that can be supported
- by the lcd controller in KHz.
- - blue-and-red-wiring: Recognized values "straight" or "crossed".
- This property deals with the LCDC revision 2 (found on AM335x)
- color errata [1].
- - "straight" indicates normal wiring that supports RGB565,
- BGR888, and XBGR8888 color formats.
- - "crossed" indicates wiring that has blue and red wires
- crossed. This setup supports BGR565, RGB888 and XRGB8888
- formats.
- - If the property is not present or its value is not recognized
- the legacy mode is assumed. This configuration supports RGB565,
- RGB888 and XRGB8888 formats. However, depending on wiring, the red
- and blue colors are swapped in either 16 or 24-bit color modes.
-
-Optional nodes:
-
- - port/ports: to describe a connection to an external encoder. The
- binding follows Documentation/devicetree/bindings/graph.txt and
- supports a single port with a single endpoint.
-
- - See also Documentation/devicetree/bindings/display/tilcdc/panel.txt and
- Documentation/devicetree/bindings/display/bridge/ti,tfp410.yaml for connecting
- tfp410 DVI encoder or lcd panel to lcdc
-
-[1] There is an errata about AM335x color wiring. For 16-bit color mode
- the wires work as they should (LCD_DATA[0:4] is for Blue[3:7]),
- but for 24 bit color modes the wiring of blue and red components is
- crossed and LCD_DATA[0:4] is for Red[3:7] and LCD_DATA[11:15] is
- for Blue[3-7]. For more details see section 3.1.1 in AM335x
- Silicon Errata:
- https://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360
-
-Example:
-
- fb: fb@4830e000 {
- compatible = "ti,am33xx-tilcdc", "ti,da850-tilcdc";
- reg = <0x4830e000 0x1000>;
- interrupt-parent = <&intc>;
- interrupts = <36>;
- ti,hwmods = "lcdc";
-
- blue-and-red-wiring = "crossed";
-
- port {
- lcdc_0: endpoint {
- remote-endpoint = <&hdmi_0>;
- };
- };
- };
-
- tda19988: tda19988 {
- compatible = "nxp,tda998x";
- reg = <0x70>;
-
- pinctrl-names = "default", "off";
- pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
- pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
-
- port {
- hdmi_0: endpoint {
- remote-endpoint = <&lcdc_0>;
- };
- };
- };
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:19 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The tilcdc hardware does not generate VESA-compliant sync signals. It
aligns the vertical sync (VS) on the second edge of the horizontal sync
(HS) instead of the first edge. To compensate for this hardware
behavior, the driver applies a timing adjustment in mode_fixup().
Previously, this adjustment was conditional based on the simulate_vesa_sync
flag, which was only set when using external encoders. This appears
problematic because:
1. The timing adjustment seems needed for the hardware behavior regardless
of whether an external encoder is used
2. The external encoder infrastructure is driver-specific and being
removed due to design issues
3. Boards using tilcdc without bridges (e.g., am335x-evm, am335x-evmsk)
may not be getting the necessary timing adjustments
Remove the simulate_vesa_sync flag and apply the VESA sync timing
adjustment unconditionally, ensuring consistent behavior across all
configurations. While it's unclear if the previous conditional behavior
was causing actual issues, the unconditional adjustment better reflects
the hardware's characteristics.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Only few board currently use tilcdc not associated to a bridge like the
am335x_evm or the am335x-evmsk.
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 16 ----------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 2 --
drivers/gpu/drm/tilcdc/tilcdc_external.c | 1 -
3 files changed, 19 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 52c95131af5af..b06b1453db2dd 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -47,9 +47,6 @@ struct tilcdc_crtc {
struct drm_framebuffer *next_fb;
- /* Only set if an external encoder is connected */
- bool simulate_vesa_sync;
-
int sync_lost_count;
bool frame_intact;
struct work_struct recover_work;
@@ -642,11 +639,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
- struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-
- if (!tilcdc_crtc->simulate_vesa_sync)
- return true;
-
/*
* tilcdc does not generate VESA-compliant sync but aligns
* VS on the second edge of HS instead of first edge.
@@ -866,14 +858,6 @@ void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
tilcdc_crtc->info = info;
}
-void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
- bool simulate_vesa_sync)
-{
- struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-
- tilcdc_crtc->simulate_vesa_sync = simulate_vesa_sync;
-}
-
void tilcdc_crtc_update_clk(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 58b276f82a669..3aba3a1155ba0 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -160,8 +160,6 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info);
-void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
- bool simulate_vesa_sync);
void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
void tilcdc_crtc_destroy(struct drm_crtc *crtc);
int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 3b86d002ef62e..da755a411d9ff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -80,7 +80,6 @@ int tilcdc_add_component_encoder(struct drm_device *ddev)
return -ENODEV;
/* Only tda998x is supported at the moment. */
- tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true);
tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x);
return 0;
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:21 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
To maintain backward compatibility while removing the deprecated
tilcdc_panel driver, add a tilcdc_panel_legacy subdriver that converts
the legacy "ti,tilcdc,panel" devicetree binding to the standard
panel-dpi binding at early boot.
The conversion uses an embedded device tree overlay that is applied and
modified during subsys_initcall. The process:
- Apply embedded overlay to create a tilcdc-panel-dpi node with
port/endpoint connections to the LCDC
- Copy all properties from the legacy panel node to the new
tilcdc-panel-dpi node
- Copy display-timings from the legacy panel
- Convert legacy panel-info properties (invert-pxl-clk, sync-edge) to
standard display timing properties (pixelclk-active, syncclk-active)
- Disable the legacy panel by removing its compatible property to
prevent the deprecated driver from binding
The result is a standard tilcdc-panel-dpi node with proper endpoints and
timing properties, allowing the DRM panel infrastructure to work with
legacy devicetrees without modification.
Other legacy panel-info properties are not migrated as they consistently
use default values across all mainline devicetrees and can be hardcoded
in the tilcdc driver.
This feature is optional via CONFIG_DRM_TILCDC_PANEL_LEGACY and should
only be enabled for systems with legacy devicetrees containing
"ti,tilcdc,panel" nodes.
Suggested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://lore.kernel.org/all/1d9a9269-bfda-4d43-938b-2df6b82b9369@ideasonboard.com/
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Using the approach of applying an overlay and then modifying the live
device tree is the solution I found that requires no modification of the
OF core. Dealing entirely with changesets would bring additional
requirements such as phandle resolution management, which is internal to
the OF framework. I intend to avoid OF core change to support this legacy
binding.
Change in v4:
- Use tab instead of space.
Change in v3:
- Use __free() macro instead of manual house cleaning.
- Enable CONFIG_DRM_TILCDC_PANEL_LEGACY config by default.
- Improve config description.
- Rename "panel-dpi" to "tilcdc-panel-dpi" to avoid any future conflict.
- Use OF changeset instead of modifying the live devicetree step by
step.
- Add kfree to avoid memory leak.
Change in v2:
- New patch.
---
drivers/gpu/drm/tilcdc/Kconfig | 16 ++
drivers/gpu/drm/tilcdc/Makefile | 2 +
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++++++++++++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++++
4 files changed, 232 insertions(+)
diff --git a/drivers/gpu/drm/tilcdc/Kconfig b/drivers/gpu/drm/tilcdc/Kconfig
index 24f9a245ba593..a36e809f984cd 100644
--- a/drivers/gpu/drm/tilcdc/Kconfig
+++ b/drivers/gpu/drm/tilcdc/Kconfig
@@ -14,3 +14,19 @@ config DRM_TILCDC
controller, for example AM33xx in beagle-bone, DA8xx, or
OMAP-L1xx. This driver replaces the FB_DA8XX fbdev driver.
+config DRM_TILCDC_PANEL_LEGACY
+ bool "Support device tree blobs using TI LCDC Panel binding"
+ default y
+ depends on DRM_TILCDC
+ depends on OF
+ depends on BACKLIGHT_CLASS_DEVICE
+ depends on PM
+ select OF_OVERLAY
+ select DRM_PANEL_SIMPLE
+ help
+ Modifies the live device tree at early boot to convert the legacy
+ "ti,tilcdc,panel" devicetree node to the standard panel-dpi node.
+ This allows to maintain backward compatibility for boards which
+ were using the deprecated tilcdc_panel driver.
+ If you find "ti,tilcdc,panel"-string from your DTB, you probably
+ need this. Otherwise you do not.
diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile
index f5190477de721..6d6a08b5adf40 100644
--- a/drivers/gpu/drm/tilcdc/Makefile
+++ b/drivers/gpu/drm/tilcdc/Makefile
@@ -11,3 +11,5 @@ tilcdc-y := \
tilcdc_drv.o
obj-$(CONFIG_DRM_TILCDC) += tilcdc.o
+obj-$(CONFIG_DRM_TILCDC_PANEL_LEGACY) += tilcdc_panel_legacy.o \
+ tilcdc_panel_legacy.dtbo.o
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c b/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
new file mode 100644
index 0000000000000..37a69b3cf04b2
--- /dev/null
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
@@ -0,0 +1,185 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Bootlin
+ * Author: Kory Maincent <kory.maincent@bootlin.com>
+ *
+ * To support the legacy "ti,tilcdc,panel" binding, the devicetree has to
+ * be transformed to the new panel-dpi binding with the endpoint associated.
+ */
+
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/slab.h>
+
+/* Embedded dtbo symbols created by cmd_wrap_S_dtb in scripts/Makefile.lib */
+extern char __dtbo_tilcdc_panel_legacy_begin[];
+extern char __dtbo_tilcdc_panel_legacy_end[];
+
+static int __init
+tilcdc_panel_update_prop(struct of_changeset *ocs, struct device_node *node,
+ char *name, void *val, int length)
+{
+ struct property *prop;
+
+ prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+ if (!prop)
+ return -ENOMEM;
+
+ prop->name = kstrdup(name, GFP_KERNEL);
+ prop->length = length;
+ prop->value = kmemdup(val, length, GFP_KERNEL);
+ if (!prop->name || !prop->value) {
+ kfree(prop->name);
+ kfree(prop->value);
+ kfree(prop);
+ return -ENOMEM;
+ }
+
+ return of_changeset_update_property(ocs, node, prop);
+}
+
+static int __init tilcdc_panel_copy_props(struct device_node *old_panel,
+ struct device_node *new_panel)
+{
+ struct device_node *old_timing __free(device_node) = NULL;
+ struct device_node *new_timing __free(device_node) = NULL;
+ struct device_node *panel_info __free(device_node) = NULL;
+ struct device_node *child __free(device_node) = NULL;
+ u32 invert_pxl_clk = 0, sync_edge = 0;
+ struct of_changeset ocs;
+ struct property *prop;
+ int ret;
+
+ child = of_get_child_by_name(old_panel, "display-timings");
+ if (!child)
+ return -EINVAL;
+
+ /* The default display timing is the one specified as native-mode.
+ * If no native-mode is specified then the first node is assumed
+ * to be the native mode.
+ */
+ old_timing = of_parse_phandle(child, "native-mode", 0);
+ if (!old_timing) {
+ old_timing = of_get_next_child(child, NULL);
+ if (!old_timing)
+ return -EINVAL;
+ }
+
+ panel_info = of_get_child_by_name(old_panel, "panel-info");
+ if (!panel_info)
+ return -EINVAL;
+
+ of_changeset_init(&ocs);
+
+ /* Copy all panel properties to the new panel node */
+ for_each_property_of_node(old_panel, prop) {
+ if (!strncmp(prop->name, "compatible", sizeof("compatible")))
+ continue;
+
+ ret = tilcdc_panel_update_prop(&ocs, new_panel, prop->name,
+ prop->value, prop->length);
+ if (ret)
+ goto destroy_ocs;
+ }
+
+ new_timing = of_changeset_create_node(&ocs, new_panel, "panel-timing");
+ if (!new_timing) {
+ ret = -ENODEV;
+ goto destroy_ocs;
+ }
+
+ /* Copy all panel timing properties to the new panel node */
+ for_each_property_of_node(old_timing, prop) {
+ ret = tilcdc_panel_update_prop(&ocs, new_timing, prop->name,
+ prop->value, prop->length);
+ if (ret)
+ goto destroy_ocs;
+ }
+
+ /* Looked only for these two parameter as all the other are always
+ * set to default and not related to common DRM properties.
+ */
+ of_property_read_u32(panel_info, "invert-pxl-clk", &invert_pxl_clk);
+ of_property_read_u32(panel_info, "sync-edge", &sync_edge);
+
+ if (!invert_pxl_clk) {
+ ret = tilcdc_panel_update_prop(&ocs, new_timing, "pixelclk-active",
+ &(u32){cpu_to_be32(1)}, sizeof(u32));
+ if (ret)
+ goto destroy_ocs;
+ }
+
+ if (!sync_edge) {
+ ret = tilcdc_panel_update_prop(&ocs, new_timing, "syncclk-active",
+ &(u32){cpu_to_be32(1)}, sizeof(u32));
+ if (ret)
+ goto destroy_ocs;
+ }
+
+ /* Remove compatible property to avoid any driver compatible match */
+ of_changeset_remove_property(&ocs, old_panel,
+ of_find_property(old_panel, "compatible", NULL));
+
+ of_changeset_apply(&ocs);
+ return 0;
+
+destroy_ocs:
+ of_changeset_destroy(&ocs);
+ return ret;
+}
+
+static const struct of_device_id tilcdc_panel_of_match[] __initconst = {
+ { .compatible = "ti,tilcdc,panel", },
+ {},
+};
+
+static const struct of_device_id tilcdc_of_match[] __initconst = {
+ { .compatible = "ti,am33xx-tilcdc", },
+ { .compatible = "ti,da850-tilcdc", },
+ {},
+};
+
+static int __init tilcdc_panel_legacy_init(void)
+{
+ struct device_node *new_panel __free(device_node) = NULL;
+ struct device_node *panel __free(device_node) = NULL;
+ struct device_node *lcdc __free(device_node) = NULL;
+ void *dtbo_start;
+ u32 dtbo_size;
+ int ovcs_id;
+ int ret;
+
+ lcdc = of_find_matching_node(NULL, tilcdc_of_match);
+ panel = of_find_matching_node(NULL, tilcdc_panel_of_match);
+
+ if (!of_device_is_available(panel) ||
+ !of_device_is_available(lcdc))
+ return 0;
+
+ dtbo_start = __dtbo_tilcdc_panel_legacy_begin;
+ dtbo_size = __dtbo_tilcdc_panel_legacy_end -
+ __dtbo_tilcdc_panel_legacy_begin;
+
+ ret = of_overlay_fdt_apply(dtbo_start, dtbo_size, &ovcs_id, NULL);
+ if (ret)
+ return ret;
+
+ new_panel = of_find_node_by_name(NULL, "tilcdc-panel-dpi");
+ if (!new_panel) {
+ ret = -ENODEV;
+ goto overlay_remove;
+ }
+
+ ret = tilcdc_panel_copy_props(panel, new_panel);
+ if (ret)
+ goto overlay_remove;
+
+ return 0;
+
+overlay_remove:
+ of_overlay_remove(&ovcs_id);
+ return ret;
+}
+
+subsys_initcall(tilcdc_panel_legacy_init);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso b/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso
new file mode 100644
index 0000000000000..ae71d10f5ec13
--- /dev/null
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DTS overlay for converting ti,tilcdc,panel binding to new binding.
+ *
+ * Copyright (C) 2025 Bootlin
+ * Author: Kory Maincent <kory.maincent@bootlin.com>
+ */
+
+/dts-v1/;
+/plugin/;
+
+&{/} {
+ tilcdc-panel-dpi {
+ compatible = "panel-dpi";
+ port {
+ panel_in: endpoint@0 {
+ remote-endpoint = <&lcd_0>;
+ };
+ };
+ };
+};
+
+&lcdc {
+ port {
+ lcd_0: endpoint@0 {
+ remote-endpoint = <&panel_in>;
+ };
+ };
+};
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:23 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Mark the ti,tilcdc,panel binding as deprecated in the documentation.
This legacy binding should no longer be used for new designs. Users
should migrate to the standard DRM panel bindings instead.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v2:
- New patch
---
Documentation/devicetree/bindings/display/tilcdc/panel.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/display/tilcdc/panel.txt b/Documentation/devicetree/bindings/display/tilcdc/panel.txt
index 808216310ea27..b973174d704ed 100644
--- a/Documentation/devicetree/bindings/display/tilcdc/panel.txt
+++ b/Documentation/devicetree/bindings/display/tilcdc/panel.txt
@@ -1,4 +1,5 @@
Device-Tree bindings for tilcdc DRM generic panel output driver
+This binding is deprecated and should not be used.
Required properties:
- compatible: value should be "ti,tilcdc,panel".
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:20 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Migrate CRTC mode configuration to use standard DRM bus flags in
preparation for removing the tilcdc_panel driver and its custom
tilcdc_panel_info structure.
Add support for DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE and
DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE flags to control pixel clock and sync
signal edge polarity, while maintaining backward compatibility with the
existing tilcdc panel info structure.
Simplify several hardware parameters by setting them to fixed defaults
based on common usage across existing device trees:
- DMA burst size: 16 (previously configurable via switch statement)
- AC bias frequency: 255 (previously panel-specific)
- FIFO DMA request delay: 128 (previously panel-specific)
These parameters show no variation in real-world usage, so hardcoding
them simplifies the driver without losing functionality.
Preserve FIFO threshold configurability by detecting the SoC type, as
this parameter varies between AM33xx (8) and DA850 (16) platforms.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v4:
- Use of_device_get_match_data() instead of of_match_node().
- Move back the tilcdc_of_match table down were it was before.
Change in v2:
- Use SoC type instead of devicetree parameter to set FIFO threshold
value.
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 47 +++++++++++++-----------------------
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 17 +++++++++++--
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 2 ++
3 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index b06b1453db2dd..2309a9a0c925d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -285,27 +285,15 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
/* Configure the Burst Size and fifo threshold of DMA: */
reg = tilcdc_read(dev, LCDC_DMA_CTRL_REG) & ~0x00000770;
- switch (info->dma_burst_sz) {
- case 1:
- reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_1);
- break;
- case 2:
- reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_2);
- break;
- case 4:
- reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_4);
- break;
- case 8:
- reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_8);
- break;
- case 16:
- reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_16);
- break;
- default:
- dev_err(dev->dev, "invalid burst size\n");
- return;
+ /* Use 16 bit DMA burst size by default */
+ reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_16);
+ if (priv->fifo_th) {
+ int fifo_th_val = ilog2(priv->fifo_th) - 3;
+
+ reg |= (fifo_th_val << 8);
+ } else {
+ reg |= (info->fifo_th << 8);
}
- reg |= (info->fifo_th << 8);
tilcdc_write(dev, LCDC_DMA_CTRL_REG, reg);
/* Configure timings: */
@@ -321,8 +309,8 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
/* Set AC Bias Period and Number of Transitions per Interrupt: */
reg = tilcdc_read(dev, LCDC_RASTER_TIMING_2_REG) & ~0x000fff00;
- reg |= LCDC_AC_BIAS_FREQUENCY(info->ac_bias) |
- LCDC_AC_BIAS_TRANSITIONS_PER_INT(info->ac_bias_intrpt);
+ /* Use 255 AC Bias Pin Frequency by default */
+ reg |= LCDC_AC_BIAS_FREQUENCY(255);
/*
* subtract one from hfp, hbp, hsw because the hardware uses
@@ -392,20 +380,19 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
return;
}
}
- reg |= info->fdd << 12;
+ /* Use 128 FIFO DMA Request Delay by default */
+ reg |= 128 << 12;
tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg);
- if (info->invert_pxl_clk)
+ if (info->invert_pxl_clk ||
+ mode->flags == DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK);
else
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK);
- if (info->sync_ctrl)
- tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
- else
- tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
-
- if (info->sync_edge)
+ tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
+ if (info->sync_edge ||
+ mode->flags == DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE)
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE);
else
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3dcbec312bacb..fe01f3fcaf3c2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -31,6 +31,11 @@
#include "tilcdc_panel.h"
#include "tilcdc_regs.h"
+enum tilcdc_variant {
+ AM33XX_TILCDC,
+ DA850_TILCDC,
+};
+
static LIST_HEAD(module_list);
static const u32 tilcdc_rev1_formats[] = { DRM_FORMAT_RGB565 };
@@ -198,6 +203,7 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct device_node *node = dev->of_node;
struct tilcdc_drm_private *priv;
+ enum tilcdc_variant variant;
u32 bpp = 0;
int ret;
@@ -209,6 +215,8 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
if (IS_ERR(ddev))
return PTR_ERR(ddev);
+ variant = (uintptr_t)of_device_get_match_data(dev);
+
ddev->dev_private = priv;
platform_set_drvdata(pdev, ddev);
drm_mode_config_init(ddev);
@@ -309,6 +317,11 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
+ if (variant == DA850_TILCDC)
+ priv->fifo_th = 16;
+ else
+ priv->fifo_th = 8;
+
ret = tilcdc_crtc_create(ddev);
if (ret < 0) {
dev_err(dev, "failed to create crtc\n");
@@ -598,8 +611,8 @@ static void tilcdc_pdev_shutdown(struct platform_device *pdev)
}
static const struct of_device_id tilcdc_of_match[] = {
- { .compatible = "ti,am33xx-tilcdc", },
- { .compatible = "ti,da850-tilcdc", },
+ { .compatible = "ti,am33xx-tilcdc", .data = (void *)AM33XX_TILCDC},
+ { .compatible = "ti,da850-tilcdc", .data = (void *)DA850_TILCDC},
{ },
};
MODULE_DEVICE_TABLE(of, tilcdc_of_match);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 3aba3a1155ba0..79078b4ae7393 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -61,6 +61,8 @@ struct tilcdc_drm_private {
*/
uint32_t max_width;
+ u32 fifo_th;
+
/* Supported pixel formats */
const uint32_t *pixelformats;
uint32_t num_pixelformats;
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:22 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The tilcdc panel subdriver is a legacy, non-standard driver that has been
replaced by the standard panel-dpi driver and panel-simple infrastructure.
With the device tree bindings removed and all in-tree users migrated to
use panel-dpi, this driver no longer has any associated device tree
bindings or users. The panel-dpi driver combined with DRM bus flags
provides equivalent functionality in a standard way that is compatible
with the broader DRM panel ecosystem.
This removal eliminates 400+ lines of redundant code and completes the
migration to standard panel handling.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/Makefile | 1 -
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 -
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 ----------------------------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 --
4 files changed, 427 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile
index 6d6a08b5adf40..b78204a65ce29 100644
--- a/drivers/gpu/drm/tilcdc/Makefile
+++ b/drivers/gpu/drm/tilcdc/Makefile
@@ -6,7 +6,6 @@ endif
tilcdc-y := \
tilcdc_plane.o \
tilcdc_crtc.o \
- tilcdc_panel.o \
tilcdc_external.o \
tilcdc_drv.o
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index fe01f3fcaf3c2..f03861ed6349d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -28,7 +28,6 @@
#include "tilcdc_drv.h"
#include "tilcdc_external.h"
-#include "tilcdc_panel.h"
#include "tilcdc_regs.h"
enum tilcdc_variant {
@@ -634,7 +633,6 @@ static int __init tilcdc_drm_init(void)
return -ENODEV;
DBG("init");
- tilcdc_panel_init();
return platform_driver_register(&tilcdc_platform_driver);
}
@@ -642,7 +640,6 @@ static void __exit tilcdc_drm_fini(void)
{
DBG("fini");
platform_driver_unregister(&tilcdc_platform_driver);
- tilcdc_panel_fini();
}
module_init(tilcdc_drm_init);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
deleted file mode 100644
index 262f290d85d91..0000000000000
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ /dev/null
@@ -1,408 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2012 Texas Instruments
- * Author: Rob Clark <robdclark@gmail.com>
- */
-
-#include <linux/backlight.h>
-#include <linux/gpio/consumer.h>
-#include <linux/platform_device.h>
-
-#include <video/display_timing.h>
-#include <video/of_display_timing.h>
-#include <video/videomode.h>
-
-#include <drm/drm_atomic_state_helper.h>
-#include <drm/drm_connector.h>
-#include <drm/drm_modeset_helper_vtables.h>
-#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
-
-#include "tilcdc_drv.h"
-#include "tilcdc_panel.h"
-
-struct panel_module {
- struct tilcdc_module base;
- struct tilcdc_panel_info *info;
- struct display_timings *timings;
- struct backlight_device *backlight;
- struct gpio_desc *enable_gpio;
-};
-#define to_panel_module(x) container_of(x, struct panel_module, base)
-
-
-/*
- * Encoder:
- */
-
-struct panel_encoder {
- struct drm_encoder base;
- struct panel_module *mod;
-};
-#define to_panel_encoder(x) container_of(x, struct panel_encoder, base)
-
-static void panel_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
- struct panel_encoder *panel_encoder = to_panel_encoder(encoder);
- struct backlight_device *backlight = panel_encoder->mod->backlight;
- struct gpio_desc *gpio = panel_encoder->mod->enable_gpio;
-
- if (backlight) {
- backlight->props.power = mode == DRM_MODE_DPMS_ON ?
- BACKLIGHT_POWER_ON : BACKLIGHT_POWER_OFF;
- backlight_update_status(backlight);
- }
-
- if (gpio)
- gpiod_set_value_cansleep(gpio,
- mode == DRM_MODE_DPMS_ON ? 1 : 0);
-}
-
-static void panel_encoder_prepare(struct drm_encoder *encoder)
-{
- panel_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
-}
-
-static void panel_encoder_commit(struct drm_encoder *encoder)
-{
- panel_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
-}
-
-static void panel_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
-{
- /* nothing needed */
-}
-
-static const struct drm_encoder_helper_funcs panel_encoder_helper_funcs = {
- .dpms = panel_encoder_dpms,
- .prepare = panel_encoder_prepare,
- .commit = panel_encoder_commit,
- .mode_set = panel_encoder_mode_set,
-};
-
-static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
- struct panel_module *mod)
-{
- struct panel_encoder *panel_encoder;
- struct drm_encoder *encoder;
- int ret;
-
- panel_encoder = devm_kzalloc(dev->dev, sizeof(*panel_encoder),
- GFP_KERNEL);
- if (!panel_encoder)
- return NULL;
-
- panel_encoder->mod = mod;
-
- encoder = &panel_encoder->base;
- encoder->possible_crtcs = 1;
-
- ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_LVDS);
- if (ret < 0)
- goto fail;
-
- drm_encoder_helper_add(encoder, &panel_encoder_helper_funcs);
-
- return encoder;
-
-fail:
- drm_encoder_cleanup(encoder);
- return NULL;
-}
-
-/*
- * Connector:
- */
-
-struct panel_connector {
- struct drm_connector base;
-
- struct drm_encoder *encoder; /* our connected encoder */
- struct panel_module *mod;
-};
-#define to_panel_connector(x) container_of(x, struct panel_connector, base)
-
-
-static void panel_connector_destroy(struct drm_connector *connector)
-{
- drm_connector_unregister(connector);
- drm_connector_cleanup(connector);
-}
-
-static int panel_connector_get_modes(struct drm_connector *connector)
-{
- struct drm_device *dev = connector->dev;
- struct panel_connector *panel_connector = to_panel_connector(connector);
- struct display_timings *timings = panel_connector->mod->timings;
- int i;
-
- for (i = 0; i < timings->num_timings; i++) {
- struct drm_display_mode *mode;
- struct videomode vm;
-
- if (videomode_from_timings(timings, &vm, i))
- break;
-
- mode = drm_mode_create(dev);
- if (!mode)
- break;
-
- drm_display_mode_from_videomode(&vm, mode);
-
- mode->type = DRM_MODE_TYPE_DRIVER;
-
- if (timings->native_mode == i)
- mode->type |= DRM_MODE_TYPE_PREFERRED;
-
- drm_mode_set_name(mode);
- drm_mode_probed_add(connector, mode);
- }
-
- return i;
-}
-
-static struct drm_encoder *panel_connector_best_encoder(
- struct drm_connector *connector)
-{
- struct panel_connector *panel_connector = to_panel_connector(connector);
- return panel_connector->encoder;
-}
-
-static const struct drm_connector_funcs panel_connector_funcs = {
- .destroy = panel_connector_destroy,
- .fill_modes = drm_helper_probe_single_connector_modes,
- .reset = drm_atomic_helper_connector_reset,
- .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
- .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-static const struct drm_connector_helper_funcs panel_connector_helper_funcs = {
- .get_modes = panel_connector_get_modes,
- .best_encoder = panel_connector_best_encoder,
-};
-
-static struct drm_connector *panel_connector_create(struct drm_device *dev,
- struct panel_module *mod, struct drm_encoder *encoder)
-{
- struct panel_connector *panel_connector;
- struct drm_connector *connector;
- int ret;
-
- panel_connector = devm_kzalloc(dev->dev, sizeof(*panel_connector),
- GFP_KERNEL);
- if (!panel_connector)
- return NULL;
-
- panel_connector->encoder = encoder;
- panel_connector->mod = mod;
-
- connector = &panel_connector->base;
-
- drm_connector_init(dev, connector, &panel_connector_funcs,
- DRM_MODE_CONNECTOR_LVDS);
- drm_connector_helper_add(connector, &panel_connector_helper_funcs);
-
- connector->interlace_allowed = 0;
- connector->doublescan_allowed = 0;
-
- ret = drm_connector_attach_encoder(connector, encoder);
- if (ret)
- goto fail;
-
- return connector;
-
-fail:
- panel_connector_destroy(connector);
- return NULL;
-}
-
-/*
- * Module:
- */
-
-static int panel_modeset_init(struct tilcdc_module *mod, struct drm_device *dev)
-{
- struct panel_module *panel_mod = to_panel_module(mod);
- struct tilcdc_drm_private *priv = dev->dev_private;
- struct drm_encoder *encoder;
- struct drm_connector *connector;
-
- encoder = panel_encoder_create(dev, panel_mod);
- if (!encoder)
- return -ENOMEM;
-
- connector = panel_connector_create(dev, panel_mod, encoder);
- if (!connector)
- return -ENOMEM;
-
- priv->encoders[priv->num_encoders++] = encoder;
- priv->connectors[priv->num_connectors++] = connector;
-
- tilcdc_crtc_set_panel_info(priv->crtc,
- to_panel_encoder(encoder)->mod->info);
-
- return 0;
-}
-
-static const struct tilcdc_module_ops panel_module_ops = {
- .modeset_init = panel_modeset_init,
-};
-
-/*
- * Device:
- */
-
-/* maybe move this somewhere common if it is needed by other outputs? */
-static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
-{
- struct device_node *info_np;
- struct tilcdc_panel_info *info;
- int ret = 0;
-
- if (!np) {
- pr_err("%s: no devicenode given\n", __func__);
- return NULL;
- }
-
- info_np = of_get_child_by_name(np, "panel-info");
- if (!info_np) {
- pr_err("%s: could not find panel-info node\n", __func__);
- return NULL;
- }
-
- info = kzalloc(sizeof(*info), GFP_KERNEL);
- if (!info)
- goto put_node;
-
- ret |= of_property_read_u32(info_np, "ac-bias", &info->ac_bias);
- ret |= of_property_read_u32(info_np, "ac-bias-intrpt", &info->ac_bias_intrpt);
- ret |= of_property_read_u32(info_np, "dma-burst-sz", &info->dma_burst_sz);
- ret |= of_property_read_u32(info_np, "bpp", &info->bpp);
- ret |= of_property_read_u32(info_np, "fdd", &info->fdd);
- ret |= of_property_read_u32(info_np, "sync-edge", &info->sync_edge);
- ret |= of_property_read_u32(info_np, "sync-ctrl", &info->sync_ctrl);
- ret |= of_property_read_u32(info_np, "raster-order", &info->raster_order);
- ret |= of_property_read_u32(info_np, "fifo-th", &info->fifo_th);
-
- /* optional: */
- info->tft_alt_mode = of_property_read_bool(info_np, "tft-alt-mode");
- info->invert_pxl_clk = of_property_read_bool(info_np, "invert-pxl-clk");
-
- if (ret) {
- pr_err("%s: error reading panel-info properties\n", __func__);
- kfree(info);
- info = NULL;
- }
-
-put_node:
- of_node_put(info_np);
- return info;
-}
-
-static int panel_probe(struct platform_device *pdev)
-{
- struct device_node *node = pdev->dev.of_node;
- struct backlight_device *backlight;
- struct panel_module *panel_mod;
- struct tilcdc_module *mod;
- int ret;
-
- /* bail out early if no DT data: */
- if (!node) {
- dev_err(&pdev->dev, "device-tree data is missing\n");
- return -ENXIO;
- }
-
- panel_mod = devm_kzalloc(&pdev->dev, sizeof(*panel_mod), GFP_KERNEL);
- if (!panel_mod)
- return -ENOMEM;
-
- backlight = devm_of_find_backlight(&pdev->dev);
- if (IS_ERR(backlight))
- return PTR_ERR(backlight);
- panel_mod->backlight = backlight;
-
- panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
- GPIOD_OUT_LOW);
- if (IS_ERR(panel_mod->enable_gpio)) {
- ret = PTR_ERR(panel_mod->enable_gpio);
- dev_err(&pdev->dev, "failed to request enable GPIO\n");
- goto fail_backlight;
- }
-
- if (panel_mod->enable_gpio)
- dev_info(&pdev->dev, "found enable GPIO\n");
-
- mod = &panel_mod->base;
- pdev->dev.platform_data = mod;
-
- tilcdc_module_init(mod, "panel", &panel_module_ops);
-
- panel_mod->timings = of_get_display_timings(node);
- if (!panel_mod->timings) {
- dev_err(&pdev->dev, "could not get panel timings\n");
- ret = -EINVAL;
- goto fail_free;
- }
-
- panel_mod->info = of_get_panel_info(node);
- if (!panel_mod->info) {
- dev_err(&pdev->dev, "could not get panel info\n");
- ret = -EINVAL;
- goto fail_timings;
- }
-
- return 0;
-
-fail_timings:
- display_timings_release(panel_mod->timings);
-
-fail_free:
- tilcdc_module_cleanup(mod);
-
-fail_backlight:
- if (panel_mod->backlight)
- put_device(&panel_mod->backlight->dev);
- return ret;
-}
-
-static void panel_remove(struct platform_device *pdev)
-{
- struct tilcdc_module *mod = dev_get_platdata(&pdev->dev);
- struct panel_module *panel_mod = to_panel_module(mod);
- struct backlight_device *backlight = panel_mod->backlight;
-
- if (backlight)
- put_device(&backlight->dev);
-
- display_timings_release(panel_mod->timings);
-
- tilcdc_module_cleanup(mod);
- kfree(panel_mod->info);
-}
-
-static const struct of_device_id panel_of_match[] = {
- { .compatible = "ti,tilcdc,panel", },
- { },
-};
-
-static struct platform_driver panel_driver = {
- .probe = panel_probe,
- .remove = panel_remove,
- .driver = {
- .name = "tilcdc-panel",
- .of_match_table = panel_of_match,
- },
-};
-
-int __init tilcdc_panel_init(void)
-{
- return platform_driver_register(&panel_driver);
-}
-
-void __exit tilcdc_panel_fini(void)
-{
- platform_driver_unregister(&panel_driver);
-}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.h b/drivers/gpu/drm/tilcdc/tilcdc_panel.h
deleted file mode 100644
index 65d735d773a48..0000000000000
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2012 Texas Instruments
- * Author: Rob Clark <robdclark@gmail.com>
- */
-
-#ifndef __TILCDC_PANEL_H__
-#define __TILCDC_PANEL_H__
-
-/* sub-module for generic lcd panel output */
-
-int tilcdc_panel_init(void);
-void tilcdc_panel_fini(void);
-
-#endif /* __TILCDC_PANEL_H__ */
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:24 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The tilcdc driver previously used the component framework to bind
external encoder subdrivers (specifically the TDA998x HDMI encoder).
With the removal of these subdrivers in previous commits, the component
framework is no longer needed.
This commit removes all component framework infrastructure including:
- Component master operations and bind/unbind callbacks
- The is_componentized flag and conditional code paths
- tilcdc_get_external_components() and tilcdc_add_component_encoder()
- TDA998x-specific panel configuration
The driver now uses a simplified initialization path that directly
attaches external devices via the DRM bridge API, eliminating the
complexity of dual code paths for componentized vs non-componentized
configurations.
This cleanup removes approximately 140 lines of code and makes the
driver initialization flow more straightforward.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 10 ----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 80 ++++----------------------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 1 -
drivers/gpu/drm/tilcdc/tilcdc_external.c | 65 --------------------------
drivers/gpu/drm/tilcdc/tilcdc_external.h | 3 --
5 files changed, 9 insertions(+), 150 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 2309a9a0c925d..252e5adaeb6e2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -1021,16 +1021,6 @@ int tilcdc_crtc_create(struct drm_device *dev)
drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs);
- if (priv->is_componentized) {
- crtc->port = of_graph_get_port_by_id(dev->dev->of_node, 0);
- if (!crtc->port) { /* This should never happen */
- dev_err(dev->dev, "Port node not found in %pOF\n",
- dev->dev->of_node);
- ret = -EINVAL;
- goto fail;
- }
- }
-
priv->crtc = crtc;
return 0;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index f03861ed6349d..f865c131dae66 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -6,7 +6,6 @@
/* LCDC DRM driver, based on da8xx-fb */
-#include <linux/component.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
@@ -220,9 +219,6 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
platform_set_drvdata(pdev, ddev);
drm_mode_config_init(ddev);
- priv->is_componentized =
- tilcdc_get_external_components(dev, NULL) > 0;
-
priv->wq = alloc_ordered_workqueue("tilcdc", 0);
if (!priv->wq) {
ret = -ENOMEM;
@@ -339,42 +335,32 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
}
#endif
- if (priv->is_componentized) {
- ret = component_bind_all(dev, ddev);
- if (ret < 0)
- goto unregister_cpufreq_notif;
-
- ret = tilcdc_add_component_encoder(ddev);
- if (ret < 0)
- goto unbind_component;
- } else {
- ret = tilcdc_attach_external_device(ddev);
- if (ret)
- goto unregister_cpufreq_notif;
- }
+ ret = tilcdc_attach_external_device(ddev);
+ if (ret)
+ goto unregister_cpufreq_notif;
if (!priv->external_connector &&
((priv->num_encoders == 0) || (priv->num_connectors == 0))) {
dev_err(dev, "no encoders/connectors found\n");
ret = -EPROBE_DEFER;
- goto unbind_component;
+ goto unregister_cpufreq_notif;
}
ret = drm_vblank_init(ddev, 1);
if (ret < 0) {
dev_err(dev, "failed to initialize vblank\n");
- goto unbind_component;
+ goto unregister_cpufreq_notif;
}
ret = platform_get_irq(pdev, 0);
if (ret < 0)
- goto unbind_component;
+ goto unregister_cpufreq_notif;
priv->irq = ret;
ret = tilcdc_irq_install(ddev, priv->irq);
if (ret < 0) {
dev_err(dev, "failed to install IRQ handler\n");
- goto unbind_component;
+ goto unregister_cpufreq_notif;
}
drm_mode_config_reset(ddev);
@@ -392,9 +378,6 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
stop_poll:
drm_kms_helper_poll_fini(ddev);
tilcdc_irq_uninstall(ddev);
-unbind_component:
- if (priv->is_componentized)
- component_unbind_all(dev, ddev);
unregister_cpufreq_notif:
#ifdef CONFIG_CPU_FREQ
cpufreq_unregister_notifier(&priv->freq_transition,
@@ -543,65 +526,20 @@ static int tilcdc_pm_resume(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(tilcdc_pm_ops,
tilcdc_pm_suspend, tilcdc_pm_resume);
-/*
- * Platform driver:
- */
-static int tilcdc_bind(struct device *dev)
-{
- return tilcdc_init(&tilcdc_driver, dev);
-}
-
-static void tilcdc_unbind(struct device *dev)
-{
- struct drm_device *ddev = dev_get_drvdata(dev);
-
- /* Check if a subcomponent has already triggered the unloading. */
- if (!ddev->dev_private)
- return;
-
- tilcdc_fini(ddev);
- dev_set_drvdata(dev, NULL);
-}
-
-static const struct component_master_ops tilcdc_comp_ops = {
- .bind = tilcdc_bind,
- .unbind = tilcdc_unbind,
-};
-
static int tilcdc_pdev_probe(struct platform_device *pdev)
{
- struct component_match *match = NULL;
- int ret;
-
/* bail out early if no DT data: */
if (!pdev->dev.of_node) {
dev_err(&pdev->dev, "device-tree data is missing\n");
return -ENXIO;
}
- ret = tilcdc_get_external_components(&pdev->dev, &match);
- if (ret < 0)
- return ret;
- else if (ret == 0)
- return tilcdc_init(&tilcdc_driver, &pdev->dev);
- else
- return component_master_add_with_match(&pdev->dev,
- &tilcdc_comp_ops,
- match);
+ return tilcdc_init(&tilcdc_driver, &pdev->dev);
}
static void tilcdc_pdev_remove(struct platform_device *pdev)
{
- int ret;
-
- ret = tilcdc_get_external_components(&pdev->dev, NULL);
- if (ret < 0)
- dev_err(&pdev->dev, "tilcdc_get_external_components() failed (%pe)\n",
- ERR_PTR(ret));
- else if (ret == 0)
- tilcdc_fini(platform_get_drvdata(pdev));
- else
- component_master_del(&pdev->dev, &tilcdc_comp_ops);
+ tilcdc_fini(platform_get_drvdata(pdev));
}
static void tilcdc_pdev_shutdown(struct platform_device *pdev)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 79078b4ae7393..c23b593dc61f6 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -84,7 +84,6 @@ struct tilcdc_drm_private {
struct drm_encoder *external_encoder;
struct drm_connector *external_connector;
- bool is_componentized;
bool irq_enabled;
};
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index da755a411d9ff..2970c41d9c3eb 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -4,7 +4,6 @@
* Author: Jyri Sarha <jsarha@ti.com>
*/
-#include <linux/component.h>
#include <linux/of_graph.h>
#include <drm/drm_atomic_helper.h>
@@ -15,19 +14,6 @@
#include "tilcdc_drv.h"
#include "tilcdc_external.h"
-static const struct tilcdc_panel_info panel_info_tda998x = {
- .ac_bias = 255,
- .ac_bias_intrpt = 0,
- .dma_burst_sz = 16,
- .bpp = 16,
- .fdd = 0x80,
- .tft_alt_mode = 0,
- .invert_pxl_clk = 1,
- .sync_edge = 1,
- .sync_ctrl = 1,
- .raster_order = 0,
-};
-
static const struct tilcdc_panel_info panel_info_default = {
.ac_bias = 255,
.ac_bias_intrpt = 0,
@@ -57,34 +43,6 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
return NULL;
}
-int tilcdc_add_component_encoder(struct drm_device *ddev)
-{
- struct tilcdc_drm_private *priv = ddev->dev_private;
- struct drm_encoder *encoder = NULL, *iter;
-
- list_for_each_entry(iter, &ddev->mode_config.encoder_list, head)
- if (iter->possible_crtcs & (1 << priv->crtc->index)) {
- encoder = iter;
- break;
- }
-
- if (!encoder) {
- dev_err(ddev->dev, "%s: No suitable encoder found\n", __func__);
- return -ENODEV;
- }
-
- priv->external_connector =
- tilcdc_encoder_find_connector(ddev, encoder);
-
- if (!priv->external_connector)
- return -ENODEV;
-
- /* Only tda998x is supported at the moment. */
- tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x);
-
- return 0;
-}
-
static
int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
{
@@ -153,26 +111,3 @@ int tilcdc_attach_external_device(struct drm_device *ddev)
drm_encoder_cleanup(priv->external_encoder);
return ret;
}
-
-static int dev_match_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
-int tilcdc_get_external_components(struct device *dev,
- struct component_match **match)
-{
- struct device_node *node;
-
- node = of_graph_get_remote_node(dev->of_node, 0, 0);
-
- if (!of_device_is_compatible(node, "nxp,tda998x")) {
- of_node_put(node);
- return 0;
- }
-
- if (match)
- drm_of_component_match_add(dev, match, dev_match_of, node);
- of_node_put(node);
- return 1;
-}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.h b/drivers/gpu/drm/tilcdc/tilcdc_external.h
index fb4476694cd89..285a132f3035d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.h
@@ -7,8 +7,5 @@
#ifndef __TILCDC_EXTERNAL_H__
#define __TILCDC_EXTERNAL_H__
-int tilcdc_add_component_encoder(struct drm_device *dev);
-int tilcdc_get_external_components(struct device *dev,
- struct component_match **match);
int tilcdc_attach_external_device(struct drm_device *ddev);
#endif /* __TILCDC_SLAVE_H__ */
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:25 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Remove the unnecessary #endif/#ifdef CONFIG_DEBUG_FS pair that splits
the debugfs code section. This keeps all debugfs-related code within a
single preprocessor conditional block, improving code readability.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index f865c131dae66..fd6764ce80afa 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -429,9 +429,6 @@ static const struct {
#undef REG
};
-#endif
-
-#ifdef CONFIG_DEBUG_FS
static int tilcdc_regs_show(struct seq_file *m, void *arg)
{
struct drm_info_node *node = (struct drm_info_node *) m->private;
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:27 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Remove the tilcdc_panel_info structure and its associated helper
function as the structure contains only redundant or unused parameters.
Most panel configuration parameters in tilcdc_panel_info are either:
- Already represented by existing DRM mode flags (invert_pxl_clk,
sync_edge via DRM_BUS_FLAG_*), or
- Set to identical values across all instances (panel_info_default),
making them effectively constants
The removed fifo_th field is already handled by priv->fifo_th when set.
Other removed fields (tft_alt_mode, raster_order) were always set to 0
in the only instance (panel_info_default) and thus had no effect.
This simplifies the code by eliminating unnecessary abstraction while
preserving all functional behavior.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 28 +++------------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 42 --------------------------------
drivers/gpu/drm/tilcdc/tilcdc_external.c | 14 -----------
3 files changed, 3 insertions(+), 81 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 252e5adaeb6e2..5b8aba0765f9b 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -31,7 +31,6 @@ struct tilcdc_crtc {
struct drm_crtc base;
struct drm_plane primary;
- const struct tilcdc_panel_info *info;
struct drm_pending_vblank_event *event;
struct mutex enable_lock;
bool enabled;
@@ -272,14 +271,10 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct tilcdc_drm_private *priv = dev->dev_private;
- const struct tilcdc_panel_info *info = tilcdc_crtc->info;
uint32_t reg, hbp, hfp, hsw, vbp, vfp, vsw;
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
struct drm_framebuffer *fb = crtc->primary->state->fb;
- if (WARN_ON(!info))
- return;
-
if (WARN_ON(!fb))
return;
@@ -287,12 +282,11 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
reg = tilcdc_read(dev, LCDC_DMA_CTRL_REG) & ~0x00000770;
/* Use 16 bit DMA burst size by default */
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_16);
+
if (priv->fifo_th) {
int fifo_th_val = ilog2(priv->fifo_th) - 3;
reg |= (fifo_th_val << 8);
- } else {
- reg |= (info->fifo_th << 8);
}
tilcdc_write(dev, LCDC_DMA_CTRL_REG, reg);
@@ -360,8 +354,6 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
LCDC_V2_TFT_24BPP_MODE | LCDC_V2_TFT_24BPP_UNPACK |
0x000ff000 /* Palette Loading Delay bits */);
reg |= LCDC_TFT_MODE; /* no monochrome/passive support */
- if (info->tft_alt_mode)
- reg |= LCDC_TFT_ALT_ENABLE;
if (priv->rev == 2) {
switch (fb->format->format) {
case DRM_FORMAT_BGR565:
@@ -384,15 +376,13 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
reg |= 128 << 12;
tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg);
- if (info->invert_pxl_clk ||
- mode->flags == DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
+ if (mode->flags == DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK);
else
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK);
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
- if (info->sync_edge ||
- mode->flags == DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE)
+ if (mode->flags == DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE)
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE);
else
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE);
@@ -407,11 +397,6 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
else
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_VSYNC);
- if (info->raster_order)
- tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ORDER);
- else
- tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ORDER);
-
tilcdc_crtc_set_clk(crtc);
tilcdc_crtc_load_palette(crtc);
@@ -838,13 +823,6 @@ static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
.atomic_flush = tilcdc_crtc_atomic_flush,
};
-void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
- const struct tilcdc_panel_info *info)
-{
- struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
- tilcdc_crtc->info = info;
-}
-
void tilcdc_crtc_update_clk(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index c23b593dc61f6..181b9d7a515b6 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -114,53 +114,11 @@ void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
const struct tilcdc_module_ops *funcs);
void tilcdc_module_cleanup(struct tilcdc_module *mod);
-/* Panel config that needs to be set in the crtc, but is not coming from
- * the mode timings. The display module is expected to call
- * tilcdc_crtc_set_panel_info() to set this during modeset.
- */
-struct tilcdc_panel_info {
-
- /* AC Bias Pin Frequency */
- uint32_t ac_bias;
-
- /* AC Bias Pin Transitions per Interrupt */
- uint32_t ac_bias_intrpt;
-
- /* DMA burst size */
- uint32_t dma_burst_sz;
-
- /* Bits per pixel */
- uint32_t bpp;
-
- /* FIFO DMA Request Delay */
- uint32_t fdd;
-
- /* TFT Alternative Signal Mapping (Only for active) */
- bool tft_alt_mode;
-
- /* Invert pixel clock */
- bool invert_pxl_clk;
-
- /* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
- uint32_t sync_edge;
-
- /* Horizontal and Vertical Sync: Control: 0=ignore */
- uint32_t sync_ctrl;
-
- /* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
- uint32_t raster_order;
-
- /* DMA FIFO threshold */
- uint32_t fifo_th;
-};
-
#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
int tilcdc_crtc_create(struct drm_device *dev);
irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
-void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
- const struct tilcdc_panel_info *info);
void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
void tilcdc_crtc_destroy(struct drm_crtc *crtc);
int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 2970c41d9c3eb..81c90c2754c6c 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -14,18 +14,6 @@
#include "tilcdc_drv.h"
#include "tilcdc_external.h"
-static const struct tilcdc_panel_info panel_info_default = {
- .ac_bias = 255,
- .ac_bias_intrpt = 0,
- .dma_burst_sz = 16,
- .bpp = 16,
- .fdd = 0x80,
- .tft_alt_mode = 0,
- .sync_edge = 0,
- .sync_ctrl = 1,
- .raster_order = 0,
-};
-
static
struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
struct drm_encoder *encoder)
@@ -55,8 +43,6 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
if (ret)
return ret;
- tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_default);
-
priv->external_connector =
tilcdc_encoder_find_connector(ddev, priv->external_encoder);
if (!priv->external_connector)
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:26 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The num_encoders/encoders and num_connectors/connectors arrays in
tilcdc_drm_private are never populated or used by the driver.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 6 ------
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index fd6764ce80afa..d911d413682ef 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -339,8 +339,7 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
if (ret)
goto unregister_cpufreq_notif;
- if (!priv->external_connector &&
- ((priv->num_encoders == 0) || (priv->num_connectors == 0))) {
+ if (!priv->external_connector) {
dev_err(dev, "no encoders/connectors found\n");
ret = -EPROBE_DEFER;
goto unregister_cpufreq_notif;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 181b9d7a515b6..717529a331009 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -75,12 +75,6 @@ struct tilcdc_drm_private {
struct drm_crtc *crtc;
- unsigned int num_encoders;
- struct drm_encoder *encoders[8];
-
- unsigned int num_connectors;
- struct drm_connector *connectors[8];
-
struct drm_encoder *external_encoder;
struct drm_connector *external_connector;
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:28 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Remove the "external_" prefix from encoder and connector members in the
tilcdc driver. These are internal driver structures and the "external"
naming is misleading. The simpler names better reflect that these are
the primary encoder and connector managed by this driver.
Also rename tilcdc_attach_external_device() to tilcdc_encoder_create()
for consistency and to better describe the function's purpose.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 4 ++--
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 4 ++--
drivers/gpu/drm/tilcdc/tilcdc_external.c | 21 +++++++++------------
drivers/gpu/drm/tilcdc/tilcdc_external.h | 2 +-
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index d911d413682ef..4b9fa819358a2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -335,11 +335,11 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
}
#endif
- ret = tilcdc_attach_external_device(ddev);
+ ret = tilcdc_encoder_create(ddev);
if (ret)
goto unregister_cpufreq_notif;
- if (!priv->external_connector) {
+ if (!priv->connector) {
dev_err(dev, "no encoders/connectors found\n");
ret = -EPROBE_DEFER;
goto unregister_cpufreq_notif;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 717529a331009..dafb00908d1d4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -75,8 +75,8 @@ struct tilcdc_drm_private {
struct drm_crtc *crtc;
- struct drm_encoder *external_encoder;
- struct drm_connector *external_connector;
+ struct drm_encoder *encoder;
+ struct drm_connector *connector;
bool irq_enabled;
};
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 81c90c2754c6c..11ac9673ba98a 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -37,21 +37,20 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
struct tilcdc_drm_private *priv = ddev->dev_private;
int ret;
- priv->external_encoder->possible_crtcs = BIT(0);
+ priv->encoder->possible_crtcs = BIT(0);
- ret = drm_bridge_attach(priv->external_encoder, bridge, NULL, 0);
+ ret = drm_bridge_attach(priv->encoder, bridge, NULL, 0);
if (ret)
return ret;
- priv->external_connector =
- tilcdc_encoder_find_connector(ddev, priv->external_encoder);
- if (!priv->external_connector)
+ priv->connector = tilcdc_encoder_find_connector(ddev, priv->encoder);
+ if (!priv->connector)
return -ENODEV;
return 0;
}
-int tilcdc_attach_external_device(struct drm_device *ddev)
+int tilcdc_encoder_create(struct drm_device *ddev)
{
struct tilcdc_drm_private *priv = ddev->dev_private;
struct drm_bridge *bridge;
@@ -65,13 +64,11 @@ int tilcdc_attach_external_device(struct drm_device *ddev)
else if (ret)
return ret;
- priv->external_encoder = devm_kzalloc(ddev->dev,
- sizeof(*priv->external_encoder),
- GFP_KERNEL);
- if (!priv->external_encoder)
+ priv->encoder = devm_kzalloc(ddev->dev, sizeof(*priv->encoder), GFP_KERNEL);
+ if (!priv->encoder)
return -ENOMEM;
- ret = drm_simple_encoder_init(ddev, priv->external_encoder,
+ ret = drm_simple_encoder_init(ddev, priv->encoder,
DRM_MODE_ENCODER_NONE);
if (ret) {
dev_err(ddev->dev, "drm_encoder_init() failed %d\n", ret);
@@ -94,6 +91,6 @@ int tilcdc_attach_external_device(struct drm_device *ddev)
return 0;
err_encoder_cleanup:
- drm_encoder_cleanup(priv->external_encoder);
+ drm_encoder_cleanup(priv->encoder);
return ret;
}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.h b/drivers/gpu/drm/tilcdc/tilcdc_external.h
index 285a132f3035d..c8f87f59024e6 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.h
@@ -7,5 +7,5 @@
#ifndef __TILCDC_EXTERNAL_H__
#define __TILCDC_EXTERNAL_H__
-int tilcdc_attach_external_device(struct drm_device *ddev);
+int tilcdc_encoder_create(struct drm_device *ddev);
#endif /* __TILCDC_SLAVE_H__ */
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:29 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The tilcdc_external module describes the encoder part of the tilcdc
driver. Rename it to tilcdc_encoder for better clarity and to make
the naming more consistent with DRM subsystem conventions, where
encoder-related files typically use "encoder" in their names.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/Makefile | 2 +-
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +-
drivers/gpu/drm/tilcdc/{tilcdc_external.c => tilcdc_encoder.c} | 2 +-
drivers/gpu/drm/tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 0
4 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/Makefile b/drivers/gpu/drm/tilcdc/Makefile
index b78204a65ce29..c6b484dad711a 100644
--- a/drivers/gpu/drm/tilcdc/Makefile
+++ b/drivers/gpu/drm/tilcdc/Makefile
@@ -6,7 +6,7 @@ endif
tilcdc-y := \
tilcdc_plane.o \
tilcdc_crtc.o \
- tilcdc_external.o \
+ tilcdc_encoder.o \
tilcdc_drv.o
obj-$(CONFIG_DRM_TILCDC) += tilcdc.o
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 4b9fa819358a2..d0503778b5f6f 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -26,7 +26,7 @@
#include "tilcdc_drv.h"
-#include "tilcdc_external.h"
+#include "tilcdc_encoder.h"
#include "tilcdc_regs.h"
enum tilcdc_variant {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
similarity index 98%
rename from drivers/gpu/drm/tilcdc/tilcdc_external.c
rename to drivers/gpu/drm/tilcdc/tilcdc_encoder.c
index 11ac9673ba98a..b1c7b2257df30 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
@@ -12,7 +12,7 @@
#include <drm/drm_simple_kms_helper.h>
#include "tilcdc_drv.h"
-#include "tilcdc_external.h"
+#include "tilcdc_encoder.h"
static
struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.h b/drivers/gpu/drm/tilcdc/tilcdc_encoder.h
similarity index 100%
rename from drivers/gpu/drm/tilcdc/tilcdc_external.h
rename to drivers/gpu/drm/tilcdc/tilcdc_encoder.h
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:30 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The tilcdc driver previously supported a sub-module system where
external display drivers (panels, encoders) could register themselves
through tilcdc_module_init() and be automatically initialized through
a module list. This infrastructure became unused after the component
framework support and panel driver was removed.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Move the removal of module_init/exit in a following patch.
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 29 -----------------------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 27 ---------------------------
2 files changed, 56 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index d0503778b5f6f..20f93240b335c 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -7,7 +7,6 @@
/* LCDC DRM driver, based on da8xx-fb */
#include <linux/mod_devicetable.h>
-#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -34,8 +33,6 @@ enum tilcdc_variant {
DA850_TILCDC,
};
-static LIST_HEAD(module_list);
-
static const u32 tilcdc_rev1_formats[] = { DRM_FORMAT_RGB565 };
static const u32 tilcdc_straight_formats[] = { DRM_FORMAT_RGB565,
@@ -50,20 +47,6 @@ static const u32 tilcdc_legacy_formats[] = { DRM_FORMAT_RGB565,
DRM_FORMAT_RGB888,
DRM_FORMAT_XRGB8888 };
-void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
- const struct tilcdc_module_ops *funcs)
-{
- mod->name = name;
- mod->funcs = funcs;
- INIT_LIST_HEAD(&mod->list);
- list_add(&mod->list, &module_list);
-}
-
-void tilcdc_module_cleanup(struct tilcdc_module *mod)
-{
- list_del(&mod->list);
-}
-
static int tilcdc_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state)
{
@@ -97,12 +80,6 @@ static const struct drm_mode_config_funcs mode_config_funcs = {
static void modeset_init(struct drm_device *dev)
{
struct tilcdc_drm_private *priv = dev->dev_private;
- struct tilcdc_module *mod;
-
- list_for_each_entry(mod, &module_list, list) {
- DBG("loading module: %s", mod->name);
- mod->funcs->modeset_init(mod, dev);
- }
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
@@ -465,15 +442,9 @@ static struct drm_info_list tilcdc_debugfs_list[] = {
static void tilcdc_debugfs_init(struct drm_minor *minor)
{
- struct tilcdc_module *mod;
-
drm_debugfs_create_files(tilcdc_debugfs_list,
ARRAY_SIZE(tilcdc_debugfs_list),
minor->debugfs_root, minor);
-
- list_for_each_entry(mod, &module_list, list)
- if (mod->funcs->debugfs_init)
- mod->funcs->debugfs_init(mod, minor);
}
#endif
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index dafb00908d1d4..60e85e29b1063 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -81,33 +81,6 @@ struct tilcdc_drm_private {
bool irq_enabled;
};
-/* Sub-module for display. Since we don't know at compile time what panels
- * or display adapter(s) might be present (for ex, off chip dvi/tfp410,
- * hdmi encoder, various lcd panels), the connector/encoder(s) are split into
- * separate drivers. If they are probed and found to be present, they
- * register themselves with tilcdc_register_module().
- */
-struct tilcdc_module;
-
-struct tilcdc_module_ops {
- /* create appropriate encoders/connectors: */
- int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
-#ifdef CONFIG_DEBUG_FS
- /* create debugfs nodes (can be NULL): */
- int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
-#endif
-};
-
-struct tilcdc_module {
- const char *name;
- struct list_head list;
- const struct tilcdc_module_ops *funcs;
-};
-
-void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
- const struct tilcdc_module_ops *funcs);
-void tilcdc_module_cleanup(struct tilcdc_module *mod);
-
#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
int tilcdc_crtc_create(struct drm_device *dev);
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:31 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Use the drm_module_platform_driver() helper macro to simplify driver
registration. This macro handles both the platform driver registration
and the drm_firmware_drivers_only() check, making the custom init/exit
functions unnecessary.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- New patch split from previous patch of the series.
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 20f93240b335c..97380b623fca3 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -20,6 +20,7 @@
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_mm.h>
+#include <drm/drm_module.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h>
@@ -532,23 +533,7 @@ static struct platform_driver tilcdc_platform_driver = {
},
};
-static int __init tilcdc_drm_init(void)
-{
- if (drm_firmware_drivers_only())
- return -ENODEV;
-
- DBG("init");
- return platform_driver_register(&tilcdc_platform_driver);
-}
-
-static void __exit tilcdc_drm_fini(void)
-{
- DBG("fini");
- platform_driver_unregister(&tilcdc_platform_driver);
-}
-
-module_init(tilcdc_drm_init);
-module_exit(tilcdc_drm_fini);
+drm_module_platform_driver(tilcdc_platform_driver);
MODULE_AUTHOR("Rob Clark <robdclark@gmail.com");
MODULE_DESCRIPTION("TI LCD Controller DRM Driver");
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:32 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Move tilcdc_init/fini functions adjacent to the probe and remove functions
in preparation for cleanup and modernization. This improves readability
for subsequent commits that will refactor these functions.
No functional changes, only code reorganization.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- New patch.
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 238 ++++++++++++++++++------------------
1 file changed, 119 insertions(+), 119 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 97380b623fca3..abe432b752dc0 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -140,6 +140,125 @@ static void tilcdc_irq_uninstall(struct drm_device *dev)
* DRM operations:
*/
+#if defined(CONFIG_DEBUG_FS)
+static const struct {
+ const char *name;
+ uint8_t rev;
+ uint8_t save;
+ uint32_t reg;
+} registers[] = {
+#define REG(rev, save, reg) { #reg, rev, save, reg }
+ /* exists in revision 1: */
+ REG(1, false, LCDC_PID_REG),
+ REG(1, true, LCDC_CTRL_REG),
+ REG(1, false, LCDC_STAT_REG),
+ REG(1, true, LCDC_RASTER_CTRL_REG),
+ REG(1, true, LCDC_RASTER_TIMING_0_REG),
+ REG(1, true, LCDC_RASTER_TIMING_1_REG),
+ REG(1, true, LCDC_RASTER_TIMING_2_REG),
+ REG(1, true, LCDC_DMA_CTRL_REG),
+ REG(1, true, LCDC_DMA_FB_BASE_ADDR_0_REG),
+ REG(1, true, LCDC_DMA_FB_CEILING_ADDR_0_REG),
+ REG(1, true, LCDC_DMA_FB_BASE_ADDR_1_REG),
+ REG(1, true, LCDC_DMA_FB_CEILING_ADDR_1_REG),
+ /* new in revision 2: */
+ REG(2, false, LCDC_RAW_STAT_REG),
+ REG(2, false, LCDC_MASKED_STAT_REG),
+ REG(2, true, LCDC_INT_ENABLE_SET_REG),
+ REG(2, false, LCDC_INT_ENABLE_CLR_REG),
+ REG(2, false, LCDC_END_OF_INT_IND_REG),
+ REG(2, true, LCDC_CLK_ENABLE_REG),
+#undef REG
+};
+
+static int tilcdc_regs_show(struct seq_file *m, void *arg)
+{
+ struct drm_info_node *node = (struct drm_info_node *) m->private;
+ struct drm_device *dev = node->minor->dev;
+ struct tilcdc_drm_private *priv = dev->dev_private;
+ unsigned i;
+
+ pm_runtime_get_sync(dev->dev);
+
+ seq_printf(m, "revision: %d\n", priv->rev);
+
+ for (i = 0; i < ARRAY_SIZE(registers); i++)
+ if (priv->rev >= registers[i].rev)
+ seq_printf(m, "%s:\t %08x\n", registers[i].name,
+ tilcdc_read(dev, registers[i].reg));
+
+ pm_runtime_put_sync(dev->dev);
+
+ return 0;
+}
+
+static int tilcdc_mm_show(struct seq_file *m, void *arg)
+{
+ struct drm_info_node *node = (struct drm_info_node *) m->private;
+ struct drm_device *dev = node->minor->dev;
+ struct drm_printer p = drm_seq_file_printer(m);
+ drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
+ return 0;
+}
+
+static struct drm_info_list tilcdc_debugfs_list[] = {
+ { "regs", tilcdc_regs_show, 0, NULL },
+ { "mm", tilcdc_mm_show, 0, NULL },
+};
+
+static void tilcdc_debugfs_init(struct drm_minor *minor)
+{
+ drm_debugfs_create_files(tilcdc_debugfs_list,
+ ARRAY_SIZE(tilcdc_debugfs_list),
+ minor->debugfs_root, minor);
+}
+#endif
+
+DEFINE_DRM_GEM_DMA_FOPS(fops);
+
+static const struct drm_driver tilcdc_driver = {
+ .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
+ DRM_GEM_DMA_DRIVER_OPS,
+ DRM_FBDEV_DMA_DRIVER_OPS,
+#ifdef CONFIG_DEBUG_FS
+ .debugfs_init = tilcdc_debugfs_init,
+#endif
+ .fops = &fops,
+ .name = "tilcdc",
+ .desc = "TI LCD Controller DRM",
+ .major = 1,
+ .minor = 0,
+};
+
+/*
+ * Power management:
+ */
+
+static int tilcdc_pm_suspend(struct device *dev)
+{
+ struct drm_device *ddev = dev_get_drvdata(dev);
+ int ret = 0;
+
+ ret = drm_mode_config_helper_suspend(ddev);
+
+ /* Select sleep pin state */
+ pinctrl_pm_select_sleep_state(dev);
+
+ return ret;
+}
+
+static int tilcdc_pm_resume(struct device *dev)
+{
+ struct drm_device *ddev = dev_get_drvdata(dev);
+
+ /* Select default pin state */
+ pinctrl_pm_select_default_state(dev);
+ return drm_mode_config_helper_resume(ddev);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(tilcdc_pm_ops,
+ tilcdc_pm_suspend, tilcdc_pm_resume);
+
static void tilcdc_fini(struct drm_device *dev)
{
struct tilcdc_drm_private *priv = dev->dev_private;
@@ -375,125 +494,6 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
return ret;
}
-#if defined(CONFIG_DEBUG_FS)
-static const struct {
- const char *name;
- uint8_t rev;
- uint8_t save;
- uint32_t reg;
-} registers[] = {
-#define REG(rev, save, reg) { #reg, rev, save, reg }
- /* exists in revision 1: */
- REG(1, false, LCDC_PID_REG),
- REG(1, true, LCDC_CTRL_REG),
- REG(1, false, LCDC_STAT_REG),
- REG(1, true, LCDC_RASTER_CTRL_REG),
- REG(1, true, LCDC_RASTER_TIMING_0_REG),
- REG(1, true, LCDC_RASTER_TIMING_1_REG),
- REG(1, true, LCDC_RASTER_TIMING_2_REG),
- REG(1, true, LCDC_DMA_CTRL_REG),
- REG(1, true, LCDC_DMA_FB_BASE_ADDR_0_REG),
- REG(1, true, LCDC_DMA_FB_CEILING_ADDR_0_REG),
- REG(1, true, LCDC_DMA_FB_BASE_ADDR_1_REG),
- REG(1, true, LCDC_DMA_FB_CEILING_ADDR_1_REG),
- /* new in revision 2: */
- REG(2, false, LCDC_RAW_STAT_REG),
- REG(2, false, LCDC_MASKED_STAT_REG),
- REG(2, true, LCDC_INT_ENABLE_SET_REG),
- REG(2, false, LCDC_INT_ENABLE_CLR_REG),
- REG(2, false, LCDC_END_OF_INT_IND_REG),
- REG(2, true, LCDC_CLK_ENABLE_REG),
-#undef REG
-};
-
-static int tilcdc_regs_show(struct seq_file *m, void *arg)
-{
- struct drm_info_node *node = (struct drm_info_node *) m->private;
- struct drm_device *dev = node->minor->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
- unsigned i;
-
- pm_runtime_get_sync(dev->dev);
-
- seq_printf(m, "revision: %d\n", priv->rev);
-
- for (i = 0; i < ARRAY_SIZE(registers); i++)
- if (priv->rev >= registers[i].rev)
- seq_printf(m, "%s:\t %08x\n", registers[i].name,
- tilcdc_read(dev, registers[i].reg));
-
- pm_runtime_put_sync(dev->dev);
-
- return 0;
-}
-
-static int tilcdc_mm_show(struct seq_file *m, void *arg)
-{
- struct drm_info_node *node = (struct drm_info_node *) m->private;
- struct drm_device *dev = node->minor->dev;
- struct drm_printer p = drm_seq_file_printer(m);
- drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
- return 0;
-}
-
-static struct drm_info_list tilcdc_debugfs_list[] = {
- { "regs", tilcdc_regs_show, 0, NULL },
- { "mm", tilcdc_mm_show, 0, NULL },
-};
-
-static void tilcdc_debugfs_init(struct drm_minor *minor)
-{
- drm_debugfs_create_files(tilcdc_debugfs_list,
- ARRAY_SIZE(tilcdc_debugfs_list),
- minor->debugfs_root, minor);
-}
-#endif
-
-DEFINE_DRM_GEM_DMA_FOPS(fops);
-
-static const struct drm_driver tilcdc_driver = {
- .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
- DRM_GEM_DMA_DRIVER_OPS,
- DRM_FBDEV_DMA_DRIVER_OPS,
-#ifdef CONFIG_DEBUG_FS
- .debugfs_init = tilcdc_debugfs_init,
-#endif
- .fops = &fops,
- .name = "tilcdc",
- .desc = "TI LCD Controller DRM",
- .major = 1,
- .minor = 0,
-};
-
-/*
- * Power management:
- */
-
-static int tilcdc_pm_suspend(struct device *dev)
-{
- struct drm_device *ddev = dev_get_drvdata(dev);
- int ret = 0;
-
- ret = drm_mode_config_helper_suspend(ddev);
-
- /* Select sleep pin state */
- pinctrl_pm_select_sleep_state(dev);
-
- return ret;
-}
-
-static int tilcdc_pm_resume(struct device *dev)
-{
- struct drm_device *ddev = dev_get_drvdata(dev);
-
- /* Select default pin state */
- pinctrl_pm_select_default_state(dev);
- return drm_mode_config_helper_resume(ddev);
-}
-
-static DEFINE_SIMPLE_DEV_PM_OPS(tilcdc_pm_ops,
- tilcdc_pm_suspend, tilcdc_pm_resume);
-
static int tilcdc_pdev_probe(struct platform_device *pdev)
{
/* bail out early if no DT data: */
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:33 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Refactor the driver initialization to use modern DRM managed resource
APIs, simplifying the code.
The tilcdc_init and tilcdc_fini wrapper functions are removed since they
served no purpose after the component framework was eliminated. Their
logic is integrated directly into probe and remove.
Key changes:
- Use devm_drm_dev_alloc() instead of drm_dev_alloc().
- Use drmm_mode_config_init() instead of drm_mode_config_init().
- Align the remove path with the probe error path to ensure consistent
cleanup ordering in both success and failure cases.
- Adjust platform_set_drvdata() to store the private structure instead
of the drm_device, matching the new allocation pattern.
These changes reduce error-prone code while maintaining the same
functional behavior.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Split the patch between code move and cleanup for better diff
readibility.
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 100 ++++++++++++------------------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 2 +
2 files changed, 35 insertions(+), 67 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index abe432b752dc0..2f35075b663ff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -259,68 +259,33 @@ static int tilcdc_pm_resume(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(tilcdc_pm_ops,
tilcdc_pm_suspend, tilcdc_pm_resume);
-static void tilcdc_fini(struct drm_device *dev)
-{
- struct tilcdc_drm_private *priv = dev->dev_private;
-
-#ifdef CONFIG_CPU_FREQ
- if (priv->freq_transition.notifier_call)
- cpufreq_unregister_notifier(&priv->freq_transition,
- CPUFREQ_TRANSITION_NOTIFIER);
-#endif
-
- if (priv->crtc)
- tilcdc_crtc_shutdown(priv->crtc);
-
- drm_dev_unregister(dev);
-
- drm_kms_helper_poll_fini(dev);
- drm_atomic_helper_shutdown(dev);
- tilcdc_irq_uninstall(dev);
- drm_mode_config_cleanup(dev);
-
- if (priv->clk)
- clk_put(priv->clk);
-
- if (priv->wq)
- destroy_workqueue(priv->wq);
-
- dev->dev_private = NULL;
-
- pm_runtime_disable(dev->dev);
-
- drm_dev_put(dev);
-}
-
-static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
+static int tilcdc_pdev_probe(struct platform_device *pdev)
{
- struct drm_device *ddev;
- struct platform_device *pdev = to_platform_device(dev);
- struct device_node *node = dev->of_node;
+ struct device_node *node = pdev->dev.of_node;
struct tilcdc_drm_private *priv;
+ struct device *dev = &pdev->dev;
enum tilcdc_variant variant;
+ struct drm_device *ddev;
u32 bpp = 0;
int ret;
- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
- ddev = drm_dev_alloc(ddrv, dev);
- if (IS_ERR(ddev))
- return PTR_ERR(ddev);
+ priv = devm_drm_dev_alloc(dev, &tilcdc_driver,
+ struct tilcdc_drm_private, ddev);
+ if (IS_ERR(priv))
+ return PTR_ERR(priv);
variant = (uintptr_t)of_device_get_match_data(dev);
ddev->dev_private = priv;
- platform_set_drvdata(pdev, ddev);
- drm_mode_config_init(ddev);
+ platform_set_drvdata(pdev, priv);
+ ddev = &priv->ddev;
+ ret = drmm_mode_config_init(ddev);
+ if (ret)
+ return ret;
priv->wq = alloc_ordered_workqueue("tilcdc", 0);
- if (!priv->wq) {
- ret = -ENOMEM;
- goto put_drm;
- }
+ if (!priv->wq)
+ return -ENOMEM;
priv->mmio = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->mmio)) {
@@ -486,33 +451,34 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
clk_put(priv->clk);
free_wq:
destroy_workqueue(priv->wq);
-put_drm:
- platform_set_drvdata(pdev, NULL);
- ddev->dev_private = NULL;
- drm_dev_put(ddev);
return ret;
}
-static int tilcdc_pdev_probe(struct platform_device *pdev)
-{
- /* bail out early if no DT data: */
- if (!pdev->dev.of_node) {
- dev_err(&pdev->dev, "device-tree data is missing\n");
- return -ENXIO;
- }
-
- return tilcdc_init(&tilcdc_driver, &pdev->dev);
-}
-
static void tilcdc_pdev_remove(struct platform_device *pdev)
{
- tilcdc_fini(platform_get_drvdata(pdev));
+ struct tilcdc_drm_private *priv = platform_get_drvdata(pdev);
+ struct drm_device *ddev = &priv->ddev;
+
+ drm_dev_unregister(ddev);
+ drm_kms_helper_poll_fini(ddev);
+ tilcdc_irq_uninstall(ddev);
+#ifdef CONFIG_CPU_FREQ
+ cpufreq_unregister_notifier(&priv->freq_transition,
+ CPUFREQ_TRANSITION_NOTIFIER);
+#endif
+ tilcdc_crtc_destroy(priv->crtc);
+ pm_runtime_disable(&pdev->dev);
+ clk_put(priv->clk);
+ destroy_workqueue(priv->wq);
}
static void tilcdc_pdev_shutdown(struct platform_device *pdev)
{
- drm_atomic_helper_shutdown(platform_get_drvdata(pdev));
+ struct tilcdc_drm_private *priv = platform_get_drvdata(pdev);
+ struct drm_device *ddev = &priv->ddev;
+
+ drm_atomic_helper_shutdown(ddev);
}
static const struct of_device_id tilcdc_of_match[] = {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 60e85e29b1063..e3d04a3eb25b4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -48,6 +48,8 @@ struct tilcdc_drm_private {
unsigned int irq;
+ struct drm_device ddev;
+
/* don't attempt resolutions w/ higher W * H * Hz: */
uint32_t max_bandwidth;
/*
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:34 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The DRM core documentation recommends against using dev_private:
"Instead of using this pointer it is recommended that drivers use
embed the struct &drm_device in their larger per-device structure."
This patch refactors the tilcdc driver to follow this recommendation
by embedding struct drm_device within struct tilcdc_drm_private and
replacing all dev->dev_private accesses with the ddev_to_tilcdc_priv()
helper macro that uses container_of().
This change aligns the driver with modern DRM best practices.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 28 ++++++++++++++--------------
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 11 +++++------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 2 ++
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 4 ++--
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 2 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 ++++----
6 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 5b8aba0765f9b..0bd99a2efeeb4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -59,7 +59,7 @@ struct tilcdc_crtc {
static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
{
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
struct drm_gem_dma_object *gem;
dma_addr_t start, end;
u64 dma_base_and_ceiling;
@@ -94,7 +94,7 @@ static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
{
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
int ret;
reinit_completion(&tilcdc_crtc->palette_loaded);
@@ -136,7 +136,7 @@ static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
static void tilcdc_crtc_enable_irqs(struct drm_device *dev)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
tilcdc_clear_irqstatus(dev, 0xffffffff);
@@ -153,7 +153,7 @@ static void tilcdc_crtc_enable_irqs(struct drm_device *dev)
static void tilcdc_crtc_disable_irqs(struct drm_device *dev)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
/* disable irqs that we might have enabled: */
if (priv->rev == 1) {
@@ -173,7 +173,7 @@ static void tilcdc_crtc_disable_irqs(struct drm_device *dev)
static void reset(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
if (priv->rev != 2)
return;
@@ -198,7 +198,7 @@ static unsigned int tilcdc_pclk_diff(unsigned long rate,
static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
unsigned long clk_rate, real_pclk_rate, pclk_rate;
unsigned int clkdiv;
@@ -270,7 +270,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
{
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
uint32_t reg, hbp, hfp, hsw, vbp, vfp, vsw;
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
struct drm_framebuffer *fb = crtc->primary->state->fb;
@@ -557,7 +557,7 @@ static void tilcdc_crtc_recover_work(struct work_struct *work)
void tilcdc_crtc_destroy(struct drm_crtc *crtc)
{
- struct tilcdc_drm_private *priv = crtc->dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(crtc->dev);
tilcdc_crtc_shutdown(crtc);
@@ -647,7 +647,7 @@ static int tilcdc_crtc_enable_vblank(struct drm_crtc *crtc)
{
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
unsigned long flags;
spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
@@ -670,7 +670,7 @@ static void tilcdc_crtc_disable_vblank(struct drm_crtc *crtc)
{
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
unsigned long flags;
spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
@@ -728,7 +728,7 @@ static enum drm_mode_status
tilcdc_crtc_mode_valid(struct drm_crtc *crtc,
const struct drm_display_mode *mode)
{
- struct tilcdc_drm_private *priv = crtc->dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(crtc->dev);
unsigned int bandwidth;
uint32_t hbp, hfp, hsw, vbp, vfp, vsw;
@@ -826,7 +826,7 @@ static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
void tilcdc_crtc_update_clk(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
drm_modeset_lock(&crtc->mutex, NULL);
@@ -850,7 +850,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
{
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
uint32_t stat, reg;
stat = tilcdc_read_irqstatus(dev);
@@ -958,7 +958,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
int tilcdc_crtc_create(struct drm_device *dev)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
struct tilcdc_crtc *tilcdc_crtc;
struct drm_crtc *crtc;
int ret;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 2f35075b663ff..1a238a22309f4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -80,7 +80,7 @@ static const struct drm_mode_config_funcs mode_config_funcs = {
static void modeset_init(struct drm_device *dev)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
@@ -106,14 +106,14 @@ static int cpufreq_transition(struct notifier_block *nb,
static irqreturn_t tilcdc_irq(int irq, void *arg)
{
struct drm_device *dev = arg;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
return tilcdc_crtc_irq(priv->crtc);
}
static int tilcdc_irq_install(struct drm_device *dev, unsigned int irq)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
int ret;
ret = request_irq(irq, tilcdc_irq, 0, dev->driver->name, dev);
@@ -127,7 +127,7 @@ static int tilcdc_irq_install(struct drm_device *dev, unsigned int irq)
static void tilcdc_irq_uninstall(struct drm_device *dev)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
if (!priv->irq_enabled)
return;
@@ -175,7 +175,7 @@ static int tilcdc_regs_show(struct seq_file *m, void *arg)
{
struct drm_info_node *node = (struct drm_info_node *) m->private;
struct drm_device *dev = node->minor->dev;
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
unsigned i;
pm_runtime_get_sync(dev->dev);
@@ -276,7 +276,6 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
variant = (uintptr_t)of_device_get_match_data(dev);
- ddev->dev_private = priv;
platform_set_drvdata(pdev, priv);
ddev = &priv->ddev;
ret = drmm_mode_config_init(ddev);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index e3d04a3eb25b4..c69e279a2539d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -85,6 +85,8 @@ struct tilcdc_drm_private {
#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+#define ddev_to_tilcdc_priv(x) container_of(x, struct tilcdc_drm_private, ddev)
+
int tilcdc_crtc_create(struct drm_device *dev);
irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
index b1c7b2257df30..d42be3e16c536 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
@@ -34,7 +34,7 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
static
int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
{
- struct tilcdc_drm_private *priv = ddev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
int ret;
priv->encoder->possible_crtcs = BIT(0);
@@ -52,7 +52,7 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
int tilcdc_encoder_create(struct drm_device *ddev)
{
- struct tilcdc_drm_private *priv = ddev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
struct drm_bridge *bridge;
struct drm_panel *panel;
int ret;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index aa72ca679598b..a77a5b22ebd96 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -101,7 +101,7 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = {
int tilcdc_plane_init(struct drm_device *dev,
struct drm_plane *plane)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
int ret;
ret = drm_universal_plane_init(dev, plane, 1, &tilcdc_plane_funcs,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_regs.h b/drivers/gpu/drm/tilcdc/tilcdc_regs.h
index f90e2dc3457cd..26ebaf1e0f70f 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_regs.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_regs.h
@@ -113,13 +113,13 @@
static inline void tilcdc_write(struct drm_device *dev, u32 reg, u32 data)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
iowrite32(data, priv->mmio + reg);
}
static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
volatile void __iomem *addr = priv->mmio + reg;
#if defined(iowrite64) && !defined(iowrite64_is_nonatomic)
@@ -133,7 +133,7 @@ static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data)
static inline u32 tilcdc_read(struct drm_device *dev, u32 reg)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
return ioread32(priv->mmio + reg);
}
@@ -156,7 +156,7 @@ static inline void tilcdc_clear(struct drm_device *dev, u32 reg, u32 mask)
/* the register to read/clear irqstatus differs between v1 and v2 of the IP */
static inline u32 tilcdc_irqstatus_reg(struct drm_device *dev)
{
- struct tilcdc_drm_private *priv = dev->dev_private;
+ struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
return (priv->rev == 2) ? LCDC_MASKED_STAT_REG : LCDC_STAT_REG;
}
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:35 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Convert the tilcdc driver to use DRM managed resources (drmm_* APIs)
to eliminate resource lifetime issues, particularly in probe deferral
scenarios.
This conversion addresses potential use-after-free bugs by ensuring
proper cleanup ordering through the DRM managed resource framework.
The changes include:
- Replace drm_crtc_init_with_planes() with drmm_crtc_alloc_with_planes()
- Replace drm_universal_plane_init() with drmm_universal_plane_alloc()
- Replace drm_simple_encoder_init() with drmm_simple_encoder_alloc()
- Remove manual cleanup in tilcdc_crtc_destroy() and error paths
- Remove drm_encoder_cleanup() from encoder error handling paths
- Use drmm_add_action_or_reset() for remaining cleanup operations
This approach is recommended by the DRM subsystem for improved resource
lifetime management and is particularly important for drivers that may
experience probe deferral.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v5:
- Move drmm_add_action_or_reset() up to avoid missing cleanup in case
of dmam_alloc_coherent() returning an error.
Change in v4:
- New patch.
- Move on to DRM managed resources to fix null pointer dereference koops
in case drm_of_find_panel_or_bridge() return EPROBE_DEFER.
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 55 +++++++++++++++++----------------
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 5 +--
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 13 ++++++--
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 38 ++++++++---------------
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 27 +++++++---------
5 files changed, 64 insertions(+), 74 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 0bd99a2efeeb4..2916de3dce91e 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -16,6 +16,7 @@
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_dma_helper.h>
+#include <drm/drm_managed.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_print.h>
#include <drm/drm_vblank.h>
@@ -30,7 +31,7 @@
struct tilcdc_crtc {
struct drm_crtc base;
- struct drm_plane primary;
+ struct tilcdc_plane *primary;
struct drm_pending_vblank_event *event;
struct mutex enable_lock;
bool enabled;
@@ -555,16 +556,15 @@ static void tilcdc_crtc_recover_work(struct work_struct *work)
drm_modeset_unlock(&crtc->mutex);
}
-void tilcdc_crtc_destroy(struct drm_crtc *crtc)
+static void tilcdc_crtc_destroy(struct drm_device *dev, void *data)
{
- struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(crtc->dev);
+ struct tilcdc_drm_private *priv = (struct tilcdc_drm_private *)data;
- tilcdc_crtc_shutdown(crtc);
+ tilcdc_crtc_shutdown(priv->crtc);
flush_workqueue(priv->wq);
- of_node_put(crtc->port);
- drm_crtc_cleanup(crtc);
+ of_node_put(priv->crtc->port);
}
int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
@@ -714,7 +714,6 @@ static void tilcdc_crtc_reset(struct drm_crtc *crtc)
}
static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
- .destroy = tilcdc_crtc_destroy,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
.reset = tilcdc_crtc_reset,
@@ -960,12 +959,31 @@ int tilcdc_crtc_create(struct drm_device *dev)
{
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
struct tilcdc_crtc *tilcdc_crtc;
+ struct tilcdc_plane *primary;
struct drm_crtc *crtc;
int ret;
- tilcdc_crtc = devm_kzalloc(dev->dev, sizeof(*tilcdc_crtc), GFP_KERNEL);
- if (!tilcdc_crtc)
- return -ENOMEM;
+ primary = tilcdc_plane_init(dev);
+ if (IS_ERR(primary)) {
+ dev_err(dev->dev, "Failed to initialize plane: %pe\n", primary);
+ return PTR_ERR(primary);
+ }
+
+ tilcdc_crtc = drmm_crtc_alloc_with_planes(dev, struct tilcdc_crtc, base,
+ &primary->base,
+ NULL,
+ &tilcdc_crtc_funcs,
+ "tilcdc crtc");
+ if (IS_ERR(tilcdc_crtc)) {
+ dev_err(dev->dev, "Failed to init CRTC: %pe\n", tilcdc_crtc);
+ return PTR_ERR(tilcdc_crtc);
+ }
+
+ tilcdc_crtc->primary = primary;
+ priv->crtc = &tilcdc_crtc->base;
+ ret = drmm_add_action_or_reset(dev, tilcdc_crtc_destroy, priv);
+ if (ret)
+ return ret;
init_completion(&tilcdc_crtc->palette_loaded);
tilcdc_crtc->palette_base = dmam_alloc_coherent(dev->dev,
@@ -978,10 +996,6 @@ int tilcdc_crtc_create(struct drm_device *dev)
crtc = &tilcdc_crtc->base;
- ret = tilcdc_plane_init(dev, &tilcdc_crtc->primary);
- if (ret < 0)
- goto fail;
-
mutex_init(&tilcdc_crtc->enable_lock);
init_waitqueue_head(&tilcdc_crtc->frame_done_wq);
@@ -989,20 +1003,7 @@ int tilcdc_crtc_create(struct drm_device *dev)
spin_lock_init(&tilcdc_crtc->irq_lock);
INIT_WORK(&tilcdc_crtc->recover_work, tilcdc_crtc_recover_work);
- ret = drm_crtc_init_with_planes(dev, crtc,
- &tilcdc_crtc->primary,
- NULL,
- &tilcdc_crtc_funcs,
- "tilcdc crtc");
- if (ret < 0)
- goto fail;
-
drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs);
- priv->crtc = crtc;
return 0;
-
-fail:
- tilcdc_crtc_destroy(crtc);
- return ret;
}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 1a238a22309f4..3b11d296a7e91 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -392,7 +392,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
if (ret) {
dev_err(dev, "failed to register cpufreq notifier\n");
priv->freq_transition.notifier_call = NULL;
- goto destroy_crtc;
+ goto disable_pm;
}
#endif
@@ -442,9 +442,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
#ifdef CONFIG_CPU_FREQ
cpufreq_unregister_notifier(&priv->freq_transition,
CPUFREQ_TRANSITION_NOTIFIER);
-destroy_crtc:
#endif
- tilcdc_crtc_destroy(priv->crtc);
disable_pm:
pm_runtime_disable(dev);
clk_put(priv->clk);
@@ -466,7 +464,6 @@ static void tilcdc_pdev_remove(struct platform_device *pdev)
cpufreq_unregister_notifier(&priv->freq_transition,
CPUFREQ_TRANSITION_NOTIFIER);
#endif
- tilcdc_crtc_destroy(priv->crtc);
pm_runtime_disable(&pdev->dev);
clk_put(priv->clk);
destroy_workqueue(priv->wq);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index c69e279a2539d..17d152f9f0b69 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -77,7 +77,7 @@ struct tilcdc_drm_private {
struct drm_crtc *crtc;
- struct drm_encoder *encoder;
+ struct tilcdc_encoder *encoder;
struct drm_connector *connector;
bool irq_enabled;
@@ -91,11 +91,18 @@ int tilcdc_crtc_create(struct drm_device *dev);
irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
-void tilcdc_crtc_destroy(struct drm_crtc *crtc);
int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event);
-int tilcdc_plane_init(struct drm_device *dev, struct drm_plane *plane);
+struct tilcdc_plane {
+ struct drm_plane base;
+};
+
+struct tilcdc_encoder {
+ struct drm_encoder base;
+};
+
+struct tilcdc_plane *tilcdc_plane_init(struct drm_device *dev);
#endif /* __TILCDC_DRV_H__ */
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
index d42be3e16c536..1ee5761757a8c 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
@@ -37,13 +37,13 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
int ret;
- priv->encoder->possible_crtcs = BIT(0);
+ priv->encoder->base.possible_crtcs = BIT(0);
- ret = drm_bridge_attach(priv->encoder, bridge, NULL, 0);
+ ret = drm_bridge_attach(&priv->encoder->base, bridge, NULL, 0);
if (ret)
return ret;
- priv->connector = tilcdc_encoder_find_connector(ddev, priv->encoder);
+ priv->connector = tilcdc_encoder_find_connector(ddev, &priv->encoder->base);
if (!priv->connector)
return -ENODEV;
@@ -53,6 +53,7 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
int tilcdc_encoder_create(struct drm_device *ddev)
{
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
+ struct tilcdc_encoder *encoder;
struct drm_bridge *bridge;
struct drm_panel *panel;
int ret;
@@ -64,33 +65,20 @@ int tilcdc_encoder_create(struct drm_device *ddev)
else if (ret)
return ret;
- priv->encoder = devm_kzalloc(ddev->dev, sizeof(*priv->encoder), GFP_KERNEL);
- if (!priv->encoder)
- return -ENOMEM;
-
- ret = drm_simple_encoder_init(ddev, priv->encoder,
- DRM_MODE_ENCODER_NONE);
- if (ret) {
- dev_err(ddev->dev, "drm_encoder_init() failed %d\n", ret);
- return ret;
+ encoder = drmm_simple_encoder_alloc(ddev, struct tilcdc_encoder,
+ base, DRM_MODE_ENCODER_NONE);
+ if (IS_ERR(encoder)) {
+ dev_err(ddev->dev, "drm_encoder_init() failed %pe\n", encoder);
+ return PTR_ERR(encoder);
}
+ priv->encoder = encoder;
if (panel) {
bridge = devm_drm_panel_bridge_add_typed(ddev->dev, panel,
DRM_MODE_CONNECTOR_DPI);
- if (IS_ERR(bridge)) {
- ret = PTR_ERR(bridge);
- goto err_encoder_cleanup;
- }
+ if (IS_ERR(bridge))
+ return PTR_ERR(bridge);
}
- ret = tilcdc_attach_bridge(ddev, bridge);
- if (ret)
- goto err_encoder_cleanup;
-
- return 0;
-
-err_encoder_cleanup:
- drm_encoder_cleanup(priv->encoder);
- return ret;
+ return tilcdc_attach_bridge(ddev, bridge);
}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index a77a5b22ebd96..d98a1ae0e31f8 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -14,7 +14,6 @@
static const struct drm_plane_funcs tilcdc_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
- .destroy = drm_plane_cleanup,
.reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
@@ -98,22 +97,20 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = {
.atomic_update = tilcdc_plane_atomic_update,
};
-int tilcdc_plane_init(struct drm_device *dev,
- struct drm_plane *plane)
+struct tilcdc_plane *tilcdc_plane_init(struct drm_device *dev)
{
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(dev);
- int ret;
-
- ret = drm_universal_plane_init(dev, plane, 1, &tilcdc_plane_funcs,
- priv->pixelformats,
- priv->num_pixelformats,
- NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
- if (ret) {
- dev_err(dev->dev, "Failed to initialize plane: %d\n", ret);
- return ret;
- }
+ struct tilcdc_plane *plane;
- drm_plane_helper_add(plane, &plane_helper_funcs);
+ plane = drmm_universal_plane_alloc(dev, struct tilcdc_plane, base,
+ 1, &tilcdc_plane_funcs,
+ priv->pixelformats,
+ priv->num_pixelformats,
+ NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+ if (IS_ERR(plane))
+ return plane;
- return 0;
+ drm_plane_helper_add(&plane->base, &plane_helper_funcs);
+
+ return plane;
}
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:36 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper which simplifies the code by:
- Automatically handling both panel and bridge cases internally
- Managing the panel-to-bridge conversion when needed
- Using devres for resource management, eliminating manual cleanup
This removes the need for explicit panel-to-bridge conversion via
devm_drm_panel_bridge_add_typed() and the associated error handling path.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v4:
- New patch
---
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
index a34a10337f6a8..546fe7e6ee815 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
@@ -55,15 +55,12 @@ int tilcdc_encoder_create(struct drm_device *ddev)
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
struct tilcdc_encoder *encoder;
struct drm_bridge *bridge;
- struct drm_panel *panel;
- int ret;
- ret = drm_of_find_panel_or_bridge(ddev->dev->of_node, 0, 0,
- &panel, &bridge);
- if (ret == -ENODEV)
+ bridge = devm_drm_of_get_bridge(ddev->dev, ddev->dev->of_node, 0, 0);
+ if (PTR_ERR(bridge) == -ENODEV)
return 0;
- else if (ret)
- return ret;
+ else if (IS_ERR(bridge))
+ return PTR_ERR(bridge);
encoder = drmm_simple_encoder_alloc(ddev, struct tilcdc_encoder,
base, DRM_MODE_ENCODER_NONE);
@@ -73,12 +70,5 @@ int tilcdc_encoder_create(struct drm_device *ddev)
}
priv->encoder = encoder;
- if (panel) {
- bridge = devm_drm_panel_bridge_add_typed(ddev->dev, panel,
- DRM_MODE_CONNECTOR_DPI);
- if (IS_ERR(bridge))
- return PTR_ERR(bridge);
- }
-
return tilcdc_attach_bridge(ddev, bridge);
}
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:38 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Replace dev_* logging calls with their DRM equivalents.
This aligns with the DRM subsystem's logging infrastructure and provides
better integration with DRM debugging mechanisms. The drm_* helpers
automatically include device information and integrate with DRM's
debug category filtering.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v4:
- New patch.
---
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 26 +++++++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 16 ++++++++--------
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 4 ++--
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 8 ++++----
4 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 2916de3dce91e..4d3b7059cd5b2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -125,7 +125,7 @@ static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
ret = wait_for_completion_timeout(&tilcdc_crtc->palette_loaded,
msecs_to_jiffies(50));
if (ret == 0)
- dev_err(dev->dev, "%s: Palette loading timeout", __func__);
+ drm_err(dev, "%s: Palette loading timeout", __func__);
/* Disable LCDC DMA and DMA Palette Loaded Interrupt. */
tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
@@ -223,7 +223,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
*/
if (!clk_rate) {
/* Nothing more we can do. Just bail out. */
- dev_err(dev->dev,
+ drm_err(dev,
"failed to set the pixel clock - unable to read current lcdc clock rate\n");
return;
}
@@ -240,7 +240,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
real_pclk_rate = clk_rate / clkdiv;
if (tilcdc_pclk_diff(pclk_rate, real_pclk_rate) > 5) {
- dev_warn(dev->dev,
+ drm_warn(dev,
"effective pixel clock rate (%luHz) differs from the requested rate (%luHz)\n",
real_pclk_rate, pclk_rate);
}
@@ -369,7 +369,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
reg |= LCDC_V2_TFT_24BPP_MODE;
break;
default:
- dev_err(dev->dev, "invalid pixel format\n");
+ drm_err(dev, "invalid pixel format\n");
return;
}
}
@@ -482,7 +482,7 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool shutdown)
tilcdc_crtc->frame_done,
msecs_to_jiffies(500));
if (ret == 0)
- dev_err(dev->dev, "%s: timeout waiting for framedone\n",
+ drm_err(dev, "%s: timeout waiting for framedone\n",
__func__);
drm_crtc_vblank_off(crtc);
@@ -543,7 +543,7 @@ static void tilcdc_crtc_recover_work(struct work_struct *work)
container_of(work, struct tilcdc_crtc, recover_work);
struct drm_crtc *crtc = &tilcdc_crtc->base;
- dev_info(crtc->dev->dev, "%s: Reset CRTC", __func__);
+ drm_info(crtc->dev, "%s: Reset CRTC", __func__);
drm_modeset_lock(&crtc->mutex, NULL);
@@ -575,7 +575,7 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
struct drm_device *dev = crtc->dev;
if (tilcdc_crtc->event) {
- dev_err(dev->dev, "already pending page flip!\n");
+ drm_err(dev, "already pending page flip!\n");
return -EBUSY;
}
@@ -707,7 +707,7 @@ static void tilcdc_crtc_reset(struct drm_crtc *crtc)
tilcdc_crtc->frame_done,
msecs_to_jiffies(500));
if (ret == 0)
- dev_err(dev->dev, "%s: timeout waiting for framedone\n",
+ drm_err(dev, "%s: timeout waiting for framedone\n",
__func__);
}
pm_runtime_put_sync(dev->dev);
@@ -895,7 +895,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
}
if (stat & LCDC_FIFO_UNDERFLOW)
- dev_err_ratelimited(dev->dev, "%s(0x%08x): FIFO underflow",
+ drm_err_ratelimited(dev, "%s(0x%08x): FIFO underflow",
__func__, stat);
if (stat & LCDC_PL_LOAD_DONE) {
@@ -909,7 +909,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
}
if (stat & LCDC_SYNC_LOST) {
- dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
+ drm_err_ratelimited(dev, "%s(0x%08x): Sync lost",
__func__, stat);
tilcdc_crtc->frame_intact = false;
if (priv->rev == 1) {
@@ -923,7 +923,7 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
} else {
if (tilcdc_crtc->sync_lost_count++ >
SYNC_LOST_COUNT_LIMIT) {
- dev_err(dev->dev,
+ drm_err(dev,
"%s(0x%08x): Sync lost flood detected, recovering",
__func__, stat);
queue_work(system_wq,
@@ -965,7 +965,7 @@ int tilcdc_crtc_create(struct drm_device *dev)
primary = tilcdc_plane_init(dev);
if (IS_ERR(primary)) {
- dev_err(dev->dev, "Failed to initialize plane: %pe\n", primary);
+ drm_err(dev, "Failed to initialize plane: %pe\n", primary);
return PTR_ERR(primary);
}
@@ -975,7 +975,7 @@ int tilcdc_crtc_create(struct drm_device *dev)
&tilcdc_crtc_funcs,
"tilcdc crtc");
if (IS_ERR(tilcdc_crtc)) {
- dev_err(dev->dev, "Failed to init CRTC: %pe\n", tilcdc_crtc);
+ drm_err(dev, "Failed to init CRTC: %pe\n", tilcdc_crtc);
return PTR_ERR(tilcdc_crtc);
}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3b11d296a7e91..c877b2be9c2ec 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -288,14 +288,14 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
priv->mmio = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->mmio)) {
- dev_err(dev, "failed to request / ioremap\n");
+ drm_err(ddev, "failed to request / ioremap\n");
ret = PTR_ERR(priv->mmio);
goto free_wq;
}
priv->clk = clk_get(dev, "fck");
if (IS_ERR(priv->clk)) {
- dev_err(dev, "failed to get functional clock\n");
+ drm_err(ddev, "failed to get functional clock\n");
ret = -ENODEV;
goto free_wq;
}
@@ -313,7 +313,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
priv->rev = 2;
break;
default:
- dev_warn(dev, "Unknown PID Reg value 0x%08x, "
+ drm_warn(ddev, "Unknown PID Reg value 0x%08x, "
"defaulting to LCD revision 1\n",
tilcdc_read(ddev, LCDC_PID_REG));
priv->rev = 1;
@@ -380,7 +380,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
ret = tilcdc_crtc_create(ddev);
if (ret < 0) {
- dev_err(dev, "failed to create crtc\n");
+ drm_err(ddev, "failed to create crtc\n");
goto disable_pm;
}
modeset_init(ddev);
@@ -390,7 +390,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
ret = cpufreq_register_notifier(&priv->freq_transition,
CPUFREQ_TRANSITION_NOTIFIER);
if (ret) {
- dev_err(dev, "failed to register cpufreq notifier\n");
+ drm_err(ddev, "failed to register cpufreq notifier\n");
priv->freq_transition.notifier_call = NULL;
goto disable_pm;
}
@@ -401,14 +401,14 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
goto unregister_cpufreq_notif;
if (!priv->connector) {
- dev_err(dev, "no encoders/connectors found\n");
+ drm_err(ddev, "no encoders/connectors found\n");
ret = -EPROBE_DEFER;
goto unregister_cpufreq_notif;
}
ret = drm_vblank_init(ddev, 1);
if (ret < 0) {
- dev_err(dev, "failed to initialize vblank\n");
+ drm_err(ddev, "failed to initialize vblank\n");
goto unregister_cpufreq_notif;
}
@@ -419,7 +419,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
ret = tilcdc_irq_install(ddev, priv->irq);
if (ret < 0) {
- dev_err(dev, "failed to install IRQ handler\n");
+ drm_err(ddev, "failed to install IRQ handler\n");
goto unregister_cpufreq_notif;
}
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
index 1ee5761757a8c..a34a10337f6a8 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
@@ -25,7 +25,7 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
return connector;
}
- dev_err(ddev->dev, "No connector found for %s encoder (id %d)\n",
+ drm_err(ddev, "No connector found for %s encoder (id %d)\n",
encoder->name, encoder->base.id);
return NULL;
@@ -68,7 +68,7 @@ int tilcdc_encoder_create(struct drm_device *ddev)
encoder = drmm_simple_encoder_alloc(ddev, struct tilcdc_encoder,
base, DRM_MODE_ENCODER_NONE);
if (IS_ERR(encoder)) {
- dev_err(ddev->dev, "drm_encoder_init() failed %pe\n", encoder);
+ drm_err(ddev, "drm_encoder_init() failed %pe\n", encoder);
return PTR_ERR(encoder);
}
priv->encoder = encoder;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index d98a1ae0e31f8..a9982a9956903 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -36,7 +36,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
return -EINVAL;
if (new_state->crtc_x || new_state->crtc_y) {
- dev_err(plane->dev->dev, "%s: crtc position must be zero.",
+ drm_err(plane->dev, "%s: crtc position must be zero.",
__func__);
return -EINVAL;
}
@@ -48,7 +48,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
if (crtc_state->mode.hdisplay != new_state->crtc_w ||
crtc_state->mode.vdisplay != new_state->crtc_h) {
- dev_err(plane->dev->dev,
+ drm_err(plane->dev,
"%s: Size must match mode (%dx%d == %dx%d)", __func__,
crtc_state->mode.hdisplay, crtc_state->mode.vdisplay,
new_state->crtc_w, new_state->crtc_h);
@@ -58,13 +58,13 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
pitch = crtc_state->mode.hdisplay *
new_state->fb->format->cpp[0];
if (new_state->fb->pitches[0] != pitch) {
- dev_err(plane->dev->dev,
+ drm_err(plane->dev,
"Invalid pitch: fb and crtc widths must be the same");
return -EINVAL;
}
if (old_state->fb && new_state->fb->format != old_state->fb->format) {
- dev_dbg(plane->dev->dev,
+ drm_dbg(plane->dev,
"%s(): pixel format change requires mode_change\n",
__func__);
crtc_state->mode_changed = true;
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:37 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
The tilcdc driver no longer uses the component framework to bind the
tda998x bridge driver. The component bind/unbind operations and the
encoder initialization code are now dead code and can be safely removed.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/bridge/tda998x_drv.c | 69 +-----------------------------------
1 file changed, 1 insertion(+), 68 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index e636459d91857..865285ba2bd8c 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -4,7 +4,6 @@
* Author: Rob Clark <robdclark@gmail.com>
*/
-#include <linux/component.h>
#include <linux/gpio/consumer.h>
#include <linux/hdmi.h>
#include <linux/i2c.h>
@@ -1963,85 +1962,19 @@ static int tda998x_create(struct device *dev)
return ret;
}
-/* DRM encoder functions */
-
-static int tda998x_encoder_init(struct device *dev, struct drm_device *drm)
-{
- struct tda998x_priv *priv = dev_get_drvdata(dev);
- u32 crtcs = 0;
- int ret;
-
- if (dev->of_node)
- crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
-
- /* If no CRTCs were found, fall back to our old behaviour */
- if (crtcs == 0) {
- dev_warn(dev, "Falling back to first CRTC\n");
- crtcs = 1 << 0;
- }
-
- priv->encoder.possible_crtcs = crtcs;
-
- ret = drm_simple_encoder_init(drm, &priv->encoder,
- DRM_MODE_ENCODER_TMDS);
- if (ret)
- goto err_encoder;
-
- ret = drm_bridge_attach(&priv->encoder, &priv->bridge, NULL, 0);
- if (ret)
- goto err_bridge;
-
- return 0;
-
-err_bridge:
- drm_encoder_cleanup(&priv->encoder);
-err_encoder:
- return ret;
-}
-
-static int tda998x_bind(struct device *dev, struct device *master, void *data)
-{
- struct drm_device *drm = data;
-
- return tda998x_encoder_init(dev, drm);
-}
-
-static void tda998x_unbind(struct device *dev, struct device *master,
- void *data)
-{
- struct tda998x_priv *priv = dev_get_drvdata(dev);
-
- drm_encoder_cleanup(&priv->encoder);
-}
-
-static const struct component_ops tda998x_ops = {
- .bind = tda998x_bind,
- .unbind = tda998x_unbind,
-};
-
static int
tda998x_probe(struct i2c_client *client)
{
- int ret;
-
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_warn(&client->dev, "adapter does not support I2C\n");
return -EIO;
}
- ret = tda998x_create(&client->dev);
- if (ret)
- return ret;
-
- ret = component_add(&client->dev, &tda998x_ops);
- if (ret)
- tda998x_destroy(&client->dev);
- return ret;
+ return tda998x_create(&client->dev);
}
static void tda998x_remove(struct i2c_client *client)
{
- component_del(&client->dev, &tda998x_ops);
tda998x_destroy(&client->dev);
}
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:39 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Now that tda998x_create and tda998x_destroy are called only in the probe
function, there is no need for separate functions.
Move the code into the tda998x_probe and tda998x_remove functions.
Rewrite the cleanup path using goto calls in probe and reorder it in the
remove function.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Change in v3:
- Move free_irq() call at the right place in the probe error path.
---
drivers/gpu/drm/bridge/tda998x_drv.c | 99 +++++++++++++++++++-----------------
1 file changed, 51 insertions(+), 48 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index 865285ba2bd8c..e06d8d4c4b875 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -1748,38 +1748,20 @@ static int tda998x_get_audio_ports(struct tda998x_priv *priv,
return 0;
}
-static void tda998x_destroy(struct device *dev)
-{
- struct tda998x_priv *priv = dev_get_drvdata(dev);
-
- drm_bridge_remove(&priv->bridge);
-
- /* disable all IRQs and free the IRQ handler */
- cec_write(priv, REG_CEC_RXSHPDINTENA, 0);
- reg_clear(priv, REG_INT_FLAGS_2, INT_FLAGS_2_EDID_BLK_RD);
-
- if (priv->audio_pdev)
- platform_device_unregister(priv->audio_pdev);
-
- if (priv->hdmi->irq)
- free_irq(priv->hdmi->irq, priv);
-
- timer_delete_sync(&priv->edid_delay_timer);
- cancel_work_sync(&priv->detect_work);
-
- i2c_unregister_device(priv->cec);
-
- cec_notifier_conn_unregister(priv->cec_notify);
-}
-
-static int tda998x_create(struct device *dev)
+static int
+tda998x_probe(struct i2c_client *client)
{
- struct i2c_client *client = to_i2c_client(dev);
struct device_node *np = client->dev.of_node;
+ struct device *dev = &client->dev;
struct i2c_board_info cec_info;
struct tda998x_priv *priv;
- u32 video;
int rev_lo, rev_hi, ret;
+ u32 video;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+ dev_warn(&client->dev, "adapter does not support I2C\n");
+ return -EIO;
+ }
priv = devm_drm_bridge_alloc(dev, struct tda998x_priv, bridge, &tda998x_bridge_funcs);
if (IS_ERR(priv))
@@ -1814,13 +1796,15 @@ static int tda998x_create(struct device *dev)
rev_lo = reg_read(priv, REG_VERSION_LSB);
if (rev_lo < 0) {
dev_err(dev, "failed to read version: %d\n", rev_lo);
- return rev_lo;
+ ret = rev_lo;
+ goto cancel_work;
}
rev_hi = reg_read(priv, REG_VERSION_MSB);
if (rev_hi < 0) {
dev_err(dev, "failed to read version: %d\n", rev_hi);
- return rev_hi;
+ ret = rev_hi;
+ goto cancel_work;
}
priv->rev = rev_lo | rev_hi << 8;
@@ -1843,7 +1827,8 @@ static int tda998x_create(struct device *dev)
break;
default:
dev_err(dev, "found unsupported device: %04x\n", priv->rev);
- return -ENXIO;
+ ret = -ENXIO;
+ goto cancel_work;
}
/* after reset, enable DDC: */
@@ -1887,7 +1872,7 @@ static int tda998x_create(struct device *dev)
if (ret) {
dev_err(dev, "failed to request IRQ#%u: %d\n",
client->irq, ret);
- goto err_irq;
+ goto cancel_work;
}
/* enable HPD irq */
@@ -1897,7 +1882,7 @@ static int tda998x_create(struct device *dev)
priv->cec_notify = cec_notifier_conn_register(dev, NULL, NULL);
if (!priv->cec_notify) {
ret = -ENOMEM;
- goto fail;
+ goto free_irq;
}
priv->cec_glue.parent = dev;
@@ -1924,7 +1909,7 @@ static int tda998x_create(struct device *dev)
priv->cec = i2c_new_client_device(client->adapter, &cec_info);
if (IS_ERR(priv->cec)) {
ret = PTR_ERR(priv->cec);
- goto fail;
+ goto notifier_conn_unregister;
}
/* enable EDID read irq: */
@@ -1941,7 +1926,7 @@ static int tda998x_create(struct device *dev)
ret = tda998x_get_audio_ports(priv, np);
if (ret)
- goto fail;
+ goto unregister_dev;
if (priv->audio_port_enable[AUDIO_ROUTE_I2S] ||
priv->audio_port_enable[AUDIO_ROUTE_SPDIF])
@@ -1956,26 +1941,44 @@ static int tda998x_create(struct device *dev)
return 0;
-fail:
- tda998x_destroy(dev);
-err_irq:
+unregister_dev:
+ i2c_unregister_device(priv->cec);
+notifier_conn_unregister:
+ cec_notifier_conn_unregister(priv->cec_notify);
+free_irq:
+ if (client->irq) {
+ cec_write(priv, REG_CEC_RXSHPDINTENA, 0);
+ reg_clear(priv, REG_INT_FLAGS_2, INT_FLAGS_2_EDID_BLK_RD);
+ free_irq(client->irq, priv);
+ }
+cancel_work:
+ timer_delete_sync(&priv->edid_delay_timer);
+ cancel_work_sync(&priv->detect_work);
return ret;
}
-static int
-tda998x_probe(struct i2c_client *client)
+static void tda998x_remove(struct i2c_client *client)
{
- if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- dev_warn(&client->dev, "adapter does not support I2C\n");
- return -EIO;
- }
+ struct tda998x_priv *priv = dev_get_drvdata(&client->dev);
- return tda998x_create(&client->dev);
-}
+ drm_bridge_remove(&priv->bridge);
-static void tda998x_remove(struct i2c_client *client)
-{
- tda998x_destroy(&client->dev);
+ if (priv->audio_pdev)
+ platform_device_unregister(priv->audio_pdev);
+
+ i2c_unregister_device(priv->cec);
+
+ cec_notifier_conn_unregister(priv->cec_notify);
+
+ /* disable all IRQs and free the IRQ handler */
+ if (client->irq) {
+ cec_write(priv, REG_CEC_RXSHPDINTENA, 0);
+ reg_clear(priv, REG_INT_FLAGS_2, INT_FLAGS_2_EDID_BLK_RD);
+ free_irq(priv->hdmi->irq, priv);
+ }
+
+ timer_delete_sync(&priv->edid_delay_timer);
+ cancel_work_sync(&priv->detect_work);
}
#ifdef CONFIG_OF
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:40 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Use directly drm_connector_cleanup in the destroy ops instead of having
a custom function that does nothing more.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/bridge/tda998x_drv.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index e06d8d4c4b875..fad3c9bfda383 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -1203,16 +1203,11 @@ tda998x_connector_detect(struct drm_connector *connector, bool force)
connector_status_disconnected;
}
-static void tda998x_connector_destroy(struct drm_connector *connector)
-{
- drm_connector_cleanup(connector);
-}
-
static const struct drm_connector_funcs tda998x_connector_funcs = {
.reset = drm_atomic_helper_connector_reset,
.fill_modes = drm_helper_probe_single_connector_modes,
.detect = tda998x_connector_detect,
- .destroy = tda998x_connector_destroy,
+ .destroy = drm_connector_cleanup,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:41 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Add support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to allow display
controller drivers to create their own connectors. This modernizes the
driver to work with the current DRM bridge framework.
The implementation includes:
- Refactoring detection and EDID reading into bridge-usable helpers
- Adding bridge operations: edid_read, detect, hpd_enable, hpd_disable
- Setting appropriate bridge ops (DRM_BRIDGE_OP_EDID, DRM_BRIDGE_OP_DETECT,
DRM_BRIDGE_OP_HPD) and connector type (HDMIA)
- Skipping connector creation when DRM_BRIDGE_ATTACH_NO_CONNECTOR is set
- Handling conditional connector cleanup in bridge_detach
The driver maintains backward compatibility by continuing to create its
own connector when the flag is not set.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
drivers/gpu/drm/bridge/tda998x_drv.c | 96 +++++++++++++++++++++++++++++++-----
1 file changed, 85 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index fad3c9bfda383..d9b388165de15 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -1193,16 +1193,22 @@ static int tda998x_audio_codec_init(struct tda998x_priv *priv,
/* DRM connector functions */
-static enum drm_connector_status
-tda998x_connector_detect(struct drm_connector *connector, bool force)
+static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
{
- struct tda998x_priv *priv = conn_to_tda998x_priv(connector);
u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
connector_status_disconnected;
}
+static enum drm_connector_status
+tda998x_connector_detect(struct drm_connector *connector, bool force)
+{
+ struct tda998x_priv *priv = conn_to_tda998x_priv(connector);
+
+ return tda998x_conn_detect(priv);
+}
+
static const struct drm_connector_funcs tda998x_connector_funcs = {
.reset = drm_atomic_helper_connector_reset,
.fill_modes = drm_helper_probe_single_connector_modes,
@@ -1276,11 +1282,10 @@ static int read_edid_block(void *data, u8 *buf, unsigned int blk, size_t length)
return ret;
}
-static int tda998x_connector_get_modes(struct drm_connector *connector)
+static const struct drm_edid *tda998x_edid_read(struct tda998x_priv *priv,
+ struct drm_connector *connector)
{
- struct tda998x_priv *priv = conn_to_tda998x_priv(connector);
const struct drm_edid *drm_edid;
- int n;
/*
* If we get killed while waiting for the HPD timeout, return
@@ -1298,6 +1303,16 @@ static int tda998x_connector_get_modes(struct drm_connector *connector)
if (priv->rev == TDA19988)
reg_set(priv, REG_TX4, TX4_PD_RAM);
+ return drm_edid;
+}
+
+static int tda998x_connector_get_modes(struct drm_connector *connector)
+{
+ struct tda998x_priv *priv = conn_to_tda998x_priv(connector);
+ const struct drm_edid *drm_edid;
+ int n;
+
+ drm_edid = tda998x_edid_read(priv, connector);
drm_edid_connector_update(connector, drm_edid);
cec_notifier_set_phys_addr(priv->cec_notify,
connector->display_info.source_physical_address);
@@ -1365,10 +1380,8 @@ static int tda998x_bridge_attach(struct drm_bridge *bridge,
{
struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
- if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
- DRM_ERROR("Fix bridge driver to make connector optional!");
- return -EINVAL;
- }
+ if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
+ return 0;
return tda998x_connector_init(priv, bridge->dev);
}
@@ -1377,7 +1390,8 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
{
struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
- drm_connector_cleanup(&priv->connector);
+ if (priv->connector.dev)
+ drm_connector_cleanup(&priv->connector);
}
static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge,
@@ -1677,6 +1691,59 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
mutex_unlock(&priv->audio_mutex);
}
+static const struct drm_edid *
+tda998x_bridge_edid_read(struct drm_bridge *bridge,
+ struct drm_connector *connector)
+{
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+ const struct drm_edid *drm_edid;
+ const struct edid *edid;
+
+ drm_edid = tda998x_edid_read(priv, connector);
+ if (!drm_edid) {
+ dev_dbg(&priv->hdmi->dev, "failed to get edid\n");
+ return NULL;
+ }
+
+ /*
+ * FIXME: This should use connector->display_info.has_audio from
+ * a path that has read the EDID and called
+ * drm_edid_connector_update().
+ */
+ edid = drm_edid_raw(drm_edid);
+
+ dev_dbg(&priv->hdmi->dev, "got edid: width[%d] x height[%d]\n",
+ edid->width_cm, edid->height_cm);
+
+ priv->sink_has_audio = drm_detect_monitor_audio(edid);
+ cec_notifier_set_phys_addr_from_edid(priv->cec_notify, edid);
+
+ return drm_edid;
+}
+
+static enum drm_connector_status
+tda998x_bridge_detect(struct drm_bridge *bridge,
+ struct drm_connector *connector)
+{
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+
+ return tda998x_conn_detect(priv);
+}
+
+static void tda998x_bridge_hpd_enable(struct drm_bridge *bridge)
+{
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+
+ cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD);
+}
+
+static void tda998x_bridge_hpd_disable(struct drm_bridge *bridge)
+{
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+
+ cec_write(priv, REG_CEC_RXSHPDINTENA, 0);
+}
+
static const struct drm_bridge_funcs tda998x_bridge_funcs = {
.attach = tda998x_bridge_attach,
.detach = tda998x_bridge_detach,
@@ -1684,6 +1751,10 @@ static const struct drm_bridge_funcs tda998x_bridge_funcs = {
.disable = tda998x_bridge_disable,
.mode_set = tda998x_bridge_mode_set,
.enable = tda998x_bridge_enable,
+ .edid_read = tda998x_bridge_edid_read,
+ .detect = tda998x_bridge_detect,
+ .hpd_enable = tda998x_bridge_hpd_enable,
+ .hpd_disable = tda998x_bridge_hpd_disable,
};
/* I2C driver functions */
@@ -1872,6 +1943,7 @@ tda998x_probe(struct i2c_client *client)
/* enable HPD irq */
cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD);
+ priv->bridge.ops = DRM_BRIDGE_OP_HPD;
}
priv->cec_notify = cec_notifier_conn_register(dev, NULL, NULL);
@@ -1932,6 +2004,8 @@ tda998x_probe(struct i2c_client *client)
priv->bridge.of_node = dev->of_node;
#endif
+ priv->bridge.ops |= DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
+ priv->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
drm_bridge_add(&priv->bridge);
return 0;
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:42 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Convert the driver to use the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag when
attaching bridges. This modernizes the driver by delegating connector
creation to the bridge subsystem through drm_bridge_connector_init()
instead of manually searching for connectors created by the bridge.
The custom tilcdc_encoder_find_connector() function is removed and
replaced with the standard drm_bridge_connector infrastructure, which
simplifies the code and aligns with current DRM bridge best practices.
This change is safe as there are now no in-tree devicetrees that
connect tilcdc to bridges which do not support the
DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Changes in v5:
- Move DRM_DISPLAY_HELPER before DRM_BRIDGE_CONNECTOR for a more logical
description.
Changes in v4:
- Select missing DRM_BRIDGE_CONNECTOR and DRM_DISPLAY_HELPER config
dependency in Kconfig
---
drivers/gpu/drm/tilcdc/Kconfig | 2 ++
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 37 ++++++++++++++-------------------
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/Kconfig b/drivers/gpu/drm/tilcdc/Kconfig
index a36e809f984cd..89df7528756c8 100644
--- a/drivers/gpu/drm/tilcdc/Kconfig
+++ b/drivers/gpu/drm/tilcdc/Kconfig
@@ -6,6 +6,8 @@ config DRM_TILCDC
select DRM_KMS_HELPER
select DRM_GEM_DMA_HELPER
select DRM_BRIDGE
+ select DRM_DISPLAY_HELPER
+ select DRM_BRIDGE_CONNECTOR
select DRM_PANEL_BRIDGE
select VIDEOMODE_HELPERS
select BACKLIGHT_CLASS_DEVICE
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
index 546fe7e6ee815..680a2ac6ab594 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_encoder.c
@@ -8,45 +8,40 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
#include <drm/drm_of.h>
#include <drm/drm_simple_kms_helper.h>
#include "tilcdc_drv.h"
#include "tilcdc_encoder.h"
-static
-struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
- struct drm_encoder *encoder)
-{
- struct drm_connector *connector;
-
- list_for_each_entry(connector, &ddev->mode_config.connector_list, head) {
- if (drm_connector_has_possible_encoder(connector, encoder))
- return connector;
- }
-
- drm_err(ddev, "No connector found for %s encoder (id %d)\n",
- encoder->name, encoder->base.id);
-
- return NULL;
-}
-
static
int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
{
struct tilcdc_drm_private *priv = ddev_to_tilcdc_priv(ddev);
+ struct drm_connector *connector;
int ret;
priv->encoder->base.possible_crtcs = BIT(0);
- ret = drm_bridge_attach(&priv->encoder->base, bridge, NULL, 0);
+ ret = drm_bridge_attach(&priv->encoder->base, bridge, NULL,
+ DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret)
return ret;
- priv->connector = tilcdc_encoder_find_connector(ddev, &priv->encoder->base);
- if (!priv->connector)
- return -ENODEV;
+ connector = drm_bridge_connector_init(ddev, &priv->encoder->base);
+ if (IS_ERR(connector)) {
+ drm_err(ddev, "bridge_connector create failed\n");
+ return PTR_ERR(connector);
+ }
+
+ ret = drm_connector_attach_encoder(connector, &priv->encoder->base);
+ if (ret) {
+ drm_err(ddev, "attaching encoder to connector failed\n");
+ return ret;
+ }
+ priv->connector = connector;
return 0;
}
--
2.43.0
|
{
"author": "\"Kory Maincent (TI.com)\" <kory.maincent@bootlin.com>",
"date": "Fri, 23 Jan 2026 17:12:43 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
Hi Kory,
On Fri Jan 23, 2026 at 5:12 PM CET, Kory Maincent (TI.com) wrote:
I'm OK with this patch, based on the v4 discussion. I have a question
however, see below.
You are introducing a subtle difference here: while you pass the connector
type to devm_drm_panel_bridge_add_typed(), devm_drm_of_get_bridge() does
not take it and expects it to ahve been set previously and errors out if it
hasn't.
Can you ensure the connector type is alway set before this
devm_drm_of_get_bridge() call?
All the changes to the driver in the previous patches of this series make
it hard to find that out from here.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
|
{
"author": "\"Luca Ceresoli\" <luca.ceresoli@bootlin.com>",
"date": "Fri, 30 Jan 2026 20:31:11 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
On Fri, 30 Jan 2026 20:31:11 +0100
"Luca Ceresoli" <luca.ceresoli@bootlin.com> wrote:
...
The connector type should be set by the bridge or the panel driver.
https://elixir.bootlin.com/linux/v6.18.6/source/drivers/gpu/drm/bridge/panel.c#L397
* This function is deprecated and should not be used in new drivers. Use
* devm_drm_panel_bridge_add() instead, and fix panel drivers as necessary if
* they don't report a connector type.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
{
"author": "Kory Maincent <kory.maincent@bootlin.com>",
"date": "Mon, 2 Feb 2026 10:57:17 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v5 00/25] Clean and update tilcdc driver to support
DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
The starting point for this work was adding support for the HDMI cape:
https://www.seeedstudio.com/Seeed-Studio-BeagleBone-Green-HDMI-Cape.html
This will be sent in a later series.
Initially, Miguel proposed modifying the ite-it66121 bridge to support
the legacy behavior without the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag:
https://lore.kernel.org/lkml/20250909-it66121-fix-v1-1-bc79ca83df17@bootlin.com/
This patch was NAK'd as we don't want to add more legacy code. Maxime
requested that the tilcdc driver be updated to use
DRM_BRIDGE_ATTACH_NO_CONNECTOR instead.
While working on this update, I discovered that the tilcdc driver
contained significant amounts of legacy code that needed cleaning.
Since this driver was developed alongside the tda998x driver for
several AM335x boards, the tda998x driver also required cleanup and
support for the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
A new tilcdc_panel_legacy driver replaces the old tilcdc_panel driver.
It modifies the devicetree at boot time to properly bind the tilcdc driver
with the standard panel-simple driver.
This series is based on the tilcdc fix sent to mainline:
https://lore.kernel.org/lkml/20251125090546.137193-1-kory.maincent@bootlin.com/
This series has been tested on:
- BeagleBone Black (tilcdc + tda998x bridge)
- BeagleBone Black with LCD cape (tilcdc + ti,tilcdc,panel binding)
- BeagleBone Green Eco with HDMI cape (tilcdc + it66121 bridge)
The following mainline devicetrees still use ti,tilcdc,panel binding.
I believe this series maintains compatibility, but I cannot test without
hardware:
- da850-evm.dts
- am335x-guardian.dts
- am335x-pdu001.dts
- am335x-pepper.dts
- am335x-sbc-t335.dts
- am335x-sl50.dts
Patches 1-2: Convert tilcdc binding to YAML and set the ti,tilcdc,panel
sub-binding as legacy.
Patches 3-6: Replace tilcdc_panel driver to the new tilcdc_panel_legacy
driver which is tweaking the devicetree at boot time.
Patches 7-20: Clean up tilcdc driver.
Patches 21-23: Clean up tda998x driver.
Patch 24: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tda998x driver.
Patch 25: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support for tilcdc driver.
Changes in v5:
- Fix a missing cleanup path.
- Link to v4: https://lore.kernel.org/r/20260116-feature_tilcdc-v4-0-2c1c22143087@bootlin.com
Changes in v4:
- Use device_get_match_data instead of of_match_node.
- Convert the driver to use DRM managed resources to avoid lifetime
resources issue.
- Add a patch to convert to drm_device-based logging helpers.
- Replace drm_of_find_panel_or_bridge() with the newer
devm_drm_of_get_bridge() helper.
- Link to v3: https://lore.kernel.org/r/20260106-feature_tilcdc-v3-0-9bad0f742164@bootlin.com
Changes in v3:
- Split patch 13 and patch 14 into two for better readability and git
history clarity.
- Update patch 5 to use OF changeset and __free() macro. Made also few
small improvements as requested by Luca.
- Rename binding file to ti,am33xx-tilcdc.yaml, use generic node name and
drop unused label.
- Link to v2: https://lore.kernel.org/r/20251211-feature_tilcdc-v2-0-f48bac3cd33e@bootlin.com
Changes in v2:
- Remove patch 2 that add fifo-threshold property. Use FIFO threshold
value from SoC id instead.
- Remove the part that breaks DTB compatibility.
- Add tilcdc_panel_legacy to modify the devicetree at boot time to properly
bind the tilcdc driver with the standard panel-simple driver.
- Link to v1: https://lore.kernel.org/r/20251126-feature_tilcdc-v1-0-49b9ef2e3aa0@bootlin.com
Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com>
---
Kory Maincent (TI.com) (25):
dt-bindings: display: tilcdc: Convert to DT schema
dt-bindings: display: tilcdc: Mark panel binding as deprecated
drm/tilcdc: Remove simulate_vesa_sync flag
drm/tilcdc: Add support for DRM bus flags and simplify panel config
drm/tilcdc: Convert legacy panel binding via DT overlay at boot time
drm/tilcdc: Remove tilcdc panel driver
drm/tilcdc: Remove component framework support
drm/tilcdc: Remove tilcdc_panel_info structure
drm/tilcdc: Remove redundant #endif/#ifdef in debugfs code
drm/tilcdc: Remove unused encoder and connector tracking arrays
drm/tilcdc: Rename external_encoder and external_connector to encoder and connector
drm/tilcdc: Rename tilcdc_external to tilcdc_encoder
drm/tilcdc: Remove the useless module list support
drm/tilcdc: Use drm_module_platform_driver() helper
drm/tilcdc: Move tilcdc_init/fini closer to probe/remove
drm/tilcdc: Modernize driver initialization and cleanup paths
drm/tilcdc: Remove the use of drm_device private_data
drm/tilcdc: Convert to DRM managed resources
drm/tilcdc: Convert to drm_device-based logging helpers
drm/tilcdc: Use devm_drm_of_get_bridge() helper
drm/bridge: tda998x: Remove component support
drm/bridge: tda998x: Move tda998x_create/destroy into probe and remove
drm/bridge: tda998x: Remove useless tda998x_connector_destroy wrapper
drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/tilcdc: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR
.../devicetree/bindings/display/tilcdc/panel.txt | 1 +
.../bindings/display/tilcdc/ti,am33xx-tilcdc.yaml | 100 +++++
.../devicetree/bindings/display/tilcdc/tilcdc.txt | 82 ----
drivers/gpu/drm/bridge/tda998x_drv.c | 251 +++++------
drivers/gpu/drm/tilcdc/Kconfig | 18 +
drivers/gpu/drm/tilcdc/Makefile | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 192 +++-----
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 486 ++++++++-------------
drivers/gpu/drm/tilcdc/tilcdc_drv.h | 99 +----
drivers/gpu/drm/tilcdc/tilcdc_encoder.c | 69 +++
.../tilcdc/{tilcdc_external.h => tilcdc_encoder.h} | 5 +-
drivers/gpu/drm/tilcdc/tilcdc_external.c | 179 --------
drivers/gpu/drm/tilcdc/tilcdc_panel.c | 408 -----------------
drivers/gpu/drm/tilcdc/tilcdc_panel.h | 15 -
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 185 ++++++++
drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.dtso | 29 ++
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 37 +-
drivers/gpu/drm/tilcdc/tilcdc_regs.h | 8 +-
18 files changed, 812 insertions(+), 1357 deletions(-)
---
base-commit: a3158f3710111bbd4bfba3bc0883449efde10a0b
change-id: 20251014-feature_tilcdc-79cd49e67bf9
Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
|
On Mon Feb 2, 2026 at 10:57 AM CET, Kory Maincent wrote:
Ah, right, so it means this patch might cause some regressions due to panel
drivers to be fixed. So it's fine as long as you are ready to handle such
regression, should any happen.
Also other patches did exactly the same, e.g.:
commit 6e1853589ea6 ("drm/lcdif: switch to devm_drm_of_get_bridge")
commit a43dd76bacd0 ("drm/vc4: dsi: Switch to devm_drm_of_get_bridge")
And so:
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
|
{
"author": "\"Luca Ceresoli\" <luca.ceresoli@bootlin.com>",
"date": "Mon, 02 Feb 2026 18:07:45 +0100",
"thread_id": "20260123-feature_tilcdc-v5-0-5a44d2aa3f6f@bootlin.com.mbox.gz"
}
|
lkml
|
[PATCH v4] scripts/x86/intel: Add a script to update the old microcode list
|
The kernel maintains a table of minimum expected microcode revisions for
Intel CPUs in intel-ucode-defs.h. Systems with microcode older than
these revisions are flagged with X86_BUG_OLD_MICROCODE.
The static list of microcode revisions needs to be updated periodically
in response to releases of the official microcode at:
https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git.
Introduce a simple script to extract the revision information from the
microcode files and print it in the precise format expected by the
microcode header.
Maintaining the script in the kernel tree ensures a central location
that a submitter can use to generate the kernel-specific update. This
not only reduces the possibility of errors but also makes it easier to
validate the changes for reviewers and maintainers.
Typically, someone at Intel would see a new public release, wait for at
least three months to ensure the update is stable, run this script to
refresh the intel-ucode-defs.h file, and send a patch upstream to update
the mainline and stable versions.
Having a standard update script and a defined process minimizes the
ambiguity when refreshing the old microcode list. As always, there can
be exceptions to this process which should be supported with appropriate
justification.
Originally-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
v4:
- Add suggested timeline to the update process.
- Include platform ID information based on Dave's series:
https://lore.kernel.org/all/20260119195047.86E3C696@davehans-spike.ostc.intel.com/
This patch should be applied after the bug-fix series has merged.
v3: https://lore.kernel.org/lkml/20250825171510.3332029-1-sohil.mehta@intel.com/
- Include motivation for having the script in the kernel. (Boris)
- Update instructions to clarify typical usage. (Boris)
---
MAINTAINERS | 1 +
scripts/update-intel-ucode-defs.py | 128 +++++++++++++++++++++++++++++
2 files changed, 129 insertions(+)
create mode 100755 scripts/update-intel-ucode-defs.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 0d044a58cbfe..861c0c42c95d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28245,6 +28245,7 @@ S: Maintained
F: Documentation/admin-guide/hw-vuln/
F: arch/x86/include/asm/nospec-branch.h
F: arch/x86/kernel/cpu/bugs.c
+F: scripts/update-intel-ucode-defs.py
X86 MCE INFRASTRUCTURE
M: Tony Luck <tony.luck@intel.com>
diff --git a/scripts/update-intel-ucode-defs.py b/scripts/update-intel-ucode-defs.py
new file mode 100755
index 000000000000..50ec47cea1c5
--- /dev/null
+++ b/scripts/update-intel-ucode-defs.py
@@ -0,0 +1,128 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0
+import argparse
+import re
+import shutil
+import subprocess
+import sys
+import os
+
+script = os.path.relpath(__file__)
+
+DESCRIPTION = f"""
+For Intel CPUs, update the microcode revisions that determine
+X86_BUG_OLD_MICROCODE.
+
+This script is intended to be run in response to releases of the
+official Intel microcode GitHub repository:
+https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git
+
+It takes the Intel microcode files as input and uses iucode-tool to
+extract the revision information. It prints the output in the format
+expected by intel-ucode-defs.h.
+
+Usage:
+ ./{script} /path/to/microcode/files > /path/to/intel-ucode-defs.h
+
+Typically, someone at Intel would see a new public release, wait for at
+least three months to ensure the update is stable, run this script to
+refresh the intel-ucode-defs.h file, and send a patch upstream to update
+the mainline and stable versions.
+
+As always, there can be exceptions to the above process which should be
+supported by appropriate justification.
+"""
+
+parser = argparse.ArgumentParser(description=DESCRIPTION,
+ formatter_class=argparse.RawDescriptionHelpFormatter)
+parser.add_argument('ucode_files', nargs='+', help='Path(s) to the microcode files')
+
+args = parser.parse_args()
+
+# Process the microcode files using iucode-tool
+if shutil.which("iucode-tool") is None:
+ print("Error: iucode-tool not found, please install it", file=sys.stderr)
+ sys.exit(1)
+
+cmd = ['iucode-tool', '--list-all' ]
+cmd.extend(args.ucode_files)
+
+process = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+process.wait()
+if process.returncode != 0:
+ print("Error: iucode-tool ran into an error, exiting", file=sys.stderr)
+ sys.exit(1)
+
+# Functions to extract family, model, and stepping
+def bits(val, bottom, top):
+ mask = (1 << (top + 1 - bottom)) - 1
+ mask = mask << bottom
+ return (val & mask) >> bottom
+
+def family(sig):
+ if bits(sig, 8, 11) == 0xf:
+ return bits(sig, 8, 11) + bits(sig, 20, 27)
+ return bits(sig, 8, 11)
+
+def model(sig):
+ return bits(sig, 4, 7) | (bits(sig, 16, 19) << 4)
+
+def step(sig):
+ return bits(sig, 0, 3)
+
+# Parse the output of iucode-tool
+ucode_list = []
+for line in process.stdout:
+ if line.find(" sig ") == -1:
+ continue
+ sig = re.search('sig (0x[0-9a-fA-F]+)', line).group(1)
+ rev = re.search('rev (0x[0-9a-fA-F]+)', line).group(1)
+ pfm = re.search('pf_mask (0x[0-9a-fA-F]+)', line).group(1)
+ sig = int(sig, 16)
+ rev = int(rev, 16)
+ pfm = int(pfm, 16)
+ debug_rev = bits(rev, 31, 31)
+ if debug_rev != 0:
+ print("Error: Debug ucode file found, exiting", file=sys.stderr)
+ sys.exit(1)
+
+ ucrev = {}
+ ucrev['sig'] = sig
+ ucrev['platforms'] = pfm
+ ucrev['rev'] = rev
+ ucode_list.append(ucrev)
+
+# Remove duplicates, if any
+ucode_dict = {}
+for rev in ucode_list:
+ ucode_key = (rev['sig'], rev['platforms'])
+ existing = ucode_dict.get(ucode_key)
+ if existing is not None:
+ # If the existing one is newer, just move on:
+ if existing['rev'] > rev['rev']:
+ continue
+ ucode_dict[ucode_key] = rev
+
+# Prepare the microcode entries
+ucode_entries = []
+for ucode_key in ucode_dict:
+ rev = ucode_dict[ucode_key]
+ sig = rev['sig']
+ ucode_entries.append({
+ 'family': family(sig),
+ 'model': model(sig),
+ 'steppings': 1 << step(sig),
+ 'platforms': rev['platforms'],
+ 'rev': rev['rev'],
+ 'sig': sig
+ })
+
+if not ucode_entries:
+ print("Error: No valid microcode files found, exiting", file=sys.stderr)
+ sys.exit(1)
+
+# Sort and print the microcode entries
+ucode_entries.sort(key=lambda x: (x['family'], x['model'], x['steppings'], x['platforms']))
+for entry in ucode_entries:
+ print("{ .flags = X86_CPU_ID_FLAG_ENTRY_VALID, .vendor = X86_VENDOR_INTEL, .family = 0x%x, .model = 0x%02x, .steppings = 0x%04x, .platform_mask = 0x%02x, .driver_data = 0x%x }," %
+ (entry['family'], entry['model'], entry['steppings'], entry['platforms'], entry['rev']))
--
2.43.0
|
On 30/01/2026 7:47 pm, Sohil Mehta wrote:
return (val >> bottom) & mask
This is crying out for a small class, and for the use of set()
Try the attached version, which is rather more pythonic.
~Andrew
|
{
"author": "Andrew Cooper <andrew.cooper3@citrix.com>",
"date": "Fri, 30 Jan 2026 22:00:38 +0000",
"thread_id": "5e3dc792-c5aa-4024-b2a3-32db49da8132@intel.com.mbox.gz"
}
|
lkml
|
[PATCH v4] scripts/x86/intel: Add a script to update the old microcode list
|
The kernel maintains a table of minimum expected microcode revisions for
Intel CPUs in intel-ucode-defs.h. Systems with microcode older than
these revisions are flagged with X86_BUG_OLD_MICROCODE.
The static list of microcode revisions needs to be updated periodically
in response to releases of the official microcode at:
https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git.
Introduce a simple script to extract the revision information from the
microcode files and print it in the precise format expected by the
microcode header.
Maintaining the script in the kernel tree ensures a central location
that a submitter can use to generate the kernel-specific update. This
not only reduces the possibility of errors but also makes it easier to
validate the changes for reviewers and maintainers.
Typically, someone at Intel would see a new public release, wait for at
least three months to ensure the update is stable, run this script to
refresh the intel-ucode-defs.h file, and send a patch upstream to update
the mainline and stable versions.
Having a standard update script and a defined process minimizes the
ambiguity when refreshing the old microcode list. As always, there can
be exceptions to this process which should be supported with appropriate
justification.
Originally-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
v4:
- Add suggested timeline to the update process.
- Include platform ID information based on Dave's series:
https://lore.kernel.org/all/20260119195047.86E3C696@davehans-spike.ostc.intel.com/
This patch should be applied after the bug-fix series has merged.
v3: https://lore.kernel.org/lkml/20250825171510.3332029-1-sohil.mehta@intel.com/
- Include motivation for having the script in the kernel. (Boris)
- Update instructions to clarify typical usage. (Boris)
---
MAINTAINERS | 1 +
scripts/update-intel-ucode-defs.py | 128 +++++++++++++++++++++++++++++
2 files changed, 129 insertions(+)
create mode 100755 scripts/update-intel-ucode-defs.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 0d044a58cbfe..861c0c42c95d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28245,6 +28245,7 @@ S: Maintained
F: Documentation/admin-guide/hw-vuln/
F: arch/x86/include/asm/nospec-branch.h
F: arch/x86/kernel/cpu/bugs.c
+F: scripts/update-intel-ucode-defs.py
X86 MCE INFRASTRUCTURE
M: Tony Luck <tony.luck@intel.com>
diff --git a/scripts/update-intel-ucode-defs.py b/scripts/update-intel-ucode-defs.py
new file mode 100755
index 000000000000..50ec47cea1c5
--- /dev/null
+++ b/scripts/update-intel-ucode-defs.py
@@ -0,0 +1,128 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0
+import argparse
+import re
+import shutil
+import subprocess
+import sys
+import os
+
+script = os.path.relpath(__file__)
+
+DESCRIPTION = f"""
+For Intel CPUs, update the microcode revisions that determine
+X86_BUG_OLD_MICROCODE.
+
+This script is intended to be run in response to releases of the
+official Intel microcode GitHub repository:
+https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git
+
+It takes the Intel microcode files as input and uses iucode-tool to
+extract the revision information. It prints the output in the format
+expected by intel-ucode-defs.h.
+
+Usage:
+ ./{script} /path/to/microcode/files > /path/to/intel-ucode-defs.h
+
+Typically, someone at Intel would see a new public release, wait for at
+least three months to ensure the update is stable, run this script to
+refresh the intel-ucode-defs.h file, and send a patch upstream to update
+the mainline and stable versions.
+
+As always, there can be exceptions to the above process which should be
+supported by appropriate justification.
+"""
+
+parser = argparse.ArgumentParser(description=DESCRIPTION,
+ formatter_class=argparse.RawDescriptionHelpFormatter)
+parser.add_argument('ucode_files', nargs='+', help='Path(s) to the microcode files')
+
+args = parser.parse_args()
+
+# Process the microcode files using iucode-tool
+if shutil.which("iucode-tool") is None:
+ print("Error: iucode-tool not found, please install it", file=sys.stderr)
+ sys.exit(1)
+
+cmd = ['iucode-tool', '--list-all' ]
+cmd.extend(args.ucode_files)
+
+process = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+process.wait()
+if process.returncode != 0:
+ print("Error: iucode-tool ran into an error, exiting", file=sys.stderr)
+ sys.exit(1)
+
+# Functions to extract family, model, and stepping
+def bits(val, bottom, top):
+ mask = (1 << (top + 1 - bottom)) - 1
+ mask = mask << bottom
+ return (val & mask) >> bottom
+
+def family(sig):
+ if bits(sig, 8, 11) == 0xf:
+ return bits(sig, 8, 11) + bits(sig, 20, 27)
+ return bits(sig, 8, 11)
+
+def model(sig):
+ return bits(sig, 4, 7) | (bits(sig, 16, 19) << 4)
+
+def step(sig):
+ return bits(sig, 0, 3)
+
+# Parse the output of iucode-tool
+ucode_list = []
+for line in process.stdout:
+ if line.find(" sig ") == -1:
+ continue
+ sig = re.search('sig (0x[0-9a-fA-F]+)', line).group(1)
+ rev = re.search('rev (0x[0-9a-fA-F]+)', line).group(1)
+ pfm = re.search('pf_mask (0x[0-9a-fA-F]+)', line).group(1)
+ sig = int(sig, 16)
+ rev = int(rev, 16)
+ pfm = int(pfm, 16)
+ debug_rev = bits(rev, 31, 31)
+ if debug_rev != 0:
+ print("Error: Debug ucode file found, exiting", file=sys.stderr)
+ sys.exit(1)
+
+ ucrev = {}
+ ucrev['sig'] = sig
+ ucrev['platforms'] = pfm
+ ucrev['rev'] = rev
+ ucode_list.append(ucrev)
+
+# Remove duplicates, if any
+ucode_dict = {}
+for rev in ucode_list:
+ ucode_key = (rev['sig'], rev['platforms'])
+ existing = ucode_dict.get(ucode_key)
+ if existing is not None:
+ # If the existing one is newer, just move on:
+ if existing['rev'] > rev['rev']:
+ continue
+ ucode_dict[ucode_key] = rev
+
+# Prepare the microcode entries
+ucode_entries = []
+for ucode_key in ucode_dict:
+ rev = ucode_dict[ucode_key]
+ sig = rev['sig']
+ ucode_entries.append({
+ 'family': family(sig),
+ 'model': model(sig),
+ 'steppings': 1 << step(sig),
+ 'platforms': rev['platforms'],
+ 'rev': rev['rev'],
+ 'sig': sig
+ })
+
+if not ucode_entries:
+ print("Error: No valid microcode files found, exiting", file=sys.stderr)
+ sys.exit(1)
+
+# Sort and print the microcode entries
+ucode_entries.sort(key=lambda x: (x['family'], x['model'], x['steppings'], x['platforms']))
+for entry in ucode_entries:
+ print("{ .flags = X86_CPU_ID_FLAG_ENTRY_VALID, .vendor = X86_VENDOR_INTEL, .family = 0x%x, .model = 0x%02x, .steppings = 0x%04x, .platform_mask = 0x%02x, .driver_data = 0x%x }," %
+ (entry['family'], entry['model'], entry['steppings'], entry['platforms'], entry['rev']))
--
2.43.0
|
On 1/30/2026 2:00 PM, Andrew Cooper wrote:
Yup, that is better. Saves an extra step/line.
Thank you for improving the script. It looks cleaner and "pythonic". It
works for my usage with unique ucode files in a single directory.
Dave probably has a use case where he passes multiple directories to the
script. IIUC, the new version just inserts a unique entry for every FMS
+ pf_mask and skips the repeats. But it doesn't necessarily use the
latest revision for the duplicates. We probably need an equivalent logic
for this:
if existing is not None:
# If the existing one is newer, just move on:
if existing['rev'] > rev['rev']:
continue
Dave, opinion?
|
{
"author": "Sohil Mehta <sohil.mehta@intel.com>",
"date": "Fri, 30 Jan 2026 15:09:35 -0800",
"thread_id": "5e3dc792-c5aa-4024-b2a3-32db49da8132@intel.com.mbox.gz"
}
|
lkml
|
[PATCH v4] scripts/x86/intel: Add a script to update the old microcode list
|
The kernel maintains a table of minimum expected microcode revisions for
Intel CPUs in intel-ucode-defs.h. Systems with microcode older than
these revisions are flagged with X86_BUG_OLD_MICROCODE.
The static list of microcode revisions needs to be updated periodically
in response to releases of the official microcode at:
https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git.
Introduce a simple script to extract the revision information from the
microcode files and print it in the precise format expected by the
microcode header.
Maintaining the script in the kernel tree ensures a central location
that a submitter can use to generate the kernel-specific update. This
not only reduces the possibility of errors but also makes it easier to
validate the changes for reviewers and maintainers.
Typically, someone at Intel would see a new public release, wait for at
least three months to ensure the update is stable, run this script to
refresh the intel-ucode-defs.h file, and send a patch upstream to update
the mainline and stable versions.
Having a standard update script and a defined process minimizes the
ambiguity when refreshing the old microcode list. As always, there can
be exceptions to this process which should be supported with appropriate
justification.
Originally-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
v4:
- Add suggested timeline to the update process.
- Include platform ID information based on Dave's series:
https://lore.kernel.org/all/20260119195047.86E3C696@davehans-spike.ostc.intel.com/
This patch should be applied after the bug-fix series has merged.
v3: https://lore.kernel.org/lkml/20250825171510.3332029-1-sohil.mehta@intel.com/
- Include motivation for having the script in the kernel. (Boris)
- Update instructions to clarify typical usage. (Boris)
---
MAINTAINERS | 1 +
scripts/update-intel-ucode-defs.py | 128 +++++++++++++++++++++++++++++
2 files changed, 129 insertions(+)
create mode 100755 scripts/update-intel-ucode-defs.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 0d044a58cbfe..861c0c42c95d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28245,6 +28245,7 @@ S: Maintained
F: Documentation/admin-guide/hw-vuln/
F: arch/x86/include/asm/nospec-branch.h
F: arch/x86/kernel/cpu/bugs.c
+F: scripts/update-intel-ucode-defs.py
X86 MCE INFRASTRUCTURE
M: Tony Luck <tony.luck@intel.com>
diff --git a/scripts/update-intel-ucode-defs.py b/scripts/update-intel-ucode-defs.py
new file mode 100755
index 000000000000..50ec47cea1c5
--- /dev/null
+++ b/scripts/update-intel-ucode-defs.py
@@ -0,0 +1,128 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0
+import argparse
+import re
+import shutil
+import subprocess
+import sys
+import os
+
+script = os.path.relpath(__file__)
+
+DESCRIPTION = f"""
+For Intel CPUs, update the microcode revisions that determine
+X86_BUG_OLD_MICROCODE.
+
+This script is intended to be run in response to releases of the
+official Intel microcode GitHub repository:
+https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git
+
+It takes the Intel microcode files as input and uses iucode-tool to
+extract the revision information. It prints the output in the format
+expected by intel-ucode-defs.h.
+
+Usage:
+ ./{script} /path/to/microcode/files > /path/to/intel-ucode-defs.h
+
+Typically, someone at Intel would see a new public release, wait for at
+least three months to ensure the update is stable, run this script to
+refresh the intel-ucode-defs.h file, and send a patch upstream to update
+the mainline and stable versions.
+
+As always, there can be exceptions to the above process which should be
+supported by appropriate justification.
+"""
+
+parser = argparse.ArgumentParser(description=DESCRIPTION,
+ formatter_class=argparse.RawDescriptionHelpFormatter)
+parser.add_argument('ucode_files', nargs='+', help='Path(s) to the microcode files')
+
+args = parser.parse_args()
+
+# Process the microcode files using iucode-tool
+if shutil.which("iucode-tool") is None:
+ print("Error: iucode-tool not found, please install it", file=sys.stderr)
+ sys.exit(1)
+
+cmd = ['iucode-tool', '--list-all' ]
+cmd.extend(args.ucode_files)
+
+process = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+process.wait()
+if process.returncode != 0:
+ print("Error: iucode-tool ran into an error, exiting", file=sys.stderr)
+ sys.exit(1)
+
+# Functions to extract family, model, and stepping
+def bits(val, bottom, top):
+ mask = (1 << (top + 1 - bottom)) - 1
+ mask = mask << bottom
+ return (val & mask) >> bottom
+
+def family(sig):
+ if bits(sig, 8, 11) == 0xf:
+ return bits(sig, 8, 11) + bits(sig, 20, 27)
+ return bits(sig, 8, 11)
+
+def model(sig):
+ return bits(sig, 4, 7) | (bits(sig, 16, 19) << 4)
+
+def step(sig):
+ return bits(sig, 0, 3)
+
+# Parse the output of iucode-tool
+ucode_list = []
+for line in process.stdout:
+ if line.find(" sig ") == -1:
+ continue
+ sig = re.search('sig (0x[0-9a-fA-F]+)', line).group(1)
+ rev = re.search('rev (0x[0-9a-fA-F]+)', line).group(1)
+ pfm = re.search('pf_mask (0x[0-9a-fA-F]+)', line).group(1)
+ sig = int(sig, 16)
+ rev = int(rev, 16)
+ pfm = int(pfm, 16)
+ debug_rev = bits(rev, 31, 31)
+ if debug_rev != 0:
+ print("Error: Debug ucode file found, exiting", file=sys.stderr)
+ sys.exit(1)
+
+ ucrev = {}
+ ucrev['sig'] = sig
+ ucrev['platforms'] = pfm
+ ucrev['rev'] = rev
+ ucode_list.append(ucrev)
+
+# Remove duplicates, if any
+ucode_dict = {}
+for rev in ucode_list:
+ ucode_key = (rev['sig'], rev['platforms'])
+ existing = ucode_dict.get(ucode_key)
+ if existing is not None:
+ # If the existing one is newer, just move on:
+ if existing['rev'] > rev['rev']:
+ continue
+ ucode_dict[ucode_key] = rev
+
+# Prepare the microcode entries
+ucode_entries = []
+for ucode_key in ucode_dict:
+ rev = ucode_dict[ucode_key]
+ sig = rev['sig']
+ ucode_entries.append({
+ 'family': family(sig),
+ 'model': model(sig),
+ 'steppings': 1 << step(sig),
+ 'platforms': rev['platforms'],
+ 'rev': rev['rev'],
+ 'sig': sig
+ })
+
+if not ucode_entries:
+ print("Error: No valid microcode files found, exiting", file=sys.stderr)
+ sys.exit(1)
+
+# Sort and print the microcode entries
+ucode_entries.sort(key=lambda x: (x['family'], x['model'], x['steppings'], x['platforms']))
+for entry in ucode_entries:
+ print("{ .flags = X86_CPU_ID_FLAG_ENTRY_VALID, .vendor = X86_VENDOR_INTEL, .family = 0x%x, .model = 0x%02x, .steppings = 0x%04x, .platform_mask = 0x%02x, .driver_data = 0x%x }," %
+ (entry['family'], entry['model'], entry['steppings'], entry['platforms'], entry['rev']))
--
2.43.0
|
On 1/30/26 15:09, Sohil Mehta wrote:
I can't think of a case where I wanted to use multiple directories for a
single run of the script. The only thing I tend to do is switch between
the distr-provided ucode in /lib/firmware and a local clone of the Intel
microcode git repo. So, one or the other, not both at once.
|
{
"author": "Dave Hansen <dave.hansen@intel.com>",
"date": "Mon, 2 Feb 2026 10:01:10 -0800",
"thread_id": "5e3dc792-c5aa-4024-b2a3-32db49da8132@intel.com.mbox.gz"
}
|
lkml
|
[PATCH] Revert "drm/amd: Check if ASPM is enabled from PCIe subsystem"
|
This reverts commit 7294863a6f01248d72b61d38478978d638641bee.
This commit was erroneously applied again after commit 0ab5d711ec74
("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
removed it, leading to very hard to debug crashes, when used with a system with two
AMD GPUs of which only one supports ASPM.
Link: https://lore.kernel.org/linux-acpi/20251006120944.7880-1-spasswolf@web.de/
Link: https://github.com/acpica/acpica/issues/1060
Fixes: 0ab5d711ec74 ("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d6d0a6e34c6b..95d26f086d54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2405,9 +2405,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
return -ENODEV;
}
- if (amdgpu_aspm == -1 && !pcie_aspm_enabled(pdev))
- amdgpu_aspm = 0;
-
if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(pdev, flags & AMD_ASIC_MASK))
supports_atomic = true;
--
2.47.3
|
On 1/31/26 6:24 PM, Bert Karwatzki wrote:
Amazing detective work, thanks so much.
This added the code initially:
cba07cce39ace drm/amd: Check if ASPM is enabled from PCIe subsystem
This effectively removed it:
0ab5d711ec74d drm/amd: Refactor `amdgpu_aspm` to be evaluated per device
This was the accidental re-apply:
7294863a6f012 drm/amd: Check if ASPM is enabled from PCIe subsystem
It looks like this as right on the edge of the 5.17-rc6 and 5.18-rc1.
I think drm-fixes-2022-02-25 and amd-drm-next-5.18-2022-02-25 ended up
with different content.
Nonethless this is the correct change and I've applied it to
amd-staging-drm-next.
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
|
{
"author": "Mario Limonciello <superm1@kernel.org>",
"date": "Mon, 2 Feb 2026 08:25:34 -0600",
"thread_id": "15517fd926161aee77b4df2ffa8bab4bd08eab9a.camel@web.de.mbox.gz"
}
|
lkml
|
[PATCH] Revert "drm/amd: Check if ASPM is enabled from PCIe subsystem"
|
This reverts commit 7294863a6f01248d72b61d38478978d638641bee.
This commit was erroneously applied again after commit 0ab5d711ec74
("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
removed it, leading to very hard to debug crashes, when used with a system with two
AMD GPUs of which only one supports ASPM.
Link: https://lore.kernel.org/linux-acpi/20251006120944.7880-1-spasswolf@web.de/
Link: https://github.com/acpica/acpica/issues/1060
Fixes: 0ab5d711ec74 ("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d6d0a6e34c6b..95d26f086d54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2405,9 +2405,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
return -ENODEV;
}
- if (amdgpu_aspm == -1 && !pcie_aspm_enabled(pdev))
- amdgpu_aspm = 0;
-
if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(pdev, flags & AMD_ASIC_MASK))
supports_atomic = true;
--
2.47.3
|
On 2/2/26 15:25, Mario Limonciello wrote:
Reviewed-by: Christian König <christian.koenig@amd.com>
There is just one major question left: Why is disabling ASPM causing problems?
I mean we had tons of problems with ASPM before, but only by accidentally enabling it and never accidentally disabling it.
IIRC we even suggested to disable ASPM as possible workaround.
Thanks,
Christian.
|
{
"author": "=?UTF-8?Q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>",
"date": "Mon, 2 Feb 2026 15:35:31 +0100",
"thread_id": "15517fd926161aee77b4df2ffa8bab4bd08eab9a.camel@web.de.mbox.gz"
}
|
lkml
|
[PATCH] Revert "drm/amd: Check if ASPM is enabled from PCIe subsystem"
|
This reverts commit 7294863a6f01248d72b61d38478978d638641bee.
This commit was erroneously applied again after commit 0ab5d711ec74
("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
removed it, leading to very hard to debug crashes, when used with a system with two
AMD GPUs of which only one supports ASPM.
Link: https://lore.kernel.org/linux-acpi/20251006120944.7880-1-spasswolf@web.de/
Link: https://github.com/acpica/acpica/issues/1060
Fixes: 0ab5d711ec74 ("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d6d0a6e34c6b..95d26f086d54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2405,9 +2405,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
return -ENODEV;
}
- if (amdgpu_aspm == -1 && !pcie_aspm_enabled(pdev))
- amdgpu_aspm = 0;
-
if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(pdev, flags & AMD_ASIC_MASK))
supports_atomic = true;
--
2.47.3
|
On 2/2/26 8:35 AM, Christian König wrote:
My theory is that it's a mismatch of PCIe core and AMDGPU. IE if the
PCIe core thinks it's enabled but amdgpu thinks it is disabled can hit
some corner scenarios.
|
{
"author": "Mario Limonciello <superm1@kernel.org>",
"date": "Mon, 2 Feb 2026 10:11:02 -0600",
"thread_id": "15517fd926161aee77b4df2ffa8bab4bd08eab9a.camel@web.de.mbox.gz"
}
|
lkml
|
[PATCH] Revert "drm/amd: Check if ASPM is enabled from PCIe subsystem"
|
This reverts commit 7294863a6f01248d72b61d38478978d638641bee.
This commit was erroneously applied again after commit 0ab5d711ec74
("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
removed it, leading to very hard to debug crashes, when used with a system with two
AMD GPUs of which only one supports ASPM.
Link: https://lore.kernel.org/linux-acpi/20251006120944.7880-1-spasswolf@web.de/
Link: https://github.com/acpica/acpica/issues/1060
Fixes: 0ab5d711ec74 ("drm/amd: Refactor `amdgpu_aspm` to be evaluated per device")
Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d6d0a6e34c6b..95d26f086d54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2405,9 +2405,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
return -ENODEV;
}
- if (amdgpu_aspm == -1 && !pcie_aspm_enabled(pdev))
- amdgpu_aspm = 0;
-
if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(pdev, flags & AMD_ASIC_MASK))
supports_atomic = true;
--
2.47.3
|
Am Montag, dem 02.02.2026 um 10:11 -0600 schrieb Mario Limonciello:
That's also my theory. In my case the discrete GPU is probed first
[ 1.652505] [ T194] amdgpu 0000:03:00.0: enabling device (0000 -> 0002)
[ 1.658662] [ T194] amdgpu 0000:03:00.0: amdgpu: initializing kernel modesetting (DIMGREY_CAVEFISH 0x1002:0x73FF 0x1462:0x1313 0xC3).
[ 1.665045] [ T194] amdgpu 0000:03:00.0: amdgpu: register mmio base: 0xFCA00000
[ 1.671399] [ T194] amdgpu 0000:03:00.0: amdgpu: register mmio size: 1048576
[ 1.681596] [ T194] amdgpu 0000:03:00.0: amdgpu: detected ip block number 0 <common_v1_0_0> (nv_common)
then the built-in GPU is probed and set amdgpu_aspm = 0.
[ 4.883191] [ T194] amdgpu 0000:08:00.0: enabling device (0006 -> 0007)
[ 4.890078] [ T194] amdgpu 0000:08:00.0: amdgpu: initializing kernel modesetting (RENOIR 0x1002:0x1638 0x1462:0x1313 0xC5).
[ 4.895907] [ T194] amdgpu 0000:08:00.0: amdgpu: register mmio base: 0xFC900000
[ 4.901640] [ T194] amdgpu 0000:08:00.0: amdgpu: register mmio size: 524288
[ 4.909833] [ T194] amdgpu 0000:08:00.0: amdgpu: detected ip block number 0 <common_v2_0_0> (soc15_common)
I'm going to monitor calls to amdgpu_device_should_use_aspm() to check if it's called during
the suspend/resumes cycle giving the wrong answer (i.e. false when ASPM is actually enabled)
Bert Karwatzki
|
{
"author": "Bert Karwatzki <spasswolf@web.de>",
"date": "Mon, 02 Feb 2026 17:43:31 +0100",
"thread_id": "15517fd926161aee77b4df2ffa8bab4bd08eab9a.camel@web.de.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/23/2026 2:20 PM, Stanislav Kinsburskii wrote:
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
|
{
"author": "Nuno Das Neves <nunodasneves@linux.microsoft.com>",
"date": "Fri, 23 Jan 2026 16:09:49 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/23/26 14:20, Stanislav Kinsburskii wrote:
Will this affect CRASH kexec? I see few CONFIG_CRASH_DUMP in kexec.c
implying that crash dump might be involved. Or did you test kdump
and it was fine?
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Fri, 23 Jan 2026 16:16:33 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 23, 2026 at 04:16:33PM -0800, Mukesh R wrote:
Yes, it will. Crash kexec depends on normal kexec functionality, so it
will be affected as well.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Sun, 25 Jan 2026 14:39:26 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 23, 2026 at 10:20:53PM +0000, Stanislav Kinsburskii wrote:
Someone might want to stop all guest VMs and do a kexec. Which is valid
and would work without any issue for L1VH.
Also, I don't think it is reasonable at all that someone needs to
disable basic kernel functionality such as kexec in order to use our
driver.
Thanks,
Anirudh.
|
{
"author": "Anirudh Rayabharam <anirudh@anirudhrb.com>",
"date": "Tue, 27 Jan 2026 00:19:24 +0530",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/25/26 14:39, Stanislav Kinsburskii wrote:
So not sure I understand the reason for this patch. We can just block
kexec if there are any VMs running, right? Doing this would mean any
further developement would be without a ver important and major feature,
right?
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Mon, 26 Jan 2026 12:20:09 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Mon, Jan 26, 2026 at 12:20:09PM -0800, Mukesh R wrote:
This is an option. But until it's implemented and merged, a user mshv
driver gets into a situation where kexec is broken in a non-obvious way.
The system may crash at any time after kexec, depending on whether the
new kernel touches the pages deposited to hypervisor or not. This is a
bad user experience.
Therefor it should be explicitly forbidden as it's essentially not
supported yet.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Mon, 26 Jan 2026 12:43:58 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Tue, Jan 27, 2026 at 12:19:24AM +0530, Anirudh Rayabharam wrote:
No, it won't work and hypervsisor depostied pages won't be withdrawn.
Also, kernel consisntency must no depend on use space behavior.
It's a temporary measure until proper page lifecycle management is
supported in the driver.
Mutual exclusion of the driver and kexec is given and thus should be
expclitily stated in the Kconfig.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Mon, 26 Jan 2026 12:46:44 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/26/26 12:43, Stanislav Kinsburskii wrote:
I understand that. But with this we cannot collect core and debug any
crashes. I was thinking there would be a quick way to prohibit kexec
for update via notifier or some other quick hack. Did you already
explore that and didn't find anything, hence this?
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Mon, 26 Jan 2026 15:07:18 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Mon, Jan 26, 2026 at 03:07:18PM -0800, Mukesh R wrote:
This quick hack you mention isn't quick in the upstream kernel as there
is no hook to interrupt kexec process except the live update one.
I sent an RFC for that one but given todays conversation details is
won't be accepted as is.
Making mshv mutually exclusive with kexec is the only viable option for
now given time constraints.
It is intended to be replaced with proper page lifecycle management in
the future.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Mon, 26 Jan 2026 16:21:43 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/26/26 16:21, Stanislav Kinsburskii wrote:
That's the one we want to interrupt and block right? crash kexec
is ok and should be allowed. We can document we don't support kexec
for update for now.
Are you taking about this?
"mshv: Add kexec safety for deposited pages"
Yeah, that could take a long time and imo we cannot just disable KEXEC
completely. What we want is just block kexec for updates from some
mshv file for now, we an print during boot that kexec for updates is
not supported on mshv. Hope that makes sense.
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Mon, 26 Jan 2026 17:39:49 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Mon, Jan 26, 2026 at 05:39:49PM -0800, Mukesh R wrote:
Yes.
The trade-off here is between disabling kexec support and having the
kernel crash after kexec in a non-obvious way. This affects both regular
kexec and crash kexec.
It’s a pity we can’t apply a quick hack to disable only regular kexec.
However, since crash kexec would hit the same issues, until we have a
proper state transition for deposted pages, the best workaround for now
is to reset the hypervisor state on every kexec, which needs design,
work, and testing.
Disabling kexec is the only consistent way to handle this in the
upstream kernel at the moment.
Thanks, Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Tue, 27 Jan 2026 09:47:01 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/27/26 09:47, Stanislav Kinsburskii wrote:
crash kexec on baremetal is not affected, hence disabling that
doesn't make sense as we can't debug crashes then on bm.
Let me think and explore a bit, and if I come up with something, I'll
send a patch here. If nothing, then we can do this as last resort.
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Tue, 27 Jan 2026 11:56:02 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
From: Mukesh R <mrathor@linux.microsoft.com> Sent: Tuesday, January 27, 2026 11:56 AM
Maybe you've already looked at this, but there's a sysctl parameter
kernel.kexec_load_limit_reboot that prevents loading a kexec
kernel for reboot if the value is zero. Separately, there is
kernel.kexec_load_limit_panic that controls whether a kexec
kernel can be loaded for kdump purposes.
kernel.kexec_load_limit_reboot defaults to -1, which allows an
unlimited number of loading a kexec kernel for reboot. But the value
can be set to zero with this kernel boot line parameter:
sysctl.kernel.kexec_load_limit_reboot=0
Alternatively, the mshv driver initialization could add code along
the lines of process_sysctl_arg() to open
/proc/sys/kernel/kexec_load_limit_reboot and write a value of zero.
Then there's no dependency on setting the kernel boot line.
The downside to either method is that after Linux in the root partition
is up-and-running, it is possible to change the sysctl to a non-zero value,
and then load a kexec kernel for reboot. So this approach isn't absolute
protection against doing a kexec for reboot. But it makes it harder, and
until there's a mechanism to reclaim the deposited pages, it might be
a viable compromise to allow kdump to still be used.
Just a thought ....
Michael
|
{
"author": "Michael Kelley <mhklinux@outlook.com>",
"date": "Wed, 28 Jan 2026 15:53:04 +0000",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Mon, Jan 26, 2026 at 12:46:44PM -0800, Stanislav Kinsburskii wrote:
All pages that were deposited in the context of a guest partition (i.e.
with the guest partition ID), would be withdrawn when you kill the VMs,
right? What other deposited pages would be left?
Thanks,
Anirudh.
|
{
"author": "Anirudh Rayabharam <anirudh@anirudhrb.com>",
"date": "Wed, 28 Jan 2026 16:16:31 +0000",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Tue, Jan 27, 2026 at 11:56:02AM -0800, Mukesh R wrote:
Bare metal support is not currently relevant, as it is not available.
This is the upstream kernel, and this driver will be accessible to
third-party customers beginning with kernel 6.19 for running their
kernels in Azure L1VH, so consistency is required.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Wed, 28 Jan 2026 15:08:30 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Wed, Jan 28, 2026 at 04:16:31PM +0000, Anirudh Rayabharam wrote:
The driver deposits two types of pages: one for the guests (withdrawn
upon gust shutdown) and the other - for the host itself (never
withdrawn).
See hv_call_create_partition, for example: it deposits pages for the
host partition.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Wed, 28 Jan 2026 15:11:14 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/28/26 07:53, Michael Kelley wrote:
Mmm...eee...weelll... i think i see a much easier way to do this by
just hijacking __kexec_lock. I will resume my normal work tmrw/Fri,
so let me test it out. if it works, will send patch Monday.
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Thu, 29 Jan 2026 18:52:59 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/28/26 15:08, Stanislav Kinsburskii wrote:
Well, without crashdump support, customers will not be running anything
anywhere.
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Thu, 29 Jan 2026 18:59:31 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Wed, Jan 28, 2026 at 03:11:14PM -0800, Stanislav Kinsburskii wrote:
Hmm.. I see. Is it not possible to reclaim this memory in module_exit?
Also, can't we forcefully kill all running partitions in module_exit and
then reclaim memory? Would this help with kernel consistency
irrespective of userspace behavior?
Thanks,
Anirudh.
|
{
"author": "Anirudh Rayabharam <anirudh@anirudhrb.com>",
"date": "Fri, 30 Jan 2026 17:11:12 +0000",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Thu, Jan 29, 2026 at 06:59:31PM -0800, Mukesh R wrote:
This is my concern too. I don't think customers will be particularly
happy that kexec doesn't work with our driver.
Thanks,
Anirudh
|
{
"author": "Anirudh Rayabharam <anirudh@anirudhrb.com>",
"date": "Fri, 30 Jan 2026 17:17:52 +0000",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 30, 2026 at 05:17:52PM +0000, Anirudh Rayabharam wrote:
I wasn’t clear earlier, so let me restate it. Today, kexec is not
supported in L1VH. This is a bug we have not fixed yet. Disabling kexec
is not a long-term solution. But it is better to disable it explicitly
than to have kernel crashes after kexec.
This does not mean the bug should not be fixed. But the upstream kernel
has its own policies and merge windows. For kernel 6.19, it is better to
have a clear kexec error than random crashes after kexec.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Fri, 30 Jan 2026 10:41:39 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 30, 2026 at 05:11:12PM +0000, Anirudh Rayabharam wrote:
It would, but this is sloppy and cannot be a long-term solution.
It is also not reliable. We have no hook to prevent kexec. So if we fail
to kill the guest or reclaim the memory for any reason, the new kernel
may still crash.
There are two long-term solutions:
1. Add a way to prevent kexec when there is shared state between the hypervisor and the kernel.
2. Hand the shared kernel state over to the new kernel.
I sent a series for the first one. The second one is not ready yet.
Anything else is neither robust nor reliable, so I don’t think it makes
sense to pursue it.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Fri, 30 Jan 2026 10:46:45 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/30/26 10:41, Stanislav Kinsburskii wrote:
I don't think there is disagreement on this. The undesired part is turning
off KEXEC config completely.
Thanks,
-Mukesh
|
{
"author": "Mukesh R <mrathor@linux.microsoft.com>",
"date": "Fri, 30 Jan 2026 11:47:48 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 30, 2026 at 10:46:45AM -0800, Stanislav Kinsburskii wrote:
Actually guests won't be running by the time we reach our module_exit
function during a kexec. Userspace processes would've been killed by
then.
Also, why is this sloppy? Isn't this what module_exit should be
doing anyway? If someone unloads our module we should be trying to
clean everything up (including killing guests) and reclaim memory.
In any case, we can BUG() out if we fail to reclaim the memory. That would
stop the kexec.
This is a better solution since instead of disabling KEXEC outright: our
driver made the best possible efforts to make kexec work.
I honestly think we should focus efforts on making kexec work rather
than finding ways to prevent it.
Thanks,
Anirudh
|
{
"author": "Anirudh Rayabharam <anirudh@anirudhrb.com>",
"date": "Fri, 30 Jan 2026 20:32:45 +0000",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 30, 2026 at 11:47:48AM -0800, Mukesh R wrote:
There is no disagreement on this either. If you have a better solution
that can be implemented and merged before next kernel merge window,
please propose it. Otherwise, this patch will remain as is for now.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Mon, 2 Feb 2026 08:43:37 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On 1/24/2026 3:50 AM, Stanislav Kinsburskii wrote:
I have not gone through entire conversation that has happened already on
this, but if you send a next version for this, please change commit msg
and subject to include MSHV_ROOT instead of MSHV, to avoid confusion.
Regards,
Naman
|
{
"author": "Naman Jain <namjain@linux.microsoft.com>",
"date": "Mon, 2 Feb 2026 22:26:10 +0530",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 30, 2026 at 08:32:45PM +0000, Anirudh Rayabharam wrote:
No, they will not: "kexec -e" doesn't kill user processes.
We must not rely on OS to do graceful shutdown before doing
kexec.
Kexec does not unload modules, but it doesn't really matter even if it
would.
There are other means to plug into the reboot flow, but neither of them
is robust or reliable.
By killing the whole system? This is not a good user experience and I
don't see how can this be justified.
How an unrealiable feature leading to potential system crashes is better
that disabling kexec outright?
It's a complete opposite story for me: the latter provides a limited,
but robust functionality, while the former provides an unreliable and
unpredictable behavior.
There is no argument about it. But until we have it fixed properly, we
have two options: either disable kexec or stop claiming we have our
driver up and ready for external customers. Giving the importance of
this driver for current projects, I believe the better way would be to
explicitly limit the functionality instead of postponing the
productization of the driver.
In other words, this is not about our fillings about kexec support: it's
about what we can reliably provide to our customers today.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Mon, 2 Feb 2026 09:10:00 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH] mshv: Make MSHV mutually exclusive with KEXEC
|
The MSHV driver deposits kernel-allocated pages to the hypervisor during
runtime and never withdraws them. This creates a fundamental incompatibility
with KEXEC, as these deposited pages remain unavailable to the new kernel
loaded via KEXEC, leading to potential system crashes upon kernel accessing
hypervisor deposited pages.
Make MSHV mutually exclusive with KEXEC until proper page lifecycle
management is implemented.
Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 7937ac0cbd0f..cfd4501db0fa 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -74,6 +74,7 @@ config MSHV_ROOT
# e.g. When withdrawing memory, the hypervisor gives back 4k pages in
# no particular order, making it impossible to reassemble larger pages
depends on PAGE_SIZE_4KB
+ depends on !KEXEC
select EVENTFD
select VIRT_XFER_TO_GUEST_WORK
select HMM_MIRROR
|
On Fri, Jan 30, 2026 at 05:11:12PM +0000, Anirudh Rayabharam wrote:
First, module_exit is not called during kexec. Second, forcefully
killing all partitions during a kexec reboot would be bulky,
error-prone, and slow. It also does not guarantee robust behavior. Too
many things can go wrong, and we could still end up in the same broken
state.
To reiterate: today, the only safe way to use kexec is to avoid any
shared state between the kernel and the hypervisor. In other words, that
state should never be created, or it must be destroyed before issuing
kexec.
Neither of this states is controlled by our driver, so the only safe
options yet is to disable kexec.
Thanks,
Stanislav
|
{
"author": "Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>",
"date": "Mon, 2 Feb 2026 10:09:38 -0800",
"thread_id": "26bdf7a9-91ea-4236-a5a6-d7f8571ab87b@linux.microsoft.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
./drivers/resctrl/mpam_internal.h: linux/srcu.h is included more than once.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=27328
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Acked-by: James Morse <james.morse@arm.com>
[BH: Keep alphabetical order]
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
drivers/resctrl/mpam_internal.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index e79c3c47259c..17cdc3080d58 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -12,7 +12,6 @@
#include <linux/jump_label.h>
#include <linux/llist.h>
#include <linux/mutex.h>
-#include <linux/srcu.h>
#include <linux/spinlock.h>
#include <linux/srcu.h>
#include <linux/types.h>
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:28 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
In the test__props_mismatch() kunit test we rely on the struct mpam_props
being packed to ensure memcmp doesn't consider packing. Making it packed
reduces the alignment of the features bitmap and so breaks a requirement
for the use of atomics. As we don't rely on the set/clear of these bits
being atomic, just make them non-atomic.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Add comment (Jonathan)
---
drivers/resctrl/mpam_internal.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 17cdc3080d58..e8971842b124 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -200,8 +200,12 @@ struct mpam_props {
} PACKED_FOR_KUNIT;
#define mpam_has_feature(_feat, x) test_bit(_feat, (x)->features)
-#define mpam_set_feature(_feat, x) set_bit(_feat, (x)->features)
-#define mpam_clear_feature(_feat, x) clear_bit(_feat, (x)->features)
+/*
+ * The non-atomic get/set operations are used because if struct mpam_props is
+ * packed, the alignment requirements for atomics aren't met.
+ */
+#define mpam_set_feature(_feat, x) __set_bit(_feat, (x)->features)
+#define mpam_clear_feature(_feat, x) __clear_bit(_feat, (x)->features)
/* The values for MSMON_CFG_MBWU_FLT.RWBW */
enum mon_filter_options {
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:29 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
The MPAMSM_EL1 register determines the MPAM configuration for an SMCU. Add
the register definition.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
arch/arm64/tools/sysreg | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg
index 8921b51866d6..afbb55c9b038 100644
--- a/arch/arm64/tools/sysreg
+++ b/arch/arm64/tools/sysreg
@@ -5052,6 +5052,14 @@ Field 31:16 PARTID_D
Field 15:0 PARTID_I
EndSysreg
+Sysreg MPAMSM_EL1 3 0 10 5 3
+Res0 63:48
+Field 47:40 PMG_D
+Res0 39:32
+Field 31:16 PARTID_D
+Res0 15:0
+EndSysreg
+
Sysreg ISR_EL1 3 0 12 1 0
Res0 63:11
Field 10 IS
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:30 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
When kvm enables or disables MPAM traps to EL2 it clears all other bits in
MPAM2_EL2. Notably, it clears the partition ids (PARTIDs) and performance
monitoring groups (PMGs). Avoid changing these bits in anticipation of
adding support for MPAM in the kernel. Otherwise, on a VHE system with the
host running at EL2 where MPAM2_EL2 and MPAM1_EL1 access the same register,
any attempt to use MPAM to monitor or partition resources for kernel space
would be foiled by running a KVM guest. Additionally, MPAM2_EL2.EnMPAMSM is
always set to 0 which causes MPAMSM_EL1 to always trap. Keep EnMPAMSM set
to 1 when not in a guest so that the kernel can use MPAMSM_EL1.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h
index c5d5e5b86eaf..63195275a8b8 100644
--- a/arch/arm64/kvm/hyp/include/hyp/switch.h
+++ b/arch/arm64/kvm/hyp/include/hyp/switch.h
@@ -269,7 +269,8 @@ static inline void __deactivate_traps_hfgxtr(struct kvm_vcpu *vcpu)
static inline void __activate_traps_mpam(struct kvm_vcpu *vcpu)
{
- u64 r = MPAM2_EL2_TRAPMPAM0EL1 | MPAM2_EL2_TRAPMPAM1EL1;
+ u64 clr = MPAM2_EL2_EnMPAMSM;
+ u64 set = MPAM2_EL2_TRAPMPAM0EL1 | MPAM2_EL2_TRAPMPAM1EL1;
if (!system_supports_mpam())
return;
@@ -279,18 +280,21 @@ static inline void __activate_traps_mpam(struct kvm_vcpu *vcpu)
write_sysreg_s(MPAMHCR_EL2_TRAP_MPAMIDR_EL1, SYS_MPAMHCR_EL2);
} else {
/* From v1.1 TIDR can trap MPAMIDR, set it unconditionally */
- r |= MPAM2_EL2_TIDR;
+ set |= MPAM2_EL2_TIDR;
}
- write_sysreg_s(r, SYS_MPAM2_EL2);
+ sysreg_clear_set_s(SYS_MPAM2_EL2, clr, set);
}
static inline void __deactivate_traps_mpam(void)
{
+ u64 clr = MPAM2_EL2_TRAPMPAM0EL1 | MPAM2_EL2_TRAPMPAM1EL1 | MPAM2_EL2_TIDR;
+ u64 set = MPAM2_EL2_EnMPAMSM;
+
if (!system_supports_mpam())
return;
- write_sysreg_s(0, SYS_MPAM2_EL2);
+ sysreg_clear_set_s(SYS_MPAM2_EL2, clr, set);
if (system_supports_mpam_hcr())
write_sysreg_s(MPAMHCR_HOST_FLAGS, SYS_MPAMHCR_EL2);
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:31 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
The MPAMSM_EL1 controls the MPAM labeling for an SMCU, Streaming Mode
Compute Unit. As there is on MPAM support in kvm, make sure MPAMSM_EL1
accesses trigger an UNDEF.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Remove paragraph from commit on allowed range of values
---
arch/arm64/kvm/sys_regs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index c8fd7c6a12a1..72654ab984ee 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -3373,6 +3373,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {
{ SYS_DESC(SYS_MPAM1_EL1), undef_access },
{ SYS_DESC(SYS_MPAM0_EL1), undef_access },
+ { SYS_DESC(SYS_MPAMSM_EL1), undef_access },
+
{ SYS_DESC(SYS_VBAR_EL1), access_rw, reset_val, VBAR_EL1, 0 },
{ SYS_DESC(SYS_DISR_EL1), NULL, reset_val, DISR_EL1, 0 },
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:32 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
MPAM allows traffic in the SoC to be labeled by the OS, these labels are
used to apply policy in caches and bandwidth regulators, and to monitor
traffic in the SoC. The label is made up of a PARTID and PMG value. The x86
equivalent calls these CLOSID and RMID, but they don't map precisely.
MPAM has two CPU system registers that is used to hold the PARTID and PMG
values that traffic generated at each exception level will use. These can
be set per-task by the resctrl file system. (resctrl is the defacto
interface for controlling this stuff).
Add a helper to switch this.
struct task_struct's separate CLOSID and RMID fields are insufficient to
implement resctrl using MPAM, as resctrl can change the PARTID (CLOSID) and
PMG (sort of like the RMID) separately. On x86, the rmid is an independent
number, so a race that writes a mismatched closid and rmid into hardware is
benign. On arm64, the pmg bits extend the partid.
(i.e. partid-5 has a pmg-0 that is not the same as partid-6's pmg-0). In
this case, mismatching the values will 'dirty' a pmg value that resctrl
believes is clean, and is not tracking with its 'limbo' code.
To avoid this, the partid and pmg are always read and written as a
pair. This requires a new u64 field. In struct task_struct there are two
u32, rmid and closid for the x86 case, but as we can't use them here do
something else. Add this new field, mpam_partid_pmg, to struct thread_info
to avoid adding more architecture specific code to struct task_struct.
Always use READ_ONCE()/WRITE_ONCE() when accessing this field.
Resctrl allows a per-cpu 'default' value to be set, this overrides the
values when scheduling a task in the default control-group, which has
PARTID 0. The way 'code data prioritisation' gets emulated means the
register value for the default group needs to be a variable.
The current system register value is kept in a per-cpu variable to avoid
writing to the system register if the value isn't going to change. Writes
to this register may reset the hardware state for regulating bandwidth.
Finally, there is no reason to context switch these registers unless there
is a driver changing the values in struct task_struct. Hide the whole thing
behind a static key. This also allows the driver to disable MPAM in
response to errors reported by hardware. Move the existing static key to
belong to the arch code, as in the future the MPAM driver may become a
loadable module.
All this should depend on whether there is an MPAM driver, hide it behind
CONFIG_ARM64_MPAM.
CC: Amit Singh Tomar <amitsinght@marvell.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
CONFIG_MPAM -> CONFIG_ARM64_MPAM in commit message
Remove extra DECLARE_STATIC_KEY_FALSE
Function name in comment, __mpam_sched_in() -> mpam_thread_switch()
Remove unused headers
Expand comment (Jonathan)
Changes since v2:
Tidy up ifdefs
---
arch/arm64/Kconfig | 2 +
arch/arm64/include/asm/mpam.h | 67 ++++++++++++++++++++++++++++
arch/arm64/include/asm/thread_info.h | 3 ++
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/mpam.c | 13 ++++++
arch/arm64/kernel/process.c | 7 +++
drivers/resctrl/mpam_devices.c | 2 -
drivers/resctrl/mpam_internal.h | 4 +-
8 files changed, 95 insertions(+), 4 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/kernel/mpam.c
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 93173f0a09c7..cdcc5b76a110 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -2049,6 +2049,8 @@ config ARM64_MPAM
MPAM is exposed to user-space via the resctrl pseudo filesystem.
+ This option enables the extra context switch code.
+
endmenu # "ARMv8.4 architectural features"
menu "ARMv8.5 architectural features"
diff --git a/arch/arm64/include/asm/mpam.h b/arch/arm64/include/asm/mpam.h
new file mode 100644
index 000000000000..14011e5970ce
--- /dev/null
+++ b/arch/arm64/include/asm/mpam.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2025 Arm Ltd. */
+
+#ifndef __ASM__MPAM_H
+#define __ASM__MPAM_H
+
+#include <linux/jump_label.h>
+#include <linux/percpu.h>
+#include <linux/sched.h>
+
+#include <asm/sysreg.h>
+
+DECLARE_STATIC_KEY_FALSE(mpam_enabled);
+DECLARE_PER_CPU(u64, arm64_mpam_default);
+DECLARE_PER_CPU(u64, arm64_mpam_current);
+
+/*
+ * The value of the MPAM0_EL1 sysreg when a task is in resctrl's default group.
+ * This is used by the context switch code to use the resctrl CPU property
+ * instead. The value is modified when CDP is enabled/disabled by mounting
+ * the resctrl filesystem.
+ */
+extern u64 arm64_mpam_global_default;
+
+/*
+ * The resctrl filesystem writes to the partid/pmg values for threads and CPUs,
+ * which may race with reads in mpam_thread_switch(). Ensure only one of the old
+ * or new values are used. Particular care should be taken with the pmg field as
+ * mpam_thread_switch() may read a partid and pmg that don't match, causing this
+ * value to be stored with cache allocations, despite being considered 'free' by
+ * resctrl.
+ */
+#ifdef CONFIG_ARM64_MPAM
+static inline u64 mpam_get_regval(struct task_struct *tsk)
+{
+ return READ_ONCE(task_thread_info(tsk)->mpam_partid_pmg);
+}
+
+static inline void mpam_thread_switch(struct task_struct *tsk)
+{
+ u64 oldregval;
+ int cpu = smp_processor_id();
+ u64 regval = mpam_get_regval(tsk);
+
+ if (!static_branch_likely(&mpam_enabled))
+ return;
+
+ if (regval == READ_ONCE(arm64_mpam_global_default))
+ regval = READ_ONCE(per_cpu(arm64_mpam_default, cpu));
+
+ oldregval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
+ if (oldregval == regval)
+ return;
+
+ write_sysreg_s(regval, SYS_MPAM1_EL1);
+ isb();
+
+ /* Synchronising the EL0 write is left until the ERET to EL0 */
+ write_sysreg_s(regval, SYS_MPAM0_EL1);
+
+ WRITE_ONCE(per_cpu(arm64_mpam_current, cpu), regval);
+}
+#else
+static inline void mpam_thread_switch(struct task_struct *tsk) {}
+#endif /* CONFIG_ARM64_MPAM */
+
+#endif /* __ASM__MPAM_H */
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index a803b887b0b4..fc801a26ff9e 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -41,6 +41,9 @@ struct thread_info {
#ifdef CONFIG_SHADOW_CALL_STACK
void *scs_base;
void *scs_sp;
+#endif
+#ifdef CONFIG_ARM64_MPAM
+ u64 mpam_partid_pmg;
#endif
u32 cpu;
};
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 76f32e424065..15979f366519 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o
obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o
obj-$(CONFIG_ARM64_PTR_AUTH) += pointer_auth.o
+obj-$(CONFIG_ARM64_MPAM) += mpam.o
obj-$(CONFIG_ARM64_MTE) += mte.o
obj-y += vdso-wrap.o
obj-$(CONFIG_COMPAT_VDSO) += vdso32-wrap.o
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
new file mode 100644
index 000000000000..9866d2ca0faa
--- /dev/null
+++ b/arch/arm64/kernel/mpam.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2025 Arm Ltd. */
+
+#include <asm/mpam.h>
+
+#include <linux/jump_label.h>
+#include <linux/percpu.h>
+
+DEFINE_STATIC_KEY_FALSE(mpam_enabled);
+DEFINE_PER_CPU(u64, arm64_mpam_default);
+DEFINE_PER_CPU(u64, arm64_mpam_current);
+
+u64 arm64_mpam_global_default;
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 489554931231..47698955fa1e 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -51,6 +51,7 @@
#include <asm/fpsimd.h>
#include <asm/gcs.h>
#include <asm/mmu_context.h>
+#include <asm/mpam.h>
#include <asm/mte.h>
#include <asm/processor.h>
#include <asm/pointer_auth.h>
@@ -738,6 +739,12 @@ struct task_struct *__switch_to(struct task_struct *prev,
if (prev->thread.sctlr_user != next->thread.sctlr_user)
update_sctlr_el1(next->thread.sctlr_user);
+ /*
+ * MPAM thread switch happens after the DSB to ensure prev's accesses
+ * use prev's MPAM settings.
+ */
+ mpam_thread_switch(next);
+
/* the actual thread switch */
last = cpu_switch_to(prev, next);
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index b495d5291868..860181266b15 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -29,8 +29,6 @@
#include "mpam_internal.h"
-DEFINE_STATIC_KEY_FALSE(mpam_enabled); /* This moves to arch code */
-
/*
* mpam_list_lock protects the SRCU lists when writing. Once the
* mpam_enabled key is enabled these lists are read-only,
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index e8971842b124..4632985bcca6 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -16,12 +16,12 @@
#include <linux/srcu.h>
#include <linux/types.h>
+#include <asm/mpam.h>
+
#define MPAM_MSC_MAX_NUM_RIS 16
struct platform_device;
-DECLARE_STATIC_KEY_FALSE(mpam_enabled);
-
#ifdef CONFIG_MPAM_KUNIT_TEST
#define PACKED_FOR_KUNIT __packed
#else
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:33 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
Now that the MPAM system registers are expected to have values that change,
reprogram them based on the previous value when a CPU is brought online.
Previously MPAM's 'default PARTID' of 0 was always used for MPAM in
kernel-space as this is the PARTID that hardware guarantees to
reset. Because there are a limited number of PARTID, this value is exposed
to user-space, meaning resctrl changes to the resctrl default group would
also affect kernel threads. Instead, use the task's PARTID value for
kernel work on behalf of user-space too. The default of 0 is kept for both
user-space and kernel-space when MPAM is not enabled.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
CONFIG_MPAM -> CONFIG_ARM64_MPAM
Check mpam_enabled
Comment about relying on ERET for synchronisation
Update commit message
---
arch/arm64/kernel/cpufeature.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index c840a93b9ef9..0cdfb3728f43 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -86,6 +86,7 @@
#include <asm/kvm_host.h>
#include <asm/mmu.h>
#include <asm/mmu_context.h>
+#include <asm/mpam.h>
#include <asm/mte.h>
#include <asm/hypervisor.h>
#include <asm/processor.h>
@@ -2483,13 +2484,17 @@ test_has_mpam(const struct arm64_cpu_capabilities *entry, int scope)
static void
cpu_enable_mpam(const struct arm64_cpu_capabilities *entry)
{
- /*
- * Access by the kernel (at EL1) should use the reserved PARTID
- * which is configured unrestricted. This avoids priority-inversion
- * where latency sensitive tasks have to wait for a task that has
- * been throttled to release the lock.
- */
- write_sysreg_s(0, SYS_MPAM1_EL1);
+ int cpu = smp_processor_id();
+ u64 regval = 0;
+
+ if (IS_ENABLED(CONFIG_ARM64_MPAM) && static_branch_likely(&mpam_enabled))
+ regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
+
+ write_sysreg_s(regval, SYS_MPAM1_EL1);
+ isb();
+
+ /* Synchronising the EL0 write is left until the ERET to EL0 */
+ write_sysreg_s(regval, SYS_MPAM0_EL1);
}
static bool
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:34 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
Requestors need to populate the MPAM fields for any traffic they send on
the interconnect. For the CPUs these values are taken from the
corresponding MPAMy_ELx register. Each requestor may have a limit on the
largest PARTID or PMG value that can be used. The MPAM driver has to
determine the system-wide minimum supported PARTID and PMG values.
To do this, the driver needs to be told what each requestor's limit is.
CPUs are special, but this infrastructure is also needed for the SMMU and
GIC ITS. Call the helper to tell the MPAM driver what the CPUs can do.
The return value can be ignored by the arch code as it runs well before the
MPAM driver starts probing.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
arch/arm64/kernel/mpam.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
index 9866d2ca0faa..e6feff2324ac 100644
--- a/arch/arm64/kernel/mpam.c
+++ b/arch/arm64/kernel/mpam.c
@@ -3,6 +3,7 @@
#include <asm/mpam.h>
+#include <linux/arm_mpam.h>
#include <linux/jump_label.h>
#include <linux/percpu.h>
@@ -11,3 +12,14 @@ DEFINE_PER_CPU(u64, arm64_mpam_default);
DEFINE_PER_CPU(u64, arm64_mpam_current);
u64 arm64_mpam_global_default;
+
+static int __init arm64_mpam_register_cpus(void)
+{
+ u64 mpamidr = read_sanitised_ftr_reg(SYS_MPAMIDR_EL1);
+ u16 partid_max = FIELD_GET(MPAMIDR_EL1_PARTID_MAX, mpamidr);
+ u8 pmg_max = FIELD_GET(MPAMIDR_EL1_PMG_MAX, mpamidr);
+
+ return mpam_register_requestor(partid_max, pmg_max);
+}
+/* Must occur before mpam_msc_driver_init() from subsys_initcall() */
+arch_initcall(arm64_mpam_register_cpus)
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:35 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
The MPAM system registers will be lost if the CPU is reset during PSCI's
CPU_SUSPEND.
Add a PM notifier to restore them.
mpam_thread_switch(current) can't be used as this won't make any changes if
the in-memory copy says the register already has the correct value. In
reality the system register is UNKNOWN out of reset.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
arch/arm64/kernel/mpam.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
index e6feff2324ac..dbe0a2d05abb 100644
--- a/arch/arm64/kernel/mpam.c
+++ b/arch/arm64/kernel/mpam.c
@@ -4,6 +4,7 @@
#include <asm/mpam.h>
#include <linux/arm_mpam.h>
+#include <linux/cpu_pm.h>
#include <linux/jump_label.h>
#include <linux/percpu.h>
@@ -13,12 +14,41 @@ DEFINE_PER_CPU(u64, arm64_mpam_current);
u64 arm64_mpam_global_default;
+static int mpam_pm_notifier(struct notifier_block *self,
+ unsigned long cmd, void *v)
+{
+ u64 regval;
+ int cpu = smp_processor_id();
+
+ switch (cmd) {
+ case CPU_PM_EXIT:
+ /*
+ * Don't use mpam_thread_switch() as the system register
+ * value has changed under our feet.
+ */
+ regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
+ write_sysreg_s(regval, SYS_MPAM1_EL1);
+ isb();
+
+ write_sysreg_s(regval, SYS_MPAM0_EL1);
+
+ return NOTIFY_OK;
+ default:
+ return NOTIFY_DONE;
+ }
+}
+
+static struct notifier_block mpam_pm_nb = {
+ .notifier_call = mpam_pm_notifier,
+};
+
static int __init arm64_mpam_register_cpus(void)
{
u64 mpamidr = read_sanitised_ftr_reg(SYS_MPAMIDR_EL1);
u16 partid_max = FIELD_GET(MPAMIDR_EL1_PARTID_MAX, mpamidr);
u8 pmg_max = FIELD_GET(MPAMIDR_EL1_PMG_MAX, mpamidr);
+ cpu_pm_register_notifier(&mpam_pm_nb);
return mpam_register_requestor(partid_max, pmg_max);
}
/* Must occur before mpam_msc_driver_init() from subsys_initcall() */
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:36 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
The MPAMSM_EL1 sets the MPAM labels, PMG and PARTID, for loads and stores
generated by a shared SMCU. Disable the traps so the kernel can use it and
set it to the same configuration as the per-EL cpu MPAM configuration.
If an SMCU is not shared with other cpus then it is implementation
defined whether the configuration from MPAMSM_EL1 is used or that from
the appropriate MPAMy_ELx. As we set the same, PMG_D and PARTID_D,
configuration for MPAM0_EL1, MPAM1_EL1 and MPAMSM_EL1 the resulting
configuration is the same regardless.
The range of valid configurations for the PARTID and PMG in MPAMSM_EL1 is
not currently specified in Arm Architectural Reference Manual but the
architect has confirmed that it is intended to be the same as that for the
cpu configuration in the MPAMy_ELx registers.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Mention PMG_D and PARTID_D specifically int he commit message
Add paragraph in commit message on range of MPAMSM_EL1 fields
---
arch/arm64/include/asm/el2_setup.h | 3 ++-
arch/arm64/include/asm/mpam.h | 2 ++
arch/arm64/kernel/cpufeature.c | 2 ++
arch/arm64/kernel/mpam.c | 3 +++
4 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
index cacd20df1786..d37984c09799 100644
--- a/arch/arm64/include/asm/el2_setup.h
+++ b/arch/arm64/include/asm/el2_setup.h
@@ -504,7 +504,8 @@
check_override id_aa64pfr0, ID_AA64PFR0_EL1_MPAM_SHIFT, .Linit_mpam_\@, .Lskip_mpam_\@, x1, x2
.Linit_mpam_\@:
- msr_s SYS_MPAM2_EL2, xzr // use the default partition
+ mov x0, #MPAM2_EL2_EnMPAMSM_MASK
+ msr_s SYS_MPAM2_EL2, x0 // use the default partition,
// and disable lower traps
mrs_s x0, SYS_MPAMIDR_EL1
tbz x0, #MPAMIDR_EL1_HAS_HCR_SHIFT, .Lskip_mpam_\@ // skip if no MPAMHCR reg
diff --git a/arch/arm64/include/asm/mpam.h b/arch/arm64/include/asm/mpam.h
index 14011e5970ce..7b3d3abad162 100644
--- a/arch/arm64/include/asm/mpam.h
+++ b/arch/arm64/include/asm/mpam.h
@@ -53,6 +53,8 @@ static inline void mpam_thread_switch(struct task_struct *tsk)
return;
write_sysreg_s(regval, SYS_MPAM1_EL1);
+ if (system_supports_sme())
+ write_sysreg_s(regval & (MPAMSM_EL1_PARTID_D | MPAMSM_EL1_PMG_D), SYS_MPAMSM_EL1);
isb();
/* Synchronising the EL0 write is left until the ERET to EL0 */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 0cdfb3728f43..2ede543b3eeb 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -2491,6 +2491,8 @@ cpu_enable_mpam(const struct arm64_cpu_capabilities *entry)
regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
write_sysreg_s(regval, SYS_MPAM1_EL1);
+ if (system_supports_sme())
+ write_sysreg_s(regval & (MPAMSM_EL1_PARTID_D | MPAMSM_EL1_PMG_D), SYS_MPAMSM_EL1);
isb();
/* Synchronising the EL0 write is left until the ERET to EL0 */
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
index dbe0a2d05abb..6ce4a36469ce 100644
--- a/arch/arm64/kernel/mpam.c
+++ b/arch/arm64/kernel/mpam.c
@@ -28,6 +28,9 @@ static int mpam_pm_notifier(struct notifier_block *self,
*/
regval = READ_ONCE(per_cpu(arm64_mpam_current, cpu));
write_sysreg_s(regval, SYS_MPAM1_EL1);
+ if (system_supports_sme())
+ write_sysreg_s(regval & (MPAMSM_EL1_PARTID_D | MPAMSM_EL1_PMG_D),
+ SYS_MPAMSM_EL1);
isb();
write_sysreg_s(regval, SYS_MPAM0_EL1);
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:37 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
Care must be taken when modifying the PARTID and PMG of a task in any
per-task structure as writing these values may race with the task being
scheduled in, and reading the modified values.
Add helpers to set the task properties, and the CPU default value. These
use WRITE_ONCE() that pairs with the READ_ONCE() in mpam_get_regval() to
avoid causing torn values.
CC: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Keep comment attached to mpam_get_regval()
Add internal helper, __mpam_regval() (Jonathan)
---
arch/arm64/include/asm/mpam.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/arch/arm64/include/asm/mpam.h b/arch/arm64/include/asm/mpam.h
index 7b3d3abad162..c9b73f1af7ce 100644
--- a/arch/arm64/include/asm/mpam.h
+++ b/arch/arm64/include/asm/mpam.h
@@ -4,6 +4,7 @@
#ifndef __ASM__MPAM_H
#define __ASM__MPAM_H
+#include <linux/bitfield.h>
#include <linux/jump_label.h>
#include <linux/percpu.h>
#include <linux/sched.h>
@@ -22,6 +23,22 @@ DECLARE_PER_CPU(u64, arm64_mpam_current);
*/
extern u64 arm64_mpam_global_default;
+static inline u64 __mpam_regval(u16 partid_d, u16 partid_i, u8 pmg_d, u8 pmg_i)
+{
+ return FIELD_PREP(MPAM0_EL1_PARTID_D, partid_d) |
+ FIELD_PREP(MPAM0_EL1_PARTID_I, partid_i) |
+ FIELD_PREP(MPAM0_EL1_PMG_D, pmg_d) |
+ FIELD_PREP(MPAM0_EL1_PMG_I, pmg_i);
+}
+
+static inline void mpam_set_cpu_defaults(int cpu, u16 partid_d, u16 partid_i,
+ u8 pmg_d, u8 pmg_i)
+{
+ u64 default_val = __mpam_regval(partid_d, partid_i, pmg_d, pmg_i);
+
+ WRITE_ONCE(per_cpu(arm64_mpam_default, cpu), default_val);
+}
+
/*
* The resctrl filesystem writes to the partid/pmg values for threads and CPUs,
* which may race with reads in mpam_thread_switch(). Ensure only one of the old
@@ -36,6 +53,17 @@ static inline u64 mpam_get_regval(struct task_struct *tsk)
return READ_ONCE(task_thread_info(tsk)->mpam_partid_pmg);
}
+static inline void mpam_set_task_partid_pmg(struct task_struct *tsk,
+ u16 partid_d, u16 partid_i,
+ u8 pmg_d, u8 pmg_i)
+{
+#ifdef CONFIG_ARM64_MPAM
+ u64 regval = __mpam_regval(partid_d, partid_i, pmg_d, pmg_i);
+
+ WRITE_ONCE(task_thread_info(tsk)->mpam_partid_pmg, regval);
+#endif
+}
+
static inline void mpam_thread_switch(struct task_struct *tsk)
{
u64 oldregval;
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:38 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
While we trap the guest's attempts to read/write the MPAM control
registers, the hardware continues to use them. Guest-EL0 uses KVM's
user-space's configuration, as the value is left in the register, and
guest-EL1 uses either the host kernel's configuration, or in the case of
VHE, the UNKNOWN reset value of MPAM1_EL1.
We want to force the guest-EL1 to use KVM's user-space's MPAM
configuration. On nVHE rely on MPAM0_EL1 and MPAM1_EL1 always being
programmed the same and on VHE copy MPAM0_EL1 into the guest's
MPAM1_EL1. There is no need to restore as this is out of context once TGE
is set.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Drop the unneeded __mpam_guest_load() in nvhre and the MPAM1_EL1 save restore
Defer EL2 handling until next patch
Changes since v2:
Use mask (Oliver)
---
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/arm64/kvm/hyp/vhe/sysreg-sr.c b/arch/arm64/kvm/hyp/vhe/sysreg-sr.c
index f28c6cf4fe1b..9fb8e6628611 100644
--- a/arch/arm64/kvm/hyp/vhe/sysreg-sr.c
+++ b/arch/arm64/kvm/hyp/vhe/sysreg-sr.c
@@ -183,6 +183,18 @@ void sysreg_restore_guest_state_vhe(struct kvm_cpu_context *ctxt)
}
NOKPROBE_SYMBOL(sysreg_restore_guest_state_vhe);
+/*
+ * The _EL0 value was written by the host's context switch and belongs to the
+ * VMM. Copy this into the guest's _EL1 register.
+ */
+static inline void __mpam_guest_load(void)
+{
+ u64 mask = MPAM0_EL1_PARTID_D | MPAM0_EL1_PARTID_I | MPAM0_EL1_PMG_D | MPAM0_EL1_PMG_I;
+
+ if (system_supports_mpam())
+ write_sysreg_el1(read_sysreg_s(SYS_MPAM0_EL1) & mask, SYS_MPAM1);
+}
+
/**
* __vcpu_load_switch_sysregs - Load guest system registers to the physical CPU
*
@@ -222,6 +234,7 @@ void __vcpu_load_switch_sysregs(struct kvm_vcpu *vcpu)
*/
__sysreg32_restore_state(vcpu);
__sysreg_restore_user_state(guest_ctxt);
+ __mpam_guest_load();
if (unlikely(is_hyp_ctxt(vcpu))) {
__sysreg_restore_vel2_state(vcpu);
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:39 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
On nVHE systems whether or not MPAM is enabled, EL2 continues to use
partid-0 for hypercalls, even when the host may have configured its kernel
threads to use a different partid. 0 may have been assigned to another
task. Copy the EL1 MPAM register to EL2. This ensures hypercalls use the
same partid as the kernel thread does on the host.
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Use mask
Use read_sysreg_el1 to cope with hvhe
---
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index a7c689152f68..ad99d8a73a9e 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -635,6 +635,14 @@ static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
unsigned long hcall_min = 0;
hcall_t hfn;
+ if (system_supports_mpam()) {
+ u64 mask = MPAM1_EL1_PARTID_D | MPAM1_EL1_PARTID_I |
+ MPAM1_EL1_PMG_D | MPAM1_EL1_PMG_I;
+
+ write_sysreg_s(read_sysreg_el1(SYS_MPAM1) & mask, SYS_MPAM2_EL2);
+ isb();
+ }
+
/*
* If pKVM has been initialised then reject any calls to the
* early "privileged" hypercalls. Note that we cannot reject
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:40 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
resctrl has its own data structures to describe its resources. We can't use
these directly as we play tricks with the 'MBA' resource, picking the MPAM
controls or monitors that best apply. We may export the same component as
both L3 and MBA.
Add mpam_resctrl_exports[] as the array of class->resctrl mappings we are
exporting, and add the cpuhp hooks that allocated and free the resctrl
domain structures.
While we're here, plumb in a few other obvious things.
CONFIG_ARM_CPU_RESCTRL is used to allow this code to be built even though
it can't yet be linked against resctrl.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Domain list is an rcu list
Add synchronize_rcu() to free the deleted element
Code flow simplification (Jonathan)
Changes since v2:
Iterate over mpam_resctrl_dom directly (Jonathan)
Code flow clarification
Comment tidying
Remove power of 2 check as no longer creates holes in rmid indices
Remove unused type argument
add macro helper for_each_mpam_resctrl_control
---
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 12 ++
drivers/resctrl/mpam_internal.h | 22 +++
drivers/resctrl/mpam_resctrl.c | 321 ++++++++++++++++++++++++++++++++
include/linux/arm_mpam.h | 3 +
5 files changed, 359 insertions(+)
create mode 100644 drivers/resctrl/mpam_resctrl.c
diff --git a/drivers/resctrl/Makefile b/drivers/resctrl/Makefile
index 898199dcf80d..40beaf999582 100644
--- a/drivers/resctrl/Makefile
+++ b/drivers/resctrl/Makefile
@@ -1,4 +1,5 @@
obj-$(CONFIG_ARM64_MPAM_DRIVER) += mpam.o
mpam-y += mpam_devices.o
+mpam-$(CONFIG_ARM_CPU_RESCTRL) += mpam_resctrl.o
ccflags-$(CONFIG_ARM64_MPAM_DRIVER_DEBUG) += -DDEBUG
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 860181266b15..b81d5c7f44ca 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1628,6 +1628,9 @@ static int mpam_cpu_online(unsigned int cpu)
mpam_reprogram_msc(msc);
}
+ if (mpam_is_enabled())
+ return mpam_resctrl_online_cpu(cpu);
+
return 0;
}
@@ -1671,6 +1674,9 @@ static int mpam_cpu_offline(unsigned int cpu)
{
struct mpam_msc *msc;
+ if (mpam_is_enabled())
+ mpam_resctrl_offline_cpu(cpu);
+
guard(srcu)(&mpam_srcu);
list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list,
srcu_read_lock_held(&mpam_srcu)) {
@@ -2517,6 +2523,12 @@ static void mpam_enable_once(void)
mutex_unlock(&mpam_list_lock);
cpus_read_unlock();
+ if (!err) {
+ err = mpam_resctrl_setup();
+ if (err)
+ pr_err("Failed to initialise resctrl: %d\n", err);
+ }
+
if (err) {
mpam_disable_reason = "Failed to enable.";
schedule_work(&mpam_broken_work);
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 4632985bcca6..e394ee78918a 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -12,6 +12,7 @@
#include <linux/jump_label.h>
#include <linux/llist.h>
#include <linux/mutex.h>
+#include <linux/resctrl.h>
#include <linux/spinlock.h>
#include <linux/srcu.h>
#include <linux/types.h>
@@ -337,6 +338,17 @@ struct mpam_msc_ris {
struct mpam_garbage garbage;
};
+struct mpam_resctrl_dom {
+ struct mpam_component *ctrl_comp;
+ struct rdt_ctrl_domain resctrl_ctrl_dom;
+ struct rdt_mon_domain resctrl_mon_dom;
+};
+
+struct mpam_resctrl_res {
+ struct mpam_class *class;
+ struct rdt_resource resctrl_res;
+};
+
static inline int mpam_alloc_csu_mon(struct mpam_class *class)
{
struct mpam_props *cprops = &class->props;
@@ -391,6 +403,16 @@ void mpam_msmon_reset_mbwu(struct mpam_component *comp, struct mon_cfg *ctx);
int mpam_get_cpumask_from_cache_id(unsigned long cache_id, u32 cache_level,
cpumask_t *affinity);
+#ifdef CONFIG_RESCTRL_FS
+int mpam_resctrl_setup(void);
+int mpam_resctrl_online_cpu(unsigned int cpu);
+void mpam_resctrl_offline_cpu(unsigned int cpu);
+#else
+static inline int mpam_resctrl_setup(void) { return 0; }
+static inline int mpam_resctrl_online_cpu(unsigned int cpu) { return 0; }
+static inline void mpam_resctrl_offline_cpu(unsigned int cpu) { }
+#endif /* CONFIG_RESCTRL_FS */
+
/*
* MPAM MSCs have the following register layout. See:
* Arm Memory System Resource Partitioning and Monitoring (MPAM) System
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
new file mode 100644
index 000000000000..cb29c05edfa8
--- /dev/null
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -0,0 +1,321 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2025 Arm Ltd.
+
+#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
+
+#include <linux/arm_mpam.h>
+#include <linux/cacheinfo.h>
+#include <linux/cpu.h>
+#include <linux/cpumask.h>
+#include <linux/errno.h>
+#include <linux/list.h>
+#include <linux/printk.h>
+#include <linux/rculist.h>
+#include <linux/resctrl.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include <asm/mpam.h>
+
+#include "mpam_internal.h"
+
+/*
+ * The classes we've picked to map to resctrl resources, wrapped
+ * in with their resctrl structure.
+ * Class pointer may be NULL.
+ */
+static struct mpam_resctrl_res mpam_resctrl_controls[RDT_NUM_RESOURCES];
+
+#define for_each_mpam_resctrl_control(res, rid) \
+ for (rid = 0, res = &mpam_resctrl_controls[rid]; \
+ rid < RDT_NUM_RESOURCES; \
+ rid++, res = &mpam_resctrl_controls[rid])
+
+/* The lock for modifying resctrl's domain lists from cpuhp callbacks. */
+static DEFINE_MUTEX(domain_list_lock);
+
+static bool exposed_alloc_capable;
+static bool exposed_mon_capable;
+
+bool resctrl_arch_alloc_capable(void)
+{
+ return exposed_alloc_capable;
+}
+
+bool resctrl_arch_mon_capable(void)
+{
+ return exposed_mon_capable;
+}
+
+/*
+ * MSC may raise an error interrupt if it sees an out or range partid/pmg,
+ * and go on to truncate the value. Regardless of what the hardware supports,
+ * only the system wide safe value is safe to use.
+ */
+u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored)
+{
+ return mpam_partid_max + 1;
+}
+
+struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)
+{
+ if (l >= RDT_NUM_RESOURCES)
+ return NULL;
+
+ return &mpam_resctrl_controls[l].resctrl_res;
+}
+
+static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
+{
+ /* TODO: initialise the resctrl resources */
+
+ return 0;
+}
+
+static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
+{
+ struct mpam_class *class = comp->class;
+
+ if (class->type == MPAM_CLASS_CACHE)
+ return comp->comp_id;
+
+ /* TODO: repaint domain ids to match the L3 domain ids */
+ /* Otherwise, expose the ID used by the firmware table code. */
+ return comp->comp_id;
+}
+
+static void mpam_resctrl_domain_hdr_init(int cpu, struct mpam_component *comp,
+ struct rdt_domain_hdr *hdr)
+{
+ lockdep_assert_cpus_held();
+
+ INIT_LIST_HEAD(&hdr->list);
+ hdr->id = mpam_resctrl_pick_domain_id(cpu, comp);
+ cpumask_set_cpu(cpu, &hdr->cpu_mask);
+}
+
+/**
+ * mpam_resctrl_offline_domain_hdr() - Update the domain header to remove a CPU.
+ * @cpu: The CPU to remove from the domain.
+ * @hdr: The domain's header.
+ *
+ * Removes @cpu from the header mask. If this was the last CPU in the domain,
+ * the domain header is removed from its parent list and true is returned,
+ * indicating the parent structure can be freed.
+ * If there are other CPUs in the domain, returns false.
+ */
+static bool mpam_resctrl_offline_domain_hdr(unsigned int cpu,
+ struct rdt_domain_hdr *hdr)
+{
+ lockdep_assert_held(&domain_list_lock);
+
+ cpumask_clear_cpu(cpu, &hdr->cpu_mask);
+ if (cpumask_empty(&hdr->cpu_mask)) {
+ list_del_rcu(&hdr->list);
+ synchronize_rcu();
+ return true;
+ }
+
+ return false;
+}
+
+static struct mpam_resctrl_dom *
+mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
+{
+ int err;
+ struct mpam_resctrl_dom *dom;
+ struct rdt_mon_domain *mon_d;
+ struct rdt_ctrl_domain *ctrl_d;
+ struct mpam_class *class = res->class;
+ struct mpam_component *comp_iter, *ctrl_comp;
+ struct rdt_resource *r = &res->resctrl_res;
+
+ lockdep_assert_held(&domain_list_lock);
+
+ ctrl_comp = NULL;
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(comp_iter, &class->components, class_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ if (cpumask_test_cpu(cpu, &comp_iter->affinity)) {
+ ctrl_comp = comp_iter;
+ break;
+ }
+ }
+
+ /* class has no component for this CPU */
+ if (WARN_ON_ONCE(!ctrl_comp))
+ return ERR_PTR(-EINVAL);
+
+ dom = kzalloc_node(sizeof(*dom), GFP_KERNEL, cpu_to_node(cpu));
+ if (!dom)
+ return ERR_PTR(-ENOMEM);
+
+ if (exposed_alloc_capable) {
+ dom->ctrl_comp = ctrl_comp;
+
+ ctrl_d = &dom->resctrl_ctrl_dom;
+ mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &ctrl_d->hdr);
+ ctrl_d->hdr.type = RESCTRL_CTRL_DOMAIN;
+ /* TODO: this list should be sorted */
+ list_add_tail_rcu(&ctrl_d->hdr.list, &r->ctrl_domains);
+ err = resctrl_online_ctrl_domain(r, ctrl_d);
+ if (err) {
+ dom = ERR_PTR(err);
+ goto offline_ctrl_domain;
+ }
+ } else {
+ pr_debug("Skipped control domain online - no controls\n");
+ }
+
+ if (exposed_mon_capable) {
+ mon_d = &dom->resctrl_mon_dom;
+ mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &mon_d->hdr);
+ mon_d->hdr.type = RESCTRL_MON_DOMAIN;
+ /* TODO: this list should be sorted */
+ list_add_tail_rcu(&mon_d->hdr.list, &r->mon_domains);
+ err = resctrl_online_mon_domain(r, mon_d);
+ if (err) {
+ dom = ERR_PTR(err);
+ goto offline_mon_hdr;
+ }
+ } else {
+ pr_debug("Skipped monitor domain online - no monitors\n");
+ }
+
+ return dom;
+
+offline_mon_hdr:
+ mpam_resctrl_offline_domain_hdr(cpu, &mon_d->hdr);
+offline_ctrl_domain:
+ resctrl_offline_ctrl_domain(r, ctrl_d);
+
+ return dom;
+}
+
+static struct mpam_resctrl_dom *
+mpam_resctrl_get_domain_from_cpu(int cpu, struct mpam_resctrl_res *res)
+{
+ struct mpam_resctrl_dom *dom;
+ struct rdt_resource *r = &res->resctrl_res;
+
+ lockdep_assert_cpus_held();
+
+ list_for_each_entry_rcu(dom, &r->ctrl_domains, resctrl_ctrl_dom.hdr.list) {
+ if (cpumask_test_cpu(cpu, &dom->ctrl_comp->affinity))
+ return dom;
+ }
+
+ return NULL;
+}
+
+int mpam_resctrl_online_cpu(unsigned int cpu)
+{
+ struct mpam_resctrl_res *res;
+ enum resctrl_res_level rid;
+
+ guard(mutex)(&domain_list_lock);
+ for_each_mpam_resctrl_control(res, rid) {
+ struct mpam_resctrl_dom *dom;
+
+ if (!res->class)
+ continue; // dummy_resource;
+
+ dom = mpam_resctrl_get_domain_from_cpu(cpu, res);
+ if (!dom)
+ dom = mpam_resctrl_alloc_domain(cpu, res);
+ if (IS_ERR(dom))
+ return PTR_ERR(dom);
+ }
+
+ resctrl_online_cpu(cpu);
+
+ return 0;
+}
+
+void mpam_resctrl_offline_cpu(unsigned int cpu)
+{
+ struct mpam_resctrl_res *res;
+ enum resctrl_res_level rid;
+
+ resctrl_offline_cpu(cpu);
+
+ guard(mutex)(&domain_list_lock);
+ for_each_mpam_resctrl_control(res, rid) {
+ struct mpam_resctrl_dom *dom;
+ struct rdt_mon_domain *mon_d;
+ struct rdt_ctrl_domain *ctrl_d;
+ bool ctrl_dom_empty, mon_dom_empty;
+
+ if (!res->class)
+ continue; // dummy resource
+
+ dom = mpam_resctrl_get_domain_from_cpu(cpu, res);
+ if (WARN_ON_ONCE(!dom))
+ continue;
+
+ if (exposed_alloc_capable) {
+ ctrl_d = &dom->resctrl_ctrl_dom;
+ ctrl_dom_empty = mpam_resctrl_offline_domain_hdr(cpu, &ctrl_d->hdr);
+ if (ctrl_dom_empty)
+ resctrl_offline_ctrl_domain(&res->resctrl_res, ctrl_d);
+ } else {
+ ctrl_dom_empty = true;
+ }
+
+ if (exposed_mon_capable) {
+ mon_d = &dom->resctrl_mon_dom;
+ mon_dom_empty = mpam_resctrl_offline_domain_hdr(cpu, &mon_d->hdr);
+ if (mon_dom_empty)
+ resctrl_offline_mon_domain(&res->resctrl_res, mon_d);
+ } else {
+ mon_dom_empty = true;
+ }
+
+ if (ctrl_dom_empty && mon_dom_empty)
+ kfree(dom);
+ }
+}
+
+int mpam_resctrl_setup(void)
+{
+ int err = 0;
+ struct mpam_resctrl_res *res;
+ enum resctrl_res_level rid;
+
+ cpus_read_lock();
+ for_each_mpam_resctrl_control(res, rid) {
+ INIT_LIST_HEAD_RCU(&res->resctrl_res.ctrl_domains);
+ INIT_LIST_HEAD_RCU(&res->resctrl_res.mon_domains);
+ res->resctrl_res.rid = rid;
+ }
+
+ /* TODO: pick MPAM classes to map to resctrl resources */
+
+ /* Initialise the resctrl structures from the classes */
+ for_each_mpam_resctrl_control(res, rid) {
+ if (!res->class)
+ continue; // dummy resource
+
+ err = mpam_resctrl_control_init(res);
+ if (err) {
+ pr_debug("Failed to initialise rid %u\n", rid);
+ break;
+ }
+ }
+ cpus_read_unlock();
+
+ if (err) {
+ pr_debug("Internal error %d - resctrl not supported\n", err);
+ return err;
+ }
+
+ if (!exposed_alloc_capable && !exposed_mon_capable) {
+ pr_debug("No alloc(%u) or monitor(%u) found - resctrl not supported\n",
+ exposed_alloc_capable, exposed_mon_capable);
+ return -EOPNOTSUPP;
+ }
+
+ /* TODO: call resctrl_init() */
+
+ return 0;
+}
diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
index 7f00c5285a32..2c7d1413a401 100644
--- a/include/linux/arm_mpam.h
+++ b/include/linux/arm_mpam.h
@@ -49,6 +49,9 @@ static inline int mpam_ris_create(struct mpam_msc *msc, u8 ris_idx,
}
#endif
+bool resctrl_arch_alloc_capable(void);
+bool resctrl_arch_mon_capable(void);
+
/**
* mpam_register_requestor() - Register a requestor with the MPAM driver
* @partid_max: The maximum PARTID value the requestor can generate.
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:41 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
resctrl documents that the domains appear in numeric order in the schemata
file. This means a little more work is needed when bringing a domain
online.
Add the support for this, using resctrl_find_domain() to find the point to
insert in the list.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
drivers/resctrl/mpam_resctrl.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index cb29c05edfa8..4dba6f58f79c 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -119,6 +119,21 @@ static bool mpam_resctrl_offline_domain_hdr(unsigned int cpu,
return false;
}
+static void mpam_resctrl_domain_insert(struct list_head *list,
+ struct rdt_domain_hdr *new)
+{
+ struct rdt_domain_hdr *err;
+ struct list_head *pos = NULL;
+
+ lockdep_assert_held(&domain_list_lock);
+
+ err = resctrl_find_domain(list, new->id, &pos);
+ if (WARN_ON_ONCE(err))
+ return;
+
+ list_add_tail_rcu(&new->list, pos);
+}
+
static struct mpam_resctrl_dom *
mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
{
@@ -156,8 +171,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
ctrl_d = &dom->resctrl_ctrl_dom;
mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &ctrl_d->hdr);
ctrl_d->hdr.type = RESCTRL_CTRL_DOMAIN;
- /* TODO: this list should be sorted */
- list_add_tail_rcu(&ctrl_d->hdr.list, &r->ctrl_domains);
+ mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr);
err = resctrl_online_ctrl_domain(r, ctrl_d);
if (err) {
dom = ERR_PTR(err);
@@ -171,8 +185,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
mon_d = &dom->resctrl_mon_dom;
mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &mon_d->hdr);
mon_d->hdr.type = RESCTRL_MON_DOMAIN;
- /* TODO: this list should be sorted */
- list_add_tail_rcu(&mon_d->hdr.list, &r->mon_domains);
+ mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr);
err = resctrl_online_mon_domain(r, mon_d);
if (err) {
dom = ERR_PTR(err);
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:42 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
Systems with MPAM support may have a variety of control types at any point
of their system layout. We can only expose certain types of control, and
only if they exist at particular locations.
Start with the well-known caches. These have to be depth 2 or 3 and support
MPAM's cache portion bitmap controls, with a number of portions fewer than
resctrl's limit.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Jonathan:
Remove brackets
Compress debug message
Use temp var, r
Changes since v2:
Return -EINVAL in mpam_resctrl_control_init() for unknown rid
---
drivers/resctrl/mpam_resctrl.c | 90 +++++++++++++++++++++++++++++++++-
1 file changed, 88 insertions(+), 2 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 4dba6f58f79c..1566d0c686e6 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -65,9 +65,94 @@ struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)
return &mpam_resctrl_controls[l].resctrl_res;
}
+static bool cache_has_usable_cpor(struct mpam_class *class)
+{
+ struct mpam_props *cprops = &class->props;
+
+ if (!mpam_has_feature(mpam_feat_cpor_part, cprops))
+ return false;
+
+ /* resctrl uses u32 for all bitmap configurations */
+ return class->props.cpbm_wd <= 32;
+}
+
+/* Test whether we can export MPAM_CLASS_CACHE:{2,3}? */
+static void mpam_resctrl_pick_caches(void)
+{
+ struct mpam_class *class;
+ struct mpam_resctrl_res *res;
+
+ lockdep_assert_cpus_held();
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(class, &mpam_classes, classes_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ if (class->type != MPAM_CLASS_CACHE) {
+ pr_debug("class %u is not a cache\n", class->level);
+ continue;
+ }
+
+ if (class->level != 2 && class->level != 3) {
+ pr_debug("class %u is not L2 or L3\n", class->level);
+ continue;
+ }
+
+ if (!cache_has_usable_cpor(class)) {
+ pr_debug("class %u cache misses CPOR\n", class->level);
+ continue;
+ }
+
+ if (!cpumask_equal(&class->affinity, cpu_possible_mask)) {
+ pr_debug("class %u has missing CPUs, mask %*pb != %*pb\n", class->level,
+ cpumask_pr_args(&class->affinity),
+ cpumask_pr_args(cpu_possible_mask));
+ continue;
+ }
+
+ if (class->level == 2)
+ res = &mpam_resctrl_controls[RDT_RESOURCE_L2];
+ else
+ res = &mpam_resctrl_controls[RDT_RESOURCE_L3];
+ res->class = class;
+ exposed_alloc_capable = true;
+ }
+}
+
static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
{
- /* TODO: initialise the resctrl resources */
+ struct mpam_class *class = res->class;
+ struct rdt_resource *r = &res->resctrl_res;
+
+ switch (r->rid) {
+ case RDT_RESOURCE_L2:
+ case RDT_RESOURCE_L3:
+ r->alloc_capable = true;
+ r->schema_fmt = RESCTRL_SCHEMA_BITMAP;
+ r->cache.arch_has_sparse_bitmasks = true;
+
+ r->cache.cbm_len = class->props.cpbm_wd;
+ /* mpam_devices will reject empty bitmaps */
+ r->cache.min_cbm_bits = 1;
+
+ if (r->rid == RDT_RESOURCE_L2) {
+ r->name = "L2";
+ r->ctrl_scope = RESCTRL_L2_CACHE;
+ } else {
+ r->name = "L3";
+ r->ctrl_scope = RESCTRL_L3_CACHE;
+ }
+
+ /*
+ * Which bits are shared with other ...things...
+ * Unknown devices use partid-0 which uses all the bitmap
+ * fields. Until we configured the SMMU and GIC not to do this
+ * 'all the bits' is the correct answer here.
+ */
+ r->cache.shareable_bits = resctrl_get_default_ctrl(r);
+ break;
+ default:
+ return -EINVAL;
+ }
return 0;
}
@@ -302,7 +387,8 @@ int mpam_resctrl_setup(void)
res->resctrl_res.rid = rid;
}
- /* TODO: pick MPAM classes to map to resctrl resources */
+ /* Find some classes to use for controls */
+ mpam_resctrl_pick_caches();
/* Initialise the resctrl structures from the classes */
for_each_mpam_resctrl_control(res, rid) {
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:43 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
We already have a helper for resetting an mpam class and component. Hook
it up to resctrl_arch_reset_all_ctrls() and the domain offline path.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Don't expose unlocked reset
---
drivers/resctrl/mpam_devices.c | 4 ++--
drivers/resctrl/mpam_internal.h | 6 ++++++
drivers/resctrl/mpam_resctrl.c | 15 +++++++++++++++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index b81d5c7f44ca..0dd7f613f7a3 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2544,7 +2544,7 @@ static void mpam_enable_once(void)
mpam_partid_max + 1, mpam_pmg_max + 1);
}
-static void mpam_reset_component_locked(struct mpam_component *comp)
+void mpam_reset_component_locked(struct mpam_component *comp)
{
struct mpam_vmsc *vmsc;
@@ -2568,7 +2568,7 @@ static void mpam_reset_component_locked(struct mpam_component *comp)
}
}
-static void mpam_reset_class_locked(struct mpam_class *class)
+void mpam_reset_class_locked(struct mpam_class *class)
{
struct mpam_component *comp;
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index e394ee78918a..f89ceaf7623d 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -393,6 +393,12 @@ extern u8 mpam_pmg_max;
void mpam_enable(struct work_struct *work);
void mpam_disable(struct work_struct *work);
+/* Reset all the RIS in a class under cpus_read_lock() */
+void mpam_reset_class_locked(struct mpam_class *class);
+
+/* Reset all the RIS in a component under cpus_read_lock() */
+void mpam_reset_component_locked(struct mpam_component *comp);
+
int mpam_apply_config(struct mpam_component *comp, u16 partid,
struct mpam_config *cfg);
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 1566d0c686e6..683bdd6989d4 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -169,6 +169,19 @@ static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
return comp->comp_id;
}
+void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
+{
+ struct mpam_resctrl_res *res;
+
+ lockdep_assert_cpus_held();
+
+ if (!mpam_is_enabled())
+ return;
+
+ res = container_of(r, struct mpam_resctrl_res, resctrl_res);
+ mpam_reset_class_locked(res->class);
+}
+
static void mpam_resctrl_domain_hdr_init(int cpu, struct mpam_component *comp,
struct rdt_domain_hdr *hdr)
{
@@ -352,6 +365,8 @@ void mpam_resctrl_offline_cpu(unsigned int cpu)
continue;
if (exposed_alloc_capable) {
+ mpam_reset_component_locked(dom->ctrl_comp);
+
ctrl_d = &dom->resctrl_ctrl_dom;
ctrl_dom_empty = mpam_resctrl_offline_domain_hdr(cpu, &ctrl_d->hdr);
if (ctrl_dom_empty)
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:44 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
Implement resctrl_arch_get_config() by testing the live configuration for a
CPOR bitmap. For any other configuration type return the default.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
drivers/resctrl/mpam_resctrl.c | 43 ++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 683bdd6989d4..25012e779509 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -169,6 +169,49 @@ static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
return comp->comp_id;
}
+u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
+ u32 closid, enum resctrl_conf_type type)
+{
+ u32 partid;
+ struct mpam_config *cfg;
+ struct mpam_props *cprops;
+ struct mpam_resctrl_res *res;
+ struct mpam_resctrl_dom *dom;
+ enum mpam_device_features configured_by;
+
+ lockdep_assert_cpus_held();
+
+ if (!mpam_is_enabled())
+ return resctrl_get_default_ctrl(r);
+
+ res = container_of(r, struct mpam_resctrl_res, resctrl_res);
+ dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom);
+ cprops = &res->class->props;
+
+ partid = resctrl_get_config_index(closid, type);
+ cfg = &dom->ctrl_comp->cfg[partid];
+
+ switch (r->rid) {
+ case RDT_RESOURCE_L2:
+ case RDT_RESOURCE_L3:
+ configured_by = mpam_feat_cpor_part;
+ break;
+ default:
+ return resctrl_get_default_ctrl(r);
+ }
+
+ if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r) ||
+ !mpam_has_feature(configured_by, cfg))
+ return resctrl_get_default_ctrl(r);
+
+ switch (configured_by) {
+ case mpam_feat_cpor_part:
+ return cfg->cpbm;
+ default:
+ return resctrl_get_default_ctrl(r);
+ }
+}
+
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
{
struct mpam_resctrl_res *res;
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:45 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
resctrl has two helpers for updating the configuration.
resctrl_arch_update_one() updates a single value, and is used by the
software-controller to apply feedback to the bandwidth controls, it has to
be called on one of the CPUs in the resctrl:domain.
resctrl_arch_update_domains() copies multiple staged configurations, it can
be called from anywhere.
Both helpers should update any changes to the underlying hardware.
Implement resctrl_arch_update_domains() to use
resctrl_arch_update_one(). Neither need to be called on a specific CPU as
the mpam driver will send IPIs as needed.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
list_for_each_entry -> list_for_each_entry_rcu
return 0
Restrict scope of local variables
Changes since v2:
whitespace fix
---
drivers/resctrl/mpam_resctrl.c | 70 ++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 25012e779509..5b73fe45b8fa 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -212,6 +212,76 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
}
}
+int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
+ u32 closid, enum resctrl_conf_type t, u32 cfg_val)
+{
+ u32 partid;
+ struct mpam_config cfg;
+ struct mpam_props *cprops;
+ struct mpam_resctrl_res *res;
+ struct mpam_resctrl_dom *dom;
+
+ lockdep_assert_cpus_held();
+ lockdep_assert_irqs_enabled();
+
+ /*
+ * No need to check the CPU as mpam_apply_config() doesn't care, and
+ * resctrl_arch_update_domains() relies on this.
+ */
+ res = container_of(r, struct mpam_resctrl_res, resctrl_res);
+ dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom);
+ cprops = &res->class->props;
+
+ partid = resctrl_get_config_index(closid, t);
+ if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r)) {
+ pr_debug("Not alloc capable or computed PARTID out of range\n");
+ return -EINVAL;
+ }
+
+ /*
+ * Copy the current config to avoid clearing other resources when the
+ * same component is exposed multiple times through resctrl.
+ */
+ cfg = dom->ctrl_comp->cfg[partid];
+
+ switch (r->rid) {
+ case RDT_RESOURCE_L2:
+ case RDT_RESOURCE_L3:
+ cfg.cpbm = cfg_val;
+ mpam_set_feature(mpam_feat_cpor_part, &cfg);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
+}
+
+int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
+{
+ int err;
+ struct rdt_ctrl_domain *d;
+
+ lockdep_assert_cpus_held();
+ lockdep_assert_irqs_enabled();
+
+ list_for_each_entry_rcu(d, &r->ctrl_domains, hdr.list) {
+ for (enum resctrl_conf_type t = 0; t < CDP_NUM_TYPES; t++) {
+ struct resctrl_staged_config *cfg = &d->staged_config[t];
+
+ if (!cfg->have_new_ctrl)
+ continue;
+
+ err = resctrl_arch_update_one(r, d, closid, t,
+ cfg->new_ctrl);
+ if (err)
+ return err;
+ }
+ }
+
+ return 0;
+}
+
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
{
struct mpam_resctrl_res *res;
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:46 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
arm64 provides helpers for changing a task's and a cpu's mpam partid/pmg
values.
These are used to back a number of resctrl_arch_ functions. Connect them
up.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
apostrophes in commit message
---
drivers/resctrl/mpam_resctrl.c | 58 ++++++++++++++++++++++++++++++++++
include/linux/arm_mpam.h | 5 +++
2 files changed, 63 insertions(+)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 5b73fe45b8fa..c596b224c967 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -8,6 +8,7 @@
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/errno.h>
+#include <linux/limits.h>
#include <linux/list.h>
#include <linux/printk.h>
#include <linux/rculist.h>
@@ -37,6 +38,8 @@ static DEFINE_MUTEX(domain_list_lock);
static bool exposed_alloc_capable;
static bool exposed_mon_capable;
+static bool cdp_enabled;
+
bool resctrl_arch_alloc_capable(void)
{
return exposed_alloc_capable;
@@ -57,6 +60,61 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored)
return mpam_partid_max + 1;
}
+void resctrl_arch_sched_in(struct task_struct *tsk)
+{
+ lockdep_assert_preemption_disabled();
+
+ mpam_thread_switch(tsk);
+}
+
+void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid)
+{
+ WARN_ON_ONCE(closid > U16_MAX);
+ WARN_ON_ONCE(rmid > U8_MAX);
+
+ if (!cdp_enabled) {
+ mpam_set_cpu_defaults(cpu, closid, closid, rmid, rmid);
+ } else {
+ /*
+ * When CDP is enabled, resctrl halves the closid range and we
+ * use odd/even partid for one closid.
+ */
+ u32 partid_d = resctrl_get_config_index(closid, CDP_DATA);
+ u32 partid_i = resctrl_get_config_index(closid, CDP_CODE);
+
+ mpam_set_cpu_defaults(cpu, partid_d, partid_i, rmid, rmid);
+ }
+}
+
+void resctrl_arch_sync_cpu_closid_rmid(void *info)
+{
+ struct resctrl_cpu_defaults *r = info;
+
+ lockdep_assert_preemption_disabled();
+
+ if (r) {
+ resctrl_arch_set_cpu_default_closid_rmid(smp_processor_id(),
+ r->closid, r->rmid);
+ }
+
+ resctrl_arch_sched_in(current);
+}
+
+void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid)
+{
+ WARN_ON_ONCE(closid > U16_MAX);
+ WARN_ON_ONCE(rmid > U8_MAX);
+
+ if (!cdp_enabled) {
+ mpam_set_task_partid_pmg(tsk, closid, closid, rmid, rmid);
+ } else {
+ u32 partid_d = resctrl_get_config_index(closid, CDP_DATA);
+ u32 partid_i = resctrl_get_config_index(closid, CDP_CODE);
+
+ mpam_set_task_partid_pmg(tsk, partid_d, partid_i, rmid, rmid);
+ }
+}
+
struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)
{
if (l >= RDT_NUM_RESOURCES)
diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
index 2c7d1413a401..5a78299ec464 100644
--- a/include/linux/arm_mpam.h
+++ b/include/linux/arm_mpam.h
@@ -52,6 +52,11 @@ static inline int mpam_ris_create(struct mpam_msc *msc, u8 ris_idx,
bool resctrl_arch_alloc_capable(void);
bool resctrl_arch_mon_capable(void);
+void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid);
+void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid);
+void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid);
+void resctrl_arch_sched_in(struct task_struct *tsk);
+
/**
* mpam_register_requestor() - Register a requestor with the MPAM driver
* @partid_max: The maximum PARTID value the requestor can generate.
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:47 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
Intel RDT's CDP feature allows the cache to use a different control value
depending on whether the accesses was for instruction fetch or a data
access. MPAM's equivalent feature is the other way up: the CPU assigns a
different partid label to traffic depending on whether it was instruction
fetch or a data access, which causes the cache to use a different control
value based solely on the partid.
MPAM can emulate CDP, with the side effect that the alternative partid is
seen by all MSC, it can't be enabled per-MSC.
Add the resctrl hooks to turn this on or off. Add the helpers that match a
closid against a task, which need to be aware that the value written to
hardware is not the same as the one resctrl is using.
Update the 'arm64_mpam_global_default' variable the arch code uses during
context switch to know when the per-cpu value should be used instead.
Awkwardly, the MB controls don't implement CDP. To emulate this, the MPAM
equivalent needs programming twice by the resctrl glue, as resctrl expects
the bandwidth controls to be applied independently for both data and
instruction-fetch.
CC: Dave Martin <Dave.Martin@arm.com>
CC: Amit Singh Tomar <amitsinght@marvell.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Fail cdp initialisation if there is only one partid
Correct data/code confusion
Changes since v2:
Don't include unused header
---
arch/arm64/include/asm/mpam.h | 1 +
drivers/resctrl/mpam_resctrl.c | 112 +++++++++++++++++++++++++++++++++
include/linux/arm_mpam.h | 2 +
3 files changed, 115 insertions(+)
diff --git a/arch/arm64/include/asm/mpam.h b/arch/arm64/include/asm/mpam.h
index c9b73f1af7ce..3a49f666e5e8 100644
--- a/arch/arm64/include/asm/mpam.h
+++ b/arch/arm64/include/asm/mpam.h
@@ -4,6 +4,7 @@
#ifndef __ASM__MPAM_H
#define __ASM__MPAM_H
+#include <linux/arm_mpam.h>
#include <linux/bitfield.h>
#include <linux/jump_label.h>
#include <linux/percpu.h>
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index c596b224c967..8112bcb85e73 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -38,6 +38,10 @@ static DEFINE_MUTEX(domain_list_lock);
static bool exposed_alloc_capable;
static bool exposed_mon_capable;
+/*
+ * MPAM emulates CDP by setting different PARTID in the I/D fields of MPAM0_EL1.
+ * This applies globally to all traffic the CPU generates.
+ */
static bool cdp_enabled;
bool resctrl_arch_alloc_capable(void)
@@ -50,6 +54,67 @@ bool resctrl_arch_mon_capable(void)
return exposed_mon_capable;
}
+bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid)
+{
+ switch (rid) {
+ case RDT_RESOURCE_L2:
+ case RDT_RESOURCE_L3:
+ return cdp_enabled;
+ case RDT_RESOURCE_MBA:
+ default:
+ /*
+ * x86's MBA control doesn't support CDP, so user-space doesn't
+ * expect it.
+ */
+ return false;
+ }
+}
+
+/**
+ * resctrl_reset_task_closids() - Reset the PARTID/PMG values for all tasks.
+ *
+ * At boot, all existing tasks use partid zero for D and I.
+ * To enable/disable CDP emulation, all these tasks need relabelling.
+ */
+static void resctrl_reset_task_closids(void)
+{
+ struct task_struct *p, *t;
+
+ read_lock(&tasklist_lock);
+ for_each_process_thread(p, t) {
+ resctrl_arch_set_closid_rmid(t, RESCTRL_RESERVED_CLOSID,
+ RESCTRL_RESERVED_RMID);
+ }
+ read_unlock(&tasklist_lock);
+}
+
+int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable)
+{
+ u32 partid_i = RESCTRL_RESERVED_CLOSID, partid_d = RESCTRL_RESERVED_CLOSID;
+
+ cdp_enabled = enable;
+
+ if (enable) {
+ if (mpam_partid_max < 1)
+ return -EINVAL;
+
+ partid_d = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_DATA);
+ partid_i = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_CODE);
+ }
+
+ mpam_set_task_partid_pmg(current, partid_d, partid_i, 0, 0);
+ WRITE_ONCE(arm64_mpam_global_default, mpam_get_regval(current));
+
+ resctrl_reset_task_closids();
+
+ return 0;
+}
+
+static bool mpam_resctrl_hide_cdp(enum resctrl_res_level rid)
+{
+ return cdp_enabled && !resctrl_arch_get_cdp_enabled(rid);
+}
+
/*
* MSC may raise an error interrupt if it sees an out or range partid/pmg,
* and go on to truncate the value. Regardless of what the hardware supports,
@@ -115,6 +180,30 @@ void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid)
}
}
+bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid)
+{
+ u64 regval = mpam_get_regval(tsk);
+ u32 tsk_closid = FIELD_GET(MPAM0_EL1_PARTID_D, regval);
+
+ if (cdp_enabled)
+ tsk_closid >>= 1;
+
+ return tsk_closid == closid;
+}
+
+/* The task's pmg is not unique, the partid must be considered too */
+bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid)
+{
+ u64 regval = mpam_get_regval(tsk);
+ u32 tsk_closid = FIELD_GET(MPAM0_EL1_PARTID_D, regval);
+ u32 tsk_rmid = FIELD_GET(MPAM0_EL1_PMG_D, regval);
+
+ if (cdp_enabled)
+ tsk_closid >>= 1;
+
+ return (tsk_closid == closid) && (tsk_rmid == rmid);
+}
+
struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)
{
if (l >= RDT_NUM_RESOURCES)
@@ -246,6 +335,14 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom);
cprops = &res->class->props;
+ /*
+ * When CDP is enabled, but the resource doesn't support it,
+ * the control is cloned across both partids.
+ * Pick one at random to read:
+ */
+ if (mpam_resctrl_hide_cdp(r->rid))
+ type = CDP_DATA;
+
partid = resctrl_get_config_index(closid, type);
cfg = &dom->ctrl_comp->cfg[partid];
@@ -273,6 +370,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type t, u32 cfg_val)
{
+ int err;
u32 partid;
struct mpam_config cfg;
struct mpam_props *cprops;
@@ -312,6 +410,20 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
return -EINVAL;
}
+ /*
+ * When CDP is enabled, but the resource doesn't support it, we need to
+ * apply the same configuration to the other partid.
+ */
+ if (mpam_resctrl_hide_cdp(r->rid)) {
+ partid = resctrl_get_config_index(closid, CDP_CODE);
+ err = mpam_apply_config(dom->ctrl_comp, partid, &cfg);
+ if (err)
+ return err;
+
+ partid = resctrl_get_config_index(closid, CDP_DATA);
+ return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
+ }
+
return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
}
diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
index 5a78299ec464..d329b1dc148b 100644
--- a/include/linux/arm_mpam.h
+++ b/include/linux/arm_mpam.h
@@ -56,6 +56,8 @@ void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid);
void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid);
void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid);
void resctrl_arch_sched_in(struct task_struct *tsk);
+bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid);
+bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid);
/**
* mpam_register_requestor() - Register a requestor with the MPAM driver
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:48 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: Dave Martin <Dave.Martin@arm.com>
MPAM uses a fixed-point formats for some hardware controls. Resctrl
provides the bandwidth controls as a percentage. Add helpers to convert
between these.
Ensure bwa_wd is at most 16 to make it clear higher values have no meaning.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Ensure bwa_wd is at most 16 (moved from patch 40: arm_mpam: Generate a
configuration for min controls)
Expand comments
---
drivers/resctrl/mpam_devices.c | 7 +++++
drivers/resctrl/mpam_resctrl.c | 51 ++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 0dd7f613f7a3..c2127570cf37 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -713,6 +713,13 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
mpam_set_feature(mpam_feat_mbw_part, props);
props->bwa_wd = FIELD_GET(MPAMF_MBW_IDR_BWA_WD, mbw_features);
+
+ /*
+ * The BWA_WD field can represent 0-63, but the control fields it
+ * describes have a maximum of 16 bits.
+ */
+ props->bwa_wd = min(props->bwa_wd, 16);
+
if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_MAX, mbw_features))
mpam_set_feature(mpam_feat_mbw_max, props);
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 8112bcb85e73..71227d072d46 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -10,6 +10,7 @@
#include <linux/errno.h>
#include <linux/limits.h>
#include <linux/list.h>
+#include <linux/math.h>
#include <linux/printk.h>
#include <linux/rculist.h>
#include <linux/resctrl.h>
@@ -223,6 +224,56 @@ static bool cache_has_usable_cpor(struct mpam_class *class)
return class->props.cpbm_wd <= 32;
}
+/*
+ * Each fixed-point hardware value architecturally represents a range
+ * of values: the full range 0% - 100% is split contiguously into
+ * (1 << cprops->bwa_wd) equal bands.
+ *
+ * Although the bwa_bwd fields have 6 bits the maximum valid value is 16
+ * as it reports the width of fields that are at most 16 bits. When
+ * fewer than 16 bits are valid the least significant bits are
+ * ignored. The implied binary point is kept between bits 15 and 16 and
+ * so the valid bits are leftmost.
+ *
+ * See ARM IHI0099B.a "MPAM system component specification", Section 9.3,
+ * "The fixed-point fractional format" for more information.
+ *
+ * Find the nearest percentage value to the upper bound of the selected band:
+ */
+static u32 mbw_max_to_percent(u16 mbw_max, struct mpam_props *cprops)
+{
+ u32 val = mbw_max;
+
+ val >>= 16 - cprops->bwa_wd;
+ val += 1;
+ val *= MAX_MBA_BW;
+ val = DIV_ROUND_CLOSEST(val, 1 << cprops->bwa_wd);
+
+ return val;
+}
+
+/*
+ * Find the band whose upper bound is closest to the specified percentage.
+ *
+ * A round-to-nearest policy is followed here as a balanced compromise
+ * between unexpected under-commit of the resource (where the total of
+ * a set of resource allocations after conversion is less than the
+ * expected total, due to rounding of the individual converted
+ * percentages) and over-commit (where the total of the converted
+ * allocations is greater than expected).
+ */
+static u16 percent_to_mbw_max(u8 pc, struct mpam_props *cprops)
+{
+ u32 val = pc;
+
+ val <<= cprops->bwa_wd;
+ val = DIV_ROUND_CLOSEST(val, MAX_MBA_BW);
+ val = max(val, 1) - 1;
+ val <<= 16 - cprops->bwa_wd;
+
+ return val;
+}
+
/* Test whether we can export MPAM_CLASS_CACHE:{2,3}? */
static void mpam_resctrl_pick_caches(void)
{
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:49 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: Dave Martin <Dave.Martin@arm.com>
resctrl specifies the format of the control schemes, and these don't match
the hardware.
Some of the conversions are a bit hairy - add some kunit tests.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
[morse: squashed enough of Dave's fixes in here that it's his patch now!]
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Include additional values from the latest spec
---
drivers/resctrl/mpam_resctrl.c | 4 +
drivers/resctrl/test_mpam_resctrl.c | 315 ++++++++++++++++++++++++++++
2 files changed, 319 insertions(+)
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 71227d072d46..b6bbe73bc248 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -767,3 +767,7 @@ int mpam_resctrl_setup(void)
return 0;
}
+
+#ifdef CONFIG_MPAM_KUNIT_TEST
+#include "test_mpam_resctrl.c"
+#endif
diff --git a/drivers/resctrl/test_mpam_resctrl.c b/drivers/resctrl/test_mpam_resctrl.c
new file mode 100644
index 000000000000..b93d6ad87e43
--- /dev/null
+++ b/drivers/resctrl/test_mpam_resctrl.c
@@ -0,0 +1,315 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2025 Arm Ltd.
+/* This file is intended to be included into mpam_resctrl.c */
+
+#include <kunit/test.h>
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/math.h>
+#include <linux/sprintf.h>
+
+struct percent_value_case {
+ u8 pc;
+ u8 width;
+ u16 value;
+};
+
+/*
+ * Mysterious inscriptions taken from the union of ARM DDI 0598D.b,
+ * "Arm Architecture Reference Manual Supplement - Memory System
+ * Resource Partitioning and Monitoring (MPAM), for A-profile
+ * architecture", Section 9.8, "About the fixed-point fractional
+ * format" (exact percentage entries only) and ARM IHI0099B.a
+ * "MPAM system component specification", Section 9.3,
+ * "The fixed-point fractional format":
+ */
+static const struct percent_value_case percent_value_cases[] = {
+ /* Architectural cases: */
+ { 1, 8, 1 }, { 1, 12, 0x27 }, { 1, 16, 0x28e },
+ { 25, 8, 0x3f }, { 25, 12, 0x3ff }, { 25, 16, 0x3fff },
+ { 33, 8, 0x53 }, { 33, 12, 0x546 }, { 33, 16, 0x5479 },
+ { 35, 8, 0x58 }, { 35, 12, 0x598 }, { 35, 16, 0x5998 },
+ { 45, 8, 0x72 }, { 45, 12, 0x732 }, { 45, 16, 0x7332 },
+ { 50, 8, 0x7f }, { 50, 12, 0x7ff }, { 50, 16, 0x7fff },
+ { 52, 8, 0x84 }, { 52, 12, 0x850 }, { 52, 16, 0x851d },
+ { 55, 8, 0x8b }, { 55, 12, 0x8cb }, { 55, 16, 0x8ccb },
+ { 58, 8, 0x93 }, { 58, 12, 0x946 }, { 58, 16, 0x9479 },
+ { 75, 8, 0xbf }, { 75, 12, 0xbff }, { 75, 16, 0xbfff },
+ { 80, 8, 0xcb }, { 80, 12, 0xccb }, { 80, 16, 0xcccb },
+ { 88, 8, 0xe0 }, { 88, 12, 0xe13 }, { 88, 16, 0xe146 },
+ { 95, 8, 0xf2 }, { 95, 12, 0xf32 }, { 95, 16, 0xf332 },
+ { 100, 8, 0xff }, { 100, 12, 0xfff }, { 100, 16, 0xffff },
+};
+
+static void test_percent_value_desc(const struct percent_value_case *param,
+ char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE,
+ "pc=%d, width=%d, value=0x%.*x\n",
+ param->pc, param->width,
+ DIV_ROUND_UP(param->width, 4), param->value);
+}
+
+KUNIT_ARRAY_PARAM(test_percent_value, percent_value_cases,
+ test_percent_value_desc);
+
+struct percent_value_test_info {
+ u32 pc; /* result of value-to-percent conversion */
+ u32 value; /* result of percent-to-value conversion */
+ u32 max_value; /* maximum raw value allowed by test params */
+ unsigned int shift; /* promotes raw testcase value to 16 bits */
+};
+
+/*
+ * Convert a reference percentage to a fixed-point MAX value and
+ * vice-versa, based on param (not test->param_value!)
+ */
+static void __prepare_percent_value_test(struct kunit *test,
+ struct percent_value_test_info *res,
+ const struct percent_value_case *param)
+{
+ struct mpam_props fake_props = { };
+
+ /* Reject bogus test parameters that would break the tests: */
+ KUNIT_ASSERT_GE(test, param->width, 1);
+ KUNIT_ASSERT_LE(test, param->width, 16);
+ KUNIT_ASSERT_LT(test, param->value, 1 << param->width);
+
+ mpam_set_feature(mpam_feat_mbw_max, &fake_props);
+ fake_props.bwa_wd = param->width;
+
+ res->shift = 16 - param->width;
+ res->max_value = GENMASK_U32(param->width - 1, 0);
+ res->value = percent_to_mbw_max(param->pc, &fake_props);
+ res->pc = mbw_max_to_percent(param->value << res->shift, &fake_props);
+}
+
+static void test_get_mba_granularity(struct kunit *test)
+{
+ int ret;
+ struct mpam_props fake_props = { };
+
+ /* Use MBW_MAX */
+ mpam_set_feature(mpam_feat_mbw_max, &fake_props);
+
+ fake_props.bwa_wd = 0;
+ KUNIT_EXPECT_FALSE(test, mba_class_use_mbw_max(&fake_props));
+
+ fake_props.bwa_wd = 1;
+ KUNIT_EXPECT_TRUE(test, mba_class_use_mbw_max(&fake_props));
+
+ /* Architectural maximum: */
+ fake_props.bwa_wd = 16;
+ KUNIT_EXPECT_TRUE(test, mba_class_use_mbw_max(&fake_props));
+
+ /* No usable control... */
+ fake_props.bwa_wd = 0;
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+
+ fake_props.bwa_wd = 1;
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 50); /* DIV_ROUND_UP(100, 1 << 1)% = 50% */
+
+ fake_props.bwa_wd = 2;
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 25); /* DIV_ROUND_UP(100, 1 << 2)% = 25% */
+
+ fake_props.bwa_wd = 3;
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 13); /* DIV_ROUND_UP(100, 1 << 3)% = 13% */
+
+ fake_props.bwa_wd = 6;
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 2); /* DIV_ROUND_UP(100, 1 << 6)% = 2% */
+
+ fake_props.bwa_wd = 7;
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 1); /* DIV_ROUND_UP(100, 1 << 7)% = 1% */
+
+ /* Granularity saturates at 1% */
+ fake_props.bwa_wd = 16; /* architectural maximum */
+ ret = get_mba_granularity(&fake_props);
+ KUNIT_EXPECT_EQ(test, ret, 1); /* DIV_ROUND_UP(100, 1 << 16)% = 1% */
+}
+
+static void test_mbw_max_to_percent(struct kunit *test)
+{
+ const struct percent_value_case *param = test->param_value;
+ struct percent_value_test_info res;
+
+ /*
+ * Since the reference values in percent_value_cases[] all
+ * correspond to exact percentages, round-to-nearest will
+ * always give the exact percentage back when the MPAM max
+ * value has precision of 0.5% or finer. (Always true for the
+ * reference data, since they all specify 8 bits or more of
+ * precision.
+ *
+ * So, keep it simple and demand an exact match:
+ */
+ __prepare_percent_value_test(test, &res, param);
+ KUNIT_EXPECT_EQ(test, res.pc, param->pc);
+}
+
+static void test_percent_to_mbw_max(struct kunit *test)
+{
+ const struct percent_value_case *param = test->param_value;
+ struct percent_value_test_info res;
+
+ __prepare_percent_value_test(test, &res, param);
+
+ KUNIT_EXPECT_GE(test, res.value, param->value << res.shift);
+ KUNIT_EXPECT_LE(test, res.value, (param->value + 1) << res.shift);
+ KUNIT_EXPECT_LE(test, res.value, res.max_value << res.shift);
+
+ /* No flexibility allowed for 0% and 100%! */
+
+ if (param->pc == 0)
+ KUNIT_EXPECT_EQ(test, res.value, 0);
+
+ if (param->pc == 100)
+ KUNIT_EXPECT_EQ(test, res.value, res.max_value << res.shift);
+}
+
+static const void *test_all_bwa_wd_gen_params(struct kunit *test, const void *prev,
+ char *desc)
+{
+ uintptr_t param = (uintptr_t)prev;
+
+ if (param > 15)
+ return NULL;
+
+ param++;
+
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "wd=%u\n", (unsigned int)param);
+
+ return (void *)param;
+}
+
+static unsigned int test_get_bwa_wd(struct kunit *test)
+{
+ uintptr_t param = (uintptr_t)test->param_value;
+
+ KUNIT_ASSERT_GE(test, param, 1);
+ KUNIT_ASSERT_LE(test, param, 16);
+
+ return param;
+}
+
+static void test_mbw_max_to_percent_limits(struct kunit *test)
+{
+ struct mpam_props fake_props = {0};
+ u32 max_value;
+
+ mpam_set_feature(mpam_feat_mbw_max, &fake_props);
+ fake_props.bwa_wd = test_get_bwa_wd(test);
+ max_value = GENMASK(15, 16 - fake_props.bwa_wd);
+
+ KUNIT_EXPECT_EQ(test, mbw_max_to_percent(max_value, &fake_props),
+ MAX_MBA_BW);
+ KUNIT_EXPECT_EQ(test, mbw_max_to_percent(0, &fake_props),
+ get_mba_min(&fake_props));
+
+ /*
+ * Rounding policy dependent 0% sanity-check:
+ * With round-to-nearest, the minimum mbw_max value really
+ * should map to 0% if there are at least 200 steps.
+ * (100 steps may be enough for some other rounding policies.)
+ */
+ if (fake_props.bwa_wd >= 8)
+ KUNIT_EXPECT_EQ(test, mbw_max_to_percent(0, &fake_props), 0);
+
+ if (fake_props.bwa_wd < 8 &&
+ mbw_max_to_percent(0, &fake_props) == 0)
+ kunit_warn(test, "wd=%d: Testsuite/driver Rounding policy mismatch?",
+ fake_props.bwa_wd);
+}
+
+/*
+ * Check that converting a percentage to mbw_max and back again (or, as
+ * appropriate, vice-versa) always restores the original value:
+ */
+static void test_percent_max_roundtrip_stability(struct kunit *test)
+{
+ struct mpam_props fake_props = {0};
+ unsigned int shift;
+ u32 pc, max, pc2, max2;
+
+ mpam_set_feature(mpam_feat_mbw_max, &fake_props);
+ fake_props.bwa_wd = test_get_bwa_wd(test);
+ shift = 16 - fake_props.bwa_wd;
+
+ /*
+ * Converting a valid value from the coarser scale to the finer
+ * scale and back again must yield the original value:
+ */
+ if (fake_props.bwa_wd >= 7) {
+ /* More than 100 steps: only test exact pc values: */
+ for (pc = get_mba_min(&fake_props); pc <= MAX_MBA_BW; pc++) {
+ max = percent_to_mbw_max(pc, &fake_props);
+ pc2 = mbw_max_to_percent(max, &fake_props);
+ KUNIT_EXPECT_EQ(test, pc2, pc);
+ }
+ } else {
+ /* Fewer than 100 steps: only test exact mbw_max values: */
+ for (max = 0; max < 1 << 16; max += 1 << shift) {
+ pc = mbw_max_to_percent(max, &fake_props);
+ max2 = percent_to_mbw_max(pc, &fake_props);
+ KUNIT_EXPECT_EQ(test, max2, max);
+ }
+ }
+}
+
+static void test_percent_to_max_rounding(struct kunit *test)
+{
+ const struct percent_value_case *param = test->param_value;
+ unsigned int num_rounded_up = 0, total = 0;
+ struct percent_value_test_info res;
+
+ for (param = percent_value_cases, total = 0;
+ param < &percent_value_cases[ARRAY_SIZE(percent_value_cases)];
+ param++, total++) {
+ __prepare_percent_value_test(test, &res, param);
+ if (res.value > param->value << res.shift)
+ num_rounded_up++;
+ }
+
+ /*
+ * The MPAM driver applies a round-to-nearest policy, whereas a
+ * round-down policy seems to have been applied in the
+ * reference table from which the test vectors were selected.
+ *
+ * For a large and well-distributed suite of test vectors,
+ * about half should be rounded up and half down compared with
+ * the reference table. The actual test vectors are few in
+ * number and probably not very well distributed however, so
+ * tolerate a round-up rate of between 1/4 and 3/4 before
+ * crying foul:
+ */
+
+ kunit_info(test, "Round-up rate: %u%% (%u/%u)\n",
+ DIV_ROUND_CLOSEST(num_rounded_up * 100, total),
+ num_rounded_up, total);
+
+ KUNIT_EXPECT_GE(test, 4 * num_rounded_up, 1 * total);
+ KUNIT_EXPECT_LE(test, 4 * num_rounded_up, 3 * total);
+}
+
+static struct kunit_case mpam_resctrl_test_cases[] = {
+ KUNIT_CASE(test_get_mba_granularity),
+ KUNIT_CASE_PARAM(test_mbw_max_to_percent, test_percent_value_gen_params),
+ KUNIT_CASE_PARAM(test_percent_to_mbw_max, test_percent_value_gen_params),
+ KUNIT_CASE_PARAM(test_mbw_max_to_percent_limits, test_all_bwa_wd_gen_params),
+ KUNIT_CASE(test_percent_to_max_rounding),
+ KUNIT_CASE_PARAM(test_percent_max_roundtrip_stability,
+ test_all_bwa_wd_gen_params),
+ {}
+};
+
+static struct kunit_suite mpam_resctrl_test_suite = {
+ .name = "mpam_resctrl_test_suite",
+ .test_cases = mpam_resctrl_test_cases,
+};
+
+kunit_test_suites(&mpam_resctrl_test_suite);
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:50 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
Because MPAM's pmg aren't identical to RDT's rmid, resctrl handles some
data structures by index. This allows x86 to map indexes to RMID, and MPAM
to map them to partid-and-pmg.
Add the helpers to do this.
Suggested-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Use ~0U instead of ~0 in lhs of left shift
Changes since v2:
Drop changes signed-off-by as reworked patch
Use multiply and add rather than shift to avoid holes
---
drivers/resctrl/mpam_resctrl.c | 16 ++++++++++++++++
include/linux/arm_mpam.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index b6bbe73bc248..92b2a2d4b51d 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -126,6 +126,22 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored)
return mpam_partid_max + 1;
}
+u32 resctrl_arch_system_num_rmid_idx(void)
+{
+ return (mpam_pmg_max + 1) * (mpam_partid_max + 1);
+}
+
+u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid)
+{
+ return closid * (mpam_pmg_max + 1) + rmid;
+}
+
+void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid)
+{
+ *closid = idx / (mpam_pmg_max + 1);
+ *rmid = idx % (mpam_pmg_max + 1);
+}
+
void resctrl_arch_sched_in(struct task_struct *tsk)
{
lockdep_assert_preemption_disabled();
diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
index d329b1dc148b..7d23c90f077d 100644
--- a/include/linux/arm_mpam.h
+++ b/include/linux/arm_mpam.h
@@ -58,6 +58,9 @@ void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid);
void resctrl_arch_sched_in(struct task_struct *tsk);
bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid);
bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid);
+u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid);
+void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid);
+u32 resctrl_arch_system_num_rmid_idx(void);
/**
* mpam_register_requestor() - Register a requestor with the MPAM driver
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:51 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
As MPAM's pmg are scoped by partid and RDT's rmid are global the
rescrl mapping to an index needs to differ.
Add some tests for the MPAM rmid mapping.
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
drivers/resctrl/test_mpam_resctrl.c | 49 +++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/resctrl/test_mpam_resctrl.c b/drivers/resctrl/test_mpam_resctrl.c
index b93d6ad87e43..a20da161d965 100644
--- a/drivers/resctrl/test_mpam_resctrl.c
+++ b/drivers/resctrl/test_mpam_resctrl.c
@@ -296,6 +296,54 @@ static void test_percent_to_max_rounding(struct kunit *test)
KUNIT_EXPECT_LE(test, 4 * num_rounded_up, 3 * total);
}
+struct rmid_idx_case {
+ u32 max_partid;
+ u32 max_pmg;
+};
+
+static const struct rmid_idx_case rmid_idx_cases[] = {
+ {0, 0}, {1, 4}, {3, 1}, {5, 9}, {4, 4}, {100, 11}, {0xFFFF, 0xFF},
+};
+
+static void test_rmid_idx_desc(const struct rmid_idx_case *param, char *desc)
+{
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE, "max_partid=%d, max_pmg=%d\n",
+ param->max_partid, param->max_pmg);
+}
+
+KUNIT_ARRAY_PARAM(test_rmid_idx, rmid_idx_cases, test_rmid_idx_desc);
+
+static void test_rmid_idx_encoding(struct kunit *test)
+{
+ u32 orig_mpam_partid_max = mpam_partid_max;
+ u32 orig_mpam_pmg_max = mpam_pmg_max;
+ const struct rmid_idx_case *param = test->param_value;
+ u32 idx, num_idx, count = 0;
+
+ mpam_partid_max = param->max_partid;
+ mpam_pmg_max = param->max_pmg;
+
+ for (u32 partid = 0; partid <= mpam_partid_max; partid++) {
+ for (u32 pmg = 0; pmg <= mpam_pmg_max; pmg++) {
+ u32 partid_out, pmg_out;
+
+ idx = resctrl_arch_rmid_idx_encode(partid, pmg);
+ /* Confirm there are no holes in the rmid idx range */
+ KUNIT_EXPECT_EQ(test, count, idx);
+ count++;
+ resctrl_arch_rmid_idx_decode(idx, &partid_out, &pmg_out);
+ KUNIT_EXPECT_EQ(test, pmg, pmg_out);
+ KUNIT_EXPECT_EQ(test, partid, partid_out);
+ }
+ }
+ num_idx = resctrl_arch_system_num_rmid_idx();
+ KUNIT_EXPECT_EQ(test, idx + 1, num_idx);
+
+ /* Restore global variables that were messed with */
+ mpam_partid_max = orig_mpam_partid_max;
+ mpam_pmg_max = orig_mpam_pmg_max;
+}
+
static struct kunit_case mpam_resctrl_test_cases[] = {
KUNIT_CASE(test_get_mba_granularity),
KUNIT_CASE_PARAM(test_mbw_max_to_percent, test_percent_value_gen_params),
@@ -304,6 +352,7 @@ static struct kunit_case mpam_resctrl_test_cases[] = {
KUNIT_CASE(test_percent_to_max_rounding),
KUNIT_CASE_PARAM(test_percent_max_roundtrip_stability,
test_all_bwa_wd_gen_params),
+ KUNIT_CASE_PARAM(test_rmid_idx_encoding, test_rmid_idx_gen_params),
{}
};
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:52 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
In order to calculate the rmid realloc threshold the size of the cache
needs to be known. Cache domains will also be named after the cache id. So
that this information can be extracted from cacheinfo we need to wait for
it to be ready. The cacheinfo information is populated in device_initcall()
so we wait for that.
Signed-off-by: James Morse <james.morse@arm.com>
[horgan: split out from another patch]
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
This is moved into it's own patch to allow all uses of cacheinfo to be
valid when they are introduced.
---
drivers/resctrl/mpam_resctrl.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 92b2a2d4b51d..3ca977527698 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -16,6 +16,7 @@
#include <linux/resctrl.h>
#include <linux/slab.h>
#include <linux/types.h>
+#include <linux/wait.h>
#include <asm/mpam.h>
@@ -45,6 +46,13 @@ static bool exposed_mon_capable;
*/
static bool cdp_enabled;
+/*
+ * We use cacheinfo to discover the size of the caches and their id. cacheinfo
+ * populates this from a device_initcall(). mpam_resctrl_setup() must wait.
+ */
+static bool cacheinfo_ready;
+static DECLARE_WAIT_QUEUE_HEAD(wait_cacheinfo_ready);
+
bool resctrl_arch_alloc_capable(void)
{
return exposed_alloc_capable;
@@ -745,6 +753,8 @@ int mpam_resctrl_setup(void)
struct mpam_resctrl_res *res;
enum resctrl_res_level rid;
+ wait_event(wait_cacheinfo_ready, cacheinfo_ready);
+
cpus_read_lock();
for_each_mpam_resctrl_control(res, rid) {
INIT_LIST_HEAD_RCU(&res->resctrl_res.ctrl_domains);
@@ -784,6 +794,15 @@ int mpam_resctrl_setup(void)
return 0;
}
+static int __init __cacheinfo_ready(void)
+{
+ cacheinfo_ready = true;
+ wake_up(&wait_cacheinfo_ready);
+
+ return 0;
+}
+device_initcall_sync(__cacheinfo_ready);
+
#ifdef CONFIG_MPAM_KUNIT_TEST
#include "test_mpam_resctrl.c"
#endif
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:53 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
resctrl supports 'MB', as a percentage throttling of traffic somewhere
after the L3. This is the control that mba_sc uses, so ideally the class
chosen should be as close as possible to the counters used for mba_local.
MB's percentage control should be backed either with the fixed point
fraction MBW_MAX or bandwidth portion bitmaps. The bandwidth portion
bitmaps is not used as its tricky to pick which bits to use to avoid
contention, and may be possible to expose this as something other than a
percentage in the future.
CC: Zeng Heng <zengheng4@huawei.com>
Co-developed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Code flow change
Commit message 'or'
---
drivers/resctrl/mpam_resctrl.c | 209 ++++++++++++++++++++++++++++++++-
1 file changed, 208 insertions(+), 1 deletion(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 3ca977527698..7402bf4293b6 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -248,6 +248,33 @@ static bool cache_has_usable_cpor(struct mpam_class *class)
return class->props.cpbm_wd <= 32;
}
+static bool mba_class_use_mbw_max(struct mpam_props *cprops)
+{
+ return (mpam_has_feature(mpam_feat_mbw_max, cprops) &&
+ cprops->bwa_wd);
+}
+
+static bool class_has_usable_mba(struct mpam_props *cprops)
+{
+ return mba_class_use_mbw_max(cprops);
+}
+
+/*
+ * Calculate the worst-case percentage change from each implemented step
+ * in the control.
+ */
+static u32 get_mba_granularity(struct mpam_props *cprops)
+{
+ if (!mba_class_use_mbw_max(cprops))
+ return 0;
+
+ /*
+ * bwa_wd is the number of bits implemented in the 0.xxx
+ * fixed point fraction. 1 bit is 50%, 2 is 25% etc.
+ */
+ return DIV_ROUND_UP(MAX_MBA_BW, 1 << cprops->bwa_wd);
+}
+
/*
* Each fixed-point hardware value architecturally represents a range
* of values: the full range 0% - 100% is split contiguously into
@@ -298,6 +325,94 @@ static u16 percent_to_mbw_max(u8 pc, struct mpam_props *cprops)
return val;
}
+static u32 get_mba_min(struct mpam_props *cprops)
+{
+ if (!mba_class_use_mbw_max(cprops)) {
+ WARN_ON_ONCE(1);
+ return 0;
+ }
+
+ return mbw_max_to_percent(0, cprops);
+}
+
+/* Find the L3 cache that has affinity with this CPU */
+static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
+{
+ u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
+
+ lockdep_assert_cpus_held();
+
+ return mpam_get_cpumask_from_cache_id(cache_id, 3, tmp_cpumask);
+}
+
+/*
+ * topology_matches_l3() - Is the provided class the same shape as L3
+ * @victim: The class we'd like to pretend is L3.
+ *
+ * resctrl expects all the world's a Xeon, and all counters are on the
+ * L3. We play fast and loose with this, mapping counters on other
+ * classes - provided the CPU->domain mapping is the same kind of shape.
+ *
+ * Using cacheinfo directly would make this work even if resctrl can't
+ * use the L3 - but cacheinfo can't tell us anything about offline CPUs.
+ * Using the L3 resctrl domain list also depends on CPUs being online.
+ * Using the mpam_class we picked for L3 so we can use its domain list
+ * assumes that there are MPAM controls on the L3.
+ * Instead, this path eventually uses the mpam_get_cpumask_from_cache_id()
+ * helper which can tell us about offline CPUs ... but getting the cache_id
+ * to start with relies on at least one CPU per L3 cache being online at
+ * boot.
+ *
+ * Walk the victim component list and compare the affinity mask with the
+ * corresponding L3. The topology matches if each victim:component's affinity
+ * mask is the same as the CPU's corresponding L3's. These lists/masks are
+ * computed from firmware tables so don't change at runtime.
+ */
+static bool topology_matches_l3(struct mpam_class *victim)
+{
+ int cpu, err;
+ struct mpam_component *victim_iter;
+ cpumask_var_t __free(free_cpumask_var) tmp_cpumask;
+
+ if (!alloc_cpumask_var(&tmp_cpumask, GFP_KERNEL))
+ return false;
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(victim_iter, &victim->components, class_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ if (cpumask_empty(&victim_iter->affinity)) {
+ pr_debug("class %u has CPU-less component %u - can't match L3!\n",
+ victim->level, victim_iter->comp_id);
+ return false;
+ }
+
+ cpu = cpumask_any(&victim_iter->affinity);
+ if (WARN_ON_ONCE(cpu >= nr_cpu_ids))
+ return false;
+
+ cpumask_clear(tmp_cpumask);
+ err = find_l3_equivalent_bitmask(cpu, tmp_cpumask);
+ if (err) {
+ pr_debug("Failed to find L3's equivalent component to class %u component %u\n",
+ victim->level, victim_iter->comp_id);
+ return false;
+ }
+
+ /* Any differing bits in the affinity mask? */
+ if (!cpumask_equal(tmp_cpumask, &victim_iter->affinity)) {
+ pr_debug("class %u component %u has Mismatched CPU mask with L3 equivalent\n"
+ "L3:%*pbl != victim:%*pbl\n",
+ victim->level, victim_iter->comp_id,
+ cpumask_pr_args(tmp_cpumask),
+ cpumask_pr_args(&victim_iter->affinity));
+
+ return false;
+ }
+ }
+
+ return true;
+}
+
/* Test whether we can export MPAM_CLASS_CACHE:{2,3}? */
static void mpam_resctrl_pick_caches(void)
{
@@ -340,9 +455,62 @@ static void mpam_resctrl_pick_caches(void)
}
}
+static void mpam_resctrl_pick_mba(void)
+{
+ struct mpam_class *class, *candidate_class = NULL;
+ struct mpam_resctrl_res *res;
+
+ lockdep_assert_cpus_held();
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(class, &mpam_classes, classes_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ struct mpam_props *cprops = &class->props;
+
+ if (class->level < 3) {
+ pr_debug("class %u is before L3\n", class->level);
+ continue;
+ }
+
+ if (!class_has_usable_mba(cprops)) {
+ pr_debug("class %u has no bandwidth control\n",
+ class->level);
+ continue;
+ }
+
+ if (!cpumask_equal(&class->affinity, cpu_possible_mask)) {
+ pr_debug("class %u has missing CPUs\n", class->level);
+ continue;
+ }
+
+ if (!topology_matches_l3(class)) {
+ pr_debug("class %u topology doesn't match L3\n",
+ class->level);
+ continue;
+ }
+
+ /*
+ * mba_sc reads the mbm_local counter, and waggles the MBA
+ * controls. mbm_local is implicitly part of the L3, pick a
+ * resource to be MBA that as close as possible to the L3.
+ */
+ if (!candidate_class || class->level < candidate_class->level)
+ candidate_class = class;
+ }
+
+ if (candidate_class) {
+ pr_debug("selected class %u to back MBA\n",
+ candidate_class->level);
+ res = &mpam_resctrl_controls[RDT_RESOURCE_MBA];
+ res->class = candidate_class;
+ exposed_alloc_capable = true;
+ }
+}
+
static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
{
struct mpam_class *class = res->class;
+ struct mpam_props *cprops = &class->props;
struct rdt_resource *r = &res->resctrl_res;
switch (r->rid) {
@@ -372,6 +540,19 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
*/
r->cache.shareable_bits = resctrl_get_default_ctrl(r);
break;
+ case RDT_RESOURCE_MBA:
+ r->alloc_capable = true;
+ r->schema_fmt = RESCTRL_SCHEMA_RANGE;
+ r->ctrl_scope = RESCTRL_L3_CACHE;
+
+ r->membw.delay_linear = true;
+ r->membw.throttle_mode = THREAD_THROTTLE_UNDEFINED;
+ r->membw.min_bw = get_mba_min(cprops);
+ r->membw.max_bw = MAX_MBA_BW;
+ r->membw.bw_gran = get_mba_granularity(cprops);
+
+ r->name = "MB";
+ break;
default:
return -EINVAL;
}
@@ -386,7 +567,17 @@ static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
if (class->type == MPAM_CLASS_CACHE)
return comp->comp_id;
- /* TODO: repaint domain ids to match the L3 domain ids */
+ if (topology_matches_l3(class)) {
+ /* Use the corresponding L3 component ID as the domain ID */
+ int id = get_cpu_cacheinfo_id(cpu, 3);
+
+ /* Implies topology_matches_l3() made a mistake */
+ if (WARN_ON_ONCE(id == -1))
+ return comp->comp_id;
+
+ return id;
+ }
+
/* Otherwise, expose the ID used by the firmware table code. */
return comp->comp_id;
}
@@ -426,6 +617,12 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
case RDT_RESOURCE_L3:
configured_by = mpam_feat_cpor_part;
break;
+ case RDT_RESOURCE_MBA:
+ if (mpam_has_feature(mpam_feat_mbw_max, cprops)) {
+ configured_by = mpam_feat_mbw_max;
+ break;
+ }
+ fallthrough;
default:
return resctrl_get_default_ctrl(r);
}
@@ -437,6 +634,8 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
switch (configured_by) {
case mpam_feat_cpor_part:
return cfg->cpbm;
+ case mpam_feat_mbw_max:
+ return mbw_max_to_percent(cfg->mbw_max, cprops);
default:
return resctrl_get_default_ctrl(r);
}
@@ -481,6 +680,13 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
cfg.cpbm = cfg_val;
mpam_set_feature(mpam_feat_cpor_part, &cfg);
break;
+ case RDT_RESOURCE_MBA:
+ if (mpam_has_feature(mpam_feat_mbw_max, cprops)) {
+ cfg.mbw_max = percent_to_mbw_max(cfg_val, cprops);
+ mpam_set_feature(mpam_feat_mbw_max, &cfg);
+ break;
+ }
+ fallthrough;
default:
return -EINVAL;
}
@@ -764,6 +970,7 @@ int mpam_resctrl_setup(void)
/* Find some classes to use for controls */
mpam_resctrl_pick_caches();
+ mpam_resctrl_pick_mba();
/* Initialise the resctrl structures from the classes */
for_each_mpam_resctrl_control(res, rid) {
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:54 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
resctrl exposes a counter via a file named llc_occupancy. This isn't really
a counter as its value goes up and down, this is a snapshot of the cache
storage usage monitor.
Add some picking code to find a cache as close as possible to the L3 that
supports the CSU monitor.
If there is an L3, but it doesn't have any controls, force the L3 resource
to exist. The existing topology_matches_l3() and
mpam_resctrl_domain_hdr_init() code will ensure this looks like the L3,
even if the class belongs to a later cache.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Co-developed-by: Dave Martin <dave.martin@arm.com>
Signed-off-by: Dave Martin <dave.martin@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
Allow csu counters however many partid or pmg there are
else if -> if
reduce scope of local variables
drop has_csu
Changes since v2:
return -> break so works for mbwu in later patch
add for_each_mpam_resctrl_mon
return error from mpam_resctrl_monitor_init(). It may fail when is abmc
allocation introduced in a later patch.
Squashed in patch from Dave Martin:
https://lore.kernel.org/lkml/20250820131621.54983-1-Dave.Martin@arm.com/
---
drivers/resctrl/mpam_internal.h | 6 ++
drivers/resctrl/mpam_resctrl.c | 173 +++++++++++++++++++++++++++++++-
2 files changed, 174 insertions(+), 5 deletions(-)
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index f89ceaf7623d..21cc776e57aa 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -349,6 +349,12 @@ struct mpam_resctrl_res {
struct rdt_resource resctrl_res;
};
+struct mpam_resctrl_mon {
+ struct mpam_class *class;
+
+ /* per-class data that resctrl needs will live here */
+};
+
static inline int mpam_alloc_csu_mon(struct mpam_class *class)
{
struct mpam_props *cprops = &class->props;
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 7402bf4293b6..5020a5faed96 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -37,6 +37,21 @@ static struct mpam_resctrl_res mpam_resctrl_controls[RDT_NUM_RESOURCES];
/* The lock for modifying resctrl's domain lists from cpuhp callbacks. */
static DEFINE_MUTEX(domain_list_lock);
+/*
+ * The classes we've picked to map to resctrl events.
+ * Resctrl believes all the worlds a Xeon, and these are all on the L3. This
+ * array lets us find the actual class backing the event counters. e.g.
+ * the only memory bandwidth counters may be on the memory controller, but to
+ * make use of them, we pretend they are on L3.
+ * Class pointer may be NULL.
+ */
+static struct mpam_resctrl_mon mpam_resctrl_counters[QOS_NUM_EVENTS];
+
+#define for_each_mpam_resctrl_mon(mon, eventid) \
+ for (eventid = 0, mon = &mpam_resctrl_counters[eventid]; \
+ eventid < QOS_NUM_EVENTS; \
+ eventid++, mon = &mpam_resctrl_counters[eventid])
+
static bool exposed_alloc_capable;
static bool exposed_mon_capable;
@@ -259,6 +274,28 @@ static bool class_has_usable_mba(struct mpam_props *cprops)
return mba_class_use_mbw_max(cprops);
}
+static bool cache_has_usable_csu(struct mpam_class *class)
+{
+ struct mpam_props *cprops;
+
+ if (!class)
+ return false;
+
+ cprops = &class->props;
+
+ if (!mpam_has_feature(mpam_feat_msmon_csu, cprops))
+ return false;
+
+ /*
+ * CSU counters settle on the value, so we can get away with
+ * having only one.
+ */
+ if (!cprops->num_csu_mon)
+ return false;
+
+ return true;
+}
+
/*
* Calculate the worst-case percentage change from each implemented step
* in the control.
@@ -507,6 +544,64 @@ static void mpam_resctrl_pick_mba(void)
}
}
+static void counter_update_class(enum resctrl_event_id evt_id,
+ struct mpam_class *class)
+{
+ struct mpam_class *existing_class = mpam_resctrl_counters[evt_id].class;
+
+ if (existing_class) {
+ if (class->level == 3) {
+ pr_debug("Existing class is L3 - L3 wins\n");
+ return;
+ }
+
+ if (existing_class->level < class->level) {
+ pr_debug("Existing class is closer to L3, %u versus %u - closer is better\n",
+ existing_class->level, class->level);
+ return;
+ }
+ }
+
+ mpam_resctrl_counters[evt_id].class = class;
+ exposed_mon_capable = true;
+}
+
+static void mpam_resctrl_pick_counters(void)
+{
+ struct mpam_class *class;
+
+ lockdep_assert_cpus_held();
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(class, &mpam_classes, classes_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ if (class->level < 3) {
+ pr_debug("class %u is before L3", class->level);
+ continue;
+ }
+
+ if (!cpumask_equal(&class->affinity, cpu_possible_mask)) {
+ pr_debug("class %u does not cover all CPUs",
+ class->level);
+ continue;
+ }
+
+ if (cache_has_usable_csu(class) && topology_matches_l3(class)) {
+ pr_debug("class %u has usable CSU, and matches L3 topology",
+ class->level);
+
+ /* CSU counters only make sense on a cache. */
+ switch (class->type) {
+ case MPAM_CLASS_CACHE:
+ counter_update_class(QOS_L3_OCCUP_EVENT_ID, class);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
{
struct mpam_class *class = res->class;
@@ -582,6 +677,57 @@ static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
return comp->comp_id;
}
+static int mpam_resctrl_monitor_init(struct mpam_resctrl_mon *mon,
+ enum resctrl_event_id type)
+{
+ struct mpam_resctrl_res *res = &mpam_resctrl_controls[RDT_RESOURCE_L3];
+ struct rdt_resource *l3 = &res->resctrl_res;
+
+ lockdep_assert_cpus_held();
+
+ /* There also needs to be an L3 cache present */
+ if (get_cpu_cacheinfo_id(smp_processor_id(), 3) == -1)
+ return 0;
+
+ /*
+ * If there are no MPAM resources on L3, force it into existence.
+ * topology_matches_l3() already ensures this looks like the L3.
+ * The domain-ids will be fixed up by mpam_resctrl_domain_hdr_init().
+ */
+ if (!res->class) {
+ pr_warn_once("Faking L3 MSC to enable counters.\n");
+ res->class = mpam_resctrl_counters[type].class;
+ }
+
+ /* Called multiple times!, once per event type */
+ if (exposed_mon_capable) {
+ l3->mon_capable = true;
+
+ /* Setting name is necessary on monitor only platforms */
+ l3->name = "L3";
+ l3->mon_scope = RESCTRL_L3_CACHE;
+
+ resctrl_enable_mon_event(type);
+
+ /*
+ * Unfortunately, num_rmid doesn't mean anything for
+ * mpam, and its exposed to user-space!
+ *
+ * num-rmid is supposed to mean the minimum number of
+ * monitoring groups that can exist simultaneously, including
+ * the default monitoring group for each control group.
+ *
+ * For mpam, each control group has its own pmg/rmid space, so
+ * it is not appropriate to advertise the whole rmid_idx space
+ * here. But the pmgs corresponding to the parent control
+ * group can be allocated freely:
+ */
+ l3->mon.num_rmid = mpam_pmg_max + 1;
+ }
+
+ return 0;
+}
+
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type type)
{
@@ -958,6 +1104,8 @@ int mpam_resctrl_setup(void)
int err = 0;
struct mpam_resctrl_res *res;
enum resctrl_res_level rid;
+ struct mpam_resctrl_mon *mon;
+ enum resctrl_event_id eventid;
wait_event(wait_cacheinfo_ready, cacheinfo_ready);
@@ -980,16 +1128,26 @@ int mpam_resctrl_setup(void)
err = mpam_resctrl_control_init(res);
if (err) {
pr_debug("Failed to initialise rid %u\n", rid);
- break;
+ goto internal_error;
}
}
- cpus_read_unlock();
- if (err) {
- pr_debug("Internal error %d - resctrl not supported\n", err);
- return err;
+ /* Find some classes to use for monitors */
+ mpam_resctrl_pick_counters();
+
+ for_each_mpam_resctrl_mon(mon, eventid) {
+ if (!mon->class)
+ continue; // dummy resource
+
+ err = mpam_resctrl_monitor_init(mon, eventid);
+ if (err) {
+ pr_debug("Failed to initialise event %u\n", eventid);
+ goto internal_error;
+ }
}
+ cpus_read_unlock();
+
if (!exposed_alloc_capable && !exposed_mon_capable) {
pr_debug("No alloc(%u) or monitor(%u) found - resctrl not supported\n",
exposed_alloc_capable, exposed_mon_capable);
@@ -999,6 +1157,11 @@ int mpam_resctrl_setup(void)
/* TODO: call resctrl_init() */
return 0;
+
+internal_error:
+ cpus_read_unlock();
+ pr_debug("Internal error %d - resctrl not supported\n", err);
+ return err;
}
static int __init __cacheinfo_ready(void)
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:55 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
resctrl has two types of counters, NUMA-local and global. MPAM has only
bandwidth counters, but the position of the MSC may mean it counts
NUMA-local, or global traffic.
But the topology information is not available.
Apply a heuristic: the L2 or L3 supports bandwidth monitors, these are
probably NUMA-local. If the memory controller supports bandwidth monitors,
they are probably global.
This also allows us to assert that we don't have the same class backing two
different resctrl events.
Because the class or component backing the event may not be 'the L3', it is
necessary for mpam_resctrl_get_domain_from_cpu() to search the monitor
domains too. This matters the most for 'monitor only' systems, where 'the
L3' control domains may be empty, and the ctrl_comp pointer NULL.
resctrl expects there to be enough monitors for every possible control and
monitor group to have one. Such a system gets called 'free running' as the
monitors can be programmed once and left running. Any other platform will
need to emulate ABMC.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since rfc:
drop has_mbwu
Changes since v2:
Iterate over mpam_resctrl_dom directly (Jonathan)
Use for_each_mpam_resctrl_mon
---
drivers/resctrl/mpam_internal.h | 8 ++
drivers/resctrl/mpam_resctrl.c | 133 +++++++++++++++++++++++++++++++-
2 files changed, 139 insertions(+), 2 deletions(-)
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 21cc776e57aa..1c5492008fe8 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -340,6 +340,14 @@ struct mpam_msc_ris {
struct mpam_resctrl_dom {
struct mpam_component *ctrl_comp;
+
+ /*
+ * There is no single mon_comp because different events may be backed
+ * by different class/components. mon_comp is indexed by the event
+ * number.
+ */
+ struct mpam_component *mon_comp[QOS_NUM_EVENTS];
+
struct rdt_ctrl_domain resctrl_ctrl_dom;
struct rdt_mon_domain resctrl_mon_dom;
};
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 5020a5faed96..14a8dcaf1366 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -68,6 +68,14 @@ static bool cdp_enabled;
static bool cacheinfo_ready;
static DECLARE_WAIT_QUEUE_HEAD(wait_cacheinfo_ready);
+/* Whether this num_mbw_mon could result in a free_running system */
+static int __mpam_monitors_free_running(u16 num_mbwu_mon)
+{
+ if (num_mbwu_mon >= resctrl_arch_system_num_rmid_idx())
+ return resctrl_arch_system_num_rmid_idx();
+ return 0;
+}
+
bool resctrl_arch_alloc_capable(void)
{
return exposed_alloc_capable;
@@ -296,6 +304,26 @@ static bool cache_has_usable_csu(struct mpam_class *class)
return true;
}
+static bool class_has_usable_mbwu(struct mpam_class *class)
+{
+ struct mpam_props *cprops = &class->props;
+
+ if (!mpam_has_feature(mpam_feat_msmon_mbwu, cprops))
+ return false;
+
+ /*
+ * resctrl expects the bandwidth counters to be free running,
+ * which means we need as many monitors as resctrl has
+ * control/monitor groups.
+ */
+ if (__mpam_monitors_free_running(cprops->num_mbwu_mon)) {
+ pr_debug("monitors usable in free-running mode\n");
+ return true;
+ }
+
+ return false;
+}
+
/*
* Calculate the worst-case percentage change from each implemented step
* in the control.
@@ -599,7 +627,36 @@ static void mpam_resctrl_pick_counters(void)
break;
}
}
+
+ if (class_has_usable_mbwu(class) && topology_matches_l3(class)) {
+ pr_debug("class %u has usable MBWU, and matches L3 topology",
+ class->level);
+
+ /*
+ * MBWU counters may be 'local' or 'total' depending on
+ * where they are in the topology. Counters on caches
+ * are assumed to be local. If it's on the memory
+ * controller, its assumed to be global.
+ */
+ switch (class->type) {
+ case MPAM_CLASS_CACHE:
+ counter_update_class(QOS_L3_MBM_LOCAL_EVENT_ID,
+ class);
+ break;
+ case MPAM_CLASS_MEMORY:
+ counter_update_class(QOS_L3_MBM_TOTAL_EVENT_ID,
+ class);
+ break;
+ default:
+ break;
+ }
+ }
}
+
+ /* Allocation of MBWU monitors assumes that the class is unique... */
+ if (mpam_resctrl_counters[QOS_L3_MBM_LOCAL_EVENT_ID].class)
+ WARN_ON_ONCE(mpam_resctrl_counters[QOS_L3_MBM_LOCAL_EVENT_ID].class ==
+ mpam_resctrl_counters[QOS_L3_MBM_TOTAL_EVENT_ID].class);
}
static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
@@ -942,6 +999,20 @@ static void mpam_resctrl_domain_insert(struct list_head *list,
list_add_tail_rcu(&new->list, pos);
}
+static struct mpam_component *find_component(struct mpam_class *class, int cpu)
+{
+ struct mpam_component *comp;
+
+ guard(srcu)(&mpam_srcu);
+ list_for_each_entry_srcu(comp, &class->components, class_list,
+ srcu_read_lock_held(&mpam_srcu)) {
+ if (cpumask_test_cpu(cpu, &comp->affinity))
+ return comp;
+ }
+
+ return NULL;
+}
+
static struct mpam_resctrl_dom *
mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
{
@@ -990,8 +1061,33 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
}
if (exposed_mon_capable) {
+ struct mpam_component *any_mon_comp;
+ struct mpam_resctrl_mon *mon;
+ enum resctrl_event_id eventid;
+
+ /*
+ * Even if the monitor domain is backed by a different
+ * component, the L3 component IDs need to be used... only
+ * there may be no ctrl_comp for the L3.
+ * Search each event's class list for a component with
+ * overlapping CPUs and set up the dom->mon_comp array.
+ */
+
+ for_each_mpam_resctrl_mon(mon, eventid) {
+ struct mpam_component *mon_comp;
+
+ if (!mon->class)
+ continue; // dummy resource
+
+ mon_comp = find_component(mon->class, cpu);
+ dom->mon_comp[eventid] = mon_comp;
+ if (mon_comp)
+ any_mon_comp = mon_comp;
+ }
+ WARN_ON_ONCE(!any_mon_comp);
+
mon_d = &dom->resctrl_mon_dom;
- mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &mon_d->hdr);
+ mpam_resctrl_domain_hdr_init(cpu, any_mon_comp, &mon_d->hdr);
mon_d->hdr.type = RESCTRL_MON_DOMAIN;
mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr);
err = resctrl_online_mon_domain(r, mon_d);
@@ -1013,6 +1109,35 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
return dom;
}
+/*
+ * We know all the monitors are associated with the L3, even if there are no
+ * controls and therefore no control component. Find the cache-id for the CPU
+ * and use that to search for existing resctrl domains.
+ * This relies on mpam_resctrl_pick_domain_id() using the L3 cache-id
+ * for anything that is not a cache.
+ */
+static struct mpam_resctrl_dom *mpam_resctrl_get_mon_domain_from_cpu(int cpu)
+{
+ u32 cache_id;
+ struct mpam_resctrl_dom *dom;
+ struct mpam_resctrl_res *l3 = &mpam_resctrl_controls[RDT_RESOURCE_L3];
+
+ lockdep_assert_cpus_held();
+
+ if (!l3->class)
+ return NULL;
+ cache_id = get_cpu_cacheinfo_id(cpu, 3);
+ if (cache_id == ~0)
+ return NULL;
+
+ list_for_each_entry_rcu(dom, &l3->resctrl_res.mon_domains, resctrl_mon_dom.hdr.list) {
+ if (dom->resctrl_mon_dom.hdr.id == cache_id)
+ return dom;
+ }
+
+ return NULL;
+}
+
static struct mpam_resctrl_dom *
mpam_resctrl_get_domain_from_cpu(int cpu, struct mpam_resctrl_res *res)
{
@@ -1026,7 +1151,11 @@ mpam_resctrl_get_domain_from_cpu(int cpu, struct mpam_resctrl_res *res)
return dom;
}
- return NULL;
+ if (r->rid != RDT_RESOURCE_L3)
+ return NULL;
+
+ /* Search the mon domain list too - needed on monitor only platforms. */
+ return mpam_resctrl_get_mon_domain_from_cpu(cpu);
}
int mpam_resctrl_online_cpu(unsigned int cpu)
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:56 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
lkml
|
[PATCH v3 00/47] arm_mpam: Add KVM/arm64 and resctrl glue code
|
This new version of the mpam missing pieces has no major rework from the
previous version. It's mainly small corrections and code tidying based on
review and things I spotted along the way. To be able to merge this we need
review from more people and people to start testing on their platforms and
giving some Tested-by tags.
Change list in patches.
As mentioned in the cover letter for v2, one major departure from the
previous snapshot branches referenced in the base driver series is that the
same MPAM setting are used for kernel-space and user-space. There are pros
and cons of choosing this policy but I think it is the best thing to start
with as there are AMD plans for adding a resctrl feature to allow a
different closid/rmid configuration for user-space from kernel space. The
AMD feature is called PLZA and is mentioned in this lpc slide deck[1]. This
gives us a path forward to add support for having the EL1 and EL0 MPAM
partid/pmg configuration differ from each other.
>From James' cover letter:
This is the missing piece to make MPAM usable resctrl in user-space. This has
shed its debugfs code and the read/write 'event configuration' for the monitors
to make the series smaller.
This adds the arch code and KVM support first. I anticipate the whole thing
going via arm64, but if goes via tip instead, the an immutable branch with those
patches should be easy to do.
Generally the resctrl glue code works by picking what MPAM features it can expose
from the MPAM drive, then configuring the structs that back the resctrl helpers.
If your platform is sufficiently Xeon shaped, you should be able to get L2/L3 CPOR
bitmaps exposed via resctrl. CSU counters work if they are on/after the L3. MBWU
counters are considerably more hairy, and depend on hueristics around the topology,
and a bunch of stuff trying to emulate ABMC.
If it didn't pick what you wanted it to, please share the debug messages produced
when enabling dynamic debug and booting with:
| dyndbg="file mpam_resctrl.c +pl"
I've not found a platform that can test all the behaviours around the monitors,
so this is where I'd expect the most bugs.
The MPAM spec that describes all the system and MMIO registers can be found here:
https://developer.arm.com/documentation/ddi0598/db/?lang=en
(Ignored the 'RETIRED' warning - that is just arm moving the documentation around.
This document has the best overview)
Based on v6.19-rc5
This series can be retrieved from:
https://gitlab.arm.com/linux-arm/linux-bh.git mpam_resctrl_glue_v3
v2 can be found at:
https://lore.kernel.org/linux-arm-kernel/20251219181147.3404071-1-ben.horgan@arm.com/
rfc can be found at:
https://lore.kernel.org/linux-arm-kernel/20251205215901.17772-1-james.morse@arm.com/
[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
Ben Horgan (10):
arm_mpam: Use non-atomic bitops when modifying feature bitmap
arm64/sysreg: Add MPAMSM_EL1 register
KVM: arm64: Preserve host MPAM configuration when changing traps
KVM: arm64: Make MPAMSM_EL1 accesses UNDEF
arm64: mpam: Initialise and context switch the MPAMSM_EL1 register
KVM: arm64: Use kernel-space partid configuration for hypercalls
arm_mpam: resctrl: Add rmid index helpers
arm_mpam: resctrl: Add kunit test for rmid idx conversions
arm_mpam: resctrl: Wait for cacheinfo to be ready
arm_mpam: resctrl: Add kunit test for mbw min control generation
Dave Martin (2):
arm_mpam: resctrl: Convert to/from MPAMs fixed-point formats
arm_mpam: resctrl: Add kunit test for control format conversions
James Morse (30):
arm64: mpam: Context switch the MPAM registers
arm64: mpam: Re-initialise MPAM regs when CPU comes online
arm64: mpam: Advertise the CPUs MPAM limits to the driver
arm64: mpam: Add cpu_pm notifier to restore MPAM sysregs
arm64: mpam: Add helpers to change a task or cpu's MPAM PARTID/PMG
values
KVM: arm64: Force guest EL1 to use user-space's partid configuration
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
arm_mpam: resctrl: Sort the order of the domain lists
arm_mpam: resctrl: Pick the caches we will use as resctrl resources
arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()
arm_mpam: resctrl: Add resctrl_arch_get_config()
arm_mpam: resctrl: Implement helpers to update configuration
arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks
arm_mpam: resctrl: Add CDP emulation
arm_mpam: resctrl: Add support for 'MB' resource
arm_mpam: resctrl: Add support for csu counters
arm_mpam: resctrl: Pick classes for use as mbm counters
arm_mpam: resctrl: Pre-allocate free running monitors
arm_mpam: resctrl: Pre-allocate assignable monitors
arm_mpam: resctrl: Add kunit test for ABMC/CDP interactions
arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
arm_mpam: resctrl: Allow resctrl to allocate monitors
arm_mpam: resctrl: Add resctrl_arch_rmid_read() and
resctrl_arch_reset_rmid()
arm_mpam: resctrl: Add resctrl_arch_cntr_read() &
resctrl_arch_reset_cntr()
arm_mpam: resctrl: Update the rmid reallocation limit
arm_mpam: resctrl: Add empty definitions for assorted resctrl
functions
arm64: mpam: Select ARCH_HAS_CPU_RESCTRL
arm_mpam: resctrl: Call resctrl_init() on platforms that can support
resctrl
arm_mpam: Generate a configuration for min controls
arm_mpam: Quirk CMN-650's CSU NRDY behaviour
Jiapeng Chong (1):
arm_mpam: Remove duplicate linux/srcu.h header
Shanker Donthineni (4):
arm_mpam: Add quirk framework
arm_mpam: Add workaround for T241-MPAM-1
arm_mpam: Add workaround for T241-MPAM-4
arm_mpam: Add workaround for T241-MPAM-6
Documentation/arch/arm64/silicon-errata.rst | 9 +
arch/arm64/Kconfig | 6 +-
arch/arm64/include/asm/el2_setup.h | 3 +-
arch/arm64/include/asm/mpam.h | 98 +
arch/arm64/include/asm/resctrl.h | 2 +
arch/arm64/include/asm/thread_info.h | 3 +
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/cpufeature.c | 21 +-
arch/arm64/kernel/mpam.c | 58 +
arch/arm64/kernel/process.c | 7 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +-
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 +
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 13 +
arch/arm64/kvm/sys_regs.c | 2 +
arch/arm64/tools/sysreg | 8 +
drivers/resctrl/Kconfig | 9 +-
drivers/resctrl/Makefile | 1 +
drivers/resctrl/mpam_devices.c | 306 ++-
drivers/resctrl/mpam_internal.h | 131 +-
drivers/resctrl/mpam_resctrl.c | 1930 +++++++++++++++++++
drivers/resctrl/test_mpam_devices.c | 66 +
drivers/resctrl/test_mpam_resctrl.c | 426 ++++
include/linux/arm_mpam.h | 32 +
23 files changed, 3119 insertions(+), 33 deletions(-)
create mode 100644 arch/arm64/include/asm/mpam.h
create mode 100644 arch/arm64/include/asm/resctrl.h
create mode 100644 arch/arm64/kernel/mpam.c
create mode 100644 drivers/resctrl/mpam_resctrl.c
create mode 100644 drivers/resctrl/test_mpam_resctrl.c
--
2.43.0
|
From: James Morse <james.morse@arm.com>
When there are enough monitors, the resctrl mbm local and total files can
be exposed. These need all the monitors that resctrl may use to be
allocated up front.
Add helpers to do this.
If a different candidate class is discovered, the old array should be
free'd and the allocated monitors returned to the driver.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
Changes since v2:
Code flow tidying (Jonathan)
---
drivers/resctrl/mpam_internal.h | 8 +++-
drivers/resctrl/mpam_resctrl.c | 81 ++++++++++++++++++++++++++++++++-
2 files changed, 86 insertions(+), 3 deletions(-)
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 1c5492008fe8..89f9d374ded0 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -360,7 +360,13 @@ struct mpam_resctrl_res {
struct mpam_resctrl_mon {
struct mpam_class *class;
- /* per-class data that resctrl needs will live here */
+ /*
+ * Array of allocated MBWU monitors, indexed by (closid, rmid).
+ * When ABMC is not in use, this array directly maps (closid, rmid)
+ * to the allocated monitor. Otherwise this array is sparse, and
+ * un-assigned (closid, rmid) are -1.
+ */
+ int *mbwu_idx_to_mon;
};
static inline int mpam_alloc_csu_mon(struct mpam_class *class)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 14a8dcaf1366..3af12ad77fba 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -572,10 +572,58 @@ static void mpam_resctrl_pick_mba(void)
}
}
+static void __free_mbwu_mon(struct mpam_class *class, int *array,
+ u16 num_mbwu_mon)
+{
+ for (int i = 0; i < num_mbwu_mon; i++) {
+ if (array[i] < 0)
+ continue;
+
+ mpam_free_mbwu_mon(class, array[i]);
+ array[i] = ~0;
+ }
+}
+
+static int __alloc_mbwu_mon(struct mpam_class *class, int *array,
+ u16 num_mbwu_mon)
+{
+ for (int i = 0; i < num_mbwu_mon; i++) {
+ int mbwu_mon = mpam_alloc_mbwu_mon(class);
+
+ if (mbwu_mon < 0) {
+ __free_mbwu_mon(class, array, num_mbwu_mon);
+ return mbwu_mon;
+ }
+ array[i] = mbwu_mon;
+ }
+
+ return 0;
+}
+
+static int *__alloc_mbwu_array(struct mpam_class *class, u16 num_mbwu_mon)
+{
+ int err;
+ size_t array_size = num_mbwu_mon * sizeof(int);
+ int *array __free(kfree) = kmalloc(array_size, GFP_KERNEL);
+
+ if (!array)
+ return ERR_PTR(-ENOMEM);
+
+ memset(array, -1, array_size);
+
+ err = __alloc_mbwu_mon(class, array, num_mbwu_mon);
+ if (err)
+ return ERR_PTR(err);
+ return_ptr(array);
+}
+
static void counter_update_class(enum resctrl_event_id evt_id,
struct mpam_class *class)
{
- struct mpam_class *existing_class = mpam_resctrl_counters[evt_id].class;
+ struct mpam_resctrl_mon *mon = &mpam_resctrl_counters[evt_id];
+ struct mpam_class *existing_class = mon->class;
+ u16 num_mbwu_mon = class->props.num_mbwu_mon;
+ int *new_array, *existing_array = mon->mbwu_idx_to_mon;
if (existing_class) {
if (class->level == 3) {
@@ -590,8 +638,37 @@ static void counter_update_class(enum resctrl_event_id evt_id,
}
}
- mpam_resctrl_counters[evt_id].class = class;
+ pr_debug("Updating event %u to use class %u\n", evt_id, class->level);
+
+ /* Might not need all the monitors */
+ num_mbwu_mon = __mpam_monitors_free_running(num_mbwu_mon);
+
+ if ((evt_id != QOS_L3_OCCUP_EVENT_ID) && num_mbwu_mon) {
+ /*
+ * This is the pre-allocated free-running monitors path. It always
+ * allocates one monitor per PARTID * PMG.
+ */
+ WARN_ON_ONCE(num_mbwu_mon != resctrl_arch_system_num_rmid_idx());
+
+ new_array = __alloc_mbwu_array(class, num_mbwu_mon);
+ if (IS_ERR(new_array)) {
+ pr_debug("Failed to allocate MBWU array\n");
+ return;
+ }
+ mon->mbwu_idx_to_mon = new_array;
+
+ if (existing_array) {
+ pr_debug("Releasing previous class %u's monitors\n",
+ existing_class->level);
+ __free_mbwu_mon(existing_class, existing_array, num_mbwu_mon);
+ kfree(existing_array);
+ }
+ } else if (evt_id != QOS_L3_OCCUP_EVENT_ID) {
+ pr_debug("Not pre-allocating free-running counters\n");
+ }
+
exposed_mon_capable = true;
+ mon->class = class;
}
static void mpam_resctrl_pick_counters(void)
--
2.43.0
|
{
"author": "Ben Horgan <ben.horgan@arm.com>",
"date": "Mon, 12 Jan 2026 16:58:57 +0000",
"thread_id": "20260112165914.4086692-1-ben.horgan@arm.com.mbox.gz"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.