Received: by 2002:a05:6a10:c7d3:0:0:0:0 with SMTP id h19csp847305pxy; Sun, 15 Aug 2021 02:10:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDCSB9gc/Da/eILqhfAvLSwRVJbAr3RuzIkaKLlx53y6sP44fvPX94O3/db5tV1GWtvtsl X-Received: by 2002:a05:6e02:dcc:: with SMTP id l12mr7804598ilj.20.1629018633178; Sun, 15 Aug 2021 02:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629018633; cv=none; d=google.com; s=arc-20160816; b=eprnaEdOn/4toQj8kNWtKd5CQX9y5cx88AbDujgJIWTxUvrPkXU6qVctQ+mqWOw2OI 3dSNqetlEuqLQSKe0i8wLQXRVJ/NDKYQRe1ewRN2E93EN6GRXeGiepfg3qRVf/RPcOph bXhcs/LvTsOj7YRJBIDAcGWw9yRaYo1gdKSatVDwfphxUowmBe6r3Zkk1OXW9G44aV3L Oz9o2CTcTtOs+rW6tfMFqWiD+6FH7XnWRQt5JnWWSMmmi24dHd4ToKJQgyBbc/QYsDCi Zq+lvep12MtJIzTkHF/UxleCk/9VCYzvQ2Giwz3w9D8722Zylqj4bVFHXTRsRyKXubwi ha5g== 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=20xKBe8g4vrnTe/XvpqjSB5hD9d3ZfZmwp03qT7qGec=; b=JTqu9JrZSQXjpIQuTlD7e2+uEdG+4Fdb68iBmcfLjR2C2yveuqKkW9WWKKtL2LaWRk P6tqXxSn2ws4R+3Wz64LbZNYtAK9MkBBbG5lHnCwZhipxRthNJg+so86j/3hF0afTa2t 5/mF6jdqdP9Iw70+hTZFhl94iGL1NE+pEuyG32yqMGQRPlGYlIXy6//AgZ944fBTjRDC WaD5p51YdPeHVW7PopIB865fFYWhiay8nZFM5IhODboQKwKEf3Zpc4GCgg1Ev10qyYnx mf3vltijpbBXz5iTDQZH+xCa1kQ/9n8oVMpa+sOWg2lh9gLHSI3x+cTAx0TqrkCBza/+ nQsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 p4si7853010ilq.160.2021.08.15.02.10.20; Sun, 15 Aug 2021 02:10:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236828AbhHOJKe (ORCPT + 99 others); Sun, 15 Aug 2021 05:10:34 -0400 Received: from verein.lst.de ([213.95.11.211]:51390 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbhHOJKe (ORCPT ); Sun, 15 Aug 2021 05:10:34 -0400 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) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org > @@ -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.