[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<MAUPR01MB1107294E89F312A26812B9FC4FE3AA@MAUPR01MB11072.INDPRD01.PROD.OUTLOOK.COM>
Date: Fri, 29 Aug 2025 08:12:50 +0800
From: Chen Wang <unicorn_wang@...look.com>
To: ALOK TIWARI <alok.a.tiwari@...cle.com>, Chen Wang <unicornxw@...il.com>,
kwilczynski@...nel.org, u.kleine-koenig@...libre.com, aou@...s.berkeley.edu,
alex@...ti.fr, arnd@...db.de, bwawrzyn@...co.com, bhelgaas@...gle.com,
conor+dt@...nel.org, 18255117159@....com, inochiama@...il.com,
kishon@...nel.org, krzk+dt@...nel.org, lpieralisi@...nel.org,
mani@...nel.org, palmer@...belt.com, paul.walmsley@...ive.com,
robh@...nel.org, s-vadapalli@...com, tglx@...utronix.de,
thomas.richard@...tlin.com, sycamoremoon376@...il.com,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org, linux-riscv@...ts.infradead.org,
sophgo@...ts.linux.dev, rabenda.cn@...il.com, chao.wei@...hgo.com,
xiaoguang.xing@...hgo.com, fengchun.li@...hgo.com
Subject: Re: [PATCH 3/5] PCI: sg2042: Add Sophgo SG2042 PCIe driver
On 8/28/2025 7:18 PM, ALOK TIWARI wrote:
>
>
> On 8/28/2025 7:47 AM, Chen Wang wrote:
>> From: Chen Wang <unicorn_wang@...look.com>
>>
[......]
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/of.h>
>> +#include <linux/pci.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pm_runtime.h>
>> +
>> +#include "pcie-cadence.h"
>> +
>> +/*
>> + * SG2042 only support 4-byte aligned access, so for the rootbus
>> (i.e. to read
>
> support -> supports
Nice catch!
>
>> + * the Root Port itself, read32 is required. For non-rootbus (i.e.
>> to read
>> + * the PCIe peripheral registers, supports 1/2/4 byte aligned
>> access, so
>> + * directly using read should be fine.
>> + *
>> + * The same is true for write.
> [clip]
>> +static int sg2042_pcie_probe(struct platform_device *pdev)
>> +{
>> + struct device *dev = &pdev->dev;
>> + struct pci_host_bridge *bridge;
>> + struct cdns_pcie *pcie;
>> + struct cdns_pcie_rc *rc;
>> + int ret;
>> +
>> + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
>> + if (!pcie)
>> + return -ENOMEM;
>> +
>> + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*rc));
>> + if (!bridge) {
>> + dev_err(dev, "Failed to alloc host bridge!\n");
>> + return -ENOMEM;
>> + }
>> +
>> + bridge->ops = &sg2042_pcie_host_ops;
>> +
>> + rc = pci_host_bridge_priv(bridge);
>> + pcie = &rc->pcie;
> First, pcie is allocated and then reassigned to &rc->pcie,
> which makes the initial allocation effectively leaked and unnecessary.
My fault.
Thanks,
Chen
[......]
>
> Thanks,
> Alok
Powered by blists - more mailing lists