All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] iommu/vt-d: Drain PRQs when domain removed from RID
@ 2024-12-11 12:42 Dan Carpenter
  2024-12-12  0:42 ` Baolu Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-12-11 12:42 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu

Hello Lu Baolu,

Commit c43e1ccdebf2 ("iommu/vt-d: Drain PRQs when domain removed from
RID") from Nov 4, 2024 (linux-next), leads to the following Smatch
static checker warning:

	drivers/iommu/intel/prq.c:95 intel_iommu_drain_pasid_prq()
	warn: sleeping in atomic context

drivers/iommu/intel/prq.c
    60 void intel_iommu_drain_pasid_prq(struct device *dev, u32 pasid)
    61 {
    62         struct device_domain_info *info;
    63         struct dmar_domain *domain;
    64         struct intel_iommu *iommu;
    65         struct qi_desc desc[3];
    66         int head, tail;
    67         u16 sid, did;
    68 
    69         info = dev_iommu_priv_get(dev);
    70         if (!info->pri_enabled)
    71                 return;
    72 
    73         iommu = info->iommu;
    74         domain = info->domain;
    75         sid = PCI_DEVID(info->bus, info->devfn);
    76         did = domain ? domain_id_iommu(domain, iommu) : FLPT_DEFAULT_DID;
    77 
    78         /*
    79          * Check and wait until all pending page requests in the queue are
    80          * handled by the prq handling thread.
    81          */
    82 prq_retry:
    83         reinit_completion(&iommu->prq_complete);
    84         tail = dmar_readq(iommu->reg + DMAR_PQT_REG) & PRQ_RING_MASK;
    85         head = dmar_readq(iommu->reg + DMAR_PQH_REG) & PRQ_RING_MASK;
    86         while (head != tail) {
    87                 struct page_req_dsc *req;
    88 
    89                 req = &iommu->prq[head / sizeof(*req)];
    90                 if (!req->pasid_present || req->pasid != pasid) {
    91                         head = (head + sizeof(*req)) & PRQ_RING_MASK;
    92                         continue;
    93                 }
    94 
--> 95                 wait_for_completion(&iommu->prq_complete);
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a sleep.

    96                 goto prq_retry;
    97         }
    98 
    99         iopf_queue_flush_dev(dev);
               ^^^^^^^^^^^^^^^^^^^^^^^^^
flush sleeps as well.

The call tree is:

intel_mm_release() <- disables preempt with a spinlock
-> intel_pasid_tear_down_entry() <- the patch added intel_iommu_drain_pasid_prq()
   -> intel_iommu_drain_pasid_prq()

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-12  0:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 12:42 [bug report] iommu/vt-d: Drain PRQs when domain removed from RID Dan Carpenter
2024-12-12  0:42 ` Baolu Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.