Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp214476pxj; Wed, 16 Jun 2021 00:18:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+BbXvmOz2ffGab++PjwTTevLzkCB/zk0GjAeswCtkR4uzJJJoHB5xlD640/fWyShwZC/b X-Received: by 2002:a05:6602:204f:: with SMTP id z15mr2591135iod.172.1623827891670; Wed, 16 Jun 2021 00:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623827891; cv=none; d=google.com; s=arc-20160816; b=UpRICD2zdtW4ArwFjDvszeTLlEfLkJogDDvZUjOejaifkPLsu00SkuFUUKYXHHPW4a 0Q5qBMfdll0u0+AdbmjAm86CDwjt559IXWMHmkaEzbBNU1RbsPj4jX2DWqYWFZk7TyIH cdSaphfNk5mBI9xa4XWSb6+c0UO8ZkWejImrWhX2aC0rEtX3eeJEEQODznhCNfkKZYDq Qxo7om/mVROTU0F86hZSmyVrY+BOrfhLGYBCnWT9f6Zj9MttTE+e9L+xdHec0ebECy+I VKdV6FrINBtF8Xzv8aiPtRDLSPE61Cr33Z/rvVwvLqzmLaifVEdPqNIuNaGEl8XveSXS XgNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HzV8mkTx1faxiKUcjaPyI96JNWuhbAj+uTdSDK5uByA=; b=KqarlkiB7YbkXkKYWrRjiuKzD/QaKtalkzGJ5dR19/CeddvDv7kWBSQOBfJ8qNF4b1 XSyQVuc062+kDSylZVhoddIbKY6kkKTaCXEH9JLbTuhi4Lbz1YN7ij5Ah5l+mRGHhIvF XomFGqGNG3PwW/9lPh8TsII5tkzwVKvCdryLYmKZJPQyB3hZMf/ZLZtdqHWSsLgHPU/1 vHbUWT0ZNQf+5SeA3wzsuGlELDarTd1zGCpQALvj5KiKUXbnKGCa8+kfaJbbI14+LiJB FZiLnPCtYNPsjSVh20bfLV8vp6MdPUbMwsiXbh681Zoro5JZ1udMT4ngdi+Rsgj0WNjD 0L7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dY/pxMWk"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si1334250ilg.11.2021.06.16.00.17.59; Wed, 16 Jun 2021 00:18:11 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dY/pxMWk"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231570AbhFPHTQ (ORCPT + 99 others); Wed, 16 Jun 2021 03:19:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:41118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231536AbhFPHTP (ORCPT ); Wed, 16 Jun 2021 03:19:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1783C60FEE; Wed, 16 Jun 2021 07:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623827828; bh=8Y2FE5YJ0Yc1yfyasf8FmPsfNNT+4GHONFUnjg85vQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dY/pxMWkXLTWodK0D+9ngsmsCNkNzjb7LVXNgfZlc8ZMh55IES89NNd4iXptge/7Y SQXqF8nUJBwRud+EKR0G5kj7OHZvA+nN1zifxuI+iRosJEG8qJCzVIeUA1ZX/x+BaT 7KxOMHacJSxrRQ0mc849RMeVL9kVu5dk2fdd5Y7Y= Date: Wed, 16 Jun 2021 09:17:06 +0200 From: Greg KH To: Sanjay R Mehta Cc: Vinod Koul , Sanjay R Mehta , dan.j.williams@intel.com, Thomas.Lendacky@amd.com, Shyam-sundar.S-k@amd.com, Nehal-bakulchandra.Shah@amd.com, robh@kernel.org, mchehab+samsung@kernel.org, davem@davemloft.net, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: Re: [PATCH v9 1/3] dmaengine: ptdma: Initial driver for the AMD PTDMA Message-ID: References: <1622654551-9204-1-git-send-email-Sanju.Mehta@amd.com> <1622654551-9204-2-git-send-email-Sanju.Mehta@amd.com> <94bba5dd-b755-81d0-de30-ce3cdaa3f241@amd.com> <0bc4e249-b8ce-1d92-ddde-b763667a0bcb@amd.com> <12ff7989-c89d-d220-da23-c13ddc53384e@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12ff7989-c89d-d220-da23-c13ddc53384e@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 16, 2021 at 12:27:32PM +0530, Sanjay R Mehta wrote: > > > On 6/16/2021 11:46 AM, Greg KH wrote: > > [CAUTION: External Email] > > > > On Wed, Jun 16, 2021 at 10:24:52AM +0530, Sanjay R Mehta wrote: > >> > >> > >> On 6/16/2021 9:45 AM, Vinod Koul wrote: > >>> [CAUTION: External Email] > >>> > >>> On 15-06-21, 16:50, Sanjay R Mehta wrote: > >>> > >>>>>> +static struct pt_device *pt_alloc_struct(struct device *dev) > >>>>>> +{ > >>>>>> + struct pt_device *pt; > >>>>>> + > >>>>>> + pt = devm_kzalloc(dev, sizeof(*pt), GFP_KERNEL); > >>>>>> + > >>>>>> + if (!pt) > >>>>>> + return NULL; > >>>>>> + pt->dev = dev; > >>>>>> + pt->ord = atomic_inc_return(&pt_ordinal); > >>>>> > >>>>> What is the use of this number? > >>>>> > >>>> > >>>> There are eight similar instances of this DMA engine on AMD SOC. > >>>> It is to differentiate each of these instances. > >>> > >>> Are they individual device objects? > >>> > >> > >> Yes, they are individual device objects. > > > > Then what is "ord" for? Why are you using an atomic variable for this? > > What does this field do? Why doesn't the normal way of naming a device > > come into play here instead? > > > > Hi Greg, > > The value of "ord" is incremented for each device instance and then it > is used to store different name for each device as shown in below snippet. > > pt->ord = atomic_inc_return(&pt_ordinal); > snprintf(pt->name, MAX_PT_NAME_LEN, "pt-%u", pt->ord); Why not use an idr structure like this like all other drivers do? That way when devices are removed the numbers are properly reused as well. And why do you need to save the value? thanks, greg k-h