diff mbox

drm/i915: Fix CSR MMIO address check

Message ID 1441810329-26674-1-git-send-email-tiwai@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Iwai Sept. 9, 2015, 2:52 p.m. UTC
Fix a wrong logical AND (&&) used for the range check of CSR MMIO.

Spotted nicely by gcc -Wlogical-op flag:
  drivers/gpu/drm/i915/intel_csr.c: In function ‘finish_csr_load’:
  drivers/gpu/drm/i915/intel_csr.c:353:41: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]

Fixes: eb805623d8b1 ('drm/i915/skl: Add support to load SKL CSR firmware.')
Cc: <stable@vger.kernel.org> # v4.2
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/gpu/drm/i915/intel_csr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Vetter Sept. 9, 2015, 3:30 p.m. UTC | #1
On Wed, Sep 09, 2015 at 04:52:09PM +0200, Takashi Iwai wrote:
> Fix a wrong logical AND (&&) used for the range check of CSR MMIO.
> 
> Spotted nicely by gcc -Wlogical-op flag:
>   drivers/gpu/drm/i915/intel_csr.c: In function ‘finish_csr_load’:
>   drivers/gpu/drm/i915/intel_csr.c:353:41: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
> 
> Fixes: eb805623d8b1 ('drm/i915/skl: Add support to load SKL CSR firmware.')
> Cc: <stable@vger.kernel.org> # v4.2
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Oops. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> and for Jani.
-Daniel

> ---
>  drivers/gpu/drm/i915/intel_csr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
> index ba1ae031e6fd..d0f1b8d833cd 100644
> --- a/drivers/gpu/drm/i915/intel_csr.c
> +++ b/drivers/gpu/drm/i915/intel_csr.c
> @@ -350,7 +350,7 @@ static void finish_csr_load(const struct firmware *fw, void *context)
>  	}
>  	csr->mmio_count = dmc_header->mmio_count;
>  	for (i = 0; i < dmc_header->mmio_count; i++) {
> -		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE &&
> +		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
>  			dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
>  			DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
>  						dmc_header->mmioaddr[i]);
> -- 
> 2.5.1
>
Manna, Animesh Sept. 9, 2015, 7:57 p.m. UTC | #2
On 9/9/2015 9:00 PM, Daniel Vetter wrote:
> On Wed, Sep 09, 2015 at 04:52:09PM +0200, Takashi Iwai wrote:
>> Fix a wrong logical AND (&&) used for the range check of CSR MMIO.
>>
>> Spotted nicely by gcc -Wlogical-op flag:
>>    drivers/gpu/drm/i915/intel_csr.c: In function ‘finish_csr_load’:
>>    drivers/gpu/drm/i915/intel_csr.c:353:41: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
>>
>> Fixes: eb805623d8b1 ('drm/i915/skl: Add support to load SKL CSR firmware.')
>> Cc: <stable@vger.kernel.org> # v4.2
>> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> Oops. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> and for Jani.
> -Daniel
The same change is submitted part of dmc-redesign patch series.
http://lists.freedesktop.org/archives/intel-gfx/2015-August/074447.html

-Animesh
>
>> ---
>>   drivers/gpu/drm/i915/intel_csr.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
>> index ba1ae031e6fd..d0f1b8d833cd 100644
>> --- a/drivers/gpu/drm/i915/intel_csr.c
>> +++ b/drivers/gpu/drm/i915/intel_csr.c
>> @@ -350,7 +350,7 @@ static void finish_csr_load(const struct firmware *fw, void *context)
>>   	}
>>   	csr->mmio_count = dmc_header->mmio_count;
>>   	for (i = 0; i < dmc_header->mmio_count; i++) {
>> -		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE &&
>> +		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
>>   			dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
>>   			DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
>>   						dmc_header->mmioaddr[i]);
>> -- 
>> 2.5.1
>>
Jani Nikula Sept. 10, 2015, 9:13 a.m. UTC | #3
On Wed, 09 Sep 2015, Animesh Manna <animesh.manna@intel.com> wrote:
> On 9/9/2015 9:00 PM, Daniel Vetter wrote:
>> On Wed, Sep 09, 2015 at 04:52:09PM +0200, Takashi Iwai wrote:
>>> Fix a wrong logical AND (&&) used for the range check of CSR MMIO.
>>>
>>> Spotted nicely by gcc -Wlogical-op flag:
>>>    drivers/gpu/drm/i915/intel_csr.c: In function ‘finish_csr_load’:
>>>    drivers/gpu/drm/i915/intel_csr.c:353:41: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
>>>
>>> Fixes: eb805623d8b1 ('drm/i915/skl: Add support to load SKL CSR firmware.')
>>> Cc: <stable@vger.kernel.org> # v4.2
>>> Signed-off-by: Takashi Iwai <tiwai@suse.de>
>> Oops. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> and for Jani.
>> -Daniel
> The same change is submitted part of dmc-redesign patch series.
> http://lists.freedesktop.org/archives/intel-gfx/2015-August/074447.html

Pushed Takashi's patch to drm-intel-next-fixes, thanks for the patch and
review.

When there are multiple patches doing the same thing, I usually pick the
earliest submitted. However Animesh's patch did not apply because it is
at the end of a long series. Indeed you should always prefer doing fixes
first, especially if they need to be backported to stable kernels. I
took the liberty of adding Animesh's contribution as Reviewed-by.

BR,
Jani.


>
> -Animesh
>>
>>> ---
>>>   drivers/gpu/drm/i915/intel_csr.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
>>> index ba1ae031e6fd..d0f1b8d833cd 100644
>>> --- a/drivers/gpu/drm/i915/intel_csr.c
>>> +++ b/drivers/gpu/drm/i915/intel_csr.c
>>> @@ -350,7 +350,7 @@ static void finish_csr_load(const struct firmware *fw, void *context)
>>>   	}
>>>   	csr->mmio_count = dmc_header->mmio_count;
>>>   	for (i = 0; i < dmc_header->mmio_count; i++) {
>>> -		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE &&
>>> +		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
>>>   			dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
>>>   			DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
>>>   						dmc_header->mmioaddr[i]);
>>> -- 
>>> 2.5.1
>>>
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
index ba1ae031e6fd..d0f1b8d833cd 100644
--- a/drivers/gpu/drm/i915/intel_csr.c
+++ b/drivers/gpu/drm/i915/intel_csr.c
@@ -350,7 +350,7 @@  static void finish_csr_load(const struct firmware *fw, void *context)
 	}
 	csr->mmio_count = dmc_header->mmio_count;
 	for (i = 0; i < dmc_header->mmio_count; i++) {
-		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE &&
+		if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
 			dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
 			DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
 						dmc_header->mmioaddr[i]);