From patchwork Thu Nov 17 18:27:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13047168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A79DC433FE for ; Thu, 17 Nov 2022 18:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235029AbiKQS1e (ORCPT ); Thu, 17 Nov 2022 13:27:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234455AbiKQS1a (ORCPT ); Thu, 17 Nov 2022 13:27:30 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CE148514D; Thu, 17 Nov 2022 10:27:26 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id x102so3884919ede.0; Thu, 17 Nov 2022 10:27:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c1L0qaHuxayV/ztjPJq7L3ZiA0tKeU5Nhm4CRbNrcJc=; b=DRZKblD/AehKJ3v1u5i7DYUgaW5+LHwWGH8MbIZgJg08pr/r6Ovc/9ynwmb/Hx4za9 uQelGbeUTs2vsU9I4/1KtC+CVFV3qeHq5Bk5OIvQN/sUWwfIf3Dx95LndHb5nQsV3Qa8 T24n3wPnqATzR4oY/a3MMoaxQfdBQkW8ARzBxICmD1Py1idUZc3nhyFla/ms6r39Hdc0 44kAsB/U78Pbz8GxnvAWbgxpz+y4IVHTIkkBdtlyyuwQtQ6Oy5LZyu3Qtjgzr1zgbO0q UEkanpXCZ7rfEV/o8N0+f6Gu79J0pddjzdVV9QcexOenwrjKm0+qyzOE8j67x4ytjuKB XXtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c1L0qaHuxayV/ztjPJq7L3ZiA0tKeU5Nhm4CRbNrcJc=; b=fD+thj++UeU7qKIKcgBvg8IglNe995YAmVs2bRcqUBtOox0jM5EIGJUNGq43chbsf2 XGgXREtYrVuZ7yVN/UFWOzjvNUI5mXkNTgN3rsZpr28Sq5U9MmZS305Oa7/c44A5BXWU XOj7kwZaZNG5QRWvHii8djeY7V15wtZ3oobvcMph3tYLEBnc3tcs8ST1kUz3nw1INqqV Eot79qxhqYpIeGpdY1MqfIh8OBQW2ZO5Xm9B5SlMumvOcknDUtSznHvAqrEZZRIsLStZ RhKL8SgmV2tomzo5mQuiIXct243U5qR/T5IdwmMkp+XlchIRjBh6ls76vKe7uzh/cz7X ZwRg== X-Gm-Message-State: ANoB5plIF55QXWeaMtbNgDKPZ7CmViFYGoFMy7tqcVHZTZVdwdVQeY9d ZchTTjyr0JLnNSRJHUfcfDk= X-Google-Smtp-Source: AA0mqf6mPgyMVUXQazAevVXoyoFrwVmk70vCWSLCnaVMiGRePK+KhynHTf5qCNauoFibO4k/HwXp1w== X-Received: by 2002:a05:6402:180d:b0:469:58:b18b with SMTP id g13-20020a056402180d00b004690058b18bmr730928edy.240.1668709644867; Thu, 17 Nov 2022 10:27:24 -0800 (PST) Received: from localhost (p200300e41f201d00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f20:1d00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id a14-20020a170906684e00b007acc5a42e77sm681845ejs.88.2022.11.17.10.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:27:24 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Adrian Hunter , Ulf Hansson , Robin Murphy Cc: Thierry Reding , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v11 1/6] iommu: Add note about struct iommu_fwspec usage Date: Thu, 17 Nov 2022 19:27:15 +0100 Message-Id: <20221117182720.2290761-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117182720.2290761-1-thierry.reding@gmail.com> References: <20221117182720.2290761-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Thierry Reding This structure is to be considered private to the IOMMU API. Except for very few exceptions, IOMMU consumer drivers should treat this as opaque data. Signed-off-by: Thierry Reding Acked-by: Joerg Roedel --- include/linux/iommu.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 1690c334e516..dc5e6f5c14fc 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -641,6 +641,10 @@ struct iommu_group *fsl_mc_device_group(struct device *dev); * @flags: IOMMU_FWSPEC_* flags * @num_ids: number of associated device IDs * @ids: IDs which this device may present to the IOMMU + * + * Note that the IDs (and any other information, really) stored in this structure should be + * considered private to the IOMMU device driver and are not to be used directly by IOMMU + * consumers. */ struct iommu_fwspec { const struct iommu_ops *ops; From patchwork Thu Nov 17 18:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13047170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33A49C4332F for ; Thu, 17 Nov 2022 18:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240443AbiKQS1g (ORCPT ); Thu, 17 Nov 2022 13:27:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239456AbiKQS1b (ORCPT ); Thu, 17 Nov 2022 13:27:31 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76B1B8514F; Thu, 17 Nov 2022 10:27:27 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id z18so3800349edb.9; Thu, 17 Nov 2022 10:27:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fN0Pf/Kjl+6iaPP/MqA8nuRuC5pA+kYilLhV8Jo1Icw=; b=VUTYep/y8dV73hoIk8ncAaDTUNNcEhN/XS9CIK8rv8gFEjJim4z4wlTNuSFqNWbxy8 4GgStA0OdOK6oD4neMSIkV0UjMrp9wgF6/zvrUvfri1EJGeFDDFRyRhLRxVqSprt3llT HRWJ8aQrwqvcNtyVoRaFyvzsb9BFVFWXALpQcnwU6g6dvsFn7B+/fb6dmsUTYfHd0pMI BgSJTTqelAbFz7eyuGzzbgQrvyl8lJAaSSaIx4tCrd/o5KoNEpxGdo06JIIAgI4xzsRx y78+MonNyjUT/7fCpqqfVjShLaqX1U7/NFlFvd6oPALVvH1N6hXQqQfWWURnLlA5XwP/ Kzwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fN0Pf/Kjl+6iaPP/MqA8nuRuC5pA+kYilLhV8Jo1Icw=; b=QhZ2NGtPlhy5B0DXSLPQx56hUSQ27E51PJVAPSFxBeQSGLZ0AiZpuxqZl17jlPyd/2 58y47k0AzdsYzeynd2aEx4Nsu4XZ/PCh1qvSyvkxa1J5HOZ95hnW0aEBbP9z8ieecXTD UMeDQkiywwDPXCWte1kCs8ylKl5xO896Fc+DaB+BBb5FI0yB9uuCl368tOo/otN93pNH QhJ6zejvqbyGDSLZlJsSfYPy4R2C1qQSBImOdkXRQvYwvhJELz3WzMoMwa+5RQ6YxnH+ cl8hQUUSbam/f7ojgW1ogVqS0afmEu5sCOkZF1qVN4Ly1J74UBbYKwt1PCBBwsrvN5dV EX1g== X-Gm-Message-State: ANoB5pmCDkv/X5SlAZdRDIyTa5mwpJxxpalZXQvJacep9nLy4hnkv0Lc Yc2meQozpwm2crECcYSG/kg= X-Google-Smtp-Source: AA0mqf7zR0i8sLAdHFWQTrKHmqDUtCnCHKRJ0xwsre9iDZaHLYaQvHEnKqU7ubogXSJLQZ+Is3H1Yw== X-Received: by 2002:aa7:d7cc:0:b0:45b:4a4b:478c with SMTP id e12-20020aa7d7cc000000b0045b4a4b478cmr3166149eds.317.1668709645912; Thu, 17 Nov 2022 10:27:25 -0800 (PST) Received: from localhost (p200300e41f201d00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f20:1d00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id v24-20020a170906859800b00781e7d364ebsm688659ejx.144.2022.11.17.10.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:27:25 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Adrian Hunter , Ulf Hansson , Robin Murphy Cc: Thierry Reding , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v11 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Date: Thu, 17 Nov 2022 19:27:16 +0100 Message-Id: <20221117182720.2290761-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117182720.2290761-1-thierry.reding@gmail.com> References: <20221117182720.2290761-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Thierry Reding Access to the internals of struct iommu_fwspec by non-IOMMU drivers is discouraged. Many drivers for Tegra SoCs, however, need access to their IOMMU stream IDs so that they can be programmed into various hardware registers. Formalize this access into a common helper to make it easier to audit and maintain. Signed-off-by: Thierry Reding --- include/linux/iommu.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index dc5e6f5c14fc..f0d72acad7db 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1186,4 +1186,25 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle) } #endif /* CONFIG_IOMMU_SVA */ +/* + * Newer generations of Tegra SoCs require devices' stream IDs to be directly programmed into + * some registers. These are always paired with a Tegra SMMU or ARM SMMU, for which the contents + * of the struct iommu_fwspec are known. Use this helper to formalize access to these internals. + */ +#define TEGRA_STREAM_ID_BYPASS 0x7f + +static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream_id) +{ +#ifdef CONFIG_IOMMU_API + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); + + if (fwspec && fwspec->num_ids == 1) { + *stream_id = fwspec->ids[0] & 0xffff; + return true; + } +#endif + + return false; +} + #endif /* __LINUX_IOMMU_H */ From patchwork Thu Nov 17 18:27:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13047169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C402CC43219 for ; Thu, 17 Nov 2022 18:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240109AbiKQS1f (ORCPT ); Thu, 17 Nov 2022 13:27:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235041AbiKQS1b (ORCPT ); Thu, 17 Nov 2022 13:27:31 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26778515B; Thu, 17 Nov 2022 10:27:28 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id f18so7239172ejz.5; Thu, 17 Nov 2022 10:27:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d+rSTxy95i5fB+h/5j4BybighhCVy5Cpr+8wxCuIfS8=; b=Rd2e9hZZ8eSFHv28+CbR29FviKgUzwBJW5uK56F6HMfv3BN7XA072eLK9qfcjOfYhW O4yJ8Sdo/JyJuOQG5q32mM8rfcybytHvqY3mGOwDE7hQeNQjGJvgDOgGmbzeqInYIaG7 mkNLnF/HylmvUR8qPla5M9EzsskJIcqt8kPtAJdCK8iWItk51at3EM0cLtheC8OdWzC3 aClvK1pAE9Ex/3bgYVWwV5SGdBfd6E1EgJ9Z4Bxhue7D0y3mRi0R33I9TnycOUFX0Aju NiJf7b1I7yfytarNclDMZp4rDmgkfjZKzBUmtUtx6tfkON+DndxoZuFFAe5Z4ssw3QS6 PVVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+rSTxy95i5fB+h/5j4BybighhCVy5Cpr+8wxCuIfS8=; b=59fefnHDvYyS8pbG1O1tknQhgaeJo1qY192qshXcIRtU0/Db81bbQaeuFSW6GVSKdV 0zxASQctbbVQP2Tj+O/dKVk5k2VKs9JAlz6kw7JEKsMpp/PtKgi/sJlswlnjYDRSeuMo OH8GFHgP1ZyfCB2YSyVwtKu1gSNqg+VOe8lnxKzcsOcUoEiH1TMZnQ0YOeRsIHcZ/zbe RsEd1p1UI3WVHA+qw21s6H/CTpAx/cjSO9DazTdfZve1GPsqm7ezgxphys9RnezN2s0p Ty4ZttkAIYCZcP2G7b2hJvU+fOBNdv7QTbeZxPdmA8MDe+9qj820U14ekuqvkbhSI/tM VimA== X-Gm-Message-State: ANoB5pkQWK3KUEVIgLoGIPnsfAsU4SHBwAbkpLzTf7sq/65maMmxOLta w2UyGlPrPip1taSrr/8/2wg= X-Google-Smtp-Source: AA0mqf6Fe/ayrdsGJkjFUrQyiSGXzBegvQwqUA8lN02/4/ld05iVODo6XHssr2OYDJS1qk2JiYT/1Q== X-Received: by 2002:a17:906:3155:b0:7ad:90db:c241 with SMTP id e21-20020a170906315500b007ad90dbc241mr3176853eje.284.1668709647195; Thu, 17 Nov 2022 10:27:27 -0800 (PST) Received: from localhost (p200300e41f201d00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f20:1d00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id e25-20020a056402105900b004610899742asm847347edu.13.2022.11.17.10.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:27:26 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Adrian Hunter , Ulf Hansson , Robin Murphy Cc: Thierry Reding , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v11 3/6] mmc: sdhci-tegra: Sort includes alphabetically Date: Thu, 17 Nov 2022 19:27:17 +0100 Message-Id: <20221117182720.2290761-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117182720.2290761-1-thierry.reding@gmail.com> References: <20221117182720.2290761-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Thierry Reding Sort includes alphabetically to make it easier to add new ones subsequently. Signed-off-by: Thierry Reding Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-tegra.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index c71000a07656..e2a8488d4fa9 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -3,28 +3,29 @@ * Copyright (C) 2010 Google, Inc. */ +#include +#include #include #include #include -#include +#include #include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include #include From patchwork Thu Nov 17 18:27:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13047172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C82FC43219 for ; Thu, 17 Nov 2022 18:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239716AbiKQS1j (ORCPT ); Thu, 17 Nov 2022 13:27:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234931AbiKQS1d (ORCPT ); Thu, 17 Nov 2022 13:27:33 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA6D785161; Thu, 17 Nov 2022 10:27:29 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id i10so7225000ejg.6; Thu, 17 Nov 2022 10:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yTb92251x+DtmUTSDWp2pFXRoCwhroQ3ngkruzpCgHo=; b=Nq6a4mCYFkvy9TVj0yPEuVKgBtpPb4BpXCbf8WERLSgME/hu4b8Lx28MSDcZLhXlr9 833t52p/MuIKDAb5zBhNK4BqMqQ/4xkYocZU352vVyi4vZO9JW6k7be7rc5zfXLg/zXk Pj2laLyanNFuIgiQsQ3hdEN3cVuY8+ly9huqr9L0rRuTess59wIcfOgsYXsOSI5yRumO ox8U5GRPhobzkQEasTmiVQJpq3IeIdKVl6HghT/57hxWyCYpmyxa0zGhzm5/SU9KAOcT xJIeYS/SnLJWZPgaKG8nAuFxJW6LTPcNmzd2iAYC5IRLsG79VmSyhdF3jaKmuu7ui8lJ 2gBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yTb92251x+DtmUTSDWp2pFXRoCwhroQ3ngkruzpCgHo=; b=2f1fGRR56PWU3bGswiHzblEbEgAin/0Zc9hMblwDDb5Q9kqV0JF2Hqx3INAoWq0v3O KV+aa0m1QcuODXZs42KuPdFJH/Rl+Zj05iXUZGUm3G5mn5bUQTDECOjvSn/JgGI0MiAF Nsj24wDCHsJZR+UsR00dSYK2Urj625A7yMlviVj9OCaH3H7W0YKjPLp2dpYVgeG19p1a y6PRtfMgtrHzN/449DtLFDguhAnu9X41r49QJihLd0vyL56zZwx4nKEucwdRaZtXG8U9 ZE3yPfryASPXA6OI4eoE0SVFOcF7+IFAqxP3QJyBmRMxh+eZ/1gSTLrdysVJoFn0eOEi SCkQ== X-Gm-Message-State: ANoB5pn8rqhdr1EhHPyelt+bydkWwbglD8hdmM9MTpYEKiaaUGBlIdUb aS8ySFCc7oa9xHoLBcxWH8M= X-Google-Smtp-Source: AA0mqf7xKeIvxXK3uLjE4xhHyQsblirdA5TbHaXa0Ef6XHK7gJHgewbrJn4bcOfQElKreFq5+S81ow== X-Received: by 2002:a17:906:edce:b0:7ad:dd43:5d18 with SMTP id sb14-20020a170906edce00b007addd435d18mr3003227ejb.389.1668709648348; Thu, 17 Nov 2022 10:27:28 -0800 (PST) Received: from localhost (p200300e41f201d00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f20:1d00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id i17-20020a1709061e5100b007addcbd402esm669232ejj.215.2022.11.17.10.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:27:27 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Adrian Hunter , Ulf Hansson , Robin Murphy Cc: Thierry Reding , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v11 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Date: Thu, 17 Nov 2022 19:27:18 +0100 Message-Id: <20221117182720.2290761-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117182720.2290761-1-thierry.reding@gmail.com> References: <20221117182720.2290761-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Prathamesh Shete Create new SoC data structure for Tegra234 platforms. Additional features, tap value configurations are added/ updated for Tegra234 platform hence separate Tegra194 and Tegra234 SoC data. Signed-off-by: Aniruddha Tvs Rao Signed-off-by: Prathamesh Shete Acked-by: Adrian Hunter Acked-by: Thierry Reding Signed-off-by: Thierry Reding --- drivers/mmc/host/sdhci-tegra.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index e2a8488d4fa9..bbe2bc238171 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -1558,7 +1558,21 @@ static const struct sdhci_tegra_soc_data soc_data_tegra194 = { .max_tap_delay = 139, }; +static const struct sdhci_tegra_soc_data soc_data_tegra234 = { + .pdata = &sdhci_tegra186_pdata, + .dma_mask = DMA_BIT_MASK(39), + .nvquirks = NVQUIRK_NEEDS_PAD_CONTROL | + NVQUIRK_HAS_PADCALIB | + NVQUIRK_DIS_CARD_CLK_CONFIG_TAP | + NVQUIRK_ENABLE_SDR50 | + NVQUIRK_ENABLE_SDR104 | + NVQUIRK_HAS_TMCLK, + .min_tap_delay = 95, + .max_tap_delay = 111, +}; + static const struct of_device_id sdhci_tegra_dt_match[] = { + { .compatible = "nvidia,tegra234-sdhci", .data = &soc_data_tegra234 }, { .compatible = "nvidia,tegra194-sdhci", .data = &soc_data_tegra194 }, { .compatible = "nvidia,tegra186-sdhci", .data = &soc_data_tegra186 }, { .compatible = "nvidia,tegra210-sdhci", .data = &soc_data_tegra210 }, From patchwork Thu Nov 17 18:27:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13047171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F8DCC4167B for ; Thu, 17 Nov 2022 18:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233679AbiKQS1h (ORCPT ); Thu, 17 Nov 2022 13:27:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240291AbiKQS1d (ORCPT ); Thu, 17 Nov 2022 13:27:33 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 669618223B; Thu, 17 Nov 2022 10:27:30 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id v17so3791465edc.8; Thu, 17 Nov 2022 10:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GjUGr7WKyo0YyM9ct/ewI14Ht6+vUBDtL7iXa+tGFX0=; b=VE68DQNUA9fgfeoMtnDgLEvCxZz0nqb41vOxQQTq3Xukd/rKzPcOYZBnOFTssKsy45 gCNmF4edoyHWMBd0+s6VjZISHBYFD3bgvWW8mQMI/LXx6LtfxYSiurKh4e+3DmFcoXXk uSPJNaG4TSlH4O9CpZM4wi3C4zL/u1rTturVS+qeGNjvFGnN6ACRS3BAMmSpFZmwkHWC 7k2RTRemeRZn0KaPVRS1eKUxBGsC7IYqJAA5hmEnS1AbUerqnM69kuzvRRvIDgAvm0Nc 1dy5SoIYEjQ+7Nuf5M1/TIfZLIl+UlWggt3165VMGaf7Lwz/TF6GTJGbY9isv+4ftnqQ MZGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GjUGr7WKyo0YyM9ct/ewI14Ht6+vUBDtL7iXa+tGFX0=; b=VePBZxg8b1VlF9Y3jJk+TCBg50pkRs1pAx8twbDDQ5wlI/JOxjKnciNPbbcpqZnEmo qvuYNwnC43C8NgstFvgBMnsdQSM8hs83pbqhgKPfjdLnzLodtAzQYGfASYjT/3RwXxUp r+LJivFUIkmzk+VtAq+UV+1/7iu/WOJEqYWdWVxtmHVo2NykRmUj3KeApEzHXkwEJ1bo AKTaqABjdQNYYBMoKTNwHBK+whCQF2xVc2cYEqvyqIV3HGZvA/qNSGwFV8h6KCgA+S/b gutf3hoJEHAMxKVsJkq/XlEJGR59jkOx2b7HR0YDKNObOdkFEIwH8PfDNpetn1ykJXUX 2ujw== X-Gm-Message-State: ANoB5pkQpEpi2u1yVzjNUeBxUSeT2krix1luUNv6eNsN5fzX0JHRIT/F Bsb0cwQhv216eUSGpaag1uQ= X-Google-Smtp-Source: AA0mqf4pn3jkO2iFdyU1c2oeforNLqsajAxZI2ywZE8W88J8+PmEZ11WKha9e8CnVPvpFbdkXSe6Iw== X-Received: by 2002:a05:6402:b50:b0:461:5d0a:78e1 with SMTP id bx16-20020a0564020b5000b004615d0a78e1mr3257910edb.425.1668709649394; Thu, 17 Nov 2022 10:27:29 -0800 (PST) Received: from localhost (p200300e41f201d00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f20:1d00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id t5-20020a1709066bc500b007ad94422cf6sm670064ejs.198.2022.11.17.10.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:27:28 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Adrian Hunter , Ulf Hansson , Robin Murphy Cc: Thierry Reding , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v11 5/6] mmc: sdhci-tegra: Add support to program MC stream ID Date: Thu, 17 Nov 2022 19:27:19 +0100 Message-Id: <20221117182720.2290761-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117182720.2290761-1-thierry.reding@gmail.com> References: <20221117182720.2290761-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Prathamesh Shete SMMU clients are supposed to program stream ID from their respective address spaces instead of MC override. Define NVQUIRK_PROGRAM_STREAMID and use it to program SMMU stream ID from the SDMMC client address space. Signed-off-by: Aniruddha TVS Rao Signed-off-by: Prathamesh Shete Acked-by: Adrian Hunter Acked-by: Thierry Reding Signed-off-by: Thierry Reding --- drivers/mmc/host/sdhci-tegra.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index bbe2bc238171..1cb7fd3afa7e 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -11,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +98,8 @@ #define SDHCI_TEGRA_AUTO_CAL_STATUS 0x1ec #define SDHCI_TEGRA_AUTO_CAL_ACTIVE BIT(31) +#define SDHCI_TEGRA_CIF2AXI_CTRL_0 0x1fc + #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0) #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1) #define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2) @@ -123,6 +127,7 @@ #define NVQUIRK_HAS_TMCLK BIT(10) #define NVQUIRK_HAS_ANDROID_GPT_SECTOR BIT(11) +#define NVQUIRK_PROGRAM_STREAMID BIT(12) /* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */ #define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000 @@ -179,6 +184,7 @@ struct sdhci_tegra { bool enable_hwcq; unsigned long curr_clk_rate; u8 tuned_tap_delay; + u32 stream_id; }; static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) @@ -1566,6 +1572,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra234 = { NVQUIRK_DIS_CARD_CLK_CONFIG_TAP | NVQUIRK_ENABLE_SDR50 | NVQUIRK_ENABLE_SDR104 | + NVQUIRK_PROGRAM_STREAMID | NVQUIRK_HAS_TMCLK, .min_tap_delay = 95, .max_tap_delay = 111, @@ -1632,6 +1639,19 @@ static int sdhci_tegra_add_host(struct sdhci_host *host) return ret; } +/* Program MC streamID for DMA transfers */ +static void sdhci_tegra_program_stream_id(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); + + if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID) { + tegra_sdhci_writel(host, FIELD_PREP(GENMASK(15, 8), tegra_host->stream_id) | + FIELD_PREP(GENMASK( 7, 0), tegra_host->stream_id), + SDHCI_TEGRA_CIF2AXI_CTRL_0); + } +} + static int sdhci_tegra_probe(struct platform_device *pdev) { const struct sdhci_tegra_soc_data *soc_data; @@ -1692,6 +1712,12 @@ static int sdhci_tegra_probe(struct platform_device *pdev) tegra_sdhci_parse_dt(host); + if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID && + !tegra_dev_iommu_get_stream_id(&pdev->dev, &tegra_host->stream_id)) { + dev_warn(mmc_dev(host->mmc), "missing IOMMU stream ID\n"); + tegra_host->stream_id = 0x7f; + } + tegra_host->power_gpio = devm_gpiod_get_optional(&pdev->dev, "power", GPIOD_OUT_HIGH); if (IS_ERR(tegra_host->power_gpio)) { @@ -1777,6 +1803,8 @@ static int sdhci_tegra_probe(struct platform_device *pdev) if (rc) goto err_add_host; + sdhci_tegra_program_stream_id(host); + return 0; err_add_host: @@ -1873,6 +1901,8 @@ static int sdhci_tegra_resume(struct device *dev) if (ret) return ret; + sdhci_tegra_program_stream_id(host); + ret = sdhci_resume_host(host); if (ret) goto disable_clk; From patchwork Thu Nov 17 18:27:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13047173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB05FC4332F for ; Thu, 17 Nov 2022 18:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240291AbiKQS1k (ORCPT ); Thu, 17 Nov 2022 13:27:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240356AbiKQS1d (ORCPT ); Thu, 17 Nov 2022 13:27:33 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786628517E; Thu, 17 Nov 2022 10:27:32 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id t25so7185464ejb.8; Thu, 17 Nov 2022 10:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9gHvtmH6qGDFUgG9Xrttoa7AgeGSmg5n5XNiv/6s7gw=; b=Er3109dKYZA7GnJLjMn74fmBltDWu4fU7J95oOgkYHBdH9QYpjjr0BerGeMINPkfgh XttoomE7vlWCZ+BOq+rtelL/3nPG9qvv4dbltBuVvjwOhmkSk6V49Y3XMkz66IOL4R6Q qiuDF8XpiCFYo3zmIozavb7Sy1rGfLO9i9yS9Jt49sSZ40rXbks2Lwu5XQM2wNfLj7id fzOECDDCbw9oAGN/2ixUoL2TKRQhIPcvKe1c525ZhcH/3WqbfBs0F5q4q0m8pNuhM1Py aslu2SnPWWEfdSOP48UaMTfqg5sU0OWBna+mYT0Ft/Yajcyryc/DDrtFNL+ig68YsXMd Xf1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9gHvtmH6qGDFUgG9Xrttoa7AgeGSmg5n5XNiv/6s7gw=; b=UxQStkurdk0+Ddb0vLXjB6p5+DOvzFqD87PZvkXDE28JZuWtjWoNdaBhV1s7gw5IA6 gkvhEuR7sYucczTxCQ4W8Z5G1Nuz91bZtYn22t5m7QOnAvoZ987qpBvDoDZHvi/LagB9 YCTuhoTZBX67EBK2GyUbeGMerRT1IxzOZk+GteiwyuSE+gBTogS8eLL6pmExR/Kuqcw1 aZ7xrroNNYvzWiwdK2Ok9KniOEzqhLHqzikJ5cztOZ+aD5fZpnhFIniLqAhQyCtEeogN nv2FWhGfwxQbDpxrFzMCCBZ4AHBgyZcv+d8uPz8Iv841+G2QzpIKQ4mVNNmMzfkjQ3mm Lmpw== X-Gm-Message-State: ANoB5pmc4JZW5Q4RkNZHyY07ma4s+3bFkYEvCzCmVi9v9l5EPkG3FIVS 4GqMyFND368vBzaIeqf1LgI= X-Google-Smtp-Source: AA0mqf4C/XcXI5n2CuuQwC6i/qjB120KD7Gvl7BFChzq0rU9n3k2h57zDx8DzAPXCaoGo/L0TRgPrA== X-Received: by 2002:a17:906:4d16:b0:78b:15dc:2355 with SMTP id r22-20020a1709064d1600b0078b15dc2355mr3145426eju.306.1668709650695; Thu, 17 Nov 2022 10:27:30 -0800 (PST) Received: from localhost (p200300e41f201d00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f20:1d00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id r11-20020a056402034b00b004587f9d3ce8sm849384edw.56.2022.11.17.10.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:27:30 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Adrian Hunter , Ulf Hansson , Robin Murphy Cc: Thierry Reding , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v11 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together Date: Thu, 17 Nov 2022 19:27:20 +0100 Message-Id: <20221117182720.2290761-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117182720.2290761-1-thierry.reding@gmail.com> References: <20221117182720.2290761-1-thierry.reding@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Prathamesh Shete In case of error condition to avoid system crash Tegra SDMMC controller requires CMD and DAT resets issued together. SDHCI controller FSM goes into bad state due to rapid SD card hot-plug event. Issuing reset on the CMD FSM before DATA FSM results in kernel panic, hence add support to issue CMD and DAT resets together. This is applicable to Tegra186 and later chips. Signed-off-by: Aniruddha TVS Rao Signed-off-by: Prathamesh Shete Acked-by: Adrian Hunter Acked-by: Thierry Reding Signed-off-by: Thierry Reding --- drivers/mmc/host/sdhci-tegra.c | 3 ++- drivers/mmc/host/sdhci.c | 5 +++++ drivers/mmc/host/sdhci.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 1cb7fd3afa7e..3384bfd3585c 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -1533,7 +1533,8 @@ static const struct sdhci_pltfm_data sdhci_tegra186_pdata = { SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | + SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER, .ops = &tegra186_sdhci_ops, }; diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index fb6e9a81f198..ed59bb3247a1 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -270,6 +270,11 @@ enum sdhci_reset_reason { static void sdhci_reset_for_reason(struct sdhci_host *host, enum sdhci_reset_reason reason) { + if (host->quirks2 & + SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER) { + sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + return; + } switch (reason) { case SDHCI_RESET_FOR_INIT: sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 908da47ac5ba..ca7ede721523 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -478,6 +478,8 @@ struct sdhci_host { * block count. */ #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT (1<<18) +/* Issue CMD and DATA reset together */ +#define SDHCI_QUIRK2_ISSUE_CMD_DAT_RESET_TOGETHER (1<<19) int irq; /* Device IRQ */ void __iomem *ioaddr; /* Mapped address */