From: Richard Purdie <rpurdie@rpsys.net>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>,
bzolnier@gmail.com, linux-ide@vger.kernel.org
Subject: [RFC/BUG?] ide_cs's removable status
Date: Wed, 21 Sep 2005 17:15:28 +0100 [thread overview]
Message-ID: <1127319328.8542.57.camel@localhost.localdomain> (raw)
I have a handheld system that takes compact flash memory cards and uses
ide_cs to interface to them. I've been trying to kill off a load of
hotplug scripts and switch to using udev. As HAL is too bloated for the
handheld, I hacked some evil auto-mount udev scripts together. When I
insert a memory card, I see the disk get repeatedly mounted and
unmounted in a loop.
I realise auto-mounting via udev is evil but I think this highlights a
kernel driver issue.
I'm seeing the following sequence of events:
1. I insert the card
2. The partitions are scanned and block devices are created
3. udev creates the device nodes
4. udev triggers my mount script which mounts the device
5. mounting the device triggers check_disk_change() in block_dev.c
6. The bd_invalidated flag is set
7. rescan_partitions is hence called
8. the block devices are destroyed
9. goto 2
As ide_cs only creates the block devices when a card is present, I think
it shouldn't be set as removable. As a point of reference, the MMC
system does not set the removable flag for exactly this reason (There is
an email from Russell King explaining this -
http://lkml.org/lkml/2005/1/8/165).
It is worth noting the MMC subsystem works with my evil udev script. If
I apply the patch below (which removes the removable flag for flash
devices), I don't see this loop.
With the patch below, the is_flash variable can actually be removed as
its only useful purpose is in ide-disk.c in a "if (drive->removable
&& !(drive->is_flash)) {" statement...
I'm wondering if one of the more experienced IDE developers could give
some insight into which drivers use bits of code at the end of
do_identify() in ide-probe.c. Some questions:
1. Can anyone provide details on what the bits in id->config really
mean?
2. Which other drivers exploit the "if (id->config & (1<<7))
drive->removable = 1;" code? Is it just ide_cs?
3. Do any other drivers expose flash interfaces in the same way ide_cs
does but with "proper" removable media handling where the block device
is persistent?
If ide_cs is the only user of this code, there is scope for a reasonable
amount of cleanup here. Other than the ATAPI drivers, I can't see any
with special removable handling which leads me to believe none of this
code is required.
Comments welcome as I can't help feeling there's something I've missed.
I'll write a neater patch if there is some agreement on what needs to be
done.
Richard
Index: linux-2.6.13/drivers/ide/ide-probe.c
===================================================================
--- linux-2.6.13.orig/drivers/ide/ide-probe.c 2005-08-29 00:41:01.000000000 +0100
+++ linux-2.6.13/drivers/ide/ide-probe.c 2005-09-21 16:57:15.000000000 +0100
@@ -147,19 +147,19 @@
{
struct hd_driveid *id = drive->id;
- if (drive->removable) {
- if (id->config == 0x848a) return 1; /* CompactFlash */
- if (!strncmp(id->model, "KODAK ATA_FLASH", 15) /* Kodak */
- || !strncmp(id->model, "Hitachi CV", 10) /* Hitachi */
- || !strncmp(id->model, "SunDisk SDCFB", 13) /* old SanDisk */
- || !strncmp(id->model, "SanDisk SDCFB", 13) /* SanDisk */
- || !strncmp(id->model, "HAGIWARA HPC", 12) /* Hagiwara */
- || !strncmp(id->model, "LEXAR ATA_FLASH", 15) /* Lexar */
- || !strncmp(id->model, "ATA_FLASH", 9)) /* Simple Tech */
- {
- return 1; /* yes, it is a flash memory card */
- }
+ if (id->config == 0x848a) return 1; /* CompactFlash */
+
+ if (!strncmp(id->model, "KODAK ATA_FLASH", 15) /* Kodak */
+ || !strncmp(id->model, "Hitachi CV", 10) /* Hitachi */
+ || !strncmp(id->model, "SunDisk SDCFB", 13) /* old SanDisk */
+ || !strncmp(id->model, "SanDisk SDCFB", 13) /* SanDisk */
+ || !strncmp(id->model, "HAGIWARA HPC", 12) /* Hagiwara */
+ || !strncmp(id->model, "LEXAR ATA_FLASH", 15) /* Lexar */
+ || !strncmp(id->model, "ATA_FLASH", 9)) /* Simple Tech */
+ {
+ return 1; /* yes, it is a flash memory card */
}
+
return 0; /* no, it is not a flash memory card */
}
@@ -278,11 +278,15 @@
/*
* Not an ATAPI device: looks like a "regular" hard disk
*/
+
if (id->config & (1<<7))
drive->removable = 1;
- if (drive_is_flashcard(drive))
+ if (drive_is_flashcard(drive)) {
drive->is_flash = 1;
+ drive->removable = 0;
+ }
+
drive->media = ide_disk;
printk("%s DISK drive\n", (drive->is_flash) ? "CFA" : "ATA" );
QUIRK_LIST(drive);
next reply other threads:[~2005-09-21 16:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-21 16:15 Richard Purdie [this message]
2005-09-21 16:57 ` [RFC/BUG?] ide_cs's removable status Alan Cox
2005-09-21 17:21 ` Mark Lord
2005-09-21 18:27 ` Alan Cox
2005-09-21 18:46 ` Richard Purdie
2005-09-22 0:18 ` Alan Cox
2002-01-01 5:18 ` Pavel Machek
2005-09-21 19:29 ` Russell King
2005-09-21 21:52 ` Richard Purdie
2005-09-22 0:06 ` Alan Cox
2005-09-22 0:10 ` Alan Cox
2005-09-22 10:22 ` Russell King
2005-09-22 13:39 ` Alan Cox
2005-09-22 13:29 ` Russell King
2005-09-22 14:41 ` Alan Cox
2005-09-22 14:21 ` Richard Purdie
2005-09-22 14:36 ` Russell King
2005-09-22 15:08 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1127319328.8542.57.camel@localhost.localdomain \
--to=rpurdie@rpsys.net \
--cc=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox