Skip to content

Commit

Permalink
gpu: host1x: Expose syncpt and channel functionality
Browse files Browse the repository at this point in the history
Expose the buffer objects, syncpoint and channel functionality in the
public public header so that drivers can use them.

Signed-off-by: Thierry Reding <treding@nvidia.com>
  • Loading branch information
Thierry Reding committed Oct 31, 2013
1 parent 53fa7f7 commit 35d747a
Show file tree
Hide file tree
Showing 14 changed files with 211 additions and 254 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/host1x/cdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <asm/cacheflush.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/host1x.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/kfifo.h>
Expand All @@ -30,7 +31,6 @@
#include "channel.h"
#include "dev.h"
#include "debug.h"
#include "host1x_bo.h"
#include "job.h"

/*
Expand Down
6 changes: 0 additions & 6 deletions drivers/gpu/host1x/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ struct host1x_channel {
/* channel list operations */
int host1x_channel_list_init(struct host1x *host);

struct host1x_channel *host1x_channel_request(struct device *dev);
void host1x_channel_free(struct host1x_channel *channel);
struct host1x_channel *host1x_channel_get(struct host1x_channel *channel);
void host1x_channel_put(struct host1x_channel *channel);
int host1x_job_submit(struct host1x_job *job);

#define host1x_for_each_channel(host, channel) \
list_for_each_entry(channel, &host->chlist.list, list)

Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/host1x/drm/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
*/

#include "host1x_client.h"
#include "dev.h"
#include "drm.h"
#include "gem.h"
#include "syncpt.h"

#define DRIVER_NAME "tegra"
#define DRIVER_DESC "NVIDIA Tegra graphics"
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/host1x/drm/gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#ifndef __HOST1X_GEM_H
#define __HOST1X_GEM_H

#include <linux/host1x.h>

#include <drm/drm.h>
#include <drm/drmP.h>

#include "host1x_bo.h"

struct tegra_bo {
struct drm_gem_object gem;
struct host1x_bo base;
Expand Down
6 changes: 1 addition & 5 deletions drivers/gpu/host1x/drm/gr2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@

#include <linux/clk.h>

#include "channel.h"
#include "host1x_client.h"
#include "drm.h"
#include "gem.h"
#include "job.h"
#include "host1x_bo.h"
#include "host1x_client.h"
#include "syncpt.h"

#define GR2D_NUM_REGS 0x4d

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/host1x/drm/hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include <linux/hdmi.h>
#include <linux/regulator/consumer.h>

#include "host1x_client.h"
#include "hdmi.h"
#include "drm.h"
#include "dc.h"
#include "host1x_client.h"

struct tegra_hdmi {
struct tegra_drm_client client;
Expand Down
87 changes: 0 additions & 87 deletions drivers/gpu/host1x/host1x_bo.h

This file was deleted.

1 change: 0 additions & 1 deletion drivers/gpu/host1x/hw/channel_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include <trace/events/host1x.h>

#include "host1x_bo.h"
#include "channel.h"
#include "dev.h"
#include "intr.h"
Expand Down
1 change: 0 additions & 1 deletion drivers/gpu/host1x/hw/debug_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "debug.h"
#include "cdma.h"
#include "channel.h"
#include "host1x_bo.h"

#define HOST1X_DEBUG_MAX_PAGE_OFFSET 102400

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/host1x/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/host1x.h>
#include <linux/kref.h>
#include <linux/module.h>
#include <linux/scatterlist.h>
Expand All @@ -27,7 +28,6 @@

#include "channel.h"
#include "dev.h"
#include "host1x_bo.h"
#include "job.h"
#include "syncpt.h"

Expand Down
108 changes: 0 additions & 108 deletions drivers/gpu/host1x/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ struct host1x_cmdbuf {
u32 pad;
};

struct host1x_reloc {
struct host1x_bo *cmdbuf;
u32 cmdbuf_offset;
struct host1x_bo *target;
u32 target_offset;
u32 shift;
u32 pad;
};

struct host1x_waitchk {
struct host1x_bo *bo;
u32 offset;
Expand All @@ -55,105 +46,6 @@ struct host1x_job_unpin_data {
struct sg_table *sgt;
};

/*
* Each submit is tracked as a host1x_job.
*/
struct host1x_job {
/* When refcount goes to zero, job can be freed */
struct kref ref;

/* List entry */
struct list_head list;

/* Channel where job is submitted to */
struct host1x_channel *channel;

u32 client;

/* Gathers and their memory */
struct host1x_job_gather *gathers;
unsigned int num_gathers;

/* Wait checks to be processed at submit time */
struct host1x_waitchk *waitchk;
unsigned int num_waitchk;
u32 waitchk_mask;

/* Array of handles to be pinned & unpinned */
struct host1x_reloc *relocarray;
unsigned int num_relocs;
struct host1x_job_unpin_data *unpins;
unsigned int num_unpins;

dma_addr_t *addr_phys;
dma_addr_t *gather_addr_phys;
dma_addr_t *reloc_addr_phys;

/* Sync point id, number of increments and end related to the submit */
u32 syncpt_id;
u32 syncpt_incrs;
u32 syncpt_end;

/* Maximum time to wait for this job */
unsigned int timeout;

/* Index and number of slots used in the push buffer */
unsigned int first_get;
unsigned int num_slots;

/* Copy of gathers */
size_t gather_copy_size;
dma_addr_t gather_copy;
u8 *gather_copy_mapped;

/* Check if register is marked as an address reg */
int (*is_addr_reg)(struct device *dev, u32 reg, u32 class);

/* Request a SETCLASS to this class */
u32 class;

/* Add a channel wait for previous ops to complete */
bool serialize;
};
/*
* Allocate memory for a job. Just enough memory will be allocated to
* accomodate the submit.
*/
struct host1x_job *host1x_job_alloc(struct host1x_channel *ch,
u32 num_cmdbufs, u32 num_relocs,
u32 num_waitchks);

/*
* Add a gather to a job.
*/
void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id,
u32 words, u32 offset);

/*
* Increment reference going to host1x_job.
*/
struct host1x_job *host1x_job_get(struct host1x_job *job);

/*
* Decrement reference job, free if goes to zero.
*/
void host1x_job_put(struct host1x_job *job);

/*
* Pin memory related to job. This handles relocation of addresses to the
* host1x address space. Handles both the gather memory and any other memory
* referred to from the gather buffers.
*
* Handles also patching out host waits that would wait for an expired sync
* point value.
*/
int host1x_job_pin(struct host1x_job *job, struct device *dev);

/*
* Unpin memory related to job.
*/
void host1x_job_unpin(struct host1x_job *job);

/*
* Dump contents of job to debug output.
*/
Expand Down
19 changes: 19 additions & 0 deletions drivers/gpu/host1x/syncpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,25 @@ void host1x_syncpt_deinit(struct host1x *host)
kfree(sp->name);
}

/*
* Read max. It indicates how many operations there are in queue, either in
* channel or in a software thread.
* */
u32 host1x_syncpt_read_max(struct host1x_syncpt *sp)
{
smp_rmb();
return (u32)atomic_read(&sp->max_val);
}

/*
* Read min, which is a shadow of the current sync point value in hardware.
*/
u32 host1x_syncpt_read_min(struct host1x_syncpt *sp)
{
smp_rmb();
return (u32)atomic_read(&sp->min_val);
}

int host1x_syncpt_nb_pts(struct host1x *host)
{
return host->info->nb_pts;
Expand Down
Loading

0 comments on commit 35d747a

Please sign in to comment.