Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2222660pxb; Fri, 25 Mar 2022 13:20:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/vojABdY+haNfh9xBWTm2fIVzZq56E+goFeqPQE2HM13KYO1/VmaIGrQ1bSgnyBV7+WGq X-Received: by 2002:a17:902:b782:b0:153:e0dc:755e with SMTP id e2-20020a170902b78200b00153e0dc755emr13581289pls.1.1648239649349; Fri, 25 Mar 2022 13:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648239649; cv=none; d=google.com; s=arc-20160816; b=k+Z4B2p/+wUZQy5oTKndWuJd+ImdPpviJ8/vbK+sp9NiL5iktsfOcfgs1yzXXQcXLY YixnrBxVXzZGRZ98feKihuDJ+alX6rMZYSgWoL2HZmmuR+Ds2NXjRwz104AtY7CXFKjQ Og0E7F28ZYEF0vCE8Hp3IKDMtzFLurQSWycd0vcfQVCVn0ntGmFITc/qlHViPLfSnRSg s2tFdqcTyuP4mQr2d38A9dg0fmzdl+OKHLB5K7j3vkFIsgqYUG+aTrB04ctygnXCEYmJ rrF37WQuUv998BVshHfpuUV1i3jmDteUG/TF5PxSeoBjSI98/GgbGWJ8+TbF6Li70F6w Sb0Q== 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=ad+rO7vPcTuzs/lRCoSBr5OavzwFZWh92/Zfl2vja4AteCYQiEuqr+LDKzfknMUyBu D3pjnwXzqKeo59afgWyzD0lDVc/q/DaA2dcV0uFUwU4knn5QEWHyGIJ6XkKa3CEeNt7G cYoF9IbjMG3DFJJjpAhsRDcBszNOHxrUdRwwfTU383zEl8nNwmi80Z+gNpGT9jVsJdOp uWr6kiuNKJvZlgrWCBP9Vg+Tkv0UQYSUV6y2vuv4+LaTa2WsOkgSujyl82SJWG45yOcb vTNW+PqRSPP9o3XnUgjVD5OXN7cc+RhdagH0TEyuonckq0iTptNBmRIZKG9EJ9i+TsZT dWaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MMT0HILF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e1-20020a63aa01000000b003816043f06asi3388842pgf.607.2022.03.25.13.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 13:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MMT0HILF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 23FA02B3303; Fri, 25 Mar 2022 12:28:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbiCYT2I (ORCPT + 99 others); Fri, 25 Mar 2022 15:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbiCYT1r (ORCPT ); Fri, 25 Mar 2022 15:27:47 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881C118C0FC for ; Fri, 25 Mar 2022 12:01:08 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b19so12034901wrh.11 for ; Fri, 25 Mar 2022 12:01:08 -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=MMT0HILFjBkL/NOsKp9IJ2Rcg0Ta+95vRvNWBYWrlOSIdSS/HBuue+mPjlkij71azQ 0P5eB1ylgJXrA8wISBW3MIEOQq9V8kTIOutdu1YyPl/RMmywWucplv9XzAl5Sofyu2NZ lcwi7kD1rUgaG48Ae5QuxCsXmr7Z/uB140i8qGVBqcVUTHKyG7HKBkKYESJoaGwgzq68 1s6A5DrtAJAdS2gEUk1lYvC1sZJlg1dpf8QKwCvEYFMZRf+w683AQkn6WnStAT09ta9A fhVdJsfPydEoaCh1FmvyfMkAS6pIKS5EA6lHAzFT+DWHuqKlMgrxCEXVqreNKQzRlsNV 1RLg== 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=Apc7tM77gFjks3tkK1ZXhvn6KxW6wbaNoNRO7rJQf/J5AC1PQIoRdtQh27ak8Grc70 wi3Enwhsn/D3WraXmAEYrZwSNzhkwk18cE2yrGis4V9ARu24cvvZo+dFz6Ic802hYns8 8dzBiEfr1u9WhVBkiZvzYFg+0Qjun8wsjLKwoe6KzdXN55tDKhtHViopoc56Tc8vj0Td SCvtm+R+gJI4KBoSNaRBGmQWBxguWdTotwjbXlEqSbwZT2Zvm2/yiC/r7h77AxwuYnZp JnsdubONDgMW/fFa3qyQdlu5j+iNw8OzEOdM5y3V5chpf6k27JdmFiAC/TH2u10pJV3S qPrw== X-Gm-Message-State: AOAM531JyiNw0CEu+XtdSZ3V/Q+gDRJW8TQq55AoRpktiec9WEjiXG5/ HkVYATSDormQglgt8A49DBZk0DV9mHY= X-Received: by 2002:ac2:4c8a:0:b0:44a:3271:dc3b with SMTP id d10-20020ac24c8a000000b0044a3271dc3bmr8382480lfl.83.1648230791199; Fri, 25 Mar 2022 10:53:11 -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 z17-20020ac24191000000b004483a4d9a3esm775738lfh.152.2022.03.25.10.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:53:10 -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 v7 3/3] i915/gvt: Use the initial HW state snapshot saved in i915 Date: Fri, 25 Mar 2022 13:52:51 -0400 Message-Id: <20220325175251.167164-3-zhi.a.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325175251.167164-1-zhi.a.wang@intel.com> References: <20220325175251.167164-1-zhi.a.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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