Commit 9ac4883d authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge tag 'drm-misc-fixes-2023-12-07' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes



drm-misc-fixes for v6.7-rc5:
- Document nouveau's GSP-RM.
- Flush vmm harder on nouveau tu102.
- Panfrost fix for imported dma-buf objects, and device frequency.
- Kconfig Build fix for tc358768.
- Call end_fb_access after atomic commit.

Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/05a26dc0-8cf1-4b1f-abb6-3bf471fbfc99@linux.intel.com
parents abd02118 e0f04e41
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -313,6 +313,7 @@ config DRM_TOSHIBA_TC358768
	select REGMAP_I2C
	select DRM_PANEL
	select DRM_MIPI_DSI
	select VIDEOMODE_HELPERS
	help
	  Toshiba TC358768AXBG/TC358778XBG DSI bridge chip driver.

+52 −26
Original line number Diff line number Diff line
@@ -2012,7 +2012,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
			return ret;

		drm_atomic_helper_async_commit(dev, state);
		drm_atomic_helper_cleanup_planes(dev, state);
		drm_atomic_helper_unprepare_planes(dev, state);

		return 0;
	}
@@ -2072,7 +2072,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
	return 0;

err:
	drm_atomic_helper_cleanup_planes(dev, state);
	drm_atomic_helper_unprepare_planes(dev, state);
	return ret;
}
EXPORT_SYMBOL(drm_atomic_helper_commit);
@@ -2650,6 +2650,39 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
}
EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);

/**
 * drm_atomic_helper_unprepare_planes - release plane resources on aborts
 * @dev: DRM device
 * @state: atomic state object with old state structures
 *
 * This function cleans up plane state, specifically framebuffers, from the
 * atomic state. It undoes the effects of drm_atomic_helper_prepare_planes()
 * when aborting an atomic commit. For cleaning up after a successful commit
 * use drm_atomic_helper_cleanup_planes().
 */
void drm_atomic_helper_unprepare_planes(struct drm_device *dev,
					struct drm_atomic_state *state)
{
	struct drm_plane *plane;
	struct drm_plane_state *new_plane_state;
	int i;

	for_each_new_plane_in_state(state, plane, new_plane_state, i) {
		const struct drm_plane_helper_funcs *funcs = plane->helper_private;

		if (funcs->end_fb_access)
			funcs->end_fb_access(plane, new_plane_state);
	}

	for_each_new_plane_in_state(state, plane, new_plane_state, i) {
		const struct drm_plane_helper_funcs *funcs = plane->helper_private;

		if (funcs->cleanup_fb)
			funcs->cleanup_fb(plane, new_plane_state);
	}
}
EXPORT_SYMBOL(drm_atomic_helper_unprepare_planes);

static bool plane_crtc_active(const struct drm_plane_state *state)
{
	return state->crtc && state->crtc->state->active;
@@ -2784,6 +2817,17 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,

		funcs->atomic_flush(crtc, old_state);
	}

	/*
	 * Signal end of framebuffer access here before hw_done. After hw_done,
	 * a later commit might have already released the plane state.
	 */
	for_each_old_plane_in_state(old_state, plane, old_plane_state, i) {
		const struct drm_plane_helper_funcs *funcs = plane->helper_private;

		if (funcs->end_fb_access)
			funcs->end_fb_access(plane, old_plane_state);
	}
}
EXPORT_SYMBOL(drm_atomic_helper_commit_planes);

@@ -2911,40 +2955,22 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_planes_on_crtc);
 * configuration. Hence the old configuration must be perserved in @old_state to
 * be able to call this function.
 *
 * This function must also be called on the new state when the atomic update
 * fails at any point after calling drm_atomic_helper_prepare_planes().
 * This function may not be called on the new state when the atomic update
 * fails at any point after calling drm_atomic_helper_prepare_planes(). Use
 * drm_atomic_helper_unprepare_planes() in this case.
 */
void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
				      struct drm_atomic_state *old_state)
{
	struct drm_plane *plane;
	struct drm_plane_state *old_plane_state, *new_plane_state;
	struct drm_plane_state *old_plane_state;
	int i;

	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
	for_each_old_plane_in_state(old_state, plane, old_plane_state, i) {
		const struct drm_plane_helper_funcs *funcs = plane->helper_private;

		if (funcs->end_fb_access)
			funcs->end_fb_access(plane, new_plane_state);
	}

	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
		const struct drm_plane_helper_funcs *funcs;
		struct drm_plane_state *plane_state;

