From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAB3C37B02A for ; Mon, 23 Mar 2026 17:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774286300; cv=none; b=VZs2vhL1AFlYgJBdaeS7FGRSK97881c/HzImYmBqgz6VgQ9ohEh3Q+6aS4CJdL4j2RqZz/vVzgcfxeKKWQhwF75c3CZ9rali0Ssrgz0Or/X/iwTnSC8xhvzNoklOIfxHbLYTtLwX47EPWGHBbpTDCwCntjsJqhpHkpDJWkVfu+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774286300; c=relaxed/simple; bh=SwZSBJ5dtFN1L7uizFJq7oOv2U7xSNXH+wFesahHWcM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uskyMmwSR2QRk/rH6V8zfPKE86LB+OT78JAhkrw8MsLsBfvfHDSgN6Q1td8nj6qcST9aCYZp/eo91tgY6WiFVfUSHdixvHwbRp7kUrk60UmpAENnKPOlFaA6Cw4OGttulcq4au2BjFE2S2z+Bqn63nvxfwxQ77tV0ZrqsQiGbZo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=H7LtVRLv; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="H7LtVRLv" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-486fda2a389so24792905e9.1 for ; Mon, 23 Mar 2026 10:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1774286296; x=1774891096; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QEgEB+FhJamQekHHnnzeHBVC3CCx1oLXNDdzh85xf2M=; b=H7LtVRLvEnB8cTx7BQFvJ5hu9u4rx5QsZxDYkmDtjyjJuafEJpVzLCAWAJURU77xBg z+7IKMdc++ikOe8pM6fhMXe+h4jQrqi63lRYfnRYy6ey+ggAa76ieXCz6qP4LZWnDlWP nuNwstvVAyOAnh/gY3dXQmuk/wFsG6A0ri7um0oX647bRHav456rcHtBk3oIiJz9h43W DxwIV2c2+lSlTFuKuQtPDRtW8Iyji+gAvs6ZjUP5MT0oN/Tfs7PpGgeH1pXKx2D36jw3 dKW1OMqFO0zByNy5eLIaM05hT/8Ec4kas0wyGTEMrJ32YXgHC8fEY4CdczmrroM8pDD4 e0Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774286296; x=1774891096; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QEgEB+FhJamQekHHnnzeHBVC3CCx1oLXNDdzh85xf2M=; b=cG17bXFbOOPfox1RBRAjnRZl5eZ96ZQAMSvKIPvSC8/PmxFEwxIHjquak4urAVGmI7 5F4yBqrsH6a7BiyyNlVIzWzVcKnkteDCCwJY4cupQ1h888RfBiOJRYM2+sBjBxS0vsGp JwVIiXYwHOHQLL23R9ufPnDyTHNW3u89gw3xZiqB/qEnTU4dYUSE9nWEyrhteMpobkAM l5vK4iAdm5qbICm6UMF2w3XfEAgcMDxg+LsRFlQw9wSi0xHq5A8vzkywf01j3PgvIQN7 VmeAeNMxEZpV0hmv6AjvVIf/Fq0eNMsXbA50cqCkL0UloUvLhI1ap93MaVWMpCCzpFhZ 8S0w== X-Forwarded-Encrypted: i=1; AJvYcCVToUgXCSMWfHZNxg8IKBh1CIQ+AKg7OzBh85ZqIlZ8H7AjzCeuXxb+JROd/OC7n+LuHz6ndM7N/9Qt@vger.kernel.org X-Gm-Message-State: AOJu0YyBw2yGBctXnoJvT/dhQEq+pgIQA1CJOhHns608fju0aAJAuLVo ujejD5aNmhlAjkMls8Io26UuW+R5vDUNGfG+F/Cxte4TPgwHB/1YVi5pqTKwJ+ThgSE= X-Gm-Gg: ATEYQzxmbreeXiawE3YitDYHd2V0hmXq0M+/TY3SjaCz950mu5WKZNjHZScu6Y6lOQL LN3hvow/Fn7HWD3dikBdWhigx6QTv1vY1K31cJC/g/P3B0TgdD4Y0uNwQXgUweEObV07+rkADfm jI7kmnIJv6HaLQe+fNrHyebcGklxat+UJ2p4PjfQkT6WskDPJ47E8VInh/L3Babi8yNbUpbryQl ZERMWsP3yOcQYBnalIPzeO5UwrB8CUti93spGY1JJsU5Rs/asZJM8QIWM7l8s+hIh4uNqRhaQRF wJU676LbEmKY10W/rQX01sTK12pt4PxzAJ+nLZucYQ+AT0qp8cNdq0sh5zekfdO99mMJ9R5oBxR nXkSa8KoMR1s7iDNor3KNkQYuRksY1SJjoFNB94n79cMpUwjRgxv7zNhsYuRj8b9mOxr6lK44yx +waNvOtvImtWvj/VNsEngt42ShXrUJMCI= X-Received: by 2002:a05:600c:c083:b0:485:3f72:324d with SMTP id 5b1f17b1804b1-486fee0481amr142927935e9.14.1774286295324; Mon, 23 Mar 2026 10:18:15 -0700 (PDT) Received: from [10.11.12.108] ([79.115.63.77]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b644bf1c5sm33929334f8f.14.2026.03.23.10.18.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Mar 2026 10:18:13 -0700 (PDT) Message-ID: <67b32e90-1f60-4bf5-b534-b4a901d5a796@linaro.org> Date: Mon, 23 Mar 2026 19:18:08 +0200 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/4] iommu: Get DT/ACPI parsing into the proper probe path To: Robin Murphy , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , Russell King , Greg Kroah-Hartman , Danilo Krummrich , Stuart Yoder , Laurentiu Tudor , Nipun Gupta , Nikhil Agarwal , Joerg Roedel , Will Deacon , Rob Herring , Bjorn Helgaas Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Charan Teja Kalla , Peter Griffin , =?UTF-8?Q?Andr=C3=A9_Draszik?= , Juan Yescas , kernel-team@android.com References: Content-Language: en-US From: Tudor Ambarus In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, Robin, On 2/28/25 5:46 PM, Robin Murphy wrote: > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index a3b45b84f42b..1cec7074367a 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -414,9 +414,21 @@ static int iommu_init_device(struct device *dev) > if (!dev_iommu_get(dev)) > return -ENOMEM; > /* > - * For FDT-based systems and ACPI IORT/VIOT, drivers register IOMMU > - * instances with non-NULL fwnodes, and client devices should have been > - * identified with a fwspec by this point. Otherwise, we can currently > + * For FDT-based systems and ACPI IORT/VIOT, the common firmware parsing > + * is buried in the bus dma_configure path. Properly unpicking that is > + * still a big job, so for now just invoke the whole thing. The device > + * already having a driver bound means dma_configure has already run and > + * either found no IOMMU to wait for, or we're in its replay call right > + * now, so either way there's no point calling it again. > + */ > + if (!dev->driver && dev->bus->dma_configure) { > + mutex_unlock(&iommu_probe_device_lock); > + dev->bus->dma_configure(dev); > + mutex_lock(&iommu_probe_device_lock); > + } I was chasing the "something fishy" dev_WARN on a 6.19+ downstream android kernel and while looking at the IOMMU code I couldn't help myself and ask whether we shall prevent concurrent execution of dma_configure(). It seems to me that while the IOMMU subsystem is executing dma_configure(), the deferred probe workqueue can concurrently pick up the same device, enter really_probe(), set dev->driver, and execute dma_configure(). Is it worth protecting against this? I can try to prove it if needed, using a downstream iommu driver (sigh). Thanks! ta diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index e61927b4d41f..5f0c1a8064b5 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -461,9 +461,19 @@ static int iommu_init_device(struct device *dev) * already having a driver bound means dma_configure has already run and * found no IOMMU to wait for, so there's no point calling it again. */ - if (!dev->iommu->fwspec && !dev->driver && dev->bus->dma_configure) { + if (!dev->iommu->fwspec && !READ_ONCE(dev->driver) && + dev->bus->dma_configure) { mutex_unlock(&iommu_probe_device_lock); - dev->bus->dma_configure(dev); + + /* + * Serialize with really_probe(). Recheck dev->driver in case a + * driver bound while we were waiting for the lock. + */ + device_lock(dev); + if (!dev->driver) + dev->bus->dma_configure(dev); + device_unlock(dev); + mutex_lock(&iommu_probe_device_lock); /* If another instance finished the job for us, skip it */ if (!dev->iommu || dev->iommu_group) (END)