Based on the upstream feedback, driver should not use any
defensive programming strategy by checking for NULL pointers
and other conditional checks unnecessarily in the code flow
to fall back, instead fail and fix the bug in a proper way.

Some of the checks checks are identified and removed/wrapped
in this patch:
- As the control queue is freed and deleted from the list after the
idpf_ctlq_shutdown call, there is no need to have the ring_size
check in idpf_ctlq_shutdown.
- From the upstream perspective shared code is part of the Linux
driver and it doesn't make sense to add zero 'len' and 'buf_size'
check in idpf_ctlq_add as to start with, driver provides valid
sizes, if not it is a bug.
- Remove cq NULL and zero ring_size check wherever possible as
the IDPF driver code flow does not pass any NULL cq pointer to
the control queue callbacks. If it passes then it is a bug and
should be fixed rather than checking for NULL pointer and falling
back which is not the right way.

Note: Most of the checks are wrapped with __KERNEL__ flag and will
not have any impact on other shared code consumers other than the
IDPF Linux driver as I am not confident if the same reasoning works
for other components as well.

Signed-off-by: Soumyadeep Hore <soumyadeep.h...@intel.com>
---
 drivers/common/idpf/base/idpf_controlq.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/common/idpf/base/idpf_controlq.c 
b/drivers/common/idpf/base/idpf_controlq.c
index 0ba7281a45..4d31c6e6d8 100644
--- a/drivers/common/idpf/base/idpf_controlq.c
+++ b/drivers/common/idpf/base/idpf_controlq.c
@@ -98,9 +98,6 @@ static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct 
idpf_ctlq_info *cq)
 {
        idpf_acquire_lock(&cq->cq_lock);
 
-       if (!cq->ring_size)
-               goto shutdown_sq_out;
-
 #ifdef SIMICS_BUILD
        wr32(hw, cq->reg.head, 0);
        wr32(hw, cq->reg.tail, 0);
@@ -115,7 +112,6 @@ static void idpf_ctlq_shutdown(struct idpf_hw *hw, struct 
idpf_ctlq_info *cq)
        /* Set ring_size to 0 to indicate uninitialized queue */
        cq->ring_size = 0;
 
-shutdown_sq_out:
        idpf_release_lock(&cq->cq_lock);
        idpf_destroy_lock(&cq->cq_lock);
 }
@@ -661,9 +657,6 @@ int idpf_ctlq_recv(struct idpf_ctlq_info *cq, u16 
*num_q_msg,
        int ret_code = 0;
        u16 i = 0;
 
-       if (!cq || !cq->ring_size)
-               return -ENOBUFS;
-
        if (*num_q_msg == 0)
                return 0;
        else if (*num_q_msg > cq->ring_size)
-- 
2.43.0

Reply via email to