From patchwork Mon Mar 22 18:57:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 87486 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2MIx0lT025487 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 22 Mar 2010 18:59:36 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NtmpA-0008LP-Dz; Mon, 22 Mar 2010 18:58:04 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Ntmp8-0008L7-VL for dri-devel@lists.sourceforge.net; Mon, 22 Mar 2010 18:58:02 +0000 Received-SPF: pass (sfi-mx-4.v28.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=mjg@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1Ntmp7-0000cW-TU for dri-devel@lists.sourceforge.net; Mon, 22 Mar 2010 18:58:02 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2MIvmLc031217 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Mar 2010 14:57:51 -0400 Received: from cavan.codon.org.uk (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2MIvlxq015157 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 22 Mar 2010 14:57:48 -0400 Received: from lan-nat-pool-bos.redhat.com ([66.187.234.200] helo=localhost.localdomain) by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Ntmor-0001yh-J4; Mon, 22 Mar 2010 18:57:45 +0000 From: Matthew Garrett To: dri-devel@lists.sourceforge.net Subject: [PATCH 1/4] radeon: Allow execution of scripts in atomic context Date: Mon, 22 Mar 2010 14:57:37 -0400 Message-Id: <1269284260-12224-1-git-send-email-mjg@redhat.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 66.187.234.200 X-SA-Exim-Mail-From: mjg@redhat.com X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Spam-Score: -1.0 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.5 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Ntmp7-0000cW-TU Cc: alexdeucher@gmail.com, Matthew Garrett X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 22 Mar 2010 18:59:36 +0000 (UTC) diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c index 247f8ee..bd5c5b5 100644 --- a/drivers/gpu/drm/radeon/atom.c +++ b/drivers/gpu/drm/radeon/atom.c @@ -651,6 +651,8 @@ static void atom_op_delay(atom_exec_context *ctx, int *ptr, int arg) SDEBUG(" count: %d\n", count); if (arg == ATOM_UNIT_MICROSEC) udelay(count); + else if (ctx->ctx->atomic) + mdelay(count); else schedule_timeout_uninterruptible(msecs_to_jiffies(count)); } @@ -1191,8 +1193,9 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32 int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params) { int r; + unsigned long flags; - mutex_lock(&ctx->mutex); + spin_lock_irqsave(&ctx->spinlock, flags); /* reset reg block */ ctx->reg_block = 0; /* reset fb window */ @@ -1200,7 +1203,26 @@ int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params) /* reset io mode */ ctx->io_mode = ATOM_IO_MM; r = atom_execute_table_locked(ctx, index, params); - mutex_unlock(&ctx->mutex); + spin_unlock_irqrestore(&ctx->spinlock, flags); + return r; +} + +int atom_execute_table_atomic(struct atom_context *ctx, int index, uint32_t * params) +{ + int r; + unsigned long flags; + spin_lock_irqsave(&ctx->spinlock, flags); + /* reset reg block */ + ctx->reg_block = 0; + /* reset fb window */ + ctx->fb_base = 0; + /* reset io mode */ + ctx->io_mode = ATOM_IO_MM; + /* be atomic */ + ctx->atomic = true; + r = atom_execute_table_locked(ctx, index, params); + ctx->atomic = false; + spin_unlock_irqrestore(&ctx->spinlock, flags); return r; } diff --git a/drivers/gpu/drm/radeon/atom.h b/drivers/gpu/drm/radeon/atom.h index cd1b64a..c26f5e1 100644 --- a/drivers/gpu/drm/radeon/atom.h +++ b/drivers/gpu/drm/radeon/atom.h @@ -121,7 +121,7 @@ struct card_info { struct atom_context { struct card_info *card; - struct mutex mutex; + spinlock_t spinlock; void *bios; uint32_t cmd_table, data_table; uint16_t *iio; @@ -135,12 +135,14 @@ struct atom_context { int cs_equal, cs_above; int io_mode; uint32_t *scratch; + bool atomic; }; extern int atom_debug; struct atom_context *atom_parse(struct card_info *, void *); int atom_execute_table(struct atom_context *, int, uint32_t *); +int atom_execute_table_atomic(struct atom_context *, int, uint32_t *); int atom_asic_init(struct atom_context *); void atom_destroy(struct atom_context *); bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size, diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 75f7b1e..3a711a9 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c @@ -384,7 +384,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); + spin_lock_init(&rdev->mode_info.atom_context->spinlock); radeon_atom_initialize_bios_scratch_regs(rdev->ddev); atom_allocate_fb_scratch(rdev->mode_info.atom_context); return 0;