Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2635195iog; Mon, 20 Jun 2022 01:04:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sTiOeIHM1p2BWeYUt32oN3ZRVVb2sVC7hqCVxD8jWwbhl22l4w2rPqApXpBP/z+H7l19/X X-Received: by 2002:a05:6a00:844:b0:525:1785:e26f with SMTP id q4-20020a056a00084400b005251785e26fmr8432347pfk.86.1655712263212; Mon, 20 Jun 2022 01:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655712263; cv=none; d=google.com; s=arc-20160816; b=p/cOaMG1zM30RPs3xC9aD8gZx9vl9xsuE4Kv72j9e5TRJLJJyR7SRDIYhLTV4Hbo40 AtDzIZvYk+ePgQ7hSD8EzwvmQsDT88kUV9G9owsvOJnkIzriHQDGIIkfLsOWxt9PxKNt V0YfeKCPAOTZeSrSkSfYDISC1vFmUoLCgNE8xQu/2wkiFfQlRiv9/sVEyxqArMFRTQpV mM/js00GLBINRzTC1A0UMUUYnrfLCRPbOTRsG+dhgBx9iro3DXULd7frnu0f79fcAkVk crh63q+OImhYM6DmAU0wGLuBsjppm0VHL/xs9/r8dfL6jdnR2tgu0tInLYAIYgcXIBBz KeXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=8xywew65kj7gzsq9s6N94BTPpY1MSy/LFNVfweYeHsM=; b=mj1qLWtILgEPrKIf1csyiCHgW8onrV75NT7Vl8/fe3kW/znQUcLDsexuFaRy+dZIFQ 1Bvf6LP1/+/VIV0waaXfRMI5RU8X6x+DcON0c5EZqDClxiXVkVa7NmnJxWcyFoHMe2FF CBEnxvKBT50ikSVjuNIh0UwKDxMgIFXU1H1vr6hKTsRjP+irRTO7b4XS8BGsFT0/0XcA BCIh2J/yt7XEg0ZFmSs3GXMAlq5w4s5NDpZ4x6g1hUcSoNnzgYo5WecoA+uayVbbvgrN W9iKSqAODa6EI8sANiI9vFbCBwhI0DhkVMQrnVbX4wYT/aiXTGMw6CFo5XrUjYFJ6LPv fMIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a636e07000000b003ff3d0bc82asi16145270pgc.325.2022.06.20.01.04.10; Mon, 20 Jun 2022 01:04:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239545AbiFTHua convert rfc822-to-8bit (ORCPT + 99 others); Mon, 20 Jun 2022 03:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239548AbiFTHu2 (ORCPT ); Mon, 20 Jun 2022 03:50:28 -0400 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00171101E9 for ; Mon, 20 Jun 2022 00:50:27 -0700 (PDT) Received: by mail-qk1-f181.google.com with SMTP id x75so7263668qkb.12 for ; Mon, 20 Jun 2022 00:50:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=EtV5ELewzqfb5WlPCrybWjJM2V9SXL9Txpvpslzl7xY=; b=NX6TVgmEQ3QBdVHQXE3swAz86vUWVUBdY4+Ju+Jeyq8d0ppU0uK3Pk1XyIz6Uj/40o xMFyC6oo5UzLs1RnrYwx8nN7fkpnMpYYkHR8iDtmq5TCT6LfSPKyWV8jvuJ7zrU9khXS EKB9l3f7eN+YkrrLhQn2q+KNQQIl1scWu8XBBytAmsBgWj4R/NZXKNB69gBhVpnzPhkL KdgyngSH5i0SM8bKiFp+vxh9qVPPUkvhzCZmIqP/aitWKwl8hqH3xALrHRFZuc2VziZH GW9m1zNO+hUL0lxG5K9rGTrSijjMqGrv2KKpK2kv/0v9T0KoEq7f6Wp6prVup3X5mySc evHA== X-Gm-Message-State: AJIora8NFI1JTuEs+vQ2yPOfGsRZJTWZbl06853XjrJyxMVatcHyCaP6 r1CFcIYj/HMV6/RDh1HXtcpQZwdssqprYA== X-Received: by 2002:a37:aa55:0:b0:6a6:b1e2:4af1 with SMTP id t82-20020a37aa55000000b006a6b1e24af1mr15594354qke.324.1655711426698; Mon, 20 Jun 2022 00:50:26 -0700 (PDT) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id w10-20020a05620a424a00b006a79d8c8198sm11272894qko.135.2022.06.20.00.50.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Jun 2022 00:50:25 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id l66so16077189ybl.10 for ; Mon, 20 Jun 2022 00:50:25 -0700 (PDT) X-Received: by 2002:a05:6902:905:b0:64a:2089:f487 with SMTP id bu5-20020a056902090500b0064a2089f487mr24122408ybb.202.1655711425255; Mon, 20 Jun 2022 00:50:25 -0700 (PDT) MIME-Version: 1.0 References: <20220619111115.6354-1-nikita.shubin@maquefel.me> <20220619111115.6354-2-nikita.shubin@maquefel.me> In-Reply-To: <20220619111115.6354-2-nikita.shubin@maquefel.me> From: Geert Uytterhoeven Date: Mon, 20 Jun 2022 09:50:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/1] RISC-V: Create unique identification for SoC PMU To: Nikita Shubin Cc: Atish Patra , Will Deacon , Sunil V L , =?UTF-8?B?Sm/Do28gTcOhcmlvIERvbWluZ29z?= , linux@yadro.com, Nikita Shubin , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Mark Rutland , linux-riscv , Linux Kernel Mailing List , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nikita, On Sun, Jun 19, 2022 at 1:11 PM Nikita Shubin wrote: > From: Nikita Shubin > > Provide RISC-V SBI PMU id to distinguish different cores or SoCs via > "devices/platform/riscv-pmu/id" sysfs entry. > > The identification is generated as string of marchid, mimpid, mvendorid > in hex format separated by coma - "0x70032,0x70032,0x0". > > The CSRs are detailed in the RISC-V privileged spec [1]. > [1] https://github.com/riscv/riscv-isa-manual > > Inspired-by: João Mário Domingos > Signed-off-by: Nikita Shubin Thanks for your patch! > --- a/arch/riscv/kernel/sbi.c > +++ b/arch/riscv/kernel/sbi.c > --- a/drivers/perf/riscv_pmu_sbi.c > +++ b/drivers/perf/riscv_pmu_sbi.c > @@ -693,6 +693,28 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde > return 0; > } > > +static ssize_t id_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + int len; > + struct riscv_pmu *pmu = container_of(dev_get_drvdata(dev), struct riscv_pmu, pmu); > + > + len = sprintf(buf, "%s\n", pmu->pmuid); > + if (len <= 0) > + dev_err(dev, "invalid sprintf len: %d\n", len); How can this fail? Please use sysfs_emit() instead of sprintf(), and drop the error message. > + > + return len; > +} Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds