All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mmc: clarifications on host.post_req()
@ 2011-08-29 13:35 ` Per Forlin
  0 siblings, 0 replies; 14+ messages in thread
From: Per Forlin @ 2011-08-29 13:35 UTC (permalink / raw)
  To: linaro-dev, linux-arm-kernel, linux-mmc, Venkatraman S,
	Russell King - ARM Linux, Santo
  Cc: Chris Ball, Per Forlin

Fixes for 3.1.
This patchset doesn't fix any bugs in 3.1 but it improves the documentation
in order to prevent new bugs.

Per Forlin (2):
  mmc: core: clarify how to use post_req in case of errors
  mmc: mmci: simplify err check in mmci_post_request

 drivers/mmc/core/core.c  |    6 ++++++
 drivers/mmc/host/mmci.c  |    2 +-
 include/linux/mmc/host.h |    3 +++
 3 files changed, 10 insertions(+), 1 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/2] mmc: clarifications on host.post_req()
@ 2011-08-29 13:35 ` Per Forlin
  0 siblings, 0 replies; 14+ messages in thread
From: Per Forlin @ 2011-08-29 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

Fixes for 3.1.
This patchset doesn't fix any bugs in 3.1 but it improves the documentation
in order to prevent new bugs.

Per Forlin (2):
  mmc: core: clarify how to use post_req in case of errors
  mmc: mmci: simplify err check in mmci_post_request

 drivers/mmc/core/core.c  |    6 ++++++
 drivers/mmc/host/mmci.c  |    2 +-
 include/linux/mmc/host.h |    3 +++
 3 files changed, 10 insertions(+), 1 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] mmc: core: clarify how to use post_req in case of errors
  2011-08-29 13:35 ` Per Forlin
@ 2011-08-29 13:35   ` Per Forlin
  -1 siblings, 0 replies; 14+ messages in thread
From: Per Forlin @ 2011-08-29 13:35 UTC (permalink / raw)
  To: linaro-dev, linux-arm-kernel, linux-mmc, Venkatraman S,
	Russell King - ARM Linux, Santo
  Cc: Chris Ball, Per Forlin

The err condition in post_req() is set to undo a call made
to pre_req() that hasn't been started yet.
The err condition is not set if an MMC request returns error.

