From patchwork Mon Feb 25 14:19:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159178 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp2081440jad; Mon, 25 Feb 2019 06:19:30 -0800 (PST) X-Received: by 2002:a19:da1a:: with SMTP id r26mr9235675lfg.2.1551104370262; Mon, 25 Feb 2019 06:19:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551104370; cv=none; d=google.com; s=arc-20160816; b=mkNwfs85B1H9kcBKmeezN5WlNzLfTRQ7+/Q7Q5Ul3xcIOG5gm15r2HJsK2ERVo+lSy Cd730ycDeLpyR/tFMcKXzNsoStiggBC9aan4CHWYcJnN0Nt9bHoBJXHsKKqzSYkh1vPU bvqugmYHkWdwIPYsgZKW6HqHYQpqmfsuzkmfcG90kedG+ZvFCk7VhTPmyecoXWtgMhkW oMyrk7n6PxDznRS4MfoxiX1l+1RtaNq6IEcv4hTjolw3M4WCND77i7VOnHmbEDHLB+Wm aZ425I4YHMrAgJb4COplQbKfxm5f72m25L/CG0zMiHQ10ZqoxvtibCgm7lYO1DJj5hwS HPGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=ULt1r6uK4NO898pcflaKUXJaDUSHTxeCDvU6A2HEM1w=; b=KuqTyPTNFQK1/9ye2Rxe9QnKJrILJyB69rGix9vsIYe5dBjfKbAVqe5IW/bdqNHZdv txhljnnQGg19s73lAw2hBIRgiRmkHKfll0N//TfSZi3VhuoVDNxRi5OpXRYxEIGR8nHa JcBxKmOb0KR3z6HukYeFEHDzK9Nz3VT7KCQ/KNQa169uYyiCn+wBYELwD6icXGkybG7e nlF/XGfecmMgxE/u8S2LULIHAPuZBHwxhaytTN3iFLblF6+5xxRkkuEF8tmpKEati9ME OYHr9YczcQNEzVaZPLv+ksLEDzBrtA1V4mMHFyGKP5w6kYLdrFlg4+seWktBDFXMVfgL DgtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGvUvupJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v7sor2345143lfg.14.2019.02.25.06.19.30 for (Google Transport Security); Mon, 25 Feb 2019 06:19:30 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGvUvupJ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@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; bh=ULt1r6uK4NO898pcflaKUXJaDUSHTxeCDvU6A2HEM1w=; b=iGvUvupJQ+bsyDLIcT3PJt+w10tkMuFO6xanIAzBRE2aitoJkHV4CznSJJTDWVGe4q YaScC/u66fqX9iGJ7csw1AA43/AvpByCsdOiqyNMD5nsUB1FcUzWJ1rYKQDy5KLQVVg2 NaW0oSJObZo9sPymSaj7M0N6iMlXPOp8kyartSzn0m2vU1rqEjPw8O+U6i7H08SZiyT9 HsGYR474KnJZtSeVZ74bw32zk0yCHpBwnjRj7AAwCQn76C/Ya8/lrZtyerBZwdUwQ5Pj iCe2/4K7u/Mp/R2r6yY8hb+LJ7zyAKMGlTBP6Rl98TY1NB1eG6Ase0XdDRJLzKzwM145 BK1w== 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; bh=ULt1r6uK4NO898pcflaKUXJaDUSHTxeCDvU6A2HEM1w=; b=lgkhdVJ+NeHqJzG/BRVCL9KOmblrJHvkXahM6eh82xIe69xyIsmhNEWwjuDeE4xH5X MRmmFlqPk5Zt2hBj2G6MPEnLaVqBiICK+NH7pFi7X6t3QLw1TSkwypuw1y2FKB/Ik48L 9pwdjKhwDXc50P2WXyrIalqX9a5GwA7CR2LcZlZczK+Sb8/Cjgk8OdTkbcNzTdqyCoPE /xfNuexd+jxRY5JSWn4FORnEdZkViesRFPagbguac9UBNV8YV9KKKZgcekDSFSdun5Ym QoLVCOs9UVZS3OOpcI9YxgXOm4/J8dpkeCpUqOhlmGuHVq6wnR9neElqURmBNYvQURE9 8RIw== X-Gm-Message-State: AHQUAuaMzB4rcTR+KV8su1ZlGT4gDGDrCqGcHzo08syMTkyF3b53QuHl IIcpu0HEuI1fdE8Cw6HFQ40BVdWl/J/OiA== X-Google-Smtp-Source: AHgI3IZ4rsqV7G6Cw/mqcABBcTvtQ9AVM3mIP4hRLpIaOyk91UhgnDNICuq+aQSU9PIi2OVjPPKnbA== X-Received: by 2002:ac2:5303:: with SMTP id c3mr10952502lfh.97.1551104369619; Mon, 25 Feb 2019 06:19:29 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j14sm2611418lfc.28.2019.02.25.06.19.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 06:19:28 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org Cc: Avri Altman , Adrian Hunter , Ulf Hansson Subject: [PATCH v2 7/7] mmc: core: Convert mmc_align_data_size() into an SDIO specific function Date: Mon, 25 Feb 2019 15:19:21 +0100 Message-Id: <20190225141921.1129-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 The only user of mmc_align_data_size() is sdio_align_size(), which is called from SDIO func drivers to let them distinguish, how to optimally allocate data buffers. Let's move mmc_align_data_size() close to the SDIO code as to make it static, rename it to _sdio_align_size() and simplify its definition, all with the purpose of clarifying that this is SDIO specific. Signed-off-by: Ulf Hansson --- Changes in v2: - Use ALIGN to avoid open-coding. --- drivers/mmc/core/core.c | 27 --------------------------- drivers/mmc/core/sdio_io.c | 29 +++++++++++++++++++++-------- drivers/mmc/core/sdio_ops.h | 1 - 3 files changed, 21 insertions(+), 36 deletions(-) -- 2.17.1 Reviewed-by: Avri Altman diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 659eb32c0246..b45aaa904107 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -757,33 +757,6 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) } EXPORT_SYMBOL(mmc_set_data_timeout); -/** - * mmc_align_data_size - pads a transfer size to a more optimal value - * @card: the MMC card associated with the data transfer - * @sz: original transfer size - * - * Pads the original data size with a number of extra bytes in - * order to avoid controller bugs and/or performance hits - * (e.g. some controllers revert to PIO for certain sizes). - * - * Returns the improved size, which might be unmodified. - * - * Note that this function is only relevant when issuing a - * single scatter gather entry. - */ -unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) -{ - /* - * FIXME: We don't have a system for the controller to tell - * the core about its problems yet, so for now we just 32-bit - * align the size. - */ - sz = ((sz + 3) / 4) * 4; - - return sz; -} -EXPORT_SYMBOL(mmc_align_data_size); - /* * Allow claiming an already claimed host if the context is the same or there is * no context but the task is the same. diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index d40744bbafa9..3f67fbbe0d75 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -203,6 +204,21 @@ static inline unsigned int sdio_max_byte_size(struct sdio_func *func) return min(mval, 512u); /* maximum size for byte mode */ } +/* + * This is legacy code, which needs to be re-worked some day. Basically we need + * to take into account the properties of the host, as to enable the SDIO func + * driver layer to allocate optimal buffers. + */ +static inline unsigned int _sdio_align_size(unsigned int sz) +{ + /* + * FIXME: We don't have a system for the controller to tell + * the core about its problems yet, so for now we just 32-bit + * align the size. + */ + return ALIGN(sz, 4); +} + /** * sdio_align_size - pads a transfer size to a more optimal value * @func: SDIO function @@ -230,7 +246,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) * wants to increase the size up to a point where it * might need more than one block. */ - sz = mmc_align_data_size(func->card, sz); + sz = _sdio_align_size(sz); /* * If we can still do this with just a byte transfer, then @@ -252,7 +268,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) */ blk_sz = ((sz + func->cur_blksize - 1) / func->cur_blksize) * func->cur_blksize; - blk_sz = mmc_align_data_size(func->card, blk_sz); + blk_sz = _sdio_align_size(blk_sz); /* * This value is only good if it is still just @@ -265,8 +281,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) * We failed to do one request, but at least try to * pad the remainder properly. */ - byte_sz = mmc_align_data_size(func->card, - sz % func->cur_blksize); + byte_sz = _sdio_align_size(sz % func->cur_blksize); if (byte_sz <= sdio_max_byte_size(func)) { blk_sz = sz / func->cur_blksize; return blk_sz * func->cur_blksize + byte_sz; @@ -276,16 +291,14 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) * We need multiple requests, so first check that the * controller can handle the chunk size; */ - chunk_sz = mmc_align_data_size(func->card, - sdio_max_byte_size(func)); + chunk_sz = _sdio_align_size(sdio_max_byte_size(func)); if (chunk_sz == sdio_max_byte_size(func)) { /* * Fix up the size of the remainder (if any) */ byte_sz = orig_sz % chunk_sz; if (byte_sz) { - byte_sz = mmc_align_data_size(func->card, - byte_sz); + byte_sz = _sdio_align_size(byte_sz); } return (orig_sz / chunk_sz) * chunk_sz + byte_sz; diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index 96945cafbf0b..1f6d0447ea0f 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h @@ -25,7 +25,6 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); int sdio_reset(struct mmc_host *host); -unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz); void sdio_irq_work(struct work_struct *work); static inline bool sdio_is_io_busy(u32 opcode, u32 arg)