Skip to contentSkip to conversation

mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

PATCH New Josh Wu 3 participants 11 messages Nov 5, 2013 – Nov 13, 2013

Subsystems (3)
lore
Share & tools
lore

Josh Wu

author
#0 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

In the atmel driver probe function, the code shows like following:

  atmel_nand_probe(...) {
        ...
  err_nand_ioremap:
        platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
  }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

---
 drivers/mtd/nand/atmel_nand.c |    1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/atmel_nand.c +0 -1
index ef9c9f5..469d4e2 100644
@@ -2142,7 +2142,6 @@ err_no_card:
 	if (host->dma_chan)
 		dma_release_channel(host->dma_chan);
 err_nand_ioremap:
-	platform_driver_unregister(&atmel_nand_nfc_driver);
 	return res;
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

Hi Josh,

Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

  atmel_nand_probe(...) {
        ...
  err_nand_ioremap:
        platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
  }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right? Shouldn't both drivers just be registered/unregistered in the module init/exit, and not in probe()?

Also, should this be marked for -stable?

Quoted 10 lines
---
 drivers/mtd/nand/atmel_nand.c |    1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/atmel_nand.c +0 -0
index ef9c9f5..469d4e2 100644

drivers/mtd/nand/atmel_nand.c err_no_card: · line 2147

Quoted 7 lines
drivers/mtd/nand/atmel_nand.c +0 -1
@@ -2142,7 +2142,6 @@ err_no_card:
 	if (host->dma_chan)
 		dma_release_channel(host->dma_chan);
 err_nand_ioremap:
-	platform_driver_unregister(&atmel_nand_nfc_driver);
 	return res;
 }
 

Brian

author
#2 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

Hi, Brian

Quoted 19 lines · Brian Norris

Hi Josh,

Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

   atmel_nand_probe(...) {
         ...

   err_nand_ioremap:
         platform_driver_unregister(&atmel_nand_nfc_driver);
         return res;
   }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines
Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right?

right.

Quoted 2 lines

Shouldn't both drivers just be
registered/unregistered in the module init/exit, and not in probe()?

currently the NFC driver is registered in the beginning of nand probe function. After NFC driver is initialized, the rest of the nand probe function
will check the NFC driver status.
I am not sure it is proper to registered another driver in a probe().

Quoted 2 lines

Also, should this be marked for -stable?

Shouldn't cc to stable after the patch is merged in mtd mail list?

Best Regards,
Josh Wu

Quoted 19 lines
Quoted 11 lines
---
  drivers/mtd/nand/atmel_nand.c |    1 -
  1 file changed, 1 deletion(-)
drivers/mtd/nand/atmel_nand.c +0 -0
index ef9c9f5..469d4e2 100644

drivers/mtd/nand/atmel_nand.c err_no_card: · line 2147

Quoted 7 lines
drivers/mtd/nand/atmel_nand.c +0 -1
@@ -2142,7 +2142,6 @@ err_no_card:
  	if (host->dma_chan)
  		dma_release_channel(host->dma_chan);
  err_nand_ioremap:
-	platform_driver_unregister(&atmel_nand_nfc_driver);
  	return res;
  }
 

Brian

#3 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

On 07/11/2013 11:26, Josh Wu :

Quoted 40 lines

Hi, Brian

Quoted 19 lines · Brian Norris

Hi Josh,

Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

    atmel_nand_probe(...) {
          ...

    err_nand_ioremap:
          platform_driver_unregister(&atmel_nand_nfc_driver);
          return res;
    }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines
Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right?

right.

Quoted 2 lines

Shouldn't both drivers just be
registered/unregistered in the module init/exit, and not in probe()?

currently the NFC driver is registered in the beginning of nand probe function. After NFC driver is initialized, the rest of the nand probe function
will check the NFC driver status.
I am not sure it is proper to registered another driver in a probe().

Quoted 1 line
Quoted 3 lines
Quoted 1 line

Also, should this be marked for -stable?

Shouldn't cc to stable after the patch is merged in mtd mail list?

Whether you add a Cc: tag in your signature location or you send another patch to the stable mailing list *but* only when the patch is accepted in Linus' git tree.

You can find the information in
Documentation/stable_kernel_rules.txt

Bye,

Quoted 21 lines
Quoted 18 lines
Quoted 10 lines
---
   drivers/mtd/nand/atmel_nand.c |    1 -
   1 file changed, 1 deletion(-)
drivers/mtd/nand/atmel_nand.c +0 -0
index ef9c9f5..469d4e2 100644

drivers/mtd/nand/atmel_nand.c err_no_card: · line 2147

Quoted 7 lines
drivers/mtd/nand/atmel_nand.c +0 -1
@@ -2142,7 +2142,6 @@ err_no_card:
   	if (host->dma_chan)
   		dma_release_channel(host->dma_chan);
   err_nand_ioremap:
-	platform_driver_unregister(&atmel_nand_nfc_driver);
   	return res;
   }
 

Brian

Signature · 1 line
Nicolas Ferre
#4 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

In reply to Josh Wu
Quoted 30 lines · Josh Wu

Hi, Brian

Quoted 19 lines · Brian Norris

Hi Josh,

Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

  atmel_nand_probe(...) {
        ...
  err_nand_ioremap:
        platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
  }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines
Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right?

right.

Quoted 8 lines
Quoted 2 lines

Shouldn't both drivers just be
registered/unregistered in the module init/exit, and not in probe()?

currently the NFC driver is registered in the beginning of nand probe function. After NFC driver is initialized, the rest of the nand probe function
will check the NFC driver status.
I am not sure it is proper to registered another driver in a probe().

This whole 2-driver registration process seems like a totally racy mess. Unless I'm reading this wrong, the code is entirely wrong. You are not properly expressing the dependency between the NFC device and the atmel_nand device, so I think you're relying purely on happenstance that when the NAND probe registers the NFC driver, it will complete the NFC probe before the NAND probe reaches:

  if (nand_nfc.is_initialized) {
    ...

This is a race, no?

Anyway, I think the current patch (fixing a deadlock) is still ready for stable, while I would expect you can fix up this racy situation in a subsequent patch. Or perhaps I'm misreading something?

Brian

author
#5 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

Hi, Brain

I resend with non-html format to make it acceptable in mail list.

Quoted 44 lines · Brian Norris
Quoted 29 lines · Josh Wu

Hi, Brian

Quoted 19 lines · Brian Norris

Hi Josh,

Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

   atmel_nand_probe(...) {
         ...

   err_nand_ioremap:
         platform_driver_unregister(&atmel_nand_nfc_driver);
         return res;
   }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines
Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right?

right.

Quoted 7 lines
Quoted 2 lines

Shouldn't both drivers just be
registered/unregistered in the module init/exit, and not in probe()?

currently the NFC driver is registered in the beginning of nand probe function. After NFC driver is initialized, the rest of the nand probe function
will check the NFC driver status.
I am not sure it is proper to registered another driver in a probe().

This whole 2-driver registration process seems like a totally racy mess. Unless I'm reading this wrong, the code is entirely wrong. You are not properly expressing the dependency between the NFC device and the atmel_nand device, so I think you're relying purely on happenstance that when the NAND probe registers the NFC driver, it will complete the NFC probe before the NAND probe reaches:

Quoted 2 lines
   if (nand_nfc.is_initialized) {
     ...

Yes, exactly.
And the NAND probe will also load the NFC device before it reach above check code.
That is what I want: make *nfc probe function* is running before reach above check code.

Quoted 2 lines

This is a race, no?

So I don't think there is a race, as NFC probe will always run before the check code:

   if (nand_nfc.is_initialized) {
     ...
Quoted 4 lines

Anyway, I think the current patch (fixing a deadlock) is still ready for stable, while I would expect you can fix up this racy situation in a subsequent patch. Or perhaps I'm misreading something?

I think my subsequent patch is to move the register/unregister() function to the module_init/exit().
And in the module_init(), make sure register NFC driver before NAND driver. That means I will revert the change that convert module_init/exit() to module_platform_driver_probe().

So the whole flow will like that:

module_init()
register nfc driver
register nand driver

nand driver probe() {

     # register nfc driver --> move to module_init()
     populate nfc device
       since nfc driver is registered, so nfc_probe() is called (init nfc)
     check whether nfc is initialized
     ...
   }

module_exit()
unregister nand driver
unregister nfc driver

Quoted 2 lines

Brian

Best Regards,
Josh Wu

#6 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

+ Greg KH

Hi Josh,

Quoted 42 lines · Josh Wu
Quoted 41 lines · Brian Norris
Quoted 25 lines · Josh Wu
Quoted 17 lines · Brian Norris
Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

  atmel_nand_probe(...) {
        ...
  err_nand_ioremap:
        platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
  }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines
Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right?

right.

Quoted 7 lines
Quoted 2 lines

Shouldn't both drivers just be
registered/unregistered in the module init/exit, and not in probe()?

currently the NFC driver is registered in the beginning of nand probe function. After NFC driver is initialized, the rest of the nand probe function
will check the NFC driver status.
I am not sure it is proper to registered another driver in a probe().

This whole 2-driver registration process seems like a totally racy mess.

Unless I'm reading this wrong, the code is entirely wrong. You are not properly expressing the dependency between the NFC device and the atmel_nand device, so I think you're relying purely on happenstance that when the NAND probe registers the NFC driver, it will complete the NFC probe before the NAND probe reaches:

Quoted 6 lines
Quoted 2 lines
  if (nand_nfc.is_initialized) {
    ...

Yes, exactly.
And the NAND probe will also load the NFC device before it reach above check code.

No, it loads the *driver*, not the *device*. I'm not familiar with the driver core guarantees, but I don't think you can guarantee that just because a driver was registered before another that the corresponding devices will be probed in that order. Or are you relying on the dependencies captured by device tree? (I don't think even the parent/child dependency between NAND/NFC gives you enough.)

Quoted 10 lines

That is what I want: make *nfc probe function* is running before reach above check code.

Quoted 2 lines

This is a race, no?

So I don't think there is a race, as NFC probe will always run before the check code:

  if (nand_nfc.is_initialized) {
    ...

It is not clear to me how you guarantee this.

Quoted 13 lines
Quoted 4 lines

Anyway, I think the current patch (fixing a deadlock) is still ready for stable, while I would expect you can fix up this racy situation in a subsequent patch. Or perhaps I'm misreading something?

I think my subsequent patch is to move the register/unregister() function to the module_init/exit().
And in the module_init(), make sure register NFC driver before NAND driver. That means I will revert the change that convert module_init/exit() to module_platform_driver_probe().

So the whole flow will like that:

Quoted 7 lines

module_init()
register nfc driver
register nand driver

nand driver probe() {

    # register nfc driver --> move to module_init()
    populate nfc device

How do you guarantee this "populate" happens here?

Quoted 1 line

since nfc driver is registered, so nfc_probe() is called (init nfc)

I'm not sure where you get this. Can you point to a line in the code?

Quoted 7 lines

check whether nfc is initialized
...
}

module_exit()
unregister nand driver
unregister nfc driver

Brian

author
#7 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

Quoted 52 lines · Brian Norris

+ Greg KH

Hi Josh,

Quoted 42 lines · Josh Wu
Quoted 41 lines · Brian Norris
Quoted 25 lines · Josh Wu
Quoted 17 lines · Brian Norris
Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

   atmel_nand_probe(...) {
         ...

   err_nand_ioremap:
         platform_driver_unregister(&atmel_nand_nfc_driver);
         return res;
   }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines
Quoted 3 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

The real key, here, is that the platform-driver probe() has no business un-registering another driver, right?

right.

Quoted 7 lines
Quoted 2 lines

Shouldn't both drivers just be
registered/unregistered in the module init/exit, and not in probe()?

currently the NFC driver is registered in the beginning of nand probe function. After NFC driver is initialized, the rest of the nand probe function
will check the NFC driver status.
I am not sure it is proper to registered another driver in a probe().

This whole 2-driver registration process seems like a totally racy mess.

Unless I'm reading this wrong, the code is entirely wrong. You are not properly expressing the dependency between the NFC device and the atmel_nand device, so I think you're relying purely on happenstance that when the NAND probe registers the NFC driver, it will complete the NFC probe before the NAND probe reaches:

Quoted 5 lines
Quoted 2 lines
   if (nand_nfc.is_initialized) {
     ...

Yes, exactly.
And the NAND probe will also load the NFC device before it reach above check code.

Quoted 6 lines

No, it loads the *driver*, not the *device*. I'm not familiar with the driver core guarantees, but I don't think you can guarantee that just because a driver was registered before another that the corresponding devices will be probed in that order. Or are you relying on the dependencies captured by device tree? (I don't think even the parent/child dependency between NAND/NFC gives you enough.)

Hi, Brain

I put more code here to make it clearer:

arch/arm/boot/dts/sama5d3.dtsi:

nand0: nand at 60000000 {
             compatible = "atmel,at91rm9200-nand";
             ...
             ranges;
             ...
             nfc at 70000000 {
                 compatible = "atmel,sama5d3-nfc";
                 ...
             };
         };

drivers/mtd/nand/atmel_nand.c

int atmel_of_init_port() {
    ...
    /* load the nfc driver if there is */

of_platform_populate(np, NULL, NULL, host->dev); # <--- Manually
populate the sub node (NFC node) to load NFC driver
...
}

static int atmel_nand_nfc_probe(struct platform_device *pdev)

{
     struct atmel_nfc *nfc = &nand_nfc;
     ...
     nfc->is_initialized = true;
     dev_info(&pdev->dev, "NFC is probed.\n");
     return 0;
}

atmel_nand_probe() {
...
res = platform_driver_register(&atmel_nand_nfc_driver); # Register
NFC driver.

    ...
    if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
       res = atmel_of_init_port(host, pdev->dev.of_node);
       #       ^^^^^^^^^^ ^^^^^^  In this function, it will populate the 

NFC node shows in above code block.
# It triggers the NFC driver's probe() function. Which will set
the 'nand_nfc.is_initialized' as true.

    } else {
       ...
    }
    ...

    if (nand_nfc.is_initialized) {               # now we know the NFC 
driver is probed.
       ...
    }
    ...
}

in summary, the following flow to make sure NFC is initialized in atmel_nand_probe():
atmel_nand_probe() {
Register NFC.
dt property check. That populates the NFC dt node.
Via the NFC compatible string, system find the registered NFC
driver, so call the NFC probe() function.
NFC probe will initialized the NFC.
Check NFC is initialized or not.
}

Quoted 26 lines
Quoted 9 lines

That is what I want: make *nfc probe function* is running before reach above check code.

Quoted 1 line

This is a race, no?

So I don't think there is a race, as NFC probe will always run before the check code:

   if (nand_nfc.is_initialized) {
     ...

It is not clear to me how you guarantee this.

Quoted 15 lines
Quoted 3 lines

Anyway, I think the current patch (fixing a deadlock) is still ready for stable, while I would expect you can fix up this racy situation in a subsequent patch. Or perhaps I'm misreading something?

I think my subsequent patch is to move the register/unregister() function to the module_init/exit().
And in the module_init(), make sure register NFC driver before NAND driver. That means I will revert the change that convert module_init/exit() to module_platform_driver_probe().

So the whole flow will like that:

module_init()
register nfc driver
register nand driver

Quoted 8 lines
Quoted 3 lines

nand driver probe() {

     # register nfc driver --> move to module_init()
     populate nfc device

How do you guarantee this "populate" happens here?

Quoted 1 line

since nfc driver is registered, so nfc_probe() is called (init nfc)

I'm not sure where you get this. Can you point to a line in the code?

atmel_nand_probe() {
    ...
    atmel_of_init_port(host, pdev->dev.of_node);
    ...
}
int atmel_of_init_port() {
    ...
    /* load the nfc driver if there is */

of_platform_populate(np, NULL, NULL, host->dev);
...
}

Quoted 9 lines
Quoted 8 lines

check whether nfc is initialized
...
}

module_exit()
unregister nand driver
unregister nfc driver

Brian

Best Regards,
Josh Wu

#8 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

Hi Josh,

Quoted 18 lines · Josh Wu
Quoted 7 lines · Brian Norris
Quoted 6 lines · Josh Wu
Quoted 2 lines · Brian Norris
  if (nand_nfc.is_initialized) {
    ...

Yes, exactly.
And the NAND probe will also load the NFC device before it reach above check code.

Quoted 6 lines

No, it loads the *driver*, not the *device*. I'm not familiar with the driver core guarantees, but I don't think you can guarantee that just because a driver was registered before another that the corresponding devices will be probed in that order. Or are you relying on the dependencies captured by device tree? (I don't think even the parent/child dependency between NAND/NFC gives you enough.)

I put more code here to make it clearer:

arch/arm/boot/dts/sama5d3.dtsi:

Quoted 10 lines
nand0: nand at 60000000 {
            compatible = "atmel,at91rm9200-nand";
            ...
            ranges;
            ...
            nfc at 70000000 {
                compatible = "atmel,sama5d3-nfc";
                ...
            };
        };

Ah, so you're focusing purely on the device tree support? It seems this driver also supports traditional platform devices, but nobody uses NFC without DT? That explains some things.

Quoted 8 lines

drivers/mtd/nand/atmel_nand.c

int atmel_of_init_port() {
   ...
   /* load the nfc driver if there is */

of_platform_populate(np, NULL, NULL, host->dev); # <--- Manually
populate the sub node (NFC node) to load NFC driver
...
}

Right, that makes sense. So the ordering of the driver registration stuff is kind of a distraction in this case, then. It's this portion of the NAND probe that triggers bus_probe_device() to initialize the NFC device before continuing on.

[snip rest of explanation; thanks!]

So I don't think you have a problem for device tree platforms. But if someone were to try to instantiate these devices via platform_device_register(), they will have a problem.

Please, do follow up with the cleanup to the driver registration that you mentioned.

Brian

#9 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

On 13/11/2013 09:44, Brian Norris :

Quoted 32 lines

Hi Josh,

Quoted 18 lines · Josh Wu
Quoted 7 lines · Brian Norris
Quoted 6 lines · Josh Wu
Quoted 2 lines · Brian Norris
   if (nand_nfc.is_initialized) {
     ...

Yes, exactly.
And the NAND probe will also load the NFC device before it reach above check code.

Quoted 6 lines

No, it loads the *driver*, not the *device*. I'm not familiar with the driver core guarantees, but I don't think you can guarantee that just because a driver was registered before another that the corresponding devices will be probed in that order. Or are you relying on the dependencies captured by device tree? (I don't think even the parent/child dependency between NAND/NFC gives you enough.)

I put more code here to make it clearer:

arch/arm/boot/dts/sama5d3.dtsi:

Quoted 10 lines
nand0: nand at 60000000 {
             compatible = "atmel,at91rm9200-nand";
             ...
             ranges;
             ...
             nfc at 70000000 {
                 compatible = "atmel,sama5d3-nfc";
                 ...
             };
         };
Quoted 3 lines

Ah, so you're focusing purely on the device tree support? It seems this driver also supports traditional platform devices, but nobody uses NFC without DT? That explains some things.

Absolutely: the NFC is only available on SoC that are pure-DT.

The traditional platform device support is for older SoC that can use this driver but do not have the NFC.

I let Josh continue the discussion on the registration topic.

[..]

Bye,

Signature · 1 line
Nicolas Ferre
Applied
#10 lore raw

PATCH 1/1 mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected

In reply to Josh Wu
Quoted 16 lines · Josh Wu

In the atmel driver probe function, the code shows like following:

  atmel_nand_probe(...) {
        ...
  err_nand_ioremap:
        platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
  }

If no nand flash detected, the driver probe function will goto err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the lock of atmel_nand device since it is parent of nfc_device. The problem is the lock is already hold by atmel_nand_probe itself. So system will be in a dead lock.

Quoted 5 lines

This patch just simply removed to platform_driver_unregister() call. When atmel_nand driver is quit the platform_driver_unregister() will be called in atmel_nand_remove().

Pushed to l2-mtd.git, with a little extra note and a
Cc: <[email protected]>

Thanks,
Brian