Received: by 10.223.185.116 with SMTP id b49csp4345212wrg; Tue, 6 Mar 2018 14:09:19 -0800 (PST) X-Google-Smtp-Source: AG47ELttSbCS5YffnHiSVhvfi4FwFCx/xRha9lErpQwjAOc3vwhbu8mEtVGEdk6BG6l3UkSd8+iI X-Received: by 10.101.76.134 with SMTP id m6mr16712569pgt.445.1520374159515; Tue, 06 Mar 2018 14:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520374159; cv=none; d=google.com; s=arc-20160816; b=BoM37niysUSWi+dx/FA2HRz66LSlGWj1uJ9FWye+Ri3LKjPpgAy07pWgMK8j+4fxD8 gl0kMlZRG6/2Bj6uLuwQn/Q7/L94VFTuPrrJ8/32G0YKNU5P0tkJ8D1JtIueopZx873k IUWaR+qrb6e3p8O8IstYF2ZGKk9gOB05qseIpowNjnvo6z72wN/HEMS6k4n3mtG57AJl 2RiGDPndp4B3CY9tCIHxvRpFVzqo3cAGo8bo3dZLtHqDTkzTeKaFlfiikHX4MOVB3CFi qD0iHTvH3UBGHNtXcu/sY1hD7/hzzqG5pTeWQ7m8I/IRtEXOLyQxY380nuiU4O9EAy9v H6uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dmarc-filter:arc-authentication-results; bh=WC0r61mUIe9iNXyoFw8wDAbnntWzBgtDl/hHU9cK7G8=; b=iJCbr9irs2swF80aFpP4MkWsYdFZymIMzEkSJHr8haBH3vmu/EIVthlCcidVFTXb2H nK5945WCyYQDn2kQHWWTXhk2HIn11HGnmdHBiUHQc840IOp892PuQjlIu3PGGYgWNpw6 2nv6Dj4x3a9jjhkmX97bz1+YtB/RiWLMKMGyqGGApR4Oxdv4+7YM67ZMjYqVRZAaNpUk T7IcPdHRkpKSVyB3xwpyCSfyWfs3b0BK37zpnISk/9WG54+JcAgF/9Xv40ZArYAZDo/I h36EX28kC5k1BIpCTXQUfbLyw8ubgrMyzMBMDs5NS901g6M1dwqRkpwDtaq+wqpd+0am FrvA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1-v6si5426238plt.54.2018.03.06.14.09.04; Tue, 06 Mar 2018 14:09:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932983AbeCFWIJ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 6 Mar 2018 17:08:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:36086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753805AbeCFWIH (ORCPT ); Tue, 6 Mar 2018 17:08:07 -0500 Received: from localhost (unknown [104.132.1.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08D32206B2; Tue, 6 Mar 2018 22:08:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08D32206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sboyd@kernel.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Lina Iyer From: Stephen Boyd In-Reply-To: <20180306162140.GC4930@codeaurora.org> Cc: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, Mahesh Sivasubramanian References: <20180226175802.20052-1-ilina@codeaurora.org> <20180226175802.20052-2-ilina@codeaurora.org> <152027534725.108663.13213325833387672227@swboyd.mtv.corp.google.com> <20180306162140.GC4930@codeaurora.org> Message-ID: <152037408636.218381.16707810584982252283@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v4 1/2] drivers: qcom: add command DB driver Date: Tue, 06 Mar 2018 14:08:06 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lina Iyer (2018-03-06 08:21:40) > On Mon, Mar 05 2018 at 11:42 -0700, Stephen Boyd wrote: > >Quoting Lina Iyer (2018-02-26 09:58:01) > > >> +} > >> +EXPORT_SYMBOL(cmd_db_ready); > >> + > >> +static u64 cmd_db_get_u64_id(const char *id) > >> +{ > >> + u64 rsc_id = 0; > >> + u8 *ch = (u8 *)&rsc_id; > >> + int i; > >> + > >> + for (i = 0; i < sizeof(rsc_id) && id[i]; i++) > >> + ch[i] = id[i]; > > > >This could be a strncpy now? Didn't I already ask this? I'll have to > >look back at the other emails it seems. Actually, it looks like a cast > >of a string to an integer, > Yes, you did ask. The cast helps do an integer comparison as opposed to > string comparision on the database. > > >which is then reversed to look up the same > >string. Not sure what the use is for this. > > > Where do you see that? Hmm no idea. I must have seen something wrong. Ignore this one. > > >> + > >> + return rsc_id; > >> +} > >> + > >> +static int cmd_db_get_header(u64 query, struct entry_header *eh, > >> + struct rsc_hdr *rh) > >> +{ > >> + struct rsc_hdr *rsc_hdr; > >> + struct entry_header *ent; > >> + int ret, i, j; > >> + > >> + ret = cmd_db_ready(); > >> + if (ret) > >> + return ret; > >> + > >> + if (!eh || !rh) > >> + return -EINVAL; > >> + > >> + for (i = 0; i < MAX_SLV_ID; i++) { > >> + rsc_hdr = &cmd_db_header->header[i]; > >> + if (!rsc_hdr->slv_id) > >> + break; > >> + > >> + ent = ENTRY_HEADER(rsc_hdr); > >> + for (j = 0; j < rsc_hdr->cnt; j++, ent++) { > >> + if (ent->id == query) > >> + break; > >> + } > >> + > >> + if (j < rsc_hdr->cnt) { > >> + memcpy(eh, ent, sizeof(*ent)); > >> + memcpy(rh, rsc_hdr, sizeof(*rh)); > > > >I suppose it's OK to punt on the endian issues for now if it's too hard. > >Eventually we'll want to handle it though and it shouldn't make the code > >any worse when endianness is the same. Can it be done now? > > > Why is the change in endian needed? We can always add that in later if > we decide to change the default endian. I would prefer that we punt it > for now. Ok! > > >> + ret = PTR_ERR(start_addr); > >> + goto done; > >> + } > >> + > >> + cmd_db_header = start_addr; > >> + if (cmd_db_header->magic_num != CMD_DB_MAGIC) { > > > >memcmp? > > > Why? It could be a simple comparison. Endian stuff again > > >> + ret = -EINVAL; > >> + dev_err(&pdev->dev, "Invalid Command DB Magic\n"); > >> + goto done; > >> + } > >> + > >> +done: > >> + devm_memunmap(&pdev->dev, dict); > > > >I'm lost why we use devm_*() for this mapping. > > > Must have picked it up from an example. Curious, why not though? devm is usually used for long lived things that need to be released on driver removal. At least that's the way I view it. For short lived things that are created and then freed in the same scope I usually avoid devm.