From patchwork Tue May 4 16:12:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 430887 Delivered-To: patches@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp3936605jao; Tue, 4 May 2021 09:12:53 -0700 (PDT) X-Received: by 2002:ac2:5e99:: with SMTP id b25mr6297275lfq.288.1620144772958; Tue, 04 May 2021 09:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620144772; cv=none; d=google.com; s=arc-20160816; b=O9H09p7c1KH5LEBHQ6RR3cluY0HmbcJzYhs0S5oPhvxrz/AXE+ATEsczgSP0UAf1VU aTkIabWWr7OfuSuirmeCvmG8yqAbarN2v+A0FYQOOvrhsC9CuS59giheoXZdGBLKyTOw sihnYh3UBfhE02h/ezHsjtMzlfTOmWoN8r4AJRJHZB9mk/qOhunUgyrc/RFBXZpvGk3h hbFndSC2hhnh8NaqwijriSAOd4MuHTyM5CyQzqtGd4J5kZGQlhZ50FnjD9owLdTa+Ry4 3jjLsk6cZHyzXSUjfhXIOuab2heIqdontBLMo+umrvvTjDrl52V0VncEeAtWTan3yraF Um6A== 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=TugmmnMP6RDSPp2L8UfvdmsSklrTobWCwgxHv2Rsq4s=; b=p3vcTKy99LfT5HogNPCH+oPsh8dkkStJGGu8B9g5n9x8t24j4oL38fPNTSPqMKh+rG Wq1B/2IH/JO6hX4jCv59QbUJvtNBtOGnLMy6HlvMNbwe1Vtv4SFbe6qc05gZNJoGlxZN C0IHiEVoYmZ6DtPLZBsCivje5pKnDCHjwjftyat9i+wxDz/5xxwZ+XJbjtv3ko+pyI9v mRiaD+U6GMqjRG1tUXBchbksHu7RVxkz2o631OC5NYu/K2hn2R0p6CeUa/b9XZ1cSz34 i++/cDV/PpFKf+wXZ5/jHfLk/FWtUmS1v/GA4ytnzreETecfJV2T8CQdumEzCDeGn4hg UvoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x7LwYTyy; 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 o25sor4332649lfl.59.2021.05.04.09.12.52 for (Google Transport Security); Tue, 04 May 2021 09:12:52 -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=x7LwYTyy; 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=TugmmnMP6RDSPp2L8UfvdmsSklrTobWCwgxHv2Rsq4s=; b=x7LwYTyyiO5EtiSTP/BPjhP9eQrFZqFYpQLS2CmnQjKkQZw4od7tGy8UXuFTWYv1LQ 1Axih3agolSFgjjMtieA8LhbmKveLqqkx5XbcK+qoBgaBQB8Km0sjqPpvYzXMF9aHi2f JhAqdotYH9n0s1TDaRyNsaE8b/1ATss11DSsIgcD26G4DjKvY2baR2fT9odGyuA6LTcl 340q7sfFGMR7IgOHASR52aooO9vkXQOFFBJY61X/SRRV6toD1cPUn5AVW9Pe7pzT1rTW jXcUO9592B8NdUvOJ0SUPZVCNjvtKn+MYADQ62S3NIHlCRxN472YCmfEQRyefBJqiy5M F47w== 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=TugmmnMP6RDSPp2L8UfvdmsSklrTobWCwgxHv2Rsq4s=; b=nlxlpfXBCf7iAIM7NsqUJZSgt8RTUaVtqhV/7r2wfR7okBw5/7G75tBNrypQQoT2oH /XXX3hEBsTVofQTWMl5i2c7ablPj0Ipc5mlvhvLRSllhR0hsoTLtbG3q3+Sul395zv0D csmqU/yqdm4FN+ZHwcgHhQMA+YjYvHQ3WQe+9idc51eslVAq4z58+oaI3HT2VnzW10yK GdAmR6s/PhQYXIgst/UwrUk3buFMOgB5lDCGEHtx5Hg4aQGAlXuflyDbEwE1nAM7I+si UkWCyDilHQfJI7pa5BR92QuomdeG8na3Ok2inzRn8wX40gY32TntO3nRKHlB7L8yLHtq +hkg== X-Gm-Message-State: AOAM533q5rF9lizbuJt/Ywx0ikjDtvtnJe2sae1ZAwWgYqjRCTqTSB9O dGNOwjGMp8bh4OAyda2dTbTNRLlGRejJAeDg3ig= X-Google-Smtp-Source: ABdhPJwRcHKF0j+XAEQinX49FLpArbd5Qu9pJndUnwAUxs9SZ+chNoCiFzzPoZIAt3hnQZ4HTmyIXw== X-Received: by 2002:a19:48d3:: with SMTP id v202mr15024111lfa.315.1620144772586; Tue, 04 May 2021 09:12:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-180-197.NA.cust.bahnhof.se. [98.128.180.197]) by smtp.gmail.com with ESMTPSA id s20sm164193ljs.116.2021.05.04.09.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 09:12:51 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Linus Walleij , Wolfram Sang , Shawn Lin , Avri Altman , Masami Hiramatsu , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/11] mmc: core: Read performance enhancements registers for SD cards Date: Tue, 4 May 2021 18:12:21 +0200 Message-Id: <20210504161222.101536-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504161222.101536-1-ulf.hansson@linaro.org> References: <20210504161222.101536-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 prepares for subsequent changes to implement the complete support for new the performance enhancement features. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sd.c | 53 ++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/card.h | 7 ++++++ 2 files changed, 60 insertions(+) -- 2.25.1 Reviewed-by: Linus Walleij diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index cb5e8b2fc32f..702d7c1a0aec 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1058,6 +1058,55 @@ static int sd_parse_ext_reg_power(struct mmc_card *card, u8 fno, u8 page, return err; } +static int sd_parse_ext_reg_perf(struct mmc_card *card, u8 fno, u8 page, + u16 offset) +{ + int err; + u8 *reg_buf; + + reg_buf = kzalloc(512, GFP_KERNEL); + if (!reg_buf) + return -ENOMEM; + + err = sd_read_ext_reg(card, fno, page, offset, 512, reg_buf); + if (err) { + pr_warn("%s: error %d reading PERF func of ext reg\n", + mmc_hostname(card->host), err); + goto out; + } + + /* 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.fno = fno; + card->ext_perf.page = page; + card->ext_perf.offset = offset; + +out: + kfree(reg_buf); + return err; +} + static int sd_parse_ext_reg(struct mmc_card *card, u8 *gen_info_buf, u16 *next_ext_addr) { @@ -1102,6 +1151,10 @@ static int sd_parse_ext_reg(struct mmc_card *card, u8 *gen_info_buf, if (sfc == 0x1) return sd_parse_ext_reg_power(card, fno, page, offset); + /* Standard Function Code for performance enhancement. */ + if (sfc == 0x2) + return sd_parse_ext_reg_perf(card, fno, page, offset); + return 0; } diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 03a862e93594..2867af0635f8 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -201,6 +201,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 { @@ -305,6 +311,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 */