Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2799499imm; Thu, 24 May 2018 16:27:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqd2WPPlq6qi2EXBEE2evAOdBOnx/NxIfRdhAjOXc89o2C3OoJmFuTymIh2V+y7gHUEMha2 X-Received: by 2002:a63:7341:: with SMTP id d1-v6mr25178pgn.404.1527204448127; Thu, 24 May 2018 16:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527204448; cv=none; d=google.com; s=arc-20160816; b=WsI9oAU26OYZ/1BxE1tRa8ShIph3PZ8ZWgGYCM28dzJ44kIqAkOsV9tlsrK1rrZMmj GccWk83HvcvQCT4yCQZUvLyTA4/D1ZtHrtNYQGvFeSYKu3FZE3t7lOWNnW3v00OX39d+ Qx3fgmtymQK4/JnYui/5mxVgjlrEOJ1B0ICz7noeO7tfjNHNJ2iPN4hvViSpLsbi6OwR qoHoAyLquxSLkiSz3LrZeZlOgHDXyzsN3HMUXEzMzFI1I0ErMQ2gZlPlGWLm7Rd8IUae GcAAE6GFflTTyqoVq98jxmUrvW4rgz0V/x5htuVAh520EqMWBaf/UpiF8Nq8sULgRprp ADQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=OhpTXTpxrnFrrX0xsP2D+6rsR1A5g1L18H3PwRXacao=; b=K2GPbTnQoZSCv+gVTElzHRw3lNdDscD4CkqL3GJoFCiCd+l6A53ABCm3Vw0yioSUDZ LADL4598D90g600ZvGwsM5OTGrLqYvc1rrFpp0BUJkh3q/Aw/XFPfybK4X6KolnOheOq Jhjn2U8gCO1hhF4kZ+f+U8K4LJHSpbbABUwU9X0Z20iar3IO4/gh3ITJeT4jAI+ZtUhd UIHDLsLZAMregisTggB8OIB8dXQ/+tyFjcQ+a/zs0D52h+5eUzT7oujZ+0GAnPlG/e/D LLl6flAqJoz8be/3tkkjjVR+VdNRGQqXyiL3T4NQXVxqjj19hr94suCtcPrSg3P20Y5B P+ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=c09jSpVe; dkim=pass header.i=@codeaurora.org header.s=default header.b=InNSyN29; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si21921823pld.188.2018.05.24.16.27.13; Thu, 24 May 2018 16:27:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=c09jSpVe; dkim=pass header.i=@codeaurora.org header.s=default header.b=InNSyN29; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966082AbeEXNgC (ORCPT + 99 others); Thu, 24 May 2018 09:36:02 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51558 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965823AbeEXNf7 (ORCPT ); Thu, 24 May 2018 09:35:59 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8E35460A00; Thu, 24 May 2018 13:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527168958; bh=SJCrNZr2KJB/0wIVB1qwLHxlpLyVFbwBA8LtnuzUs7o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=c09jSpVeWiQ7WWzhDvpDtggIdKSUmSdwGOS9vb0WGJ4kpypK56QvtnFvcJksLFeO1 /yzD/2i6fEfAPOrL1CiyIaxIJ8ZKGvOSG2q7Af7zAtdigUaLp+IZpn2mzsBcvPz7+h 2SUZtPJ92E14t2lz8Fi+uVMXuEWPG8qka9ByIT7Q= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 925CC602BC; Thu, 24 May 2018 13:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527168957; bh=SJCrNZr2KJB/0wIVB1qwLHxlpLyVFbwBA8LtnuzUs7o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=InNSyN29uU2XgaudN8kGeiLn1e/pYgsUovQPN4JQ70RZZ+1PkA2e3MP6N2AM+QPO7 ZfsXCsTjgLd05grQkvU4+c+hObtUF+nzdCys0Li0ZWdiNw29Cw+APlX+s8ZHrylfn8 5zqmkC7VOPLQzT1t2ilHt/+wS/XrPs94dRhQ1F5c= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 24 May 2018 09:35:57 -0400 From: okaya@codeaurora.org To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, timur@codeaurora.org, ryan@finnie.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, Bjorn Helgaas , "Rafael J. Wysocki" , Greg Kroah-Hartman , Thomas Gleixner , Kate Stewart , Frederick Lawler , Dongdong Liu , Mika Westerberg , open list , Don Brace , esc.storagedev@microsemi.com, linux-scsi@vger.kernel.org Subject: Re: [PATCH V2] PCI/portdrv: do not disable device on reboot/shutdown In-Reply-To: <20180524130727.GA85822@bhelgaas-glaptop.roam.corp.google.com> References: <1527043490-17268-1-git-send-email-okaya@codeaurora.org> <20180523213249.GD150632@bhelgaas-glaptop.roam.corp.google.com> <61f70fd6-52fd-da07-ce73-303f95132131@codeaurora.org> <82656e20-e821-1944-3399-1667ceb27719@codeaurora.org> <20180524130727.GA85822@bhelgaas-glaptop.roam.corp.google.com> Message-ID: <24846c30ceab15075205b34305b97ba8@codeaurora.org> X-Sender: okaya@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-24 09:07, Bjorn Helgaas wrote: > On Thu, May 24, 2018 at 07:43:05AM -0400, Sinan Kaya wrote: >> On 5/23/2018 6:57 PM, Sinan Kaya wrote: >> >> The crash seems to indicate that the hpsa device attempted a DMA after >> >> we cleared the Root Port's PCI_COMMAND_MASTER, which means >> >> hpsa_shutdown() didn't stop DMA from the device (it looks like *most* >> >> shutdown methods don't disable device DMA, so it's in good company). >> > All drivers are expected to shutdown DMA and interrupts in their shutdown() >> > routines. They can skip removing threads, data structures etc. but DMA and >> > interrupt disabling are required. This is the difference between shutdown() >> > and remove() callbacks. >> >> I found this note yesterday to see why we are not disabling the >> devices in the PCI core itself. >> >> pci_device_remove() >> >> /* >> * We would love to complain here if pci_dev->is_enabled is set, that >> * the driver should have called pci_disable_device(), but the >> * unfortunate fact is there are too many odd BIOS and bridge setups >> * that don't like drivers doing that all of the time. >> * Oh well, we can dream of sane hardware when we sleep, no matter >> how >> * horrible the crap we have to deal with is when we are awake... >> */ >> >> Ryan, can you discard the previous patch and test this one instead? >> remove() path in hpsa driver seems to call pci_disable_device() via >> >> hpsa_remove_one() >> hpsa_free_pci_init() >> >> but nothing on the shutdown path. >> >> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c >> index 4ed3d26..3823f04 100644 >> --- a/drivers/scsi/hpsa.c >> +++ b/drivers/scsi/hpsa.c >> @@ -8651,6 +8651,7 @@ static void hpsa_shutdown(struct pci_dev *pdev) >> h->access.set_intr_mask(h, HPSA_INTR_OFF); >> hpsa_free_irqs(h); /* init_one 4 */ >> hpsa_disable_interrupt_mode(h); /* pci_init 2 */ >> + pci_disable_device(h->pdev); >> } > > I suspect this will make things "work" (if the device can't attempt > DMA, no Unsupported Request error will occur). > > But I'm concerned that the reason for the DMA might that hpsa is > transferring buffers from system memory to the hpsa device, and if we > arbitrarily terminate those transfers with pci_disable_device(), we > may leave the hpsa device in an inconsistent state, e.g., with a dirty > filesystem. > > But we really need guidance from an hpsa expert. I don't know the > filesystem/SCSI/hpsa details. Agreed, We can drop shutdown and use the remove callback. Remove is supposed to do a safe cleanup. > > Bjorn