From patchwork Tue Sep 29 17:37:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 7288821 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6B8CCBEEA4 for ; Tue, 29 Sep 2015 17:38:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49520206B0 for ; Tue, 29 Sep 2015 17:38:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 235C9206D4 for ; Tue, 29 Sep 2015 17:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935280AbbI2Rh5 (ORCPT ); Tue, 29 Sep 2015 13:37:57 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:38034 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935262AbbI2Rhu (ORCPT ); Tue, 29 Sep 2015 13:37:50 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 01CD08EE394; Tue, 29 Sep 2015 10:37:48 -0700 (PDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xxXVWZ2-rxuq; Tue, 29 Sep 2015 10:37:48 -0700 (PDT) Received: from [153.66.254.242] (unknown [184.11.141.41]) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 7E3578EE339; Tue, 29 Sep 2015 10:37:48 -0700 (PDT) Message-ID: <1443548266.2207.19.camel@HansenPartnership.com> Subject: Re: twa generates WARNING upon boot From: James Bottomley To: =?ISO-8859-1?Q?=22T=F3th?= "Attila\"" Cc: adam radford , linux-scsi Date: Tue, 29 Sep 2015 10:37:46 -0700 In-Reply-To: References: <68ee66bf9581d10b0ab813e5006869ec.squirrel@atoth.sote.hu> X-Mailer: Evolution 3.12.11 Mime-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 2015-09-29 at 18:49 +0200, "Tóth Attila" wrote: > 2015.Szeptember 27.(V) 23:19 id?pontban adam radford ezt írta: > > On Sun, Sep 27, 2015 at 4:56 AM, "Tóth Attila" > > wrote: > >> Here is a current trace I see after booting that kernel: > >> ------------[ cut here ]------------ > >> WARNING: CPU: 0 PID: 1 at drivers/iommu/intel-iommu.c:3214 > >> intel_unmap+0x186/0x1f0() > >> Driver unmaps unmatched page at PFN 0 > >> Modules linked in: > >> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.1.7-hardened-r1 #2 > >> Hardware name: System manufacturer System Product Name/Z8P(N)E-D12(X), > >> BIOS 1302 06/25/2012 > >> ffffffffab40bd6b 0000000000000000 0000000000000000 ffffffffab21608f > >> ffff880237c03ca8 ffffffffa4ed0fa6 00000000000015d2 ffff880237c03d00 > >> ffff880237c03ce8 ffffffffa40ad9a0 0000000000000000 ffffffffab21608f > >> Call Trace: > >> [] dump_stack+0x45/0x5d > >> [] warn_slowpath_common+0x80/0xc0 > >> [] warn_slowpath_fmt+0x64/0x90 > >> [] intel_unmap+0x186/0x1f0 > >> [] intel_unmap_sg+0x1a/0x30 > >> [] scsi_dma_unmap+0x73/0x90 > >> [] twa_interrupt+0x493/0x780 > >> [] handle_irq_event_percpu+0x7a/0x130 > >> [] handle_irq_event+0x39/0x60 > >> [] handle_fasteoi_irq+0x89/0x1a0 > >> [] handle_irq+0x85/0x160 > >> [] do_IRQ+0x4c/0x100 > >> [] common_interrupt+0x97/0x97 > >> [] ? > >> default_send_IPI_mask_allbutself_phys+0xbc/0x100 > >> [] physflat_send_IPI_allbutself+0x19/0x30 > >> [] native_send_call_func_ipi+0x108/0x140 > >> [] ? proc_dma_show+0x70/0x70 > >> [] smp_call_function_many+0x1c4/0x270 > >> [] kick_all_cpus_sync+0x21/0x30 > >> [] __do_tune_cpucache+0x56/0x4d0 > >> [] ? string.isra.3+0x47/0x100 > >> [] do_tune_cpucache+0x37/0xb0 > >> [] enable_cpucache+0x65/0x130 > >> [] setup_cpu_cache+0x173/0x270 > >> [] __kmem_cache_create+0x262/0x360 > >> [] do_kmem_cache_create+0x92/0x1d0 > >> [] kmem_cache_create+0x11e/0x1d0 > >> [] ? twa_init+0x36/0x36 > >> [] init_sd+0xd7/0x198 > >> [] do_one_initcall+0x94/0x1a0 > >> [] kernel_init_freeable+0x183/0x22f > >> [] ? rest_init+0x80/0x80 > >> [] kernel_init+0x9/0xf0 > >> [] ret_from_fork+0x3e/0x70 > >> [] ? rest_init+0x80/0x80 > >> ---[ end trace a39a5826ea41aa47 ]--- > >> > >> The 3ware card is a 9650SE-12ML running in a Asus Z8PE-D12X motherboard. > >> > > > > Can you re-try with Christoph's patch: > > > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=118c855b5623f3e2e6204f02623d88c09e0c34de > > As I've told this patch has been already included in the kernel I'm using > (4.1.7-hardened-r1, which is based on 4.1.7). > Out of curiosity I've reverted the patch and the WARNING no longer appears > during boot... Ah, it looks like there's a bug in the patch, it doesn't take into account that the driver has a minimum sg map length and it copies for things under that, so we're likely unmapping something that wasn't mapped. It's slightly hard to fix given that the indicator flag we'd use for this is gone in that patch; does this fix the warning? James --- -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index add419d..4c2c476 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -151,7 +151,19 @@ static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int re static char *twa_string_lookup(twa_message_type *table, unsigned int aen_code); /* Functions */ +static void twa_scsi_dma_unmap(struct scsi_cmnd *SCpnt, int request_id) +{ + TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; + TW_Command_Apache *command_packet = &tw_dev->command_packet_virt[request_id]->command.newcommand; + + if (command_packet->sg_list[0].address == TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id])) + /* command is copied not mapped */ + return; + + twa_scsi_dma_unmap(SCpnt, request_id); +} + /* Show some statistics about the card */ static ssize_t twa_show_stats(struct device *dev, struct device_attribute *attr, char *buf) @@ -1339,7 +1351,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance) } /* Now complete the io */ - scsi_dma_unmap(cmd); + twa_scsi_dma_unmap(cmd, request_id); cmd->scsi_done(cmd); tw_dev->state[request_id] = TW_S_COMPLETED; twa_free_request_id(tw_dev, request_id); @@ -1582,7 +1594,7 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev) struct scsi_cmnd *cmd = tw_dev->srb[i]; cmd->result = (DID_RESET << 16); - scsi_dma_unmap(cmd); + twa_scsi_dma_unmap(cmd, i); cmd->scsi_done(cmd); } } @@ -1765,12 +1777,12 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL); switch (retval) { case SCSI_MLQUEUE_HOST_BUSY: - scsi_dma_unmap(SCpnt); + twa_scsi_dma_unmap(SCpnt, request_id); twa_free_request_id(tw_dev, request_id); break; case 1: SCpnt->result = (DID_ERROR << 16); - scsi_dma_unmap(SCpnt); + twa_scsi_dma_unmap(SCpnt, request_id); done(SCpnt); tw_dev->state[request_id] = TW_S_COMPLETED; twa_free_request_id(tw_dev, request_id);