mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 22:52:35 +02:00
net: hns3: bugfix for is_valid_csq_clean_head()
[ Upstream commit6d71ec6cbf] The HEAD pointer of the hardware command queue maybe equal to the command queue's next_to_use in the driver, so that does not belong to the invalid HEAD pointer, since the hardware may not process the command in time, causing the HEAD pointer to be too late to update. The variables' name in this function is unreadable, so give them a more readable one. Fixes:3ff504908f("net: hns3: fix a dead loop in hclge_cmd_csq_clean") Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e334510840
commit
12eeb72afa
|
|
@ -24,15 +24,15 @@ static int hclge_ring_space(struct hclge_cmq_ring *ring)
|
|||
return ring->desc_num - used - 1;
|
||||
}
|
||||
|
||||
static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int h)
|
||||
static int is_valid_csq_clean_head(struct hclge_cmq_ring *ring, int head)
|
||||
{
|
||||
int u = ring->next_to_use;
|
||||
int c = ring->next_to_clean;
|
||||
int ntu = ring->next_to_use;
|
||||
int ntc = ring->next_to_clean;
|
||||
|
||||
if (unlikely(h >= ring->desc_num))
|
||||
return 0;
|
||||
if (ntu > ntc)
|
||||
return head >= ntc && head <= ntu;
|
||||
|
||||
return u > c ? (h > c && h <= u) : (h > c || h <= u);
|
||||
return head >= ntc || head <= ntu;
|
||||
}
|
||||
|
||||
static int hclge_alloc_cmd_desc(struct hclge_cmq_ring *ring)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user