From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCB3FC4320E for ; Sun, 15 Aug 2021 09:10:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2AC0761042 for ; Sun, 15 Aug 2021 09:10:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2AC0761042 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A68BF8E0001; Sun, 15 Aug 2021 05:10:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A18DD8D0005; Sun, 15 Aug 2021 05:10:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92EEA8E0001; Sun, 15 Aug 2021 05:10:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 769BC8D0005 for ; Sun, 15 Aug 2021 05:10:04 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E7BA7181AF5C3 for ; Sun, 15 Aug 2021 09:10:03 +0000 (UTC) X-FDA: 78476743086.28.7A701A5 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf22.hostedemail.com (Postfix) with ESMTP id 92C4A75B3 for ; Sun, 15 Aug 2021 09:10:03 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 9DEF66736F; Sun, 15 Aug 2021 11:10:00 +0200 (CEST) Date: Sun, 15 Aug 2021 11:10:00 +0200 From: Christoph Hellwig To: Alex Sierra Cc: akpm@linux-foundation.org, Felix.Kuehling@amd.com, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jgg@nvidia.com, jglisse@redhat.com Subject: Re: [PATCH v6 04/13] drm/amdkfd: add SPM support for SVM Message-ID: <20210815091000.GB25067@lst.de> References: <20210813063150.2938-1-alex.sierra@amd.com> <20210813063150.2938-5-alex.sierra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210813063150.2938-5-alex.sierra@amd.com> User-Agent: Mutt/1.5.17 (2007-11-01) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=none; spf=none (imf22.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de X-Stat-Signature: mn3c7gng7b58xga53nci37gm67iojqm4 X-Rspamd-Queue-Id: 92C4A75B3 X-Rspamd-Server: rspam05 X-HE-Tag: 1629018603-362639 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > @@ -880,17 +881,22 @@ int svm_migrate_init(struct amdgpu_device *adev) > * should remove reserved size > */ > size = ALIGN(adev->gmc.real_vram_size, 2ULL << 20); > - res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); > + if (xgmi_connected_to_cpu) > + res = lookup_resource(&iomem_resource, adev->gmc.aper_base); > + else > + res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); > + Can you explain what the point of the lookup_resource is here? res->start is obviously identical to the start value you pass in. So this is used as a way to query the length, but I'm pretty sure the driver must already know that as it inserted the resource itself, right? On a slightly higher level comment svm_migrate_init is a bit of a mess with all the if/else already, and with the above addressed will become a bit more. I think splitting it into a device private and device generic case would probably help people finding it to understand the code much better later on. Even more so with a useful comment.