This commit is contained in:
Maneet Singh
2026-06-17 12:58:23 -07:00
parent 5be0ed832e
commit 722ae84526
56 changed files with 435 additions and 123 deletions

View File

@@ -79,7 +79,7 @@ ccflags-y += -I$(src)/common/inc
ccflags-y += -I$(src)
ccflags-y += -Wall $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-format-extra-args
ccflags-y += -D__KERNEL__ -DMODULE -DNVRM
ccflags-y += -DNV_VERSION_STRING=\"595.80\"
ccflags-y += -DNV_VERSION_STRING=\"595.84\"
# Include and link Tegra out-of-tree modules.
ifneq ($(wildcard /usr/src/nvidia/nvidia-public),)

View File

@@ -1063,6 +1063,7 @@ typedef struct nv_dma_map_s {
NvU64 page_count;
NvBool contiguous;
NvU32 cache_type;
NvBool bReadOnlyDeviceMap;
struct sg_table *import_sgt;
union

View File

@@ -968,9 +968,9 @@ void NV_API_CALL nv_unregister_sgt (nv_state_t *, struct sg_table
NV_STATUS NV_API_CALL nv_register_phys_pages (nv_state_t *, NvU64 *, NvU64, NvU32, void **);
void NV_API_CALL nv_unregister_phys_pages (nv_state_t *, void *);
NV_STATUS NV_API_CALL nv_dma_map_sgt (nv_dma_device_t *, NvU64, NvU64 *, NvU32, void **);
NV_STATUS NV_API_CALL nv_dma_map_sgt (nv_dma_device_t *, NvU64, NvU64 *, NvU32, NvBool, void **);
NV_STATUS NV_API_CALL nv_dma_map_alloc (nv_dma_device_t *, NvU64, NvU64 *, NvBool, void **);
NV_STATUS NV_API_CALL nv_dma_map_alloc (nv_dma_device_t *, NvU64, NvU64 *, NvBool, NvBool, void **);
NV_STATUS NV_API_CALL nv_dma_unmap_alloc (nv_dma_device_t *, NvU64, NvU64 *, void **);
NV_STATUS NV_API_CALL nv_dma_map_peer (nv_dma_device_t *, nv_dma_device_t *, NvU8, NvU64, NvU64 *);

View File

@@ -408,7 +408,7 @@ static const NvU32 __nv_drm_connector_supported_colorspaces =
#if defined(NV_DRM_CONNECTOR_ATTACH_HDR_OUTPUT_METADATA_PROPERTY_PRESENT)
static int
__nv_drm_connector_atomic_check(struct drm_connector *connector,
struct drm_atomic_state *state)
nv_drm_atomic_state_base_t *state)
{
struct drm_connector_state *new_connector_state =
drm_atomic_get_new_connector_state(state, connector);

View File

@@ -1624,16 +1624,16 @@ static int __nv_drm_cursor_atomic_check(struct drm_plane *plane,
return 0;
}
#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_FULL_STATE_ARG)
static int nv_drm_plane_atomic_check(struct drm_plane *plane,
struct drm_atomic_state *state)
nv_drm_atomic_state_base_t *state)
#else
static int nv_drm_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *plane_state)
#endif
{
struct nv_drm_plane *nv_plane = to_nv_plane(plane);
#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_FULL_STATE_ARG)
struct drm_plane_state *plane_state =
drm_atomic_get_new_plane_state(state, plane);
#endif
@@ -2442,15 +2442,15 @@ static int color_mgmt_config_set_luts(struct nv_drm_crtc_state *nv_crtc_state,
* the 'nv_drm_crtc_state::req_config', that is fine because 'nv_drm_crtc_state'
* will be discarded if ->atomic_check() fails.
*/
#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_FULL_STATE_ARG)
static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_atomic_state *state)
nv_drm_atomic_state_base_t *state)
#else
static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *crtc_state)
#endif
{
#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG)
#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_FULL_STATE_ARG)
struct drm_crtc_state *crtc_state =
drm_atomic_get_new_crtc_state(state, crtc);
#endif

View File

@@ -934,7 +934,7 @@ static void nv_drm_master_set(struct drm_device *dev,
static
int nv_drm_reset_input_colorspace(struct drm_device *dev)
{
struct drm_atomic_state *state;
nv_drm_atomic_state_base_t *state;
struct drm_plane_state *plane_state;
struct drm_plane *plane;
struct nv_drm_plane_state *nv_drm_plane_state;
@@ -943,7 +943,7 @@ int nv_drm_reset_input_colorspace(struct drm_device *dev)
bool do_reset = false;
NvU32 flags = 0;
state = drm_atomic_state_alloc(dev);
state = nv_drm_atomic_state_base_alloc(dev);
if (!state)
return -ENOMEM;
@@ -974,7 +974,7 @@ int nv_drm_reset_input_colorspace(struct drm_device *dev)
}
out:
drm_atomic_state_put(state);
nv_drm_atomic_state_base_put(state);
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
@@ -1382,7 +1382,7 @@ static int nv_drm_grant_permission_ioctl(struct drm_device *dev, void *data,
}
static int
nv_drm_atomic_disable_connector(struct drm_atomic_state *state,
nv_drm_atomic_disable_connector(nv_drm_atomic_state_base_t *state,
struct nv_drm_connector *nv_connector)
{
struct drm_crtc_state *crtc_state;
@@ -1415,7 +1415,7 @@ static int nv_drm_revoke_modeset_permission(struct drm_device *dev,
struct drm_file *filep, NvU32 dpyId)
{
struct drm_modeset_acquire_ctx *pctx;
struct drm_atomic_state *state;
nv_drm_atomic_state_base_t *state;
struct drm_connector *connector;
struct drm_crtc *crtc;
int ret = 0;
@@ -1430,7 +1430,7 @@ static int nv_drm_revoke_modeset_permission(struct drm_device *dev,
pctx = dev->mode_config.acquire_ctx;
#endif
state = drm_atomic_state_alloc(dev);
state = nv_drm_atomic_state_base_alloc(dev);
if (!state) {
ret = -ENOMEM;
goto done;
@@ -1466,7 +1466,7 @@ static int nv_drm_revoke_modeset_permission(struct drm_device *dev,
ret = drm_atomic_commit(state);
done:
drm_atomic_state_put(state);
nv_drm_atomic_state_base_put(state);
#if NV_DRM_MODESET_LOCK_ALL_END_ARGUMENT_COUNT == 3
DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);

View File

@@ -91,7 +91,7 @@
int nv_drm_atomic_helper_disable_all(struct drm_device *dev,
struct drm_modeset_acquire_ctx *ctx)
{
struct drm_atomic_state *state;
nv_drm_atomic_state_base_t *state;
struct drm_connector_state *conn_state;
struct drm_connector *conn;
struct drm_plane_state *plane_state;
@@ -101,7 +101,7 @@ int nv_drm_atomic_helper_disable_all(struct drm_device *dev,
unsigned plane_mask = 0;
int ret, i;
state = drm_atomic_state_alloc(dev);
state = nv_drm_atomic_state_base_alloc(dev);
if (!state)
return -ENOMEM;
@@ -173,7 +173,7 @@ free:
}
}
drm_atomic_state_put(state);
nv_drm_atomic_state_base_put(state);
return ret;
}

View File

@@ -135,6 +135,92 @@ nv_drm_prime_pages_to_sg(struct drm_device *dev,
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
/*
* Linux commit 5164f7e7ff8e ("drm: Rename struct drm_atomic_state to
* drm_atomic_commit"), expected in Linux v7.2, renamed the top-level atomic
* commit object and its lifetime helpers.
*/
#if defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
typedef struct drm_atomic_commit nv_drm_atomic_state_base_t;
#else
typedef struct drm_atomic_state nv_drm_atomic_state_base_t;
#endif
/*
* Linux commits 29b77ad7b9ca ("drm/atomic: Pass the full state to CRTC
* atomic_check") and 7c11b99a8e58 ("drm/atomic: Pass the full state to
* planes atomic_check") changed the CRTC and plane helper atomic_check
* callbacks from per-object state arguments to the full atomic transaction
* state. The existing conftests detect those full-state callback signatures
* when the argument type is still struct drm_atomic_state.
*
* Linux commit 5164f7e7ff8e ("drm: Rename struct drm_atomic_state to
* drm_atomic_commit"), expected in Linux v7.2, renamed that full transaction
* type. In those kernels, the callbacks still use the full atomic transaction
* state ABI, but the argument type is struct drm_atomic_commit. Either
* conftest means the helper callbacks take the full atomic transaction state.
*/
#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG) || \
defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
#define NV_DRM_CRTC_ATOMIC_CHECK_HAS_FULL_STATE_ARG
#endif
#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG) || \
defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
#define NV_DRM_PLANE_ATOMIC_CHECK_HAS_FULL_STATE_ARG
#endif
static inline nv_drm_atomic_state_base_t *
nv_drm_atomic_state_base_alloc(struct drm_device *dev)
{
#if defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
return drm_atomic_commit_alloc(dev);
#else
return drm_atomic_state_alloc(dev);
#endif
}
static inline int
nv_drm_atomic_state_base_init(struct drm_device *dev,
nv_drm_atomic_state_base_t *state)
{
#if defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
return drm_atomic_commit_init(dev, state);
#else
return drm_atomic_state_init(dev, state);
#endif
}
static inline void
nv_drm_atomic_state_base_put(nv_drm_atomic_state_base_t *state)
{
#if defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
drm_atomic_commit_put(state);
#else
drm_atomic_state_put(state);
#endif
}
static inline void
nv_drm_atomic_state_base_default_clear(nv_drm_atomic_state_base_t *state)
{
#if defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
drm_atomic_commit_default_clear(state);
#else
drm_atomic_state_default_clear(state);
#endif
}
static inline void
nv_drm_atomic_state_base_default_release(nv_drm_atomic_state_base_t *state)
{
#if defined(NV_DRM_ATOMIC_COMMIT_STRUCT_PRESENT)
drm_atomic_commit_default_release(state);
#else
drm_atomic_state_default_release(state);
#endif
}
int nv_drm_atomic_helper_disable_all(struct drm_device *dev,
struct drm_modeset_acquire_ctx *ctx);

View File

@@ -49,21 +49,23 @@
struct nv_drm_atomic_state {
struct NvKmsKapiRequestedModeSetConfig config;
struct drm_atomic_state base;
nv_drm_atomic_state_base_t base;
};
static inline struct nv_drm_atomic_state *to_nv_atomic_state(
struct drm_atomic_state *state)
nv_drm_atomic_state_base_t *state)
{
return container_of(state, struct nv_drm_atomic_state, base);
}
struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev)
nv_drm_atomic_state_base_t *
nv_drm_atomic_state_alloc(struct drm_device *dev)
{
struct nv_drm_atomic_state *nv_state =
nv_drm_calloc(1, sizeof(*nv_state));
if (nv_state == NULL || drm_atomic_state_init(dev, &nv_state->base) < 0) {
if (nv_state == NULL ||
nv_drm_atomic_state_base_init(dev, &nv_state->base) < 0) {
nv_drm_free(nv_state);
return NULL;
}
@@ -71,16 +73,16 @@ struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev)
return &nv_state->base;
}
void nv_drm_atomic_state_clear(struct drm_atomic_state *state)
void nv_drm_atomic_state_clear(nv_drm_atomic_state_base_t *state)
{
drm_atomic_state_default_clear(state);
nv_drm_atomic_state_base_default_clear(state);
}
void nv_drm_atomic_state_free(struct drm_atomic_state *state)
void nv_drm_atomic_state_free(nv_drm_atomic_state_base_t *state)
{
struct nv_drm_atomic_state *nv_state =
to_nv_atomic_state(state);
drm_atomic_state_default_release(state);
nv_drm_atomic_state_base_default_release(state);
nv_drm_free(nv_state);
}
@@ -177,7 +179,7 @@ __nv_drm_plane_fence_cb(
static int __nv_drm_convert_in_fences(
struct nv_drm_device *nv_dev,
struct drm_atomic_state *state,
nv_drm_atomic_state_base_t *state,
struct drm_crtc *crtc,
struct drm_crtc_state *crtc_state)
{
@@ -391,7 +393,7 @@ static int __nv_drm_get_syncpt_data(
*/
static int
nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
struct drm_atomic_state *state,
nv_drm_atomic_state_base_t *state,
bool commit)
{
struct nv_drm_device *nv_dev = to_nv_device(dev);
@@ -508,7 +510,7 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
}
int nv_drm_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state)
nv_drm_atomic_state_base_t *state)
{
int ret = 0;
@@ -617,7 +619,7 @@ static void __nv_drm_handle_flip_event(struct nv_drm_crtc *nv_crtc)
}
int nv_drm_atomic_commit(struct drm_device *dev,
struct drm_atomic_state *state,
nv_drm_atomic_state_base_t *state,
bool nonblock)
{
int ret = -EBUSY;

View File

@@ -27,20 +27,21 @@
#if defined(NV_DRM_AVAILABLE)
#include "nvidia-drm-helper.h"
#include "nvkms-kapi.h"
struct drm_device;
struct drm_atomic_state;
struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev);
void nv_drm_atomic_state_clear(struct drm_atomic_state *state);
void nv_drm_atomic_state_free(struct drm_atomic_state *state);
nv_drm_atomic_state_base_t *
nv_drm_atomic_state_alloc(struct drm_device *dev);
void nv_drm_atomic_state_clear(nv_drm_atomic_state_base_t *state);
void nv_drm_atomic_state_free(nv_drm_atomic_state_base_t *state);
int nv_drm_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state);
nv_drm_atomic_state_base_t *state);
int nv_drm_atomic_commit(struct drm_device *dev,
struct drm_atomic_state *state, bool nonblock);
nv_drm_atomic_state_base_t *state, bool nonblock);
void nv_drm_handle_flip_occurred(struct nv_drm_device *nv_dev,

View File

@@ -109,3 +109,4 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_output_poll_changed
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_date
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_connector_helper_funcs_mode_valid_has_const_mode_arg
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_fb_create_takes_format_info
NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_commit_struct_present

View File

@@ -53,6 +53,14 @@ void nv_unmap_dma_map_scatterlist (nv_dma_map_t *dma_map);
static void nv_dma_unmap_contig (nv_dma_map_t *dma_map);
static void nv_dma_unmap_scatterlist (nv_dma_map_t *dma_map);
static enum dma_data_direction nv_dma_get_direction
(
nv_dma_map_t *dma_map
)
{
return DMA_BIDIRECTIONAL;
}
static inline NvBool nv_dma_is_addressable(
nv_dma_device_t *dma_dev,
NvU64 start,
@@ -72,9 +80,11 @@ static NV_STATUS nv_dma_map_contig(
NvU64 *va
)
{
enum dma_data_direction direction = nv_dma_get_direction(dma_map);
*va = dma_map_page_attrs(dma_map->dev, dma_map->pages[0], 0,
dma_map->page_count * PAGE_SIZE,
DMA_BIDIRECTIONAL,
direction,
(dma_map->cache_type == NV_MEMORY_UNCACHED) ?
DMA_ATTR_SKIP_CPU_SYNC : 0);
if (dma_mapping_error(dma_map->dev, *va))
@@ -101,9 +111,11 @@ static NV_STATUS nv_dma_map_contig(
static void nv_dma_unmap_contig(nv_dma_map_t *dma_map)
{
enum dma_data_direction direction = nv_dma_get_direction(dma_map);
dma_unmap_page_attrs(dma_map->dev, dma_map->mapping.contig.dma_addr,
dma_map->page_count * PAGE_SIZE,
DMA_BIDIRECTIONAL,
direction,
(dma_map->cache_type == NV_MEMORY_UNCACHED) ?
DMA_ATTR_SKIP_CPU_SYNC : 0);
}
@@ -224,6 +236,7 @@ NV_STATUS nv_map_dma_map_scatterlist(nv_dma_map_t *dma_map)
NV_STATUS status = NV_OK;
nv_dma_submap_t *submap;
NvU64 i;
enum dma_data_direction direction = nv_dma_get_direction(dma_map);
NV_FOR_EACH_DMA_SUBMAP(dma_map, submap, i)
{
@@ -233,7 +246,7 @@ NV_STATUS nv_map_dma_map_scatterlist(nv_dma_map_t *dma_map)
dma_map_sg(dma_map->dev,
submap->sgt.sgl,
submap->sgt.orig_nents,
DMA_BIDIRECTIONAL);
direction);
if (submap->sg_map_count == 0)
{
status = NV_ERR_OPERATING_SYSTEM;
@@ -253,6 +266,7 @@ void nv_unmap_dma_map_scatterlist(nv_dma_map_t *dma_map)
{
nv_dma_submap_t *submap;
NvU64 i;
enum dma_data_direction direction = nv_dma_get_direction(dma_map);
NV_FOR_EACH_DMA_SUBMAP(dma_map, submap, i)
{
@@ -269,7 +283,7 @@ void nv_unmap_dma_map_scatterlist(nv_dma_map_t *dma_map)
dma_unmap_sg(dma_map->dev, submap->sgt.sgl,
submap->sgt.orig_nents,
DMA_BIDIRECTIONAL);
direction);
}
}
@@ -376,6 +390,7 @@ NV_STATUS NV_API_CALL nv_dma_map_sgt(
NvU64 page_count,
NvU64 *va_array,
NvU32 cache_type,
NvBool bReadOnlyDeviceMap,
void **priv
)
{
@@ -408,6 +423,7 @@ NV_STATUS NV_API_CALL nv_dma_map_sgt(
dma_map->page_count = page_count;
dma_map->contiguous = NV_FALSE;
dma_map->cache_type = cache_type;
dma_map->bReadOnlyDeviceMap = bReadOnlyDeviceMap;
dma_map->mapping.discontig.submap_count = 0;
status = nv_dma_map_scatterlist(dma_dev, dma_map, va_array);
@@ -453,6 +469,7 @@ static NV_STATUS NV_API_CALL nv_dma_map_pages(
NvU64 *va_array,
NvBool contig,
NvU32 cache_type,
NvBool bReadOnlyDeviceMap,
void **priv
)
{
@@ -489,6 +506,7 @@ static NV_STATUS NV_API_CALL nv_dma_map_pages(
dma_map->page_count = page_count;
dma_map->contiguous = contig;
dma_map->cache_type = cache_type;
dma_map->bReadOnlyDeviceMap = bReadOnlyDeviceMap;
if (dma_map->page_count > 1 && !dma_map->contiguous)
{
@@ -579,6 +597,7 @@ NV_STATUS NV_API_CALL nv_dma_map_alloc
NvU64 page_count,
NvU64 *va_array,
NvBool contig,
NvBool bReadOnlyDeviceMap,
void **priv
)
{
@@ -594,7 +613,7 @@ NV_STATUS NV_API_CALL nv_dma_map_alloc
{
*priv = at->import_sgt;
status = nv_dma_map_sgt(dma_dev, page_count, va_array, at->cache_type,
priv);
bReadOnlyDeviceMap, priv);
if (status != NV_OK)
{
*priv = at;
@@ -653,7 +672,7 @@ NV_STATUS NV_API_CALL nv_dma_map_alloc
*priv = pages;
status = nv_dma_map_pages(dma_dev, page_count, va_array, contig, cache_type,
priv);
bReadOnlyDeviceMap, priv);
if (status != NV_OK)
{
*priv = at;

View File

@@ -610,7 +610,7 @@ nv_dma_buf_get_phys_addresses (
nvidia_stack_t *sp = NULL;
NvBool api_lock_taken = NV_FALSE;
NvBool gpu_lock_taken = NV_FALSE;
NvU32 i;
NvU32 i = 0;
int rc = 0;
if (!nv_inc_and_check_one_phys_refcount(priv, start_index, handle_count))

View File

@@ -468,6 +468,7 @@ nv_procfs_read_registry(
nvl->registry_keys : nv_registry_keys);
seq_printf(s, "Binary: \"%s\"\n", registry_keys);
return 0;
}