From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Aleksey Makarov <aleksey.makarov@linaro.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
Graeme Gregory <graeme.gregory@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Shannon Zhao <shannon.zhao@linaro.org>,
Vladimir Zapolskiy <vz@mleia.com>, Len Brown <lenb@kernel.org>
Subject: Re: [PATCH v5 2/2] ACPI: amba bus probing support
Date: Mon, 11 Jan 2016 15:27:32 +0000 [thread overview]
Message-ID: <20160111152732.GU19062@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAHp75Vew8HMMrc2vdKbSVuB2reOCrwZZg3-a4nBUyfiQ=c0Y4A@mail.gmail.com>
On Mon, Jan 11, 2016 at 05:13:20PM +0200, Andy Shevchenko wrote:
> On Mon, Jan 11, 2016 at 3:26 PM, Aleksey Makarov
> <aleksey.makarov@linaro.org> wrote:
> > From: Graeme Gregory <graeme.gregory@linaro.org>
> >
> > On ARM64 some devices use the AMBA device and not the platform bus for
> > probing so add support for this. Uses a dummy clock for apb_pclk as ACPI
> > does not have a suitable clock representation and to keep the core
> > AMBA bus code unchanged between probing methods.
> >
>
> My comments below.
>
> > +++ b/drivers/acpi/acpi_amba.c
> > @@ -0,0 +1,122 @@
> > +
> > +/*
> > + * ACPI support for platform bus type.
> > + *
> > + * Copyright (C) 2015, Linaro Ltd
> > + * Author: Graeme Gregory <graeme.gregory@linaro.org>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/acpi.h>
> > +#include <linux/amba/bus.h>
> > +#include <linux/clkdev.h>
> > +#include <linux/clk-provider.h>
> > +#include <linux/device.h>
> > +#include <linux/err.h>
> > +#include <linux/ioport.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +
> > +#include "internal.h"
> > +
> > +static const struct acpi_device_id amba_id_list[] = {
> > + {"ARMH0061", 0}, /* PL061 GPIO Device */
> > + {"", 0},
> > +};
> > +
> > +static void amba_register_dummy_clk(void)
> > +{
> > + static struct clk *amba_dummy_clk;
> > +
> > + /* If clock already registered */
> > + if (amba_dummy_clk)
> > + return;
> > +
> > + amba_dummy_clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL,
> > + CLK_IS_ROOT, 0);
> > + clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL);
> > +}
> > +
> > +static int amba_handler_attach(struct acpi_device *adev,
> > + const struct acpi_device_id *id)
> > +{
> > + struct amba_device *dev;
> > + struct resource_entry *rentry;
> > + struct list_head resource_list;
> > + bool address_found = false;
> > + int irq_no = 0;
> > + int ret;
> > +
> > + /* If the ACPI node already has a physical device attached, skip it. */
> > + if (adev->physical_node_count)
> > + return 0;
> > +
> > + dev = amba_device_alloc(dev_name(&adev->dev), 0, 0);
> > + if (!dev) {
> > + dev_err(&adev->dev, "%s(): amba_device_alloc() failed\n",
> > + __func__);
> > + return -ENOMEM;
> > + }
> > +
> > + INIT_LIST_HEAD(&resource_list);
> > + ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
> > + if (ret < 0)
> > + goto err_free;
> > +
> > + list_for_each_entry(rentry, &resource_list, node) {
> > + switch (resource_type(rentry->res)) {
> > + case IORESOURCE_MEM:
> > + if (!address_found) {
> > + dev->res = *rentry->res;
>
> dev->res is 0 before this one, right? Could you use this fact instead
> of address_found flag?
amba_device_alloc() zero-initialises everything. However, dev->res is
a struct resource, and I'd prefer _this_ method that the OT is using
to testing some random part of struct resource.
> > + address_found = true;
> > + }
> > + break;
> > + case IORESOURCE_IRQ:
> > + if (irq_no < AMBA_NR_IRQS)
> > + dev->irq[irq_no++] = rentry->res->start;
> > + break;
> > + default:
> > + dev_warn(&adev->dev, "Invalid resource\n");
>
> Why? Isn't possible to have other resources for the devices?
AMBA primecell devices have one memory region, and a number of
interrupts. Other resource types don't make sense.
> > + break;
> > + }
> > + }
> > +
> > + acpi_dev_free_resource_list(&resource_list);
> > +
> > + /*
> > + * If the ACPI node has a parent and that parent has a physical device
> > + * attached to it, that physical device should be the parent of
> > + * the amba device we are about to create.
> > + */
> > + if (adev->parent)
> > + dev->dev.parent = acpi_get_first_physical_node(adev->parent);
> > +
> > + ACPI_COMPANION_SET(&dev->dev, adev);
> > +
> > + ret = amba_device_add(dev, &iomem_resource);
> > + if (ret) {
>
> ret < 0?
>
> What to do if ret > 0? It will be considered as not error. Please,
> check what function returns and adjust this.
Non-zero is treated as an error by amba_device_add(). Doing otherwise
here puts it at odds to the outcome of that function. This code is fine.
--
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2016-01-11 15:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 13:26 [PATCH v5 0/2] ACPI: amba bus probing support Aleksey Makarov
2016-01-11 13:26 ` [PATCH v5 1/2] ACPI: introduce a function to find the first physical device Aleksey Makarov
2016-01-11 14:40 ` Andy Shevchenko
2016-01-11 14:45 ` Andy Shevchenko
2016-01-11 13:26 ` [PATCH v5 2/2] ACPI: amba bus probing support Aleksey Makarov
2016-01-11 15:05 ` Russell King - ARM Linux
2016-01-11 15:13 ` Andy Shevchenko
2016-01-11 15:27 ` Russell King - ARM Linux [this message]
2016-01-11 16:26 ` Andy Shevchenko
2016-01-11 17:24 ` Russell King - ARM Linux
2016-01-11 19:03 ` Andy Shevchenko
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=20160111152732.GU19062@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=aleksey.makarov@linaro.org \
--cc=andy.shevchenko@gmail.com \
--cc=graeme.gregory@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=shannon.zhao@linaro.org \
--cc=vz@mleia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox