Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4921217pxk; Wed, 30 Sep 2020 15:41:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxciors1jZJSE6lKFn2Wth+3uUz8FdmnazizgiOyekXG7U+JY7RSlXT5N8jdfUjhZrzhGz/ X-Received: by 2002:a17:907:43c3:: with SMTP id i3mr3959360ejs.231.1601505671373; Wed, 30 Sep 2020 15:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601505671; cv=none; d=google.com; s=arc-20160816; b=d4ndhbMPSqoSUqAkkTlN1DLtN1T+xFZzjpso7eHrycGJVGOvkaI3VhGIByd5l1lUOp Fk7lqrLKLfPbEcMS6sSH3GTBYXPu04t34IFLGLD+iREFCs1mPB3GEQzzYsVgB1+dnusf Dabqm3JUXCGdty29FdlOi/JjQbz/s6JjS+8b6RAOqjxo3s17uEyTO30BrqAAT5gKiVSY lQxAvWc5RQiSMqjBz33yi+gmzN8NjEjrANqiOKTVINuHpMbSY/jwVEwC9x9YhCVAO8Sx 1/isliNgl2xW+VkUI9LGR6x26Wl4gmYl/oz5jDRe2WEjYuSoITXwbW7UQrV/c6i3BqZy EV+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=w7o/225bpCqBg7FmoWrj/SlNuFA9GxGFAjODbwr8ThA=; b=wITFmg7+P7jNaLeKh9S7fhoo22+7NRaULbVRl0rdgTye+1/392F7bWJ61HpyEFMnmD zrrQcsar/nlzfNgnz7OBZY898MqzgcwT9/iz29tL37ttPUpzdw8AVN8aeHicJJSXm9AD 6NVRtSkvUNhETGnhoISmJ/tYuz2/6DqxpNHyAwdplVoxFKMldoKmW9lwjvZSW6GJz5n1 d68UH879UgN/2SZ4+ISLZHX4GmQzFTHP8UuHwZnCp1DtUQHYHqNdw56mh6TjlWaLzr8S L5AryljuB+AjU4tiWOqIywZsNQPIy1BQzhjR/AgDqE6GR2GMQPVAfOC59hdYHh4dZSti B+Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eXjsNbxQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si2221475ejo.510.2020.09.30.15.40.39; Wed, 30 Sep 2020 15:41:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eXjsNbxQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730501AbgI3VYb (ORCPT + 99 others); Wed, 30 Sep 2020 17:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbgI3VY3 (ORCPT ); Wed, 30 Sep 2020 17:24:29 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B4D6C061755; Wed, 30 Sep 2020 14:24:29 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u4so2831069ljd.10; Wed, 30 Sep 2020 14:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=w7o/225bpCqBg7FmoWrj/SlNuFA9GxGFAjODbwr8ThA=; b=eXjsNbxQqWC5CCwUu0puomcGEldKCcKmI8va7D2gUg851zg1BA+c3zkKJ0dBQVbi3p qD0rvTyXPPz7eq/yxfyje4zD07KO9hAgoEfoLXjglZrjSBupeQz4EN5gLGAHzNPvqrnm ONdhWJPmxCBO2Ii+nIcHV5UHiX9/1TqLY+/Tt9Z4kEAFmxRnqlk/gmeHZIVClgLeUxPR b0tmypFPj17AJ74vzTIOhBY88as2kCPAtfXpOwncrW4QfyzigcM00eTRfksMwOwz8tgf MNCdpU6lzZiM9CqX1X4Sb1MTKvuJ+9O2Em351/8knDMKj5uSJJMHu/tVv49rFv/mmAao RBTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=w7o/225bpCqBg7FmoWrj/SlNuFA9GxGFAjODbwr8ThA=; b=B3jSqLAvAmySVlK/HdcX3T0fc/xVLpgGNlSttW1EEDbJ5VuSlAFdw45XesRVJpACIH U8HhRjT7/Zw9bsmXDRuZOdHzjSlhvq3L9NmHkgsc0B7XHJAsfkbUpOt8drCJ32oVEYNQ sQow5IQpLcXOchNe2Wvz+dIQE4cbONQ0mAhHjGAzNBy8/bXNGEQ/IvELxDKIM9T9i9bO FSSB9RbzLgZT3wcqwsNmRlEohWGXjepy4qfuXT1VXzht0SOEkzMwNEpovmTx5TiU2h3S LE6ExoivtCFTW8A9YPNo1s6aNQJWmzJ/Jvj9haOFIrDSrxJRlC2GXf7ttIizotJe5L7Q O1+A== X-Gm-Message-State: AOAM533chLsIuogN83jhRDFxE3aI9b8tZ0LOtlPsNOqaqNKgPi2s2ftl worcIl19KiD2uQF2nxtY3Jd43/Mt2Zk= X-Received: by 2002:a2e:880d:: with SMTP id x13mr1482497ljh.20.1601501067211; Wed, 30 Sep 2020 14:24:27 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id n3sm315733lfq.274.2020.09.30.14.24.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Sep 2020 14:24:26 -0700 (PDT) Subject: Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev To: Nicolin Chen , Thierry Reding Cc: joro@8bytes.org, krzk@kernel.org, vdumpa@nvidia.com, jonathanh@nvidia.com, linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20200930084258.25493-1-nicoleotsuka@gmail.com> <20200930084258.25493-3-nicoleotsuka@gmail.com> <20200930153131.GB3833404@ulmo> <20200930203618.GC2110@Asurada-Nvidia> From: Dmitry Osipenko Message-ID: <13746922-0253-cda7-e9ac-2bd20bf1a17f@gmail.com> Date: Thu, 1 Oct 2020 00:24:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200930203618.GC2110@Asurada-Nvidia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... >> It looks to me like the only reason why you need this new global API is >> because PCI devices may not have a device tree node with a phandle to >> the IOMMU. However, SMMU support for PCI will only be enabled if the >> root complex has an iommus property, right? In that case, can't we >> simply do something like this: >> >> if (dev_is_pci(dev)) >> np = find_host_bridge(dev)->of_node; >> else >> np = dev->of_node; >> >> ? I'm not sure exactly what find_host_bridge() is called, but I'm pretty >> sure that exists. >> >> Once we have that we can still iterate over the iommus property and do >> not need to rely on this global variable. > > I agree that it'd work. But I was hoping to simplify the code > here if it's possible. Looks like we have an argument on this > so I will choose to go with your suggestion above for now. This patch removed more lines than were added. If this will be opposite for the Thierry's suggestion, then it's probably not a great suggestion.