		/*
		 * This might be called before swapping when commit is aborted,
		 * in which case we have to cleanup the new state.
		 */
		if (old_plane_state == plane->state)
			plane_state = new_plane_state;
		else
			plane_state = old_plane_state;

		funcs = plane->helper_private;

		if (funcs->cleanup_fb)
			funcs->cleanup_fb(plane, plane_state);
			funcs->cleanup_fb(plane, old_plane_state);
	}
}
EXPORT_SYMBOL(drm_atomic_helper_cleanup_planes);
+1 −1
Original line number Diff line number Diff line
@@ -7488,7 +7488,7 @@ int intel_atomic_commit(struct drm_device *dev, struct drm_atomic_state *_state,
		for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i)
			intel_color_cleanup_commit(new_crtc_state);

		drm_atomic_helper_cleanup_planes(dev, &state->base);
		drm_atomic_helper_unprepare_planes(dev, &state->base);
		intel_runtime_pm_put(&dev_priv->runtime_pm, state->wakeref);
		return ret;
	}
+1 −1
Original line number Diff line number Diff line
@@ -2474,7 +2474,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,

err_cleanup:
	if (ret)
		drm_atomic_helper_cleanup_planes(dev, state);
		drm_atomic_helper_unprepare_planes(dev, state);
done:
	pm_runtime_put_autosuspend(dev->dev);
	return ret;
+51 −0
Original line number Diff line number Diff line
@@ -26,6 +26,49 @@
 * DEALINGS IN THE SOFTWARE.
 */

/**
 * msgqTxHeader -- TX queue data structure
 * @version: the version of this structure, must be 0
 * @size: the size of the entire queue, including this header
 * @msgSize: the padded size of queue element, 16 is minimum
 * @msgCount: the number of elements in this queue
 * @writePtr: head index of this queue
 * @flags: 1 = swap the RX pointers
 * @rxHdrOff: offset of readPtr in this structure
 * @entryOff: offset of beginning of queue (msgqRxHeader), relative to
 *          beginning of this structure
 *
 * The command queue is a queue of RPCs that are sent from the driver to the
 * GSP.  The status queue is a queue of messages/responses from GSP-RM to the
 * driver.  Although the driver allocates memory for both queues, the command
 * queue is owned by the driver and the status queue is owned by GSP-RM.  In
 * addition, the headers of the two queues must not share the same 4K page.
 *
 * Each queue is prefixed with this data structure.  The idea is that a queue
 * and its header are written to only by their owner.  That is, only the
 * driver writes to the command queue and command queue header, and only the
 * GSP writes to the status (receive) queue and its header.
 *
 * This is enforced by the concept of "swapping" the RX pointers.  This is
 * why the 'flags' field must be set to 1.  'rxHdrOff' is how the GSP knows
 * where the where the tail pointer of its status queue.
 *
 * When the driver writes a new RPC to the command queue, it updates writePtr.
 * When it reads a new message from the status queue, it updates readPtr.  In
 * this way, the GSP knows when a new command is in the queue (it polls
 * writePtr) and it knows how much free space is in the status queue (it
 * checks readPtr).  The driver never cares about how much free space is in
 * the status queue.
 *
 * As usual, producers write to the head pointer, and consumers read from the
 * tail pointer.  When head == tail, the queue is empty.
 *
 * So to summarize:
 * command.writePtr = head of command queue
 * command.readPtr = tail of status queue
 * status.writePtr = head of status queue
 * status.readPtr = tail of command queue
 */
typedef struct
{
    NvU32 version;   // queue version
@@ -38,6 +81,14 @@ typedef struct
    NvU32 entryOff;  // Offset of entries from start of backing store.
} msgqTxHeader;

/**
 * msgqRxHeader - RX queue data structure
 * @readPtr: tail index of the other queue
 *
 * Although this is a separate struct, it could easily be merged into
 * msgqTxHeader.  msgqTxHeader.rxHdrOff is simply the offset of readPtr
 * from the beginning of msgqTxHeader.
 */
typedef struct
{
    NvU32 readPtr; // message id of last message read
Loading