From patchwork Wed Jan 3 17:09:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10142657 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 370146034B for ; Wed, 3 Jan 2018 17:10:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8B628B78 for ; Wed, 3 Jan 2018 17:10:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC98291CC; Wed, 3 Jan 2018 17:10:03 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A72D29160 for ; Wed, 3 Jan 2018 17:10:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751021AbeACRKB (ORCPT ); Wed, 3 Jan 2018 12:10:01 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35006 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbeACRKA (ORCPT ); Wed, 3 Jan 2018 12:10:00 -0500 Received: by mail-lf0-f65.google.com with SMTP id h5so2369959lfj.2 for ; Wed, 03 Jan 2018 09:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:user-agent:date:to:cc:subject:mime-version :content-disposition; bh=LdHRCBodASLAKfysq3HBr13opeI5nBP7XsZasLZIumQ=; b=zoE9NFuOVBw/OxZ5NJqDqRLbvzhRY6sBSK22MGlLLyHRqfVWCz5j+SidOCH8T0eYZi EMMOlqwzNVaKG70E1oyFZx/U3OG0E6zz2sorO5jhcO1EyLSlsGJI5MWA2KOeIAHjbL4B Idc91CYNzK3OksCKS8d2D8VjJ/jDBXPrhUT/qJWk3HmnHRY7zpENi+VRxzipNbGmhG4A 19hgh3RJeCqDZeS6DAFoGdw2/dzmKGLmAC0/eLhKZKmcuXwzLpHTgrxOkcOYqdbjVXJ3 zZoNnmfm2vrS9fMUMbahAzPx3dcSU+NNWU06WrN5GOC15LHU67XzQkS5SAZ168ZeTvN9 FZGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:user-agent:date:to:cc:subject :mime-version:content-disposition; bh=LdHRCBodASLAKfysq3HBr13opeI5nBP7XsZasLZIumQ=; b=iAgfnRQO+CqP6oum6th5plFd2bDrr3hsntcyDh0X6w2Zhb3K3rkdW4K2SKIg9quaF4 qfLiKrxpqTMzV3IMgl+ut1W50XAzqb8tFDq71GakIWY8jINSNS4GRmwmuG8dmN8l7PoK MsF8x87jimnrGVV1IM7iAVOC8SE2gIa2isq3JGK6FtWbpEsrT40Jv9Gb61ApZzMvtFIx Hjn+qgkLiq2GW6JZWBxLO5r4bMcaHnS7jNOlfPOGriqg++SKHH63d9965R/KPfk9+hu8 mXOS3t+wRbSkBOBq4uqClS4Xf2tVIk8/8lV8AR3x5mmEBVjpQUXpFQyxsz4eB6ZIDvWl P/YA== X-Gm-Message-State: AKGB3mK09lileaMBVj+dCvvqXATez3MJbG7+o6dL8CYZxKOL11xYJY/U 9bTmQ4Ra2KKl7qvV6e5r5nIutw== X-Google-Smtp-Source: ACJfBosgB4v6aF29OymPTDksEp3v9Ern/dEStPRej746+DPW95cz8BsYVfB8FmecEZYt3E1Ni845fg== X-Received: by 10.46.23.156 with SMTP id 28mr1327293ljx.3.1514999398808; Wed, 03 Jan 2018 09:09:58 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.87.30]) by smtp.gmail.com with ESMTPSA id 19sm258445ljf.0.2018.01.03.09.09.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 09:09:57 -0800 (PST) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Wed, 03 Jan 2018 20:09:55 +0300 Message-Id: <20180103170955.343662722@cogentembedded.com> User-Agent: quilt/0.64 Date: Wed, 03 Jan 2018 20:09:49 +0300 To: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: linux-sh@vger.kernel.org, Nobuhiro Iwamatsu , Sergei Shtylyov Subject: [PATCH] sh_eth: fix TSU resource handling MIME-Version: 1.0 Content-Disposition: inline; filename=sh_eth-fix-TSU-resource-handling.patch Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When switching the driver to the managed device API, I managed to break the case of a dual Ether devices sharing a single TSU: the 2nd Ether port wouldn't probe. Iwamatsu-san has tried to fix this but his patch was buggy and he then dropped the ball... The solution is to limit calling devm_request_mem_region() to the first of the two ports sharing the same TSU, so devm_ioremap_resource() can't be used anymore for the TSU resource... Fixes: d5e07e69218f ("sh_eth: use managed device API") Reported-by: Nobuhiro Iwamatsu Signed-off-by: Sergei Shtylyov --- The patch is against Dave Miller's 'net.git' repo. drivers/net/ethernet/renesas/sh_eth.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net/drivers/net/ethernet/renesas/sh_eth.c @@ -3225,10 +3225,29 @@ static int sh_eth_drv_probe(struct platf /* ioremap the TSU registers */ if (mdp->cd->tsu) { struct resource *rtsu; + rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); - mdp->tsu_addr = devm_ioremap_resource(&pdev->dev, rtsu); - if (IS_ERR(mdp->tsu_addr)) { - ret = PTR_ERR(mdp->tsu_addr); + if (!rtsu) { + dev_err(&pdev->dev, "no TSU resource\n"); + ret = -ENODEV; + goto out_release; + } + /* We can only request the TSU region for the first port + * of the two sharing this TSU for the probe to succeed... + */ + if (devno % 2 == 0 && + !devm_request_mem_region(&pdev->dev, rtsu->start, + resource_size(rtsu), + dev_name(&pdev->dev))) { + dev_err(&pdev->dev, "can't request TSU resource.\n"); + ret = -EBUSY; + goto out_release; + } + mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start, + resource_size(rtsu)); + if (!mdp->tsu_addr) { + dev_err(&pdev->dev, "TSU region ioremap() failed.\n"); + ret = -ENOMEM; goto out_release; } mdp->port = devno % 2;