Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1021828lqs; Wed, 6 Mar 2024 04:13:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2nYEIZ02+vTp8f+lrFLei1Gl5geg4+9d9xkTUonbYSMNXi+hWgnPj5QHTQKC173PhMwbj96TG3tStqmhEUQNorJ8b4ALoKE84FnLkBQ== X-Google-Smtp-Source: AGHT+IHmwQm/QjVvLrvBN0OgbbgUI+L6dUKCbvjAlCWMWKnQKyxW3cMY+Bu4S9dwlb/Aze2yt4e8 X-Received: by 2002:a17:902:d385:b0:1dc:4bc2:4923 with SMTP id e5-20020a170902d38500b001dc4bc24923mr4271662pld.65.1709727206629; Wed, 06 Mar 2024 04:13:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709727206; cv=pass; d=google.com; s=arc-20160816; b=UGS37N4whLhHcCONWGHN8GQomyGtPHSJJR4gOtlq9jjmsxd4fXOYmFHsR7+9+QYWwT R9AhX1rf+nizL9n3TL8nJt1DBuvQF+5KXiVH9w8wJQiJZjRG20tCZE3gSl+wi7HaqTqx L6KkO60xvbROG/LQ0FW63eure2q9nzxizux5EgQr0bnrS1srxsvMdXDQgi7ZYoKsTIAN lGWk/HCf7073AfU1kso3tXDjRjvPpVLLKZ0xSWloj2TCdFtJ2wmWONWUzLUjt4pC04nA GhN/yCGK1GdeDXkhz6e7V3t1w9Uqh67O3JYB2aIs6AlKRUr5or2taobRqzjYbnM0K92d yMYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=M24mEXhEijJg73gWUpW6KA+Popv3l8CYmbbCO5rEZZE=; fh=DOt3aUHTs0xEQoKEeCDCUVC5arZVS4AGISGL5W5DYQo=; b=dKOegoiaMgn1WhXmsCFq9H6CgJ9GL/Av2TAp44p0qHL8RRdwmgMXVt2F7oYebZnn6Y a3XLRqojnkusuVZT6WvbnPs+u3YKecpZU9+r8esZldkMs9WK3Yz0h0cohsBjollXr3dn jlZxQqOSORFHzGlIIt1i8AnI5vR+tvuZXWcPa9EcgjfHhEZdDCPZOa18HIgLltRXRIHj GFUdYH/gYMucFFWnOVyjqf+gQpJSblncBvMAiyP6nahLsIRci31z4T9TFlYkTIZBia6Q IAU0UkrqME+0Npgki9xmNKrJY+b/n+xtZuj8zqUDH93xSXgDGjDpRxiEdCJ1JssuAK+c gkFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=qd7s+P0c; dkim=pass header.i=@codewreck.org header.s=2 header.b=qd7s+P0c; arc=pass (i=1 spf=pass spfdomain=codewreck.org dkim=pass dkdomain=codewreck.org dkim=pass dkdomain=codewreck.org dmarc=pass fromdomain=codewreck.org); spf=pass (google.com: domain of linux-kernel+bounces-93852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h21-20020a170902ac9500b001d8e974ed24si11277357plr.626.2024.03.06.04.13.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 04:13:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=qd7s+P0c; dkim=pass header.i=@codewreck.org header.s=2 header.b=qd7s+P0c; arc=pass (i=1 spf=pass spfdomain=codewreck.org dkim=pass dkdomain=codewreck.org dkim=pass dkdomain=codewreck.org dmarc=pass fromdomain=codewreck.org); spf=pass (google.com: domain of linux-kernel+bounces-93852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 032B6B228BA for ; Wed, 6 Mar 2024 11:40:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CFD37FBDC; Wed, 6 Mar 2024 11:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b="qd7s+P0c"; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b="qd7s+P0c" Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6E7E7FBB4; Wed, 6 Mar 2024 11:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.121.71.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709725196; cv=none; b=Vz4FtXkXDXMP5/6newE3+CsbsBkKrqWE8C12l1IXA5jd/PNCrOy5RoifTAWqLictAZSMscGKREW10TQPsPsECplyV7OcP3CUEeS/d4ntbds9Yq785+LMOBUdgHQGYIM8yjAQfjxmPDqIrJusWpYuQ7GSPMzSe+BztL6x9CUpwAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709725196; c=relaxed/simple; bh=xwoFzPsHeZCk2y4J/x89E9mHH56JSmXj2yHhGVcCVyQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tHrW6pntP8UjKKHZkuVLJBoqDmoqnI5mwVJJtzqAc9NswObrrzkag4jDdtK26l36pO/Kb2BB6E0HLaft3cmovMk85ftszgrZrrlKan1Yd3SvQHv+CsCzcFBnXwNxPjUAP4rD2dpevzvO99GgbSdUOJw8xSsRXYnc4V1sXvMlAak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codewreck.org; spf=pass smtp.mailfrom=codewreck.org; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b=qd7s+P0c; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b=qd7s+P0c; arc=none smtp.client-ip=91.121.71.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codewreck.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codewreck.org Received: by nautica.notk.org (Postfix, from userid 108) id DE277C01B; Wed, 6 Mar 2024 12:39:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1709725191; bh=M24mEXhEijJg73gWUpW6KA+Popv3l8CYmbbCO5rEZZE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qd7s+P0cWX1xdYZUCxiiKX9bBF4pIaMd6U7LCsMAwda6rils2ZVEu/fezpefjRM88 NfambXuo3ZHK1u2KpXY+p6P2w3bW0HyKRGlp5KlNktlDo5qgAZvLBRpAU7ev2mlW3I aCZrJdnqvuGPnCK37namJfsymVf4N477ftHBkSryt/U+xph8+DqZerSADOoRyRurAy 2G2UtdPrxIDVQ85CeHwn+zX8Ok/S2UYw3tvJrg97pRlb5mX+72sr9KfUnxXZpKfrCG VYVOvh+QmuIab+vNOir6jL9c3uu2EedFxHBX6dW0HnfDbBQuBeWIhsOb9ZjVSpYUvA lpXJCDXJ7toDw== X-Spam-Level: Received: from gaia.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 4E49FC009; Wed, 6 Mar 2024 12:39:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1709725191; bh=M24mEXhEijJg73gWUpW6KA+Popv3l8CYmbbCO5rEZZE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qd7s+P0cWX1xdYZUCxiiKX9bBF4pIaMd6U7LCsMAwda6rils2ZVEu/fezpefjRM88 NfambXuo3ZHK1u2KpXY+p6P2w3bW0HyKRGlp5KlNktlDo5qgAZvLBRpAU7ev2mlW3I aCZrJdnqvuGPnCK37namJfsymVf4N477ftHBkSryt/U+xph8+DqZerSADOoRyRurAy 2G2UtdPrxIDVQ85CeHwn+zX8Ok/S2UYw3tvJrg97pRlb5mX+72sr9KfUnxXZpKfrCG VYVOvh+QmuIab+vNOir6jL9c3uu2EedFxHBX6dW0HnfDbBQuBeWIhsOb9ZjVSpYUvA lpXJCDXJ7toDw== Received: from localhost (gaia.codewreck.org [local]) by gaia.codewreck.org (OpenSMTPD) with ESMTPA id 01e7a05f; Wed, 6 Mar 2024 11:39:44 +0000 (UTC) Date: Wed, 6 Mar 2024 20:39:29 +0900 From: Dominique Martinet To: "Jorge Ramirez-Ortiz, Foundries" Cc: Ulf Hansson , Linus Walleij , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Dominique Martinet , stable@vger.kernel.org Subject: Re: [PATCH] mmc: part_switch: fixes switch on gp3 partition Message-ID: References: <20240306-mmc-partswitch-v1-1-bf116985d950@codewreck.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Jorge Ramirez-Ortiz, Foundries wrote on Wed, Mar 06, 2024 at 10:05:40AM +0100: > > the part_type values of interest here are defined as follow: > > main 0 > > boot0 1 > > boot1 2 > > rpmb 3 > > gp0 4 > > gp1 5 > > gp2 6 > > gp3 7 > > right, the patch I originally sent didn't consider anything after GP0 as per > the definitions below. > > #define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) > #define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) > #define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3) > #define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4) Yes, as far as I can see these are used in drivers/mmc/core/mmc.c for example for GP0, below snippet: mmc_part_add(card, part_size << 19, EXT_CSD_PART_CONFIG_ACC_GP0 + idx, "gp%d", idx, false, MMC_BLK_DATA_AREA_GP); where idx is in [0;3], so we've got 4-7 for GP partitions in the part's part_cfg. (similarly, boot has BOOT0 + [0-1], and RPMB has RPMB without anything added -- so as far as this field is concerned there seems to be a single RPMB) > That looked strange as there should be support for 4 GP but this code > kind of convinced me of the opposite. > > if (idata->rpmb) { > /* Support multiple RPMB partitions */ > target_part = idata->rpmb->part_index; > target_part |= EXT_CSD_PART_CONFIG_ACC_RPMB; > } > > So if we apply the fix that you propose, how are multiple RPMB > partitions (ie, 4) going to be identified as RPMB? Unless there can't be > more than 3? Hmm, that code is definitely odd. Reading this I'd normally assume that idata->rpmb->part_index ought to be in a range separate fom EXT_CSD_PART_CONFIG_ACC_MASK -- so we've got the ACC_RPMB "flag" that identifies it as RPMB within the mask, and then it can target a given index within that. But as far as I'm seeing in the code, rpmb->part_index always comes from mmc_blk_alloc_rpmb_part (set to part's part_cfg), which in turn is only called if area_type is MMC_BLK_DATA_AREA_RPMB, which is only set for mmc_part_add() for rpmb with ACC_RPMB as part_index.. So we've got target_part = 3 and then target_part |= 3 which will leave the value unchanged. Even assuming part_index was something else than 3 (let's say 1 or 2), we'd end up with target_part = 4 or 5 which won't match the PART_CONFIG_ACC_MASK check (&3 != 3), so it doesn't make sense until something is shifted somewhere outside of the mask, and I see no trace of part_index being shifted. So the if (idata->rpmb) itself makes sense as per the comment, but we could just have target_part take either values here as far as I understand. I've never actually used the rpmb partition of my MMCs so I'm not sure how multiple RPMB partitions is supposed to work in the first place, sorry. That code is authored by Linus W (in 2017), perhaps he'll remember something? -- Dominique