Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2015339pxj; Sun, 9 May 2021 12:13:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0jnXI+mdHN15MNS8xDLhtQubr/2WSpPLxNmBywWaQx45cNqGKav6PFpKHubm9aWsUmkS7 X-Received: by 2002:a17:906:2b0c:: with SMTP id a12mr21881769ejg.473.1620587631251; Sun, 09 May 2021 12:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620587631; cv=none; d=google.com; s=arc-20160816; b=aePSb0cuqIZQN8XR6koeZ0GVdWEHeiLMPMwAFZ/hDWfay3bbs9IsixtBfnNTvzgcUA dZ562eusZGpMD7l7yqcAd0WkMHiRfjbVekOoyDW87iYbsqEI+qrCuafIc0In1aXEhnoi zdwyE2XIWcx323sezFOOvvm0mNjk8mMFmtGXj+wjfRlpVi4SdcxYWNwfUGHO9iJ6lL7n acUOEQ9ZnEApCYY4f4u7BgdAmqIYMYtXk61d5gXiTCLBCyN32FXDxRBMOiQjBuAVAnRW Oc0vRSvUXfk1tNC8DUCQf/UZgWUKrZAjorZ37tWyk7magJ1arLwfJBZvbzeYh/xVoQ3z DecA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gKQhzQ0P4XyQz90sgnwAHoDnS29R/uNtlMfJta0NT4E=; b=T4SkSryTuLtN1h0jqa3dt2+UgE0kbwUKlJjgxbgPdUyJFBofSEXfAHYK2JVkl0XJVG vKDghVgnnzdeAInvybRUrG61LSUeLWgvmUsbrOTubmlEenH+rybvj767fkUJXTJ/e2qm jtVw1XlFv/oIf5OgMu4TzKpfIJHAyEo0pemEEnhuK0M8q0UWKlwRUmFZD4yW8nkRCP7w 951ljrIyvqHthlxw7M5/KQRorsmxaaYmV4lpFW1Kr0Y2KF5FCeXYuYg1Z3WxlpeiJgqR kUggjV6Yx0a18lvfKCN1an9mfta5nKxGomt7RYIcN+r8FToCG5Kyur+HkruznUYwwd7y 3RdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dWDqSKTe; 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 h8si11669834ejj.270.2021.05.09.12.13.25; Sun, 09 May 2021 12:13:51 -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=dWDqSKTe; 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 S229933AbhEITCp (ORCPT + 99 others); Sun, 9 May 2021 15:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbhEITCo (ORCPT ); Sun, 9 May 2021 15:02:44 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C02C061574 for ; Sun, 9 May 2021 12:01:40 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id e11so4531421ljn.13 for ; Sun, 09 May 2021 12:01:40 -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; bh=gKQhzQ0P4XyQz90sgnwAHoDnS29R/uNtlMfJta0NT4E=; b=dWDqSKTe3nZml1msjJQErs0BtDMqlsiQNWe0ZBwXAzTUZ0QIbPG0MToiUvfbzYs6F0 2SsrqFpVLZVtskz5MEennoADCCmTOqdta8BZe7PUGW/gpdO/Xmt75iQ855UIDkpwycGc apt1Deib0Etzm6NjIxxV3fUfaq/iBXOW92uNoATb76zFuadg49eXGSZ+fFENll38Cngo tBmEndDuGmXm8R4O9K8k/Dn8qoO8Spcc6OjS6WLZZMiYpozbTn7m0l8HA39rVpBrv6oG IEAkSNM6s01oNV4Hf/Avmirecv4vSqMlbjGFPUkRAMWtzHBpa1P/tmhfCQ8esaL1nPdX dWtA== 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; bh=gKQhzQ0P4XyQz90sgnwAHoDnS29R/uNtlMfJta0NT4E=; b=Wg23nP8AbxPNiyMe58CbHg3jorQMxgkM00CtXplZ6bhcKLjysx2YAweOoAuq1clbPX DppPGHE4Un9E1jnMncpgDoDiWpRHlBa+B73jSn4LfawJHWBa/FwrgklXq+wW0yrLlss1 hVBitqgo/WcLljJwN0VIkeuiFyj7EOKktzCNE8A8170MFVytR5gB88LsNvDxJBjYKu7r dlX8dS+4O/SL0h3drESVRUOyOEc3Je7ff1z/UehJ62LWTcA3XKW6pCsbI16kyc1flpjd ySTQSSfr7DubWyq8Nx5zX9Smraor/cBP2K1+xI6/KfTLV7lIRizd0MUjDtCVnZrDGXYU eLyg== X-Gm-Message-State: AOAM5321obDCHLAY/LzMFZvfA9EWgpsU9at+scseOHxTxgypZPEtDHzc YaEhS02dhfwigGWPBosMcOvcEO7giHf+q0uIectr0A== X-Received: by 2002:a2e:889a:: with SMTP id k26mr17085100lji.438.1620586899039; Sun, 09 May 2021 12:01:39 -0700 (PDT) MIME-Version: 1.0 References: <20210506145829.198823-1-ulf.hansson@linaro.org> <20210506145829.198823-3-ulf.hansson@linaro.org> In-Reply-To: <20210506145829.198823-3-ulf.hansson@linaro.org> From: Linus Walleij Date: Sun, 9 May 2021 21:01:27 +0200 Message-ID: Subject: Re: [PATCH 2/2] mmc: core: Add support for cache ctrl for SD cards To: Ulf Hansson Cc: linux-mmc , Adrian Hunter , Wolfram Sang , Shawn Lin , Avri Altman , Masami Hiramatsu , linux-block , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 6, 2021 at 4:58 PM Ulf Hansson wrote: > In SD spec v6.x the SD function extension registers for performance > enhancements were introduced. As a part of this an optional internal cache > on the SD card, can be used to improve performance. > > The let the SD card use the cache, the host needs to enable it and manage > flushing of the cache, so let's add support for this. > > Note that for an SD card supporting the cache it's mandatory for it, to > also support the poweroff notification feature. According to the SD spec, > if the cache has been enabled and a poweroff notification is sent to the > card, that implicitly also means that the card should flush its internal > cache. Therefore, dealing with cache flushing for REQ_OP_FLUSH block > requests is sufficient. > > Signed-off-by: Ulf Hansson (...) > + /* > + * Set the Flush Cache bit in the performance enhancement register at > + * 261 bytes offset. > + */ > + fno = card->ext_perf.fno; > + page = card->ext_perf.page; > + offset = card->ext_perf.offset + 261; 261 looks a bit magic, can we add a define of some sort? I guess it has a name in the spec? > + err = sd_write_ext_reg(card, fno, page, offset, 0x1); > + if (err) { > + pr_warn("%s: error %d writing Cache Flush bit\n", > + mmc_hostname(host), err); > + goto out; > + } So this offset contains a single bit. > + if (reg_buf[0] & 0x1) > + err = -ETIMEDOUT; And that same bit is checked here. Is it always going to be one bit only or do we want to #include #define SD_CACHE_FLUSH_FLAG BIT(0) Does it have a name in the spec we can use? > + /* > + * Set the Cache Enable bit in the performance enhancement register at > + * 260 bytes offset. > + */ > + err = sd_write_ext_reg(card, card->ext_perf.fno, card->ext_perf.page, > + card->ext_perf.offset + 260, 0x1); Same here we want to #define 260 to something symbolic, And here some define for BIT(0) as well. At least with BIT(0) in the call to sd_write_ext_reg() rather than 0x1 if I can say something. With the above nitpicking fixed up (I trust you): Reviewed-by: Linus Walleij Yours, Linus Walleij