Signed-off-by: Per Forlin <per.forlin@linaro.org>
---
 drivers/mmc/core/core.c  |    6 ++++++
 include/linux/mmc/host.h |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 91a0a74..542aa06 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -279,8 +279,14 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
 		mmc_wait_for_req_done(host, host->areq->mrq);
 		err = host->areq->err_check(host->card, host->areq);
 		if (err) {
+			/* post process the completed failed request */
 			mmc_post_req(host, host->areq->mrq, 0);
 			if (areq)
+				/*
+				 * Cancel the new prepared request, because
+				 * it can't run until the failed
+				 * request has been properly handled.
+				 */
 				mmc_post_req(host, areq->mrq, -EINVAL);
 
 			host->areq = NULL;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 1d09562..7896fb4 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -108,6 +108,9 @@ struct mmc_host_ops {
 	 * It is optional for the host to implement pre_req and post_req in
 	 * order to support double buffering of requests (prepare one
 	 * request while another request is active).
+	 * pre_req() must always be followed by a post_req().
+	 * To undo a call made to pre_req(), call post_req() with
+	 * a nonzero err condition.
 	 */
 	void	(*post_req)(struct mmc_host *host, struct mmc_request *req,
 			    int err);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 1/2] mmc: core: clarify how to use post_req in case of errors
@ 2011-08-29 13:35   ` Per Forlin
  0 siblings, 0 replies; 14+ messages in thread
From: Per Forlin @ 2011-08-29 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

The err condition in post_req() is set to undo a call made
to pre_req() that hasn't been started yet.
The err condition is not set if an MMC request returns error.

Signed-off-by: Per Forlin <per.forlin@linaro.org>
---
 drivers/mmc/core/core.c  |    6 ++++++
 include/linux/mmc/host.h |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 91a0a74..542aa06 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -279,8 +279,14 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
 		mmc_wait_for_req_done(host, host->areq->mrq);
 		err = host->areq->err_check(host->card, host->areq);
 		if (err) {
+			/* post process the completed failed request */
 			mmc_post_req(host, host->areq->mrq, 0);
 			if (areq)
+				/*
+				 * Cancel the new prepared request, because
+				 * it can't run until the failed
+				 * request has been properly handled.
+				 */
 				mmc_post_req(host, areq->mrq, -EINVAL);
 
 			host->areq = NULL;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 1d09562..7896fb4 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -108,6 +108,9 @@ struct mmc_host_ops {
 	 * It is optional for the host to implement pre_req and post_req in
 	 * order to support double buffering of requests (prepare one
 	 * request while another request is active).
+	 * pre_req() must always be followed by a post_req().
+	 * To undo a call made to pre_req(), call post_req() with
+	 * a nonzero err condition.
 	 */
 	void	(*post_req)(struct mmc_host *host, struct mmc_request *req,
 			    int err);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] mmc: mmci: simplify err check in mmci_post_request
  2011-08-29 13:35 ` Per Forlin
@ 2011-08-29 13:35   ` Per Forlin
  -1 siblings, 0 replies; 14+ messages in thread
From: Per Forlin @ 2011-08-29 13:35 UTC (permalink / raw)
  To: linaro-dev, linux-arm-kernel, linux-mmc, Venkatraman S,
	Russell King - ARM Linux, Santo
  Cc: Chris Ball, Per Forlin

The error condition indicates that mmci_post_request() should cleanup
after the mmci_pre_request(). In this case the resources allocated by
device_prep_slave_sg() are freed by calling dmaengine_terminate_all().
dma_unmap_sg() should always be performed if the host_cookie is set.

Signed-off-by: Per Forlin <per.forlin@linaro.org>
---
 drivers/mmc/host/mmci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 56e9a41..40e4c05 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -529,7 +529,7 @@ static void mmci_post_request(struct mmc_host *mmc, struct mmc_request *mrq,
 	if (chan) {
 		if (err)
 			dmaengine_terminate_all(chan);
-		if (err || data->host_cookie)
+		if (data->host_cookie)
 			dma_unmap_sg(mmc_dev(host->mmc), data->sg,
 				     data->sg_len, dir);
 		mrq->data->host_cookie = 0;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] mmc: mmci: simplify err check in mmci_post_request
@ 2011-08-29 13:35   ` Per Forlin
  0 siblings, 0 replies; 14+ messages in thread
From: Per Forlin @ 2011-08-29 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

The error condition indicates that mmci_post_request() should cleanup
after the mmci_pre_request(). In this case the resources allocated by
device_prep_slave_sg() are freed by calling dmaengine_terminate_all().
dma_unmap_sg() should always be performed if the host_cookie is set.

Signed-off-by: Per Forlin <per.forlin@linaro.org>
---
 drivers/mmc/host/mmci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 56e9a41..40e4c05 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -529,7 +529,7 @@ static void mmci_post_request(struct mmc_host *mmc, struct mmc_request *mrq,
 	if (chan) {
 		if (err)
 			dmaengine_terminate_all(chan);
-		if (err || data->host_cookie)
+		if (data->host_cookie)
 			dma_unmap_sg(mmc_dev(host->mmc), data->sg,
 				     data->sg_len, dir);
 		mrq->data->host_cookie = 0;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] mmc: core: clarify how to use post_req in case of errors
  2011-08-29 13:35   ` Per Forlin
@ 2011-09-12 14:05     ` Linus Walleij
  -1 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2011-09-12 14:05 UTC (permalink / raw)
  To: Per Forlin
  Cc: Chris Ball, linaro-dev, Balaji T Krishnamoorthy, linux-mmc,
	Santosh, Russell King - ARM Linux, Sourav Poddar,
	linux-arm-kernel

On Mon, Aug 29, 2011 at 3:35 PM, Per Forlin <per.forlin@linaro.org> wrote:

> The err condition in post_req() is set to undo a call made
> to pre_req() that hasn't been started yet.
> The err condition is not set if an MMC request returns error.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>

Comments look correct so:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] mmc: core: clarify how to use post_req in case of errors
@ 2011-09-12 14:05     ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2011-09-12 14:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 29, 2011 at 3:35 PM, Per Forlin <per.forlin@linaro.org> wrote:

> The err condition in post_req() is set to undo a call made
> to pre_req() that hasn't been started yet.
> The err condition is not set if an MMC request returns error.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>

Comments look correct so:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] mmc: mmci: simplify err check in mmci_post_request
  2011-08-29 13:35   ` Per Forlin
@ 2011-09-12 14:06     ` Linus Walleij
  -1 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2011-09-12 14:06 UTC (permalink / raw)
  To: Per Forlin
  Cc: linaro-dev, linux-arm-kernel, linux-mmc, Venkatraman S,
	Russell King - ARM Linux, Santosh, Balaji T Krishnamoorthy,
	Sourav Poddar, Chris Ball

On Mon, Aug 29, 2011 at 3:35 PM, Per Forlin <per.forlin@linaro.org> wrote:

> The error condition indicates that mmci_post_request() should cleanup
> after the mmci_pre_request(). In this case the resources allocated by
> device_prep_slave_sg() are freed by calling dmaengine_terminate_all().
> dma_unmap_sg() should always be performed if the host_cookie is set.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/2] mmc: mmci: simplify err check in mmci_post_request
@ 2011-09-12 14:06     ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2011-09-12 14:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 29, 2011 at 3:35 PM, Per Forlin <per.forlin@linaro.org> wrote:

> The error condition indicates that mmci_post_request() should cleanup
> after the mmci_pre_request(). In this case the resources allocated by
> device_prep_slave_sg() are freed by calling dmaengine_terminate_all().
> dma_unmap_sg() should always be performed if the host_cookie is set.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] mmc: clarifications on host.post_req()
  2011-08-29 13:35 ` Per Forlin
@ 2011-09-21 18:30   ` Chris Ball
  -1 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2011-09-21 18:30 UTC (permalink / raw)
  To: Per Forlin
  Cc: linaro-dev, linux-arm-kernel, linux-mmc, Venkatraman S,
	Russell King - ARM Linux

Hi Per,

On Mon, Aug 29 2011, Per Forlin wrote:
> Fixes for 3.1.
> This patchset doesn't fix any bugs in 3.1 but it improves the documentation
> in order to prevent new bugs.

I've merged this into mmc-next now, but I'm planning on sending it for
3.2 instead of 3.1 at this point; hope that's okay.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/2] mmc: clarifications on host.post_req()
@ 2011-09-21 18:30   ` Chris Ball
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Ball @ 2011-09-21 18:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Per,

On Mon, Aug 29 2011, Per Forlin wrote:
> Fixes for 3.1.
> This patchset doesn't fix any bugs in 3.1 but it improves the documentation
> in order to prevent new bugs.

I've merged this into mmc-next now, but I'm planning on sending it for
3.2 instead of 3.1 at this point; hope that's okay.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] mmc: clarifications on host.post_req()
  2011-09-21 18:30   ` Chris Ball
@ 2011-09-21 18:43     ` Per Fridén Förlin
  -1 siblings, 0 replies; 14+ messages in thread
From: Per Fridén Förlin @ 2011-09-21 18:43 UTC (permalink / raw)
  To: Chris Ball
  Cc: Per Forlin, linaro-dev, linux-arm-kernel, linux-mmc,
	Venkatraman S, Russell King - ARM Linux

On Wed, Sep 21, 2011 at 8:30 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi Per,
>
> On Mon, Aug 29 2011, Per Forlin wrote:
>> Fixes for 3.1.
>> This patchset doesn't fix any bugs in 3.1 but it improves the documentation
>> in order to prevent new bugs.
>
> I've merged this into mmc-next now, but I'm planning on sending it for
> 3.2 instead of 3.1 at this point; hope that's okay.
>
Fine with me.

Thanks,
Per

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/2] mmc: clarifications on host.post_req()
@ 2011-09-21 18:43     ` Per Fridén Förlin
  0 siblings, 0 replies; 14+ messages in thread
From: Per Fridén Förlin @ 2011-09-21 18:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 21, 2011 at 8:30 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi Per,
>
> On Mon, Aug 29 2011, Per Forlin wrote:
>> Fixes for 3.1.
>> This patchset doesn't fix any bugs in 3.1 but it improves the documentation
>> in order to prevent new bugs.
>
> I've merged this into mmc-next now, but I'm planning on sending it for
> 3.2 instead of 3.1 at this point; hope that's okay.
>
Fine with me.

Thanks,
Per

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-09-21 18:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-29 13:35 [PATCH 0/2] mmc: clarifications on host.post_req() Per Forlin
2011-08-29 13:35 ` Per Forlin
2011-08-29 13:35 ` [PATCH 1/2] mmc: core: clarify how to use post_req in case of errors Per Forlin
2011-08-29 13:35   ` Per Forlin
2011-09-12 14:05   ` Linus Walleij
2011-09-12 14:05     ` Linus Walleij
2011-08-29 13:35 ` [PATCH 2/2] mmc: mmci: simplify err check in mmci_post_request Per Forlin
2011-08-29 13:35   ` Per Forlin
2011-09-12 14:06   ` Linus Walleij
2011-09-12 14:06     ` Linus Walleij
2011-09-21 18:30 ` [PATCH 0/2] mmc: clarifications on host.post_req() Chris Ball
2011-09-21 18:30   ` Chris Ball
2011-09-21 18:43   ` Per Fridén Förlin
2011-09-21 18:43     ` Per Fridén Förlin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.