Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp341377pxv; Wed, 30 Jun 2021 06:54:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCcRW2sm6CtBiyryiv7Jdp7omuXjFsA///nj/tQF29UQbrrznDVCPSVioQJG27nDihMOoK X-Received: by 2002:a17:906:90c5:: with SMTP id v5mr35243895ejw.52.1625061297353; Wed, 30 Jun 2021 06:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625061297; cv=none; d=google.com; s=arc-20160816; b=Eqlzuiajq8xn/h8tGlUzbv7TsrlKDizvzm4uZaQep+nwJ70qtKDn3iA66fqAEOTOS0 QX6nn519+sVX2ZppLX1X81I5fqbWo/YPYrp8ZJAsqaNzRnJhvjeVGZDLo/isI5QvZd2W 05rV4wp7f0+CnaRzDC/lVQQkj5MmnoAT94gj9+UH7I5P0BR6JCH1kLVUGSFJRMoD20eh kbOfd+ALxkik92vIL054DQe8BtEF5yFX46OHpuEjOHmnQlGbEXOVUrx4bBKGvgCRAQEF lJBNlYiTeyY8lXbZZzcBKD7cjLqHEnIoHTbC81dkjBMQWpDfF70xgDWSbqphyOlrCdE1 6Myg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=d1cSqPx9pwGhKnZCV2Y0J34t69/XEg5eeRgYlRD/e/8=; b=RmtNqbj6WszZKyv/v3PK+mzt5ZZsJRLwuy62VVE7TDxRkgYsJER5yjsOfOpe0avCP/ a4NT1hR1NKqmq0BI2dB3g+c/M3GtykzC523d7bfwEglHwZSXc1T7fSv8UgdMGEj81W5h dGYWiwlwuJVHwaf4jEf6lEbHzd4jRwCScSu+BUoc+hWQHs++2C+Nr9ST2Or+g0rL1mDE iDx5sh43GWX7rzrilw5lFmJllGR00Jaqd8vEa4PflSWgiEki9QVZUVOiSG5b6XPi86ss R45SDUf6b2rbDc1SLZlnA7LYj6j5Ia38fPyI6dVveavi7bwbT4f+rCT49cTWtB8bUorn jo1Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si21071345eds.190.2021.06.30.06.54.34; Wed, 30 Jun 2021 06:54:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236717AbhF3Nzm (ORCPT + 99 others); Wed, 30 Jun 2021 09:55:42 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47410 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235663AbhF3Nvu (ORCPT ); Wed, 30 Jun 2021 09:51:50 -0400 Received: from maud (unknown [IPv6:2600:8800:8c04:8c00::912b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: alyssa) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id EF5171F43548; Wed, 30 Jun 2021 14:49:13 +0100 (BST) Date: Wed, 30 Jun 2021 09:49:07 -0400 From: Alyssa Rosenzweig To: Sven Peter Cc: Will Deacon , Robin Murphy , Joerg Roedel , Arnd Bergmann , devicetree@vger.kernel.org, Hector Martin , linux-kernel@vger.kernel.org, Marc Zyngier , Mohamed Mediouni , Stan Skowronek , linux-arm-kernel@lists.infradead.org, Mark Kettenis , iommu@lists.linux-foundation.org, Alexander Graf , Alyssa Rosenzweig , Rob Herring , r.czerwinski@pengutronix.de Subject: Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver Message-ID: References: <20210627143405.77298-1-sven@svenpeter.dev> <20210627143405.77298-4-sven@svenpeter.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210627143405.77298-4-sven@svenpeter.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looks really good! Just a few minor comments. With them addressed, Reviewed-by: Alyssa Rosenzweig > + Say Y here if you are using an Apple SoC with a DART IOMMU. Nit: Do we need to spell out "with a DART IOMMU"? Don't all the apple socs need DART? > +/* > + * This structure is used to identify a single stream attached to a domain. > + * It's used as a list inside that domain to be able to attach multiple > + * streams to a single domain. Since multiple devices can use a single stream > + * it additionally keeps track of how many devices are represented by this > + * stream. Once that number reaches zero it is detached from the IOMMU domain > + * and all translations from this stream are disabled. > + * > + * @dart: DART instance to which this stream belongs > + * @sid: stream id within the DART instance > + * @num_devices: count of devices attached to this stream > + * @stream_head: list head for the next stream > + */ > +struct apple_dart_stream { > + struct apple_dart *dart; > + u32 sid; > + > + u32 num_devices; > + > + struct list_head stream_head; > +}; It wasn't obvious to me why we can get away without reference counting. Looking ahead it looks like we assert locks in each case. Maybe add that to the comment? ``` > +static void apple_dart_hw_set_ttbr(struct apple_dart *dart, u16 sid, u16 idx, > + phys_addr_t paddr) > +{ > + writel(DART_TTBR_VALID | (paddr >> DART_TTBR_SHIFT), > + dart->regs + DART_TTBR(sid, idx)); > +} ``` Should we be checking alignment here? Something like BUG_ON(paddr & ((1 << DART_TTBR_SHIFT) - 1));