Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp283124pxj; Fri, 7 May 2021 08:31:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIqO/fqyXVz2F0RB/qaHbOpVQ51z9w+jofzTIF5hG6taV2Xx3sdiXSJigmFRB1iA4sYkky X-Received: by 2002:a17:90a:a78c:: with SMTP id f12mr24059771pjq.219.1620401466975; Fri, 07 May 2021 08:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620401466; cv=none; d=google.com; s=arc-20160816; b=QzSo+F9j6X0EvfYNfURonNTaFxB2G+DijOalMmADgEFbBuArIiE3Wk1/I4v0iFyP5o j4PaDzgIQ/Q+BWIc75NelCIwiLNBQbSvgan2kWAg6pJxCcMOH3+iwRlj6Xh1Bp4NzZ53 ekgzc4/FzxiETGml/PlIYKmrBCqSTOQvCNWxe+v2QBzaRlsfcFwpx2a0kKSAHx6q7+T+ JL6mJ75czXShIHtmTtYt1lp+Ew0+Y/uIIukLSQkCuwVPK5rQ6mEgzRU4ta2TjON+8lF6 YUwqrSWdySQdaT4FhFlCUEnczYN1DZJIgm65/T6EsvXq7JiTLmhUm6+yMV7lFhBkr/Ea +uqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=f55cQFhONZr0u6mB8Fak6qVyDt1MOUtBrLmIIiZqgic=; b=qJGQ64Olg8Yi6BDHf+/HwDs6/HcEpRgg4RkTkZUIJ3RhJvJ3YyG0IXt+ZeJsPYkW1+ rQAyFfu2FHwejQTw73Lv6/Q11R16zaD8pQlkgK40ql9C3iTk1gtZGbHbnwk6JDOsPtHF vTlzAn1AiS7FgCfWgx8vtpPsGZgaEtcNswhsTftBotRwkQ8w/L3Mjj+yeScCOx1BxeUf /wD74Vvp69qdUJS/3LWFJQfz7FGcE5NstHfxPxYCZSVo1XdAurh+SZjFuKq99UtIKQt7 td4UkQqVldjlOAWYzbFuyykhEJSmLTmSWm9Il5iG+Iz4Ce4eCCB5iI2IjX1T4cnx2SH2 sh2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f6t3iVYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n23si7689025pfd.27.2021.05.07.08.30.54; Fri, 07 May 2021 08:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f6t3iVYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233706AbhEGLfz (ORCPT + 99 others); Fri, 7 May 2021 07:35:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231500AbhEGLfy (ORCPT ); Fri, 7 May 2021 07:35:54 -0400 Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E18C061761 for ; Fri, 7 May 2021 04:34:54 -0700 (PDT) Received: by mail-vs1-xe2c.google.com with SMTP id o192so4507977vsd.7 for ; Fri, 07 May 2021 04:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=f55cQFhONZr0u6mB8Fak6qVyDt1MOUtBrLmIIiZqgic=; b=f6t3iVYg1du6X2O2OD9hfE4OJA+8L2O1WZcrXR4Uk+Yfx0uvFNEMEhcSicqhhR0I5x 3+eT2YG4YV9zi7Uabg64d8kppicafuFBh+7hevH59fqd7Gvbdc4Cek1DwxEmC/+ir/Q6 x8+kdx0t/LwoEyq5pTeh2FmhCZrCr1OSu+ui4IEdKVRG8vX8/QDWwJab4yZNm6XmAJGo CxIyakTIj7pvDvqSVsBFIVRRiSZR0oPvF0XJ3+KZm/C5sUA+QUhYvd1WGnylkcYPxkLL ZtBR8k8f9yxVVdhO4OpuF+2ZecT/AFDAkFxs376iHHRe0b4nL75+ku+m1gtzi9kkIzzZ CT/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=f55cQFhONZr0u6mB8Fak6qVyDt1MOUtBrLmIIiZqgic=; b=st6kOzyVfrIj/eoRlWeua+0PTwGTD4l0w+Fn77k5QRbt2xplFklrGFfybhTlEI8v3h 07bhtr04mUcN/d6+nMU/MTzvboF9qU2IVcxscn50HhyGKfijrUSN8is0KBQi+wCkhzZ7 V2o2pk1HOTO1O+Uz3ooIu8MwT4KXofM6dOEzTRnGcPCYe7ponLkobSh9QLp3Z34Qd5Ov zmaXc/TqbVQjtAIaO7NwAJBrWjhT+lVjLMc7+MTqjJvIrco7RTqt1vZK6UOCKoTwr77F gRvyRT41Q1q2uPo8UgHN/+LltOGiRf4oKvqmBVe6SuM5ZQvUZBlh/vVkIrWiTVKiBcmt TOXQ== X-Gm-Message-State: AOAM532fEx599QY0K8VL8W3YFiy2KdlMogMFm3JY0PFQmdYXrS6cL2FP zGz/FpPDW0hIQ2tAPN7bi3Cv0gXAXiqlij2wf+P7RV1DkDj9Jw== X-Received: by 2002:a05:6102:505:: with SMTP id l5mr4387167vsa.55.1620387293243; Fri, 07 May 2021 04:34:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ulf Hansson Date: Fri, 7 May 2021 13:34:17 +0200 Message-ID: Subject: Re: [PATCH v2] mmc: block: ioctl: No busywaiting of non-TRAN CMDs To: =?UTF-8?Q?Christian_L=C3=B6hle?= Cc: Avri Altman , "adrian.hunter@intel.com" , "linux-kernel@vger.kernel.org" , "linux-mmc@vger.kernel.org" , "axboe@kernel.dk" , "zliua@micron.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 May 2021 at 12:34, Christian L=C3=B6hle = wrote: > > Prevent busywaiting for TRAN state indication > after issuing a command that will not transition > to TRAN state. > > Signed-off-by: Christian Loehle > --- > drivers/mmc/core/block.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c > index 689eb9afeeed..48be2ca5e3d1 100644 > --- a/drivers/mmc/core/block.c > +++ b/drivers/mmc/core/block.c > @@ -446,6 +446,20 @@ static int card_busy_detect(struct mmc_card *card, u= nsigned int timeout_ms, > return err; > } > > +static inline bool is_tran_transition_cmd(struct mmc_command *cmd, > + struct mmc_card *card) > +{ > + /* Cards will not be in TRAN after completing identification comm= ands > + * or MMC_SEND_STATUS if they are not selected. > + */ > + return !(cmd->opcode =3D=3D MMC_SEND_CID > + || cmd->opcode =3D=3D MMC_ALL_SEND_CID > + || cmd->opcode =3D=3D MMC_SEND_CSD > + || (cmd->opcode =3D=3D MMC_SEND_STATUS && > + MMC_EXTRACT_INDEX_FROM_ARG(cmd->arg) !=3D card->= rca)); > + > +} > + > static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_dat= a *md, > struct mmc_blk_ioc_data *idata) > { > @@ -593,7 +607,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card,= struct mmc_blk_data *md, > > memcpy(&(idata->ic.response), cmd.resp, sizeof(cmd.resp)); > > - if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) =3D=3D MMC_RSP_R1B) = { > + if ((idata->rpmb || (cmd.flags & MMC_RSP_R1B)) > + && is_tran_transition_cmd(&cmd, card)) { None of the commands you are checking for should have an R1B response according to the spec, I think. That said, I don't think we should do these kinds of sanity checks in the kernel for the mmc ioctls, that just doesn't scale. > /* > * Ensure RPMB/R1B command has completed by polling CMD13 > * "Send Status". > -- Kind regards Uffe