Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp640920pxb; Tue, 1 Feb 2022 07:30:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwStn0kvlHwMd5OXM5vgdTVxUy50ZwqSpTLtqg1fzBEqUXIN/ZW4R5YvHaEFvxvaux7zmXd X-Received: by 2002:a63:6983:: with SMTP id e125mr20953591pgc.574.1643729452727; Tue, 01 Feb 2022 07:30:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643729452; cv=none; d=google.com; s=arc-20160816; b=c+TUHjyvqTsddjZs43/twsHUUbPd+SKhC1EpwHEE0YNljbY1F44WyfOZN04hpPt52R /ULAdM/hKQSb9IJXHI2EV1fPOr7vYUb3O3XpPzQM3NzwLBsPigcfjNBjFQ3k45v6i51m XwI9JQWeVjw1aAofj3qoKbkndiT0LMWMT6lxJZllVPTFuefIx71yjlLShqyUcCFjVRl3 Wxd9RgUdbHP59gofTRKeG9d6QRBgPMndSmrxSWTqvHpP4Yqr7H/zHiIZaH1/89D+Tpja ndSTmJlotP8p9AIN88CBYd8HUcGKeVNoJ/aZ4pPxAvbjX2zW2hAF2k5JZyy98X4g+6ZA Waug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=H3oxqWArPGLl3FnVo7O+yqEx5V27JrSxA8/uc4cwTeA=; b=jUIlzIb7zs/fbnGwlG3JJWkD+OcJc0wxToRL0t6AkZf0w+wwGzPTKP6j3fwJmqhms+ 8XmkbFxhQdFovJzZ02/AeQE8BeOfLBhr9PnNG1W+oBqy8BMfq00wi51U8qrjbbNoc3Gk xUFDxNDZIDqzPz9uaw4Cb4JwUing1Zi4ja/r04agi/eGrcOFz7fp17ZN3Wd+u4JnEvMo QAvuw97mk/658o3AbwhwYJqN1W2yc3isAiou59pTyBkmR1SEP+X1628JT3GjKh2UwBuW Jfcu1hJXVc6FYGzuhNRUG70HJEcZFI3DeJoeOR5dslWoqX1I6TDwAMdtPJfjgicqvYmr NJOg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 15si16758813pfl.378.2022.02.01.07.30.39; Tue, 01 Feb 2022 07:30:52 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357679AbiAaGiI (ORCPT + 99 others); Mon, 31 Jan 2022 01:38:08 -0500 Received: from verein.lst.de ([213.95.11.211]:53688 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352820AbiAaGiH (ORCPT ); Mon, 31 Jan 2022 01:38:07 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id E502468AFE; Mon, 31 Jan 2022 07:38:03 +0100 (CET) Date: Mon, 31 Jan 2022 07:38:03 +0100 From: Christoph Hellwig To: Zhi Wang Cc: hch@lst.de, jgg@nvidia.com, jani.nikula@linux.intel.com, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zhi Wang , Joonas Lahtinen , Vivi Rodrigo , Zhenyu Wang Subject: Re: [PATCH 2/3] i915/gvt: save the initial HW state snapshot in i915. Message-ID: <20220131063803.GB4390@lst.de> References: <20220127120508.11330-1-zhi.a.wang@intel.com> <20220127120508.11330-2-zhi.a.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220127120508.11330-2-zhi.a.wang@intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 27, 2022 at 07:05:07AM -0500, Zhi Wang wrote: > +static void save_mmio(struct intel_gvt_mmio_table_iter *iter, u32 offset, > + u32 size) > +{ > + struct drm_i915_private *dev_priv = iter->i915; > + void *mmio = iter->data; > + u32 start, end, i; > + > + start = offset; > + end = offset + size; > + > + for (i = start; i < end; i += 4) { > + *(u32 *)(mmio + i) = intel_uncore_read_notrace( > + to_gt(dev_priv)->uncore, _MMIO(offset)); > + } > +} This can be simplified to: static void intel_gvt_save_mmio(struct intel_gvt_mmio_table_iter *iter, u32 offset, u32 size) { struct drm_i915_private *dev_priv = iter->i915; u32 *mmio = iter->data, i; for (i = offset; i < offset + size; i += 4) { mmio[i] = intel_uncore_read_notrace(to_gt(dev_priv)->uncore, _MMIO(offset)); } } > + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); > + struct intel_gvt_device_info info; > + struct i915_virtual_gpu *vgpu = &dev_priv->vgpu; > + struct intel_gvt_mmio_table_iter iter; > + void *mem; > + int i, ret; > + > + intel_gvt_init_device_info(dev_priv, &info); There is no real need for this call. > + > + mem = kzalloc(info.cfg_space_size, GFP_KERNEL); > + if (!mem) > + return -ENOMEM; info.cfg_space_size is always PCI_CFG_SPACE_EXP_SIZE, and the code relies onb that just a few lines below. > + mem = vzalloc(info.mmio_size); And info.mmio_size is a constant that can just use a define.