msm: iommu: Check if device is already attached

An IOMMU device can only be attached to one IOMMU domain at
any given time. Check whether the device is already
attached to a domain before allowing it to be attached to
another domain. If so, return busy.

Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Daniel Walker <dwalker@codeaurora.org>
This commit is contained in:
Stepan Moskovchenko 2010-11-12 19:29:56 -08:00 коммит произвёл Daniel Walker
Родитель 2607b0a260
Коммит 00d4b2bb03
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -241,6 +241,11 @@ static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
goto fail; goto fail;
} }
if (!list_empty(&ctx_drvdata->attached_elm)) {
ret = -EBUSY;
goto fail;
}
list_for_each_entry(tmp_drvdata, &priv->list_attached, attached_elm) list_for_each_entry(tmp_drvdata, &priv->list_attached, attached_elm)
if (tmp_drvdata == ctx_drvdata) { if (tmp_drvdata == ctx_drvdata) {
ret = -EBUSY; ret = -EBUSY;