From: Yidong Zhang <yidong.zhang@amd.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
<linux-kernel@vger.kernel.org>, <linux-fpga@vger.kernel.org>,
<mdf@kernel.org>, <hao.wu@intel.com>, <yilun.xu@intel.com>
Cc: <lizhi.hou@amd.com>, DMG Karthik <Karthik.DMG@amd.com>,
Nishad Saraf <nishads@amd.com>,
Prapul Krishnamurthy <prapulk@amd.com>,
Hayden Laccabue <hayden.laccabue@amd.com>
Subject: Re: [PATCH V2 1/4] drivers/fpga/amd: Add new driver amd versal-pci
Date: Sun, 26 Jan 2025 11:56:17 -0800 [thread overview]
Message-ID: <b0a07e5a-fa0b-40fb-9d85-5f316f94a226@amd.com> (raw)
In-Reply-To: <d156bc11-3d8e-44a0-b311-b4b931c54a7c@wanadoo.fr>
On 1/26/25 02:12, Christophe JAILLET wrote:
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Le 10/12/2024 à 19:37, Yidong Zhang a écrit :
>> AMD Versal based PCIe card, including V70, is designed for AI inference
>> efficiency and is tuned for video analytics and natural language
>> processing
>> applications.
>
> ...
>
>> +static void versal_pci_uuid_parse(struct versal_pci_device *vdev,
>> uuid_t *uuid)
>> +{
>> + char str[UUID_STRING_LEN];
>> + u8 i, j;
>> +
>> + /* parse uuid into a valid uuid string format */
>> + for (i = 0, j = 0; i < strlen(vdev->fw_id) && i < sizeof(str);
>> i++) {
>
> Unneeded extra space in "i = 0"
Great catch! I will fix this.
>
> I think that the compiler already does it on its own, but the strlen
> could be computed before the for loop.
I will change the code.
>
>> + str[j++] = vdev->fw_id[i];
>> + if (j == 8 || j == 13 || j == 18 || j == 23)
>> + str[j++] = '-';
>> + }
>> +
>> + uuid_parse(str, uuid);
>> + vdev_info(vdev, "Interface uuid %pU", uuid);
>> +}
>> +
>> +static struct fpga_device *versal_pci_fpga_init(struct
>> versal_pci_device *vdev)
>> +{
>> + struct device *dev = &vdev->pdev->dev;
>> + struct fpga_manager_info info = { 0 };
>
> Is the { 0 } needed?
> Isn't the assigment below enough?
Right. I will remove the unnecessary { 0 }.
>
>> + struct fpga_device *fdev;
>> + int ret;
>> +
>> + fdev = devm_kzalloc(dev, sizeof(*fdev), GFP_KERNEL);
>> + if (!fdev)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + fdev->vdev = vdev;
>> +
>> + info = (struct fpga_manager_info) {
>> + .name = "AMD Versal FPGA Manager",
>> + .mops = &versal_pci_fpga_ops,
>> + .priv = fdev,
>> + };
>> +
>> + fdev->mgr = fpga_mgr_register_full(dev, &info);
>> + if (IS_ERR(fdev->mgr)) {
>> + ret = PTR_ERR(fdev->mgr);
>> + vdev_err(vdev, "Failed to register FPGA manager, err
>> %d", ret);
>> + return ERR_PTR(ret);
>> + }
>> +
>> + /* Place holder for rm_queue_get_fw_id(vdev->rdev) */
>> + versal_pci_uuid_parse(vdev, &vdev->intf_uuid);
>> +
>> + return fdev;
>> +}
>
> ...
>
>> +static struct firmware_device *versal_pci_fw_upload_init(struct
>> versal_pci_device *vdev)
>> +{
>> + struct device *dev = &vdev->pdev->dev;
>> + struct firmware_device *fwdev;
>> + u32 devid;
>> +
>> + fwdev = devm_kzalloc(dev, sizeof(*fwdev), GFP_KERNEL);
>> + if (!fwdev)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + devid = versal_pci_devid(vdev);
>> + fwdev->name = kasprintf(GFP_KERNEL, "%s%x", DRV_NAME, devid);
>
> Why is fwdev managed, and not fwdev->name?
> It looks ok as-is, but using devm_kasprintf() would save a few lines of
> code.
I will change the code. Great suggestion.
>
>> + if (!fwdev->name)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + fwdev->fw = firmware_upload_register(THIS_MODULE, dev, fwdev->name,
>> + &versal_pci_fw_ops, fwdev);
>> + if (IS_ERR(fwdev->fw)) {
>> + kfree(fwdev->name);
>> + return ERR_CAST(fwdev->fw);
>> + }
>> +
>> + fwdev->vdev = vdev;
>> +
>> + return fwdev;
>> +}
>
> ...
>
>> +static int versal_pci_probe(struct pci_dev *pdev, const struct
>> pci_device_id *pdev_id)
>> +{
>> + struct versal_pci_device *vdev;
>> + int ret;
>> +
>> + vdev = devm_kzalloc(&pdev->dev, sizeof(*vdev), GFP_KERNEL);
>> + if (!vdev)
>> + return -ENOMEM;
>> +
>> + pci_set_drvdata(pdev, vdev);
>> + vdev->pdev = pdev;
>> +
>> + ret = pcim_enable_device(pdev);
>> + if (ret) {
>> + vdev_err(vdev, "Failed to enable device %d", ret);
>> + return ret;
>> + }
>> +
>> + vdev->io_regs = pcim_iomap_region(vdev->pdev, MGMT_BAR, DRV_NAME);
>> + if (IS_ERR(vdev->io_regs)) {
>> + vdev_err(vdev, "Failed to map RM shared memory BAR%d",
>> MGMT_BAR);
>> + return PTR_ERR(vdev->io_regs);
>> + }
>> +
>> + ret = versal_pci_device_setup(vdev);
>> + if (ret) {
>> + vdev_err(vdev, "Failed to setup Versal device %d", ret);
>> + return ret;
>> + }
>> +
>> + vdev_dbg(vdev, "Successfully probed %s driver!", DRV_NAME);
>
> Usually, such debug messages are not needed.
> No strong opinion about it.
I will remove this. The dbg only enable in the debug kernel, but this
line isn't necessary. I will fix it.
>
>> + return 0;
>> +}
>
> ...
>
> CJ
next prev parent reply other threads:[~2025-01-26 19:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 18:37 [PATCH V2 0/4] Add versal-pci driver Yidong Zhang
2024-12-10 18:37 ` [PATCH V2 1/4] drivers/fpga/amd: Add new driver amd versal-pci Yidong Zhang
2025-01-26 9:24 ` Xu Yilun
2025-01-26 19:50 ` Yidong Zhang
2025-01-26 10:12 ` Christophe JAILLET
2025-01-26 19:56 ` Yidong Zhang [this message]
2025-01-26 10:16 ` Christophe JAILLET
2025-01-26 10:32 ` Xu Yilun
2025-01-26 19:46 ` Yidong Zhang
2025-02-06 4:15 ` Xu Yilun
2025-02-06 4:31 ` Yidong Zhang
2025-02-07 2:19 ` Xu Yilun
2025-02-07 3:16 ` Yidong Zhang
2025-02-07 4:40 ` Xu Yilun
2025-02-10 11:33 ` Yidong Zhang
2025-02-11 9:09 ` Xu Yilun
2025-02-11 11:31 ` Yidong Zhang
2025-03-01 8:20 ` Xu Yilun
2025-03-01 19:03 ` Yidong Zhang
2025-03-03 7:57 ` Xu Yilun
2025-03-03 17:00 ` Yidong Zhang
2024-12-10 18:37 ` [PATCH V2 2/4] drivers/fpga/amd: Add communication channel Yidong Zhang
2025-01-26 10:19 ` Christophe JAILLET
2025-01-26 19:57 ` Yidong Zhang
2024-12-10 18:37 ` [PATCH V2 3/4] drivers/fpga/amd: Add remote queue Yidong Zhang
2025-01-26 10:24 ` Christophe JAILLET
2024-12-10 18:37 ` [PATCH V2 4/4] drivers/fpga/amd: Add load xclbin and load firmware Yidong Zhang
2025-01-26 9:27 ` [PATCH V2 0/4] Add versal-pci driver Xu Yilun
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=b0a07e5a-fa0b-40fb-9d85-5f316f94a226@amd.com \
--to=yidong.zhang@amd.com \
--cc=Karthik.DMG@amd.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=hao.wu@intel.com \
--cc=hayden.laccabue@amd.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=mdf@kernel.org \
--cc=nishads@amd.com \
--cc=prapulk@amd.com \
--cc=yilun.xu@intel.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.