On Thu, Sep 08, 2016 at 01:18:16 -0700, Yuval Shaia wrote: > On Wed, Sep 07, 2016 at 05:25:30PM +0000, Adit Ranadive wrote: > > > > + > > > > +static int pvrdma_poll_one(struct pvrdma_cq *cq, struct pvrdma_qp > > > **cur_qp, > > > > + struct ib_wc *wc) > > > > +{ > > > > + struct pvrdma_dev *dev = to_vdev(cq->ibcq.device); > > > > + int has_data; > > > > + unsigned int head; > > > > + bool tried = false; > > > > + struct pvrdma_cqe *cqe; > > > > + > > > > +retry: > > > > + has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx, > > > > + cq->ibcq.cqe, &head); > > > > + if (has_data == 0) { > > > > + u32 val; > > > > + > > > > + if (tried) > > > > + return -EAGAIN; > > > > + > > > > + /* Pass down POLL to give physical HCA a chance to poll. */ > > > > + val = cq->cq_handle | PVRDMA_UAR_CQ_POLL; > > > > + writel(cpu_to_le32(val), > > > > + dev->driver_uar.map + PVRDMA_UAR_CQ_OFFSET); > > > > + > > > > + tried = true; > > > > + goto retry; > > > > + } else if (has_data == PVRDMA_INVALID_IDX) { > > > > + /* Ring state could be corrupted. Treat as unrecoverable. */ > > > > + return -EINVAL; > > > > > > Please try your best not to return anything but 0 or -EAGAIN from > > > this function. > > > Returning -EINVAL will cause caller (pvrdma_poll_cq) to drop all > > > successive CQE in tn batch. > > > > This reason I want to return -EINVAL here is that its possible that > > the ring state is corrupted so any successive calls to poll_cq will likely not > give any valid data. > > If that means successive CQEs are dropped then that should be okay > > since we have no idea now which CQEs were consumed. > > In this case you should handle the problematic CQ in driver, ULPs are not built > to handle it. Ok, sounds reasonable. I understand Jason's concerns. Thanks for pointing me those links! I can return -EAGAIN here and add a dev warning to make sure we atleast log this condition. How would the ULP recover if the driver kept returning 0 for CQEs polled? Do ULPs usually have some timeout notion when polling CQs? Thanks, Adit -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html