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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 C936DC433DF for ; Fri, 31 Jul 2020 14:23:54 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DEFB208E4 for ; Fri, 31 Jul 2020 14:23:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="SO5Az25C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DEFB208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7DEB688796; Fri, 31 Jul 2020 14:23:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SsiF-XIK1dYw; Fri, 31 Jul 2020 14:23:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id F3C5688789; Fri, 31 Jul 2020 14:23:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DBD17C004F; Fri, 31 Jul 2020 14:23:53 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6A857C004D for ; Fri, 31 Jul 2020 14:23:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 51D4B85FDE for ; Fri, 31 Jul 2020 14:23:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HjtXoyLkIcey for ; Fri, 31 Jul 2020 14:23:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3215785E6F for ; Fri, 31 Jul 2020 14:23:52 +0000 (UTC) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E66C222D2A for ; Fri, 31 Jul 2020 14:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596205432; bh=p6Dyfo2urJO4AhbyumMGMhFkpTQ7ortakkUGpTrUpmQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SO5Az25CevLmfcenbN2c7sl6b6bmuFxDrbUgyN0CyQoiqqjwbDK/k32lbmpUiBt0s IQIcX5y+uC4L3wjkyt2cclp61d6Ebt13/K3jEBgB1lh1O6bDDbJGlzd7cZqIN9QcAS jBqyu1DxeQzHV7JAR8HtfaYIfAsfk1vDM96jC7+o= Received: by mail-yb1-f171.google.com with SMTP id y17so16298580ybm.12 for ; Fri, 31 Jul 2020 07:23:51 -0700 (PDT) X-Gm-Message-State: AOAM532VwRMsFcQIJAbGLJK4bZ5AIMtnbFiCIfWZzo3DkFmo5F+2GbDP IIBNAoYNZ/bRJHZTSOifePI1kLOPEagZr00JZQ== X-Google-Smtp-Source: ABdhPJyKOAtr6VPGSPomkdltpSsLr5l7uePcUajkE/DQZzP1vNdcO1EO/U2cbsU8VZIKN9wGPlt25OG9uNG86TDPGSk= X-Received: by 2002:a9d:46c:: with SMTP id 99mr3203799otc.192.1596205429361; Fri, 31 Jul 2020 07:23:49 -0700 (PDT) MIME-Version: 1.0 References: <20200724203407.16972-1-james.quinlan@broadcom.com> <20200724203407.16972-9-james.quinlan@broadcom.com> <20200729061903.GA31671@lst.de> In-Reply-To: From: Rob Herring Date: Fri, 31 Jul 2020 08:23:37 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 08/12] device core: Introduce DMA range map, supplanting dma_pfn_offset To: Jim Quinlan Cc: Rich Felker , "open list:SUPERH" , David Airlie , PCI , Hanjun Guo , "open list:REMOTE PROCESSOR \(REMOTEPROC\) SUBSYSTEM" , Andy Shevchenko , Julien Grall , Heikki Krogerus , "H. Peter Anvin" , Will Deacon , Christoph Hellwig , "open list:STAGING SUBSYSTEM" , Jean-Philippe Brucker , Yoshinori Sato , Frank Rowand , "maintainer:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , Russell King , "open list:ACPI FOR ARM64 \(ACPI/arm64\)" , Chen-Yu Tsai , Ingo Molnar , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Alan Stern , Len Brown , Ohad Ben-Cohen , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Philipp Zabel , Arnd Bergmann , Suzuki K Poulose , Maxime Ripard , Florian Fainelli , Borislav Petkov , "open list:DRM DRIVERS FOR ALLWINNER A10" , Yong Deng , Santosh Shilimkar , Bjorn Helgaas , Thomas Gleixner , Mauro Carvalho Chehab , "moderated list:ARM PORT" , Saravana Kannan , Greg Kroah-Hartman , Oliver Neukum , "Rafael J. Wysocki" , open list , Paul Kocialkowski , "open list:IOMMU DRIVERS" , "open list:USB SUBSYSTEM" , Stefano Stabellini , Daniel Vetter , Sudeep Holla , "open list:ALLWINNER A10 CSI DRIVER" , Robin Murphy , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Thu, Jul 30, 2020 at 10:44 AM Jim Quinlan wrote: > > On Wed, Jul 29, 2020 at 10:28 AM Rob Herring wrote: > > > > On Wed, Jul 29, 2020 at 12:19 AM Christoph Hellwig wrote: > > > > > > On Tue, Jul 28, 2020 at 02:24:51PM -0400, Jim Quinlan wrote: > > > > I started using devm_kcalloc() but at least two reviewers convinced me > > > > to just use kcalloc(). In addition, when I was using devm_kcalloc() > > > > it was awkward because 'dev' is not available to this function. > > > > > > > > It comes down to whether unbind/binding the device N times is actually > > > > a reasonable usage. As for my experience I've seen two cases: (1) my > > > > overnight "bind/unbind the PCIe RC driver" script, and we have a > > > > customer who does an unbind/bind as a hail mary to bring back life to > > > > their dead EP device. If the latter case happens repeatedly, there > > > > are bigger problems. > > > > > > We can't just leak the allocations. Do you have a pointer to the > > > arguments against managed resources? I'm generally not a huge fan > > > of the managed resources, but for a case like this they actually seem > > > useful. If we don't use the managed resources we'll at leat need > > > to explicitly free the resources when freeing the device. > > > > The lifetime for devm_kcalloc may not be what we want here. devm > > allocs are freed on probe fail or remove, not on freeing the device > > (there is a just in case free there too though). > > What do you suggest doing as an alternative? I believe I gave it already. Put a kfree in the struct device release function. But you can't be passing the pointer from device to device if you go that route. You'd have to either copy the struct or check if it's the same as the parent's and skip the kfree in that case. Rob _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu