From patchwork Thu Jan 20 11:30:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Piotr_Pi=C3=B3rkowski?= X-Patchwork-Id: 12718553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5176C433F5 for ; Thu, 20 Jan 2022 11:26:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 58B3710E196; Thu, 20 Jan 2022 11:26:35 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 129D910E34F for ; Thu, 20 Jan 2022 11:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642677994; x=1674213994; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=m4PrV3z1PoS+usp8AJOUrL6/GiK7FRIYFRYp23fI/ks=; b=MGZ003yWd8ToPM5DNE+F9BjtPHBhVw2M56HB5i2pM8LRjgUtPZgmVpID sZ0d2EkDI/w78Nd4uGooQBdXW2xdJeKKHR0Ecz8TaPEmYLJWXnBaVw2pt lDtzn5Us2alkbL/WPjnT2DldyvH0oXn4g7VkSBjLDA4siwmmXKlEV74Ha Nq7C7pKL3h3lEFeGMPUulahZd2n58LKRw1Es5CRmepVmluQSZBtvm5P/t +SYxdTvjN/ZVnWC1rYYSKl4pNVrhMVGbMJeXq+57Lc5k2Ut043fKLCWZd L5G1pUk6NgFso0vF8stKr3qGC8nvr+CQ+GYygvyVVnMqBZBgp0ljjseeT Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10232"; a="242893325" X-IronPort-AV: E=Sophos;i="5.88,302,1635231600"; d="scan'208";a="242893325" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2022 03:26:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,302,1635231600"; d="scan'208";a="622866398" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga002.fm.intel.com with ESMTP; 20 Jan 2022 03:26:33 -0800 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 20 Jan 2022 03:26:32 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Thu, 20 Jan 2022 03:26:32 -0800 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.43) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Thu, 20 Jan 2022 03:26:32 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kuHh3kv/kR/zwmGAvXJFMxPm0S/6/hyZU0mbGdoDeqzmEmOt5WUeNgRZPaWIjnE43rHfO+cqeCC913TEmqN7ldk8j6GbHJ8H3HfFsoI2/X2/YuZVFHolB7bucexbgo6kZev+hllaBSpeRkcnU3J3x1WrF4FLD1X2UYiux2zugLQb4/a2evT63Y+7SJPZJ2n+/lWkTzvKc10KaBuJusoF6lgFYvRCs/mqjsAnYbeuhY3kGghpN5Xf6VylOoZV/tCDNjIeNm65XLPhV3sE7roFUKXY+VO8ZE3eDc3dL1W1HIy/2E20n/vME/1nawqySUhCm+EpzhXoFOlxRWBPFPpb9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SHGVLg/CbnzN+/Q1bBBlxXPM2C3zgTjeWjXufxeNJLc=; b=KwNxVaIWpgB7iHdUeV3vB+7Is49aMs3EQYecCtV5rNbyq5Kz3sM/zgdgDwDilOB6rX1PcsbXaMmGL3iJiQx80DZQsFktPPOMAj2Rn7xStCbpwTdnrLWjYQv4tkOtzUtnsp7zqAriKpWnTV6+4Tdf5ig3Wq//AvDiPDvztyAviMs9VTLy3gegrxSUSi8jUFWs7jjw4hlN1O416MnrPwPT/42JHzetLVIkiWyWsK73T8kfbz+ojzB32cX96X2jg5s7VcBeafjx1UV6wt9k+N2zbjDRCiKclu5PvprIPSO1gD8TQKVqUzLNOydKJcZY5SKGO0J/CQaZg9EG4LLBCMuVsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM5PR11MB1372.namprd11.prod.outlook.com (2603:10b6:3:11::14) by MN2PR11MB4510.namprd11.prod.outlook.com (2603:10b6:208:17b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Thu, 20 Jan 2022 11:26:30 +0000 Received: from DM5PR11MB1372.namprd11.prod.outlook.com ([fe80::3dd6:746:9428:7315]) by DM5PR11MB1372.namprd11.prod.outlook.com ([fe80::3dd6:746:9428:7315%10]) with mapi id 15.20.4909.011; Thu, 20 Jan 2022 11:26:30 +0000 From: "Piorkowski, Piotr" To: Date: Thu, 20 Jan 2022 12:30:49 +0100 Message-ID: <20220120113049.213361-1-piotr.piorkowski@intel.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: LO4P123CA0509.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:272::13) To DM5PR11MB1372.namprd11.prod.outlook.com (2603:10b6:3:11::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58a245ec-7b04-4d58-938f-08d9dc07b44e X-MS-TrafficTypeDiagnostic: MN2PR11MB4510:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1z3hD6d+/vzhsN8Hh7B/ef/Zg6AOFnzv3SbAcfpvk+is7ObJ91EvzHQDt6RWqKEFnBL14668pYizTJ6tsBlhQ75WF1WxO8J8+gwouAPAIzR2yAOU3jzLrVpGb9Iki8w/D9hZFqR+RAe6zwIU1y0LZNCKLqiVIVsEJqUvPeVnkFbiDPCWql9i+nu1/T3naJmRLAa6uQjA4miwq8CS6Q3qKmLLqkN/4TA7q31nVCgCjNGjVBIZbiBseoNAdpPHRxxKUNh7oz3Yn+ptC82W1sSVXrD3PIL/OyPsdduHoaX5Kpw7XJ81OunR0sK+OCu1ybexrz0Ce3LsAqO0RZ+MvFqdOg9V3kiQVov/2FWEm2tneo+Upu+rQhDQTvF1gxurJdR1VfZscA8SZY4tjYfjM7mXE/3w64KATe8My+msQ0iqV2BdZtySyQfxc0h5vmbogiZcFnen1l0qF+oFYr3TNUEeLUj02MKYjWEoqfineYln53Jv/403XfWGMCTtVFVsta4ulNzl7UaW99Wbm50haxhsFw86JW0edX2kWK+0SQQFgcTm9nh2XBXe/u+J+wddR5DQzXIMIaX165e4n0AQl/jryMMJjsYFXkcMwfceMYdopbqW74tRn+JHWqP/Ujzwaj8CbrjfNWo4uJiMU0ri4chMjA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR11MB1372.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(66574015)(1076003)(8676002)(6506007)(66946007)(83380400001)(54906003)(316002)(26005)(508600001)(6916009)(2906002)(66476007)(66556008)(8936002)(6512007)(4326008)(86362001)(82960400001)(2616005)(6666004)(5660300002)(38100700002)(6486002)(36756003)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qWdShvwjgMphSUReJzsm4orIgyZE?= =?utf-8?q?IVh948p5DauxfQiLraQwnZv2PzVqUYlPdANXZYEINZAS9K81R+0AroVozg0FaSehM?= =?utf-8?q?fBGOzdz6ihlEU6Sgh4d4n+JGGCCDjA55/AgogTUOU5sBaJd/Fk/efBsNVM6aFymN8?= =?utf-8?q?6bxFVl00Xm9rc8sl2Fe+vSm7faXZMD3CgzKitiv8S4+r6CrprEMdWnjIA1d23/qzB?= =?utf-8?q?5uqHtXXfYPLSc1U9I0z0CY0r3YzDPpeOcvmbskLueiz1MvQoyDSD4kQvy/xD8LARy?= =?utf-8?q?trM9bu6CQZyb6eowsBgAUCE1XvLR6MntkXjymbLW9X1EtiXRtX1EuuD212XD5A+vg?= =?utf-8?q?t+qEwTVlJI5zAElfABu03FeH9OVc+5BKMGSa+eobXxR4v9n0jRtk+FoT+SsjKdRNO?= =?utf-8?q?RqID9iPg7qEJ8L59WtB1+mFsFj74pIuyB6YyhyMPzg40+6jNjjJWw1tgguoew6Sl6?= =?utf-8?q?z/TbkH6JdoUknDskWqNvCdD/AS3KFCK6JsBB+eglBBqkqNeUGejdqTKoCsuo0ggOA?= =?utf-8?q?lP9eIOlv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yLei4Go/H9glNEoxnTz9kmJwcCqK5f2JgSQb8rKKikI8P?= =?utf-8?q?V1LMOH8ttFv+pGHwA8q15nxa3H7HL3hqAnvNLWLXGMCSqJ2iwSYPNWYKIvAZJOIXE?= =?utf-8?q?iee8pIapfHK5r7JPBp1dZEhIMT5yfCuBVxvam+G82tVvFqkXwgRULHeM4QJGoeYU4?= =?utf-8?q?vb5ueQ5+97tdSuTtRy6Se6XHTllhd7FmA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 58a245ec-7b04-4d58-938f-08d9dc07b44e X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB1372.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 11:26:30.1940 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z6SB4gJOXPetlsaBBaSX6OSU29JVAZ/OEAY1cROqAMVYxH6pQFG57/YXBuKAsb3scWds0ewyr7f7BJxcTeZyUE4rht+GjYNmcNIIJX82yMg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4510 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Piotr PiĆ³rkowski For proper operation of i915 we need usable PCI BARs: - GTTMMADDR BAR 0 (1 for GEN2) - GFXMEM BAR 2. Lets check before we start the i915 probe that these BARs are set, and that they have a size greater than 0. Signed-off-by: Piotr PiĆ³rkowski Cc: Michal Wajdeczko Cc: Jani Nikula Acked-by: Lucas De Marchi --- drivers/gpu/drm/i915/i915_pci.c | 33 +++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pci_config.h | 5 ++++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 8261b6455747..ad60c69d9dd8 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -29,6 +29,8 @@ #include "i915_drv.h" #include "i915_pci.h" +#include "intel_pci_config.h" + #define PLATFORM(x) .platform = (x) #define GEN(x) \ .graphics.ver = (x), \ @@ -1181,6 +1183,34 @@ static bool force_probe(u16 device_id, const char *devices) return ret; } +static bool __pci_resource_valid(struct pci_dev *pdev, int bar) +{ + if (!pci_resource_flags(pdev, bar)) + return false; + + if (pci_resource_flags(pdev, bar) & IORESOURCE_UNSET) + return false; + + if (!pci_resource_len(pdev, bar)) + return false; + + return true; +} + +static bool intel_bars_valid(struct pci_dev *pdev, struct intel_device_info *intel_info) +{ + const int gttmmaddr_bar = intel_info->graphics.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR; + const int gfxmem_bar = GFXMEM_BAR; + + if (!__pci_resource_valid(pdev, gttmmaddr_bar)) + return false; + + if (!__pci_resource_valid(pdev, gfxmem_bar)) + return false; + + return true; +} + static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct intel_device_info *intel_info = @@ -1206,6 +1236,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (PCI_FUNC(pdev->devfn)) return -ENODEV; + if (!intel_bars_valid(pdev, intel_info)) + return -ENODEV; + /* Detect if we need to wait for other drivers early on */ if (intel_modeset_probe_defer(pdev)) return -EPROBE_DEFER; diff --git a/drivers/gpu/drm/i915/intel_pci_config.h b/drivers/gpu/drm/i915/intel_pci_config.h index 12cd9d4f23de..c08fd5d48ada 100644 --- a/drivers/gpu/drm/i915/intel_pci_config.h +++ b/drivers/gpu/drm/i915/intel_pci_config.h @@ -6,6 +6,11 @@ #ifndef __INTEL_PCI_CONFIG_H__ #define __INTEL_PCI_CONFIG_H__ +/* PCI BARs */ +#define GTTMMADR_BAR 0 +#define GEN2_GTTMMADR_BAR 1 +#define GFXMEM_BAR 2 + /* BSM in include/drm/i915_drm.h */ #define MCHBAR_I915 0x44