[{"id":3677888,"web_url":"http://patchwork.ozlabs.org/comment/3677888/","msgid":"<44d27b03-0d16-4114-9565-ee01e8d6189e@huawei.com>","list_archive_url":null,"date":"2026-04-16T01:16:15","subject":"Re: [PATCH 4/4] vfio/pci: Add PCIe TPH SET_ST interface","submitter":{"id":92756,"url":"http://patchwork.ozlabs.org/api/people/92756/","name":"fengchengwen","email":"fengchengwen@huawei.com"},"content":"On 4/15/2026 10:01 PM, Wathsala Vithanage wrote:\n>>   +static int vfio_pci_tph_set_st(struct vfio_pci_core_device *vdev,\n>> +                   struct vfio_device_pci_tph_op *op,\n>> +                   void __user *uarg)\n>> +{\n>> +    struct vfio_pci_tph_entry *ents;\n>> +    struct vfio_pci_tph_st st;\n>> +    enum tph_mem_type mtype;\n>> +    int i, err, size;\n>> +    u16 st_val;\n>> +\n>> +    if (copy_from_user(&st, uarg, sizeof(st)))\n>> +        return -EFAULT;\n>> +\n>> +    if (!st.count || st.count > 2048)\n>> +        return -EINVAL;\n>> +\n>> +    size = st.count * sizeof(*ents);\n>> +    ents = kvmalloc(size, GFP_KERNEL);\n>> +    if (!ents)\n>> +        return -ENOMEM;\n>> +\n>> +    if (copy_from_user(ents, uarg + sizeof(st), size)) {\n>> +        err = -EFAULT;\n>> +        goto out;\n>> +    }\n>> +\n>> +    for (i = 0; i < st.count; i++) {\n>> +        if (ents[i].mem_type == VFIO_PCI_TPH_MEM_TYPE_VM) {\n>> +            mtype = TPH_MEM_TYPE_VM;\n>> +        } else if (ents[i].mem_type == VFIO_PCI_TPH_MEM_TYPE_PM) {\n>> +            mtype = TPH_MEM_TYPE_PM;\n>> +        } else {\n>> +            err = -EINVAL;\n>> +            goto out;\n>> +        }\n>> +\n>> +        err = pcie_tph_get_cpu_st(vdev->pdev, mtype, ents[i].cpu, &st_val);\n>> +        if (err)\n>> +            goto out;\n>> +        err = pcie_tph_set_st_entry(vdev->pdev, ents[i].index, st_val);\n>> +        if (err)\n>> +            goto out;\n>> +    }\n> \n> We also dropped batched updates of steering tags because there is no way a user could tell\n> which entry failed unless struct vfio_pci_tph_entry had an error field. But, we thought the\n> added complexity is not justified as these calls are only used during initialization.\n\nThank you for the feedback on batched steering tag updates.\n\nI agree that per-entry error reporting adds unnecessary\ncomplexity, especially for initialization-time operations.\n\nTo keep things simple and robust, the next version batch\nimplementation will use a straightforward failure model:\n  if programming any ST entry fails, the kernel will roll\n  back all previously programmed entries by clearing them\n  to 0, then return an error to userspace.\n\nThis avoids partial programming states, requires no per-entry\nerror fields, and fits well with one-shot device initialization.\n\nThanks\n\n> \n> --wathsala","headers":{"Return-Path":"\n <linux-pci+bounces-52568-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256\n header.s=dkim header.b=UQnetT4U;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52568-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com\n header.b=\"UQnetT4U\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=113.46.200.218","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=huawei.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=huawei.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fx0VF4B6Hz1yG9\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 11:17:09 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id CFA5730626E4\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 01:16:27 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id C9C441F5825;\n\tThu, 16 Apr 2026 01:16:26 +0000 (UTC)","from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com\n [113.46.200.218])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 92B9613B58C;\n\tThu, 16 Apr 2026 01:16:24 +0000 (UTC)","from mail.maildlp.com (unknown [172.19.162.140])\n\tby canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4fx0L24hRqzpSvH;\n\tThu, 16 Apr 2026 09:10:02 +0800 (CST)","from kwepemk500009.china.huawei.com (unknown [7.202.194.94])\n\tby mail.maildlp.com (Postfix) with ESMTPS id 4C6EC2012A;\n\tThu, 16 Apr 2026 09:16:16 +0800 (CST)","from [10.67.121.161] (10.67.121.161) by\n kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.1544.11; Thu, 16 Apr 2026 09:16:15 +0800"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776302186; cv=none;\n b=n4rf8XWg56fXzzsSX1+O2eSFxEojP2pFQfVbGPxP2vz6qnC3gZx9+aGziySHAX894sKee99ZZHHIeFbk+g6B6cQKMO3WVamX7Cz4lm4Ov1eSIT6UolseiyB4te8aKDoUjD7AzeOiGgM28nEv1j5zidOvFg0vSqOJIQHdXubLEzU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776302186; c=relaxed/simple;\n\tbh=S6lzco+aUY6xHjvjSvPcuUWmitVVuzM1k4I7ufSflBU=;\n\th=Message-ID:Date:MIME-Version:Subject:To:CC:References:From:\n\t In-Reply-To:Content-Type;\n b=Muy+k9RwpacA7jZVgRSK4gzrK1+zJ4m6AnCmTH0L1/52onOMkodDZVaMAmFgZwXFRhFeS+juC30jxIkZFGcK9WU97ptfkTkixRGf/1gvMk7T7FXu+ynATeDq4y5pZednzpZORQ9g78z2NL+ERiX79saMaQhwDvfIIvXWR6bjFrs=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=huawei.com;\n spf=pass smtp.mailfrom=huawei.com;\n dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com\n header.b=UQnetT4U; arc=none smtp.client-ip=113.46.200.218","dkim-signature":"v=1; a=rsa-sha256; d=huawei.com; s=dkim;\n\tc=relaxed/relaxed; q=dns/txt;\n\th=From;\n\tbh=MGT+QgMDGRLeV/oInIFWFUL4aCEDD9cQy1MPH8ZCZWk=;\n\tb=UQnetT4UB7zPkbAqQXCf9fjgedJh0Z5VEIwwsq3H74aHBhFxWVxnFfx9HjnwNPT4yNvpxOVvv\n\tMI6h/XL1v8DtdnRVftnqPrcmYy7h0x1/BX7L0C/UChf085SwUo5sJR/r2VCfjYy0iItiw8HR5C1\n\tc20BEC9j41ampPq0pGzNEb8=","Message-ID":"<44d27b03-0d16-4114-9565-ee01e8d6189e@huawei.com>","Date":"Thu, 16 Apr 2026 09:16:15 +0800","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 4/4] vfio/pci: Add PCIe TPH SET_ST interface","To":"Wathsala Vithanage <wathsala.vithanage@arm.com>, <alex@shazbot.org>,\n\t<jgg@ziepe.ca>","CC":"<kvm@vger.kernel.org>, <linux-pci@vger.kernel.org>","References":"<20260415090959.53672-1-fengchengwen@huawei.com>\n <20260415090959.53672-5-fengchengwen@huawei.com>\n <e6dbfdd5-5117-4c3e-bb84-ee1e489aa38f@arm.com>","Content-Language":"en-US","From":"fengchengwen <fengchengwen@huawei.com>","In-Reply-To":"<e6dbfdd5-5117-4c3e-bb84-ee1e489aa38f@arm.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"8bit","X-ClientProxiedBy":"kwepems200001.china.huawei.com (7.221.188.67) To\n kwepemk500009.china.huawei.com (7.202.194.94)"}}]