Re: Silent corruption on AMD64

2007-04-01 Thread Andi Kleen
Aaron Lehmann [EMAIL PROTECTED] writes:

[adding netdev]
[meta-comment: I wish people wouldn't use such unnecessarily broad subjects 
-- how is it the x86-64 port's or AMD's fault when you have broken hardware? 
Would anybody write Silent corruption on i386 or Silent corruption 
on Intel or Silent corruption on Linux?]

 On Sat, Mar 31, 2007 at 08:03:16PM -0700, Jim Paris wrote:
  Since it shows up under heavy load that includes unrelated devices, I
  think ruling out hardware problems is important.  Some suggestions:
 
 I've been able to narrow it down to the Realtek Ethernet card. I can't
 reproduce the problem using onboard Ethernet, whereas the Realtek card
 causes trouble in any slot. However, I still don't know whether it's a
 hardware or software issue, or whether it's caused directly or
 indirectly by the Realtek card.

You could disable the hardware checksumming support in the card with
the appended patch. Then hopefully Linux will catch most corruptions
(but perhaps not all because TCP checksums are not very strong) 
You can watch failed checksums then with netstat -s

-Andi

Index: linux-2.6.21-rc3-net/drivers/net/r8169.c
===
--- linux-2.6.21-rc3-net.orig/drivers/net/r8169.c
+++ linux-2.6.21-rc3-net/drivers/net/r8169.c
@@ -2477,6 +2477,7 @@ static inline int rtl8169_fragmented_fra
 
 static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc)
 {
+#if 0
u32 opts1 = le32_to_cpu(desc-opts1);
u32 status = opts1  RxProtoMask;
 
@@ -2485,6 +2486,7 @@ static inline void rtl8169_rx_csum(struc
((status == RxProtoIP)  !(opts1  IPFail)))
skb-ip_summed = CHECKSUM_UNNECESSARY;
else
+#endif
skb-ip_summed = CHECKSUM_NONE;
 }
 

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFD driver-core] Lifetime problems of the current driver model

2007-04-01 Thread Tejun Heo
Hello, James, Greg.

On Fri, Mar 30, 2007 at 01:19:34PM -0500, James Bottomley wrote:
 That's sort of what I was reaching for too ... it just looks to me that
 all the sysfs glue is in kobject, so they make a good candidate for the
 pure sysfs objects.  Whatever we do, there has to be breakable cross
 linking between the driver's tree and the sysfs representation ... of
 course, nasty things like ksets get in the way of considering the
 objects as separate, sigh.

The dependency between kobject and sysfs doesn't seem to be that
tight.  I managed to break them such that sysfs can disconnect from
its kobject on deletion _without_ changing sysfs/kobject API.

  This way the sysfs reference counting can be put completely out of
  picture without impacting the rest of code.  Handling symlink and
  suicidal attributes might need some extra attention but I think they can
  be done.
 
 True ... but you'll also have to implement something within sysfs to do
 refcounting ... it needs to know how long to keep its nodes around.

sysfs_dirent already had reference counter and plays that role quite
nicely.

Okay, here's preliminary patch.  I've tested it very lightly so it's
likely to contain bugs and definitely needs to be splitted.

Dependencies between sysfs/kobject objects are clearer now and I think
I got the locking and referencing correct.  This patch immediately
fixes 'sysfs attr grabbing the wrong kobject and module' problem -
sysfs and module lifetimes are unrelated now.  We can drop
half-working attr-owner.

* A sysfs node no longer hold reference to its kobject.  It just
  attaches itself to the kobject on creation and detaches on deletion.

* For a dir node, sysfs_dirent no longer directly points to kobject.
  It points to sysfs_dir which contains pointer to kobject and a rwsem
  to protect it.

* An open file doesn't hold a reference to kobject.  It holds a
  reference to sysfs_dirent.  kobject pointer is verified and
  show/store are performed with rwsem read-locked.  Deletion
  disconnects the sysfs from its kobject while the rwsem is
  write-locked.  This mechanism replaces buffer orphaning and kobject
  validation during open.

* attr ops is determined on sysfs node creation not on open.  This is
  a step toward making kobject opaque in sysfs.

* bin files are handled similarly but mmap makes the open file hold
  reference to the kobject till it's closed.  Any better ideas?

* symlink is reimplemented in terms of sysfs_dirents instead of
  kobjects.  sysfs_dirent-s_parent is added and each sysfs_dirent
  holds reference to its parent.  Currently walking up the tree
  requires read locking and unlocking sysfs_dir at each level.  This
  can be removed if name is added to sysfs_dirent.

* As kobject can be disconnected anytime and sysfs code still needs to
  look follow dentry link in kobject, kobject-dentry is protected by
  dcache_lock.  Once kobject becomes opaque to sysfs, this hack can go
  away.  All in all, making kobject completely opaque in sysfs isn't
  too far away after this patch although it would require mass code
  update.

