From patchwork Wed Mar 21 01:25:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lin Ming X-Patchwork-Id: 147892 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8546CB6F62 for ; Wed, 21 Mar 2012 12:25:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756277Ab2CUBZh (ORCPT ); Tue, 20 Mar 2012 21:25:37 -0400 Received: from mga11.intel.com ([192.55.52.93]:41387 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755417Ab2CUBZg (ORCPT ); Tue, 20 Mar 2012 21:25:36 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 20 Mar 2012 18:25:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="142235434" Received: from minggr.sh.intel.com (HELO [10.239.36.45]) ([10.239.36.45]) by fmsmga002.fm.intel.com with ESMTP; 20 Mar 2012 18:25:34 -0700 Subject: Re: DMA doesn't work since "make ata port as parent device of scsi host" From: Lin Ming To: =?ISO-8859-1?Q?J=F6rg?= Sommer Cc: Jeff Garzik , Tejun Heo , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, "James E.J. Bottomley" In-Reply-To: <20120315155924.GA6738@alea.gnuu.de> References: <20120315014807.GA3051@alea.gnuu.de> <1331776741.3436.33.camel@minggr> <1331781968.3436.43.camel@minggr> <20120315074835.GA18295@alea.gnuu.de> <1331799598.3436.46.camel@minggr> <20120315155924.GA6738@alea.gnuu.de> Date: Wed, 21 Mar 2012 09:25:33 +0800 Message-ID: <1332293133.17160.12.camel@minggr> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org On Thu, 2012-03-15 at 16:59 +0100, Jörg Sommer wrote: > Lin Ming hat am Thu 15. Mar, 16:19 (+0800) geschrieben: > > On Thu, 2012-03-15 at 08:48 +0100, Jörg Sommer wrote: > > > Lin Ming hat am Thu 15. Mar, 11:26 (+0800) geschrieben: > > > > On Thu, 2012-03-15 at 09:59 +0800, Lin Ming wrote: > > > > > On Thu, 2012-03-15 at 02:48 +0100, Jörg Sommer wrote: > > > > > > Hi, > > > > > > > > > > > > I'm getting these messages in a KVM virtualized host and the access to > > > > > > the disks is very slow. Using libata.dma=0 suppresses the warnings, but > > > > > > the disks are still slow. > > > > > > > > > > Hi Jörg, > > > > > > > > > > Let me try to reproduce this issue first. > > > > > > > > I tried below commands on x86_32, but can't reproduce it. > > > > > > > > qemu-system-i386 -kernel /root/vmlinuz-3.3.0-rc7 -append "root=/dev/sda1 > > > > zcache" -hda /root/debian-32.img -hdb /root/data.img > > > > > > > > Maybe because i386 uses different ata controller than ppc(ata_piix vs > > > > pata-macio). > > > > > > > > I'll try qemu-system-ppc. > > > > > > > > Did you need to run some workload to trigger these warings? > > > > Or did you get these warnings right after booting the VM? > > > > > > These warnings come up before »INIT started«. I don't have to do > > > anything, just wait and see. > > > > > > # truncate -s100M /mnt/data/new > > > # mke2fs -Fq /mnt/data/new > > > # mount -o loop /mnt/data/new /mnt/other > > > # cp --parents /bin/zsh-static /mnt/other/zsh > > > # umount /mnt/other > > > # qemu-system-ppc -enable-kvm -M mac99 -cpu G4 -k de -kernel /boot/vmlinuz-3.3.0-rc5-04520-g8d233c0 -append 'root=/dev/sda ro console=ttyPZ0 init=/zsh' -hda /mnt/data/new > > > > > > I've uploaded my config and the kernel: > > > http://alioth.debian.org/~jo-guest/config-3.3.0-rc5-04520-g8d233c0 > > > http://alioth.debian.org/~jo-guest/vmlinuz-3.3.0-rc5-04520-g8d233c0 > > > > > > You have to switch to the serial console (Ctrl-Alt-3 or with -nographic > > > Ctrl-a c). All kernel messages arrive there. > > > > > > > Would you please try to disable ata port runtime pm? > > > > You can disable it by, for example, > > > > > > Is this also possible with a kernel parameter? It takes very long until I > > > get a shell prompt. > > > > No, but you can try below debug patch to disable port runtime pm. > > > > diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c > > index 74aaee3..8def3fc 100644 > > --- a/drivers/ata/libata-transport.c > > +++ b/drivers/ata/libata-transport.c > > @@ -293,7 +293,6 @@ int ata_tport_add(struct device *parent, > > > > device_enable_async_suspend(dev); > > pm_runtime_set_active(dev); > > - pm_runtime_enable(dev); > > This patch doesn't change anything. The kernel still hangs. If you have > more patches or ideas, let me know. Hi, Below patch should fix the problem. Could you help to test it? From a36022015c97c9a9f80e71b4283f0ff5f481ffc3 Mon Sep 17 00:00:00 2001 From: Lin Ming Date: Tue, 20 Mar 2012 14:35:10 +0800 Subject: [PATCH] [SCSI] scsi_lib: use correct DMA device in __scsi_alloc_queue Currently, __scsi_alloc_queue uses SCSI host's parent device as DMA device to set segment boundary. But the parent device may not refer to the DMA device. For example, for ATA disk, SCSI host's parent device now refers to ATA port. Since commit d139b9b([SCSI] scsi_lib_dma: fix bug with dma maps on nested scsi objects), a new field Scsi_Host->dma_device was introduced to refer to the real DMA device. Use ->dma_device in __scsi_alloc_queue to correctly set segment boundary. And use scsi_add_host_with_dma in ata_scsi_add_hosts to pass in the correct DMA device. Signed-off-by: Lin Ming Tested-by: Jörg Sommer --- drivers/ata/libata-scsi.c | 3 ++- drivers/scsi/scsi_lib.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 7ae1e77..e47f889 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3398,7 +3398,8 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) */ shost->max_host_blocked = 1; - rc = scsi_add_host(ap->scsi_host, &ap->tdev); + rc = scsi_add_host_with_dma(ap->scsi_host, + &ap->tdev, ap->host->dev); if (rc) goto err_add; } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index f85cfa6..486088b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1642,7 +1642,7 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, request_fn_proc *request_fn) { struct request_queue *q; - struct device *dev = shost->shost_gendev.parent; + struct device *dev = shost->dma_dev; q = blk_init_queue(request_fn, NULL); if (!q)