diff mbox series

[2/2] mmc : fix for check cqe halt.

Message ID 20240826091703.14631-1-sh8267.baek@samsung.com
State Superseded
Headers show
Series None | expand

Commit Message

Seunghwan Baek Aug. 26, 2024, 9:17 a.m. UTC
To check if mmc cqe is in halt state, need to check set/clear of CQHCI_HALT
bit. At this time, we need to check with &, not &&. Therefore, code to
check whether cqe is in halt state is modified to cqhci_halted, which has
already been implemented.

Fixes: 0653300224a6 ("mmc: cqhci: rename cqhci.c to cqhci-core.c")
Cc: stable@vger.kernel.org
Signed-off-by: Seunghwan Baek <sh8267.baek@samsung.com>
---
 drivers/mmc/host/cqhci-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Adrian Hunter Aug. 26, 2024, 10:16 a.m. UTC | #1
On 26/08/24 12:17, Seunghwan Baek wrote:

The subject starts with "[Patch 2/2]" but is there another patch?
Did you mean "[Patch v2] ..."?

> To check if mmc cqe is in halt state, need to check set/clear of CQHCI_HALT
> bit. At this time, we need to check with &, not &&. Therefore, code to> check whether cqe is in halt state is modified to cqhci_halted, which has
> already been implemented.

Doesn't compile:

drivers/mmc/host/cqhci-core.c: In function ‘__cqhci_enable’:
drivers/mmc/host/cqhci-core.c:285:13: error: implicit declaration of function ‘cqhci_halted’; did you mean ‘cqhci_writel’? [-Werror=implicit-function-declaration]
  285 |         if (cqhci_halted(cq_host))
      |             ^~~~~~~~~~~~
      |             cqhci_writel
drivers/mmc/host/cqhci-core.c: At top level:
drivers/mmc/host/cqhci-core.c:956:13: error: conflicting types for ‘cqhci_halted’; have ‘bool(struct cqhci_host *)’ {aka ‘_Bool(struct cqhci_host *)’}
  956 | static bool cqhci_halted(struct cqhci_host *cq_host)
      |             ^~~~~~~~~~~~
drivers/mmc/host/cqhci-core.c:285:13: note: previous implicit declaration of ‘cqhci_halted’ with type ‘int()’
  285 |         if (cqhci_halted(cq_host))
      |             ^~~~~~~~~~~~
cc1: all warnings being treated as errors

Not only should it compile, but you must test it!

Probably better to make 2 patches:
1. Just the fix, cc stable i.e.

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index c14d7251d0bb..a02da26a1efd 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -617,7 +617,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		cqhci_writel(cq_host, 0, CQHCI_CTL);
 		mmc->cqe_on = true;
 		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
-		if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) {
+		if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
 			pr_err("%s: cqhci: CQE failed to exit halt state\n",
 			       mmc_hostname(mmc));
 		}

2. Tidy up, no cc stable

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index a02da26a1efd..178277d90c31 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -33,6 +33,11 @@ struct cqhci_slot {
 #define CQHCI_HOST_OTHER	BIT(4)
 };
 
+static bool cqhci_halted(struct cqhci_host *cq_host)
+{
+	return cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT;
+}
+
 static inline u8 *get_desc(struct cqhci_host *cq_host, u8 tag)
 {
 	return cq_host->desc_base + (tag * cq_host->slot_sz);
@@ -282,7 +287,7 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
 
 	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
 
-	if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
+	if (cqhci_halted(cq_host))
 		cqhci_writel(cq_host, 0, CQHCI_CTL);
 
 	mmc->cqe_on = true;
@@ -617,7 +622,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		cqhci_writel(cq_host, 0, CQHCI_CTL);
 		mmc->cqe_on = true;
 		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
-		if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
+		if (cqhci_halted(cq_host)) {
 			pr_err("%s: cqhci: CQE failed to exit halt state\n",
 			       mmc_hostname(mmc));
 		}
@@ -953,11 +958,6 @@ static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout)
 	return ret;
 }
 
