Skip to content

Commit

Permalink
drm/radeon/kms: prevent parallel AtomBIOS calls
Browse files Browse the repository at this point in the history
This just adds a mutex around the atombios table execution
so we don't call it from two contexts at once.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Rafał Miłecki authored and Dave Airlie committed Dec 23, 2009
1 parent d79766f commit c31ad97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/gpu/drm/radeon/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct {
} atom_exec_context;

int atom_debug = 0;
static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params);
void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params);

static uint32_t atom_arg_mask[8] =
Expand Down Expand Up @@ -573,7 +574,7 @@ static void atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg)
else
SDEBUG(" table: %d\n", idx);
if (U16(ctx->ctx->cmd_table + 4 + 2 * idx))
atom_execute_table(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
}

static void atom_op_clear(atom_exec_context *ctx, int *ptr, int arg)
Expand Down Expand Up @@ -1040,7 +1041,7 @@ static struct {
atom_op_shr, ATOM_ARG_MC}, {
atom_op_debug, 0},};

void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params)
{
int base = CU16(ctx->cmd_table + 4 + 2 * index);
int len, ws, ps, ptr;
Expand Down Expand Up @@ -1092,6 +1093,13 @@ void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
kfree(ectx.ws);
}

void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
{
mutex_lock(&ctx->mutex);
atom_execute_table_locked(ctx, index, params);
mutex_unlock(&ctx->mutex);
}

static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 };

static void atom_index_iio(struct atom_context *ctx, int base)
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/radeon/atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct card_info {

struct atom_context {
struct card_info *card;
struct mutex mutex;
void *bios;
uint32_t cmd_table, data_table;
uint16_t *iio;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/radeon/radeon_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ int radeon_atombios_init(struct radeon_device *rdev)
atom_card_info->pll_write = cail_pll_write;

rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios);
mutex_init(&rdev->mode_info.atom_context->mutex);
radeon_atom_initialize_bios_scratch_regs(rdev->ddev);
atom_allocate_fb_scratch(rdev->mode_info.atom_context);
return 0;
Expand Down

0 comments on commit c31ad97

Please sign in to comment.