linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Marek Vasut <marek.vasut@gmail.com>
Cc: Simon Horman <horms@verge.net.au>,
	linux-pci <linux-pci@vger.kernel.org>,
	Dien Pham <dien.pham.ry@rvc.renesas.com>,
	Hien Dang <hien.dang.eb@renesas.com>,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Phil Edworthy <phil.edworthy@renesas.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH V5] PCI: rcar: Use runtime PM to control controller clock
Date: Thu, 19 Apr 2018 12:00:21 +0200	[thread overview]
Message-ID: <CAMuHMdWpV-HN=ojjv_-PGDCe+Ud8AOPzJSk5fZXOG6tVC3mV+w@mail.gmail.com> (raw)
In-Reply-To: <cdc1b25a-e87d-144b-50c1-4abe31bcf5d0@gmail.com>

Hi Marek,

On Tue, Apr 10, 2018 at 6:17 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> On 04/10/2018 05:28 PM, Geert Uytterhoeven wrote:
>>>>> The pairing looks as follows:
>>>>>
>>>>> .- rcar_pcie_parse_request_of_pci_ranges()
>>>>> |  (pm_runtime_enable is here)
>>>>> | .- pm_runtime_get_sync()
>>>>> | | .- rcar_pcie_get_resources()
>>>>
>>>> rcar_pcie_get_resources() is called  while the device is runtime-enabled/resumed
>>>
>>> Because something may access the device, yes.
>>>
>>>>> | | |
>>>>> | | '- pm_runtime_put()
>>>>> | '- pm_runtime_disable() + pci_free_resource_list()
>>>>
>>>> pci_free_resource_list() is called while the device is runtime-disabled.
>>>
>>> Because nothing will access the device.
>>>
>>>>> '- pci_free_host_bridge()
>>>>>
>>>>> It looks symmetric to me ...
>>>>
>>>> rcar_pcie_get_resources() is called while the device is
>>>> runtime-enabled/resumed,
>>>> pci_free_resource_list() is called while the device is runtime-disabled.
>>>
>>> At this point, I think I'd rather see a diff of changes which you have
>>> in mind rather than this endless discussion. Can you provide one against
>>> this patch ?
>>
>> My final comment:
>>
>> If the steps during probing are A..Z, cleanup and removal should undo them
>> in reverse order (Z..A), unless there's a very good reason not to do so.
>
> I spent extra time going through the probe function and I just don't see
> how it is not done in the exact reverse, I checked every single goto
> statement in probe.
>
> I noticed this though:
>
>>>> rcar_pcie_get_resources() is called while the device is
>>>> runtime-enabled/resumed,
>>>> pci_free_resource_list() is called while the device is runtime-disabled.
>
> rcar_pcie_get_resources() is NOT a pair function for
> pci_free_resource_list() . rcar_pcie_parse_request_of_pci_ranges() is a
> pair function for pci_free_resource_list().
>
> rcar_pcie_parse_request_of_pci_ranges() calls
> of_pci_get_host_bridge_resources() internally, so every single function
> called after successful call of rcar_pcie_parse_request_of_pci_ranges()
> must call pci_free_resource_list().
>
> Both of_pci_get_host_bridge_resources() and pci_free_resource_list() are
> called with runtime PM disabled.
>
> The naming of the functions is confusing though.

You are right, your changes are correct, and the naming of these functions
is confusing. Perhaps it should be changed, to avoid misleading the (not so)
casual reviewer?

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

BTW, while diving deeper, I noticed a few other pre-existing issues in error
handling:

1. If anything fails after rcar_pcie_get_resources(), the bus clock is never
   disabled,
2. The error path of rcar_pcie_enable_msi() does not call
   irq_dispose_mapping() before irq_domain_remove(),
3. If rcar_pcie_enable() fails, none of the setup done in
   rcar_pcie_enable_msi() is reverted.
   Apart from the IRQ domain handling in 2, that includes freeing msi->pages
   (should this be allocated using the DMA API?), and undoing the related HW
   setup, to prevent the HW from scribbling the former MSI page in the future.

Care to fix these, too?
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  parent reply	other threads:[~2018-04-19 10:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-08 13:09 [PATCH V5] PCI: rcar: Use runtime PM to control controller clock Marek Vasut
2018-04-09  8:07 ` Geert Uytterhoeven
2018-04-09  8:20   ` Marek Vasut
2018-04-09 11:41     ` Simon Horman
2018-04-09 11:47       ` Geert Uytterhoeven
2018-04-09 12:26         ` Simon Horman
2018-04-10 14:31           ` Marek Vasut
2018-04-10 14:42             ` Geert Uytterhoeven
2018-04-10 15:25               ` Marek Vasut
2018-04-10 15:28                 ` Geert Uytterhoeven
2018-04-10 16:17                   ` Marek Vasut
2018-04-13 12:48                     ` Simon Horman
2018-04-13 17:48                       ` Lorenzo Pieralisi
2018-05-01 10:55                       ` Lorenzo Pieralisi
2018-05-14 15:32                         ` Marek Vasut
2018-05-14 15:49                           ` Lorenzo Pieralisi
2018-05-21 11:08                             ` Marek Vasut
2018-05-21 13:03                               ` Lorenzo Pieralisi
2018-05-21 13:09                                 ` Marek Vasut
2018-04-19 10:00                     ` Geert Uytterhoeven [this message]
2018-05-21 12:57                       ` Marek Vasut

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='CAMuHMdWpV-HN=ojjv_-PGDCe+Ud8AOPzJSk5fZXOG6tVC3mV+w@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=dien.pham.ry@rvc.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=hien.dang.eb@renesas.com \
    --cc=horms@verge.net.au \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=marek.vasut@gmail.com \
    --cc=phil.edworthy@renesas.com \
    --cc=wsa@the-dreams.de \
    /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;
as well as URLs for NNTP newsgroup(s).