From patchwork Wed Apr 21 10:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 425287 Delivered-To: patches@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp203530jao; Wed, 21 Apr 2021 03:32:14 -0700 (PDT) X-Received: by 2002:ac2:46c8:: with SMTP id p8mr18336084lfo.561.1619001133929; Wed, 21 Apr 2021 03:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619001133; cv=none; d=google.com; s=arc-20160816; b=UdjFxdAY1QnMCCpR+v8hWxvwByjx3eoEno+CbvuvpY2hGLp2HH6xjZKbGl6sJ4njsA mq/4h0z0vuFJwjR7cvKY3CbZMuBPvSYI324ngzy1aWBBM9d4DSN3U5wLhKSlP+IG8QIc fYDBpDjFGy71ohfgD5waTjOq7c1TSElVctmgISJW1tw3Abe8cO5m3WJyJWFJlVi74FAk FWagkVbXvavPbHLfTsbIdr56aKQouEQWJAgrDZhhn6ShykjvcSpIGj1wmbmShwpBiWI0 tpV7Z1ck7hleP4uvyPNMEj2P0SRGmLi0THx+ZvTr8J2sAaFLsa/RwRKaWWk1bWOBfNXM NxJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=bcsktzE2LmD65+1hOHiSw/mP2z1mU2lSfJMjIjsWTl8=; b=HNvmkdnF3a6qfYkNybn4T8bzs9X2eSiDOP7YRCcFztfolw40NfKChPm0Pmvi+WR67Z j/5Y90CTjzhhCjCX0JS84mt/R7K08K3RbvVLxShKPIgxw0iHhFcOgJ25Ea0E7wOYjMTG 9iWy4tQMBxrYKndRG7WZG4ASActDBOsT7qXePrWLH5+i6GRQlNfq1A10CLI47uYN+Asp gyCvl7Tp/tV0C9Qt1e1bZCnvEbkKlaDgD/ZYdwqELV3M7x8em8otaXF61+70A44FZlEe 6GFuseSj+kt693i+bTOyM24AH7yA6n5VbUXqHSlXLOJPN2K7wMzFOGrAk/LubCcONHrU uyyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MeDREFOX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 84sor396258lfm.11.2021.04.21.03.32.13 for (Google Transport Security); Wed, 21 Apr 2021 03:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MeDREFOX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bcsktzE2LmD65+1hOHiSw/mP2z1mU2lSfJMjIjsWTl8=; b=MeDREFOXhXuJmdNkZlfNo6r09BtFQhtpatiA2dLOAjjAx9WJX57MEqtOeMptwJzzxg KcFM8UVx0SBV4dYxGqW+lMn/XOuElbSINB3SPmjzyeEr36jWpVyIwgfPxwa8ssflH2mJ Oxolx5TZP8FqxdkDpcOeNYrs4SB5XroN/kGPdRGF9BF/qijCo8EDgYg6VMySHJfVq2hA z29f+TyFBf1pCEfF7kx9mvQBUWc32kJJuNY5XG87OR7ZsqmuKlJ0GbDGfTS98sSe2gAb i8ZRbFepki5l8v/b9AHTV32HDeKv1wZbpuFH0314bcqBTpdBW9PE+iVZ4ltSbO6R/x/G M/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bcsktzE2LmD65+1hOHiSw/mP2z1mU2lSfJMjIjsWTl8=; b=ulopd9WzDfExpd2b68y5A22fwSqzIvavr6DcN56QScoLE9SLXQUOFpLOWrjwWhKQKx y8ON4njraB6SH9t67Q0IC5oLIxlKZF9SFcBAltPrQm1/gu78pYnrw4ZeKCjr1QVsOFlI b0jI/N5fpTxb5J3M96aK6Tmj7Xb73Mc8O77giGxufd0a3jZj7FvLw2i6U8Y66D+awbSQ 6+tBpnQxWs4GIYyxPM1vwv+m92fmqTqbO9DsDM0OKP9FYTf8EtW9cSKhneIE3fYYomsw Qdo5/irQheN+wRBlWJqr8fP5cif9kWkuwbs+S/5QkUtAPaxD3ZQXjWkHZ4Prai6w90Hd X0bA== X-Gm-Message-State: AOAM531X5vZidNfAf5/Mw8qP/NoA8/0O5XQDt8P04jJMQbW+ar1C4kq0 oQ3aYTUiGQeQk/jhH2I2McLuBS/Z X-Google-Smtp-Source: ABdhPJxV6dxPVTt9qygoUmgvT6O4ATvKPQcYo7j/3FM4lE7OAyE15x7FJ/923njgXMQ0S3Iy0/lpcQ== X-Received: by 2002:a05:6512:12c3:: with SMTP id p3mr12128089lfg.595.1619001133570; Wed, 21 Apr 2021 03:32:13 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-234.NA.cust.bahnhof.se. [155.4.129.234]) by smtp.gmail.com with ESMTPSA id u13sm170603lfg.139.2021.04.21.03.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 03:32:12 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Shawn Lin , Avri Altman , Masami Hiramatsu , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mmc: core: Read performance enhancements registers for SD cards Date: Wed, 21 Apr 2021 12:31:54 +0200 Message-Id: <20210421103154.169410-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421103154.169410-1-ulf.hansson@linaro.org> References: <20210421103154.169410-1-ulf.hansson@linaro.org> MIME-Version: 1.0 In SD spec v6.x the SD function extension registers for performance enhancements were introduced. These registers let the SD card announce supports for various performance related features, like "self-maintenance", "cache" and "command queuing". Let's extend the parsing of SD function extension registers and store the information in the struct mmc_card. This allows subsequent changes to easier implement the complete support for new the performance enhancement features. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd.c | 46 ++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/card.h | 7 ++++++ 2 files changed, 53 insertions(+) -- 2.25.1 diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index d6e838b7c895..0e946afd6d22 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1063,6 +1063,48 @@ static int sd_decode_ext_reg_power(struct mmc_card *card, u8 fno, u32 reg_addr) return 0; } +static int sd_decode_ext_reg_perf(struct mmc_card *card, u8 fno, u32 reg_addr) +{ + int err; + u8 *reg_buf; + + err = sd_read_ext_reg_fno(card, fno, reg_addr, ®_buf); + if (err) { + pr_warn("%s: error %d reading PERF func of ext reg\n", + mmc_hostname(card->host), err); + return err; + } + + /* PERF revision. */ + card->ext_perf.rev = reg_buf[0]; + + /* FX_EVENT support at bit 0. */ + if (reg_buf[1] & 0x1) + card->ext_perf.feature_support |= SD_EXT_PERF_FX_EVENT; + + /* Card initiated self-maintenance support at bit 0. */ + if (reg_buf[2] & 0x1) + card->ext_perf.feature_support |= SD_EXT_PERF_CARD_MAINT; + + /* Host initiated self-maintenance support at bit 1. */ + if (reg_buf[2] & 0x2) + card->ext_perf.feature_support |= SD_EXT_PERF_HOST_MAINT; + + /* Cache support at bit 0. */ + if (reg_buf[4] & 0x1) + card->ext_perf.feature_support |= SD_EXT_PERF_CACHE; + + /* Command queue support indicated via queue depth bits (0 to 4). */ + if (reg_buf[6] & 0x1f) + card->ext_perf.feature_support |= SD_EXT_PERF_CMD_QUEUE; + + card->ext_perf.reg_addr = reg_addr; + card->ext_perf.fno = fno; + + kfree(reg_buf); + return 0; +} + static int sd_decode_ext_reg(struct mmc_card *card, u8 *gen_info_buf, u16 *next_ext_addr) { @@ -1103,6 +1145,10 @@ static int sd_decode_ext_reg(struct mmc_card *card, u8 *gen_info_buf, if (sfc == 0x1) return sd_decode_ext_reg_power(card, fno, reg_addr); + /* Standard Function Code for performance enhancement. */ + if (sfc == 0x2) + return sd_decode_ext_reg_perf(card, fno, reg_addr); + return 0; } diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 6a1d64fba0f3..8e21eebe704d 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -200,6 +200,12 @@ struct sd_ext_reg { #define SD_EXT_POWER_OFF_NOTIFY (1<<0) #define SD_EXT_POWER_SUSTENANCE (1<<1) #define SD_EXT_POWER_DOWN_MODE (1<<2) +/* Performance Enhancement Function. */ +#define SD_EXT_PERF_FX_EVENT (1<<0) +#define SD_EXT_PERF_CARD_MAINT (1<<1) +#define SD_EXT_PERF_HOST_MAINT (1<<2) +#define SD_EXT_PERF_CACHE (1<<3) +#define SD_EXT_PERF_CMD_QUEUE (1<<4) }; struct sdio_cccr { @@ -304,6 +310,7 @@ struct mmc_card { struct sd_ssr ssr; /* yet more SD information */ struct sd_switch_caps sw_caps; /* switch (CMD6) caps */ struct sd_ext_reg ext_power; /* SD extension reg for PM */ + struct sd_ext_reg ext_perf; /* SD extension reg for PERF */ unsigned int sdio_funcs; /* number of SDIO functions */ atomic_t sdio_funcs_probed; /* number of probed SDIO funcs */