Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp141466pxk; Wed, 30 Sep 2020 21:06:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbTCs1G5X/TkcIQHpg0gj8RdHAM6S4kXHEyYWXoxko+DYJPYCZF2UnAPDOhS/GbEvpcIju X-Received: by 2002:a17:906:e50:: with SMTP id q16mr6318114eji.544.1601525189222; Wed, 30 Sep 2020 21:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601525189; cv=none; d=google.com; s=arc-20160816; b=HDADj0TS8rZiX0uBkvyHbWrF1NmW5wsz6p2UGZvxiuPEUMVYdau2ko2FxMelDmhweZ sRPKOoSCcUSiLoJO9UATyuU2oHdCsRrqv6qVH2E4WOwNuawO7DgXr/NZVsO69A0VcuYF llygf50e75hND6S8igI7/h0qxUu+PKqV8DmCF3Vnt4XEYGyBTOoiFylZOPYrTK3EQJ7x GM29lGzhdZP8CqVwQVWYP3bGboS/3hh01Nwb11GLjuoOGYjxAD+dMZmD4XQxGXkNcjYI x+RvxnVdsuTDKtTGsm7iq4B44UJQcEBF0nyQotIGm12d+ElTX9nQSGAyvAwHL+awWD+p hVDg== 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=4qFJEZiPLmg9u9W5QYna2OZEUfz9MtyCy7mA+ICTo1g=; b=iMK3aOf2XL2V+cggDKKZ5FuFcCj60yICGooVexHCsT2m3EPNKk7cosPFf/aiV6DqPx 87jZzs3EvH4LN4M+wlcc5GaRwiQHAK2GtqxS7QJjoX+y9dPms7s4cDG2BMSkquvXiDMq 5P17+ePBAIkXesVNOZgE5lkMEWFY0+LtGVOc1XTaXR8FaSb08tDurA8xVRoq6W52ldm+ rlhM+xYOHeGRiCK6I6E6qQ9jRoS2q2QyORTh3hF6OSCTw3Vu+I89Owwux3W9ccS8IrzW iSReG5fBD+yoZM6FslKhzq9RI+m6gLg2FjTozZjlLAYDPWLewDGN1m4ImDgR8v/yUk1U WHIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M5xaEfBc; 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 c9si2456301edr.568.2020.09.30.21.06.05; Wed, 30 Sep 2020 21:06:29 -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=M5xaEfBc; 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 S1725897AbgJAEFF (ORCPT + 99 others); Thu, 1 Oct 2020 00:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725800AbgJAEFF (ORCPT ); Thu, 1 Oct 2020 00:05:05 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40E8BC061755; Wed, 30 Sep 2020 21:05:03 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w3so3418883ljo.5; Wed, 30 Sep 2020 21:05:03 -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=4qFJEZiPLmg9u9W5QYna2OZEUfz9MtyCy7mA+ICTo1g=; b=M5xaEfBcC9EtbINBwGw4i/0+Nw+ePBsBY7HpPZsmhZQSsUpvgm99fltKKaQsxwhGgV sxXJ72bYTlARe2QzjDpqpeIMSt5urFVIG2fe5YgbevVNO+UWS/CQyEJSAo8rmkRCYnXQ pZf7Mued90MklbHxfRJRrhsD4oUcwu+dFTYs6UjD9YKvQyMb38MS+nFecxp2koU9OnwY boAg4blzbqNIHuF3P6ty2CMMKTNsE81P5UPei/P+eEAbWUz2viAjzGYPs0Cd+poFoaap ITUNvvhsozRcIw0szsVf9aCTbTqPRz90Fk858piggd396svSaN7eNc6vT3Tno73BQ8Hr aVGw== 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=4qFJEZiPLmg9u9W5QYna2OZEUfz9MtyCy7mA+ICTo1g=; b=LBkkFtS5n5lHdZ4A5DVUP+u+R6EK+3Q+47OGmfnUiqQeb8JUdttDC3PjCw305uhWK4 bPeqCOjypau1C01H/kTl4DeWHYTIvNoGiCSmqmt2oAphyTX7AgMilRw/jZ80zUYF1Rpm 9E3e0nKcyIKW7WMNOYRuT3AYd/v1WnQPW5umgqaJ71WAFCkeYFIzdIocNNqB0XkpPZ2h /KL8oe+lgcMfB868TifhT9roVuoTnwYVekFhF8Xo8mLrsI0eUfp7i11HYU9lZfPDIjev X2MffUpeQhPwIndQbKrh21g5LwyRiCf80KpGS1TAv9GBD7VjY7xx+Mksi9cRRsSx4ytA 3UcA== X-Gm-Message-State: AOAM530pyqjTJI5ynjmxcN5Y0ebakIqghXBbuyl0QcsTULfXYDXE8L3Y fIqLNb9oK2chmff8CG0U1RXjh5yS7ro= X-Received: by 2002:a2e:9588:: with SMTP id w8mr1544467ljh.298.1601525101140; Wed, 30 Sep 2020 21:05:01 -0700 (PDT) Received: from [192.168.2.145] ([109.252.91.252]) by smtp.googlemail.com with ESMTPSA id i7sm314259ljb.44.2020.09.30.21.04.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Sep 2020 21:05:00 -0700 (PDT) Subject: Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev To: Nicolin Chen Cc: Thierry Reding , 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> <13746922-0253-cda7-e9ac-2bd20bf1a17f@gmail.com> <20200930213244.GA10573@Asurada-Nvidia> <5945a63e-79d8-e3ae-ab53-cee8c220ac7d@gmail.com> <20201001012630.GA28240@Asurada-Nvidia> <72b11925-5857-8ce5-d084-cab01ca1b396@gmail.com> <20201001024850.GA28456@Asurada-Nvidia> From: Dmitry Osipenko Message-ID: Date: Thu, 1 Oct 2020 07:04:59 +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: <20201001024850.GA28456@Asurada-Nvidia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 01.10.2020 05:48, Nicolin Chen пишет: > On Thu, Oct 01, 2020 at 05:06:19AM +0300, Dmitry Osipenko wrote: >> 01.10.2020 04:26, Nicolin Chen пишет: >>> On Thu, Oct 01, 2020 at 12:56:46AM +0300, Dmitry Osipenko wrote: >>>> 01.10.2020 00:32, Nicolin Chen пишет: >>>>> On Thu, Oct 01, 2020 at 12:24:25AM +0300, Dmitry Osipenko wrote: >>>>>> ... >>>>>>>> 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. >>>>> >>>>> Sorry, I don't quite understand this comments. Would you please >>>>> elaborate what's this "it" being "not a great suggestion"? >>>>> >>>> >>>> I meant that you should try to implement Thierry's solution, but if the >>>> end result will be worse than the current patch, then you shouldn't make >>>> a v4, but get back to this discussion in order to choose the best option >>>> and make everyone agree on it. >>> >>> I see. Thanks for the reply. And here is a sample implementation: >> >> That's what I supposed to happen :) The new variant adds code and >> complexity, while old did the opposite. Hence the old variant is clearly >> more attractive, IMO. > > I personally am not a fan of adding a path for PCI device either, > since PCI/IOMMU cores could have taken care of it while the same > path can't be used for other buses. > > If we can't come to an agreement on globalizing mc pointer, would > it be possible to pass tegra_mc_driver through tegra_smmu_probe() > so we can continue to use driver_find_device_by_fwnode() as v1? > > v1: https://lkml.org/lkml/2020/9/26/68 > I think we already agreed that it will be good to have a common helper. So far Thierry only objected that the implementation of the helper could be improved.