From patchwork Sun May 6 09:21:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10382687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B063260353 for ; Sun, 6 May 2018 09:22:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A585628969 for ; Sun, 6 May 2018 09:22:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99F0D28C63; Sun, 6 May 2018 09:22:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0778B28969 for ; Sun, 6 May 2018 09:22:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD64B6B000C; Sun, 6 May 2018 05:22:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B85066B0266; Sun, 6 May 2018 05:22:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4CF36B0269; Sun, 6 May 2018 05:22:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 6486E6B000C for ; Sun, 6 May 2018 05:22:05 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id j18-v6so15986954pgv.18 for ; Sun, 06 May 2018 02:22:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=p67K0feJquKLzEWe3b0GRe3NFztLGmXg7cKPd7ELhfk=; b=AC04xQ8/zyWreyvDO0VK1HOVesjupBVlydlsO+AWMDxMuzUAlliYsIymoD7c9Bw2FF BPFDsxCwYF/GeA/Xmx55o+gEL7TclqSH6SJuh+y3k1SiTbCt68MpX7P62362Ll/z/kBR S0I0BYlzMyFzTWV6nBLKS32m1cY82cEb6jXKibfIJAr6Q0cSHNMQToumguq3g7FlyIQf j9RsasQV/WEyCmDzou1NM4znkcCh1RcNWshL7GyehVyTHR8EenosKDtIWfZH8lnlPeyI QcGV47eKUlQLIfUvS5lacfvd6VmoSfP8r25lWRvL2QIrSiUZwy4fqpihCotkHojvMpnO U4NA== X-Gm-Message-State: ALQs6tBS3NkEJSa2+ENhBJ8CDDYhir7yuIF5cAeBHi9acue5lpQ8Ujb4 Rn/SPpRIWAeThFV9z3+Es/ELWNQ+KXBbM/FWrz4D3AadCdfhKSKM1Mgy0oD8l7sgZzgjtRCwKmG wgfeAKEaOIX3uyu7dz8dSTbxZKKAOdechtm4HER6ENcq38+KwK8cAnpKD51P7bDU= X-Received: by 2002:a63:66c2:: with SMTP id a185-v6mr16530683pgc.347.1525598524950; Sun, 06 May 2018 02:22:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpXKluJprCjPd/rZoicXs8AA0CKUBIW8KxrBsiJTa3pCIhqN2vmgCXwQc2am5cfN9d486U/ X-Received: by 2002:a63:66c2:: with SMTP id a185-v6mr16530649pgc.347.1525598523889; Sun, 06 May 2018 02:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525598523; cv=none; d=google.com; s=arc-20160816; b=FUz76neSD3z0UEaoWyNlIFEOi5Z3LFrmQ8tHs5zoyu4QYR04VIpp0lFpCKyuJochkK TGVDOoa1MSsYBax8AVOs7qe+Yk9kV3pymPeH0Ulh0VgJ9xbHZ4otrZpTnCzNybFXhw4P 4fTrhqVNg3Dqgz1vK7Fh8xApv82iZQ//4dM233g/GIlL2WjM1Vys1OKuWZsWCCazATqq ELJNdJWKnRvSjcAdMDjFVfbcfPpuXwdPsNMfgtBRAERb3YvtoIbRvK/MMpgdZVpIliqB L/lUikU47Xgi6FyBFYDQm31j7Imyc29ZuHOi3SPm797u2A70rLVo8Kk/BP7kKq0yaFb0 XldQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=p67K0feJquKLzEWe3b0GRe3NFztLGmXg7cKPd7ELhfk=; b=wb5gCwReqO41aqKXYmawMJrZ/TlipzARsqCbkADCqjVo+NYrM63xR6iFX9th5QHgxM Laprc2FrB+OYs83lM+UmmgC+JJNzp37DWNC8B4W0zGPcsFat45GJAUYhXvig0fo29hDh 6eCV1RQrxwJt2/zmiFf/IXZXHlEDlkpmIfyrE5LBnMr7j55s5rI0XRFOlj3pDaBfJ6xY qw9rTrJTEkHMOfp6tJohAzGGOqM1eX4USl9Pw/ckpe9iWKhdmIP/HmSGgLATwcxmQ4Au I2mR4OV0Sw4l4FZvVu/tdKV29udlwqULrFxFy17jNiyVXMWX/Ub3EdY0/kiFIX+tsLII 7QKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=XxvjxnVY; spf=softfail (google.com: domain of transitioning mchehab+samsung@kernel.org does not designate 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=mchehab+samsung@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a12-v6si16157695pgn.631.2018.05.06.02.22.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 06 May 2018 02:22:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning mchehab+samsung@kernel.org does not designate 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=XxvjxnVY; spf=softfail (google.com: domain of transitioning mchehab+samsung@kernel.org does not designate 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=mchehab+samsung@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=p67K0feJquKLzEWe3b0GRe3NFztLGmXg7cKPd7ELhfk=; b=XxvjxnVYlDvjgsTUaPhxatbiW LhGPqXjhoYeN4cMyFALUzv37KMQXNsKNqkVRoREQuBcGkVaMUGd4BlMbwCvPDdls2hdPXEIAIro+r wzQcYvASS26xdHC3DHrP73Jek/5k+3rVYuRbVNK8N4CbjuE54Ra7KNx/TJUkjHoiBeqCgI1IvxSJk FcT0CmkUirCRPd+6mEHK4SnUzXSJyTSVrQtOrbTD2fTpBm39XfkyJBYcAZkuTPH3MGXT041olmhJ/ Q55DKaOIVGIDvmpKvGw/SPGmDm6WZcXYz9dtDq0Den5HTqE55Rj4gDC6IcHxJzvbtLM1zDG1sGGJN 8PdV53g5A==; Received: from [177.159.250.117] (helo=vento.lan) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFFrb-0002vH-MS; Sun, 06 May 2018 09:21:52 +0000 Date: Sun, 6 May 2018 06:21:47 -0300 From: Mauro Carvalho Chehab To: Tomoki Sekiyama Cc: Linux Media Mailing List , Mauro Carvalho Chehab , Markus Elfring , Hans Verkuil , "Luis R. Rodriguez" , linux-mm@kvack.org Subject: Re: [PATCH 1/2] media: siano: don't use GFP_DMA Message-ID: <20180506062147.260be463@vento.lan> In-Reply-To: References: X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Em Sun, 6 May 2018 08:05:05 +0900 Tomoki Sekiyama escreveu: > 2018/5/6 1:09 Mauro Carvalho Chehab : > > > I can't think on a single reason why this driver would be using > > GFP_DMA. The typical usage is as an USB driver. Any DMA restrictions > > should be handled inside the HCI driver, if any. > > > > siano driver supports SDIO (implemented > in drivers/media/mmc/siano/smssdio.c) as well as USB. > It looks like using sdio_memcpy_toio() to DMA transfer. I think that's why > it is using GFP_DMA. Good point. I always forget about the mmc variant, as I don't have any hardware to test. The best seems to add a new parameter to sms core register function, allowing it to use extra gfp flags, and pass it only for the SDIO variant. Patch enclosed. Regards, Mauro [PATCH 1/2 v2] media: siano: use GFP_DMA only for smssdio Right now, the Siano's core uses GFP_DMA for both USB and SDIO variants of the driver. There's no reason to use it for USB. So, pass GFP_DMA as a parameter during sms core register. Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c index b5dcc6d1fe90..9ed7afa7b2ae 100644 --- a/drivers/media/common/siano/smscoreapi.c +++ b/drivers/media/common/siano/smscoreapi.c @@ -649,6 +649,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, */ int smscore_register_device(struct smsdevice_params_t *params, struct smscore_device_t **coredev, + gfp_t gfp_buf_flags, void *mdev) { struct smscore_device_t *dev; @@ -661,6 +662,7 @@ int smscore_register_device(struct smsdevice_params_t *params, #ifdef CONFIG_MEDIA_CONTROLLER_DVB dev->media_dev = mdev; #endif + dev->gfp_buf_flags = gfp_buf_flags; /* init list entry so it could be safe in smscore_unregister_device */ INIT_LIST_HEAD(&dev->entry); @@ -697,7 +699,7 @@ int smscore_register_device(struct smsdevice_params_t *params, buffer = dma_alloc_coherent(params->device, dev->common_buffer_size, &dev->common_buffer_phys, - GFP_KERNEL | GFP_DMA); + GFP_KERNEL | dev->gfp_buf_flags); if (!buffer) { smscore_unregister_device(dev); return -ENOMEM; @@ -792,7 +794,7 @@ static int smscore_init_ir(struct smscore_device_t *coredev) else { buffer = kmalloc(sizeof(struct sms_msg_data2) + SMS_DMA_ALIGNMENT, - GFP_KERNEL | GFP_DMA); + GFP_KERNEL | coredev->gfp_buf_flags); if (buffer) { struct sms_msg_data2 *msg = (struct sms_msg_data2 *) @@ -933,7 +935,7 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, } /* PAGE_SIZE buffer shall be enough and dma aligned */ - msg = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA); + msg = kmalloc(PAGE_SIZE, GFP_KERNEL | coredev->gfp_buf_flags); if (!msg) return -ENOMEM; @@ -1168,7 +1170,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, } pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename, fw->size); fw_buf = kmalloc(ALIGN(fw->size + sizeof(struct sms_firmware), - SMS_ALLOC_ALIGNMENT), GFP_KERNEL | GFP_DMA); + SMS_ALLOC_ALIGNMENT), GFP_KERNEL | coredev->gfp_buf_flags); if (!fw_buf) { pr_err("failed to allocate firmware buffer\n"); rc = -ENOMEM; @@ -1260,7 +1262,7 @@ EXPORT_SYMBOL_GPL(smscore_unregister_device); static int smscore_detect_mode(struct smscore_device_t *coredev) { void *buffer = kmalloc(sizeof(struct sms_msg_hdr) + SMS_DMA_ALIGNMENT, - GFP_KERNEL | GFP_DMA); + GFP_KERNEL | coredev->gfp_buf_flags); struct sms_msg_hdr *msg = (struct sms_msg_hdr *) SMS_ALIGN_ADDRESS(buffer); int rc; @@ -1309,7 +1311,7 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode) int rc = 0; buffer = kmalloc(sizeof(struct sms_msg_data) + - SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); + SMS_DMA_ALIGNMENT, GFP_KERNEL | coredev->gfp_buf_flags); if (!buffer) return -ENOMEM; @@ -1398,7 +1400,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode) coredev->device_flags &= ~SMS_DEVICE_NOT_READY; buffer = kmalloc(sizeof(struct sms_msg_data) + - SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); + SMS_DMA_ALIGNMENT, GFP_KERNEL | coredev->gfp_buf_flags); if (buffer) { struct sms_msg_data *msg = (struct sms_msg_data *) SMS_ALIGN_ADDRESS(buffer); @@ -1971,7 +1973,7 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 pin_num, total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6); buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT, - GFP_KERNEL | GFP_DMA); + GFP_KERNEL | coredev->gfp_buf_flags); if (!buffer) return -ENOMEM; @@ -2043,7 +2045,7 @@ int smscore_gpio_set_level(struct smscore_device_t *coredev, u8 pin_num, (3 * sizeof(u32)); /* keep it 3 ! */ buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT, - GFP_KERNEL | GFP_DMA); + GFP_KERNEL | coredev->gfp_buf_flags); if (!buffer) return -ENOMEM; @@ -2091,7 +2093,7 @@ int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 pin_num, total_len = sizeof(struct sms_msg_hdr) + (2 * sizeof(u32)); buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT, - GFP_KERNEL | GFP_DMA); + GFP_KERNEL | coredev->gfp_buf_flags); if (!buffer) return -ENOMEM; diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h index 134c69f7ea7b..eb58853008c9 100644 --- a/drivers/media/common/siano/smscoreapi.h +++ b/drivers/media/common/siano/smscoreapi.h @@ -190,6 +190,8 @@ struct smscore_device_t { int mode, modes_supported; + gfp_t gfp_buf_flags; + /* host <--> device messages */ struct completion version_ex_done, data_download_done, trigger_done; struct completion data_validity_done, device_ready_done; @@ -1125,6 +1127,7 @@ extern void smscore_unregister_hotplug(hotplug_t hotplug); extern int smscore_register_device(struct smsdevice_params_t *params, struct smscore_device_t **coredev, + gfp_t gfp_buf_flags, void *mdev); extern void smscore_unregister_device(struct smscore_device_t *coredev); diff --git a/drivers/media/mmc/siano/smssdio.c b/drivers/media/mmc/siano/smssdio.c index fee2d710bbf8..b9e40d4ca0e8 100644 --- a/drivers/media/mmc/siano/smssdio.c +++ b/drivers/media/mmc/siano/smssdio.c @@ -279,7 +279,7 @@ static int smssdio_probe(struct sdio_func *func, goto free; } - ret = smscore_register_device(¶ms, &smsdev->coredev, NULL); + ret = smscore_register_device(¶ms, &smsdev->coredev, GFP_DMA, NULL); if (ret < 0) goto free; diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c index 6d436e9e454f..be3634407f1f 100644 --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -455,7 +455,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) mdev = siano_media_device_register(dev, board_id); /* register in smscore */ - rc = smscore_register_device(¶ms, &dev->coredev, mdev); + rc = smscore_register_device(¶ms, &dev->coredev, 0, mdev); if (rc < 0) { pr_err("smscore_register_device(...) failed, rc %d\n", rc); smsusb_term_device(intf);