Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1010590imu; Thu, 20 Dec 2018 08:42:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/XvSI0Xc6zlieX7tJS/JkNYyiZEO0bECWlK+Lls9pIyAkPRchgvOb+0ZEO8Gm//deP0j2OA X-Received: by 2002:a63:d818:: with SMTP id b24mr20006947pgh.174.1545324136095; Thu, 20 Dec 2018 08:42:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545324136; cv=none; d=google.com; s=arc-20160816; b=mBkqOKjnygYNOacOiyhXRBjlvQrGEQzFeIYHy3NyFlPi4s4lJXfFAszXgZ9QLgv0fQ inXI/mdepjvpR2XULXaCxIDv5FAxrfCX028uISUx5va2Id10mbVaqxEoTSCTx5k/ZZyX auO8anIMdA3SPw/IWKKWLIe0MQw9eoo0bEH5mtfPTs53ihE6li7JYQEzoqJJlLHLzWdo CGgkRPAZvprQO6K8vif0zFhtXqHLwwwXp/iRpIi51pIFbB09/xQXNis4TAHAVdqo4N1R 9W+8R5m14NDwFb6eerdQcB6CHIDTPLfMsfT4TM3N02VY2/orL3fBJbuaEhYqi8TPbUHB cW3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=4VtWPvW52YZYn0DyOhzncFDVF+ilIuxDnKS05SgjmDw=; b=vG6VUYNePaBAXwjnKfnX0Clicb27c1Sm2H4SIwrYF6bAc3md5cD4g1WHwmQwlsB+fS R5VQKwr1MwNPm+G5ujQ2phl2MxnmUUDxEkLyzVT2yCcWKe7TIjdDZkTbGULSCJLlU5Hu xh3c8s5oaqJB4dytiC6/GsXFKjJMaBBRqM21E2hco6Sp9qmDoEVnjhNPnLfnitJ/ngUl S5LtyLylrZ5dkrl5Pf2fctuH8VwhO4daUzr6v87x6UWvyRX7DLEqcJF2C7YvG+YADImo UYwHz9UojKlBw5Mu8bRln92A14BpOT7MlXNR0hfmkLkV3sNlQX3kKc7OHj19s19PJto1 r4Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si372096plc.88.2018.12.20.08.42.00; Thu, 20 Dec 2018 08:42:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731768AbeLTPmd convert rfc822-to-8bit (ORCPT + 99 others); Thu, 20 Dec 2018 10:42:33 -0500 Received: from mail-vk1-f194.google.com ([209.85.221.194]:42891 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729184AbeLTPmb (ORCPT ); Thu, 20 Dec 2018 10:42:31 -0500 Received: by mail-vk1-f194.google.com with SMTP id y14so470648vky.9 for ; Thu, 20 Dec 2018 07:42:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tHQnhEmeNAkhfMiX5dm+pc4968Yh2EmyfSDMadQr4KU=; b=G15LryuEzwKxSJgAq6U3IpngjFb394sRdG52H+7RQcgtV+J8FoO8Trzs0LrMyT/r8p NaE1b9AUz4dGAKuHopvfDuGnU2SttHJtE5/DH9vrn5PGBaa3Oa35FNN/eZh43HT4W1xH Y+EUP+T1ABWM3aIt988zTKKjqYeB9KUhX1cPbidJDFXp1InjqZs4KuyQy03oUnW2HzKT OXobMTN6DCxoi6aKZp13sRBRG2d978abpXb0fo61y7HWD75qUZH2R6nQ8o+3EquMARgP QLnD1JAq/GGpWMtGS9SmCk9xLINDJLqyZjbiFiqgQbNLmlcfdmcfGmR+29UlL2lFmrS+ 1smQ== X-Gm-Message-State: AA+aEWaXAzNYOY8aAkYomDTwvAObpRTzBihiSWUzzk5s4yIEZJD8kO4+ pgh5CCJsTNksbNQi8MDWC9ej3n5tl+SiyNFN0a0= X-Received: by 2002:a1f:2145:: with SMTP id h66mr11841962vkh.65.1545320549416; Thu, 20 Dec 2018 07:42:29 -0800 (PST) MIME-Version: 1.0 References: <20181211150513.15161-1-joro@8bytes.org> <20181211150513.15161-4-joro@8bytes.org> <30d86186-e0a2-2be1-2295-20510fbd74ba@samsung.com> <20181219143451.GY16835@8bytes.org> In-Reply-To: <20181219143451.GY16835@8bytes.org> From: Geert Uytterhoeven Date: Thu, 20 Dec 2018 16:42:17 +0100 Message-ID: Subject: Re: [PATCH 3/4] iommu/of: Don't call iommu_ops->add_device directly To: Joerg Roedel Cc: Marek Szyprowski , Linux IOMMU , Linux Kernel Mailing List , Joerg Roedel , Sudeep Holla , Robin Murphy , Krzysztof Kozlowski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jörg, On Wed, Dec 19, 2018 at 5:51 PM Joerg Roedel wrote: > On Wed, Dec 19, 2018 at 10:54:18AM +0100, Marek Szyprowski wrote: > > On 2018-12-11 16:05, Joerg Roedel wrote: > > > From: Joerg Roedel > > > > > > Make sure to invoke this call-back through the proper > > > function of the IOMMU-API. > > > > > > Signed-off-by: Joerg Roedel > > > --- > > > drivers/iommu/of_iommu.c | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > > > index c5dd63072529..4d4847de727e 100644 > > > --- a/drivers/iommu/of_iommu.c > > > +++ b/drivers/iommu/of_iommu.c > > > @@ -218,10 +218,10 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, > > > ops = dev->iommu_fwspec->ops; > > > /* > > > * If we have reason to believe the IOMMU driver missed the initial > > > - * add_device callback for dev, replay it to get things in order. > > > + * probe for dev, replay it to get things in order. > > > */ > > > - if (ops && ops->add_device && dev->bus && !dev->iommu_group) > > > - err = ops->add_device(dev); > > > + if (dev->bus && !dev->iommu_group) > > > + err = iommu_probe_device(dev); > > > > This change removes a check for NULL ops, what causes NULL pointer > > exception on first device without IOMMU. > > Bummer, this check was supposed to be in iommu_probe_device(), but > apparently it got lost. Does the attached patch fix it? > > > I'm also not sure if this is a good idea to call iommu_probe_device(), > > which comes from dev->bus->iommu_ops, which might be different from ops > > from local variable. > > The local variable comes from dev->iommu_fwspec->ops, which should be > exactly the same as dev->bus->iommu_ops. I'll leave that for now until > it turns out to be a problem (which I don't expect). > > > Regards, > > Joerg > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index a2131751dcff..3ed4db334341 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -114,10 +114,14 @@ void iommu_device_unregister(struct iommu_device *iommu) > int iommu_probe_device(struct device *dev) > { > const struct iommu_ops *ops = dev->bus->iommu_ops; > + int ret = -EINVAL; > > WARN_ON(dev->iommu_group); > > - return ops->add_device(dev); > + if (ops) Is this sufficient? The old code checked for ops->add_device != NULL, too. > + ret = ops->add_device(dev); > + > + return ret; > } > > void iommu_release_device(struct device *dev) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds