Received: by 10.213.65.68 with SMTP id h4csp3016156imn; Mon, 9 Apr 2018 12:46:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+mSlL5BSMh7V1E4hlsWjabrBtHZglDZJby8vEf55hU12Wv281WiAS+eLwqWT0EbJivwop5 X-Received: by 10.101.74.69 with SMTP id a5mr26726864pgu.32.1523303193996; Mon, 09 Apr 2018 12:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523303193; cv=none; d=google.com; s=arc-20160816; b=YkYDYh6zj7jFJ5C6ivpprChnp80XtnobCmoUuDs8qqr3sDj9RkQToudAqBk0ufaTJc 2mr7hcHlVafkPO7SGgoXOpZNsixOTqKkPWWHKpk2BuiryYL8hyn+khJLPUrBzwgsQSvc rEo75+K1z2ZrBWraeZ/SMQfOWnHZozYhS/iYF66KlTBkykC4LO1NBpUrAYK246EDECqP W1VZM97mNZW/1+SV9ozmco0ynTni4Zwf1N2ixsICEWce/FOrYYIgDMl7hwIjpZwbZMDs jXMr7rGW3gkJgQCA00O2q1LjSpUjp3CJoUzvI9MOnlg+RUkPQnb2nmjkx77/YZqCUxDn 1RMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature :arc-authentication-results; bh=sFaKj9TTj/DzphMeDVwo2wEGTmDUXbvDRUsiQRGJh24=; b=gJcnSwC0LUofxSyHXxccR8dU/DsEk1ilcV0XDAdGfcPCm73i2WGEl2HK/wTGAIUrkf BGdjjvnQGO6LQeaHRZXsnXKy9E1myVexcyfjdw/AqU9MG8W9q5wKc+M4pG5YIgB+R+xw lFUYf/cMC/adBfgbnKOgR8dBFtxtgbvj16ejjAmNLQzjOKIclDkBoPSWuNxDpf//JxwE 4h9xJkgmXrAdqCpD98q3kwyrGHoOwx4tDzGF0Agqiw72rH78lcthoOUwAhn4f+pR8CJX AhAnjVyhkErAFGeZ3wtS+LGrW3/t+HqIVzpF+qYq7xHQKdi3JV+7lNOY8BjK0f0ejLZN hFtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q+nwEjqK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si969914plr.398.2018.04.09.12.45.57; Mon, 09 Apr 2018 12:46:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q+nwEjqK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754357AbeDITju (ORCPT + 99 others); Mon, 9 Apr 2018 15:39:50 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:35943 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754264AbeDITjo (ORCPT ); Mon, 9 Apr 2018 15:39:44 -0400 Received: by mail-io0-f193.google.com with SMTP id o4so11017851iod.3 for ; Mon, 09 Apr 2018 12:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=sFaKj9TTj/DzphMeDVwo2wEGTmDUXbvDRUsiQRGJh24=; b=Q+nwEjqKduwrE1aILPiUnF6CT8p0ymOUlwnCJqDB+ikpi83AzOTcZwrUmJsXASAniX m8enL9pvThH2Z/h4v1SaanjyUMN2+69M/tpF4xRSRgJ5iDq3RkDH5s761UiC264TzLg5 FxqoopX/K52BYNBAfDKcIEbufx9GmHExHYP5SnJhFyUfI6Dtt/Yqg6tai64t1MeNgu1Y NDh8gc6L7JRq6AAnxcCr07MIYKvHXOLMIUHLwhaJ6BlMDhbfwvQr7wAw4gEbG5PO9yZd icq2tdoUvPIuS2fu8Tt4tj4ptMArxacp0SJCgCEoCC8KuUsI6aJaLkC30PeAiu9Q3Mev FpQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sFaKj9TTj/DzphMeDVwo2wEGTmDUXbvDRUsiQRGJh24=; b=VbkaDfQdBzqDxEdilzDR1kH6BYmMXceWudo8HseiER8t5D2zxloQGBr/jiHGhba1gi YXpnI2Oz7CjGpRWx/g+6TW6t8UzMt8LwXd4ofxNuCxS2+mY7F2x5Lht3Mlz1N2ljP+bC nrZSvm0f+71KXRQeCCFQwzSUIulW8L8aFU17L51T54Z4rbo0SU1vpro90Zjb3bTX/qXv 9fcyOpCp3JCWqasijX5YteJI0pAXDDqbl6L5S4zWMfym3s/Du9qURTZ0HaB7aV9jvIWe IUMwH8FnXQTBXPMNSKQqJOAAUc4gFi6pD3EViD5WOc5UUNC27a75rH0QGWHZ3L9w4io2 z8Mw== X-Gm-Message-State: ALQs6tD51pDBRQuG2tHU4dLlWUBMcyhS5aYcE+05wCwGmgZ69Ge7dInv v9VudA/p8/qpMZ83M04dlUOmYn1GY90= X-Received: by 10.107.15.196 with SMTP id 65mr366684iop.90.1523302783587; Mon, 09 Apr 2018 12:39:43 -0700 (PDT) Received: from [10.0.2.15] (CPEac9e17937810-CM64777dd8e660.cpe.net.cable.rogers.com. [99.245.240.231]) by smtp.gmail.com with ESMTPSA id r32sm473515ioe.31.2018.04.09.12.39.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 12:39:42 -0700 (PDT) Subject: Re: [PATCH] rapidio: use a reference count for struct mport_dma_req To: Ioan Nicu , Andrew Morton , Barry Wood , Matt Porter , Christophe JAILLET , Al Viro , Logan Gunthorpe , Chris Wilson , Tvrtko Ursulin , Frank Kunz , Alexander Sverdlin , linux-kernel@vger.kernel.org References: <20180405203342.GA16191@nokia.com> From: Alex Bounine Message-ID: <2dbed6e5-2244-2de3-ad1a-9d010fa94b5e@gmail.com> Date: Mon, 9 Apr 2018 15:39:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180405203342.GA16191@nokia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-04-05 04:33 PM, Ioan Nicu wrote: > Once the dma request is passed to the DMA engine, the DMA > subsystem would hold a pointer to this structure and could > call the completion callback after do_dma_request() has > timed out. > > The current code deals with this by putting timed out SYNC > requests to a pending list and freeing them later, when the > mport cdev device is released. But this still does not > guarantee that the DMA subsystem is really done with those > transfers, so in theory dma_xfer_callback/dma_req_free > could be called after mport_cdev_release_dma and could > potentially access already freed memory. > > This patch simplifies the current handling by using a kref > in the mport dma request structure, so that it gets freed > only when nobody uses it anymore. > > This also simplifies the code a bit, as FAF transfers are > now handled in the same way as SYNC and ASYNC transfers. > There is no need anymore for the pending list and for the > dma workqueue which was used in case of FAF transfers, so > we remove them both. > > Signed-off-by: Ioan Nicu > --- > drivers/rapidio/devices/rio_mport_cdev.c | 122 +++++-------------------------- > 1 file changed, 18 insertions(+), 104 deletions(-) Acked-by: Alexandre Bounine