Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751688AbdGZKof (ORCPT ); Wed, 26 Jul 2017 06:44:35 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:33290 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbdGZKod (ORCPT ); Wed, 26 Jul 2017 06:44:33 -0400 MIME-Version: 1.0 In-Reply-To: <597833A2.8090709@windriver.com> References: <1500630080-18234-1-git-send-email-liwei.song@windriver.com> <597833A2.8090709@windriver.com> From: Andy Shevchenko Date: Wed, 26 Jul 2017 13:44:32 +0300 Message-ID: Subject: Re: [PATCH] ACPI, APEI: Fixup incorrect 16-bit access width firmware bug To: Liwei Song Cc: "Rafael J . Wysocki" , Len Brown , linux-acpi , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1284 Lines: 35 On Wed, Jul 26, 2017 at 9:16 AM, Liwei Song wrote: > On 07/21/2017 05:56 PM, Andy Shevchenko wrote: >> On Fri, Jul 21, 2017 at 12:41 PM, Song liwei wrote: >> /* Fixup common BIOS bug */ >> if (bit_offset == 0) { >> if (bit_width == 16 && (*paddr & 0x01) == 0 && *access_bit_width < 16) >> *access_bit_width = 16; >> else if (bit_width == 32 && (*paddr & 0x03) == 0 && >> *access_bit_width < 32) >> *access_bit_width = 32; >> else if (bit_width == 64 && (*paddr & 0x07) == 0 && >> *access_bit_width < 64) >> *access_bit_width = 64; >> } > Thanks for your suggestion, what about the condition like the following? > The main bug in bios is bit_width is not comfortable with access_bit_width > So check it first. > > if (*access_bit_width < bit_width && bit_offset == 0) { > if ((bit_width == 16 && (*paddr & 0x01) == 0) || > (bit_width == 32 && (*paddr & 0x03) == 0) || > (bit_width == 64 && (*paddr & 0x07) == 0)) > *access_bit_width = bit_width; > } Either works to me. P.S. Less explicit case is to use bit operations to check those, i.e. is_power_of_2(), fls(). -- With Best Regards, Andy Shevchenko