From patchwork Fri Sep 29 07:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 13403779 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 C398FE743F4 for ; Fri, 29 Sep 2023 07:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbjI2Hp3 (ORCPT ); Fri, 29 Sep 2023 03:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232606AbjI2Hp1 (ORCPT ); Fri, 29 Sep 2023 03:45:27 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2048.outbound.protection.outlook.com [40.107.20.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC5DA1A7; Fri, 29 Sep 2023 00:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S8uXqPoVH8eIQRp1PE0u9WwuMmdNwYbUzsd7zfskxjuV0db1BjcEz5xYTexXfcZ8NuJKaAkKCjBk1CgnmXa7xC0CqFRxKr0QkBYzplNdHBGrgPC/9q4Z6Pc5Fd2d8kmIhOVkdN/yIYdmRl6xwb3Amt45+Y2KQb2A0dBkmLB+NXetOlARuWFVutTN8QprwoQSPIx2kC1cRKgd1tD6iEnwq1B3GMCp+mbFg9UAuQWUMA991gAfGXmKs9wItcf57y3DAebvkce06ddNBhhwb87JdNAxPQmXxe4SkFYbpyotiUripQtU4YO3VhwEla3HrkmCR+YDVvDQITKAuuLf/rynug== 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=6Uq7HsJO9/a32sMOp9mjH3Oru3eRABhG9sDr50c7ACE=; b=IpQaoR/xRQTdX8Ph6Co5/1Ox1pZ+s86s41b9owRYIbefcCBrnaybr3FJh9OxvvrUr+x9BPsJkgOzOwJ3Zad9kHeNCEX3JyO9qEgRGLelWYw/zOJGWAirUh2ClrXpChcw9gAinK0lbZtskYVuP5PEXXY2dqkQGL02KkqNh5TtEiInek3Rx3BfVMHHq1iafP5762nwxtoD84kIkMTbedIsv0QWPb1G0hSJFwd1jMX2WeSueKQj+voJg45n07IVBXiBPghglXvFZm+UGUSfQMAoZTi1xazHmF1dBpMeCmGeN46EOD1dvB+kWoQaib43ObEznHqN3JSuEWPZ3w6zr+A6Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=linaro.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Uq7HsJO9/a32sMOp9mjH3Oru3eRABhG9sDr50c7ACE=; b=G0jZLixyts5KDtzYkGE+0XqhTNgNSR9NdkMbhMvh+zpi+B0oeZOGkG2gputlL2XMWtJZ/wF6EDtudqMEvEzQ13FsXydD8FJm60biGtnIHV92mjOpkOOIbGX6YEgCEIueQrIzgvy+7hYZ4JItYEbySVcQaBD6LS4Y01zp0KqYt1c= Received: from AM6P192CA0106.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::47) by AM9PR02MB6706.eurprd02.prod.outlook.com (2603:10a6:20b:2c0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.36; Fri, 29 Sep 2023 07:45:22 +0000 Received: from AMS0EPF000001B0.eurprd05.prod.outlook.com (2603:10a6:209:8d:cafe::4b) by AM6P192CA0106.outlook.office365.com (2603:10a6:209:8d::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26 via Frontend Transport; Fri, 29 Sep 2023 07:45:22 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001B0.mail.protection.outlook.com (10.167.16.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.14 via Frontend Transport; Fri, 29 Sep 2023 07:45:22 +0000 Received: from SE-MAIL21W.axis.com (10.20.40.16) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 29 Sep 2023 09:45:18 +0200 Received: from se-mail01w.axis.com (10.20.40.7) by SE-MAIL21W.axis.com (10.20.40.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 29 Sep 2023 09:45:18 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 29 Sep 2023 09:45:18 +0200 Received: from pc45945-2140.se.axis.com (pc45945-2140.se.axis.com [10.88.125.80]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 5FAD529E0; Fri, 29 Sep 2023 09:45:18 +0200 (CEST) Received: by pc45945-2140.se.axis.com (Postfix, from userid 10564) id 5BB1F7124470; Fri, 29 Sep 2023 09:45:18 +0200 (CEST) From: Vincent Whitchurch Date: Fri, 29 Sep 2023 09:45:08 +0200 Subject: [PATCH v2 1/2] mmc: core: Always reselect card type MIME-Version: 1.0 Message-ID: <20230929-mmc-caps-v2-1-11a4c2d94f15@axis.com> References: <20230929-mmc-caps-v2-0-11a4c2d94f15@axis.com> In-Reply-To: <20230929-mmc-caps-v2-0-11a4c2d94f15@axis.com> To: Ulf Hansson CC: , , , Vincent Whitchurch X-Mailer: b4 0.12.3 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001B0:EE_|AM9PR02MB6706:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d1d4149-2c80-492f-d003-08dbc0c0092f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u1oSB4ap8MfRZoRnVvE6ejkUyHd0RkqbXdd8wGw5vVutM77jWjgDHEWHvprAvNxp9SsqG2FYx+kR0fBZCWAawVuO7lry0pOxjx2I5hm3ahJnJ2CsFwQhzqWNvUsJn0DFsqoNgFi/dGWgSso+t1b2/xml+lmxP2U8dZJdOApYqbNrXyC6dp5mjiP3BA4k5K20GBXkn8mQGobeht72PnMrjjQbobqshFXfkGbt1gIa3aSDtHrwqIwQ8C0LlRNVnB/Y3DOKB/Hvh6SPCQcji8i28zERvaQazn6/2klgX4MV5T9S3ROXg2Oeyvc3+iESDwN/UjbXNFzCVQmQFIFUmM8w2s6cFH4hqTHuClNLYBiUlZ+u0PwL+HQ8wHoR/wcngn+VFIAjrFt4HvKrdxcCiW+2xDpSccdMxK8Ah+1V37+X/H7Yvrf9Yr5XxCq4SdZUAyrH5nS9tiUFbpbiDVt0qNPW61AhHLgtf2g0HmJlcNRfOtzV1YUP+S80dFeYzDUMo0PHn8/HFn2IWjflMkrxdPyRoVg7ZH+V7aptGAIo93WNeU66Tt8S0//+SC+SrD/0Z5ttorfZ8dnVzbQWslfBuJ9qy60lJ8CNFfs9TU1Gcj570QTPqcX7yMZ4YgAxm2snE3BUawdD3rkRqVEbNVc4VIN8pKfCqiDPvtzu9d6eVLGBDT1+9qJJAa5/czK2IZ1B4San+NNMsXocQPqpwEjT2e8W33nsaeQVkC5m22ROBC9KSTigI9b993WI2RxkpTBZ6+/TZR/+t7+fJ+BmtEHZOu3Xvw== X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(396003)(136003)(346002)(230922051799003)(451199024)(1800799009)(64100799003)(186009)(82310400011)(40470700004)(36840700001)(46966006)(40460700003)(40480700001)(6666004)(478600001)(36860700001)(86362001)(82740400003)(81166007)(356005)(8936002)(6916009)(316002)(2616005)(83380400001)(107886003)(6266002)(426003)(336012)(26005)(2906002)(36756003)(70206006)(4326008)(8676002)(41300700001)(54906003)(42186006)(44832011)(70586007)(5660300002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 07:45:22.3126 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d1d4149-2c80-492f-d003-08dbc0c0092f X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001B0.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR02MB6706 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org We want to allow host caps to be changed dynamically via debugfs, so for these to have an effect, ensure that the card type reselection is always applied even if the card is old. Signed-off-by: Vincent Whitchurch --- drivers/mmc/core/mmc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 89cd48fcec79..d372e2098ffc 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -419,7 +419,6 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) card->ext_csd.strobe_support = ext_csd[EXT_CSD_STROBE_SUPPORT]; card->ext_csd.raw_card_type = ext_csd[EXT_CSD_CARD_TYPE]; - mmc_select_card_type(card); card->ext_csd.raw_s_a_timeout = ext_csd[EXT_CSD_S_A_TIMEOUT]; card->ext_csd.raw_erase_timeout_mult = @@ -1732,6 +1731,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, mmc_set_erase_size(card); } + /* + * Reselect the card type since host caps could have been changed when + * debugging even if the card is not new. + */ + mmc_select_card_type(card); + /* Enable ERASE_GRP_DEF. This bit is lost after a reset or power off. */ if (card->ext_csd.rev >= 3) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, From patchwork Fri Sep 29 07:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 13403778 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 3AC00E743F1 for ; Fri, 29 Sep 2023 07:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232679AbjI2Hp3 (ORCPT ); Fri, 29 Sep 2023 03:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjI2Hp1 (ORCPT ); Fri, 29 Sep 2023 03:45:27 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2081.outbound.protection.outlook.com [40.107.105.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1E91A8; Fri, 29 Sep 2023 00:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N+eXxXFxdGKMBC1WrS9sCYkiLizQuEDfyeWP1w0ukICqE9BpK5US7Rz7C9dvWNcaJKgaVamnCNGK7ySMaNyRY+9UnKGMbQzqj28um9Z9AyMrPrMs/UxAjdWxWHGp7MC3R8c8gQYLyW7cu9SfigWXvXM5kD84Gt0Ba+z0cP5X1ucxfUvS/qM1egUHA5vOlaz9GFOSDP7MVsdoAL1paRsSj/NhUs1uh+oPh64DMSdCef3udiEPpjXp+KwtY8E5x1XHPhCXdfkdt4DYeNqXP7k5QI27qlki4p+UkTgZHnMhuEHjOrChhzGNDkC0deQM3jG5e4ON68FWI2LJzRHj9+Z6GQ== 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=XCkbBxXVt6OagbPZG0fqwWIlqmcUQmCg3s909KOvWZw=; b=MLOcMAqNOhgOPOei3zIlHnlwZ2jQxjULHEoha2A+ufwB5WimgbynAY6qK/tNcgaeKoil3c4MfINcPfDPlHncNA82foF6F7ibB5+UgfSAUEPJsuadMRUZOuXl5MygdsUxC5CI4O2TtykW9qniU9BPtI4abhgnm6sx79wzvyRlQ81895ZXRdPEk7PgQVcJ9ecLZy5CQEe9RhTvn6GmvfA1KJGGt73rBFeEog7vXAHPuBw0vVkz8IzJhK7+Z0f7YqFptTY6CRIZ2YwMd1LzqVqBPWnRQrISGmLHMwW0U1qkY2SIjGWPgQb8k1+Oar4ezab0vF1+akv4/tJ3hawpJbCKig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=linaro.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XCkbBxXVt6OagbPZG0fqwWIlqmcUQmCg3s909KOvWZw=; b=QP+71y8SiPK3PrkTVIFCRWOW0pfhhaGotKIoVNx4aCtMeS0oqPJUXRTbAxtLJFErK1Os0TWfxDoypd0fRNmZhJ5zRc9/cuI/rO6+ARaNDLTzhsPmTvrYhpwsDpJez3JY+yl9NgFr65MPOeU7dqSlfri3fM9twVyARmObLyJGFsE= Received: from AM6P192CA0086.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::27) by PAVPR02MB9643.eurprd02.prod.outlook.com (2603:10a6:102:300::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Fri, 29 Sep 2023 07:45:19 +0000 Received: from AMS0EPF000001B0.eurprd05.prod.outlook.com (2603:10a6:209:8d:cafe::d) by AM6P192CA0086.outlook.office365.com (2603:10a6:209:8d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26 via Frontend Transport; Fri, 29 Sep 2023 07:45:19 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001B0.mail.protection.outlook.com (10.167.16.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.14 via Frontend Transport; Fri, 29 Sep 2023 07:45:18 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 29 Sep 2023 09:45:18 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 29 Sep 2023 09:45:18 +0200 Received: from pc45945-2140.se.axis.com (pc45945-2140.se.axis.com [10.88.125.80]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 615A33071; Fri, 29 Sep 2023 09:45:18 +0200 (CEST) Received: by pc45945-2140.se.axis.com (Postfix, from userid 10564) id 5DB967124471; Fri, 29 Sep 2023 09:45:18 +0200 (CEST) From: Vincent Whitchurch Date: Fri, 29 Sep 2023 09:45:09 +0200 Subject: [PATCH v2 2/2] mmc: debugfs: Allow host caps to be modified MIME-Version: 1.0 Message-ID: <20230929-mmc-caps-v2-2-11a4c2d94f15@axis.com> References: <20230929-mmc-caps-v2-0-11a4c2d94f15@axis.com> In-Reply-To: <20230929-mmc-caps-v2-0-11a4c2d94f15@axis.com> To: Ulf Hansson CC: , , , Vincent Whitchurch X-Mailer: b4 0.12.3 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001B0:EE_|PAVPR02MB9643:EE_ X-MS-Office365-Filtering-Correlation-Id: cbc2c3fc-711a-4904-5e49-08dbc0c00717 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5CBtZNecg98ybzve50TUf3YGYjUdNLzqMFR/FKmIZ5iwH7efYbSBlo30byCbJgZ8+HIrw/nhNsCsZaUUJd5bN162dhpqVEAssCsF2DaodYocF+U191YDRrWmoN5eLXaCbG7+dWSJ3U+NRK7U5xW3/AdgZ+AN7w4V1O9dgZpHJB8Q5FN01aUBmtBedccQHWMqLZ2/iZTpMvlJSkNmiH4f0suh094peOJI541XjuU1cuzWC6WqepmWngiLhmiYihL8Ua2A1WsGggixGiFlbSW+zlZOq6u+/KAlLtvQgllA9G0j0WcBb/vMLq1WbekWEvKR2epHcDGSO3XQCEVJlN8DoWW+0mIN/zQPClWPE6oom0paZdWVn/L91R8GP3lm5+1j+LSC9cMoxHKXBQAdmXFO+OG7Jvp5bLpxFAmTYkO0Q2k1cxIIn0IosqUFnqbjY2yhIFZEwJHxmV9FhkAXGlKTK3V0sN52QURyPVt5YtQRvHYJgkwsKEwBTh481pP1DZQw+HlXhZznOLVWJYggxAReEDfLFSdOr+s1ASHRYW+bbQRkZUZaFslvVDInwkjWpor5oxiao0hIObXagY97hgaTCZ3MZIyKkEgjnA0Zod9v/0LWQsc4hmV28Cs6VRBj7az5Bo34qnx6LbFRcPIL1G/kptOQm+WPkrnqdfYf+0Nt2XsDBLGSjLdD+buwGc4X6bI8IcEl27RjxCkOiKUPxrdZI5Rcoqs5FMd+Jm2TYPa5eNkpAQp05F1NbsnjiOJuWUVC67NKj0usC03OjLwe26iyPQ== X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(346002)(376002)(396003)(230922051799003)(82310400011)(451199024)(186009)(1800799009)(64100799003)(40470700004)(46966006)(36840700001)(336012)(426003)(2616005)(26005)(6266002)(6666004)(47076005)(107886003)(4326008)(83380400001)(2906002)(8676002)(70206006)(70586007)(42186006)(54906003)(8936002)(5660300002)(41300700001)(44832011)(6916009)(316002)(40480700001)(40460700003)(356005)(36860700001)(86362001)(36756003)(81166007)(82740400003)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 07:45:18.7970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbc2c3fc-711a-4904-5e49-08dbc0c00717 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001B0.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR02MB9643 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org During board verification, there is a need to test the various supported eMMC/SD speed modes. However, since the framework chooses the best mode supported by the card and the host controller's caps, this currently necessitates changing the devicetree for every iteration. Allow the various speed mode host capabilities to be modified via debugfs in order to allow easier hardware verification. The values to be written are the raw MMC_CAP* values from include/linux/mmc/host.h. This is rather low-level, and these defines are not guaranteed to be stable, but it is perhaps good enough for the intended use case. MMC_CAP_AGGRESSIVE_PM can also be set, in order to be able to re-initialize the card without having to physically remove and re-insert it. /sys/kernel/debug/mmc0# grep timing ios timing spec: 9 (mmc HS200) // Turn on MMC_CAP_AGGRESSIVE_PM and re-trigger runtime suspend /sys/kernel/debug/mmc0# echo $(($(cat caps) | (1 << 7))) > caps /sys/kernel/debug/mmc0# echo on > /sys/bus/mmc/devices/mmc0\:0001/power/control /sys/kernel/debug/mmc0# echo auto > /sys/bus/mmc/devices/mmc0\:0001/power/control // MMC_CAP2_HS200_1_8V_SDR /sys/kernel/debug/mmc0# echo $(($(cat caps2) & ~(1 << 5))) > caps2 /sys/kernel/debug/mmc0# echo on > /sys/bus/mmc/devices/mmc0\:0001/power/control /sys/kernel/debug/mmc0# grep timing ios timing spec: 8 (mmc DDR52) Signed-off-by: Vincent Whitchurch --- drivers/mmc/core/debugfs.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 2c97b94aab23..1642ea72d22c 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include +#include +#include #include "core.h" #include "card.h" @@ -298,6 +301,49 @@ static const struct file_operations mmc_err_stats_fops = { .release = single_release, }; +static int mmc_caps_get(void *data, u64 *val) +{ + *val = *(u32 *)data; + return 0; +} + +static int mmc_caps_set(void *data, u64 val) +{ + u32 *caps = data; + u32 diff = *caps ^ val; + u32 allowed = MMC_CAP_AGGRESSIVE_PM | + MMC_CAP_SD_HIGHSPEED | + MMC_CAP_MMC_HIGHSPEED | + MMC_CAP_UHS | + MMC_CAP_DDR; + + if (diff & ~allowed) + return -EINVAL; + + *caps = val; + + return 0; +} + +static int mmc_caps2_set(void *data, u64 val) +{ + u32 allowed = MMC_CAP2_HSX00_1_8V | MMC_CAP2_HSX00_1_2V; + u32 *caps = data; + u32 diff = *caps ^ val; + + if (diff & ~allowed) + return -EINVAL; + + *caps = val; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(mmc_caps_fops, mmc_caps_get, mmc_caps_set, + "0x%08llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(mmc_caps2_fops, mmc_caps_get, mmc_caps2_set, + "0x%08llx\n"); + void mmc_add_host_debugfs(struct mmc_host *host) { struct dentry *root; @@ -306,8 +352,9 @@ void mmc_add_host_debugfs(struct mmc_host *host) host->debugfs_root = root; debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops); - debugfs_create_x32("caps", S_IRUSR, root, &host->caps); - debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2); + debugfs_create_file("caps", 0600, root, &host->caps, &mmc_caps_fops); + debugfs_create_file("caps2", 0600, root, &host->caps2, + &mmc_caps2_fops); debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host, &mmc_clock_fops);