Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3203795lqp; Tue, 26 Mar 2024 02:38:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBiLOnJLzb+VbbRLTzlU0YznlU74sFoMX9cXEVe64DWRIHrgBIwocTN3iVcNp8wSdq/TLT4o8+CVmL+kaBx+8+bCFDshH8DKJ9CnP2Ug== X-Google-Smtp-Source: AGHT+IGzfHqF9S4uf4RVRhaZjSWkOumf8INkhm5V4tPN2WetvALgVsa3QDVyi/EB6hZcJwD3EtMb X-Received: by 2002:a05:620a:3b98:b0:78a:1891:806e with SMTP id ye24-20020a05620a3b9800b0078a1891806emr10372820qkn.21.1711445918035; Tue, 26 Mar 2024 02:38:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711445918; cv=pass; d=google.com; s=arc-20160816; b=u+WsSKZbpvoKGPE1H7Vk5t+mhdYBgGXPxWY2EkqBW3vLvLaJ7kBnSFnV2wULocQ9jA /aoDjFbF20X5xfgLAbTn+Fsf27cS3NyYWyZJ/YSq94joT6RI4Cl/gCww3snDx45HTk58 Vz+mEf8m0ERZcDnon6MsGLwdQ05O0NBUgsigUzDRNeFNm0jCPwsHngsnw5BbFSTGXQPR RXyuRlIp9/YnrjozRlXd4UoMqaEkMtTSHdxDMybP/8wl0/TPIJnaXwCZKSJsL3S3mANo 6obuVxCpcNmmcOMGEuFG4jglsWsUfuiTyFktQghiDEwvQ14xEaOJLlDsE0W82V2xz6J0 qIjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=BMhFHhRNIcpJJMFIKlSsNwlVmtmxYOcIFrOt1gt3EN8=; fh=5bCgRfo2ePVF7bHIicRyZ59Po8KAbJYUYPJ+bAotoy8=; b=DH5Gl+BybVMPtXguAK9E1s1IwFHI2tJ8/35mVb36TRFVHEVVHSo1BvuOxiD7aTyGU8 kcxrbFCipR1+iLKLdXrJhi64oOIu5B2GLaxw3YtQz0UupnopFkZJ3m8HLgYXTx+swLcG WJSYdFIPnFPCOfmzTuDnFm6XMFERmuTqvPRjaGf3+hJWh3cQ93FyaZKs9TqCvCYTaFcq Wrw6ujggtuCNyFTI39bfvg7eT1azqe0G+sv3vO8fDqVfcpgIrNlpyoiHdKOjD8gVBqMN FmWFCo8d3iK+5iSheQmagU3GJznexQ+T1g8tThQRi0GOECbdAjO18LTQ+a5I0Q+5S00X pzSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=PULiK7P7; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-118684-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i5-20020a37c205000000b00789ddf7c5d5si6970957qkm.38.2024.03.26.02.38.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 02:38:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118684-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=PULiK7P7; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-118684-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A7DDD1C399D0 for ; Tue, 26 Mar 2024 09:38:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B114174405; Tue, 26 Mar 2024 09:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="PULiK7P7" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3AF974414; Tue, 26 Mar 2024 09:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711445182; cv=none; b=PVLzR+ncaze8vkxwoq8NMgss1dOdMUO8VRnYoZ6oiV3RQgxzQRE+0rkzLEfS8uicWSS4mReNTIsOU8ZR6i1HXEhhX/yij7vDKRm5BOLD4wFi4RUVMOerUeYKhfkxt7CbRoigYiA3OrBPEmnHSMI0uGyLXAP8nWY729PtrzqSfzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711445182; c=relaxed/simple; bh=BIWWw8INVgFbVYlCNSVCSXKr5nfSD3WYB4BQMSkbYDE=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=L/RNufQctWKDKmDItCspaTZOx+VPd8kmmGLl+3GBbi/NsdZLmQdiOiozEehWxkDDEV4vuFRScZETi7WbHxxrmsb76PrdsaxkCFLCLRk04kzjnggYG2dtzfkdiWngUTPRnw0u37Ezw8CQrNvEYXGeyp1FdPX7C9TuCWqpfdicEcQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=PULiK7P7; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42Q6RYBx027139; Tue, 26 Mar 2024 09:26:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=BMhFHhRNIcpJJMFIKlSsNwlVmtmxYOcIFrOt1gt3EN8=; b=PU LiK7P7VRDcvqzvajCbXEV3LDkUsYIZLrSb9CUvxaCXjPbjoi7Vr2DctaEnwTa6T9 yPKcXSMUQsTTyYGzTbaAvi7EW3vYc4nkQCdfzP3YCaLsPPWezWe4EK7TjaqzdKA2 mJDAOQGFNTnC3oYfzcIH162YmCAWX5D4EB1oY6AsUhwm/FU24gfkuBwo80g8MzWG hTsuNa1Xp8YVZLLy68j4GQevGkZqTR7rpb72ZSvh+jGbv/uCZvG4BLVyLi6jUR+4 Al56Lc5bHY/S49nRd4MNa4elbGhxUxlsSPh125KudWYkragim1ATD0RK8T69HdCH MicEQ0MohZnRUOBCEUFA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x3mems4yd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 09:26:15 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42Q9QEA3027920 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 09:26:14 GMT Received: from [10.239.105.140] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 26 Mar 2024 02:26:12 -0700 Message-ID: <8fbb904c-8d24-4d00-bff8-65f1e4bad5bb@quicinc.com> Date: Tue, 26 Mar 2024 17:26:09 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/3] virtio-spi: Add virtio SPI driver. To: Viresh Kumar , Harald Mommer CC: Mark Brown , , , , Matti Moell , Mikhail Golubev References: <20240304154342.44021-1-Harald.Mommer@opensynergy.com> <20240304154342.44021-4-Harald.Mommer@opensynergy.com> <99afc631-c02b-42da-a8d4-87c65087f390@quicinc.com> <5dedcd26-ed59-415f-b978-87a546a0816d@opensynergy.com> <20240320031253.eutoon7l7nkjehft@vireshk-i7> Content-Language: en-US From: Haixu Cui In-Reply-To: <20240320031253.eutoon7l7nkjehft@vireshk-i7> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: y5TuuR43vNRe00J5-t0FxUv0bZLb9JeG X-Proofpoint-ORIG-GUID: y5TuuR43vNRe00J5-t0FxUv0bZLb9JeG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-26_04,2024-03-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 suspectscore=0 clxscore=1011 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403260064 Hi all, On 3/20/2024 11:12 AM, Viresh Kumar wrote: > Hi Harald, > > On 19-03-24, 16:05, Harald Mommer wrote: >> On 18.03.24 10:39, Haixu Cui wrote: >>> On 3/4/2024 11:43 PM, Harald Mommer wrote: >>>> +static int virtio_spi_probe(struct virtio_device *vdev) >>>> +{ >>>> +    struct device_node *np = vdev->dev.parent->of_node; >>>> +    struct virtio_spi_priv *priv; >>>> +    struct spi_controller *ctrl; >>>> +    int err; >>>> +    u32 bus_num; >>>> +    u16 csi; >>>> + >>>> +    ctrl = devm_spi_alloc_host(&vdev->dev, sizeof(*priv)); >>>> +    if (!ctrl) >>>> +        return -ENOMEM; >>>> + >>>> +    priv = spi_controller_get_devdata(ctrl); >>>> +    priv->vdev = vdev; >>>> +    vdev->priv = priv; >>>> +    dev_set_drvdata(&vdev->dev, ctrl); >>> >>>     ctrl->dev.of_node is not set, so the child node cannot be parsed. I >>> would say, it's necessary to support the virtio spi device node in the >>> format: >> >> >> What you most probably want to have here is >> >>   ctrl->dev.of_node = np; > > Looking at how i2c-virtio does it, it should be tied to the device itself > instead of its parent: Yes, it is ctrl->dev.of_node = vdev->dev.of_node; > > ctrl->dev.of_node = vdev->dev.of_node; > >>>     virtio-spi@4b013000 { >>>         compatible = "virtio,mmio"; >>>         reg = <0x4b013000 0x1000>; >>>         interrupts = <0 497 4>; >>> >>>         spi { >>>             compatible = "virtio,device2d"; >>>             #address-cells = <1>; >>>             #size-cells = <0>; >>> >>>             spidev { >>>                 compatible = "xxx"; >>>                 reg = <0>; >>>                 spi-max-frequency = <100000>; >>>             }; >>>         }; >>>     }; > > Right, some work was done in the past to standardize these compatibles: > > $ git log -p --stat --reverse 0d8c9e7d4b40..694a1116b405 > Here I would like the inner layer "spidev", to match then probe the spidev driver, the "reg" is the chip select index. "spi-max-frequency" is not necessary, while It doesn't matter. You can also customize the inner layer to match your own driver. In my test, I set the cs max number as 1, and in device tree node inner layer, reg as 0. So certainly spidev driver probed and spidev0.0 is added successfully. But then the driver proceed to the following code, chip select index 0 device is created again, the driver fail with log: "chipselect 0 already in use". for (csi = 0; csi < ctrl->num_chipselect; csi++) { dev_dbg(&vdev->dev, "Setting up CS=%u\n", csi); board_info.chip_select = csi; if (!(priv->mode_func_supported & VIRTIO_SPI_CS_HIGH)) board_info.mode = SPI_MODE_0; else board_info.mode = SPI_MODE_0 | SPI_CS_HIGH; if (!spi_new_device(ctrl, &board_info)) { dev_err(&vdev->dev, "Cannot setup device %u\n", csi); spi_unregister_controller(ctrl); err = -ENODEV; goto err_return; } } I hope I made myself clear. Thank you, Harald and Kumar. Best regards.