From patchwork Wed Feb 13 19:54:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 158251 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp470171jaa; Wed, 13 Feb 2019 11:54:58 -0800 (PST) X-Received: by 2002:a19:4847:: with SMTP id v68mr1310470lfa.136.1550087697985; Wed, 13 Feb 2019 11:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550087697; cv=none; d=google.com; s=arc-20160816; b=RYvpT5CkibvSa+iV9Or5lYN9zz7+USWQiOR06fTIu5bpKSTo3RU9n9YgIEx/wvjJZ6 koy8ZDYxRixIWrLDLHzyl7Sa4tJlUcN27zymBjU/YIIzb3np1HPQiEOwht/xO1k9dIjZ 4wO6t4B/Gxc/UiWFAmcHrzssau3QP4xQZxLuqZE6t06ouM/bq1QxrkU1HjUmqmDA+qTP X364fkI3mMWIVHac3Hsp6sN2bsDPu+52kFrW8I0gB9KKKmU366DHx+zfAf1zx+7ZhWm9 gWP+H8osuBY48QOLKgKNdRm4o8s3kSvOWV7ye7IYxq0/27PK5EfsgEcy9TG3t0xeEbVt yKhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QsrtEZTLEsP2XILqx5eH4QDILCJkqe7UoHCPhY85Pc0=; b=CBxb7WlsI9BdjVmT8qTKXeDssbXFKaNvESFtuxWZoG1W+JHlPZwc5u0isjNEPnGsXF ZII+hjhuB07xHHpenwGwhjzICdgdGNC6T0tGKEdSkZLbL9iX2XXgY/Bb0YVav1JbGz3K Eoya7DHEdAFcbRxGNZzImUBgmxg0L0TIOR48qfJtPrbV9MJqCzj5B3Z6YSNRdw+ASREa rBD8qJ+IUcpsD+qWeSidqvgDSGKt4sa/6LhlhHInTxONW5Rt+sV0OexIa68snm7wsrSf IpjG4e0wXjKVMdUlWvLH23PzRqY+7QyrSLqLk1DcIbGFvWf5v0WTkBM2NQqLkeOMh6o6 wVDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="w/zJfg0g"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d2sor62598lfk.41.2019.02.13.11.54.57 for (Google Transport Security); Wed, 13 Feb 2019 11:54:57 -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="w/zJfg0g"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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; bh=QsrtEZTLEsP2XILqx5eH4QDILCJkqe7UoHCPhY85Pc0=; b=w/zJfg0g16k4bISobpl514UBQ03quu1cOWcrPWDeXNPIxozDRlontbcShYuBVwDR0q oQIwYqIEZTXdP0FhEir7+tj4W0DtwOOVpANBBQfX2etIKFJJsE3P6rDcVrqvEPvRYtIx HIM0uub2eAHbkNlgMtpe2Bvas1yME8zU/vCp/Ffu24hsMlvtral+CLIY7ds/ksm7NtNt yDgP/Bp6xYivrSuBphr3WwKqt6oGxJFOzZM1qd+x9hiKLHEaLdnrr/3o+AK1MenEBzuc jNVJhzgt3Gtj6wWT9fFsRENmeHkO2eeWYEWYXhIClSrsLfOPqwUGIyvaH4KjeN+zVvpd Cgxg== 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; bh=QsrtEZTLEsP2XILqx5eH4QDILCJkqe7UoHCPhY85Pc0=; b=MkG/FwCEoL9q5ROOs18dNaP5hG4kxTO4ylLhG6ujkxKHrkb1fpHAcECX0Aj/C+gZ52 uT+SNSmshEN0pZwYy8PV+ykuPrKvWhLC6dRF0lT1YxOOPBKBKgHts8SpSSMb0hfaZYXk HLwopXwIAR3lfNZsVkcUrVJt2lBJ37+2ylR1EpVrT+eCD8cx+fYh1j1gvVQS5sFhuIcV RPxx0NZz+keM+e3Ym34phd5ES6cLxSK8qmV/IzIP8nAULnQFXzShaIM3ZCnOQsiDu8Ma BrgweDIgWYdgjL/NnPkKW84DhOQWSRizJk7FQd5CgX1b77iPLLDq2pi4taxip3hHxHzW ablA== X-Gm-Message-State: AHQUAublkzoQmUuVYVyoPTaX2jb3JIIQKoJK0SQ1a3aSdFRUSM5Lfze6 bFkXuzZ4Lcre0wgp4NazWpWL9hN+ X-Google-Smtp-Source: AHgI3IbTqElkQ5+erA8bqWWq/eI2BNmj0F/NvUdAhIIAXGrAH83rhLvDBfZEGR6OsD8WSPleiLmWHQ== X-Received: by 2002:a19:f244:: with SMTP id d4mr1487588lfk.0.1550087697426; Wed, 13 Feb 2019 11:54:57 -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 g194sm39169lfg.55.2019.02.13.11.54.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 11:54:56 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Adrian Hunter Cc: Ulf Hansson Subject: [PATCH 7/7] mmc: core: Convert mmc_align_data_size() into an SDIO specific function Date: Wed, 13 Feb 2019 20:54:43 +0100 Message-Id: <20190213195443.18935-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213195443.18935-1-ulf.hansson@linaro.org> References: <20190213195443.18935-1-ulf.hansson@linaro.org> 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 --- drivers/mmc/core/core.c | 27 --------------------------- drivers/mmc/core/sdio_io.c | 30 ++++++++++++++++++++++-------- drivers/mmc/core/sdio_ops.h | 1 - 3 files changed, 22 insertions(+), 36 deletions(-) -- 2.17.1 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..6ce089d6b1f5 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c @@ -203,6 +203,23 @@ 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. + */ + sz = ((sz + 3) / 4) * 4; + + return sz; +} + /** * sdio_align_size - pads a transfer size to a more optimal value * @func: SDIO function @@ -230,7 +247,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 +269,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 +282,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 +292,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)