What do you think about this approach?  If it's acceptable, I'll test
further and split the patch into logical steps to get it reviewed
better.

Thanks.

---
 fs/sysfs/bin.c |  121 +++-
 fs/sysfs/dir.c |  134 ++--
 fs/sysfs/file.c|  158 ++---
 fs/sysfs/inode.c   |   25 
 fs/sysfs/mount.c   |9 ---
 fs/sysfs/symlink.c |  115 +++---
 fs/sysfs/sysfs.h   |   75 +
 7 files changed, 366 insertions(+), 271 deletions(-)

diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index d3b9f5f..0c4671b 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -20,26 +20,41 @@
 
 #include sysfs.h
 
+struct bin_buffer {
+   struct mutexmutex;
+   void*buffer;
+   int mmapped;
+};
+
 static int
 fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count)
 {
struct bin_attribute * attr = to_bin_attr(dentry);
-   struct kobject * kobj = to_kobj(dentry-d_parent);
+   struct sysfs_dirent * sd = dentry-d_parent-d_fsdata;
+   struct kobject * kobj;
+   int rc;
 
if (!attr-read)
return -EIO;
 
-   return attr-read(kobj, buffer, off, count);
+   kobj = sysfs_get_kobj(sd);
+   if (!kobj)
+   return -ENODEV;
+
+   rc = attr-read(kobj, buffer, off, count);
+
+   sysfs_put_kobj(sd);
+
+   return rc;
 }
 
 static ssize_t
 read(struct file * file, char __user * userbuf, size_t count, loff_t * off)
 {
-   char *buffer = file-private_data;
+   struct bin_buffer *bb = file-private_data;
struct dentry *dentry = file-f_path.dentry;
int size = dentry-d_inode-i_size;
loff_t offs = *off;
-   int ret;
 
if (count  PAGE_SIZE)
count 

[PATCH 0/4] libata: Workaround/fixes for ATAPI devices (take 3)

2007-04-01 Thread Albert Lee
patch 1/4: Reorder HSM_ST_FIRST
patch 2/4: Clear tf before doing request sense
patch 3/4: Limit max sector to 128 for TORiSAN DVD drives
patch 4/4: Limit ATAPI DMA to R/W commands only for TORiSAN DVD drives

(patch 2/4 revised per Tejun's advice.)
(patch 3/4 revised per Vlad's new test result.)

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] libata: reorder HSM_ST_FIRST for easier decoding (take 3)

2007-04-01 Thread Albert Lee
patch 1/4:
  Reorder HSM_ST_FIRST, such that the task state transition is easier decoded 
with human eyes.

Signed-off-by: Albert Lee [EMAIL PROTECTED]
---
Patch against libata-dev tree, for your review, thanks.

diff -Nrup 00_libata-dev.ori/include/linux/libata.h 
01_hsm_st/include/linux/libata.h
--- 00_libata-dev.ori/include/linux/libata.h2007-03-23 16:56:24.0 
+0800
+++ 01_hsm_st/include/linux/libata.h2007-04-02 10:50:50.0 +0800
@@ -315,11 +315,11 @@ enum {
 
 enum hsm_task_states {
HSM_ST_IDLE,/* no command on going */
+   HSM_ST_FIRST,   /* (waiting the device to)
+  write CDB or first data block */
HSM_ST, /* (waiting the device to) transfer data */
HSM_ST_LAST,/* (waiting the device to) complete command */
HSM_ST_ERR, /* error */
-   HSM_ST_FIRST,   /* (waiting the device to)
-  write CDB or first data block */
 };
 
 enum ata_completion_errors {


-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] libata: Clear tf before doing request sense (take 3)

2007-04-01 Thread Albert Lee
patch 2/4:
  Clear tf before doing request sense.

This fixes the AOpen 56X/AKH timeout problem.
(http://bugzilla.kernel.org/show_bug.cgi?id=8244)

Signed-off-by: Albert Lee [EMAIL PROTECTED]
---
Per Tejun's advice to use result_tf instead.
Patch against libata-dev tree, for your review, thanks.

diff -Nrup 01_hsm_st/drivers/ata/libata-eh.c 02_aopen_rs/drivers/ata/libata-eh.c
--- 01_hsm_st/drivers/ata/libata-eh.c   2007-03-23 16:56:13.0 +0800
+++ 02_aopen_rs/drivers/ata/libata-eh.c 2007-04-02 11:04:11.0 +0800
@@ -982,26 +982,27 @@ static int ata_eh_read_log_10h(struct at
  * RETURNS:
  * 0 on success, AC_ERR_* mask on failure
  */
-static unsigned int atapi_eh_request_sense(struct ata_device *dev,
-  unsigned char *sense_buf)
+static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
 {
+   struct ata_device *dev = qc-dev;
+   unsigned char *sense_buf = qc-scsicmd-sense_buffer;
struct ata_port *ap = dev-ap;
struct ata_taskfile tf;
u8 cdb[ATAPI_CDB_LEN];
 
DPRINTK(ATAPI request sense\n);
 
-   ata_tf_init(dev, tf);
-
/* FIXME: is this needed? */
memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE);
 
-   /* XXX: why tf_read here? */
-   ap-ops-tf_read(ap, tf);
-
-   /* fill these in, for the case where they are -not- overwritten */
+   /* initialize sense_buf with the error register,
+* for the case where they are -not- overwritten
+*/
sense_buf[0] = 0x70;
-   sense_buf[2] = tf.feature  4;
+   sense_buf[2] = qc-result_tf.feature  4;
+
+   /* some devices time out if garbage left in tf */ 
+   ata_tf_init(dev, tf);
 
memset(cdb, 0, ATAPI_CDB_LEN);
cdb[0] = REQUEST_SENSE;
@@ -1165,8 +1166,7 @@ static unsigned int ata_eh_analyze_tf(st
 
case ATA_DEV_ATAPI:
if (!(qc-ap-pflags  ATA_PFLAG_FROZEN)) {
-   tmp = atapi_eh_request_sense(qc-dev,
-qc-scsicmd-sense_buffer);
+   tmp = atapi_eh_request_sense(qc);
if (!tmp) {
/* ATA_QCFLAG_SENSE_VALID is used to
 * tell atapi_qc_complete() that sense


-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] libata: Limit max sector to 128 for TORiSAN DVD drives (take 3)

2007-04-01 Thread Albert Lee
patch 3/4:
  The TORiSAN drive locks up when max sector == 256.
  Limit max sector to 128 for the TORiSAN DRD-N216 drives.
  (http://bugzilla.kernel.org/show_bug.cgi?id=6710)

Signed-off-by: Albert Lee [EMAIL PROTECTED]
---
Revised to use max sector = 128 per Vlad's new test result.
Patch against libata-dev tree, for your review, thanks.

diff -Nrup 02_aopen_rs/drivers/ata/libata-core.c 
03_max_sect/drivers/ata/libata-core.c
--- 02_aopen_rs/drivers/ata/libata-core.c   2007-03-23 16:56:13.0 
+0800
+++ 03_max_sect/drivers/ata/libata-core.c   2007-04-02 10:56:59.0 
+0800
@@ -1784,6 +1784,9 @@ int ata_dev_configure(struct ata_device 
dev-max_sectors = ATA_MAX_SECTORS;
}
 
+   if (ata_device_blacklisted(dev)  ATA_HORKAGE_MAX_SEC_128)
+   dev-max_sectors = min(ATA_MAX_SECTORS_128, dev-max_sectors);
+
if (ap-ops-dev_config)
ap-ops-dev_config(ap, dev);
 
@@ -3352,6 +3355,9 @@ static const struct ata_blacklist_entry 
{ _NEC DV5800A,   NULL,   ATA_HORKAGE_NODMA },
{ SAMSUNG CD-ROM SN-124,N001,   ATA_HORKAGE_NODMA },
 
+   /* Weird ATAPI devices */
+   { TORiSAN DVD-ROM DRD-N216, NULL, ATA_HORKAGE_MAX_SEC_128 },
+
/* Devices we expect to fail diagnostics */
 
/* Devices where NCQ should be avoided */
diff -Nrup 02_aopen_rs/include/linux/ata.h 03_max_sect/include/linux/ata.h
--- 02_aopen_rs/include/linux/ata.h 2007-03-23 16:56:24.0 +0800
+++ 03_max_sect/include/linux/ata.h 2007-04-02 10:56:59.0 +0800
@@ -40,6 +40,7 @@ enum {
ATA_MAX_DEVICES = 2,/* per bus/port */
ATA_MAX_PRD = 256,  /* we could make these 256/256 */
ATA_SECT_SIZE   = 512,
+   ATA_MAX_SECTORS_128 = 128,
ATA_MAX_SECTORS = 256,
ATA_MAX_SECTORS_LBA48   = 65535,/* TODO: 65536? */
 
diff -Nrup 02_aopen_rs/include/linux/libata.h 03_max_sect/include/linux/libata.h
--- 02_aopen_rs/include/linux/libata.h  2007-04-02 10:50:50.0 +0800
+++ 03_max_sect/include/linux/libata.h  2007-04-02 10:56:59.0 +0800
@@ -311,6 +311,7 @@ enum {
ATA_HORKAGE_DIAGNOSTIC  = (1  0), /* Failed boot diag */
ATA_HORKAGE_NODMA   = (1  1), /* DMA problems */
ATA_HORKAGE_NONCQ   = (1  2), /* Don't use NCQ */
+   ATA_HORKAGE_MAX_SEC_128 = (1  3), /* Limit max sects to 128 */
 };
 
 enum hsm_task_states {


-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html