[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: debug-pl011.inc: Use macros instead of hardcoded values


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 16 Nov 2022 15:45:58 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w2kg0mYJ/BV+np7FuvaiEUyqoTrcgnnJ+v1rzQy5YkI=; b=BqHOOtRh2GRBCr9ye11/t+csNfuHj6hmgaHEYqDx0SgqW2pPNRQykpQB9IpZRkUJ2WCtNU4O4hoQllw+kqgmndqjgycnnh8Y0Z8CHNIr7EgYew2uMsXVJ6G6pJBT2dFu+K+i2yqJSsAxbq2dScwlyufTCwHhdqZB7N8VTL4uFZDDqnzL/SlBR4NyNVtzrozSK6TsSo+nb5qRRnNhYIKifsYXcXZJjF9w4ECSRkNFZN1bz5KgSXPcs1MqxsiQCngzqmWyywHUpkr0q1rbs3oHUSVleOtD+/QqRhfvp8Lmq6ZHCLDUOR49y00Rd8Sm9+JT1r+EQaQ6gBT04gJc3hlRKw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BDtHfUQbc+TD7SK9VigXUsFa/69dQS0wM2UulAklN21dHHRVue0+q3BgTrlj8Zf2JAQ2MFeX3VIaaQcNvDUoqW40f3pwPe/W1UBEa6JmdXdFPUWZXQqLsDwXSkKy1c6n9m0er4rgWFk6jjd31KglZw1n6mV/HCNkmjI9j82lHuVAOM34V8PAZFRGqG8/wpB2169oJAhGHuM2vqw+PK2eHtmML4vReKU2yTPxca+FX8hU8aBToNrVWH8q2PD+orxwfwgS1umpEAdxAoUmUWNAylw39KX+oTtmbBqK2hb5+yDT9pQZKVGbF6woyiQkn84T6g1z3u5jGJXqznKv0aK8Hw==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 16 Nov 2022 14:46:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 16/11/2022 14:41, Julien Grall wrote:
> 
> 
> On 16/11/2022 08:05, Michal Orzel wrote:
>> On 16/11/2022 00:10, Julien Grall wrote:
>>>
>>>
>>> Hi Michal,
>>>
>>> On 24/10/2022 11:05, Michal Orzel wrote:
>>>> Make use of the macros defined in asm/pl011-uart.h instead of hardcoding
>>>> the values. Also, take the opportunity to fix the file extension in a
>>>> top-level comment.
>>>>
>>>> No functional change intended.
>>>>
>>>> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
>>>
>>> With one comment below:
>>>
>>> Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
>>>
>>>> ---
>>>>    xen/arch/arm/arm64/debug-pl011.inc | 20 +++++++++++---------
>>>>    1 file changed, 11 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/xen/arch/arm/arm64/debug-pl011.inc 
>>>> b/xen/arch/arm/arm64/debug-pl011.inc
>>>> index 1928a2e3ffbb..d82f2f1de197 100644
>>>> --- a/xen/arch/arm/arm64/debug-pl011.inc
>>>> +++ b/xen/arch/arm/arm64/debug-pl011.inc
>>>> @@ -1,5 +1,5 @@
>>>>    /*
>>>> - * xen/arch/arm/arm64/debug-pl011.S
>>>> + * xen/arch/arm/arm64/debug-pl011.inc
>>>>     *
>>>>     * PL011 specific debug code
>>>>     *
>>>> @@ -16,6 +16,8 @@
>>>>     * GNU General Public License for more details.
>>>>     */
>>>>
>>>> + #include <asm/pl011-uart.h>
>>>> +
>>>>    /*
>>>>     * PL011 UART initialization
>>>>     * xb: register which containts the UART base address
>>>> @@ -23,13 +25,13 @@
>>>>     */
>>>>    .macro early_uart_init xb, c
>>>>            mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16)
>>>> -        strh  w\c, [\xb, #0x28]      /* -> UARTFBRD (Baud divisor 
>>>> fraction) */
>>>> +        strh  w\c, [\xb, #FBRD]      /* -> UARTFBRD (Baud divisor 
>>>> fraction) */
>>>>            mov   x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16)
>>>> -        strh  w\c, [\xb, #0x24]      /* -> UARTIBRD (Baud divisor 
>>>> integer) */
>>>> +        strh  w\c, [\xb, #IBRD]      /* -> UARTIBRD (Baud divisor 
>>>> integer) */
>>>>            mov   x\c, #0x60             /* 8n1 */
>>>
>>> Can we introduce macro/define for 0x60?
>> We could but I think this should not be part of this patch.
>> The reason being, the arm32 code also uses hardcoded 0x60 so it should be 
>> changed as well.
>> I can create a prerequisite patch introducing the macro and changing the 
>> arm32 code first unless you prefer to have everything in a single patch.
> 
> I am fine with either prerequisite or a follow-up to define a macro and
> use it in both arm32/arm64.
I would then prefer to add a follow-up patch as this one is already acked
and created for a different reason.

> 
>>
>> As for the macro itself, because 8n1 only requires setting bits for WLEN (1 
>> stop bit and no parity are 0 by default), we can do
>> the following in pl011-uart.h:
>> #define WLEN_8 0x60
> 
> I think it would be clearer and easier to check the spec if the value is
> (_AC(0x3, U) << 5).
sounds good.

> 
>> and use it in the pl011-debug files (+ there is a question whether we should 
>> define WLEN_7-5 for completeness).
> 
> I would not define WLEN_7-5. That said, I wonder if we really need to
> set the baud rate & co here?
> 
> AFAICT the runtime driver never touch them. The reasoning is the
> firmware is responsible to configure the serial. Therefore, I would
> consider to drop the code (setting UARTCR might still be necessary).
I do not really agree because the current behavior was done on purpose.
At the moment early_uart_init is called only if EARLY_UART_PL011_BAUD_RATE is 
set to a value != 0.
This is done in order to have flexibility to either stick to what 
firmware/bootloader configured or to change this
configuration by specifying the EARLY_UART_PL011_BAUD_RATE (useful when you do 
not know what
the firmware configured).

> 
> Cheers,
> 
> --
> Julien Grall

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.