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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 633D8C4332F for ; Thu, 15 Dec 2022 11:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:Subject:From:References:CC:To: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=awHToiLJ0gZCyk7G35QkNl5Si4EPJ+tnG/NaugEw3Fs=; b=D3zlSoz7QLW/HK xdtkCIb9OfUjpHd13LakGAVqyX5nEgg/8Oeye1s69QNpTVJcFu7J7BkD0hrK4puPBSWYGvMIZ85al kbdGg0upfQZOlyNEGB8pcv4slz2WlU3p4G5sTQgZ+V+0pc7g+ot3WpxjM+vd8YEyA5Spdt5ILa+tu 8I5Ifi/1Fkdv+DZBhG3q/Io5yrcMNPOftlFPmTVoQPmkRZjKuXUboLwpgdSisMiLguiAK1G3lghRP TyHoNFWdYodjW2MUvvvTQRZYvwzwbaWDdb7KBHONE7i3u8nZYQPIexrU22r1p7+LixE0XTLZ3QYW7 P4TgpR6DsX1x/0ScKCug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5meX-0095JE-W8; Thu, 15 Dec 2022 11:43:54 +0000 Received: from mail-dm6nam12on2088.outbound.protection.outlook.com ([40.107.243.88] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5meM-0095Ep-1Z for linux-arm-kernel@lists.infradead.org; Thu, 15 Dec 2022 11:43:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3fj6ozGkzXoaEuUNPkxanWJYaEpKRhGI/YttSmu8/4MniFjZWUFGecocwV3cAwZ7OGsBkmMpZUal3YRMQbXp/cxIXRVb88v1n4o8yYCr1NO8lwx9Ps93U8aqtzuoov3U3Ex+5fwB2UmgGb8z04yOEfncDb8d/dT6kka6bQHPbsUEWjgwmVCwqB8Jw6ixNPfETW+oPUdBNKyCsZq50fkos+rHbWF8xviADf+gaK5z/13RhhpUMT6VES7fd3sjeYA/Pg1aYLpV5xz6ZEyVWs65JyL4uB5pQ02VJmsXZW6LynK3g+YjGTBC3KVmqa+jh33QUgiqiw8amW92vNmvQqOwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hygQluDrbEYEsG2HUez4W5BOIACkkPR6GJshBuCqOQY=; b=hiTYVZFL2JnSiG0SPlc33T4H6xHGL4lZI3c4RmkwA1wZpuESGwq2epaI5tefx6xiGKm17F1uLs2niu+ZgD4Ck3S4GE6Ika6kpYPYJJh3xq+WAxZ+m8h48+ItbI3H7h6P0UOh5N3s3+HzkP1anKFaxpu+AdbcWrX/uncgV2KsXmZrMwWeO/bfMB7IJTcSVFuY84Yo0Op3ATaH1Pvc3bDn1qe+dSNFVOLvLCOdBYvPtYVenWkjPGY195qB3qA3TXZrV4FlRL5M6FybVdQ3aadH0itk5/soeoGmAjWzeOak6e+U2XpPyVBOsA6mfpTVMPYgpTwBUh2uKiPWfzkwp+0H8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=denx.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hygQluDrbEYEsG2HUez4W5BOIACkkPR6GJshBuCqOQY=; b=snW9Y0rvboVJ3dwhQtMb6/pogpqj9q7+s5hQlJvcq4JbXkJSR47NuaPw+SDTFnwMyUK9IJeElJ6wsLJVoh9wEiESN3hbAs4VAHVM119IUQMDnWva5kkYp/1CBm2ka/YQ97i4nH1g3nuRKPqvJtbqOAJBZS3P6hOJ/RpBYpxR6CQ= Received: from MW4P223CA0001.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::6) by MN2PR12MB4270.namprd12.prod.outlook.com (2603:10b6:208:1d9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Thu, 15 Dec 2022 11:43:36 +0000 Received: from CO1NAM11FT087.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::2) by MW4P223CA0001.outlook.office365.com (2603:10b6:303:80::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12 via Frontend Transport; Thu, 15 Dec 2022 11:43:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT087.mail.protection.outlook.com (10.13.174.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5924.12 via Frontend Transport; Thu, 15 Dec 2022 11:43:35 +0000 Received: from [10.254.241.50] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 15 Dec 2022 05:43:32 -0600 Message-ID: <84c375ee-56d7-d885-c45c-0206dd80f010@amd.com> Date: Thu, 15 Dec 2022 12:43:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Content-Language: en-US To: Marek Vasut , , "Sai Krishna Potthuri" CC: Abhyuday Godhasara , Harsha , Rajan Vaja , Ronak Jain , Tanmay Shah References: <20221020200223.795142-1-marex@denx.de> From: Michal Simek Subject: Re: [PATCH v2] firmware: xilinx: Clear IOCTL_SET_SD_TAPDELAY using PM_MMIO_WRITE In-Reply-To: <20221020200223.795142-1-marex@denx.de> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT087:EE_|MN2PR12MB4270:EE_ X-MS-Office365-Filtering-Correlation-Id: 486106df-6505-4cad-6221-08dade9199dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: egemsvWBwAvZ52C06OnCTuXKskos3KT1l/xlMGXQ4mk1WC4okN5W0jcPak2VR312jDZymd8UZAvMAHE52T7yY+hmjuj3tAuyCpWyjCIASc+Z7EZhHVNXpn2xS6E3cviDAIZm2uRgNTH1WufpcBpPDaP2C6o7yvlm2qAyZkrxhfe2d6jyAn9F8XTwGmKxcW+3EQQb7YpSFl7WM5t1d6c0vf6VPaHoJbbJ1JqBJ1FyLWf/eH++QPTsfkstAn0dFITV/a8zEGbV0NPp8k9JylhuxRPovWcSjEr6zWEwEX6dONiteoA1frC54d7X0nAW/tSVnwm5b9kHHYT3GZcX+e+0WzWNBgYeTvxuma0uip2qNXUBjVZHELNaI+MIQ5t2Kx4E0oA6IdGyBpUL7E3mz5CVOYrDih6Sg5pBeaNszFOf2d+q4SSF83JyteqpLUKWd3ysLQk2+UecshZoj4pzTfIwcR/Hjgmx+i/3Mut3T2RY/xC5tqrHxkNdkHTbkaJM8DpiwPf3stt6NS8RSEQSgziVql+ybN+RZj/t36/XGY7qL+xy3zjia1Np4NjsBaRB84Pd0zW8YyqaKYFCY0uOJklggQOIg3BenXRYU9Tmbx/ggc4eNqPacUtzD/PUHrDx1wu5hTmmQifPwrwyqJKP4w77feWmSyD6ptrVRZb3eE0pAMnOWVMVH+yew62mZKYcaCecoV+O68ru5KtYGLYbR7gw6a/ZEnAJ7jAy6b/I5OpcvHyKZZe365TDq7NNJhQhPsZPLghOF+Gv4n71lwST5q0guA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(136003)(346002)(396003)(451199015)(36840700001)(46966006)(40470700004)(40460700003)(316002)(6636002)(478600001)(110136005)(54906003)(36756003)(16576012)(2906002)(26005)(356005)(83380400001)(36860700001)(82310400005)(81166007)(40480700001)(47076005)(336012)(16526019)(186003)(53546011)(31696002)(86362001)(82740400003)(2616005)(426003)(107886003)(8936002)(41300700001)(5660300002)(4326008)(70206006)(8676002)(70586007)(31686004)(44832011)(36900700001)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 11:43:35.7921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 486106df-6505-4cad-6221-08dade9199dc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT087.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4270 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221215_034342_145333_9DC685A6 X-CRM114-Status: GOOD ( 27.36 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/20/22 22:02, Marek Vasut wrote: > In case the tap delay required by Arasan SDHCI is set to 0, the current > embeddedsw firmware unconditionally writes IOU_SLCR SD_ITAPDLY to 0x100 > (SD0_ITAPDLYENA=1, SD0_ITAPDLYSEL=0). Previous behavior was to keep the > IOU_SLCR SD_ITAPDLY set to 0x0. There is some sort of difference in the > behavior between SD0_ITAPDLYENA=1/0 with the same SD0_ITAPDLYSEL=0, even > though the behavior should be identical -- zero delay added to rxclk_in > line. The former breaks HS200 training in low temperature conditions. > > Write IOU_SLCR SD_ITAPDLY register to 0 using PM_MMIO_WRITE which seem > to allow unrestricted WRITE access (and PM_MMIO_READ which allows read > access) to the entire address space. This way, it is possible to work > around the defect in IOCTL_SET_SD_TAPDELAY design which does not permit > clearing SDx_ITAPDLYENA bit. > > Note that the embeddedsw firmware does not permit clearing the SD_ITAPDLY > SD0_ITAPDLYENA bit, this bit can only ever be set by the firmware and it > is often impossible to update the possibly broken firmware. > > Signed-off-by: Marek Vasut > --- > Cc: Abhyuday Godhasara > Cc: Harsha > Cc: Michal Simek > Cc: Rajan Vaja > Cc: Ronak Jain > Cc: Tanmay Shah > To: linux-arm-kernel@lists.infradead.org > --- > V2: - Use PM_MMIO_WRITE to clear SD_xTAPDLYx bitfields and work around > the IOCTL_SET_SD_TAPDELAY design defect. > - Update commit message accordingly. > --- > drivers/firmware/xilinx/zynqmp.c | 29 +++++++++++++++++++++++++++-- > 1 file changed, 27 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c > index 6bc6b6c84241c..c0ff3efd321fc 100644 > --- a/drivers/firmware/xilinx/zynqmp.c > +++ b/drivers/firmware/xilinx/zynqmp.c > @@ -738,8 +738,33 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_get_pll_frac_data); > */ > int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value) > { > - return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, IOCTL_SET_SD_TAPDELAY, > - type, value, NULL); > +#define SD_ITAPDLY 0xFF180314 > +#define SD_OTAPDLYSEL 0xFF180318 These two macros should go to include/linux/firmware/xlnx-zynqmp.h > + u32 reg = (type == PM_TAPDELAY_INPUT) ? SD_ITAPDLY : SD_OTAPDLYSEL; > + u32 mask = (node_id == NODE_SD_0) ? GENMASK(15, 0) : GENMASK(31, 16); > + > + if (value) { > + return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, > + IOCTL_SET_SD_TAPDELAY, > + type, value, NULL); > + } > + > + /* > + * Work around completely misdesigned firmware API on Xilinx ZynqMP. > + * The IOCTL_SET_SD_TAPDELAY firmware call allows the caller to only > + * ever set IOU_SLCR SD_ITAPDLY Register SD0_ITAPDLYENA/SD1_ITAPDLYENA > + * bits, but there is no matching call to clear those bits. If those > + * bits are not cleared, SDMMC tuning may fail. > + * > + * Luckily, there are PM_MMIO_READ/PM_MMIO_WRITE calls which seem to > + * allow complete unrestricted access to all address space, including > + * IOU_SLCR SD_ITAPDLY Register and all the other registers, access > + * to which was supposed to be protected by the current firmware API. > + * > + * Use PM_MMIO_READ/PM_MMIO_WRITE to re-implement the missing counter > + * part of IOCTL_SET_SD_TAPDELAY which clears SDx_ITAPDLYENA bits. > + */ > + return zynqmp_pm_invoke_fn(PM_MMIO_WRITE, reg, mask, 0, 0, NULL); > } > EXPORT_SYMBOL_GPL(zynqmp_pm_set_sd_tapdelay); > I am fine with this workaround. Just for the record the way forward is IMHO to deprecate the whole IOCTL_SET_SD_TAPDELAY and create new one IOCTL_SET_SD_TAPDELAY2 and use feature check interface to find it if new firmware provides it. If provides use it and don't get to PM_MMIO_WRITE interface. It is our plan of record that MMIO_READ/WRITE interface should be deprecated. Once macro position is fixed I will queue it. Thanks, Michal _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel