Received: by 10.223.176.5 with SMTP id f5csp1260795wra; Sat, 27 Jan 2018 20:28:46 -0800 (PST) X-Google-Smtp-Source: AH8x226nRU/RtBjRHPGbRsGv9eM8Cvy97q3W1JZeY9eNfebxlUXV2yO/tful4M53dTsWlY1QRIbg X-Received: by 10.99.103.198 with SMTP id b189mr18391443pgc.20.1517113726597; Sat, 27 Jan 2018 20:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517113726; cv=none; d=google.com; s=arc-20160816; b=dItTGbs+UnSn5Vh+xZ6lgsXGCOqhYmtnCYtiKDEO9nA6UTHd99CCfx1+sAmwIUYVca zwGMnTItnY6cmq6H9CWdjJJl+OZoIm6N4Jlq6c2OotaPoYyD3UAsJIjbrZn7D7gFng5c 0BdIx1ISTpm4UjoBRHsKcbL+B+0Y2yXqN06EhEW5lc4Bue7H7hDmXwm+AaenMl9TZBed iLjOp9Ws36jvqcFopOvmVA6nC1qr6/1dMVimmd9lfd88i3g7Cac/skAK4Got/1dY5bcp 5wWvZ36mxKUuyZoEzlLbMtjya4sk35IMvigslggojc1aNlCHGQESY13Bjrb31pRptW+c CROw== 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:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=NvNoGWtlIYHFUBgd9GOcayVxRH5HjLpGDi1OfthQQAE=; b=ro9xIGzETTTflM1Ju0dx3+ctrErk3ujRmyKgNfAm4eFO5d6FV7uW9MxnJNjQoTYbYz xtzD/sjYNnc++uAF0s6hJomCpmaYcUn30wQOEy0Z9SdIAaNGHppEFhaK8crm2Y/4HeHR +g/2hAz3p+QNrLsGprT3hu6h1hwumAS8/m213BZKoyFLxZGMUA1BB/8upJzlH7hk2UQW 7/mGE68Y4IlZcemTQWUDNr6Wz5QWfqLGo+ixcRn8E2hjhzNi9q7qW22zBKMf/2r6Av05 7gmJWCsbul6Ws5iz0oN8vJaQKBpBNqVUr5hDbcygkg6Lyoxk7mJdxTuwn7RTluq95zz2 GkGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJFrngzq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si1784063ple.375.2018.01.27.20.28.32; Sat, 27 Jan 2018 20:28:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJFrngzq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753305AbeA1E1b (ORCPT + 99 others); Sat, 27 Jan 2018 23:27:31 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42910 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753266AbeA1E13 (ORCPT ); Sat, 27 Jan 2018 23:27:29 -0500 Received: by mail-pl0-f65.google.com with SMTP id 11so1360302plc.9; Sat, 27 Jan 2018 20:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=NvNoGWtlIYHFUBgd9GOcayVxRH5HjLpGDi1OfthQQAE=; b=TJFrngzqrWJRqMWcedxErSQ6TaRBWMOp6YEiR7qpzGgI71KuOO1Nsw7n4kugij6er/ rVETWr7Un9U8ntHf6+RVHGAWt8FcsEXjBYhDQVwRq0kdvHoDukIVQ1xAaCRQZ68Hr/TR nzjlPqQjSYzyN53pegxAylEkSXbhK8dCSyGFIKyrr2ksbAYNYR3EF13a3bTFZb27meqF xgHtFCae4irgn124FKFz/OoAHW9e0Oa2ZnEwXKnav9J77ngp/PsQBhuD6qXucCr5tMC6 1v7PB7kOTxrfrgIjwzUJeuV+M6kofb7OxLsFmdZkMnSp5zqj47Keg3dHMRYtFByvN6uf q6mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=NvNoGWtlIYHFUBgd9GOcayVxRH5HjLpGDi1OfthQQAE=; b=RCDewpWslHXLcLu+ITqwVZNK/EzZFVREU7iNrtVfi4DkLNdyDq0sRG7WtlITOElvHE iZ+pYQSTaeY+NBqCVQMqKgAA8zVWydoU16elgftmmNpwqrPq851Im6nYIpI1pBoIMTzF eD5c+iMrTGT50mMTvk1FEKiZ8L0fa2Q7IBZqxZSfbv8VRBsbwdpEoR2qI39iMxN4tFso DlW1k32WIYffF5jSrffltiwCRz8GSOnUyyfirLnWd7u815I3vx9mhFEeaC/x9Si4zT1Q HCFYbHIqjxFmU1hwC17WqyR18XDORI4i0dFSRzH5LiBfrffiLhud2pA33DrURnZolE6x 501A== X-Gm-Message-State: AKwxytdjRajsPCrySZzIs0ntOwhTuaVWWusgaVxKEm+C2VMF+PZV7ZDN CiK1AG71KanpBZAqUMXl/yA= X-Received: by 2002:a17:902:8487:: with SMTP id c7-v6mr8984655plo.7.1517113648563; Sat, 27 Jan 2018 20:27:28 -0800 (PST) Received: from [192.168.1.108] (c-73-67-222-53.hsd1.or.comcast.net. [73.67.222.53]) by smtp.gmail.com with ESMTPSA id s14sm7564151pfa.120.2018.01.27.20.27.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jan 2018 20:27:28 -0800 (PST) Subject: Re: [PATCH v1 1/2] platform/x86: intel_pmc_ipc: Use MFD framework to create dependent devices To: Andy Shevchenko , Kuppuswamy Sathyanarayanan Cc: Darren Hart , Andy Shevchenko , Zha Qipeng , "Krogerus, Heikki" , Linux Kernel Mailing List , Platform Driver , Andy Shevchenko References: From: sathya Message-ID: Date: Sat, 27 Jan 2018 20:27:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: 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 Hi Andy, Thanks for the review. On 01/26/2018 08:17 AM, Andy Shevchenko wrote: > On Fri, Jan 26, 2018 at 12:53 AM, > wrote: >> From: Kuppuswamy Sathyanarayanan >> >> Currently, we have lot of repetitive code in dependent device resource >> allocation and device creation handling code. This logic can be improved if >> we use MFD framework for dependent device creation. This patch adds this >> support. > Thanks for an update. My comments below. > >> Signed-off-by: Kuppuswamy Sathyanarayanan >> Signed-off-by: Andy Shevchenko > First of all, I barely remember what I did to this patch. Sorry, I know I took a long break. But its over now. I will be active in coming months. > In any case > this one is redundant since it will have mine when I push it to our > repo. > >> @@ -508,7 +492,7 @@ static int ipc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) >> ret = devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_pmc_ipc", >> pmc); >> if (ret) { >> - dev_err(&pdev->dev, "Failed to request irq\n"); >> + dev_err(&pdev->dev, "Failed to request IRQ\n"); Will split these renames into a separate patch. >> return ret; >> } > Split this kind of changes in a separate patch. > >> +static int ipc_create_punit_device(struct platform_device *pdev) >> { >> + static struct resource punit_res[PLAT_RESOURCE_MEM_MAX_INDEX]; >> + static struct mfd_cell punit_cell; >> + struct resource *res; >> + int ret, mindex, pindex = 0; >> + >> + for (mindex = 0; mindex <= PLAT_RESOURCE_MEM_MAX_INDEX; mindex++) { > '<=' ??? (Why = is here?) Good catch. It should be only <. I will fix it in next release. > >> + res = platform_get_resource(pdev, IORESOURCE_MEM, mindex); >> + >> + switch (mindex) { >> + /* Get PUNIT resources */ >> + case PLAT_RESOURCE_BIOS_DATA_INDEX: >> + case PLAT_RESOURCE_BIOS_IFACE_INDEX: >> + /* BIOS resources are required, so return error if not >> + * available >> + */ > It's not the network subsystem, please, do a proper style for > multi-line comments. Will fix it in next release. > >> + if (!res) { > Would the following work for you? > > if (res) > break; > dev_err(&pdev->dev, "Failed to get PUNIT MEM resource %d\n", pindex); > return -ENXIO; > case ...: > ... > if (res) > break; > default: > continue; > > memcpy(...); > ... If you move memcpy outside the switch statement, then it will be called for cases (non punit cases) like PLAT_RESOURCE_TELEM_SSRAM_INDEX or PLAT_RESOURCE_ACPI_IO_INDEX which is logically incorrect. > >> + dev_err(&pdev->dev, >> + "Failed to get PUNIT MEM resource %d\n", >> + pindex); >> + return -ENXIO; >> + } >> + case PLAT_RESOURCE_ISP_DATA_INDEX: >> + case PLAT_RESOURCE_ISP_IFACE_INDEX: >> + case PLAT_RESOURCE_GTD_DATA_INDEX: >> + case PLAT_RESOURCE_GTD_IFACE_INDEX: >> + /* if valid resource found, copy the resource to PUNIT >> + * resource >> + */ >> + if (res) >> + memcpy(&punit_res[pindex], res, sizeof(*res)); >> + punit_res[pindex].flags = IORESOURCE_MEM; >> + pindex++; >> + break; >> }; >> + } >> + ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, &punit_cell, >> + 1, NULL, 0, NULL); >> >> + dev_dbg(&pdev->dev, "Successfully created PUNIT device\n"); >> > Wrong. If ret is not 0 the message is misleading. > Just remove it. > > Same for the rest cases. I will remove it. > >> + return ret; >> } >> +static int ipc_create_wdt_device(struct platform_device *pdev) >> { >> + static struct resource wdt_ipc_res[2]; >> + static struct mfd_cell wdt_cell; >> struct resource *res; >> + int ret; >> >> + /* If we have ACPI based watchdog use that instead, othewise create >> + * a MFD cell for iTCO watchdog >> + */ > Style. Got it. I will be fixed in next version. > >> + if (acpi_has_watchdog()) >> + return 0; >> + ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, &wdt_cell, >> + 1, NULL, 0, NULL); >> + >> + dev_dbg(&pdev->dev, "Successfully created watchdog device\n"); >> + >> + return ret; > What Heikki meant is to fill cells by those helper functions and call > mfd_add_devices() only once. Ok. It will be fixed in next version. I could not find the actual BUG reported by Heikki. So I did not understand the reason behind his proposal. > > See lpc_ich.c as an example. > >> } >> +static int ipc_create_pmc_devices(struct platform_device *pdev) >> { >> int ret; >> >> + ret = ipc_create_punit_device(pdev); >> + if (ret < 0) >> + return ret; > Is it fatal? (Hint: it's quite likely not) Logically not. But this logic exist in originally driver. I did not want to change the behavior without knowing the full details. Let me know your opinion. > >> + ret = ipc_create_wdt_device(pdev); >> + if (ret < 0) >> + return ret; > Is it fatal? Same as above. > >> + ret = ipc_create_telemetry_device(pdev); >> + if (ret < 0) >> + return ret; > Is it fatal? Same as above. > >> + return 0; >> } >> + ret = devm_request_irq(&pdev->dev, ipcdev.irq, ioc, IRQF_NO_SUSPEND, >> + "intel_pmc_ipc", &ipcdev); >> + if (ret) { >> + dev_err(&pdev->dev, "Failed to request IRQ\n"); >> + return ret; >> } >> >> ret = sysfs_create_group(&pdev->dev.kobj, &intel_ipc_group); >> if (ret) { >> dev_err(&pdev->dev, "Failed to create sysfs group %d\n", >> ret); >> - goto err_sys; >> + devm_free_irq(&pdev->dev, ipcdev.irq, &ipcdev); > Why do you need this one? This was added by you in one of the previous submissions. I think you added it because we have a separate device remove function in this driver, and not explicitly freeing IRQ could mess up the resource cleanup order. > >> + return ret; >> } >> >> ipcdev.has_gcr_regs = true; >> >> return 0; >> } > And to the main question, what this is doing in PDx86 now? There > should be a patch to move it under drivers/mfd. Drivers like drivers/platform/chrome/cros_ec_dev.c already use MFD calls outside MFD framework. I am not sure what is the norm. If you agree with the move, I will submit a patch for it. > > In _any case_ I need an Ack from Lee. >