Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753565AbdCHNzz (ORCPT ); Wed, 8 Mar 2017 08:55:55 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:33160 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbdCHNzw (ORCPT ); Wed, 8 Mar 2017 08:55:52 -0500 MIME-Version: 1.0 In-Reply-To: <148897090350.16106.1978549972946371705.sendpatchset@little-apple> References: <148897088333.16106.13237004440297956899.sendpatchset@little-apple> <148897090350.16106.1978549972946371705.sendpatchset@little-apple> From: Geert Uytterhoeven Date: Wed, 8 Mar 2017 14:47:09 +0100 X-Google-Sender-Auth: WwtYMM6oKnZUqad8YPJ_CrC5PtQ Message-ID: Subject: Re: [PATCH v3 02/09] iommu/ipmmu-vmsa: Add optional root device feature To: Magnus Damm Cc: Joerg Roedel , Laurent Pinchart , Geert Uytterhoeven , "linux-kernel@vger.kernel.org" , Linux-Renesas , iommu@lists.linux-foundation.org, Simon Horman , Robin Murphy , Marek Szyprowski Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2132 Lines: 76 Hi Magnus, On Wed, Mar 8, 2017 at 12:01 PM, Magnus Damm wrote: > From: Magnus Damm > > Add root device handling to the IPMMU driver by allowing certain > DT compat strings to enable has_cache_leaf_nodes that in turn will > support both root devices with interrupts and leaf devices that > face the actual IPMMU consumer devices. > > Signed-off-by: Magnus Damm > --- 0011/drivers/iommu/ipmmu-vmsa.c > +++ work/drivers/iommu/ipmmu-vmsa.c 2017-03-08 17:56:51.770607110 +0900 > @@ -216,6 +219,44 @@ static void set_archdata(struct device * > #define IMUASID_ASID0_SHIFT 0 > > /* ----------------------------------------------------------------------------- > + * Root device handling > + */ > + > +static bool ipmmu_is_root(struct ipmmu_vmsa_device *mmu) > +{ > + if (mmu->features->has_cache_leaf_nodes) > + return mmu->is_leaf ? false : true; Expressions using the ternary operator are sometimes hard to read. In this case, you want negation, so why not use that? return !mmu->is_leaf; > + else I'd drop the else. > + return true; /* older IPMMU hardware treated as single root */ > +} > + > +static struct ipmmu_vmsa_device *__ipmmu_find_root(void) > +{ > + struct ipmmu_vmsa_device *mmu; > + bool found = false; struct ipmmu_vmsa_device *root = NULL; > + > + spin_lock(&ipmmu_devices_lock); > + > + list_for_each_entry(mmu, &ipmmu_devices, list) { > + if (ipmmu_is_root(mmu)) { > + found = true; root = mmu; > + break; > + } > + } > + > + spin_unlock(&ipmmu_devices_lock); > + return found ? mmu : NULL; return root; > +} 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