From patchwork Mon Aug 10 07:37:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duc Dang X-Patchwork-Id: 6980321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1E1DC05AC for ; Mon, 10 Aug 2015 07:41:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1973D20763 for ; Mon, 10 Aug 2015 07:41:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3640E20738 for ; Mon, 10 Aug 2015 07:41:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOhew-0004de-V7; Mon, 10 Aug 2015 07:38:14 +0000 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOhet-0004Ze-Pz for linux-arm-kernel@lists.infradead.org; Mon, 10 Aug 2015 07:38:12 +0000 Received: by pdco4 with SMTP id o4so68577986pdc.3 for ; Mon, 10 Aug 2015 00:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2DTCmHsz5IGRZC/SDJGr33gaZn/t3aDsZK/9NY99rMU=; b=RcV8sJ/qwJ717K4R7IvSCqiJ68K+dS5Y7hJqxb08uos+dbYpxg4U32vlvK+BgvdSqr T+Az8dqWM/2e5XHNetR8FTcsFHWJFjjJkrs5wTFClXgju/p6cYmb9xni2TEmCHJvidH7 WRrBnrgIp0f9LKOi22FDpSdiRkrDb7LFkHjJc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2DTCmHsz5IGRZC/SDJGr33gaZn/t3aDsZK/9NY99rMU=; b=kSXHTKEL9ePU996MwmckV8mnTzFi/hfi7xtT2Qn49T3msKGfG1249efCezEC/fqW73 Fax3UOyGkxMOWtcBRqP29SD0hipg71wQzHRoYE5XL+5KXPXXm9OUondeMzcY5giohE9E yeykOinpeZy8EcMDq56wVIu+XkM2a1c3oXjDTIQI2BlOzz8lJaiFuRJcM4LUqE0qyQLG PgsKd7TmSUy2GgupQ0kAGxTNmxnQKRrO5gFuuQSXHCCmJvRrPhB0TkwDW4d4KDHlH6XD ZIh2Sp1dUo5Pv1lKjvswSv5UQY3UZ0B5NtfgIlMIJxsSnS94bCG4at68d1siaKXFnS0t RxAA== X-Gm-Message-State: ALoCoQmwa6bnvDqJE6pMJ59uSNATxMN928RqLSkQbN2HjCZz9XfSb0dfs3Lmz1bfxcwh8UPfVWiu X-Received: by 10.70.119.66 with SMTP id ks2mr9957885pdb.11.1439192269920; Mon, 10 Aug 2015 00:37:49 -0700 (PDT) Received: from dhdang-Precision-WorkStation-T3400.amcc.com (70-35-53-82.static.wiline.com. [70.35.53.82]) by smtp.gmail.com with ESMTPSA id pu4sm18769089pdb.86.2015.08.10.00.37.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Aug 2015 00:37:49 -0700 (PDT) From: Duc Dang To: Greg KH , Russell King - ARM Linux , Loc Ho Subject: [PATCH v6 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA Date: Mon, 10 Aug 2015 00:37:21 -0700 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: <20150808092252.GJ7557@n2100.arm.linux.org.uk> References: <20150808092252.GJ7557@n2100.arm.linux.org.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150810_003811_894413_5A75B968 X-CRM114-Status: GOOD ( 15.01 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Feng Kan , Mark Langsdorf , Arnd Bergmann , mathias.nyman@intel.com, Duc Dang , USB list , patches , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The xhci platform driver needs to work on systems that either only support 64-bit DMA or only support 32-bit DMA. Attempt to set a coherent dma mask for 64-bit DMA, and attempt again with 32-bit DMA if that fails. [dhdang: regenerate the patch over 4.2-rc5 and address new comments] Signed-off-by: Mark Langsdorf Tested-by: Mark Salter Signed-off-by: Duc Dang --- Changes from v5: -Change comment -Assign dma_mask to coherent_dma_mask if dma_mask is NULL to make sure dma_set_mask_and_coherent does not fail prematurely. Changes from v4: -None Changes from v3: -Re-generate the patch over 4.2-rc5 -No code change. Changes from v2: -None Changes from v1: -Consolidated to use dma_set_mask_and_coherent -Got rid of the check against sizeof(dma_addr_t) drivers/usb/host/xhci-plat.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 890ad9d..5d1b84b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -93,14 +93,18 @@ static int xhci_plat_probe(struct platform_device *pdev) if (irq < 0) return -ENODEV; - /* Initialize dma_mask and coherent_dma_mask to 32-bits */ - ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; + /* + * Try setting dma_mask and coherent_dma_mask to 64 bits, + * then try 32 bits + */ if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - else - dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + if (ret) { + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + if (ret) + return ret; + } hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd)