[PATCH V2 01/10] accel/amdxdna: Add a new driver for AMD AI Engine

Lizhi Hou lizhi.hou at amd.com
Mon Aug 12 15:58:04 UTC 2024


On 8/9/24 08:24, Carl Vanderlip wrote:
> On 8/5/2024 10:39 AM, Lizhi Hou wrote:
> > +static int aie2_init(struct amdxdna_dev *xdna)
> > +{
> > +    struct pci_dev *pdev = to_pci_dev(xdna->ddev.dev);
> > +    struct amdxdna_dev_hdl *ndev;
> > +    struct psp_config psp_conf;
> > +    const struct firmware *fw;
> > +    void __iomem * const *tbl;
> > +    int i, bars, nvec, ret;
> > +
> > +    ndev = devm_kzalloc(&pdev->dev, sizeof(*ndev), GFP_KERNEL);
> > +    if (!ndev)
> > +        return -ENOMEM;
> > +
> > +    ndev->priv = xdna->dev_info->dev_priv;
> > +    ndev->xdna = xdna;
> > +
> > +    ret = request_firmware(&fw, ndev->priv->fw_path, &pdev->dev);
> > +    if (ret) {
> > +        XDNA_ERR(xdna, "failed to request_firmware %s, ret %d",
> > +             ndev->priv->fw_path, ret);
> > +        return ret;
> > +    }
> > +
> > +    ret = pcim_enable_device(pdev);
>
>
> Does request_firmware need to be the first thing here? Its not used 
> until the end of init. Likewise, fw image is copied in *_create, but 
> then not released until after *_hw_start; could release_firmware more 
> closely wrap where it is used? I could see it being checked first 
> because if the fw isn't there, what's the point, but that could be 
> said about any of the other resources here.
request_firmware() will failed if user forget to install the firmware 
package. Other initialization calls (e.g. enable device, etc) are very 
unlikely to happen.  That is why request_firmware() is checked first. 
This will only hold the memory before the function exits. I think it is 
very short period and should be ok.
>
> On 8/5/2024 10:39 AM, Lizhi Hou wrote:
> > +enum aie2_smu_reg_idx {
> > +    SMU_CMD_REG = 0,
> > +    SMU_ARG_REG,
> > +    SMU_INTR_REG,
> > +    SMU_RESP_REG,
> > +    SMU_OUT_REG,
> > +    SMU_MAX_REGS /* Kepp this at the end */
> > +};
>
> *Keep

Thanks. I will fix this.


Lizhi

>
>
> -Carl V.
>
> PS Sorry for double email Lizhi, forgot to send to list.


More information about the dri-devel mailing list