From patchwork Tue Dec 19 12:06:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 10123137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD32D6019C for ; Tue, 19 Dec 2017 12:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C595C2927D for ; Tue, 19 Dec 2017 12:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA46D292C8; Tue, 19 Dec 2017 12:07:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E172927D for ; Tue, 19 Dec 2017 12:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762568AbdLSMHR (ORCPT ); Tue, 19 Dec 2017 07:07:17 -0500 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:43388 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751599AbdLSMHO (ORCPT ); Tue, 19 Dec 2017 07:07:14 -0500 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id vBJC4r8H005408; Tue, 19 Dec 2017 04:07:08 -0800 Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2ew1qn2dgp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 19 Dec 2017 04:07:07 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 19 Dec 2017 04:07:06 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Tue, 19 Dec 2017 04:07:06 -0800 Received: from smtp.marvell.com (unknown [10.38.32.107]) by maili.marvell.com (Postfix) with SMTP id 729C93F7048; Tue, 19 Dec 2017 04:07:02 -0800 (PST) Received: by smtp.marvell.com (sSMTP sendmail emulation); Tue, 19 Dec 2017 20:06:56 +0800 From: Xinming Hu To: Linux MMC CC: Ulf Hansson , Kalle Valo , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , Zhiyuan Yang , Tim Song , Cathy Luo , James Cao , Ganapathi Bhat , Xu Wang , Bob Tan , Xinming Hu , Amitkumar Karwar Subject: [PATCH v6 1/4] mmc: API for accessing host supported maximum segment count and size Date: Tue, 19 Dec 2017 20:06:47 +0800 Message-ID: <1513685211-640-1-git-send-email-huxm@marvell.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-19_07:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=923 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712190176 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sdio device drivers need be able to get the host supported max_segs and max_seg_size, so that they know the buffer size to allocate while utilizing the scatter/gather DMA buffer list. This patch provides API for this purpose. Signed-off-by: Xinming Hu Signed-off-by: Amitkumar Karwar --- v2: v2 was submitted with minor improvement like replacing BUG_ON() with WARN_ON() v3: Addressed below review comments from Ulf Hansson a) In v3, patch has been split into two separate patches. b) Patch 1/2 introduces an API to fetch max_seg_size and max_segs c) Replaced WARN_ON() with proper error code when sg_ptr->length is invalid d) Instead of duplicating the code in mmc_io_rw_extended(), extra bool parameter has been added to this function and used it in new APIs for SG. v4: Removed WARN_ON() calls in newly added APIs. It's gets called in probe handler. Caller already takes care of it(Shawn Lin). v5: Rebased on latest code base. v6: Split driver caller to separate patch. --- drivers/mmc/core/sdio_io.c | 21 +++++++++++++++++++++ include/linux/mmc/sdio_func.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index d40744b..4806521 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c @@ -725,3 +725,24 @@ int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) return 0; } EXPORT_SYMBOL_GPL(sdio_set_host_pm_flags); + +/** + * sdio_get_host_max_seg_size - get host maximum segment size + * @func: SDIO function attached to host + */ +unsigned int sdio_get_host_max_seg_size(struct sdio_func *func) +{ + return func->card->host->max_seg_size; +} +EXPORT_SYMBOL_GPL(sdio_get_host_max_seg_size); + +/** + * sdio_get_host_max_seg_count - get host maximum segment count + * @func: SDIO function attached to host + */ +unsigned short sdio_get_host_max_seg_count(struct sdio_func *func) +{ + return func->card->host->max_segs; +} +EXPORT_SYMBOL_GPL(sdio_get_host_max_seg_count); + diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index 97ca105..72d4de4 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h @@ -159,4 +159,7 @@ extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func); extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags); +unsigned short sdio_get_host_max_seg_count(struct sdio_func *func); +unsigned int sdio_get_host_max_seg_size(struct sdio_func *func); + #endif /* LINUX_MMC_SDIO_FUNC_H */