Skip to content

Commit

Permalink
Merge branch 'devel' into amd_vmap_texture
Browse files Browse the repository at this point in the history
  • Loading branch information
pioto1225 committed Sep 4, 2021
2 parents 5490f94 + b0b2c80 commit e9ef330
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 113 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
- KVER=5.8
- KVER=5.9
- KVER=5.11
- KVER=5.12
- KVER=master

jobs:
Expand Down
1 change: 1 addition & 0 deletions docs/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ This notification is sent for a cursor position change. It is raised only when c
#!c
void (*crtc_state_handler)(int state, void* user_data);

This event is deprecated. Please use DPMS mode change event instead.
Sent when DRM's CRTC changes state. The `state` is a value that's forwarded from the kernel.

#### DDC/CI data notification
Expand Down
17 changes: 10 additions & 7 deletions module/evdi_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ static int evdi_get_modes(struct drm_connector *connector)
ret = drm_mode_connector_update_edid_property(connector, edid);
#endif

if (!ret)
ret = drm_add_edid_modes(connector, edid);
else
EVDI_ERROR("Failed to set edid modes! error: %d", ret);
if (ret) {
EVDI_ERROR("Failed to set edid property! error: %d", ret);
goto err;
}

ret = drm_add_edid_modes(connector, edid);
EVDI_INFO("(card%d) Edid property set", evdi->dev_index);
err:
kfree(edid);
return ret;
}
Expand All @@ -69,7 +72,7 @@ static enum drm_mode_status evdi_mode_valid(struct drm_connector *connector,
return MODE_OK;

if (mode_area > evdi->sku_area_limit) {
EVDI_WARN("(dev=%d) Mode %dx%d@%d rejected\n",
EVDI_WARN("(card%d) Mode %dx%d@%d rejected\n",
evdi->dev_index,
mode->hdisplay,
mode->vdisplay,
Expand All @@ -87,11 +90,11 @@ evdi_detect(struct drm_connector *connector, __always_unused bool force)

EVDI_CHECKPT();
if (evdi_painter_is_connected(evdi->painter)) {
EVDI_DEBUG("(dev=%d) poll connector state: connected\n",
EVDI_INFO("(card%d) Connector state: connected\n",
evdi->dev_index);
return connector_status_connected;
}
EVDI_DEBUG("(dev=%d) poll connector state: disconnected\n",
EVDI_VERBOSE("(card%d) Connector state: disconnected\n",
evdi->dev_index);
return connector_status_disconnected;
}
Expand Down
2 changes: 1 addition & 1 deletion module/evdi_cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void evdi_cursor_set_gem(struct evdi_cursor *cursor,
if (obj)
drm_gem_object_get(&obj->base);
if (cursor->obj)
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE || defined(EL8)
drm_gem_object_put(&cursor->obj->base);
#else
drm_gem_object_put_unlocked(&cursor->obj->base);
Expand Down
6 changes: 3 additions & 3 deletions module/evdi_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "evdi_debug.h"

void evdi_log_process(void)
void evdi_log_process(char *buf, size_t size)
{
int task_pid = (int)task_pid_nr(current);
char task_comm[TASK_COMM_LEN] = { 0 };
Expand All @@ -21,13 +21,13 @@ void evdi_log_process(void)
char process_comm[TASK_COMM_LEN] = { 0 };

get_task_comm(process_comm, current->group_leader);
EVDI_INFO("Task %d (%s) of process %d (%s)\n",
snprintf(buf, size, "Task %d (%s) of process %d (%s)",
task_pid,
task_comm,
(int)task_pid_nr(current->group_leader),
process_comm);
} else {
EVDI_INFO("Task %d (%s)\n",
snprintf(buf, size, "Task %d (%s)",
task_pid,
task_comm);
}
Expand Down
2 changes: 1 addition & 1 deletion module/evdi_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
#define EVDI_ENTER() EVDI_VERBOSE("enter\n")
#define EVDI_EXIT() EVDI_VERBOSE("exit\n")

void evdi_log_process(void);
void evdi_log_process(char *buf, size_t size);

#endif /* EVDI_DEBUG_H */
23 changes: 18 additions & 5 deletions module/evdi_drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,20 @@ static void evdi_disable_vblank(__always_unused struct drm_device *dev,
#endif

static struct drm_driver driver = {
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE || defined(EL8)
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
#else
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME
| DRIVER_ATOMIC,
#endif
.unload = evdi_driver_unload,

.open = evdi_driver_open,
.postclose = evdi_driver_postclose,

/* gem hooks */
#if KERNEL_VERSION(5, 11, 0) <= LINUX_VERSION_CODE
#elif KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
#elif KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE || defined(EL8)
.gem_free_object_unlocked = evdi_gem_free_object,
#else
.gem_free_object = evdi_gem_free_object,
Expand Down Expand Up @@ -147,6 +148,7 @@ static int evdi_driver_setup(struct drm_device *dev)

evdi->ddev = dev;
dev->dev_private = evdi;
evdi->dev_index = dev->primary->index;

evdi->cursor_events_enabled = false;
ret = evdi_cursor_init(&evdi->cursor);
Expand Down Expand Up @@ -209,6 +211,16 @@ void evdi_driver_unload(struct drm_device *dev)
kfree(evdi);
}

int evdi_driver_open(struct drm_device *drm_dev, __always_unused struct drm_file *file)
{
struct evdi_device *evdi = drm_dev->dev_private;
char buf[100];

evdi_log_process(buf, sizeof(buf));
EVDI_INFO("(card%d) Opened by %s\n", evdi->dev_index, buf);
return 0;
}

static void evdi_driver_close(struct drm_device *drm_dev, struct drm_file *file)
{
struct evdi_device *evdi = drm_dev->dev_private;
Expand All @@ -226,10 +238,11 @@ void evdi_driver_preclose(struct drm_device *drm_dev, struct drm_file *file)
void evdi_driver_postclose(struct drm_device *drm_dev, struct drm_file *file)
{
struct evdi_device *evdi = drm_dev->dev_private;
char buf[100];

EVDI_DEBUG("(dev=%d) Process tries to close us, postclose\n",
evdi ? evdi->dev_index : -1);
evdi_log_process();
evdi_log_process(buf, sizeof(buf));
EVDI_INFO("(card%d) Closed by %s\n",
evdi->dev_index, buf);

evdi_driver_close(drm_dev, file);
}
Expand Down
2 changes: 1 addition & 1 deletion module/evdi_drm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct drm_encoder *evdi_encoder_init(struct drm_device *dev);

int evdi_driver_load(struct drm_device *dev, unsigned long flags);
void evdi_driver_unload(struct drm_device *dev);
int evdi_driver_open(struct drm_device *drm_dev, struct drm_file *file);
void evdi_driver_preclose(struct drm_device *dev, struct drm_file *file_priv);
void evdi_driver_postclose(struct drm_device *dev, struct drm_file *file_priv);

Expand Down Expand Up @@ -145,7 +146,6 @@ void evdi_painter_send_update_ready_if_needed(struct evdi_painter *painter);
void evdi_painter_dpms_notify(struct evdi_device *evdi, int mode);
void evdi_painter_mode_changed_notify(struct evdi_device *evdi,
struct drm_display_mode *mode);
void evdi_painter_crtc_state_notify(struct evdi_device *evdi, int state);
unsigned int evdi_painter_poll(struct file *filp,
struct poll_table_struct *wait);

Expand Down
10 changes: 5 additions & 5 deletions module/evdi_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static void evdi_user_framebuffer_destroy(struct drm_framebuffer *fb)

EVDI_CHECKPT();
if (efb->obj)
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE || defined(EL8)
drm_gem_object_put(&efb->obj->base);
#else
drm_gem_object_put_unlocked(&efb->obj->base);
Expand Down Expand Up @@ -441,7 +441,7 @@ static int evdifb_create(struct drm_fb_helper *helper,

return ret;
out_gfree:
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE || defined(EL8)
drm_gem_object_put(&efbdev->efb.obj->base);
#else
drm_gem_object_put_unlocked(&efbdev->efb.obj->base);
Expand Down Expand Up @@ -471,7 +471,7 @@ static void evdi_fbdev_destroy(__always_unused struct drm_device *dev,
if (efbdev->efb.obj) {
drm_framebuffer_unregister_private(&efbdev->efb.base);
drm_framebuffer_cleanup(&efbdev->efb.base);
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE || defined(EL8)
drm_gem_object_put(&efbdev->efb.obj->base);
#else
drm_gem_object_put_unlocked(&efbdev->efb.obj->base);
Expand All @@ -493,7 +493,7 @@ int evdi_fbdev_init(struct drm_device *dev)
evdi->fbdev = efbdev;
drm_fb_helper_prepare(dev, &efbdev->helper, &evdi_fb_helper_funcs);

#if KERNEL_VERSION(5, 7, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 7, 0) <= LINUX_VERSION_CODE || defined(EL8)
ret = drm_fb_helper_init(dev, &efbdev->helper);
#else
ret = drm_fb_helper_init(dev, &efbdev->helper, 1);
Expand All @@ -503,7 +503,7 @@ int evdi_fbdev_init(struct drm_device *dev)
return ret;
}

#if KERNEL_VERSION(5, 7, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 7, 0) <= LINUX_VERSION_CODE || defined(EL8)
#else
drm_fb_helper_single_add_all_connectors(&efbdev->helper);
#endif
Expand Down
8 changes: 6 additions & 2 deletions module/evdi_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <drm/drmP.h>
#endif
#include "evdi_drm_drv.h"
#include "evdi_params.h"
#include <linux/shmem_fs.h>
#include <linux/dma-buf.h>
#include <drm/drm_cache.h>
Expand Down Expand Up @@ -101,7 +102,7 @@ evdi_gem_create(struct drm_file *file,
kfree(obj);
return ret;
}
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 9, 0) <= LINUX_VERSION_CODE || defined(EL8)
drm_gem_object_put(&obj->base);
#else
drm_gem_object_put_unlocked(&obj->base);
Expand Down Expand Up @@ -344,6 +345,9 @@ evdi_prime_import_sg_table(struct drm_device *dev,
struct evdi_gem_object *obj;
int npages;

if (evdi_disable_texture_import)
return ERR_PTR(-ENOMEM);

obj = evdi_gem_alloc_object(dev, attach->dmabuf->size);
if (IS_ERR(obj))
return ERR_CAST(obj);
Expand All @@ -368,7 +372,7 @@ evdi_prime_import_sg_table(struct drm_device *dev,
struct sg_table *evdi_prime_get_sg_table(struct drm_gem_object *obj)
{
struct evdi_gem_object *bo = to_evdi_bo(obj);
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE || defined(EL8)
return drm_prime_pages_to_sg(obj->dev, bo->pages, bo->base.size >> PAGE_SHIFT);
#else
return drm_prime_pages_to_sg(bo->pages, bo->base.size >> PAGE_SHIFT);
Expand Down
Loading

0 comments on commit e9ef330

Please sign in to comment.