Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1636116ybs; Mon, 25 May 2020 23:07:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyawBDBGVdva2AVaP0KN1r1dupQRS0CuL/n13Oqw+7nn1NPkQIWwHEh8GnkEWeqxXtUnbhQ X-Received: by 2002:a17:906:279a:: with SMTP id j26mr20472312ejc.398.1590473256900; Mon, 25 May 2020 23:07:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1590473256; cv=pass; d=google.com; s=arc-20160816; b=ObOdMMOUZK/BMI9qfKpP/vrxOUryR6gN9z+xq9cngDpHW6TsNDdPvqhFYUQLs36XCT FZR/v47aGJkcc76/UmVmUz09IDuqUE0A/ZQqlf1HZXpKtHiX+/k4H+S9pMxSl/1dIGgT WU1a3+TAA++hu14GMGbnar7oK1D8MQ6c0nYUaDe9DgLfiIlsWOyBWELVl7pTL1h0R2zB kvbmCA9TctkFWWmvwKCZAdOW2Cmh2XUXz0hpO9Phafh6+9mpxovwShxu08WfOOGeZ/2g 2Ukx/6i4/P6tFTv1eux6g9aqis0BkJ1+Nv2e1XWuo0B86WzCx3ehDO7DcaVkkfHY8Ozn BkpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=PUa4bADADBOhG3tCpkfSCKHPyQ+8tJ2lloe4Zb75FG0=; b=WKDF3zp0mICxGXX1QSV5U8p4vDvpxFg0jvo1GNIntFQOYisvd4O17e8/s6eDyvKu1F fiv0yQbbsAuuUZ6faw43cwy599MKDBqPMauQiMRi5x2k2T5sKKhqUI6m+wrHZthD6QR9 1afq1fplhhH5KUCjZ+ohZsiAt/bVe0NuPHJDfs1hKagYALW1tR+rsJb78rI6LkousST7 +XEAmt4LsnOcOZPkCKPjD7NAj1quXpF2GM9UB0Ht01nP+9kzsLq/LMGT+UrF9uEeYbSU g9iHEFkQ2SnCWAbV0DfDQxbtWQGGDlI7tlAoCyyUeESPuAnfylRkPdW8mvKNG7/N4J9P rkTw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=FV3TTSZU; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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 h24si10591841ejb.719.2020.05.25.23.07.13; Mon, 25 May 2020 23:07:36 -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=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=FV3TTSZU; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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 S1726638AbgEZGFU (ORCPT + 99 others); Tue, 26 May 2020 02:05:20 -0400 Received: from mail-dm6nam11on2069.outbound.protection.outlook.com ([40.107.223.69]:39008 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725771AbgEZGFU (ORCPT ); Tue, 26 May 2020 02:05:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eXFbbJmVFUIdNI0EZPkpwXa/+PC3UDpLAdhxm6r9dDxh+43hpdfHXMru0wDV518kX2piNHNo5g7ZMy1FDGTWIDWFp5ihtFN38iHTKgDtk67y+0rIQzJSCUUQZx+7lSRimIzZ+5cZG7F05eHuRZd4ca94l9s71gYhK7g0VsDH395CtxS2GZda/fHTnR7aVtWZznsldYsFZseCAkJSpjhMWnVeqNEUEDSVSUbQ0t5aZxeQ9yRDM0GMnfDB5+kc35CKOM2Z1zsLr1mV+8DeQT9KlMdrdvubAXqL+n42Xeagjf+qw87q/g5NXBictyR5kk9eGE5WpsK6wook4BK0WwevpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PUa4bADADBOhG3tCpkfSCKHPyQ+8tJ2lloe4Zb75FG0=; b=aVCEmomzlq9CIzIgKpt+G/4oW7CRyRzbU43BrMXYBhRcUGN914sICcJkr+dcV00w+S7+S2P/vztgiDiCDxX8R/G9TCKfpj4zKQCzXtfBESUTZxAwu3KGRnI3l6ifsiRzjr06kHmx6Gumls3yA5a+u4phYZKHKPnAphkO51QGC2/eaW6P4r+IJO7b3fEKbWF5+bO4GZgp5h6OqgNhYgTDaAK1RcZNGrUr03LZ3AFH3QwO/jIi3UlpynK0KZWGG83qr/xsWg+tDWb0NaCqzP0VxFtFSPrATkc1Zzy6n1pVTA5n1c+26h0Y0/L80wxmdNJE0gXURFUN7fkzyPraS4QHCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PUa4bADADBOhG3tCpkfSCKHPyQ+8tJ2lloe4Zb75FG0=; b=FV3TTSZUSSp9xPXl/DNpN1XUYM7tY6QNrDbym1N6T4phn0AFa9YpMtYsOOLxLYiY8Rp5Br2DqRs6HW6Mo1nDy+F6Nmw9P1ocXXI7yt9XKL/I7fyZP1FU39BkN9BeNlkXv93InXfezobZu39tyE5+6ZyawDoZ9v5mXgcoJQ+2Liw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB3420.namprd12.prod.outlook.com (2603:10b6:5:3a::27) by DM6PR12MB3291.namprd12.prod.outlook.com (2603:10b6:5:186::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24; Tue, 26 May 2020 06:05:16 +0000 Received: from DM6PR12MB3420.namprd12.prod.outlook.com ([fe80::d007:1b50:9d7c:632f]) by DM6PR12MB3420.namprd12.prod.outlook.com ([fe80::d007:1b50:9d7c:632f%5]) with mapi id 15.20.3021.029; Tue, 26 May 2020 06:05:16 +0000 Subject: Re: [PATCH v4 1/3] dmaengine: ptdma: Initial driver for the AMD PTDMA controller To: Vinod Koul , Sanjay R Mehta Cc: gregkh@linuxfoundation.org, 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 References: <1588108416-49050-1-git-send-email-Sanju.Mehta@amd.com> <1588108416-49050-2-git-send-email-Sanju.Mehta@amd.com> <20200504055539.GJ1375924@vkoul-mobl> From: Sanjay R Mehta Message-ID: Date: Tue, 26 May 2020 11:35:02 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 In-Reply-To: <20200504055539.GJ1375924@vkoul-mobl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BM1PR01CA0163.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::33) To DM6PR12MB3420.namprd12.prod.outlook.com (2603:10b6:5:3a::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2406:7400:70:65d3::1] (2406:7400:70:65d3::1) by BM1PR01CA0163.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Tue, 26 May 2020 06:05:11 +0000 X-Originating-IP: [2406:7400:70:65d3::1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d4ab657e-1f81-470e-9223-08d8013ac2c0 X-MS-TrafficTypeDiagnostic: DM6PR12MB3291: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-Forefront-PRVS: 041517DFAB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J4TV7KPNmXR1yx9MFvC/TusuVAZG5iTHoywfKup/Q/d9ujIT323VHHt0DWdGZSbIyvI57BQGm/qh/iijNhRj3aGjb3G52dY60s1ZP0HmqwG0+egVkI4teIRgK1miUgTRuwv2pLTcGAj4YrByWqHUyJJDgBj30AwaA6RGb+dxYXdMcsAaLW0iNUjuluEYfiVq8gnWm/uUqVdzbY5Tlap/ZE84nREMluHkMmu3zZwpkQ7Gbtbd9zgixOVQ9t04++rZHdopjH5Io/slb6mEgr8ur+y143/POiXPNiCP+4z9Op/2OTCgvp1L90hPs4PcLY45d/1WoslbpmkPnqUXS3vof73tBYSnmNNE5cvHdq0NPK7mMuwsaqlizgnyx0sJ1wwc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3420.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(366004)(396003)(346002)(376002)(39860400002)(36756003)(8936002)(2616005)(110136005)(8676002)(316002)(4326008)(478600001)(2906002)(31696002)(6666004)(6486002)(6636002)(66556008)(66476007)(66946007)(52116002)(5660300002)(16526019)(186003)(31686004)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EiOgUr4hXwUQ9TvRAZEjnqRnUXz7jtH4dH/D3ZCgTJ9c7sWQsjpc+kkPNaEN6WbW74leVtIfqNK18GJYsXJBDM/OwDJgwktGejP7eTLAaDZWslgQCoh4mfeRiKykOPwfLm1o8ztb3Sguvx+4KLy3Brj+cN80mKLxSW1qxyg7HwDz1321RUVoMtbO4TdnlzuhRMNhxI6kbjLAUSQWe7Y8rxu6vAlJW6dIhOrNEYNGyiX9v0c6g4/Coz15XaIlBVAbyW/gRVFN/qlzfx76nyCe0yYT58o5e6crWwC9U4iZqlgw3DDjPi4RKB3cllDhILBdKrqo38CW2xqVb8MGCVwB5u6MM/Ye2tNRnidOqvpmCTVr2lPzqCVaPqh6prcI+xxH5LKuAfXr5D5/E2ra7u5laJg8QLzgU3oVXkigWfWuGrsbQJaJe6sstR3L7KwlBcp3SW4VZE7hxbwINCdGYezFAYBc2ChwxTNFLX6iS/F9eaqCm5p75DaKRomYae31vZMp X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4ab657e-1f81-470e-9223-08d8013ac2c0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2020 06:05:16.4283 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dH/rYTItsNGn/vERn8FT/gBMZIviXNy4+l8tdNtoQtGyJ9TzHVzlzkxiAGRPmpoZ33Dwd3xrTooju39Gi1yXMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3291 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apologies for my delayed response. >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "ptdma.h" >> + >> +static int cmd_queue_length = 32; >> +module_param(cmd_queue_length, uint, 0644); >> +MODULE_PARM_DESC(cmd_queue_length, >> + " length of the command queue, a power of 2 (2 <= val <= 128)"); > > Any reason for this as module param? who will configure this and how? > The command queue length can be from 2 to 64K command. Therefore added as module parameter to allow the length of the queue to be specified at load time. >> + * List of PTDMAs, PTDMA count, read-write access lock, and access functions >> + * >> + * Lock structure: get pt_unit_lock for reading whenever we need to >> + * examine the PTDMA list. While holding it for reading we can acquire >> + * the RR lock to update the round-robin next-PTDMA pointer. The unit lock >> + * must be acquired before the RR lock. >> + * >> + * If the unit-lock is acquired for writing, we have total control over >> + * the list, so there's no value in getting the RR lock. >> + */ >> +static DEFINE_RWLOCK(pt_unit_lock); >> +static LIST_HEAD(pt_units); >> + >> +static struct pt_device *pt_rr; > > why do we need these globals and not in driver context? > The AMD SOC has multiple PT controller's with the same PCI device ID and hence the same driver is probed for each instance. The driver stores the pt_device context of each PT controller in this global list. >> +static void pt_add_device(struct pt_device *pt) >> +{ >> + unsigned long flags; >> + >> + write_lock_irqsave(&pt_unit_lock, flags); >> + list_add_tail(&pt->entry, &pt_units); >> + if (!pt_rr) >> + /* >> + * We already have the list lock (we're first) so this >> + * pointer can't change on us. Set its initial value. >> + */ >> + pt_rr = pt; >> + write_unlock_irqrestore(&pt_unit_lock, flags); >> +} > > Can you please explain what do you mean by having a list of devices and > why are we adding/removing dynamically? > Since AMD SOC has many PT controller's with the same PCI device ID and hence the same driver probed for initialization of each PT controller device instance. Also, the number of PT controller varies for different AMD SOC's. Therefore the dynamic adding/removing of each PT controller context to global device list implemented. > -- > ~Vinod >