Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp648415ybh; Wed, 15 Jul 2020 11:26:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhsHNp5I4YE74x/udOe/sDNEr+79phfyaRoSa8XvNV5CbnlVoXtoHtyBfXxqiJJd8/KZek X-Received: by 2002:a50:e047:: with SMTP id g7mr893756edl.290.1594837563708; Wed, 15 Jul 2020 11:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594837563; cv=none; d=google.com; s=arc-20160816; b=rZN82xyGY8CWMUI+Z5UIxCL2kdjf7f0VMEW2K68W3TIDB09a+NAB2LQjme0Sdl2r2c yoThBWf3ey6P7AELIn4k3pZuyV0UtRXsnSWv0ho6VcEvdnrGZeAtO3qmuBXLf028Sg7z uf9vNzf+p0emWc9GCGs46hvyDmf8rfum4lROMg0TAKF9A2kFd9k3CMwXKeBMcnopHSPF RINt4WOWXTklyiCjy20mIUbDvJWvuJghifH3Ml+V06TfborR0ttGQDUNFLuQ9wIuarUb JTmUjo+YOUT+cVPkeReEgbJwS2vamOxrKxjw8H+N5QaY57xwLa0sNj5/TzZEAnZNMy45 VSYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=A1O8hMul/CJLSbV1N5c3JTA54EIaO3M+DVJ+l+X2WwY=; b=TIXvJr9C7CkEyJeaWx58CLZ16hXDHwOYbCYJOxNazGhNfokd6gMZ/E37mndb35XNq4 4QvoWnPcgqa33Bqzx6iVHjzUddp7a0ldOFc1giB2logEnkmiytSkmn0c/fWHlckbEA/Z wsAL4WncuFjmWmqzfi8seTVyhsnEIG5Dqk9zAce+ZJKvTHwVoIntJ69YecPJi4pHI7yw z8DGca6oM3mjo2bcFlWDoiIZDTV3fYAXEQEL70SG7RtLWif9VORYEX0O+C3cpuSjfSFt NZo8IER7488jBLxvDW6MLKQaQ9hJDNKDHdQCCsAidztvh/fiHWuKch9y1/WuG5C/1SaO ibbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uONZHPpi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc19si1569089ejb.584.2020.07.15.11.25.39; Wed, 15 Jul 2020 11:26:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uONZHPpi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726376AbgGOSXC (ORCPT + 99 others); Wed, 15 Jul 2020 14:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgGOSXB (ORCPT ); Wed, 15 Jul 2020 14:23:01 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE96C061755; Wed, 15 Jul 2020 11:23:00 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id n22so233877ejy.3; Wed, 15 Jul 2020 11:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=A1O8hMul/CJLSbV1N5c3JTA54EIaO3M+DVJ+l+X2WwY=; b=uONZHPpirU56iDmZf7UJPLf4XCv8SFTwAJCeF0ZahyHBh2Q1OZwv9p7PFDP0YsAK9v HWH1Qz9J+uEzZpnVXgmqPR6piZHgQeVFyzB5DWgE8/05Sh9s0hQ3THroLvv1ldx81Cu7 78P78TU2pwfpEdKUXHZvo0/9asBMkzKlr4RaEigWa8zdpf2fGph1xxnFye4ImwlgoLKk HHX2/CW+BCqHhB/xZwEtYAlJNpMSq++rA2wRCULjRheyqx7teTCOWEKoH8n4hckjvd0C zwws5WFYH1YmucevJN7vUlkYZPrzwo4u5LIkLoNE6Avj0ZWE8bo/Olu7CZyVvEn/yAg+ hY7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=A1O8hMul/CJLSbV1N5c3JTA54EIaO3M+DVJ+l+X2WwY=; b=N+T3Pf07ChXnCRXfLt41uV7lpG7XAiGmNKGOOMo/pMjwhO+a9+uCXGzTwxQHCA1c6V Pji6CPDyXKZIOa92c/6gvqNVGvdAjYhis58P3K3aPWyhKvWaP7jqPnm7gxhb/fk2Tvly ONEY9thiSMeMuTjsLIEEA9D4dznXA3rDi4t7M/zVbTTstAy5sUOMtZOQBXeuLOKxe7al rBWO4gJtnZ0VnwufOy2T8pniasOjmZzv/85q4jHjZqhNsgAyEXjCBGlgo4gKfhuZG57p tjRKxwMX4xcBcipvF3oLXPy38vLIiDy4pEUB/3zCKJmPSbKcV/SLmxSMx4YMJTk6VZwf XdOw== X-Gm-Message-State: AOAM530v8mZBSd4WaKFCU/MbIK0XmclJ7mZmOlnlSWRcNoWvg4cnWLsp uoBGWYF0yrzdwtILbXVEBE98BI89L3w= X-Received: by 2002:a17:906:c943:: with SMTP id fw3mr232794ejb.55.1594837379427; Wed, 15 Jul 2020 11:22:59 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:5700:99de:6366:d65c:d599? (p200300ea8f23570099de6366d65cd599.dip0.t-ipconnect.de. [2003:ea:8f23:5700:99de:6366:d65c:d599]) by smtp.googlemail.com with ESMTPSA id ai4sm2756085ejc.91.2020.07.15.11.22.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jul 2020 11:22:58 -0700 (PDT) Subject: Re: PCI: Disable not requested resource types in pci_enable_resources To: Bjorn Helgaas Cc: Bjorn Helgaas , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List References: <20200710210924.GA80868@bjorn-Precision-5520> From: Heiner Kallweit Message-ID: Date: Wed, 15 Jul 2020 20:22:51 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200710210924.GA80868@bjorn-Precision-5520> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10.07.2020 23:09, Bjorn Helgaas wrote: > On Thu, May 28, 2020 at 08:47:12PM +0200, Heiner Kallweit wrote: >> Currently, if both resource types are enabled before the call, the mask >> value doesn't matter. Means as of today I wouldn't be able to e.g. >> disable PCI_COMMAND_IO. At least my interpretation is that mask defines >> which resource types are enabled after the call. Therefore change the >> behavior to disable not requested resource types. >> >> At least on my x86 devices this change doesn't have side effects. > > Does this have a practical benefit? If it fixes a bug or if there's > something useful we can do because of this patch, I'll push it higher > up the priority list. > There's no big benefit. The current behavior just doesn't seem to be consistent, and I don't see why we have a function pci_enable_device_mem(). Also after calling this function IO resources can be active. So why not remove this function and use pci_enable_device() always. Small benefit is that the change allows to guarantee that IO resources are disabled after calling pci_enable_device_mem(). This might help to avoid using IO resources mistakenly in a driver. >> Signed-off-by: Heiner Kallweit >> --- >> drivers/pci/setup-res.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c >> index d21fa04fa..6ef458c10 100644 >> --- a/drivers/pci/setup-res.c >> +++ b/drivers/pci/setup-res.c >> @@ -459,8 +459,8 @@ int pci_enable_resources(struct pci_dev *dev, int mask) >> int i; >> struct resource *r; >> >> - pci_read_config_word(dev, PCI_COMMAND, &cmd); >> - old_cmd = cmd; >> + pci_read_config_word(dev, PCI_COMMAND, &old_cmd); >> + cmd = old_cmd & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY); >> >> for (i = 0; i < PCI_NUM_RESOURCES; i++) { >> if (!(mask & (1 << i))) >> -- >> 2.26.2 >>