X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcommon%2Fcnxk%2Froc_dev.c;h=9a869698c4cdbaa037c004e6e53c823b0ebed1d2;hb=b934e65b01357844f80a109106e50ce4aaece486;hp=ce6980cbe492f6467a3d4c41831447b46d3d3816;hpb=f11873922a3a8a846042251e75640b59682fee89;p=dpdk.git diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index ce6980cbe4..9a869698c4 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -57,7 +57,7 @@ pf_af_sync_msg(struct dev *dev, struct mbox_msghdr **rsp) struct mbox *mbox = dev->mbox; struct mbox_dev *mdev = &mbox->dev[0]; - volatile uint64_t int_status; + volatile uint64_t int_status = 0; struct mbox_msghdr *msghdr; uint64_t off; int rc = 0; @@ -152,6 +152,11 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg) /* Reserve PF/VF mbox message */ size = PLT_ALIGN(size, MBOX_MSG_ALIGN); rsp = mbox_alloc_msg(&dev->mbox_vfpf, vf, size); + if (!rsp) { + plt_err("Failed to reserve VF%d message", vf); + continue; + } + mbox_rsp_init(msg->id, rsp); /* Copy message from AF<->PF mbox to PF<->VF mbox */ @@ -236,6 +241,12 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf) BIT_ULL(vf % max_bits); rsp = (struct ready_msg_rsp *)mbox_alloc_msg( mbox, vf, sizeof(*rsp)); + if (!rsp) { + plt_err("Failed to alloc VF%d READY message", + vf); + continue; + } + mbox_rsp_init(msg->id, rsp); /* PF/VF function ID */ @@ -641,7 +652,7 @@ roc_af_pf_mbox_irq(void *param) static int mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev) { - struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; + struct plt_intr_handle *intr_handle = pci_dev->intr_handle; int i, rc; /* HW clear irq */ @@ -691,7 +702,7 @@ mbox_register_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev) static int mbox_register_vf_irq(struct plt_pci_device *pci_dev, struct dev *dev) { - struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; + struct plt_intr_handle *intr_handle = pci_dev->intr_handle; int rc; /* Clear irq */ @@ -724,7 +735,7 @@ mbox_register_irq(struct plt_pci_device *pci_dev, struct dev *dev) static void mbox_unregister_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev) { - struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; + struct plt_intr_handle *intr_handle = pci_dev->intr_handle; int i; /* HW clear irq */ @@ -755,7 +766,7 @@ mbox_unregister_pf_irq(struct plt_pci_device *pci_dev, struct dev *dev) static void mbox_unregister_vf_irq(struct plt_pci_device *pci_dev, struct dev *dev) { - struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; + struct plt_intr_handle *intr_handle = pci_dev->intr_handle; /* Clear irq */ plt_write64(~0ull, dev->bar2 + RVU_VF_INT_ENA_W1C); @@ -839,7 +850,7 @@ roc_pf_vf_flr_irq(void *param) static int vf_flr_unregister_irqs(struct plt_pci_device *pci_dev, struct dev *dev) { - struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; + struct plt_intr_handle *intr_handle = pci_dev->intr_handle; int i; plt_base_dbg("Unregister VF FLR interrupts for %s", pci_dev->name); @@ -860,7 +871,7 @@ vf_flr_unregister_irqs(struct plt_pci_device *pci_dev, struct dev *dev) static int vf_flr_register_irqs(struct plt_pci_device *pci_dev, struct dev *dev) { - struct plt_intr_handle *handle = &pci_dev->intr_handle; + struct plt_intr_handle *handle = pci_dev->intr_handle; int i, rc; plt_base_dbg("Register VF FLR interrupts for %s", pci_dev->name); @@ -988,6 +999,9 @@ dev_setup_shared_lmt_region(struct mbox *mbox, bool valid_iova, uint64_t iova) struct lmtst_tbl_setup_req *req; req = mbox_alloc_msg_lmtst_tbl_setup(mbox); + if (!req) + return -ENOSPC; + /* This pcifunc is defined with primary pcifunc whose LMT address * will be shared. If call contains valid IOVA, following pcifunc * field is of no use. @@ -1061,6 +1075,11 @@ dev_lmt_setup(struct dev *dev) */ if (!dev->disable_shared_lmt) { idev = idev_get_cfg(); + if (!idev) { + errno = EFAULT; + goto free; + } + if (!__atomic_load_n(&idev->lmt_pf_func, __ATOMIC_ACQUIRE)) { idev->lmt_base_addr = dev->lmt_base; idev->lmt_pf_func = dev->pf_func; @@ -1211,7 +1230,7 @@ error: int dev_fini(struct dev *dev, struct plt_pci_device *pci_dev) { - struct plt_intr_handle *intr_handle = &pci_dev->intr_handle; + struct plt_intr_handle *intr_handle = pci_dev->intr_handle; struct mbox *mbox; /* Check if this dev hosts npalf and has 1+ refs */