From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56926C11F65 for ; Wed, 30 Jun 2021 13:53:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DF21614A7 for ; Wed, 30 Jun 2021 13:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236744AbhF3Nzp (ORCPT ); Wed, 30 Jun 2021 09:55:45 -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)); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D45A2C11F65 for ; Wed, 30 Jun 2021 14:07:22 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9267C61437 for ; Wed, 30 Jun 2021 14:07:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9267C61437 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0C79D415B5; Wed, 30 Jun 2021 14:07:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W2coXzwkmXmi; Wed, 30 Jun 2021 14:07:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 12FC2415B2; Wed, 30 Jun 2021 14:07:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C71BBC001C; Wed, 30 Jun 2021 14:07:16 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 49FB8C000E for ; Wed, 30 Jun 2021 13:49:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 37E7D40568 for ; Wed, 30 Jun 2021 13:49:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CMjOxRDB6uKJ for ; Wed, 30 Jun 2021 13:49:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by smtp4.osuosl.org (Postfix) with ESMTPS id 097F8404F6 for ; Wed, 30 Jun 2021 13:49:21 +0000 (UTC) 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 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-Disposition: inline In-Reply-To: <20210627143405.77298-4-sven@svenpeter.dev> X-Mailman-Approved-At: Wed, 30 Jun 2021 14:07:16 +0000 Cc: devicetree@vger.kernel.org, r.czerwinski@pengutronix.de, Arnd Bergmann , Will Deacon , Hector Martin , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Rob Herring , Alexander Graf , Alyssa Rosenzweig , Marc Zyngier , Mohamed Mediouni , Mark Kettenis , Robin Murphy , linux-arm-kernel@lists.infradead.org, Stan Skowronek X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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)); _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEBDBC11F65 for ; Wed, 30 Jun 2021 14:08:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ABEC461433 for ; Wed, 30 Jun 2021 14:08:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABEC461433 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pjsUdxTZSvappabKR3ukpiQxJEhd2f7x7Ifc9q8dcVY=; b=j/EwmOX7TUXuNs d59EtzbFon3SD63Ra1d/PVMEDhw73BDr51p3KIEZNDJAI9DFL1/Mafhnlu9O/8C19O+cAm/oQRc3X 1DzpIJQtQ/Ygz0duO+/1ZAYGGG+xWJoXX8tpsB2TJzKF1nydeOCNyAaInOz+GmEL+mDdW5YonJ1O5 DmnlvgWTbzM420rljbEJ5nmYsYPFtGf7rWcBqtiUz0ZFC30gQH99V6lnKoH1jTsmzIYNd1B/m7P7X +2PI2uRGt5JY+QAnoOBv1nYKh51+GZqCe4aZe9ZAXXi2zwununDGIxarXng2WSzD1x8Pq21ytiDxz X/hELRGkOOesUuSQggdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyar9-00EGmA-Lp; Wed, 30 Jun 2021 14:06:24 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyaah-00EAlZ-CR for linux-arm-kernel@lists.infradead.org; Wed, 30 Jun 2021 13:49:27 +0000 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-Disposition: inline In-Reply-To: <20210627143405.77298-4-sven@svenpeter.dev> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210630_064923_630166_6BDCD9E8 X-CRM114-Status: GOOD ( 17.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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)); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel