From: jeffy <jeffy.chen@rock-chips.com>
To: Shawn Lin <shawn.lin@rock-chips.com>,
Brian Norris <briannorris@chromium.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Rob Herring <robh@kernel.org>,
Kishon Vijay Abraham I <kishon@ti.com>,
Heiko Stuebner <heiko@sntech.de>,
linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org,
devicetree@vger.kernel.org
Subject: Re: [RFC PATCH 3/6] phy: rockcip-pcie: reconstruct driver to support per-lane PHYs
Date: Fri, 14 Jul 2017 15:03:38 +0800 [thread overview]
Message-ID: <59686CCA.60804@rock-chips.com> (raw)
In-Reply-To: <a0b188ea-71e2-8c8a-999d-754a35891ab9@rock-chips.com>
Hi Shawn,
On 07/14/2017 02:33 PM, Shawn Lin wrote:
>>
>>> + return rk_phy->phys[0];
>>> + }
>>> +}
>>> +
>>> static inline void phy_wr_cfg(struct rockchip_pcie_phy *rk_phy,
>>> u32 addr, u32 data)
>>> {
>>> @@ -114,20 +139,55 @@ static inline u32 phy_rd_cfg(struct
>>> rockchip_pcie_phy *rk_phy,
>>> return val;
>>> }
>>> -static int rockchip_pcie_phy_power_off(struct phy *phy)
>>> +static int rockchip_pcie_phy_common_power_off(struct phy *phy)
>>> {
>>> struct rockchip_pcie_phy *rk_phy = phy_get_drvdata(phy);
>>> int err = 0;
>>> + if (WARN_ON(!rk_phy->pwr_cnt))
>>> + return -EINVAL;
>>> +
>>> + if (rk_phy->pwr_cnt > 0)
>>
>> This should be:
>>
>> if (--rk_phy->pwr_cnt)
>>
>> Also, you technically might need locking, now that multiple phys (which
>> each only have their own independent mutex) are accessing the same
>> refcount. Or maybe just make this an atomic variable.
>
> Good catch!
Sounds like we need something similar to phy-core.c's power_count and
init_count.
>>> +
>>> return 0;
>>> }
>>> +#define DECLARE_PHY_POWER_OFF_PER_LANE(id) \
>>> +static int rockchip_pcie_lane##id##_phy_power_off(struct phy *phy) \
>>
>> What? All this macro magic (and duplicate generated functions) should
>> not be necessary. You just need some per-phy data that keeps the index.
>
> I can't quite follow yours here. The only argument passing on to
> the PHY APIs is 'struct phy *phy', and how could you trace the index
> from it? The caller should save phy instead of 'rockchip_pcie_phy', in
> which the per-phy data should be.
>
> Or could you kindly show me some example here:)
>
Maybe add a struct rockchip_pcie_phy_data for each phy, contains their
index and a pointer to the common struct rockchip_pcie_phy?
WARNING: multiple messages have this Message-ID (diff)
From: jeffy <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
To: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
Brian Norris
<briannorris-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Bjorn Helgaas <bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>,
Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC PATCH 3/6] phy: rockcip-pcie: reconstruct driver to support per-lane PHYs
Date: Fri, 14 Jul 2017 15:03:38 +0800 [thread overview]
Message-ID: <59686CCA.60804@rock-chips.com> (raw)
In-Reply-To: <a0b188ea-71e2-8c8a-999d-754a35891ab9-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Hi Shawn,
On 07/14/2017 02:33 PM, Shawn Lin wrote:
>>
>>> + return rk_phy->phys[0];
>>> + }
>>> +}
>>> +
>>> static inline void phy_wr_cfg(struct rockchip_pcie_phy *rk_phy,
>>> u32 addr, u32 data)
>>> {
>>> @@ -114,20 +139,55 @@ static inline u32 phy_rd_cfg(struct
>>> rockchip_pcie_phy *rk_phy,
>>> return val;
>>> }
>>> -static int rockchip_pcie_phy_power_off(struct phy *phy)
>>> +static int rockchip_pcie_phy_common_power_off(struct phy *phy)
>>> {
>>> struct rockchip_pcie_phy *rk_phy = phy_get_drvdata(phy);
>>> int err = 0;
>>> + if (WARN_ON(!rk_phy->pwr_cnt))
>>> + return -EINVAL;
>>> +
>>> + if (rk_phy->pwr_cnt > 0)
>>
>> This should be:
>>
>> if (--rk_phy->pwr_cnt)
>>
>> Also, you technically might need locking, now that multiple phys (which
>> each only have their own independent mutex) are accessing the same
>> refcount. Or maybe just make this an atomic variable.
>
> Good catch!
Sounds like we need something similar to phy-core.c's power_count and
init_count.
>>> +
>>> return 0;
>>> }
>>> +#define DECLARE_PHY_POWER_OFF_PER_LANE(id) \
>>> +static int rockchip_pcie_lane##id##_phy_power_off(struct phy *phy) \
>>
>> What? All this macro magic (and duplicate generated functions) should
>> not be necessary. You just need some per-phy data that keeps the index.
>
> I can't quite follow yours here. The only argument passing on to
> the PHY APIs is 'struct phy *phy', and how could you trace the index
> from it? The caller should save phy instead of 'rockchip_pcie_phy', in
> which the per-phy data should be.
>
> Or could you kindly show me some example here:)
>
Maybe add a struct rockchip_pcie_phy_data for each phy, contains their
index and a pointer to the common struct rockchip_pcie_phy?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-07-14 7:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 3:48 [RFC PATCH 0/6] Reconstruct rockchip's PCIe and PCIe-PHY driver for per-lane PHY model Shawn Lin
2017-07-14 3:48 ` Shawn Lin
2017-07-14 3:48 ` [RFC PATCH 1/6] PCI: rockchip: split out rockchip_pcie_get_phys Shawn Lin
2017-07-14 3:48 ` Shawn Lin
2017-07-14 3:52 ` [RFC PATCH 2/6] PCI: rockchip: introduce per-lanes PHYs support Shawn Lin
2017-07-14 3:52 ` [RFC PATCH 3/6] phy: rockcip-pcie: reconstruct driver to support per-lane PHYs Shawn Lin
2017-07-14 3:52 ` Shawn Lin
2017-07-14 5:10 ` Brian Norris
2017-07-14 5:10 ` Brian Norris
2017-07-14 6:33 ` Shawn Lin
2017-07-14 7:03 ` jeffy [this message]
2017-07-14 7:03 ` jeffy
2017-07-14 9:14 ` Shawn Lin
2017-07-14 9:14 ` Shawn Lin
2017-07-14 7:19 ` jeffy
2017-07-14 7:19 ` jeffy
2017-07-14 3:52 ` [RFC PATCH 4/6] PCI: rockchip: idle the inactive PHY(s) Shawn Lin
2017-07-14 3:52 ` Shawn Lin
2017-07-14 3:52 ` [RFC PATCH 5/6] arm64: dts: rockchip: convert PCIe to use per-lane PHYs for rk3339-evb Shawn Lin
2017-07-14 3:52 ` Shawn Lin
2017-07-14 3:52 ` [RFC PATCH 6/6] dt-bindings: PCI: rockchip: convert to use per-lane PHY model Shawn Lin
2017-07-14 3:52 ` Shawn Lin
2017-07-14 20:47 ` Brian Norris
2017-07-14 20:47 ` Brian Norris
2017-07-17 3:25 ` Shawn Lin
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=59686CCA.60804@rock-chips.com \
--to=jeffy.chen@rock-chips.com \
--cc=bhelgaas@google.com \
--cc=briannorris@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=kishon@ti.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.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 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.