From patchwork Thu Jun 16 09:23:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitkumar Karwar X-Patchwork-Id: 9180227 X-Patchwork-Delegate: kvalo@adurom.com 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 4761960760 for ; Thu, 16 Jun 2016 09:25:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 339F028309 for ; Thu, 16 Jun 2016 09:25:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26EC128328; Thu, 16 Jun 2016 09:25:18 +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 7899328309 for ; Thu, 16 Jun 2016 09:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753849AbcFPJZQ (ORCPT ); Thu, 16 Jun 2016 05:25:16 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:19495 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753864AbcFPJYv (ORCPT ); Thu, 16 Jun 2016 05:24:51 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u5G9M5qn013892; Thu, 16 Jun 2016 02:24:48 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 23gj5fra85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Jun 2016 02:24:47 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Thu, 16 Jun 2016 02:24:44 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server id 15.0.1104.5 via Frontend Transport; Thu, 16 Jun 2016 02:24:43 -0700 Received: from pe-lt949 (unknown [10.31.130.198]) by maili.marvell.com (Postfix) with ESMTP id CFD5B3F7041; Thu, 16 Jun 2016 02:24:43 -0700 (PDT) Received: from pe-lt949 (localhost [127.0.0.1]) by pe-lt949 (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id u5G9OW60010789; Thu, 16 Jun 2016 14:54:33 +0530 Received: (from root@localhost) by pe-lt949 (8.14.4/8.14.4/Submit) id u5G9OUKH010788; Thu, 16 Jun 2016 14:54:30 +0530 From: Amitkumar Karwar To: CC: Nishant Sarmukadam , Wei-Ning Huang , , Cathy Luo , Xinming Hu , Amitkumar Karwar Subject: [PATCH v4 1/2] mmc: API for accessing host supported maximum segment count and size Date: Thu, 16 Jun 2016 14:53:25 +0530 Message-ID: <1466069006-10757-1-git-send-email-akarwar@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=2016-06-16_04:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606160110 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xinming Hu 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). --- drivers/mmc/core/sdio_io.c | 21 +++++++++++++++++++++ .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 6 +++--- include/linux/mmc/sdio_func.h | 3 +++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index 78cb4d5..b1ecacc 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c @@ -720,3 +720,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/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c index c4b89d2..ba579f4 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c @@ -896,9 +896,9 @@ void brcmf_sdiod_sgtable_alloc(struct brcmf_sdio_dev *sdiodev) max_blocks = min_t(uint, host->max_blk_count, 511u); sdiodev->max_request_size = min_t(uint, host->max_req_size, max_blocks * func->cur_blksize); - sdiodev->max_segment_count = min_t(uint, host->max_segs, - SG_MAX_SINGLE_ALLOC); - sdiodev->max_segment_size = host->max_seg_size; + sdiodev->max_segment_count = min_t(uint, SG_MAX_SINGLE_ALLOC, + sdio_get_host_max_seg_count(func)); + sdiodev->max_segment_size = sdio_get_host_max_seg_size(func); if (!sdiodev->sg_support) return; diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index aab032a..b2b91df 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 */