From patchwork Mon Apr 22 14:18:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 2472161 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id A79343FCA5 for ; Mon, 22 Apr 2013 14:18:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D985E6815 for ; Mon, 22 Apr 2013 07:18:22 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CCF3E5F05 for ; Mon, 22 Apr 2013 07:18:10 -0700 (PDT) Received: by mail-vb0-f44.google.com with SMTP id e12so5885167vbg.31 for ; Mon, 22 Apr 2013 07:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=PiUC9f980Urxt68kVsPxjS0ydrv49M57sob6/YMw9DQ=; b=bUgxH59cMiE9IA5ykZhKX+hr5F9DkzpbV2BH41A0IT3cnpmcYnOBQDK0C4RB7nOl5w yOJtWJtV/SHpGjQiZ/bZQW957jHo8bgY8FcW4zf6+pnCY6+xJHQtrnkAnb+6lEO7gJaM zjzasAYlSuXyK7TZBUr5Be+JYDt12ihD04IorX37FvsFWOd7iXNRGVBWDrHuwAUvVzqc jejWfEbRRHOC0oWMZOmzlHSsUwBhsRnRyV+pKn7dhvC2Uu1qkxhxU0u22HbsL2FT+feZ +deh42Ok7cFv0MCcStnrixT1jI/bNAEYT7xj9wl7aSDOJ0BLJRSAHsCk4g4YLc83uage 1+SQ== MIME-Version: 1.0 X-Received: by 10.220.153.69 with SMTP id j5mr19035627vcw.35.1366640289542; Mon, 22 Apr 2013 07:18:09 -0700 (PDT) Received: by 10.59.4.180 with HTTP; Mon, 22 Apr 2013 07:18:09 -0700 (PDT) In-Reply-To: <20130422140857.GC8936@mwanda> References: <20130418184709.GA11596@elgon.mountain> <1366639393-10190-1-git-send-email-alexdeucher@gmail.com> <20130422140857.GC8936@mwanda> Date: Mon, 22 Apr 2013 10:18:09 -0400 Message-ID: Subject: Re: [PATCH] drm/radeon: fix endian bugs in radeon_atom_get_clock_dividers() From: Alex Deucher To: Dan Carpenter Cc: Alex Deucher , 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 Mon, Apr 22, 2013 at 10:08 AM, Dan Carpenter wrote: > On Mon, Apr 22, 2013 at 10:03:13AM -0400, alexdeucher@gmail.com wrote: >> From: Alex Deucher >> >> Reported-by: Dan Carpenter >> Signed-off-by: Alex Deucher >> --- >> drivers/gpu/drm/radeon/atombios.h | 2 ++ >> drivers/gpu/drm/radeon/radeon_atombios.c | 6 ++---- >> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/gpu/drm/radeon/atombios.h b/drivers/gpu/drm/radeon/atombios.h >> index 4b04ba3..de678dd 100644 >> --- a/drivers/gpu/drm/radeon/atombios.h >> +++ b/drivers/gpu/drm/radeon/atombios.h >> @@ -459,6 +459,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V3 >> { >> ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter >> ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter >> + ULONG ulClockFbDiv; > > Why is this a long instead of an __le32 or u32? atombios.h is shared across OSes and has it's own types. > > >> }; >> UCHAR ucRefDiv; //Output Parameter >> UCHAR ucPostDiv; //Output Parameter >> @@ -491,6 +492,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V5 >> { >> ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter >> ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter >> + ULONG ulClockFbDiv; >> }; >> UCHAR ucRefDiv; //Output Parameter >> UCHAR ucPostDiv; //Output Parameter >> diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c >> index 8c1779c..2fc444e 100644 >> --- a/drivers/gpu/drm/radeon/radeon_atombios.c >> +++ b/drivers/gpu/drm/radeon/radeon_atombios.c >> @@ -2710,8 +2710,7 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev, >> dividers->enable_post_div = (dividers->fb_div & 1) ? true : false; >> } else { >> if (clock_type == COMPUTE_ENGINE_PLL_PARAM) { >> - args.v3.ulClock.ulComputeClockFlag = clock_type; >> - args.v3.ulClock.ulClockFreq = cpu_to_le32(clock); /* 10 khz */ >> + args.v3.ulClockFbDiv = cpu_to_le32((clock_type << 24) | clock); >> >> atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); >> >> @@ -2726,8 +2725,7 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev, >> dividers->vco_mode = (args.v3.ucCntlFlag & >> ATOM_PLL_CNTL_FLAG_MPLL_VCO_MODE) ? 1 : 0; >> } else { >> - args.v5.ulClock.ulComputeClockFlag = clock_type; >> - args.v5.ulClock.ulClockFreq = cpu_to_le32(clock); /* 10 khz */ >> + args.v3.ulClockFbDiv = cpu_to_le32((clock_type << 24) | clock); > > We've changed from v5 to v3. Was that intentional? Copy paste typo. fixed in v2 which is attached. > > I'm confused by this patch as well. I assumed the datatypes were > determined by the hardware spec. I'm not sure I follow. The atombios interpretor requires data in little endian format. Alex From ce94ed1083df11895dbec520ef243d4fd805a4a9 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 22 Apr 2013 09:59:01 -0400 Subject: [PATCH] drm/radeon: fix endian bugs in radeon_atom_get_clock_dividers() (v2) v2: fix copy paste typo. Reported-by: Dan Carpenter Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/atombios.h | 2 ++ drivers/gpu/drm/radeon/radeon_atombios.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/atombios.h b/drivers/gpu/drm/radeon/atombios.h index 4b04ba3..de678dd 100644 --- a/drivers/gpu/drm/radeon/atombios.h +++ b/drivers/gpu/drm/radeon/atombios.h @@ -459,6 +459,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V3 { ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter + ULONG ulClockFbDiv; }; UCHAR ucRefDiv; //Output Parameter UCHAR ucPostDiv; //Output Parameter @@ -491,6 +492,7 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V5 { ATOM_COMPUTE_CLOCK_FREQ ulClock; //Input Parameter ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output Parameter + ULONG ulClockFbDiv; }; UCHAR ucRefDiv; //Output Parameter UCHAR ucPostDiv; //Output Parameter diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index 8c1779c..4b853d8 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -2710,8 +2710,7 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev, dividers->enable_post_div = (dividers->fb_div & 1) ? true : false; } else { if (clock_type == COMPUTE_ENGINE_PLL_PARAM) { - args.v3.ulClock.ulComputeClockFlag = clock_type; - args.v3.ulClock.ulClockFreq = cpu_to_le32(clock); /* 10 khz */ + args.v3.ulClockFbDiv = cpu_to_le32((clock_type << 24) | clock); atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); @@ -2726,8 +2725,7 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev, dividers->vco_mode = (args.v3.ucCntlFlag & ATOM_PLL_CNTL_FLAG_MPLL_VCO_MODE) ? 1 : 0; } else { - args.v5.ulClock.ulComputeClockFlag = clock_type; - args.v5.ulClock.ulClockFreq = cpu_to_le32(clock); /* 10 khz */ + args.v5.ulClockFbDiv = cpu_to_le32((clock_type << 24) | clock); if (strobe_mode) args.v5.ucInputFlag = ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN; -- 1.7.7.5