-static bool cqhci_halted(struct cqhci_host *cq_host)
-{
-	return cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT;
-}
-
 static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)
 {
 	struct cqhci_host *cq_host = mmc->cqe_private;



> 
> Fixes: 0653300224a6 ("mmc: cqhci: rename cqhci.c to cqhci-core.c")

Fixes tag should be the commit that introduced the code, not one
that moved it.  In this case, it has been there since the beginning:

Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")

Looks like the offending code kinda worked which explains why it
wasn't noticed sooner.

> Cc: stable@vger.kernel.org
> Signed-off-by: Seunghwan Baek <sh8267.baek@samsung.com>
> ---
>  drivers/mmc/host/cqhci-core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
> index c14d7251d0bb..3d5bcb92c78e 100644
> --- a/drivers/mmc/host/cqhci-core.c
> +++ b/drivers/mmc/host/cqhci-core.c
> @@ -282,7 +282,7 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
>  
>  	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
>  
> -	if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
> +	if (cqhci_halted(cq_host))
>  		cqhci_writel(cq_host, 0, CQHCI_CTL);
>  
>  	mmc->cqe_on = true;
> @@ -617,7 +617,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
>  		cqhci_writel(cq_host, 0, CQHCI_CTL);
>  		mmc->cqe_on = true;
>  		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
> -		if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) {
> +		if (cqhci_halted(cq_host)) {
>  			pr_err("%s: cqhci: CQE failed to exit halt state\n",
>  			       mmc_hostname(mmc));
>  		}
Seunghwan Baek Aug. 27, 2024, 1:42 a.m. UTC | #2
> The subject starts with "[Patch 2/2]" but is there another patch?
> Did you mean "[Patch v2] ..."?
> 
> > To check if mmc cqe is in halt state, need to check set/clear of
> > CQHCI_HALT bit. At this time, we need to check with &, not &&.
> > Therefore, code to> check whether cqe is in halt state is modified to
> cqhci_halted, which has already been implemented.
> 
> Doesn't compile:
> 
> drivers/mmc/host/cqhci-core.c: In function ‘__cqhci_enable’:
> drivers/mmc/host/cqhci-core.c:285:13: error: implicit declaration of
> function ‘cqhci_halted’; did you mean ‘cqhci_writel’? [-Werror=implicit-
> function-declaration]
>   285 |         if (cqhci_halted(cq_host))
>       |             ^~~~~~~~~~~~
>       |             cqhci_writel
> drivers/mmc/host/cqhci-core.c: At top level:
> drivers/mmc/host/cqhci-core.c:956:13: error: conflicting types for
> ‘cqhci_halted’; have ‘bool(struct cqhci_host *)’ {aka ‘_Bool(struct
> cqhci_host *)’}
>   956 | static bool cqhci_halted(struct cqhci_host *cq_host)
>       |             ^~~~~~~~~~~~
> drivers/mmc/host/cqhci-core.c:285:13: note: previous implicit declaration
> of ‘cqhci_halted’ with type ‘int()’
>   285 |         if (cqhci_halted(cq_host))
>       |             ^~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> Not only should it compile, but you must test it!
> 
> Probably better to make 2 patches:
> 1. Just the fix, cc stable i.e.
> 
> diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
> index c14d7251d0bb..a02da26a1efd 100644
> --- a/drivers/mmc/host/cqhci-core.c
> +++ b/drivers/mmc/host/cqhci-core.c
> @@ -617,7 +617,7 @@ static int cqhci_request(struct mmc_host *mmc, struct
> mmc_request *mrq)
>  		cqhci_writel(cq_host, 0, CQHCI_CTL);
>  		mmc->cqe_on = true;
>  		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
> -		if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) {
> +		if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
>  			pr_err("%s: cqhci: CQE failed to exit halt state\n",
>  			       mmc_hostname(mmc));
>  		}
> 
> 2. Tidy up, no cc stable
> 
> diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
> index a02da26a1efd..178277d90c31 100644
> --- a/drivers/mmc/host/cqhci-core.c
> +++ b/drivers/mmc/host/cqhci-core.c
> @@ -33,6 +33,11 @@ struct cqhci_slot {
>  #define CQHCI_HOST_OTHER	BIT(4)
>  };
> 
> +static bool cqhci_halted(struct cqhci_host *cq_host) {
> +	return cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT; }
> +
>  static inline u8 *get_desc(struct cqhci_host *cq_host, u8 tag)  {
>  	return cq_host->desc_base + (tag * cq_host->slot_sz); @@ -282,7
> +287,7 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
> 
>  	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
> 
> -	if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
> +	if (cqhci_halted(cq_host))
>  		cqhci_writel(cq_host, 0, CQHCI_CTL);
> 
>  	mmc->cqe_on = true;
> @@ -617,7 +622,7 @@ static int cqhci_request(struct mmc_host *mmc, struct
> mmc_request *mrq)
>  		cqhci_writel(cq_host, 0, CQHCI_CTL);
>  		mmc->cqe_on = true;
>  		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
> -		if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
> +		if (cqhci_halted(cq_host)) {
>  			pr_err("%s: cqhci: CQE failed to exit halt state\n",
>  			       mmc_hostname(mmc));
>  		}
> @@ -953,11 +958,6 @@ static bool cqhci_clear_all_tasks(struct mmc_host
> *mmc, unsigned int timeout)
>  	return ret;
>  }
> 
> -static bool cqhci_halted(struct cqhci_host *cq_host) -{
> -	return cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT;
> -}
> -
>  static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)  {
>  	struct cqhci_host *cq_host = mmc->cqe_private;
> 
> 
> 
> >
> > Fixes: 0653300224a6 ("mmc: cqhci: rename cqhci.c to cqhci-core.c")
> 
> Fixes tag should be the commit that introduced the code, not one that
> moved it.  In this case, it has been there since the beginning:
> 
> Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
> 
> Looks like the offending code kinda worked which explains why it wasn't
> noticed sooner.
> 
Sorry for my mistake.

I will make the patch again as you advised.

Thank you for your help.

> > Cc: stable@vger.kernel.org
> > Signed-off-by: Seunghwan Baek <sh8267.baek@samsung.com>
> > ---
> >  drivers/mmc/host/cqhci-core.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/cqhci-core.c
> > b/drivers/mmc/host/cqhci-core.c index c14d7251d0bb..3d5bcb92c78e
> > 100644
> > --- a/drivers/mmc/host/cqhci-core.c
> > +++ b/drivers/mmc/host/cqhci-core.c
> > @@ -282,7 +282,7 @@ static void __cqhci_enable(struct cqhci_host
> > *cq_host)
> >
> >  	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
> >
> > -	if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
> > +	if (cqhci_halted(cq_host))
> >  		cqhci_writel(cq_host, 0, CQHCI_CTL);
> >
> >  	mmc->cqe_on = true;
> > @@ -617,7 +617,7 @@ static int cqhci_request(struct mmc_host *mmc,
> struct mmc_request *mrq)
> >  		cqhci_writel(cq_host, 0, CQHCI_CTL);
> >  		mmc->cqe_on = true;
> >  		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
> > -		if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) {
> > +		if (cqhci_halted(cq_host)) {
> >  			pr_err("%s: cqhci: CQE failed to exit halt state\n",
> >  			       mmc_hostname(mmc));
> >  		}
diff mbox series

Patch

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index c14d7251d0bb..3d5bcb92c78e 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -282,7 +282,7 @@  static void __cqhci_enable(struct cqhci_host *cq_host)
 
 	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
 
-	if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
+	if (cqhci_halted(cq_host))
 		cqhci_writel(cq_host, 0, CQHCI_CTL);
 
 	mmc->cqe_on = true;
@@ -617,7 +617,7 @@  static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		cqhci_writel(cq_host, 0, CQHCI_CTL);
 		mmc->cqe_on = true;
 		pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
-		if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) {
+		if (cqhci_halted(cq_host)) {
 			pr_err("%s: cqhci: CQE failed to exit halt state\n",
 			       mmc_hostname(mmc));
 		}