mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
iommu/arm-smmu-v3: Add Q_POS() macro
A queue position, the wrap bit combined with the index, is Q_WRP | Q_IDX. It is a (max_n_shift + 1)-bit value that wraps at twice the queue capacity. queue_inc_cons(), queue_sync_cons_ovf(), and queue_inc_prod_n() currently compute such positions by open-coding the two macros at each call site. Add a Q_POS() macro and switch the open-coded sites to it. A subsequent change will build a Q_DIFF() on it, to count the entries that a queue pointer moved past. No functional change intended. Assisted-by: LLM Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
580bbfcdcd
commit
02b5c4639b
|
|
@ -187,8 +187,8 @@ static void queue_sync_cons_out(struct arm_smmu_queue *q)
|
|||
|
||||
static void queue_inc_cons(struct arm_smmu_ll_queue *q)
|
||||
{
|
||||
u32 cons = (Q_WRP(q, q->cons) | Q_IDX(q, q->cons)) + 1;
|
||||
q->cons = Q_OVF(q->cons) | Q_WRP(q, cons) | Q_IDX(q, cons);
|
||||
u32 cons = Q_POS(q, q->cons) + 1;
|
||||
q->cons = Q_OVF(q->cons) | Q_POS(q, cons);
|
||||
}
|
||||
|
||||
static void queue_sync_cons_ovf(struct arm_smmu_queue *q)
|
||||
|
|
@ -198,8 +198,7 @@ static void queue_sync_cons_ovf(struct arm_smmu_queue *q)
|
|||
if (likely(Q_OVF(llq->prod) == Q_OVF(llq->cons)))
|
||||
return;
|
||||
|
||||
llq->cons = Q_OVF(llq->prod) | Q_WRP(llq, llq->cons) |
|
||||
Q_IDX(llq, llq->cons);
|
||||
llq->cons = Q_OVF(llq->prod) | Q_POS(llq, llq->cons);
|
||||
queue_sync_cons_out(q);
|
||||
}
|
||||
|
||||
|
|
@ -224,8 +223,8 @@ static int queue_sync_prod_in(struct arm_smmu_queue *q)
|
|||
|
||||
static u32 queue_inc_prod_n(struct arm_smmu_ll_queue *q, int n)
|
||||
{
|
||||
u32 prod = (Q_WRP(q, q->prod) | Q_IDX(q, q->prod)) + n;
|
||||
return Q_OVF(q->prod) | Q_WRP(q, prod) | Q_IDX(q, prod);
|
||||
u32 prod = Q_POS(q, q->prod) + n;
|
||||
return Q_OVF(q->prod) | Q_POS(q, prod);
|
||||
}
|
||||
|
||||
static void queue_poll_init(struct arm_smmu_device *smmu,
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@ struct arm_vsmmu;
|
|||
|
||||
#define Q_IDX(llq, p) ((p) & ((1 << (llq)->max_n_shift) - 1))
|
||||
#define Q_WRP(llq, p) ((p) & (1 << (llq)->max_n_shift))
|
||||
/* A position is Q_WRP | Q_IDX, wrapping at twice the queue capacity */
|
||||
#define Q_POS(llq, p) (Q_WRP(llq, p) | Q_IDX(llq, p))
|
||||
#define Q_OVERFLOW_FLAG (1U << 31)
|
||||
#define Q_OVF(p) ((p) & Q_OVERFLOW_FLAG)
|
||||
#define Q_ENT(q, p) ((q)->base + \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user