All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Xu <xuwei5@hisilicon.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Linuxarm <linuxarm@huawei.com>,
	Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>,
	"Zengtao \(B\)" <prime.zeng@hisilicon.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [Xen-devel] [PATCH v2] ns16550: Add ACPI support for ARM only
Date: Wed, 22 Jan 2020 14:42:42 +0800	[thread overview]
Message-ID: <5E27EEE2.2060402@hisilicon.com> (raw)
In-Reply-To: <f067440e-7df6-b40e-ed98-6b14c5c5f53d@suse.com>

Hi Jan,

On 2020/1/21 19:13, Jan Beulich wrote:
> On 21.01.2020 04:44, Wei Xu wrote:
>> --- a/xen/drivers/char/ns16550.c
>> +++ b/xen/drivers/char/ns16550.c
>> @@ -1620,6 +1620,66 @@ DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIAL)
>>   DT_DEVICE_END
>>   
>>   #endif /* HAS_DEVICE_TREE */
>> +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM)
> 
> Blank line above here please.

OK.
I will add it.

> 
>> +#include <xen/acpi.h>
>> +
>> +static int __init ns16550_acpi_uart_init(const void *data)
>> +{
>> +    struct acpi_table_spcr *spcr;
>> +    acpi_status status;
>> +
>> +    /* Same as the DT part.
> 
> Comment style (again below). Also there shouldn't be a blank line
> until after _all_ declarations.

OK.
I will add a separate line leading with '*' as the comment beginning
and remove the blank line in the declarations.

> 
>> +     * Only support one UART on ARM which happen to be ns16550_com[0].
>> +     */
>> +    struct ns16550 *uart = &ns16550_com[0];
>> +
>> +    status = acpi_get_table(ACPI_SIG_SPCR, 0,
>> +                            (struct acpi_table_header **)&spcr);
> 
> Please avoid casts like this. Use more type-safe constructs like
> container_of() instead.
> 
>> +    if ( ACPI_FAILURE(status) )
>> +    {
>> +        printk("ns16550: Failed to get SPCR table\n");
> 
> Is such a message warranted? I.e. wouldn't it trigger on all
> systems not having the table, which is hardly what you/we want?
> 
>> +        return -EINVAL;
> 
> Also, is it really an error if there's no such table?
> 
>> +    }
>> +
>> +    ns16550_init_common(uart);
>> +
>> +    /* The baud rate is pre-configured by the firmware.
>> +     * And currently the ACPI part is only targeting ARM so some fields
>> +     * like PCI, flow control and so on we do not care yet are ignored.
>> +     */
> 
> I'm no convinced though you can ignore some other fields. In
> particular on v1 I recall pointing out that the GAS structure
> has more fields you should look at. (Overall I'm not happy
> with "and so on" here - please list all fields you mean to
> ignore so that reviewers as well as future readers can judge
> whether this is appropriate.)
>

OK.
I will investigate and list all the ignore fields.

>> +    uart->baud = BAUD_AUTO;
>> +    uart->data_bits = 8;
>> +    uart->parity = spcr->parity;
>> +    uart->stop_bits = spcr->stop_bits;
>> +    uart->io_base = spcr->serial_port.address;
>> +    uart->io_size = 8;
>> +    uart->reg_shift = spcr->serial_port.bit_offset;
>> +    uart->reg_width = 1;
>> +
>> +    /* The trigger/polarity information is not available in spcr. */
>> +    irq_set_type(spcr->interrupt, IRQ_TYPE_LEVEL_HIGH);
>> +    uart->irq = spcr->interrupt;
>> +
>> +    uart->vuart.base_addr = uart->io_base;
>> +    uart->vuart.size = uart->io_size;
>> +    uart->vuart.data_off = UART_THR << uart->reg_shift;
>> +    uart->vuart.status_off = UART_LSR << uart->reg_shift;
>> +    uart->vuart.status = UART_LSR_THRE | UART_LSR_TEMT;
>> +
>> +    /*  Register with generic serial driver. */
> 
> Stray double blanks at the beginning of the comment.
>

Sorry, I will remove it.

>> +    serial_register_uart(uart - ns16550_com, &ns16550_driver, uart);
> 
> I guess it's fine this way, but with "uart = &ns16550_com[0]" above
> the construct looks more complicated than it needs to look.

Yes, I can change to use "SERHND_DTUART".
Thanks for you guidance!

Best Regards,
Wei

> 
> Jan
> 
> .
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      parent reply	other threads:[~2020-01-22  6:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21  3:44 [Xen-devel] [PATCH v2] ns16550: Add ACPI support for ARM only Wei Xu
2020-01-21 11:13 ` Jan Beulich
2020-01-21 11:16   ` Julien Grall
2020-01-21 11:25     ` Jan Beulich
2020-01-21 11:44       ` Julien Grall
2020-01-22  6:42   ` Wei Xu [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=5E27EEE2.2060402@hisilicon.com \
    --to=xuwei5@hisilicon.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linuxarm@huawei.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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.