From patchwork Fri Dec 2 15:26:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 631230 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 8F7ACC4321E for ; Fri, 2 Dec 2022 15:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233389AbiLBP0w (ORCPT ); Fri, 2 Dec 2022 10:26:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233332AbiLBP0w (ORCPT ); Fri, 2 Dec 2022 10:26:52 -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 D31F7CFE63; Fri, 2 Dec 2022 07:26:50 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id vp12so12321471ejc.8; Fri, 02 Dec 2022 07:26:50 -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=e14vmcIMdCGeDCCsvjNA18WeSIg6j6mtLwuur7IIU+k=; b=Wo285BO/721PWAYj15qfo9b13dYOBqV9yq7NYdJJqZddw7cnvioHdb9vWP8jeJ9hY5 xfU1KLLgs6Ojb0fOkkDHyZrRPyemn58ZScZ4bw6NEUzIMN5o8/gYbpnCSwPV1QGHzGWG nmu3gtwSINzDiYpB/zMksVpjStsSU+k7twwQaTc9HOPcKnlNlBJ0lMSll4qEJUpfJ1eo MUJ6QjfhC+ecaeNx3rbrlSK1fouQ17H1FvcEyzDBfpZcMV5Q88ZP/3oL8Asw7y1ElRAz xLJ33C67xggzDGikUCOitCRaZDBrF8j56M1hk1kQgS+pdT4XJubUVKAvbZ0EX5tfx5zU 1gpQ== 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=e14vmcIMdCGeDCCsvjNA18WeSIg6j6mtLwuur7IIU+k=; b=RCP7HGZQteNX+D1+9DjGbWc96DeA7PDOB9/DWn3m8nqfsboCjLhalvXiiTcZPrDOYk Gc4Qx/0anSIxWxbscfb4huJ8gUv/og6PnOTJYlvjSp6dhPeOhnfN6LtMTuDoaEsgyFhF MApaX94inZxXugcLhPMH0lKGVgSlzVqM32IcF7ylPtBE2IV5Z6vPmSag69S0pcgqdaAK DsGuOmWVX+/nzrQ1VIfIOwRZFcEQAXEpwSZH5O5k4qGWZ+wHYgE7+SAplOYrPefUPKBZ f2otpkcdoe490rNWAVInm5V44KflE/nyTU5hvnLdJz302vrCcN1kkSgdLGXnc/68Uq0/ QvBg== X-Gm-Message-State: ANoB5plCi7eL8KSLPJnp9JSkpjr+ueavYsJRf9raeC7KAHI0hCjmFb5j YHxEsZOAXWiMbgYH/P9cgUw= X-Google-Smtp-Source: AA0mqf6oCzTeSo7xY47G/Tjr3MvqWWirxM+oqGCDmV+NBKOJ3PloaH8CuQ1sZ7WtYu1sZIVw1lIGTw== X-Received: by 2002:a17:906:c40b:b0:7ae:1e53:95b2 with SMTP id u11-20020a170906c40b00b007ae1e5395b2mr59446368ejz.333.1669994809240; Fri, 02 Dec 2022 07:26:49 -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 ta17-20020a1709078c1100b007ae035374a0sm3164454ejc.214.2022.12.02.07.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 07:26:48 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Ulf Hansson , Robin Murphy Cc: Adrian Hunter , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org, Joerg Roedel Subject: [PATCH v12 1/6] iommu: Add note about struct iommu_fwspec usage Date: Fri, 2 Dec 2022 16:26:39 +0100 Message-Id: <20221202152644.29450-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202152644.29450-1-thierry.reding@gmail.com> References: <20221202152644.29450-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. Acked-by: Joerg Roedel Signed-off-by: Thierry Reding --- 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 Fri Dec 2 15:26:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 630524 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 03DDCC636F8 for ; Fri, 2 Dec 2022 15:26:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233541AbiLBP0y (ORCPT ); Fri, 2 Dec 2022 10:26:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiLBP0x (ORCPT ); Fri, 2 Dec 2022 10:26:53 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B841CFE62; Fri, 2 Dec 2022 07:26:52 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id vv4so12310845ejc.2; Fri, 02 Dec 2022 07:26:52 -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=eGHB6tdBRBPjrl2PVp3GLnf15MzJQhjBnIOQJObZPmLIKb4TzWTJBJ9GMWEmX5vpo9 r99zYspTSUndyWjqW+r479cyRrT682YVfiYMbV7A2NxpOmBIcfV6521de2L5qdYvZUYL Xsf/S3byP3KKemkRlO0E0qbs0TzzRdJywdZTX2E7HpeJvpEgyPxwT31/l/WDiq94008k AmfMTjKG0e1bhd54oMRiRNjNqPqS9rKJXP3ZbqvdGj9o70DPb1S33F1Q/zCtbXOJXKbz 6BVFVTTMHK36/aLmnSLtWJw5s2iXtdofUe5IUGU1rRiU8TB2wtV84AlrQXZG9EFhinmf rXVA== 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=OAb1BfJhawnPHrkMEK5wtQGRoZqgK6Vz2bPFHXwzcvH0eqma0zYlXqFm17WOlclNXH HbF2/re5AOG3zlE4zYaufbrRf4/xp9My26HH3vhwBwy+p+Ubycdh9PVJmIukPRoXsyBw v2coQQ0Q3eiX71bKlFqWfajDNdA9PYUvKcPXODzp9gI7tlHybhE9sqIQ5kGe42RRQT6N rAWc2NnpLrgwkSmnoWPS3tXOqnf8+ROWouewmNpx8LHV+E5NJRUZ9lH/pTeTsp6YxauE dvZb3gKXFAvWD86pOcQTXZEG8hUNhNQc6jdCal7LwGuAB1C+3h8GeOHjiR+lLkuNkwmo 9U1Q== X-Gm-Message-State: ANoB5plt+RPjk5AqcoJR396IfFslr9g4O7csV1upAHx00kmAEpoIK2ZY Kuxn3qERcdol6FKZX9vCisU= X-Google-Smtp-Source: AA0mqf7CGmeR68IkFAhvIdJzrxBnPV/WlIzW6f5GgQazUYTy4/IPjmNLCvwKhjXmKX+8OsEartC+eg== X-Received: by 2002:a17:906:6a0c:b0:7ad:9f03:aa46 with SMTP id qw12-20020a1709066a0c00b007ad9f03aa46mr45647632ejc.175.1669994810368; Fri, 02 Dec 2022 07:26:50 -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 c20-20020a056402159400b0046a0096bfdfsm3057372edv.52.2022.12.02.07.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 07:26:50 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Ulf Hansson , Robin Murphy Cc: Adrian Hunter , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v12 2/6] iommu/tegra: Add tegra_dev_iommu_get_stream_id() helper Date: Fri, 2 Dec 2022 16:26:40 +0100 Message-Id: <20221202152644.29450-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202152644.29450-1-thierry.reding@gmail.com> References: <20221202152644.29450-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 Acked-by: Robin Murphy --- 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 Fri Dec 2 15:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 631229 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 49511C47088 for ; Fri, 2 Dec 2022 15:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233279AbiLBP1E (ORCPT ); Fri, 2 Dec 2022 10:27:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233545AbiLBP0z (ORCPT ); Fri, 2 Dec 2022 10:26:55 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 662EBCFE67; Fri, 2 Dec 2022 07:26:54 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id b2so12327317eja.7; Fri, 02 Dec 2022 07:26:54 -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=oSPEHSYmi4vlcGVbczR4I6cGH/dyxfXxCF0BQRo95CI=; b=EkqSCjXLPAcY5hECGJeH97TDy4+9gHKZQdYLOUPDw792oRA2oUe8skoF1OoVvwTqvk Jc4doB9qCP+hOtw3qp3c+2DdNsrWUO/TZGcRI90WeCPvevH4f4nkPXIP124S5Ph3N/Xv eOxOI1V4i4Ep3XlZS856CYligI6aIdhnKQjqhB0qozS5hfQW9Y24/vqcik7W4d0LX4pw 5mRuHPN2T6ohkHaUBNyEC3kPmRXXQu+mRESzPTAGdDQfgjc2SJRs1VrwJAH4PkXQgp78 UAgHjPE0aSLW47AN9m2eivkcHvzYWPxkuctEiEuMj6qN44bGUNEb1L6PZ7G/lVtlFNIH sV4w== 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=oSPEHSYmi4vlcGVbczR4I6cGH/dyxfXxCF0BQRo95CI=; b=dGqDCLoumGRZL5B+uQyL2zlTperdkvPjAskZIMhKCW6NJtYwRogg5P+93aj5LeHuYL SlMVn0GlfLCN5buD8rAqi5hfjJ7mZPwV4DcWkU0OKMb8dWeKdg94174JLh0ESufVLSTP MMb38hHPq2xLhpEoQFcv9TmWIxVWtvQKLrgpGSSf3ru66Cg6uLo0AnrXlnqyRE6bwqC9 anI+ySHz5Z5N6v8U4Yowjc43Ix16z0oD43wVuJ7nq+7SYFbV4LFQqhfZFczDDly72zWQ EysTWt9q3FV73hh9fDEGb51sti18NHDyyTKGQF7rA3zhePQHhQR4ughDsobjFOra9xW0 gwGQ== X-Gm-Message-State: ANoB5pmKbaAChJGo5u5isacC01m2M+eiTan1Wzuop5CKX2k1Pt7VJMIm 0MOLygEcwizlEn/ftdE7gq4= X-Google-Smtp-Source: AA0mqf4YzA6rYqJ9/n2IsfEwxQK762QnL559L95HzIwJrjNNnR9Ygm8zuD1MyIeKgDXovGdzFzvCww== X-Received: by 2002:a17:906:39c8:b0:7ad:79c0:5482 with SMTP id i8-20020a17090639c800b007ad79c05482mr50981225eje.730.1669994812806; Fri, 02 Dec 2022 07:26:52 -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 ky1-20020a170907778100b0072a881b21d8sm3103086ejc.119.2022.12.02.07.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 07:26:52 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Ulf Hansson , Robin Murphy Cc: Adrian Hunter , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v12 3/6] mmc: sdhci-tegra: Sort includes alphabetically Date: Fri, 2 Dec 2022 16:26:41 +0100 Message-Id: <20221202152644.29450-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202152644.29450-1-thierry.reding@gmail.com> References: <20221202152644.29450-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. Acked-by: Adrian Hunter Signed-off-by: Thierry Reding --- drivers/mmc/host/sdhci-tegra.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 9fc8a61eca54..afa9cbf9cb6f 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -3,28 +3,28 @@ * 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 From patchwork Fri Dec 2 15:26:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 630522 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 2A8A8C636F9 for ; Fri, 2 Dec 2022 15:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbiLBP1G (ORCPT ); Fri, 2 Dec 2022 10:27:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiLBP04 (ORCPT ); Fri, 2 Dec 2022 10:26:56 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735A5D03A9; Fri, 2 Dec 2022 07:26:55 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id v8so6950737edi.3; Fri, 02 Dec 2022 07:26:55 -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=mCJXfYzTI2dyLGbCy2BhHsRfkj/QAMNTLWYIlL2SJZ0=; b=hSRF5F3oUfAiQnRWAfNrjCkA2x0vFkvX3Xh8Xo+larZW6oE0taUlK1CsKplyHMUqvp 0W8ksnnKDt6WQ4QEmCxSI7Ndx4rwXjpKpJyX99Qlv8nMV9WVuOwoZWRYvyN7J5d07o1/ /GLNQHGeCUdCgrsY+5fwuJ5ocfyZrSwKDaJGJSEZc4sLB/7OKUeWODwerIXmXNexgnnu T67JP1TywcNmjJa3JWfjmMA2c7xqdjwyqhMD2jYZalCrdyK3JOl+uJpexc9zSdhRhHup venRjrPshSEPRlOWYuE+g/FOB9R/Sxjo1kzyUQXVP7ysMcOWRhZU9Ni2xBYMUGyR+70c K96Q== 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=mCJXfYzTI2dyLGbCy2BhHsRfkj/QAMNTLWYIlL2SJZ0=; b=d0towj+2aByh5gPg82mBOkFztV3aJ6brXToqTcaOQ6yQzqQOYnLPyJ5HfINYVrXYNf r/EbsvdtxR+oFT0Crc63QHQ8f7nWBRDq/DQewxr7JFrCxukG1ad0MOysG2DBeIT75bxr JamSXsBSdhau5cCoYp7s3aYdcrgxWYm9eJLO0S8rkMdgfVSQUg7KCiFtCUxC1BPjPLdK KXGXhG61v+R0tsTnHYLls+L5iPFp5Rr7WFtTUx+i/3SmKr+hg4QHmLlu1jgjZye96NyD gPIDi5NOMxFaG0cs2mOOYdT6M5hryoL9dKNbPE7JtXobSrd/yT1iQ+Ja8FT28rPgr9iR zxRA== X-Gm-Message-State: ANoB5pktzjKJ63iU68CtysmezY64TNL8ywYiftrDaqJKwZQGly6Fnhkp ECfFwaWQQr+eOSHpEeSwgfg= X-Google-Smtp-Source: AA0mqf6fGwGlYMveTxFx5oIgPKUlZyWXB66dY7F1HfxGeQpDVnjRaFtUuebSZkAkbRc4dY2dNZBh4w== X-Received: by 2002:a50:fc10:0:b0:464:2afe:ae18 with SMTP id i16-20020a50fc10000000b004642afeae18mr66132715edr.183.1669994813911; Fri, 02 Dec 2022 07:26:53 -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 q2-20020a17090676c200b00770812e2394sm3104389ejn.160.2022.12.02.07.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 07:26:53 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Ulf Hansson , Robin Murphy Cc: Adrian Hunter , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org, Thierry Reding Subject: [PATCH v12 4/6] mmc: sdhci-tegra: Separate Tegra194 and Tegra234 SoC data Date: Fri, 2 Dec 2022 16:26:42 +0100 Message-Id: <20221202152644.29450-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202152644.29450-1-thierry.reding@gmail.com> References: <20221202152644.29450-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 afa9cbf9cb6f..f3f5a4abcafb 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -1553,7 +1553,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 Fri Dec 2 15:26:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 631228 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 2A724C4321E for ; Fri, 2 Dec 2022 15:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233607AbiLBP1F (ORCPT ); Fri, 2 Dec 2022 10:27:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbiLBP06 (ORCPT ); Fri, 2 Dec 2022 10:26:58 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B81D20BB; Fri, 2 Dec 2022 07:26:56 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id td2so12328829ejc.5; Fri, 02 Dec 2022 07:26:56 -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=BUewn1AUNXCDBruRDFsIE2JVfskfTWK9MuOJPLZRYu4=; b=YSfn9CZ+iPnRjoD7FvrtKCcEI201HWqkaAShkXgrw5hhzs86vVLEldXbjzsCO/XOK4 9cBcXgjU91/iNYAweTU8cyix01yDGjmLZ4JynBQDj1/1EmJc3q9EhaKqqwtVjA1qdOZX YuFHSA3VW6apeEMJA6jYHaA4GYg45YkVK2HylNYT9wFq5ZssmPz4pEEVMTntXhlEa+WR z7wl1qUSSs60B8hwaFoqZGiR+g+ujN9PC3ZF8WsxQPAn36RGPbyV2/n50bDaMNcwyRhY NjjBOrrQtkUMIT29lYBujjBADDnj1RZhgRTdMV/zv1WmE6p8mHtydEc03kWW/MXt0nW8 wyqQ== 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=BUewn1AUNXCDBruRDFsIE2JVfskfTWK9MuOJPLZRYu4=; b=e5aoB38p4ZgWL3FoC0SQteHcW+mrXKWM9S9YMFRwVB1jpWGpH8J07THUVfgIWFUMzN 6Mty5tdQBMyTh3gx4J9Kp2QvatieZMeu3BPKdw5f0OtBj9mS4/Ca+nR1rwfPaF1Ru570 qYQ2eQzzVcclcieoB3XCh8Vm1aBafo5t5Ygc2wW93MlzdaEnycfiB9KZGfkFW3aus0vf AxDSz1qIJEeNkwFRphjsmW3FbVbv/gCjW8b05DVbOMcAHr78Biuj7Vf21m1YcvCHuIwj 37RMnEKvn6G4yj7W5lco6erJvmy/XdVBcoU4VxzxQT+h2T+1M4Q+euwy1/MfXGOhOAqy vREg== X-Gm-Message-State: ANoB5pnu57dekNFLeFnsV28DZ6OO53LGUY5eeHIMGoN+UDqJWP8+McSn iijfFBMkeWFVEup8uK2bnb8= X-Google-Smtp-Source: AA0mqf5FnUj8gBTFrpkAkp5Y6sXADRVjcNARijz6JjiUjFT1/xTC76FbssvYEjEq5ls46zjhXj/Dtg== X-Received: by 2002:a17:906:a157:b0:7a5:7e25:5b11 with SMTP id bu23-20020a170906a15700b007a57e255b11mr59867283ejb.254.1669994815018; Fri, 02 Dec 2022 07:26:55 -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 dn11-20020a05640222eb00b00462bd673453sm3073741edb.39.2022.12.02.07.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 07:26:54 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Ulf Hansson , Robin Murphy Cc: Adrian Hunter , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org, Thierry Reding Subject: [PATCH v12 5/6] mmc: sdhci-tegra: Add support to program MC stream ID Date: Fri, 2 Dec 2022 16:26:43 +0100 Message-Id: <20221202152644.29450-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202152644.29450-1-thierry.reding@gmail.com> References: <20221202152644.29450-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 f3f5a4abcafb..c17700fa9899 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -3,6 +3,7 @@ * Copyright (C) 2010 Google, Inc. */ +#include #include #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +97,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) @@ -122,6 +126,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 @@ -178,6 +183,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) @@ -1561,6 +1567,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, @@ -1627,6 +1634,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; @@ -1687,6 +1707,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)) { @@ -1772,6 +1798,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: @@ -1868,6 +1896,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 Fri Dec 2 15:26:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 630523 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 A4EC9C47089 for ; Fri, 2 Dec 2022 15:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233565AbiLBP1E (ORCPT ); Fri, 2 Dec 2022 10:27:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233635AbiLBP07 (ORCPT ); Fri, 2 Dec 2022 10:26:59 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5B13D0390; Fri, 2 Dec 2022 07:26:57 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id fc4so5378237ejc.12; Fri, 02 Dec 2022 07:26:57 -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=1yABTotUF1aHfY2MvDhzL0Nasx3orq8o9ESsBCAmUe4=; b=LQOtUd70pxQF/PYBI+E7Ast5RY8z/1CQLkbm0kM3GR6fjttSEg9vUcgH9JB9/fCQrF SMVbuN1a364G1jwA2a9nzy8MVHfY3vPAe9D9sO+xJxGNQg1lk2mBI4b0jlK8wKW+2wVe t/QB9Uh96vYG9zrPGwE53IG/zdhGnQfFuVvNCQiRfJ1OhahG5VUY3QoHK0Op6amzmA1T 4o9BK0OK18W33uPmC8qw1i2z23CtdFTh8x35RwMHetjTdZxmfyneFr0kGoEk22jweqrw Ql8xIJlowkCw2viJBvSyYE/ofgB9wec0mcXXhGiglHBAhF3bYYawjwCh6aONR6cVD8kk +kbQ== 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=1yABTotUF1aHfY2MvDhzL0Nasx3orq8o9ESsBCAmUe4=; b=WNbeMkN68O6LIpalJRifYwYVE9bgwNJT1r36x9S25hP6LI+cNCrG0FzIiOYTc5Zqhj RhAaPNh5k/c2dYi8pE9zWWX/1rNhDBnKYFcl6FpxqdnIOrXuUXMNTjbGexwk7lXX9jT5 6T6PfATOQhzMEC4O4UKROOnYdQICKXYZH3SiJo6g7h5346VbE0opr16V9YT8rJBFPzPw 7zp/iBpNanO37EExm2NDLPvtLvZSDqf90dk/MU1g8ECSTs7Iel48tFov/B3BQpuSOJWf fG2E1/zUKJ6b4lotuLirZNuyLL/DNs4Vqir74pzOaeTfCk6uXVmGceajr3q6yTnnzusH 2/tA== X-Gm-Message-State: ANoB5pkD6G69QJ+eQJJtrqKD1g/U9FBzJvBtFI4Q3ulznORSt86agTXp FuHyhavZhumxujiUAqGKr1A= X-Google-Smtp-Source: AA0mqf7fF9YbsaKeHpA/1+LF6sgvUbDCFvfeZvxpbLCimbL4kRbRCVmTwTsIy6UffpRKqhriTPD8DA== X-Received: by 2002:a17:907:3f8a:b0:7bf:4ae6:c36 with SMTP id hr10-20020a1709073f8a00b007bf4ae60c36mr23176828ejc.674.1669994816065; Fri, 02 Dec 2022 07:26:56 -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 d18-20020a05640208d200b0046150ee13besm3001605edz.65.2022.12.02.07.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 07:26:55 -0800 (PST) From: Thierry Reding To: Joerg Roedel , Ulf Hansson , Robin Murphy Cc: Adrian Hunter , Jonathan Hunter , Prathamesh Shete , Will Deacon , iommu@lists.linux-foundation.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org, Thierry Reding Subject: [PATCH v12 6/6] mmc: sdhci-tegra: Issue CMD and DAT resets together Date: Fri, 2 Dec 2022 16:26:44 +0100 Message-Id: <20221202152644.29450-7-thierry.reding@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221202152644.29450-1-thierry.reding@gmail.com> References: <20221202152644.29450-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 c17700fa9899..49f60e292551 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -1528,7 +1528,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 df1c1d10a338..81f4fed11629 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 b6f31a7d6152..605eaee805f7 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 */