Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4802012pxu; Wed, 21 Oct 2020 05:54:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjsYGtbwEew2hTU7cNAWao6zLn6DfMry/0Ct0E5lL7hBn0nPPVRK8YMFC0yfrdU1TGV1Q3 X-Received: by 2002:a17:906:9396:: with SMTP id l22mr3300801ejx.36.1603284855375; Wed, 21 Oct 2020 05:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603284855; cv=none; d=google.com; s=arc-20160816; b=xF7mxtrJf/fgl1abTYHZ9P8lF3YrAZIbXMDjNJGUBXlq93uc4XIRpoe5c6KiDUmwBj rz7IWubp4NMIutTRtzSYYb25Wj0F6I4AAzT9vth/aDaQO4yTVvFEm0jxBW1Wwa4XhNtv U260DtAOU2HOfk1hD/udtk+5UcXOUWs+Aztd0JeHptUSighG9OjnBJx3yjRLNJ/hWkzn Jj7heOZ21sbjDIq6OTQToWTiFMuCzULdQu2jdmJ2l98wIWX2Wjn2kTsESNJ2qUBnbpJU da/rYrZ/cS9A8r48u+geg/WiucYZyViYc7Sox2WstWSv3TjgRnsEV2subuFr4Ms53A0+ jqjQ== 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=ZRaeFp/xjvskpvoZzDQUVoJLtFjrMp/+1ZWgX79TN5I=; b=T7uAwQ0Txbw2dvTADFaLWzmbn2vfQz1Bo/nM33XgdaphIgyOKltgLgu1CRyhpTtLR8 dC5eSbtos6rezI9ACfYDvIk4UUaS1DHXIVTz2yj64caGQD0nlK38PQV0w09xgtI2k5Eq D48UdnzUfIK6fOX3jw6nE0MaGrE+7hEF8SxRiZ5m2WU8RYVkEPqAZ0NkFgtg8UHuYAGC CFM/dmquWqMvJfVY5cBlqiSwTd0rXeILWP7L1AN3UjNsHaVoTotZxuo2Wtv9gNbVtvOB sVRIB5WAxdYkIbsQ2aST1ZHJNuN6es188gqWBhIsTSslYjOirsO5nxdIU8zdjOXRGNM1 lm8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u3KbvVk+; 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=fail (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 e8si1226552ejd.228.2020.10.21.05.53.53; Wed, 21 Oct 2020 05:54:15 -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=@kernel.org header.s=default header.b=u3KbvVk+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441096AbgJUIvu (ORCPT + 99 others); Wed, 21 Oct 2020 04:51:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:52348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441066AbgJUIvt (ORCPT ); Wed, 21 Oct 2020 04:51:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AAA9F21789; Wed, 21 Oct 2020 08:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603270308; bh=4h+OCFwSPTmgFlamZlpSXwlJHTKoRjaneJzFZE4B7Ew=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u3KbvVk+KhFdwL/JVPEJ0vMyVlvj0blxtoQqmyp0G8n+HQYpNUzASeF76z/iEI3vq HF7zfP4hhGbP25E0gz4BW35/cKmugIuqoTokRMnaIcY4kOiILmSdn/Cw+16appdaGR lOXjWykj1n9hB9yWyloufkUjRDZx/veSr6cFoQWw= Date: Wed, 21 Oct 2020 10:52:27 +0200 From: Greg Kroah-Hartman To: Furquan Shaikh Cc: Ard Biesheuvel , Linux Kernel Mailing List , Prashant Malani , Arthur Heymans , Patrick Rudolph , Duncan Laurie Subject: Re: [PATCH] firmware: gsmi: Drop the use of dma_pool_* API functions Message-ID: <20201021085227.GA1102039@kroah.com> References: <20201021050141.377787-1-furquan@google.com> <20201021051931.GA967331@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2020 at 12:37:52AM -0700, Furquan Shaikh wrote: > On Tue, Oct 20, 2020 at 11:37 PM Ard Biesheuvel wrote: > > > > On Wed, 21 Oct 2020 at 07:18, Greg Kroah-Hartman > > wrote: > > > > > > On Tue, Oct 20, 2020 at 10:01:41PM -0700, Furquan Shaikh wrote: > > > > GSMI driver uses dma_pool_* API functions for buffer allocation > > > > because it requires that the SMI buffers are allocated within 32-bit > > > > physical address space. However, this does not work well with IOMMU > > > > since there is no real device and hence no domain associated with the > > > > device. > > > > > > > > Since this is not a real device, it does not require any device > > > > address(IOVA) for the buffer allocations. The only requirement is to > > > > ensure that the physical address allocated to the buffer is within > > > > 32-bit physical address space. This change allocates a page using > > > > `get_zeroed_page()` and passes in GFP_DMA32 flag to ensure that the > > > > page allocation is done in the DMA32 zone. All the buffer allocation > > > > requests for gsmi_buf are then satisfed using this pre-allocated page > > > > for the device. > > > > > > Are you sure that "GFP_DMA32" really does what you think it does? A > > > "normal" call with GFP_KERNEL" will give you memory that is properly > > > dma-able. > > > > > > We should not be adding new GFP_DMA* users in the kernel in these days, > > > just call dma_alloc*() and you should be fine. > > > > > > > The point seems to be that this is not about DMA at all, and so there > > is no device associated with the DMA allocation. > > > > The other 'master' is the CPU running firmware in an execution mode > > where it can only access the bottom 4 GB of memory, and GFP_DMA32 > > happens to allocate from a zone which is guaranteed to be accessible > > to the firmware. > > Ard captured the context and requirement perfectly. GFP_DMA32 > satisfies the requirement for allocating memory from a zone which is > accessible to the firmware in SMI mode. This seems to be one of the > common ways how other drivers and common code in the kernel currently > allocate physical memory below the 4G boundary. Hence, I used the same > mechanism in GSMI driver. Then can you please document this a bit better in the changelog, explaining why this is ok to use this obsolete api, and also in the code itself so that no one tries to clean it up in the future? thanks, greg k-h