From patchwork Tue Jul 21 00:14:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 6831501 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7D0519F380 for ; Tue, 21 Jul 2015 00:15:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF5892069F for ; Tue, 21 Jul 2015 00:15:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D880920632 for ; Tue, 21 Jul 2015 00:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbbGUAPA (ORCPT ); Mon, 20 Jul 2015 20:15:00 -0400 Received: from mail-ig0-f178.google.com ([209.85.213.178]:35410 "EHLO mail-ig0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757286AbbGUAO6 (ORCPT ); Mon, 20 Jul 2015 20:14:58 -0400 Received: by igr7 with SMTP id 7so26848916igr.0 for ; Mon, 20 Jul 2015 17:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=t7M6SpV/HrhF8qbk0x1pbMk5M2HVh9hWVeyGWfl7yiQ=; b=LpWDqDpOf+I6MrLkUQs/J0EsFFQgZamJBWd4cZ9LHytCHlHyQZyjfT056hInGOswmK PJDnKjx27nY1T4VLfhcqPSBTpUfmZa3sxGPxrQV1P/93OIuwYugIYTV2yg6wdi8IQeIv CEHJfvu4pS3vTjW6nbcagTQIaOYvn8ocRM3hxDpQCZBnnYSRwOhSnRx+5PInKTPgmrQt zxNgp7fTo5lEYM+kMlrfJEsNVpgMVv+15APTocW8V2ZebHJzy1JZ1N2kVf290a+oB3Ey U7qd27PwgzAfbNTTFH2ZqPEYRJIGicVwQlLe3SJE9zGYkSTBActseihYs+k9PwIDhYej 7MBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=t7M6SpV/HrhF8qbk0x1pbMk5M2HVh9hWVeyGWfl7yiQ=; b=QmIVeuJiLD9IqLTPEpQdsMwPqSkMv+95AYoCd8JdGbPcIjqwA8qHy9gMbdwJtHaFKT XGqjxfg+zD1c55wvPg6q11mE9FfdIzO8AYfgdUnoAmYNY+jnJ8Ee06IVtM+E+WFemHQZ F9AaBvAT8Kc7JU1Y04pfFjWJlKvbTXdEujtyuQKOMrRabHhZSpJByHrAFqldbYLeQCTq G3/t0b90pNeWFIBLzQ4tSAp5YHju1yAuP2mC9dtS5g5lvxjRY4TYyRVdJiGAKOFnoUTF 7X749x5/GKy35wTkkyZCxi2NCxablaXCUXFLlt+ifp2Tlg8XJxIqUjffPdrAlcQaXhZR p3tA== X-Gm-Message-State: ALoCoQmx9e/FhKtQutTeZYdiq4A54fUPXw549hAtf29gzzMMR2JcZGDmx7FdQVwOXPISo98P4Q6y X-Received: by 10.107.155.74 with SMTP id d71mr44341884ioe.41.1437437698003; Mon, 20 Jul 2015 17:14:58 -0700 (PDT) Received: from localhost ([69.71.1.1]) by smtp.gmail.com with ESMTPSA id p82sm10209046ioi.14.2015.07.20.17.14.55 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 20 Jul 2015 17:14:56 -0700 (PDT) Subject: [PATCH v2 08/11] PCI: Clean up ATS error handling To: linux-pci@vger.kernel.org, Joerg Roedel , David Woodhouse From: Bjorn Helgaas Cc: iommu@lists.linux-foundation.org, Gregor Dick Date: Mon, 20 Jul 2015 19:14:54 -0500 Message-ID: <20150721001454.28145.35617.stgit@bhelgaas-glaptop2.roam.corp.google.com> In-Reply-To: <20150721001243.28145.81610.stgit@bhelgaas-glaptop2.roam.corp.google.com> References: <20150721001243.28145.81610.stgit@bhelgaas-glaptop2.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 There's no need to BUG() if we enable ATS when it's already enabled. We don't need to BUG() when disabling ATS on a device that doesn't support ATS or if it's already disabled. If ATS is enabled, certainly we found an ATS capability in the past, so it should still be there now. Clean up these error paths. Signed-off-by: Bjorn Helgaas --- drivers/pci/ats.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" 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/pci/ats.c b/drivers/pci/ats.c index 0b5b0ed..67524a7 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c @@ -44,11 +44,12 @@ int pci_enable_ats(struct pci_dev *dev, int ps) u16 ctrl; struct pci_dev *pdev; - BUG_ON(dev->ats_cap && dev->ats_enabled); - if (!dev->ats_cap) return -EINVAL; + if (pci_ats_enabled(dev)) + return -EINVAL; + if (ps < PCI_ATS_MIN_STU) return -EINVAL; @@ -83,7 +84,8 @@ void pci_disable_ats(struct pci_dev *dev) struct pci_dev *pdev; u16 ctrl; - BUG_ON(!dev->ats_cap || !dev->ats_enabled); + if (!pci_ats_enabled(dev)) + return; if (atomic_read(&dev->ats_ref_cnt)) return; /* VFs still enabled */ @@ -107,8 +109,6 @@ void pci_restore_ats_state(struct pci_dev *dev) if (!pci_ats_enabled(dev)) return; - if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS)) - BUG(); ctrl = PCI_ATS_CTRL_ENABLE; if (!dev->is_virtfn)