diff mbox

[v5,1/2] mmc: API for accessing host supported maximum segment count and size

Message ID 1511336987-21263-1-git-send-email-huxm@marvell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xinming Hu Nov. 22, 2017, 7:49 a.m. UTC
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 <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
---
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.
---
 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(-)

Comments

Ulf Hansson Dec. 19, 2017, 8:36 a.m. UTC | #1
On 22 November 2017 at 08:49, Xinming Hu <huxm@marvell.com> wrote:
> 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.

Apologize for the delay.

Overall, this makes perfect sense to me. However some minor comment, see below.

>
> Signed-off-by: Xinming Hu <huxm@marvell.com>
> Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
> ---
> 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.
> ---
>  drivers/mmc/core/sdio_io.c                          | 21 +++++++++++++++++++++
>  .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c   |  6 +++---

The changes to the wifi driver, could please make that a separate
patch on top of this one?

There are actually a couple of more wireless drivers that should
convert to use these new API, I would appreciate if you could fold in
patches in the series for each of them as well (don't forget to cc
correct people for them), then I intend to apply all of them via my
tree, if no objections.

Otherwise this change looks good to me!

[...]

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index cd58732..bbad62d 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 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 */