Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1885584ybz; Sat, 18 Apr 2020 10:28:31 -0700 (PDT) X-Google-Smtp-Source: APiQypK6H8AAdAQ3oO0kg9SOtkjrJFy3ICx0r8sQiUgqxVxUofN3W10fGcU4AKvbkyWTorzh/wrl X-Received: by 2002:a50:ed8f:: with SMTP id h15mr8137831edr.331.1587230911336; Sat, 18 Apr 2020 10:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587230911; cv=none; d=google.com; s=arc-20160816; b=wt72+9j9GjSTpE2P/0iLl9a8H/rT09pO+xLz5CDQcImOfdZMAAVRCVvstqHdHW6Ol4 I17a0HnRdfE+/72del+KJatNkbUGtASpzbPmKFu24yZdggxlNvIjJgXzjL5n9XH7bcQM k2LDoHZQoUkCAIPTus1GYMp5CoN5opFGv8XfdvjHAo25u5+fNjsuRY/XgPbRedXpxAIx UXB10j+IV3FNEI5ubDTlxTTaO8pBQ5sZdvTCfzW88PSvkSpt/10uKioEJFJMs6lC4suh i4N8YYx0+0YARL5iSBWHOH2CSbbYptNWJ9QV336+2YQeH2Ybmj/DAmDRSS5u5yxXbmHK g9Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:dkim-signature; bh=OMU4gc4xJrsz9oC2mAccr/thZgznAgM1yG5wcPECHkg=; b=ZyV1pxK95t1GD3OI94kVYwCH2BfRIQNfF2Lblv8lmZip8Z4qUdlbE8X+Lh9PBDEI0J Z1T0cyfr6E5WWl+C0PCC3bSjr8fvc+vzDNir9mHtZo5sq4QOcktL/gcg91KvZXTI1y8x roh8p+0nnaKt3Ei+U298Xkpof2DDor8wSnd/ifypd2juOz+q6EXTAIYp6IxDeCZ9Gvjs HROBDRyHhoCiv3LjU6C5dELnHNtD/AGvXbgG73Yx0svdCWHCKHhLO9pL2tZgrDi7UQFY nRtBeMHL6k2zCPI48/QlJWL4poGw1URBni0AjWib3JEcLtyrRM0S//XcyVBm6Mn//vEy TvtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=hGVK77kM; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu1si15603372edb.589.2020.04.18.10.28.08; Sat, 18 Apr 2020 10:28:31 -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=@broadcom.com header.s=google header.b=hGVK77kM; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbgDRR0E (ORCPT + 99 others); Sat, 18 Apr 2020 13:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgDRR0D (ORCPT ); Sat, 18 Apr 2020 13:26:03 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4A7C061A10 for ; Sat, 18 Apr 2020 10:26:03 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id y25so2748649pfn.5 for ; Sat, 18 Apr 2020 10:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=OMU4gc4xJrsz9oC2mAccr/thZgznAgM1yG5wcPECHkg=; b=hGVK77kM162LwI61a0prF7TRDY3sTb+b5wvtpmeTOvBZSjhXTZ4KtYe+4KIMRdV7i7 sATr30xlpwsSy5LoneFDQ5Lm4qNwy1XZPOpsYs7AdIdCkSILl9o/eKhblnMatJ/DQ099 6O0bWbR+0j5NV+t/XiLqUMrAO+Rybib+2O03c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=OMU4gc4xJrsz9oC2mAccr/thZgznAgM1yG5wcPECHkg=; b=SNMiaHl6H3t1Hwr+cFAqhJOV4Um0ka89bKFwq/Ornt9d79Boz5pOSdUtWn94+OF4H5 YEJC+VnG2o9UAGO5FzadjRzLLkUSTRzjRrD55/M4ZzGHmRi1reHhVbz5OZ4j0sU7HONt 9GDUivefHpVkL3orVLj9A0BJjLNERnC4He1noUPAyGHjnS+B9qm0VdJ79PoOSMu9xid+ gjPhRjkIImQa9OAlF41mHtbuWF75lECFo+/tP+fxNz70gQKZNZroegYIehX0ZZKKZdHb u46+rc09jfoOJPlAwUXmUfJpgZBJEHrScJpS5yaa9ynm7lWfzHK2PwKO71eCQaXpD3wZ u97Q== X-Gm-Message-State: AGi0PuYzKt32tGZqD+3B8yx+dN9gPOjjCUqhICUJngcFIQ2lPklHmbcO YDEuv8HjAjLrBdM3A8IYqy00MQ== X-Received: by 2002:a62:d086:: with SMTP id p128mr9463319pfg.241.1587230762967; Sat, 18 Apr 2020 10:26:02 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id u13sm9211650pjb.45.2020.04.18.10.25.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Apr 2020 10:26:02 -0700 (PDT) From: Scott Branden Subject: Re: [PATCH v2 6/7] misc: bcm-vk: add Broadcom VK driver To: Dan Carpenter Cc: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross , Desmond Yan , James Hu References: <20200220004825.23372-1-scott.branden@broadcom.com> <20200220004825.23372-7-scott.branden@broadcom.com> <20200220104321.GX7838@kadam> <63c9dcda-7a31-78a7-1d11-9d9af38add46@broadcom.com> <20200418114516.GE12862@kadam> <20200418114725.GF12862@kadam> Message-ID: Date: Sat, 18 Apr 2020 10:25:58 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200418114725.GF12862@kadam> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Dan, I'll send out new version as soon as my other patch (you had requested for test_fx mutex cleanups) https://lore.kernel.org/linux-arm-msm/20200415002517.4328-1-scott.branden@broadcom.com/ hits the linux-next tree so this patch series will apply cleanly to linux-next. On 2020-04-18 4:47 a.m., Dan Carpenter wrote: > On Sat, Apr 18, 2020 at 02:45:16PM +0300, Dan Carpenter wrote: >> On Fri, Apr 17, 2020 at 02:49:11PM -0700, Scott Branden wrote: >>>>> +static int bcm_vk_dma_alloc(struct device *dev, >>>>> + struct bcm_vk_dma *dma, >>>>> + int direction, >>>>> + struct _vk_data *vkdata) >>>>> +{ >>>>> + dma_addr_t addr, sg_addr; >>>>> + int err; >>>>> + int i; >>>>> + int offset; >>>>> + uint32_t size; >>>>> + uint32_t remaining_size; >>>>> + uint32_t transfer_size; >>>>> + uint64_t data; >>>>> + unsigned long first, last; >>>>> + struct _vk_data *sgdata; >>>>> + >>>>> + /* Get 64-bit user address */ >>>>> + data = get_unaligned(&(vkdata->address)); >>>> Extra parens. >>> removed >>>>> + >>>>> + /* offset into first page */ >>>>> + offset = offset_in_page(data); >>>>> + >>>>> + /* Calculate number of pages */ >>>>> + first = (data & PAGE_MASK) >> PAGE_SHIFT; >>>>> + last = ((data + vkdata->size - 1) & PAGE_MASK) >> PAGE_SHIFT; >>>>> + dma->nr_pages = last - first + 1; >>>>> + >>>>> + /* Allocate DMA pages */ >>>>> + dma->pages = kmalloc_array(dma->nr_pages, >>>>> + sizeof(struct page *), >>>>> + GFP_KERNEL); >>>>> + if (dma->pages == NULL) >>>>> + return -ENOMEM; >>>>> + >>>>> + dev_dbg(dev, "Alloc DMA Pages [0x%llx+0x%x => %d pages]\n", >>>>> + data, vkdata->size, dma->nr_pages); >>>>> + >>>>> + dma->direction = direction; >>>>> + >>>>> + /* Get user pages into memory */ >>>>> + err = get_user_pages_fast(data & PAGE_MASK, >>>>> + dma->nr_pages, >>>>> + direction == DMA_FROM_DEVICE, >>>>> + dma->pages); >>>>> + if (err != dma->nr_pages) { >>>>> + dma->nr_pages = (err >= 0) ? err : 0; >>>>> + dev_err(dev, "get_user_pages_fast, err=%d [%d]\n", >>>>> + err, dma->nr_pages); >>>>> + return err < 0 ? err : -EINVAL; >>>>> + } >>>>> + >>>>> + /* Max size of sg list is 1 per mapped page + fields at start */ >>>>> + dma->sglen = (dma->nr_pages * sizeof(*sgdata)) + >>>>> + (sizeof(uint32_t) * SGLIST_VKDATA_START); >>>>> + >>>>> + /* Allocate sglist */ >>>>> + dma->sglist = dma_alloc_coherent(dev, >>>>> + dma->sglen, >>>>> + &dma->handle, >>>>> + GFP_KERNEL); >>>> dma->sglist = dma_alloc_coherent(dev, dma->sglen, &dma->handle, >>>> GFP_KERNEL); >>> done >>>> >>>>> + if (!dma->sglist) >>>>> + return -ENOMEM; >>>> No cleanup? >>> what needs to be cleaned up? >> dma->pages should be freed probably? And a put_user_pages_fast()? > Sorry put_user_pages_fast() isn't a function. My bad. > > regards, > dan carpenter