From patchwork Tue Jul 31 20:05:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luca Tettamanti X-Patchwork-Id: 1261891 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id AD455DF26F for ; Tue, 31 Jul 2012 20:05:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DFB49E84B for ; Tue, 31 Jul 2012 13:05:42 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E25E9E70A for ; Tue, 31 Jul 2012 13:05:28 -0700 (PDT) Received: by wgbdr1 with SMTP id dr1so5124022wgb.12 for ; Tue, 31 Jul 2012 13:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=SKHeZBwnfYx6eUlD37ioZcSAb7MjTrdYW4TuWP+AxeA=; b=PMg4aA2+5Utulu0Q36IoT4eoeQta9hcWFpqu0P9zk7ShQkjE00xB7CmnR1tCZtT+jp HP8S2iXE9yTpju6772jW6qJsJIvQ1J/8mA8ug3AIEcGEW7VyvyyPWX2lzg0pyUW0ywnj tWU4zKtlrPQcMYgA2AT4Wf6ir37r3QXfwwekMQdoZimOL32YUP0v1jtJQLScw/sQafiE 0yLLvlc8UQkv4QsLYpyGyKR4sfFSDur895CBoBA/1SCcrMo9+2zrhZXEMCGgtlZP3jKC 8HMMibyMoivNeUQaZ0yEjbA7wMebQHZv8dhtfra41jlfRmpLbbDwGgZ4ma7j5rmw7zuA uNRg== Received: by 10.180.84.164 with SMTP id a4mr10068444wiz.12.1343765127437; Tue, 31 Jul 2012 13:05:27 -0700 (PDT) Received: from growl (dynamic-adsl-78-14-229-172.clienti.tiscali.it. [78.14.229.172]) by mx.google.com with ESMTPS id z11sm2619665wiv.10.2012.07.31.13.05.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 Jul 2012 13:05:26 -0700 (PDT) Date: Tue, 31 Jul 2012 22:05:20 +0200 From: Luca Tettamanti To: Alex Deucher Subject: Re: [PATCH] drm/radeon: add new AMD ACPI header and update relevant code Message-ID: <20120731200520.GA5425@growl> References: <20120726193346.GA11288@growl> <20120728145626.GA6304@growl> <20120729130644.GA12378@growl> <20120730202449.GA5600@growl> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Alex Deucher , joeyli , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org On Tue, Jul 31, 2012 at 09:58:04AM -0400, Alex Deucher wrote: > On Tue, Jul 31, 2012 at 5:16 AM, Luca Tettamanti wrote: > > On Mon, Jul 30, 2012 at 10:45 PM, Alex Deucher wrote: > >> Regarding patches 3 and 4, it might be easier to just store a pointer > >> to the relevant encoder when you verify ATIF rather than walking the > >> encoder list every time. Done. > > Makes sense, I was unsure about the lifetime of the encoders, but > > AFAICS they're destroyed only when the module in unloaded. > > They are present for the life of the driver. I had to move to call to radeon_acpi_init after radeon_modeset_init, otherwise the encoders are not present yet (the tear down code path is correct, acpi first, then modeset). Latest and greatest version is attached; I fixed notifications when using custom command codes (tested by Pali Rohár) and implemented your suggestion. Luca From f0f8699eabee0d47b93fba14f8126b821cc106a5 Mon Sep 17 00:00:00 2001 From: Luca Tettamanti Date: Sun, 29 Jul 2012 17:04:43 +0200 Subject: [PATCH 1/4] drm/radeon: refactor radeon_atif_call Don't hard-code function number, this will allow to reuse the function. v2: add support for the 2nd parameter (from Lee, Chun-Yi ). Signed-off-by: Luca Tettamanti --- drivers/gpu/drm/radeon/radeon_acpi.c | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c index 5b32e49..158e514 100644 --- a/drivers/gpu/drm/radeon/radeon_acpi.c +++ b/drivers/gpu/drm/radeon/radeon_acpi.c @@ -14,23 +14,30 @@ #include /* Call the ATIF method - * - * Note: currently we discard the output */ -static int radeon_atif_call(acpi_handle handle) +static union acpi_object *radeon_atif_call(acpi_handle handle, int function, + struct acpi_buffer *params) { acpi_status status; union acpi_object atif_arg_elements[2]; struct acpi_object_list atif_arg; - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; atif_arg.count = 2; atif_arg.pointer = &atif_arg_elements[0]; atif_arg_elements[0].type = ACPI_TYPE_INTEGER; - atif_arg_elements[0].integer.value = ATIF_FUNCTION_VERIFY_INTERFACE; - atif_arg_elements[1].type = ACPI_TYPE_INTEGER; - atif_arg_elements[1].integer.value = 0; + atif_arg_elements[0].integer.value = function; + + if (params) { + atif_arg_elements[1].type = ACPI_TYPE_BUFFER; + atif_arg_elements[1].buffer.length = params->length; + atif_arg_elements[1].buffer.pointer = params->pointer; + } else { + /* We need a second fake parameter */ + atif_arg_elements[1].type = ACPI_TYPE_INTEGER; + atif_arg_elements[1].integer.value = 0; + } status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer); @@ -39,18 +46,18 @@ static int radeon_atif_call(acpi_handle handle) DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n", acpi_format_exception(status)); kfree(buffer.pointer); - return 1; + return NULL; } - kfree(buffer.pointer); - return 0; + return buffer.pointer; } /* Call all ACPI methods here */ int radeon_acpi_init(struct radeon_device *rdev) { acpi_handle handle; - int ret; + union acpi_object *info; + int ret = 0; /* Get the device handle */ handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); @@ -60,10 +67,11 @@ int radeon_acpi_init(struct radeon_device *rdev) return 0; /* Call the ATIF method */ - ret = radeon_atif_call(handle); - if (ret) - return ret; + info = radeon_atif_call(handle, ATIF_FUNCTION_VERIFY_INTERFACE, NULL); + if (!info) + ret = -EIO; - return 0; + kfree(info); + return ret; }