All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple@vodafone.de>
To: "Michel Dänzer" <michel@daenzer.net>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/4] drm/radeon: fix and simplify pot argument checks
Date: Tue, 23 Oct 2012 15:40:45 +0200	[thread overview]
Message-ID: <50869E5D.1060103@vodafone.de> (raw)
In-Reply-To: <1350996241.11117.19.camel@thor.local>

On 23.10.2012 14:44, Michel Dänzer wrote:
> On Die, 2012-10-23 at 14:23 +0200, Christian König wrote:
>> GART and VRAM size limits need to be a power of two.
>> Fix values greater than 1GB and simplify those checks a bit.
>>
>> Signed-off-by: Christian König <deathsimple@vodafone.de>
>> ---
>>   drivers/gpu/drm/radeon/radeon_device.c |   55 ++++++++++++--------------------
>>   1 file changed, 21 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
>> index bd13ca0..3277aa1 100644
>> --- a/drivers/gpu/drm/radeon/radeon_device.c
>> +++ b/drivers/gpu/drm/radeon/radeon_device.c
>> @@ -835,6 +835,19 @@ static unsigned int radeon_vga_set_decode(void *cookie, bool state)
>>   }
>>   
>>   /**
>> + * radeon_check_pot_argument - check that argument is a power of two
>> + *
>> + * @arg: value to check
>> + *
>> + * Validates that a certain argument is a power of two (all asics).
>> + * Returns true if argument is valid.
>> + */
>> +static bool radeon_ckeck_pot_argument(int arg)
>> +{
>> +	return (arg & ((1 << __fls(arg)) - 1)) == 0;
>> +}
> This could be simplified as
>
> return (arg & (arg - 1)) == 0;

Fixed.

>
>
>> -	radeon_vram_limit = radeon_vram_limit << 20;
>> +	radeon_vram_limit = (uint64_t)radeon_vram_limit << 20;
> Does this cast have any effect without also changing the type of
> radeon_vram_limit to something other than int? If the point is to allow
> the shift to set the sign bit, I think casting to unsigned int or
> uint32_t would be slightly less confusing, but a comment is probably
> warranted anyway to prevent this from getting broken accidentally.
Well, I actually focused on the GART limit instead, and just tried to 
fix that in the same way.

But wait a moment, modifying the radeon_vmram_limit here is quite faulty 
anyway, cause this code gets executed for each card in the system. So 
the vram limit won't work for the second card any more (and might 
produce quite unusable results).

Going to fix that.

>
>
> The commit message of patch 2 has a typo (vzmalloc instead of vzalloc),
> other than that patches 2-4 are
>
> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Thanks for the review, going to send out a v2 of the patchset soon.

Christian.

      reply	other threads:[~2012-10-23 13:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 12:23 [PATCH 1/4] drm/radeon: fix and simplify pot argument checks Christian König
2012-10-23 12:23 ` [PATCH 2/4] drm/radeon: use vzalloc for gart pages Christian König
2012-10-23 12:23 ` [PATCH 3/4] drm/radeon: move size limits to gem_object_create Christian König
2012-10-23 12:23 ` [PATCH 4/4] drm/radeon: move the retry " Christian König
2012-10-23 12:44 ` [PATCH 1/4] drm/radeon: fix and simplify pot argument checks Michel Dänzer
2012-10-23 13:40   ` Christian König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50869E5D.1060103@vodafone.de \
    --to=deathsimple@vodafone.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.