Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1748823pxb; Sat, 2 Apr 2022 01:54:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiVck7cts5Kdwp6rgsJPd+GJfSHAiMUTbpjLvO0oxPa1iyXg9bK4B2r4Lv1lsS3m6IJ4sW X-Received: by 2002:a17:902:8e82:b0:151:777b:6d7 with SMTP id bg2-20020a1709028e8200b00151777b06d7mr14135390plb.172.1648889695788; Sat, 02 Apr 2022 01:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648889695; cv=none; d=google.com; s=arc-20160816; b=kKlP5ZAQbTbQOn+a27vZIrol8j6mvOQqjVjCbKXjl5YWyPPfrApmeZgVDdqA0GohSq H/MmujuPv19VZa1fGm6PwoHNMXYjt/e1CtjboZp/am9Mp4M8wRMXQwkAoAA7xQVI3aZR WfMxFA/uGW4TJh04x2c+aQVUjkOeXkhp5Tt0fLiVCkFoPEJNShfwsq77Bf+gXZGZT4Q9 wXF2cYIjABYmeySWTR49SgyKsdrg7kvgyPTLhbaYj5BzAuQoI5e7sZGquW13LTFzh8Rz nH7s88vDpApvoZlI1/gHkU/+syEUZgzuGS8WE3IsczghCfC2O7cSbbTlJVIztiL4lWkg RxZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g3YdE7NZj+L8Dg/chDHlwxEN35uclyYb0VXoHTgKIhw=; b=zDKQmnFZqyjYOuGMZB1S/6SYAYxHK8wZR1kMcwYZCqduN4L1Jfwd++IfEYlBT7zMPv 5rNxnQ1QeRUXS8fWCpjgispiPrIoeiYEExcH1C2j4uQH8esWjiGojFA8RiAiyxD2fnp6 QSulIrVLBPn+GKh3SXEuLpKwL+Sy1RGsA4WSjwoLwjwz6/sJbxlk1LAoQjvBGEPQ0Fis IQ5VHIJz7AT+LMOh5xMNPHvUmO/w3fH0l9mH9yc4MMK7ewm/MzIRzsyOmEjQXHUc15lX YRtY63cFtBFGYLPbvKpkgqNAjDg/GCYFNgndEzA+BHLdEkQs6urWezauD/CWtfctUNXk /mew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nfVXaACm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj6-20020a17090b4f4600b001bf207bdb67si4377528pjb.47.2022.04.02.01.54.22; Sat, 02 Apr 2022 01:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nfVXaACm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1346085AbiDANEM (ORCPT + 99 others); Fri, 1 Apr 2022 09:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346072AbiDANEF (ORCPT ); Fri, 1 Apr 2022 09:04:05 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 945AB21FC5C for ; Fri, 1 Apr 2022 06:02:15 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id bt26so4822291lfb.3 for ; Fri, 01 Apr 2022 06:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g3YdE7NZj+L8Dg/chDHlwxEN35uclyYb0VXoHTgKIhw=; b=nfVXaACmCvFErHHLmNFXvYLypWAxntbQhOofhVv7ZNsll0iXH7oC2baijOofqH55tl ocaVjxe21bM+Po4QV0VsMrwJBUEd08ytEQRibXrlPAg4QTN6ioVivclEaDWT1LnyEWEx 8jAlXp8JIhhCPXZavsM4YpGUxzJJMDxUJvZQQuXujz+Db+429L0Gp8YXugIIseHVbtcP O/APz+MB2/JCJ/erH8dsKo4GwrOtcW5hoK4y48UOly6cL7/KwsV5n+5QVPftBNnqUaNE NBzltQ3wWRi7k0Mn50dLAFjZzLkurSmhPYdviABfBO4NDKlNUBYtE+wsBToRBTwX8Jv0 7yHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g3YdE7NZj+L8Dg/chDHlwxEN35uclyYb0VXoHTgKIhw=; b=O9z3lTPJ6E4/wAJJlykV5SVhEXthsqdMWT98NcsxpuIkkkmpeUBb1LCqmWTXgvFKXw D3RqghaTaj00qbvut/YczxqCAc8EEMUkWbLtB/1YsiVLf6dW7HILTLX4/Iwa/98lAe0b BAS8FJ5lplFRpqJkes4skm/e9YirP92Jc223aGV5PALrlgz9vwYZpf8EUbiAm1xawydc 8ECENKeDwbScejQueMgbkCTIJSPFKZfn2DQfpmSBQbG8OlpuYGLmzyi048efw5WUFvJM feT4olzib8zDHzIjv4UlxcfSwSi5YfzCNSV842yNgvmf0dw9JYuxT4bJFs3khebXlomb G11Q== X-Gm-Message-State: AOAM530B8EvWhXpSvQD1MOHpiut/gW2e3Ooc0YKA7WH5UXsLG6LQkSlb P5HwADdiky9Z2G3W1hZ3gqE= X-Received: by 2002:a05:6512:908:b0:44a:e242:2876 with SMTP id e8-20020a056512090800b0044ae2422876mr960482lft.511.1648818133696; Fri, 01 Apr 2022 06:02:13 -0700 (PDT) Received: from inno-pc.lan (88-115-161-74.elisa-laajakaista.fi. [88.115.161.74]) by smtp.gmail.com with ESMTPSA id y22-20020a056512045600b0044a997dea9esm235574lfk.283.2022.04.01.06.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 06:02:13 -0700 (PDT) From: Zhi Wang X-Google-Original-From: Zhi Wang To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org Cc: Zhi Wang , Christoph Hellwig , Jason Gunthorpe , Jani Nikula , Joonas Lahtinen , Vivi Rodrigo , Zhenyu Wang Subject: [PATCH v8 3/3] i915/gvt: Use the initial HW state snapshot saved in i915 Date: Fri, 1 Apr 2022 09:02:07 -0400 Message-Id: <20220401130207.33944-4-zhi.a.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220401130207.33944-1-zhi.a.wang@intel.com> References: <20220401130207.33944-1-zhi.a.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code of saving initial HW state snapshot has been moved into i915. Let the GVT-g core logic use that snapshot. Cc: Christoph Hellwig Cc: Jason Gunthorpe Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Vivi Rodrigo Cc: Zhenyu Wang Cc: Zhi Wang Signed-off-by: Zhi Wang --- drivers/gpu/drm/i915/gvt/firmware.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/firmware.c b/drivers/gpu/drm/i915/gvt/firmware.c index 1a8274a3f4b1..54fe442238c6 100644 --- a/drivers/gpu/drm/i915/gvt/firmware.c +++ b/drivers/gpu/drm/i915/gvt/firmware.c @@ -66,22 +66,16 @@ static struct bin_attribute firmware_attr = { .mmap = NULL, }; -static int mmio_snapshot_handler(struct intel_gvt *gvt, u32 offset, void *data) -{ - *(u32 *)(data + offset) = intel_uncore_read_notrace(gvt->gt->uncore, - _MMIO(offset)); - return 0; -} - static int expose_firmware_sysfs(struct intel_gvt *gvt) { struct intel_gvt_device_info *info = &gvt->device_info; - struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); + struct drm_i915_private *i915 = gvt->gt->i915; + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); struct gvt_firmware_header *h; void *firmware; void *p; unsigned long size, crc32_start; - int i, ret; + int ret; size = sizeof(*h) + info->mmio_size + info->cfg_space_size; firmware = vzalloc(size); @@ -99,17 +93,16 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) p = firmware + h->cfg_space_offset; - for (i = 0; i < h->cfg_space_size; i += 4) - pci_read_config_dword(pdev, i, p + i); - - memcpy(gvt->firmware.cfg_space, p, info->cfg_space_size); + memcpy(gvt->firmware.cfg_space, i915->vgpu.initial_cfg_space, + info->cfg_space_size); + memcpy(p, gvt->firmware.cfg_space, info->cfg_space_size); p = firmware + h->mmio_offset; - /* Take a snapshot of hw mmio registers. */ - intel_gvt_for_each_tracked_mmio(gvt, mmio_snapshot_handler, p); + memcpy(gvt->firmware.mmio, i915->vgpu.initial_mmio, + info->mmio_size); - memcpy(gvt->firmware.mmio, p, info->mmio_size); + memcpy(p, gvt->firmware.mmio, info->mmio_size); crc32_start = offsetof(struct gvt_firmware_header, crc32) + 4; h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); -- 2.25.1