Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Jie Gan <jie.gan@oss.qualcomm.com>
To: Jie Luo <quic_luoj@quicinc.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Lei Wei <quic_leiwei@quicinc.com>,
	Suruchi Agarwal <quic_suruchia@quicinc.com>,
	Pavithra R <quic_pavir@quicinc.com>,
	Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-hardening@vger.kernel.org,
	quic_kkumarcs@quicinc.com, quic_linchen@quicinc.com,
	srinivas.kandagatla@linaro.org, bartosz.golaszewski@linaro.org,
	john@phrozen.org
Subject: Re: [PATCH net-next v3 03/14] net: ethernet: qualcomm: Add PPE driver for IPQ9574 SoC
Date: Wed, 12 Feb 2025 09:58:53 +0800	[thread overview]
Message-ID: <1882f5dd-4e46-40b9-977d-dc3570975738@oss.qualcomm.com> (raw)
In-Reply-To: <63f1d25c-087a-46dd-9053-60334a0095d5@quicinc.com>



On 2/11/2025 9:58 PM, Jie Luo wrote:
> 
> 
> On 2/10/2025 10:12 AM, Jie Gan wrote:
>>> +static int ppe_clock_init_and_reset(struct ppe_device *ppe_dev)
>>> +{
>>> +    unsigned long ppe_rate = ppe_dev->clk_rate;
>>> +    struct device *dev = ppe_dev->dev;
>>> +    struct reset_control *rstc;
>>> +    struct clk_bulk_data *clks;
>>> +    struct clk *clk;
>>> +    int ret, i;
>>> +
>>> +    for (i = 0; i < ppe_dev->num_icc_paths; i++) {
>>> +        ppe_dev->icc_paths[i].name = ppe_icc_data[i].name;
>>> +        ppe_dev->icc_paths[i].avg_bw = ppe_icc_data[i].avg_bw ? :
>>> +                           Bps_to_icc(ppe_rate);
>> it's ppe_dev->icc_paths[i].avg_bw = ppe_icc_data[i].avg_bw ? 
>> ppe_icc_data[i].avg_bw : Bps_to_icc(ppe_rate);  ?
> 
> I feel the above used notation is also fine for readability, and is
> shorter and simpler.
> 
>>
>>
>>> +        ppe_dev->icc_paths[i].peak_bw = ppe_icc_data[i].peak_bw ? :
>>> +                        Bps_to_icc(ppe_rate);
>> Same with previous one?
> 
> Same response as for the previous comment is applicable here as well.
> 
>>
>>> +    }
>>> +
>>> +    ret = devm_of_icc_bulk_get(dev, ppe_dev->num_icc_paths,
>>> +                   ppe_dev->icc_paths);
>>> +    if (ret)
>>> +        return ret;
>>> +
>>> +    ret = icc_bulk_set_bw(ppe_dev->num_icc_paths, ppe_dev->icc_paths);
>>> +    if (ret)
>>> +        return ret;
>>> +
>>> +    /* The PPE clocks have a common parent clock. Setting the clock
>> Should be:
>> /*
>>   * The PPE clocks have a common parent clock. Setting the clock
>>   * rate of "ppe" ensures the clock rate of all PPE clocks is
>>   * configured to the same rate.
>>   */
>>
> 
> I think for drivers/net, the above format follows the recommended
> commenting style. Pls see: https://www.kernel.org/doc/html/v6.10/
> process/coding-style.html
> 
> For files in net/ and drivers/net/ the preferred style for long
> (multi-line) comments is a little different.
> 
>> BTW, it's better wrapped with ~75 characters per line.
> 
> Yes, the comments should be wrapped to ~75 characters.
> 
>>
>>> +     * rate of "ppe" ensures the clock rate of all PPE clocks is
>>> +     * configured to the same rate.
>>> +     */
>>> +    clk = devm_clk_get(dev, "ppe");
>>> +    if (IS_ERR(clk))
>>> +        return PTR_ERR(clk);
>>> +
>>> +    ret = clk_set_rate(clk, ppe_rate);
>>> +    if (ret)
>>> +        return ret;
>>> +
>>> +    ret = devm_clk_bulk_get_all_enabled(dev, &clks);
>>> +    if (ret < 0)
>>> +        return ret;
>>> +
>>> +    /* Reset the PPE. */
>>> +    rstc = devm_reset_control_get_exclusive(dev, NULL);
>>> +    if (IS_ERR(rstc))
>>> +        return PTR_ERR(rstc);
>>> +
>>> +    ret = reset_control_assert(rstc);
>>> +    if (ret)
>>> +        return ret;
>>> +
>>> +    /* The delay 10 ms of assert is necessary for resetting PPE. */
>>> +    usleep_range(10000, 11000);
>>> +
>>> +    return reset_control_deassert(rstc);
>>> +}
>>> +
>>> +static int qcom_ppe_probe(struct platform_device *pdev)
>>> +{
>>> +    struct device *dev = &pdev->dev;
>>> +    struct ppe_device *ppe_dev;
>>> +    void __iomem *base;
>>> +    int ret, num_icc;
>> I think it's better with:
>>      int num_icc = ARRAY_SIZE(ppe_icc_data);
> 
> This will impact the “reverse xmas tree” rule for local variable
> definitions. Also, the num_icc will vary as per the different SoC,
> so we will need to initialize the num_icc in a separate statement.
> 
> (Note: This driver will be extended to support different SoC in
> the future.)
> 
Got your point here. So there may have multiple definitions like 
ppe_icc_data here, right? But the num_icc here is hardcoded.
Maybe it would be better defined within the ppe_icc_data, if possible?
Then just directly use ppe_icc_data->num_icc?

Never mind, that's just my thought on the flexibility.

Jie
>>
>>> +
>>> +    num_icc = ARRAY_SIZE(ppe_icc_data);
>>> +    ppe_dev = devm_kzalloc(dev, struct_size(ppe_dev, icc_paths, 
>>> num_icc),
>>> +                   GFP_KERNEL);
>>> +    if (!ppe_dev)
>>> +        return -ENOMEM;
>>> +
>>> +    base = devm_platform_ioremap_resource(pdev, 0);
>>> +    if (IS_ERR(base))
>>> +        return dev_err_probe(dev, PTR_ERR(base), "PPE ioremap 
>>> failed\n");
>>> +
>>> +    ppe_dev->regmap = devm_regmap_init_mmio(dev, base, 
>>> &regmap_config_ipq9574);
>>> +    if (IS_ERR(ppe_dev->regmap))
>>> +        return dev_err_probe(dev, PTR_ERR(ppe_dev->regmap),
>>> +                     "PPE initialize regmap failed\n");
>>> +    ppe_dev->dev = dev;
>>> +    ppe_dev->clk_rate = PPE_CLK_RATE;
>>> +    ppe_dev->num_ports = PPE_PORT_MAX;
>>> +    ppe_dev->num_icc_paths = num_icc;
>>> +
>>> +    ret = ppe_clock_init_and_reset(ppe_dev);
>>> +    if (ret)
>>> +        return dev_err_probe(dev, ret, "PPE clock config failed\n");
>>> +
>>> +    platform_set_drvdata(pdev, ppe_dev);
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static const struct of_device_id qcom_ppe_of_match[] = {
>>> +    { .compatible = "qcom,ipq9574-ppe" },
>>> +    {}
>>> +};
>>> +MODULE_DEVICE_TABLE(of, qcom_ppe_of_match);
>>> +
>>> +static struct platform_driver qcom_ppe_driver = {
>>> +    .driver = {
>>> +        .name = "qcom_ppe",
>>> +        .of_match_table = qcom_ppe_of_match,
>>> +    },
>>> +    .probe    = qcom_ppe_probe,
>>> +};
>>> +module_platform_driver(qcom_ppe_driver);
>>> +
>>> +MODULE_LICENSE("GPL");
>>> +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. IPQ PPE driver");
>>> diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe.h b/drivers/net/ 
>>> ethernet/qualcomm/ppe/ppe.h
>>> new file mode 100644
>>> index 000000000000..cc6767b7c2b8
>>> --- /dev/null
>>> +++ b/drivers/net/ethernet/qualcomm/ppe/ppe.h
>>> @@ -0,0 +1,36 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-only
>>> + *
>>> + * Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights 
>>> reserved.
>>> + */
>>> +
>>> +#ifndef __PPE_H__
>>> +#define __PPE_H__
>>> +
>>> +#include <linux/compiler.h>
>>> +#include <linux/interconnect.h>
>>> +
>>> +struct device;
>> #include <linux/device.h> ?
>>
>>> +struct regmap;
>> Same with previous one, include it's header file?
> 
> The driver only need to reference these structures but don't
> need their full definitions. So it should be fine to declare
> the existence of these structures here.
> 
>>
>>> +
>>> +/**
>>> + * struct ppe_device - PPE device private data.
>>> + * @dev: PPE device structure.
>>> + * @regmap: PPE register map.
>>> + * @clk_rate: PPE clock rate.
>>> + * @num_ports: Number of PPE ports.
>>> + * @num_icc_paths: Number of interconnect paths.
>>> + * @icc_paths: Interconnect path array.
>>> + *
>>> + * PPE device is the instance of PPE hardware, which is used to
>>> + * configure PPE packet process modules such as BM (buffer management),
>>> + * QM (queue management), and scheduler.
>>> + */
>>> +struct ppe_device {
>>> +    struct device *dev;
>>> +    struct regmap *regmap;
>>> +    unsigned long clk_rate;
>>> +    unsigned int num_ports;
>>> +    unsigned int num_icc_paths;
>>> +    struct icc_bulk_data icc_paths[] __counted_by(num_icc_paths);
>>> +};
>>> +#endif
>>>
>>
>> Thanks,
>> Jie
> 


  reply	other threads:[~2025-02-12  1:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-09 14:29 [PATCH net-next v3 00/14] Add PPE driver for Qualcomm IPQ9574 SoC Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 01/14] dt-bindings: net: Add PPE " Luo Jie
2025-02-10  2:47   ` Jie Gan
2025-02-11 14:02     ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 02/14] docs: networking: Add PPE driver documentation " Luo Jie
2025-02-10  2:15   ` Bagas Sanjaya
2025-02-11 12:36     ` Lei Wei
2025-02-09 14:29 ` [PATCH net-next v3 03/14] net: ethernet: qualcomm: Add PPE driver for " Luo Jie
2025-02-10  2:12   ` Jie Gan
2025-02-11 13:04     ` Andrew Lunn
2025-02-12  1:49       ` Jie Gan
2025-02-11 13:58     ` Jie Luo
2025-02-12  1:58       ` Jie Gan [this message]
2025-02-14  6:09         ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 04/14] net: ethernet: qualcomm: Initialize PPE buffer management for IPQ9574 Luo Jie
2025-02-11 13:14   ` Andrew Lunn
2025-02-19 13:00     ` Jie Luo
2025-02-11 13:22   ` Andrew Lunn
2025-02-20 14:38     ` Jie Luo
2025-02-20 15:09       ` Andrew Lunn
2025-03-06 10:01         ` Jie Luo
2025-03-06 15:29           ` Andrew Lunn
2025-03-11 10:44             ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 05/14] net: ethernet: qualcomm: Initialize PPE queue " Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 06/14] net: ethernet: qualcomm: Initialize the PPE scheduler settings Luo Jie
2025-02-11 13:32   ` Andrew Lunn
2025-02-20 14:50     ` Jie Luo
2025-02-20 15:12       ` Andrew Lunn
2025-02-28 15:24         ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 07/14] net: ethernet: qualcomm: Initialize PPE queue settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 08/14] net: ethernet: qualcomm: Initialize PPE service code settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 09/14] net: ethernet: qualcomm: Initialize PPE port control settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 10/14] net: ethernet: qualcomm: Initialize PPE RSS hash settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 11/14] net: ethernet: qualcomm: Initialize PPE queue to Ethernet DMA ring mapping Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 12/14] net: ethernet: qualcomm: Initialize PPE L2 bridge settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 13/14] net: ethernet: qualcomm: Add PPE debugfs support for PPE counters Luo Jie
2025-02-11 13:55   ` Andrew Lunn
2025-02-14  7:53     ` Jie Luo
2025-02-14 14:02       ` Andrew Lunn
2025-02-18 11:16         ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 14/14] MAINTAINERS: Add maintainer for Qualcomm PPE driver Luo Jie

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=1882f5dd-4e46-40b9-977d-dc3570975738@oss.qualcomm.com \
    --to=jie.gan@oss.qualcomm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=john@phrozen.org \
    --cc=kees@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=quic_kkumarcs@quicinc.com \
    --cc=quic_leiwei@quicinc.com \
    --cc=quic_linchen@quicinc.com \
    --cc=quic_luoj@quicinc.com \
    --cc=quic_pavir@quicinc.com \
    --cc=quic_suruchia@quicinc.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox